/* Forma — a shape sorter.
   Roles: paper canvas, ink text, four craft colours. Every photo is cropped to its craft's shape. */

:root {
  --paper: #f4ecdc;
  --paper-2: #ebe0c8;
  --ink: #1b1a2e;
  --ink-soft: #4a4760;
  --cream: #fff9ec;
  --focus: #2229ff;

  --c-ceramics: #9dbfe6;
  --c-painting: #f26b4f;
  --c-floristry: #f7b52c;
  --c-baking: #d98e4a;

  --display: "Futura", "Avenir Next", "Century Gothic", "Trebuchet MS", system-ui, sans-serif;
  --body: "Avenir Next", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --gutter: clamp(20px, 4vw, 56px);
  --max: 1320px;
  --squish: cubic-bezier(.3, 1.7, .5, 1);
  --shelf-h: 76px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
html.lock { overflow: hidden; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.55 var(--body);
  padding-bottom: calc(var(--shelf-h) + 24px);
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.shelf :focus-visible, .detail-close:focus-visible { outline-color: #fff; }
.detail-panel :focus-visible { outline-color: var(--ink); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: var(--cream); padding: 10px 16px; border-radius: 8px; }
.skip:focus { top: 12px; }

/* ---------- the shape system (signature device) ---------- */
.shape {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--c);
  transition: border-radius .55s var(--squish), transform .55s var(--squish);
}
.shape img { width: 100%; height: 100%; object-fit: cover; }
[data-cat="Ceramics"] { --c: var(--c-ceramics); }
[data-cat="Painting"] { --c: var(--c-painting); }
[data-cat="Floristry"] { --c: var(--c-floristry); }
[data-cat="Baking"] { --c: var(--c-baking); }

[data-cat="Ceramics"] .shape, .wm-circle { border-radius: 50%; }
[data-cat="Painting"] .shape, .wm-square { border-radius: 6%; }
[data-cat="Baking"] .shape, .wm-arch { border-radius: 999px 999px 6% 6%; }
[data-cat="Floristry"] .shape, .wm-petal { border-radius: 0 100% 0 100%; }

[data-cat="Ceramics"] .shape img { object-position: 50% 50%; }
[data-cat="Painting"] .shape img { object-position: 45% 40%; }
[data-cat="Floristry"] .shape img { object-position: 52% 55%; }
[data-cat="Baking"] .shape img { object-position: 55% 50%; }

/* clay squish: shapes soften into a pinched pebble when touched */
.squishable:hover .shape,
.squishable:focus-within .shape,
.squishable[aria-pressed="true"] .shape { border-radius: 34% 66% 58% 42% / 44% 38% 62% 56%; transform: rotate(0deg) scale(1.03); }

.wm { display: inline-block; width: 1em; height: 1em; }
.wm-circle { background: var(--c-ceramics); }
.wm-square { background: var(--c-painting); }
.wm-arch { background: var(--c-baking); }
.wm-petal { background: var(--c-floristry); }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 20px;
  max-width: var(--max); margin: 0 auto; padding: 18px var(--gutter);
}
.wordmark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.wm-shapes { display: inline-flex; gap: 3px; font-size: 18px; align-items: flex-end; }
.wm-text { font: 800 30px/1 var(--display); letter-spacing: -.03em; }
.top-note { margin-left: auto; font: 500 12px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  background: var(--ink); color: var(--cream);
  border: 2px solid var(--ink); border-radius: 999px;
  font: 700 15px/1 var(--body);
  transition: transform .3s var(--squish), background .2s, color .2s;
}
.btn:hover { transform: translateY(-2px) rotate(-1.5deg); }
.btn:active { transform: translateY(0) scale(.97); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--cream); }

