/* Forma — a printed workshop programme.
   Signature: the perforated ticket stub carrying the date, coloured by craft. */

:root {
  --canvas: #f3ede2;
  --surface: #fbf8f2;
  --ink: #1c1814;
  --muted: #5b5348;
  --line: #1c1814;
  --soft-line: #d6cdbd;
  --accent: #c8361a;
  --on-accent: #ffffff;
  --focus: #1a47d6;

  --c-ceramics: #2f5f82;
  --c-painting: #a82a68;
  --c-floristry: #f0a81a;
  --c-baking: #6b4a2b;
  --on-c-ceramics: #fff;
  --on-c-painting: #fff;
  --on-c-floristry: #1c1814;
  --on-c-baking: #fff;

  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --gutter: clamp(20px, 4vw, 56px);
  --max: 1360px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
body.is-locked { overflow: hidden; }
img { display: block; max-width: 100%; }
h1, h2, h3, p, dl, dd, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

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

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: var(--canvas); padding: 10px 16px; text-decoration: none;
}
.skip:focus { top: 12px; }

.label {
  font: 500 0.78rem/1.3 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Masthead ---------- */
.masthead {
  display: flex; align-items: center; gap: 24px;
  max-width: var(--max); margin: 0 auto;
  padding: 18px var(--gutter);
}
.wordmark {
  display: inline-flex; align-items: center; gap: 10px;
  font: 600 1.75rem/1 var(--display); letter-spacing: -0.02em;
  color: var(--ink); text-decoration: none;
}
.wordmark__glyph {
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(var(--c-ceramics) 0 25%, var(--c-painting) 0 50%, var(--c-floristry) 0 75%, var(--c-baking) 0);
}
.masthead__tag { margin-left: auto; font: 500 0.78rem/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.shortlist-link {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  background: transparent; border: 1.5px solid var(--ink); border-radius: 999px;
  font-weight: 600; font-size: 0.95rem;
}
.shortlist-link:hover { background: var(--ink); color: var(--canvas); }
.shortlist-link__n {
  min-width: 24px; height: 24px; padding: 0 6px; display: inline-grid; place-items: center;
  background: var(--accent); color: var(--on-accent); border-radius: 999px;
  font: 600 0.8rem/1 var(--mono);
}

/* ---------- Hero ---------- */
.hero {
  max-width: var(--max); margin: 0 auto;
  padding: clamp(20px, 3vw, 40px) var(--gutter) clamp(48px, 6vw, 88px);
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(28px, 4vw, 64px); align-items: end;
}
.hero__copy { display: grid; gap: 22px; align-content: end; padding-bottom: 8px; }
.hero h1 {
  font: 500 clamp(3rem, 6.2vw, 6.25rem)/0.95 var(--display);
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero__lede { font-size: 1.125rem; max-width: 42ch; color: var(--muted); }
.hero__facts { display: flex; gap: 0; border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); }
.hero__facts > div { flex: 1; padding: 12px 0 12px 14px; border-left: 1px dashed var(--ink); }
.hero__facts > div:first-child { border-left: 0; padding-left: 0; }
.hero__facts dt { font: 500 0.72rem/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.hero__facts dd { font: 500 1.6rem/1.15 var(--display); }

.hero__tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: end; }
.tile {
  position: relative; display: block; width: 100%; padding: 0; border: 0; text-align: left;
  background: var(--ink); color: #fff; overflow: hidden;
  height: clamp(380px, 38vw, 540px);
  border-radius: 50% 50% 0 0 / 120px 120px 0 0;
}
.tile:nth-child(2) { height: clamp(330px, 33vw, 470px); }
.tile:nth-child(3) { height: clamp(360px, 36vw, 510px); }
.tile:nth-child(4) { height: clamp(310px, 31vw, 440px); }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s ease; }
.tile__cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 14px 14px;
  display: grid; gap: 2px;
  background: var(--tile-bg); color: var(--tile-fg);
}
.tile__cap strong { font: 500 1.35rem/1.1 var(--display); }
.tile__cap span { font: 500 0.72rem/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; }
.tile:hover img { transform: scale(1.05); }
.tile:focus-visible { outline-offset: 4px; }

