/* Forma: a rack of paint chips. The page background is "the wall";
   pointing at a chip holds it against the wall and tints the page. */

:root {
  color-scheme: light dark;
  --ceramics: #86a8cc;
  --painting: #ee5240;
  --floristry: #f6a91b;
  --baking: #2f2a27;
  --ink: #14171a;
  --base: #e9ecef;
  --fg: #14171a;
  --muted: #2d3237;
  --field: #fbfcfc;
  --wall: var(--base);
  --r: 6px;
  --display: "Avenir Next", "Helvetica Neue", Helvetica, Arial, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.2, 0.9, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --base: #15181b;
    --fg: #f1f3f4;
    --muted: #d3d8dc;
    --field: #1f2328;
  }
}

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

/* Holding a chip against the wall */
body:has(.chip[data-cat="Ceramics"]:hover),
body:has(.chip[data-cat="Ceramics"] .open-item:focus-visible),
body[data-wall="Ceramics"] { --wall: color-mix(in srgb, var(--ceramics) 36%, var(--base)); }
body:has(.chip[data-cat="Painting"]:hover),
body:has(.chip[data-cat="Painting"] .open-item:focus-visible),
body[data-wall="Painting"] { --wall: color-mix(in srgb, var(--painting) 34%, var(--base)); }
body:has(.chip[data-cat="Floristry"]:hover),
body:has(.chip[data-cat="Floristry"] .open-item:focus-visible),
body[data-wall="Floristry"] { --wall: color-mix(in srgb, var(--floristry) 38%, var(--base)); }
body:has(.chip[data-cat="Baking"]:hover),
body:has(.chip[data-cat="Baking"] .open-item:focus-visible),
body[data-wall="Baking"] { --wall: color-mix(in srgb, var(--baking) 34%, var(--base)); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--wall);
  color: var(--fg);
  font-family: var(--display);
  font-size: 1rem;
  line-height: 1.45;
  transition: background-color 0.45s ease;
}
body.lock { overflow: hidden; }

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

.wrap { width: 100%; max-width: 1440px; margin: 0 auto; padding-left: 40px; padding-right: 40px; }

.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 5;
  background: var(--fg); color: var(--base); padding: 10px 14px; border-radius: var(--r); font-weight: 700;
}
.skip:focus { top: 12px; }

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

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; border-radius: var(--r); }
.mark { display: grid; grid-template-columns: 1fr 1fr; width: 26px; height: 26px; gap: 2px; }
.mark i { display: block; border-radius: 2px; }
.mark i:nth-child(1) { background: var(--ceramics); }
.mark i:nth-child(2) { background: var(--painting); }
.mark i:nth-child(3) { background: var(--floristry); }
.mark i:nth-child(4) { background: var(--baking); box-shadow: 0 0 0 1px color-mix(in srgb, var(--fg) 30%, transparent); }
.brand-name { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.04em; }
.range { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 48px; align-items: end; padding-top: 12px; padding-bottom: 26px; }
h1 {
  font-size: clamp(2.3rem, 0.9rem + 4.7vw, 5rem);
  font-weight: 800; letter-spacing: -0.045em; line-height: 0.98;
}
h1 span { display: block; }
.swatch-word {
  font-style: normal; padding-bottom: 0.04em;
  background: linear-gradient(90deg, var(--ceramics) 0 25%, var(--painting) 25% 50%, var(--floristry) 50% 75%, var(--baking) 75% 100%) 0 100% / 100% 0.13em no-repeat;
}
.lede { margin-top: 18px; max-width: 46ch; font-size: 1.15rem; color: var(--muted); }

