:root {
  --marigold: #f5b92f;
  --ink: #181a2e;
  --ink-soft: #3d3a27;
  --ticket: #fffefa;
  --cobalt: #2236c9;
  --brick: #c0361f;
  --teal: #12718b;
  --plum: #762a63;
  --rule: #d9d3c0;

  --display: Rockwell, "Rockwell Nova", "Roboto Slab", "Bitter", "Courier New", serif;
  --text: "Gill Sans", "Gill Sans MT", Candara, "Trebuchet MS", "Segoe UI", sans-serif;

  --notch: 11px;
  --radius: 16px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--marigold);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.0625rem;
  line-height: 1.5;
}

img { display: block; max-width: 100%; }

h1, h2, p { margin: 0; }

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

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

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 50;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
}
.skip:focus { top: 12px; }

/* ---------- Layout ---------- */

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 22px 16px 56px;
}

.intro { min-width: 0; }

.board { min-width: 0; outline: none; }

@media (min-width: 960px) {
  .shell {
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 56px;
    padding: 36px 48px 72px;
    align-items: start;
  }
}

@media (min-width: 960px) and (min-height: 940px) {
  .intro {
    position: sticky;
    top: 36px;
  }
}

/* ---------- Intro ---------- */

.wordmark {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
  line-height: 1;
  margin-bottom: 18px;
}

h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.1rem, 3.1vw, 2.9rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.lede {
  margin-top: 14px;
  max-width: 34ch;
  color: var(--ink-soft);
}

.studio {
  display: none;
  margin: 26px 0 0;
}

@media (min-width: 960px) {
  .studio { display: block; }
}

.studio img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
}

/* ---------- Controls ---------- */

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
}

.field { display: grid; gap: 4px; min-width: 0; }
.field:first-child { grid-column: 1 / -1; }

.field label {
  font-weight: 700;
  font-size: 0.9375rem;
}

input[type="search"], select {
  width: 100%;
  min-height: 48px;
  padding: 8px 14px;
  background: var(--ticket);
  border: 2px solid var(--ink);
  border-radius: 12px;
}

input[type="search"]::placeholder { color: #6b6755; opacity: 1; }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.saved-toggle {
  grid-column: 2;
  align-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 12px;
  background: transparent;
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  line-height: 1.15;
}

.saved-toggle svg { flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.saved-toggle span:nth-of-type(1) { flex: 1; }

.saved-count {
  min-width: 26px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--ink);
  color: #fff;
  font-size: 0.875rem;
  text-align: center;
}

.saved-toggle:hover { background: rgba(255, 255, 255, 0.35); }

.saved-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}
.saved-toggle[aria-pressed="true"] svg { fill: var(--marigold); stroke: var(--marigold); }
.saved-toggle[aria-pressed="true"] .saved-count { background: var(--marigold); color: var(--ink); }

@media (min-width: 960px) {
  .controls { grid-template-columns: 1fr; }
  .saved-toggle { grid-column: 1; }
}

/* ---------- Status ---------- */

.status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 20px;
  margin-bottom: 14px;
  font-weight: 700;
}

.shortlist-note { font-weight: 400; color: var(--ink-soft); }
.shortlist-note strong { color: var(--ink); }

/* ---------- Tickets ---------- */

.tickets {
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ticket {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "photo"
    "date"
    "main";
  background: var(--ticket);
  border-radius: var(--radius);
  overflow: hidden;
  --accent: var(--ink);
}

.ticket[hidden],
.tickets[hidden] { display: none; }

.ticket[data-cat="Baking"]    { --accent: var(--brick); }
.ticket[data-cat="Ceramics"]  { --accent: var(--teal); }
.ticket[data-cat="Floristry"] { --accent: var(--cobalt); }
.ticket[data-cat="Painting"]  { --accent: var(--plum); }

.t-date {
  grid-area: date;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  font-family: var(--display);
  line-height: 1;
}
.t-date .d { font-size: 2rem; font-weight: 800; }
.t-date .m, .t-date .w { font-size: 1rem; font-weight: 700; }

.t-photo {
  grid-area: photo;
  position: relative;
  height: 168px;
}
.t-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.t-price {
  position: absolute;
  left: 14px; bottom: 14px;
  padding: 4px 12px 5px;
  background: var(--marigold);
  color: var(--ink);
  border-radius: 8px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1.1;
}

.t-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px 18px;
  min-width: 0;
}

.t-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 26px;
}

.t-cat {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9375rem;
}

.t-saved {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px 2px 8px;
  background: var(--ink);
  color: #fff;
  border-radius: 99px;
  font-size: 0.875rem;
  font-weight: 700;
  transform: rotate(-3deg);
}
.t-saved[hidden] { display: none; }
.t-saved svg { fill: var(--marigold); stroke: var(--marigold); stroke-width: 2; stroke-linejoin: round; }

.t-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.t-desc {
  max-width: 58ch;
  color: #35364a;
}

.t-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 6px;
}

.t-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 18px;
  font-weight: 700;
  font-size: 0.9375rem;
}

.t-open {
  padding: 7px 16px;
  background: var(--ink);
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 99px;
  font-weight: 700;
  cursor: pointer;
}
.t-open:hover { background: var(--cobalt); border-color: var(--cobalt); }

/* the whole ticket is the click target */
.t-open::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
}
.t-open:focus-visible { outline: none; }
.t-open:focus-visible::after {
  outline: 4px solid var(--ink);
  outline-offset: -4px;
  border-radius: var(--radius);
}