[data-cat="Ceramics"] { --tile-bg: var(--c-ceramics); --tile-fg: var(--on-c-ceramics); }
[data-cat="Painting"] { --tile-bg: var(--c-painting); --tile-fg: var(--on-c-painting); }
[data-cat="Floristry"] { --tile-bg: var(--c-floristry); --tile-fg: var(--on-c-floristry); }
[data-cat="Baking"] { --tile-bg: var(--c-baking); --tile-fg: var(--on-c-baking); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 22px; text-decoration: none;
  border: 1.5px solid var(--ink); border-radius: 999px;
  font-weight: 600; font-size: 0.98rem; background: transparent; color: var(--ink);
  justify-self: start;
}
.btn--solid { background: var(--ink); color: var(--canvas); }
.btn--solid:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--ghost:hover { background: var(--ink); color: var(--canvas); }

/* ---------- Programme ---------- */
.programme { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter) clamp(56px, 7vw, 104px); }
.programme__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  padding-top: 20px; border-top: 3px solid var(--ink); margin-bottom: 24px;
}
.programme h2 { font: 500 clamp(2.2rem, 4vw, 3.5rem)/1 var(--display); letter-spacing: -0.025em; }
.programme h2:focus { outline: none; }
.programme h2:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.programme__sub { color: var(--muted); }

