@font-face {
  font-family: "Oswald";
  src: url("assets/oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-display: swap;
}
@font-face {
  font-family: "Work Sans";
  src: url("assets/work-sans.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ink: #15153a;
  --desk: #17173f;
  --desk-2: #24245c;
  --text: #f2efff;
  --muted: #bcb9e8;
  --hi: #ffd43b;
  --red: #c4211a;
  --stock: #f2efff;

  --art: #ff8fc0;
  --film: #8cc8ff;
  --food: #ffd43b;
  --literature: #c4b0ff;
  --music: #ff8a4c;
  --outdoors: #86e39b;
  --walks: #4fe0d0;

  --display: "Oswald", "Arial Narrow", Impact, sans-serif;
  --body: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --stub-w: 100px;
  --bar-h: 30px;
}

[data-cat="Art"] { --stock: var(--art); }
[data-cat="Film"] { --stock: var(--film); }
[data-cat="Food"] { --stock: var(--food); }
[data-cat="Literature"] { --stock: var(--literature); }
[data-cat="Music"] { --stock: var(--music); }
[data-cat="Outdoors"] { --stock: var(--outdoors); }
[data-cat="Walks"] { --stock: var(--walks); }

*, *::before, *::after { box-sizing: border-box; }

html { scroll-padding-top: 40px; }

body {
  margin: 0;
  background: var(--desk);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }

h1, h2, h3, p, dl, dd, ol { margin: 0; padding: 0; }
ol { list-style: none; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 3px solid var(--hi); outline-offset: 3px; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- the perforation that scissors cut as you scroll ---------- */

.cutline {
  --p: 0;
  position: fixed; top: 0; left: 0; right: 0; height: 30px; z-index: 5;
  display: flex; align-items: center;
  background: var(--desk);
  pointer-events: none;
}
.cut-gone {
  flex: 0 0 calc(var(--p) * (100% - 34px));
  height: 0; border-top: 2px solid rgba(242, 239, 255, 0.14);
}
.cut-scissors {
  flex: 0 0 34px; display: grid; place-items: center; color: var(--hi);
}
.cut-scissors svg { width: 24px; height: 24px; display: block; }
.cut-left {
  flex: 1; height: 0; border-top: 2px dashed var(--text);
}

/* ---------- shell ---------- */

.shell {
  padding: 46px 16px 40px;
  max-width: 1400px;
  margin: 0 auto;
}

.brand { margin-bottom: 22px; }

.wordmark {
  position: relative;
  display: inline-block;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(64px, 19vw, 92px);
  line-height: 1;
  letter-spacing: -0.01em;
  padding: 0 12px 12px 0;
}
.tear-top, .tear-bot { display: block; white-space: nowrap; }
.tear-top {
  color: var(--hi);
  clip-path: polygon(0 0, 100% 0, 100% 46%, 87.5% 56%, 75% 46%, 62.5% 56%, 50% 46%, 37.5% 56%, 25% 46%, 12.5% 56%, 0 46%);
}
.tear-bot {
  position: absolute; left: 0; top: 0;
  color: var(--art);
  transform: translate(7px, 8px) rotate(1.4deg);
  transform-origin: 0 100%;
  clip-path: polygon(0 46%, 12.5% 56%, 25% 46%, 37.5% 56%, 50% 46%, 62.5% 56%, 75% 46%, 87.5% 56%, 100% 46%, 100% 100%, 0 100%);
}

.lede {
  max-width: 34ch;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
  margin-top: 10px;
}

/* ---------- controls ---------- */

.controls { display: grid; gap: 14px; margin-bottom: 26px; }

.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 15px; }

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 8px 14px;
  background: var(--text);
  color: var(--ink);
  border: 2px solid var(--text);
  border-radius: 6px;
}
.field select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 22px) 52%, calc(100% - 16px) 52%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}
.field input::placeholder { color: #6b6a96; }

.toggles { display: flex; flex-wrap: wrap; gap: 10px; }

.toggle {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 6px 14px 6px 10px;
  background: transparent;
  border: 2px dashed rgba(242, 239, 255, 0.55);
  border-radius: 6px;
  font-weight: 600; font-size: 15px;
  text-align: left;
}
.toggle-box {
  flex: none; width: 22px; height: 22px;
  border: 2px solid var(--text); border-radius: 4px;
  display: grid; place-items: center;
}
.toggle[aria-pressed="true"] {
  background: var(--hi); color: var(--ink);
  border-style: solid; border-color: var(--hi);
}
.toggle[aria-pressed="true"] .toggle-box { border-color: var(--ink); background: var(--ink); }
.toggle[aria-pressed="true"] .toggle-box::after {
  content: ""; width: 10px; height: 5px;
  border-left: 3px solid var(--hi); border-bottom: 3px solid var(--hi);
  transform: translateY(-1px) rotate(-45deg);
}
.pocket-count {
  display: inline-block; min-width: 1.6em; margin-left: 4px; padding: 0 6px;
  text-align: center; border-radius: 99px;
  background: var(--text); color: var(--ink); font-weight: 700; font-size: 14px;
}
.toggle[aria-pressed="true"] .pocket-count { background: var(--ink); color: var(--hi); }

/* ---------- the pocket ruler ---------- */

.pocket {
  border: 2px dashed rgba(242, 239, 255, 0.4);
  border-radius: 8px;
  padding: 16px 16px 14px;
  margin-bottom: 8px;
}
.pocket h2 {
  font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1.1;
  margin-bottom: 10px;
}
.lane { margin-bottom: 8px; }
.lane-name { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.track {
  position: relative;
  background:
    repeating-linear-gradient(to right, rgba(242, 239, 255, 0.16) 0 1px, transparent 1px calc(100% / 7)),
    var(--desk-2);
  border-radius: 4px;
}
.bar {
  position: absolute;
  height: var(--bar-h);
  min-width: 14px;
  padding: 0 7px;
  display: flex; align-items: center;
  background-color: var(--stock);
  color: var(--ink);
  border: 0; border-radius: 4px;
  font-size: 12.5px; font-weight: 600; line-height: 1;
  text-align: left;
  overflow: hidden;
}
.bar span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar.is-clash {
  background-image: repeating-linear-gradient(135deg, rgba(21, 21, 58, 0.3) 0 4px, transparent 4px 9px);
  box-shadow: 0 0 0 2px #ff5a4d inset;
}
.axis { position: relative; height: 20px; margin-top: 2px; font-size: 12px; color: var(--muted); }
.axis span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.axis span:first-child { transform: none; }
.axis span:last-child { transform: translateX(-100%); }
.pocket-note { font-size: 15px; line-height: 1.45; color: var(--muted); margin-top: 6px; max-width: 46ch; }
.pocket-note.has-clash { color: #ffb3ab; }

/* ---------- the roll ---------- */

.tally { color: var(--muted); font-size: 15px; margin: 22px 0 6px; }

.day { margin-bottom: 30px; }
.day-head {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--display); font-weight: 700; font-size: clamp(30px, 8vw, 42px);
  line-height: 1.1; margin: 14px 0 14px;
}
.day-head::after { content: ""; flex: 1; border-top: 3px dashed rgba(242, 239, 255, 0.4); }

.tickets { display: grid; gap: 14px; }

.ticket {
  position: relative;
  display: grid;
  grid-template-columns: var(--stub-w) 1fr;
  column-gap: 0;
  transition: column-gap 0.35s cubic-bezier(0.3, 1.4, 0.5, 1);
  color: var(--ink);
}
.ticket:has(.open:focus-visible) { outline: 3px solid var(--hi); outline-offset: 4px; border-radius: 10px; }

.stub, .stock {
  background-color: var(--stock);
}
.stub {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px 6px;
  text-align: center;
  border-radius: 10px 0 0 10px;
  background-image: linear-gradient(rgba(21, 21, 58, 0.07), rgba(21, 21, 58, 0.07));
  -webkit-mask:
    radial-gradient(circle 9px at 100% 0, #0000 8.5px, #000 9px) top / 100% 51% no-repeat,
    radial-gradient(circle 9px at 100% 100%, #0000 8.5px, #000 9px) bottom / 100% 51% no-repeat;
  mask:
    radial-gradient(circle 9px at 100% 0, #0000 8.5px, #000 9px) top / 100% 51% no-repeat,
    radial-gradient(circle 9px at 100% 100%, #0000 8.5px, #000 9px) bottom / 100% 51% no-repeat;
  transition: transform 0.35s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.stub-time {
  font-family: var(--display); font-weight: 700; font-size: 36px; line-height: 1; letter-spacing: -0.01em;
}
.stub-time small { display: block; font-size: 16px; font-weight: 500; line-height: 1.2; }
.stub-until { font-size: 12.5px; font-weight: 600; line-height: 1.25; margin-top: 8px; }

.stock {
  padding: 14px 16px 14px 20px;
  border-radius: 0 10px 10px 0;
  background-image: repeating-linear-gradient(to bottom, rgba(21, 21, 58, 0.5) 0 6px, transparent 6px 12px);
  background-repeat: no-repeat;
  background-size: 2px calc(100% - 34px);
  background-position: 0 50%;
  -webkit-mask:
    radial-gradient(circle 9px at 0 0, #0000 8.5px, #000 9px) top / 100% 51% no-repeat,
    radial-gradient(circle 9px at 0 100%, #0000 8.5px, #000 9px) bottom / 100% 51% no-repeat;
  mask:
    radial-gradient(circle 9px at 0 0, #0000 8.5px, #000 9px) top / 100% 51% no-repeat,
    radial-gradient(circle 9px at 0 100%, #0000 8.5px, #000 9px) bottom / 100% 51% no-repeat;
  min-width: 0;
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kind {
  display: inline-block; padding: 0 9px;
  border: 1.5px solid var(--ink); border-radius: 99px;
  font-size: 13px; font-weight: 600; line-height: 1.5;
}
.price { font-family: var(--display); font-weight: 600; font-size: 22px; line-height: 1; }
.t { margin: 8px 0 6px; font-family: var(--display); font-weight: 600; font-size: 24px; line-height: 1.12; }
.open {
  display: block; width: 100%; padding: 0; border: 0; background: none;
  text-align: left; font: inherit; color: inherit;
}
.open::after { content: ""; position: absolute; inset: 0; border-radius: 10px; z-index: 1; }
.open:focus-visible { outline: none; }
.where, .fmt { font-size: 15px; line-height: 1.4; }
.fmt { font-weight: 600; }
.stamp {
  position: absolute; right: 14px; bottom: 12px; z-index: 2;
  padding: 1px 10px;
  border: 3px solid var(--red); border-radius: 6px;
  color: var(--red);
  font-family: var(--display); font-weight: 700; font-size: 18px; line-height: 1.2;
  transform: rotate(-7deg) scale(1.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.ticket.is-kept { column-gap: 12px; }
.ticket.is-kept .stub { transform: translate(-4px, 3px) rotate(-3deg); }
.ticket.is-kept .stamp { opacity: 0.92; transform: rotate(-7deg) scale(1); }
.ticket:hover .stub { transform: translate(-2px, 1px) rotate(-1.2deg); }
.ticket.is-kept:hover .stub { transform: translate(-6px, 4px) rotate(-4deg); }

.empty {
  border: 3px dashed rgba(242, 239, 255, 0.5);
  border-radius: 10px;
  padding: 28px 22px;
  margin-top: 18px;
  max-width: 560px;
}
.empty-title { font-family: var(--display); font-weight: 700; font-size: 34px; line-height: 1.1; margin-bottom: 8px; }
.empty p + p { color: var(--muted); margin-bottom: 18px; max-width: 42ch; }

.btn {
  min-height: 48px; padding: 8px 20px;
  background: var(--hi); color: var(--ink);
  border: 0; border-radius: 6px;
  font-weight: 700; font-size: 16px;
}
.load-error { margin-top: 20px; color: #ffb3ab; }
.foot { margin-top: 36px; color: var(--muted); font-size: 14px; max-width: 52ch; }

/* ---------- the open ticket ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(9, 9, 30, 0.74);
}
.detail {
  position: fixed; z-index: 21;
  left: 0; right: 0; bottom: 0; top: 14px;
  display: flex; flex-direction: column;
  background-color: var(--stock);
  color: var(--ink);
  -webkit-mask: radial-gradient(circle 9px at 12px 0, #0000 8.5px, #000 9px) 0 0 / 24px 100% repeat-x;
  mask: radial-gradient(circle 9px at 12px 0, #0000 8.5px, #000 9px) 0 0 / 24px 100% repeat-x;
  animation: unfold 0.28s ease-out;
}
.detail :focus-visible { outline-color: var(--ink); }
@keyframes unfold { from { transform: translateY(30px); opacity: 0; } }

.d-scroll { flex: 1; overflow-y: auto; padding: 26px 20px 20px; }
.d-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.close {
  min-height: 44px; padding: 6px 16px;
  background: transparent; border: 2px solid var(--ink); border-radius: 99px;
  font-weight: 700; font-size: 15px;
}
.close:hover { background: var(--ink); color: var(--stock); }
.d-title {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(36px, 10vw, 50px); line-height: 1.02;
  margin: 18px 0 14px;
}
.d-when {
  display: grid; gap: 2px;
  padding: 12px 0; margin-bottom: 18px;
  border-top: 3px dashed rgba(21, 21, 58, 0.5);
  border-bottom: 3px dashed rgba(21, 21, 58, 0.5);
}
.d-day { font-weight: 600; font-size: 17px; }
.d-time { font-family: var(--display); font-weight: 600; font-size: 34px; line-height: 1.1; }
.d-body { white-space: pre-line; font-size: 17px; line-height: 1.6; max-width: 50ch; }
.d-facts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px;
  margin-top: 26px; padding-top: 18px;
  border-top: 3px dashed rgba(21, 21, 58, 0.5);
}
.d-facts dt { font-size: 14px; font-weight: 600; opacity: 0.8; }
.d-facts dd { font-family: var(--display); font-weight: 500; font-size: 22px; line-height: 1.15; }

.d-foot {
  padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
  border-top: 3px dashed rgba(21, 21, 58, 0.5);
}
.d-clash { font-size: 15px; font-weight: 600; color: var(--red); margin-bottom: 8px; }
.d-clash:empty { display: none; }
.save {
  width: 100%; min-height: 56px; padding: 8px 20px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--ink); color: #fff;
  border: 3px solid var(--ink); border-radius: 8px;
  font-family: var(--display); font-weight: 600; font-size: 22px;
}
.save svg { width: 24px; height: 24px; }
.save.is-on { background: #fff; color: var(--ink); }
.save.pop { animation: pop 0.4s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { 0% { transform: scale(0.94) rotate(-1.5deg); } 100% { transform: none; } }

/* ---------- wider screens ---------- */

@media (min-width: 600px) {
  :root { --stub-w: 124px; }
  .stub-time { font-size: 44px; }
  .t { font-size: 28px; }
  .shell { padding-left: 32px; padding-right: 32px; }
}

@media (min-width: 900px) {
  :root { --bar-h: 32px; }
  .shell {
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    column-gap: 56px;
    align-items: start;
    padding: 30px 48px 40px;
  }
  .side {
    position: sticky; top: 30px;
    max-height: calc(100vh - 30px);
    overflow-y: auto;
    padding: 24px 6px 24px 0;
    scrollbar-width: thin;
  }
  .roll { padding-top: 24px; max-width: 820px; }
  .tally { margin-top: 0; }
  .wordmark { font-size: 88px; }

  .detail {
    left: auto; top: 0; width: min(580px, 100%);
    -webkit-mask: radial-gradient(circle 9px at 0 12px, #0000 8.5px, #000 9px) 0 0 / 100% 24px repeat-y;
    mask: radial-gradient(circle 9px at 0 12px, #0000 8.5px, #000 9px) 0 0 / 100% 24px repeat-y;
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
    animation-name: unfold-side;
  }
  .d-scroll { padding: 34px 40px 24px 44px; }
  .d-foot { padding: 16px 40px 22px 44px; }
}
@keyframes unfold-side { from { transform: translateX(40px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