/* ---------- tray ---------- */
.tray {
  border: 2px solid var(--fg); border-radius: var(--r); padding: 14px 16px 16px;
  background: color-mix(in srgb, var(--field) 55%, transparent);
}
.tray-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tray h2 { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.01em; }
.linkish {
  font: inherit; font-size: 0.9rem; font-weight: 700; color: var(--fg); background: none; border: 0;
  padding: 4px 2px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; border-radius: 3px;
}
.slots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 12px 0; }
.slots li { display: block; }
.slot {
  display: flex; width: 100%; aspect-ratio: 3 / 4; border-radius: var(--r);
  align-items: center; justify-content: center; flex-direction: column; gap: 2px;
}
span.slot { border: 2px dashed color-mix(in srgb, var(--fg) 55%, transparent); }
button.slot {
  border: 0; padding: 0; background: var(--c); color: var(--on); cursor: pointer; font-family: var(--mono);
  box-shadow: 0 8px 14px -8px color-mix(in srgb, var(--c) 80%, #000);
  transition: translate 0.25s var(--ease);
}
button.slot:hover { translate: 0 -4px; }
button.slot b { font-size: 1.15rem; line-height: 1; letter-spacing: -0.04em; }
button.slot small { font-size: 0.75rem; line-height: 1; }
button.slot.fresh { animation: drop 0.55s var(--ease); }
.tray-note { font-size: 0.95rem; color: var(--muted); }

/* ---------- controls ---------- */
.controls { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto; gap: 16px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.9rem; font-weight: 700; }
input[type="text"], select {
  width: 100%; height: 50px; padding: 0 14px; font: inherit; font-size: 1rem; color: var(--fg);
  background-color: var(--field); border: 2px solid var(--fg); border-radius: var(--r);
}
select {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg) 50%), linear-gradient(135deg, var(--fg) 50%, transparent 50%);
  background-position: calc(100% - 22px) 22px, calc(100% - 16px) 22px;
  background-size: 6px 6px; background-repeat: no-repeat;
}
.toggle {
  display: inline-flex; align-items: center; gap: 10px; height: 50px; padding: 0 18px; white-space: nowrap;
  font: inherit; font-weight: 800; color: var(--fg); background: transparent; border: 2px solid var(--fg);
  border-radius: var(--r); cursor: pointer; transition: translate 0.15s var(--ease);
}
.toggle .box { width: 16px; height: 16px; border: 2px solid currentColor; border-radius: 3px; flex: none; }
.toggle .count { font-family: var(--mono); font-weight: 700; }
.toggle[aria-pressed="true"] { background: var(--fg); color: var(--base); }
.toggle[aria-pressed="true"] .box { background: currentColor; box-shadow: inset 0 0 0 2px var(--fg); }
.toggle:active, .solid:active, .save:active { translate: 0 1px; }

.results { margin: 18px 0 4px; font-family: var(--mono); font-size: 0.9rem; color: var(--muted); min-height: 1.4em; }

/* ---------- the rack ---------- */
.rack { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; align-items: start; padding: 10px 0 56px; }