.toolbar {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 16px; align-items: end;
  padding: 16px 0 20px; border-bottom: 1px solid var(--soft-line);
}
.field { display: grid; gap: 6px; }
.field label { font: 500 0.78rem/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.field input, .field select {
  width: 100%; min-height: 48px; padding: 0 14px;
  background: var(--surface); border: 1.5px solid var(--ink); border-radius: 0;
  appearance: none; -webkit-appearance: none;
}
.field select {
  padding-right: 40px;
  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; background-repeat: no-repeat;
}
.field input::placeholder { color: #7a7164; }
.field input:focus-visible, .field select:focus-visible { outline-offset: 2px; }

.toggle {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 18px;
  background: var(--surface); border: 1.5px solid var(--ink); border-radius: 999px; font-weight: 600;
}
.toggle__n { display: inline-block; margin-left: 4px; font: 600 0.82rem/1 var(--mono); }
.toggle:hover { background: #fff; }
.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.results-bar { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 0 20px; color: var(--muted); font-size: 0.95rem; }
.results-bar__saved { color: var(--ink); font-weight: 600; }

/* ---------- Ticket rows ---------- */
.list { display: grid; gap: 18px; }
.ticket {
  position: relative;
  display: grid;
  grid-template-columns: 132px 250px minmax(0, 1fr) 190px;
  grid-template-areas: "stub image main aside";
  background: var(--surface);
  border: 1.5px solid var(--ink);
  cursor: pointer;
}
.ticket.is-saved { box-shadow: 6px 6px 0 var(--accent); }

.ticket__stub {
  grid-area: stub; position: relative;
  background: var(--tile-bg); color: var(--tile-fg);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px;
  padding: 18px 8px; text-align: center;
}
/* perforation + notches */
.ticket__stub::after {
  content: ""; position: absolute; top: 12px; bottom: 12px; right: -1px;
  border-right: 3px dotted var(--surface); opacity: 0.9;
}
.ticket__notch {
  position: absolute; right: -11px; width: 20px; height: 20px; z-index: 2;
  background: var(--canvas); border: 1.5px solid var(--ink); border-radius: 50%;
}
.ticket__notch--top { top: -11px; clip-path: inset(50% 0 0 0); }
.ticket__notch--bot { bottom: -11px; clip-path: inset(0 0 50% 0); }
.ticket__day { font: 500 4rem/0.9 var(--display); letter-spacing: -0.03em; }
.ticket__mon { font: 600 0.82rem/1.2 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; }
.ticket__dow { font: 500 0.72rem/1.2 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.92; }

.ticket__img { grid-area: image; position: relative; overflow: hidden; min-height: 190px; background: var(--soft-line); }
.ticket__img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.ticket__main { grid-area: main; padding: 22px 24px; display: grid; gap: 8px; align-content: center; min-width: 0; }
.chip {
  justify-self: start; padding: 3px 9px;
  background: var(--tile-bg); color: var(--tile-fg);
  font: 600 0.72rem/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
}
.ticket__title { font: 500 clamp(1.7rem, 2.4vw, 2.2rem)/1.05 var(--display); letter-spacing: -0.02em; }
.ticket__desc { color: var(--muted); max-width: 52ch; font-size: 1rem; }
.ticket__meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font: 500 0.85rem/1.4 var(--mono); color: var(--ink); }
.ticket__meta span::before { content: "·"; margin-right: 16px; color: var(--muted); }
.ticket__meta span:first-child::before { content: none; margin: 0; }

.ticket__aside {
  grid-area: aside; padding: 22px 22px 22px 20px;
  border-left: 1.5px dashed var(--ink);
  display: grid; gap: 10px; align-content: center; justify-items: stretch;
}
.ticket__price { font: 500 2.4rem/1 var(--display); letter-spacing: -0.02em; }
.ticket__seats { font: 500 0.8rem/1.3 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-top: -4px; }
.ticket__actions { display: grid; gap: 8px; margin-top: 4px; }
.ticket .btn { min-height: 44px; padding: 0 16px; justify-self: stretch; }
.quick-save {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 14px; background: transparent;
  border: 1.5px solid var(--ink); border-radius: 999px; font-weight: 600; font-size: 0.95rem;
}
.quick-save:hover { background: #fff; }
.quick-save[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.quick-save[aria-pressed="false"] svg path { fill: none; stroke: currentColor; stroke-width: 2; }

/* ---------- Empty state ---------- */
.empty {
  display: grid; gap: 14px; justify-items: start;
  padding: clamp(28px, 5vw, 56px); border: 1.5px dashed var(--ink); background: var(--surface);
}
.empty h3 { font: 500 clamp(1.8rem, 3vw, 2.6rem)/1.05 var(--display); letter-spacing: -0.02em; }
.empty p { color: var(--muted); max-width: 52ch; }
.notice { padding: 20px; border: 1.5px solid var(--ink); }

/* ---------- Detail dialog ---------- */
dialog.detail {
  position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0;
  width: min(620px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh;
  border: 0; border-left: 1.5px solid var(--ink);
  background: var(--canvas); color: var(--ink); overflow: hidden;
}
dialog.detail::backdrop { background: rgba(28, 24, 20, 0.6); }
.sheet { display: flex; flex-direction: column; height: 100%; }
.sheet__scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.sheet__media { position: relative; aspect-ratio: 16 / 9; background: var(--soft-line); overflow: hidden; }
.sheet__media img { width: 100%; height: 100%; object-fit: cover; }
.sheet__close {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  background: var(--canvas); border: 1.5px solid var(--ink); border-radius: 999px; font-weight: 600;
}
.sheet__close:hover { background: var(--ink); color: var(--canvas); }
.sheet__body { padding: 28px 28px 8px; display: grid; gap: 18px; }
.sheet__head { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: stretch; }
.sheet .ticket__stub { position: relative; width: 104px; padding: 16px 6px; }
.sheet .ticket__day { font-size: 3.2rem; }
.sheet__titles { display: grid; gap: 10px; align-content: center; }
.sheet__titles h2 { font: 500 clamp(2rem, 4vw, 2.7rem)/1 var(--display); letter-spacing: -0.025em; }
.sheet__body-text { font-size: 1.15rem; line-height: 1.6; max-width: 54ch; }
.facts { display: grid; grid-template-columns: 1fr 1fr; border-top: 1.5px solid var(--ink); }
.facts div { padding: 12px 0; border-bottom: 1px solid var(--soft-line); }
.facts div:nth-child(odd) { padding-right: 16px; }
.facts div:nth-child(even) { padding-left: 16px; border-left: 1px dashed var(--ink); }
.facts dt { font: 500 0.72rem/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.facts dd { font-weight: 600; }
.sheet__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px; background: var(--surface); border-top: 1.5px solid var(--ink);
}
.sheet__price { font: 500 2.2rem/1 var(--display); letter-spacing: -0.02em; }
.sheet__price small { display: block; font: 500 0.72rem/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.save-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 24px; border-radius: 999px;
  background: var(--ink); color: var(--canvas); border: 1.5px solid var(--ink); font-weight: 700;
}
.save-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.save-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.save-btn[aria-pressed="false"] svg path { fill: none; stroke: currentColor; stroke-width: 2; }
.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;
}

/* ---------- Footer ---------- */
.foot { background: var(--ink); color: var(--canvas); display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.foot__img { min-height: 320px; position: relative; }
.foot__img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.foot__copy { padding: clamp(32px, 5vw, 72px) var(--gutter); display: grid; gap: 14px; align-content: center; max-width: 720px; }
.foot__mark { font: 500 clamp(4rem, 10vw, 8rem)/0.9 var(--display); letter-spacing: -0.04em; font-style: italic; }
.foot__note { color: #cfc6b6; font-size: 0.95rem; max-width: 56ch; }
.foot__top { color: var(--canvas); justify-self: start; padding: 10px 0; font-weight: 600; }
.foot a:focus-visible { outline-color: #9db6ff; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .ticket { transition: transform 0.2s ease, box-shadow 0.2s ease; }
  .ticket:hover { transform: translate(-2px, -2px); }
  dialog.detail[open] { animation: slide-in 0.28s cubic-bezier(0.2, 0.7, 0.2, 1); }
  dialog.detail[open]::backdrop { animation: fade-in 0.28s ease; }
  @keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
  html { scroll-behavior: smooth; }
}
@media (prefers-reduced-motion: reduce) {
  .tile img { transition: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .ticket { grid-template-columns: 112px 200px minmax(0, 1fr) 170px; }
  .ticket__day { font-size: 3.4rem; }
  .toolbar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .field--search { grid-column: 1 / -1; }
  .toolbar .toggle { justify-self: start; }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero__tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tile, .tile:nth-child(n) { height: clamp(260px, 44vw, 380px); }
  .tile:nth-child(even) { height: clamp(220px, 38vw, 330px); }

  .ticket {
    grid-template-columns: 104px minmax(0, 1fr);
    grid-template-areas: "image image" "stub main" "stub aside";
  }
  .ticket__img { min-height: 0; aspect-ratio: 16 / 7; }
  .ticket__main { padding: 18px 20px 6px; }
  .ticket__aside {
    border-left: 0; padding: 4px 20px 20px;
    grid-template-columns: auto 1fr; align-items: center; column-gap: 16px;
  }
  .ticket__price { grid-row: 1; }
  .ticket__seats { grid-row: 2; grid-column: 1; margin-top: 0; }
  .ticket__actions { grid-row: 1 / span 2; grid-column: 2; grid-template-columns: 1fr 1fr; margin: 0; }
  .ticket__stub { border-top: 1.5px solid var(--ink); }
  .ticket__stub::after { top: 12px; bottom: 12px; }
  .ticket__notch--top { top: -11px; }
}

@media (max-width: 640px) {
  body { font-size: 1rem; }
  .masthead { gap: 12px; padding-top: 14px; padding-bottom: 14px; }
  .masthead__tag { display: none; }
  .shortlist-link { margin-left: auto; }
  .wordmark { font-size: 1.55rem; }
  .hero { gap: 28px; padding-bottom: 48px; }
  .hero__tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile, .tile:nth-child(n) { height: 230px; border-radius: 50% 50% 0 0 / 80px 80px 0 0; }
  .tile:nth-child(even) { height: 230px; }
  .hero__facts dd { font-size: 1.3rem; }
  .hero .btn { justify-self: stretch; }

  .programme__head { flex-direction: column; gap: 6px; }
  .toolbar { grid-template-columns: 1fr 1fr; gap: 12px; }
  .toolbar .toggle { grid-column: 1 / -1; justify-self: stretch; justify-content: center; }
  .results-bar { flex-direction: column; gap: 4px; }

  .ticket { grid-template-columns: 92px minmax(0, 1fr); }
  .ticket__day { font-size: 2.9rem; }
  .ticket__img { aspect-ratio: 16 / 9; }
  .ticket__aside { grid-template-columns: 1fr 1fr; }
  .ticket__price { grid-row: 1; grid-column: 1; }
  .ticket__seats { grid-row: 1; grid-column: 2; justify-self: end; align-self: center; text-align: right; }
  .ticket__actions { grid-row: 2; grid-column: 1 / -1; }

  dialog.detail { width: 100vw; border-left: 0; }
  .sheet__media { aspect-ratio: 16 / 10; }
  .sheet__body { padding: 20px 20px 4px; }
  .sheet__head { grid-template-columns: 88px 1fr; gap: 14px; }
  .sheet .ticket__stub { width: 88px; }
  .sheet .ticket__day { font-size: 2.7rem; }
  .sheet__foot { padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); }
  .sheet__price { font-size: 1.8rem; }
  .save-btn { padding: 0 18px; }
  .foot { grid-template-columns: 1fr; }
  .foot__img { min-height: 200px; }
}

@media (max-width: 380px) {
  .tile__cap strong { font-size: 1.15rem; }
  .hero__facts dd { font-size: 1.15rem; }
}