/* ---------- hero: the shape sorter ---------- */
.hero {
  max-width: var(--max); margin: 0 auto;
  padding: clamp(12px, 3vw, 36px) var(--gutter) clamp(32px, 5vw, 64px);
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 64px); align-items: center;
}
.eyebrow { font: 500 13px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.hero h1 {
  margin: 14px 0 20px;
  font: 800 clamp(54px, 9.2vw, 132px)/.88 var(--display);
  letter-spacing: -.045em;
  text-wrap: balance;
}
.lede { max-width: 46ch; font-size: clamp(17px, 1.5vw, 20px); }
.hint { margin-top: 22px; font: 700 13px/1 var(--mono); text-transform: uppercase; letter-spacing: .12em; }

.sorter-board {
  display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 2vw, 24px);
  padding: clamp(12px, 2vw, 24px);
  padding-bottom: calc(clamp(12px, 2vw, 24px) + clamp(10px, 2.5vw, 34px));
  max-width: 540px; width: 100%; justify-self: end;
  background: var(--paper-2);
  border: 2px dashed var(--ink);
  border-radius: 28px;
}
.sorter {
  display: flex; flex-direction: column; gap: 10px;
  background: none; border: 0; padding: 0; text-align: left;
}
.sorter:nth-child(even) { transform: translateY(clamp(10px, 2.5vw, 34px)); }
.sorter .shape { width: 100%; box-shadow: 0 0 0 0 var(--ink); }
.sorter[aria-pressed="true"] .shape { box-shadow: 0 0 0 4px var(--paper-2), 0 0 0 7px var(--ink); }
.sorter-label { display: flex; flex-direction: column; font: 500 12px/1.35 var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.sorter-label b { font: 800 clamp(17px, 1.8vw, 24px)/1.1 var(--display); letter-spacing: -.01em; text-transform: none; }

@media (prefers-reduced-motion: no-preference) {
  .sorter .shape { animation: bob 5s ease-in-out infinite; }
  .sorter:nth-child(2) .shape { animation-delay: -1.2s; }
  .sorter:nth-child(3) .shape { animation-delay: -2.4s; }
  .sorter:nth-child(4) .shape { animation-delay: -3.6s; }
  @keyframes bob { 0%, 100% { transform: rotate(-2deg) translateY(0); } 50% { transform: rotate(2deg) translateY(-6px); } }
  .sorter:hover .shape, .sorter:focus-visible .shape, .sorter[aria-pressed="true"] .shape { animation: none; }
}

/* ---------- ruler ---------- */
.ruler-wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter) clamp(32px, 5vw, 56px); }
.ruler-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 24px; margin-bottom: 14px; }
.ruler-head h2 { font: 800 clamp(24px, 3vw, 34px)/1.1 var(--display); letter-spacing: -.02em; }
.ruler-head p { font-size: 15px; color: var(--ink-soft); max-width: 60ch; }
.ruler-scroll { overflow-x: auto; border-top: 3px solid var(--ink); border-bottom: 3px solid var(--ink); background: var(--cream); }
.ruler { display: grid; grid-template-columns: repeat(var(--days), minmax(56px, 1fr)); min-width: calc(var(--days) * 56px); }
.day {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px;
  min-height: 118px; padding: 8px 2px 8px;
  border-left: 1px solid rgba(27, 26, 46, .25);
  font: 500 11px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft);
}
.day:first-child { border-left: 0; }
.day b { font: 800 18px/1 var(--display); color: var(--ink); letter-spacing: 0; }
.day.is-weekend { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(27, 26, 46, .06) 6px 8px); }
.day-pick {
  width: 44px; height: 44px; padding: 0; border: 0; background: none; flex: none;
  transition: opacity .25s, transform .4s var(--squish);
}
.day-pick .shape { width: 100%; }
.day-pick:hover { transform: translateY(-4px) rotate(-6deg); }
.day-pick.is-dim { opacity: .22; }
.day-pick.is-dim:hover, .day-pick.is-dim:focus-visible { opacity: 1; }
.day-gap { width: 44px; height: 44px; display: grid; place-items: center; }
.day-gap::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: rgba(27, 26, 46, .3); }

/* ---------- toolbar ---------- */
.browse { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); scroll-margin-top: 12px; }
.toolbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: 12px; align-items: end;
  margin: 0 calc(var(--gutter) * -1); padding: 14px var(--gutter);
  background: var(--paper); border-bottom: 2px solid var(--ink);
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font: 500 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.field input, .field select {
  width: 100%; min-height: 48px; padding: 8px 16px;
  background: var(--cream); border: 2px solid var(--ink); border-radius: 14px;
  font-size: 16px;
}
.field select { appearance: none; padding-right: 40px; cursor: pointer;
  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; }
.toggle {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 16px;
  background: var(--cream); border: 2px solid var(--ink); border-radius: 14px; font-weight: 700;
  transition: background .2s, transform .3s var(--squish);
}
.toggle:hover { transform: rotate(-1.5deg); }
.toggle[aria-pressed="true"] { background: var(--ink); color: var(--cream); }
.toggle .count { min-width: 24px; height: 24px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; background: var(--c-floristry); color: var(--ink); font: 800 13px/1 var(--mono); }
.results-line { margin: 18px 0 20px; font: 500 13px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }

/* ---------- list: tiles ---------- */
.list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 2.2vw, 32px); }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 16px;
  padding: 20px; min-height: 100%;
  background: var(--c); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 24px;
  box-shadow: 6px 6px 0 var(--ink);
  transition: transform .4s var(--squish), box-shadow .3s;
}
.tile:hover, .tile:focus-within { transform: translate(-3px, -3px); box-shadow: 9px 9px 0 var(--ink); }
.tile-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tile-date { display: flex; flex-direction: column; font: 500 12px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.tile-date b { font: 800 44px/.95 var(--display); letter-spacing: -.03em; text-transform: none; }
.tile-cat { padding: 5px 11px; border: 2px solid var(--ink); border-radius: 999px; font: 700 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; background: rgba(255, 249, 236, .55); }
.tile .shape { width: 68%; margin: 0 auto; --tilt: 0deg; transform: rotate(var(--tilt)); border: 2px solid var(--ink); }
.tile:nth-child(3n+1) .shape { --tilt: -4deg; }
.tile:nth-child(3n+2) .shape { --tilt: 3deg; margin-right: 6%; }
.tile:nth-child(3n) .shape { --tilt: -2deg; margin-left: 6%; }
.tile:hover .shape, .tile:focus-within .shape { transform: rotate(0deg) scale(1.03); border-radius: 34% 66% 58% 42% / 44% 38% 62% 56%; }
.tile h3 { font: 800 clamp(30px, 3.1vw, 42px)/.98 var(--display); letter-spacing: -.035em; text-wrap: balance; }
.tile .open { background: none; border: 0; padding: 0; text-align: left; font: inherit; letter-spacing: inherit; color: inherit; }
.tile .open::after { content: ""; position: absolute; inset: 0; border-radius: 22px; }
.tile .open:focus-visible { outline: none; }
.tile:has(.open:focus-visible) { outline: 3px solid var(--focus); outline-offset: 4px; }
.tile-desc { font-size: 16px; }
.tile-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font: 500 13px/1.3 var(--mono); }
.tile-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 2px dashed var(--ink); }
.price { font: 800 30px/1 var(--display); letter-spacing: -.03em; }
.seats { font: 500 12px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .06em; text-align: right; }
.quick {
  position: relative; z-index: 2; flex: none;
  width: 48px; height: 48px; display: grid; place-items: center;
  background: var(--cream); border: 2px solid var(--ink); border-radius: 50%;
  transition: transform .4s var(--squish), background .2s;
}
.quick:hover { transform: scale(1.12) rotate(-8deg); }
.quick[aria-pressed="true"] { background: var(--ink); color: var(--cream); }
.quick svg path { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; }
.quick[aria-pressed="true"] svg path { fill: currentColor; }
.tile.is-new { animation: plop .5s var(--squish); }
@keyframes plop { 0% { transform: scale(.94); } 100% { transform: scale(1); } }

/* ---------- empty ---------- */
.empty { max-width: 560px; margin: 40px auto 20px; padding: 32px; text-align: center; background: var(--cream); border: 2px dashed var(--ink); border-radius: 28px; }
.empty[hidden] { display: none; }
.empty-shapes { display: flex; justify-content: center; gap: 10px; font-size: 34px; margin-bottom: 16px; }
.empty-shapes .wm:nth-child(odd) { transform: translateY(-8px) rotate(-8deg); }
.empty-shapes .wm:nth-child(even) { transform: translateY(6px) rotate(10deg); }
.empty h3 { font: 800 clamp(28px, 4vw, 38px)/1.05 var(--display); letter-spacing: -.03em; margin-bottom: 8px; }
.empty p { margin-bottom: 20px; }

.foot { padding: 56px 0 24px; font-size: 14px; color: var(--ink-soft); }