@media (min-width: 640px) {
  .ticket {
    grid-template-columns: 112px minmax(0, 1fr) 210px;
    grid-template-areas: "date main photo";
    min-height: 208px;
  }

  .t-date {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 8px;
    text-align: center;
  }
  .t-date .m { font-size: 1.125rem; }
  .t-date .d { font-size: 3.5rem; line-height: 0.9; }
  .t-date .w { font-size: 1.125rem; }

  .t-photo { height: auto; }
  .t-photo img { position: absolute; inset: 0; }

  .t-main { padding: 20px 24px 20px 28px; }

  /* perforation and punched notches between the three parts */
  .t-main,
  .t-photo { border-left: 2px dashed var(--rule); }
  .t-date { position: relative; }
  .t-date::before,
  .t-date::after,
  .t-photo::before,
  .t-photo::after {
    content: "";
    position: absolute;
    z-index: 3;
    width: calc(var(--notch) * 2);
    height: calc(var(--notch) * 2);
    border-radius: 50%;
    background: var(--marigold);
  }
  .t-date::before { right: calc(var(--notch) * -1 - 1px); top: calc(var(--notch) * -1); }
  .t-date::after  { right: calc(var(--notch) * -1 - 1px); bottom: calc(var(--notch) * -1); }
  .t-photo::before { left: calc(var(--notch) * -1 - 1px); top: calc(var(--notch) * -1); }
  .t-photo::after  { left: calc(var(--notch) * -1 - 1px); bottom: calc(var(--notch) * -1); }
}

@media (min-width: 640px) and (max-width: 959px) {
  .ticket { grid-template-columns: 100px minmax(0, 1fr) 180px; }
}

/* ---------- Empty state ---------- */

.empty {
  padding: 36px 28px;
  background: var(--ticket);
  border-radius: var(--radius);
  max-width: 560px;
}
.empty[hidden] { display: none; }
.empty h2 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1.1;
}
.empty p { margin: 8px 0 20px; color: #35364a; max-width: 44ch; }

.btn {
  padding: 10px 20px;
  background: var(--ink);
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 99px;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { background: var(--cobalt); border-color: var(--cobalt); }

/* ---------- Detail dialog ---------- */

body.is-locked { overflow: hidden; }

.detail {
  width: min(960px, calc(100vw - 48px));
  max-width: none;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--ticket);
  color: var(--ink);
  overflow: auto;
  --accent: var(--ink);
}
.detail[data-cat="Baking"]    { --accent: var(--brick); }
.detail[data-cat="Ceramics"]  { --accent: var(--teal); }
.detail[data-cat="Floristry"] { --accent: var(--cobalt); }
.detail[data-cat="Painting"]  { --accent: var(--plum); }

.detail::backdrop { background: rgba(24, 26, 46, 0.72); }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.d-photo {
  position: relative;
  height: 220px;
}
.d-photo img { width: 100%; height: 100%; object-fit: cover; }

.d-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 20px 24px;
}

.d-close {
  position: sticky;
  top: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: 12px 12px -60px auto;
  min-height: 48px;
  padding: 8px 16px 8px 14px;
  background: var(--ticket);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 99px;
  font-weight: 700;
  cursor: pointer;
}
.d-close:hover { background: var(--marigold); }
.d-close svg { stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; fill: none; }

.d-cat { color: var(--accent); font-weight: 700; }

.d-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
}

.d-body {
  max-width: 52ch;
  font-size: 1.1875rem;
  line-height: 1.55;
}

.d-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 4px 0 0;
  border-top: 2px solid var(--ink);
}
.d-facts div {
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--rule);
}
.d-facts div.wide { grid-column: 1 / -1; }
.d-facts dt { font-size: 0.9375rem; color: #55536a; }
.d-facts dd { margin: 0; font-weight: 700; }
.d-facts .price { font-family: var(--display); font-size: 1.5rem; line-height: 1.2; }

.d-actions { margin-top: 6px; display: grid; gap: 8px; }

.save-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 22px;
  background: var(--cobalt);
  color: #fff;
  border: 2px solid var(--cobalt);
  border-radius: 99px;
  font-weight: 700;
  font-size: 1.0625rem;
  cursor: pointer;
}
.save-btn svg { flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.save-btn:hover { background: #1a2aa3; border-color: #1a2aa3; }
.save-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); }
.save-btn[aria-pressed="true"] svg { fill: var(--marigold); stroke: var(--marigold); }

.d-hint { font-size: 0.9375rem; color: #55536a; }

@media (max-width: 639px) {
  .detail {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border-radius: 0;
  }
}

@media (min-width: 760px) {
  .detail-grid { grid-template-columns: 5fr 6fr; min-height: 520px; }
  .d-photo { height: auto; min-height: 360px; }
  .d-photo img { position: absolute; inset: 0; }
  .d-content { padding: 64px 36px 32px 36px; }
  .d-actions { grid-template-columns: auto; justify-items: start; }
}

@media (prefers-reduced-motion: no-preference) {
  .detail[open] { animation: lift 220ms cubic-bezier(.2, .7, .2, 1); }
  .detail[open]::backdrop { animation: fade 220ms ease-out; }
  .t-open, .btn, .save-btn, .saved-toggle { transition: background-color 120ms, border-color 120ms; }
  @keyframes lift { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
}