.chip {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  margin-top: calc(var(--off, 0) * 1px);
  background: var(--c); color: var(--on); border-radius: var(--r);
  rotate: var(--tilt, 0deg); transform-origin: 50% 19px;
  box-shadow: 0 20px 28px -20px color-mix(in srgb, var(--c) 75%, #000), inset 0 2px 0 rgb(255 255 255 / 0.22);
  transition: translate 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.chip.enter { animation: hang 0.8s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 60ms); }
.chip:not(.enter):is(:hover, :has(:focus-visible)) {
  translate: 0 -8px; animation: swing 0.9s ease-out;
  box-shadow: 0 28px 34px -20px color-mix(in srgb, var(--c) 75%, #000), inset 0 2px 0 rgb(255 255 255 / 0.22);
}
/* the punched hole and the nail */
.chip::before {
  content: ""; position: absolute; left: 50%; top: 10px; width: 18px; height: 18px; margin-left: -9px;
  border-radius: 50%; background: var(--wall); box-shadow: inset 0 2px 3px rgb(0 0 0 / 0.3);
}
.chip::after {
  content: ""; position: absolute; left: 50%; top: 15px; width: 8px; height: 8px; margin-left: -4px;
  border-radius: 50%; background: var(--fg);
}
.chip.skel { min-height: 420px; background: color-mix(in srgb, var(--fg) 12%, transparent); box-shadow: none; }
.chip.skel::after { display: none; }

.band {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 34px 14px 10px; font-family: var(--mono); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}
.kept { padding: 1px 6px; border: 1.5px solid currentColor; border-radius: 3px; rotate: -6deg; font-size: 0.75rem; }
.chip img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.chip .body { display: flex; flex-direction: column; padding: 14px 14px 16px; flex: 1; }
.name { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; text-wrap: balance; min-height: 2.2em; }
.open-item {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; letter-spacing: inherit;
}
.open-item::after { content: ""; position: absolute; inset: 0; border-radius: var(--r); }
.open-item:focus-visible { outline: none; }
.open-item:focus-visible::after { outline: 3px solid var(--fg); outline-offset: 4px; }

.when { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-family: var(--mono); }
.day { font-family: var(--display); font-size: 2.7rem; font-weight: 800; line-height: 0.9; letter-spacing: -0.05em; }
.mon { display: flex; flex-direction: column; font-size: 0.85rem; line-height: 1.25; font-weight: 700; }
.time { margin-left: auto; font-size: 0.95rem; font-weight: 700; }
.meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; font-family: var(--mono); font-size: 0.9rem; font-weight: 700; }

/* ---------- empty / error ---------- */
.empty {
  max-width: 560px; margin: 24px 0 64px; padding: 28px; border: 2px dashed var(--fg); border-radius: var(--r);
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
}
.empty h3 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.empty p { color: var(--muted); }
.solid {
  margin-top: 6px; height: 48px; padding: 0 20px; font: inherit; font-weight: 800; color: var(--base); background: var(--fg);
  border: 2px solid var(--fg); border-radius: var(--r); cursor: pointer;
}

.foot { padding-top: 12px; padding-bottom: 36px; font-size: 0.9rem; color: var(--muted); }

/* ---------- detail dialog ---------- */
.detail {
  padding: 0; border: 0; background: transparent; color: inherit; overflow: visible;
  width: min(1080px, calc(100vw - 48px)); max-width: none; max-height: none; margin: auto;
}
.detail:not([open]) { display: none; }
.detail::backdrop { background: rgb(20 23 26 / 0.6); backdrop-filter: blur(4px); }
.sheet {
  display: grid; grid-template-columns: 5fr 6fr; background: var(--c); color: var(--on);
  border-radius: var(--r); overflow: hidden auto; max-height: calc(100dvh - 48px);
  box-shadow: 0 30px 60px -20px rgb(0 0 0 / 0.5);
}
.detail[open] .sheet { animation: unfold 0.4s var(--ease); }
.sheet-photo { position: relative; min-height: 320px; }
.sheet-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.panel { display: flex; flex-direction: column; gap: 18px; padding: 26px 32px 32px; min-width: 0; }
.panel :focus-visible { outline-color: currentColor; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cat-line { font-family: var(--mono); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.close {
  height: 44px; padding: 0 16px; font: inherit; font-weight: 800; color: inherit; background: transparent;
  border: 2px solid currentColor; border-radius: var(--r); cursor: pointer;
}
.close:hover { background: var(--on); color: var(--c); }
.panel h2 { font-size: clamp(2.1rem, 1.2rem + 2.6vw, 3.6rem); font-weight: 800; letter-spacing: -0.045em; line-height: 1; text-wrap: balance; }
.panel .desc { font-size: 1.15rem; line-height: 1.5; max-width: 46ch; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fact { padding: 12px 14px; border-radius: var(--r); background: color-mix(in srgb, var(--on) 13%, transparent); }
.fact dt { font-family: var(--mono); font-size: 0.8rem; font-weight: 700; }
.fact dd small { display: block; margin-top: 2px; font-family: var(--mono); font-size: 0.8rem; font-weight: 700; letter-spacing: 0; }
.fact dd { margin-top: 4px; font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.save {
  display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: auto; min-height: 60px; padding: 14px 20px;
  font: inherit; font-size: 1.1rem; font-weight: 800; color: var(--c); background: var(--on); border: 2px solid var(--on);
  border-radius: var(--r); cursor: pointer;
}
.save::before { content: ""; width: 18px; height: 18px; border: 2px solid currentColor; border-radius: 3px; flex: none; }
.save[aria-pressed="true"] { background: transparent; color: var(--on); }
.save[aria-pressed="true"]::before { background: currentColor; box-shadow: inset 0 0 0 3px var(--c); }

/* ---------- motion ---------- */
@keyframes hang {
  from { translate: 0 -46px; rotate: calc(var(--tilt, 0deg) - 7deg); }
}
@keyframes swing {
  0% { rotate: var(--tilt, 0deg); }
  25% { rotate: calc(var(--tilt, 0deg) + var(--kick, 1) * 5deg); }
  55% { rotate: calc(var(--tilt, 0deg) - var(--kick, 1) * 3deg); }
  80% { rotate: calc(var(--tilt, 0deg) + var(--kick, 1) * 1.2deg); }
  100% { rotate: var(--tilt, 0deg); }
}
@keyframes drop {
  from { translate: 0 -22px; rotate: -10deg; }
}
@keyframes unfold {
  from { translate: 0 24px; rotate: -1.5deg; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .rack { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 28px; }
  .hero { grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; }
}

@media (max-width: 900px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .hero { grid-template-columns: 1fr; gap: 22px; }
  .controls { grid-template-columns: minmax(0, 1fr) auto; }
  .controls .field:first-child { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .top { height: 60px; }
  .range { display: none; }
  .rack { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; row-gap: 20px; }
  .chip { margin-top: calc(var(--off, 0) * 0.45px); }
  .band { padding: 32px 10px 8px; font-size: 0.75rem; }
  .chip .body { padding: 12px 10px 14px; }
  .name { font-size: 1.1rem; }
  .day { font-size: 2.2rem; }
  .when { gap: 8px; }
  .meta { font-size: 0.85rem; }
  .tray { padding: 12px; }
  .slots { gap: 6px; }

  .detail { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; }
  .sheet { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .sheet-photo { min-height: 0; height: 200px; }
  .panel { padding: 0 16px 24px; gap: 16px; }
  .panel-head { position: sticky; top: 0; z-index: 1; padding: 14px 0 6px; background: var(--c); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .save { margin-top: 4px; }
}