/* ---------- shelf ---------- */
.shelf {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: var(--shelf-h);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 20px;
  padding: 0 var(--gutter) 0;
  background: var(--ink); color: var(--cream);
  border-top: 4px solid var(--c-floristry);
}
.shelf > * { grid-row: 1; }
.shelf-items { grid-column: 2; }
.shelf-total { grid-column: 3; }
.shelf-label { grid-column: 1; align-self: center; display: flex; flex-direction: column; font: 500 12px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.shelf-label strong { font: 800 20px/1.1 var(--display); letter-spacing: -.01em; text-transform: none; }
.shelf-items { display: flex; align-items: flex-end; gap: 12px; padding: 0 4px; overflow-x: auto; overflow-y: hidden; height: 100%; }
.shelf-items li { flex: none; align-self: flex-end; }
.shelf-pick { display: block; width: 44px; padding: 0; border: 0; background: none; margin-bottom: 0; transition: transform .4s var(--squish); }
.shelf-pick .shape { width: 100%; }
.shelf-pick:hover { transform: translateY(-6px) rotate(-6deg); }
.shelf-pick.is-new { animation: drop .6s var(--squish); }
@keyframes drop { 0% { transform: translateY(-50px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.shelf-empty { align-self: center; grid-column: 2; font-size: 14px; color: #d9d2e8; }
.shelf-items:not(:empty) + .shelf-empty { display: none; }
.shelf-total { align-self: center; display: flex; flex-direction: column; align-items: flex-end; font: 700 14px/1.3 var(--mono); }
.shelf-clear { background: none; border: 0; padding: 4px 0; color: var(--cream); text-decoration: underline; text-underline-offset: 3px; font: 500 12px/1.2 var(--mono); }

/* ---------- detail dialog: a ticket ---------- */
.detail {
  padding: 0; border: 3px solid var(--ink); border-radius: 28px; background: var(--paper); color: var(--ink);
  width: min(1080px, calc(100vw - 48px)); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  overflow: auto; box-shadow: 10px 10px 0 var(--ink);
}
.detail::backdrop { background: rgba(27, 26, 46, .72); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); min-height: 560px; }
.detail-art {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  padding: 40px; background: var(--c); border-right: 3px dashed var(--ink);
}
.detail-art .shape { width: min(100%, 360px); border: 3px solid var(--ink); transform: rotate(-3deg); }
.detail-art:hover .shape { border-radius: 34% 66% 58% 42% / 44% 38% 62% 56%; transform: rotate(0); }
.seat-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 320px; }
.seat-dots i { width: 18px; height: 18px; background: var(--ink); }
[data-cat="Ceramics"] .seat-dots i { border-radius: 50%; }
[data-cat="Painting"] .seat-dots i { border-radius: 15%; }
[data-cat="Baking"] .seat-dots i { border-radius: 999px 999px 15% 15%; }
[data-cat="Floristry"] .seat-dots i { border-radius: 0 100% 0 100%; }
.seat-cap { font: 700 12px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; text-align: center; }
.detail-panel { position: relative; display: flex; flex-direction: column; gap: 20px; padding: clamp(24px, 4vw, 44px); }
.detail-close {
  position: absolute; top: 16px; right: 16px; z-index: 3;
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  background: var(--ink); color: var(--cream); border: 0; border-radius: 999px; font-weight: 700;
}
.detail-close:hover { background: var(--focus); }
.detail .eyebrow { padding-right: 110px; }
.detail h2 { font: 800 clamp(42px, 6vw, 76px)/.9 var(--display); letter-spacing: -.045em; text-wrap: balance; }
.detail-body { font-size: 19px; line-height: 1.5; max-width: 44ch; }
.ticket { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: 2px dashed var(--ink); border-bottom: 2px dashed var(--ink); }
.ticket > div { padding: 12px 0; border-bottom: 1px solid rgba(27, 26, 46, .2); }
.ticket > div:nth-last-child(-n+2) { border-bottom: 0; }
.ticket dt { font: 500 11px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.ticket dd { font: 700 18px/1.3 var(--body); }
.ticket dd.big { font: 800 34px/1 var(--display); letter-spacing: -.03em; }
.save-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: auto; }
.save {
  display: inline-flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 26px;
  background: var(--c); color: var(--ink); border: 3px solid var(--ink); border-radius: 999px;
  font: 800 17px/1.1 var(--body); box-shadow: 4px 4px 0 var(--ink);
  transition: transform .3s var(--squish), box-shadow .2s, background .2s;
}
.save:hover { transform: translate(-2px, -2px) rotate(-1deg); box-shadow: 6px 6px 0 var(--ink); }
.save:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.save[aria-pressed="true"] { background: var(--ink); color: var(--cream); }
.save svg path { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; }
.save[aria-pressed="true"] svg path { fill: currentColor; }
.save-note { font: 500 12px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .top-note { display: none; }
  #surprise { margin-left: auto; }
  .detail-grid { grid-template-columns: 1fr; min-height: 0; }
  .detail-art { border-right: 0; border-bottom: 3px dashed var(--ink); padding: 56px 24px 28px; }
  .detail-art .shape { width: min(62%, 260px); }
}
@media (max-width: 640px) {
  body { font-size: 16px; --shelf-h: 68px; }
  .hero h1 { font-size: clamp(52px, 15.5vw, 70px); }
  .sorter-label { font-size: 11px; }
  .toolbar { position: static; grid-template-columns: 1fr 1fr; }
  .field-search { grid-column: 1 / -1; }
  .toggle { grid-column: 1 / -1; justify-content: center; }
  .field-filter { grid-column: 1 / -1; }
  .list { grid-template-columns: 1fr; }
  .tile .shape { width: 62%; }
  .shelf { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .shelf-label { display: none; }
  .shelf-items { grid-column: 1; }
  .shelf-total { grid-column: 2; }
  .shelf-empty { grid-column: 1; font-size: 13px; line-height: 1.3; }
  .shelf-pick { width: 38px; }
  .detail {
    width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh;
    margin: 0; border-radius: 0; border-width: 0; box-shadow: none;
  }
  .detail .eyebrow { padding-right: 0; }
  .detail-panel { padding-top: 28px; }
  .detail-close { position: fixed; top: 12px; right: 12px; }
  .ticket dd.big { font-size: 28px; }
  .save { width: 100%; justify-content: center; }
}

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