/* Before It Falls — "The Keepsake": archive tags on a red thread.
   Recursive carries both voices: CASL 1 for the person, MONO 1 for measurements. */
@import url("https://fonts.googleapis.com/css2?family=Recursive:slnt,wght,CASL,CRSV,MONO@-15..0,300..800,0..1,0..1,0..1&display=swap");

:root {
  --lichen: #eceeea;
  --tag: #ffffff;
  --ink: #23262a;
  --ink-soft: #5b6066;
  --moss: #4d6150;
  --moss-deep: #3d4e40;
  --thread: #a3352b;
  --rule: #d9dcd6;
  --hair: #6b5544; /* replaced at runtime by the person's measured colour */
  --radius: 14px;
  --shadow: 0 1px 0 rgba(35, 38, 42, 0.06), 0 10px 30px -18px rgba(35, 38, 42, 0.45);
  --voice: "CASL" 1, "MONO" 0, "CRSV" 1;
  --data: "CASL" 0, "MONO" 1;
  --plain: "CASL" 0.3, "MONO" 0;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--lichen); color: var(--ink); }

body {
  font-family: "Recursive", ui-sans-serif, system-ui, sans-serif;
  font-variation-settings: var(--plain);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.voice { font-variation-settings: var(--voice); font-weight: 420; }
.data { font-variation-settings: var(--data); font-size: 0.86em; letter-spacing: -0.01em; }

main { max-width: 460px; margin: 0 auto; padding: 20px 18px 120px; }

header.top { display: flex; align-items: baseline; justify-content: space-between; padding: 10px 0 18px; }
header.top .mark { font-variation-settings: var(--voice); font-size: 1.45rem; font-weight: 500; }
header.top .step { font-variation-settings: var(--data); font-size: 0.78rem; color: var(--ink-soft); }

h1 { font-variation-settings: var(--voice); font-weight: 520; font-size: 2.1rem; line-height: 1.12; margin: 6px 0 12px; }
h2 { font-variation-settings: var(--plain); font-weight: 650; font-size: 1.15rem; margin: 26px 0 10px; }
p.lede { color: var(--ink-soft); margin: 0 0 18px; }

/* The tag: a white card with cut corners, a punched hole and a red thread.
   Corners are cut with gradients, not clip-path, so the thread can hang outside. */
.tag {
  position: relative;
  background:
    linear-gradient(135deg, transparent 22px, var(--tag) 22.5px) top left / 51% 100% no-repeat,
    linear-gradient(225deg, transparent 22px, var(--tag) 22.5px) top right / 51% 100% no-repeat;
  border-radius: var(--radius);
  filter: drop-shadow(0 1px 0 rgba(35, 38, 42, 0.06)) drop-shadow(0 10px 16px rgba(35, 38, 42, 0.12));
  padding: 34px 20px 20px;
  margin-top: 30px;
}
.tag::before { /* the punched hole */
  content: "";
  position: absolute; top: 12px; left: 50%;
  width: 16px; height: 16px; margin-left: -8px;
  border-radius: 50%;
  background: var(--lichen);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.22), 0 0 0 3px #f4f5f2;
  z-index: 1;
}
.thread { position: absolute; top: -30px; left: calc(50% - 1px); width: 2px; height: 50px; background: var(--thread); border-radius: 2px; transform: rotate(9deg); transform-origin: bottom; z-index: 2; }
.thread::after { content: ""; position: absolute; bottom: -2px; left: -3px; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--thread); }

.fields { width: 100%; border-collapse: collapse; margin-top: 14px; }
.fields th, .fields td { text-align: left; vertical-align: top; padding: 9px 0; border-top: 1px solid var(--rule); }
.fields th { font-variation-settings: var(--plain); font-weight: 600; width: 34%; font-size: 0.92rem; }
.fields td { font-variation-settings: var(--data); font-size: 0.9rem; }
.fields td .muted { color: var(--ink-soft); }

.swatch { flex-shrink: 0; display: inline-block; width: 44px; height: 44px; border-radius: 50%; background: var(--hair); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6), 0 0 0 1px var(--rule); vertical-align: middle; }
.swatch.small { width: 18px; height: 18px; box-shadow: 0 0 0 1px var(--rule); }

.note { font-variation-settings: var(--voice); font-size: 1.15rem; border-bottom: 1px solid var(--rule); padding: 8px 0; margin-top: 10px; }

button, .button {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; padding: 0 22px; border-radius: 999px;
  background: var(--moss); color: #fff;
  font: inherit; font-variation-settings: var(--plain); font-weight: 600; font-size: 1.02rem;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.12s ease;
}
button:hover, .button:hover { background: var(--moss-deep); }
button:active { transform: scale(0.985); }
button.outline, .button.outline { background: transparent; color: var(--moss); box-shadow: inset 0 0 0 2px var(--moss); }
button[disabled] { opacity: 0.55; cursor: progress; }
.actions { display: grid; gap: 10px; margin-top: 22px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; }
.chip { font-variation-settings: var(--data); font-size: 0.74rem; padding: 5px 10px; border-radius: 999px; background: #fff; box-shadow: 0 0 0 1px var(--rule); color: var(--ink-soft); }
.chip.on { background: var(--moss); color: #fff; box-shadow: none; }
.chip.done { color: var(--moss); box-shadow: 0 0 0 1px var(--moss); }

.photo { position: relative; border-radius: 12px; overflow: hidden; background: #dfe2dc; aspect-ratio: 3 / 4; touch-action: manipulation; }
.photo img, .photo canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.tap { position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 2px solid var(--thread); background: rgba(255, 255, 255, 0.55); pointer-events: none; animation: pop 0.25s ease-out; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.badge { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(255, 255, 255, 0.92); border-radius: 999px; padding: 4px 12px; font-variation-settings: var(--data); font-size: 0.74rem; white-space: nowrap; }

/* Try-on: today's tag on the left, wig tags on the thread to the right. */
.board { display: grid; grid-template-columns: 38% 1fr; gap: 14px; align-items: start; }
.board .today { position: sticky; top: 12px; }
.board .today .photo { aspect-ratio: 3 / 4; }
.label { font-variation-settings: var(--voice); font-size: 1.25rem; text-align: center; margin-top: 8px; }
.wigs { display: grid; gap: 14px; }
.wig { padding: 26px 12px 12px; margin-top: 18px; }
.wig .row { display: grid; grid-template-columns: 1fr 26px; gap: 8px; }
.wig .strip { border-radius: 6px; background: linear-gradient(180deg, var(--hair) 0 50%, var(--wig, #999) 50% 100%); }
.wig .meta { font-variation-settings: var(--data); font-size: 0.74rem; margin-top: 8px; line-height: 1.35; }
.wig .score { font-variation-settings: var(--plain); font-weight: 700; font-size: 1.35rem; }
.wig .verdict { text-decoration: underline; text-decoration-color: var(--thread); text-underline-offset: 3px; }
.wig button { min-height: 40px; font-size: 0.86rem; margin-top: 10px; }
.wig.kept::after { /* a small archive stamp, not a box: the tag has cut corners */
  content: "kept"; position: absolute; top: 34px; right: 16px; transform: rotate(-8deg);
  font-variation-settings: var(--data); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--thread); border: 2px solid var(--thread); border-radius: 6px; padding: 2px 7px; background: rgba(255, 255, 255, 0.85);
}

.catalog { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.catalog figure { margin: 0; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 1px var(--rule); cursor: pointer; }
.catalog figure img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; }
.catalog figcaption { font-variation-settings: var(--data); font-size: 0.66rem; padding: 6px; line-height: 1.25; }
.catalog figure.picked { box-shadow: 0 0 0 2px var(--moss); }

.notice { background: #fff; border-left: 3px solid var(--thread); border-radius: 8px; padding: 12px 14px; font-size: 0.92rem; color: var(--ink-soft); }
.quote { font-variation-settings: var(--voice); font-size: 1.1rem; color: var(--ink); }
.source { font-variation-settings: var(--data); font-size: 0.72rem; color: var(--ink-soft); }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

footer.small { margin-top: 40px; font-size: 0.78rem; color: var(--ink-soft); }
footer.small a { color: inherit; }

@media print {
  body { background: #fff; }
  header.top, .actions, .no-print { display: none !important; }
  .tag { filter: none; border: 1px solid var(--rule); background: #fff; }
}

/* ---------- Wow 1: the hanging mobile on the welcome screen ---------- */
.mobile { position: relative; height: clamp(340px, 46vh, 420px); margin: -20px -18px 6px; overflow: hidden;
  background: radial-gradient(ellipse 80% 60% at 50% 18%, #f6f7f3 0%, var(--lichen) 72%); }
.mobile::after { content: ""; position: absolute; inset: auto 0 0 0; height: 70px; background: linear-gradient(transparent, var(--lichen)); pointer-events: none; }
.hang { position: absolute; top: 0; left: var(--x); width: var(--w); margin-left: calc(var(--w) / -2); transform-origin: 50% 0; will-change: transform; cursor: grab; }
.hang .string { width: 2px; height: var(--len); margin: 0 auto; background: linear-gradient(var(--thread), #8d2c23); border-radius: 2px; }
.mini {
  position: relative; padding: 20px 8px 9px; margin-top: -3px;
  background:
    linear-gradient(135deg, transparent 13px, #fff 13.5px) top left / 51% 100% no-repeat,
    linear-gradient(225deg, transparent 13px, #fff 13.5px) top right / 51% 100% no-repeat;
  border-radius: 7px;
  filter: drop-shadow(0 12px 14px rgba(35, 38, 42, 0.16)) drop-shadow(0 2px 2px rgba(35, 38, 42, 0.08));
}
.mini::before { content: ""; position: absolute; top: 6px; left: 50%; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: var(--lichen); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25), 0 0 0 2px #f4f5f2; }
.mini img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 3px; }
.mini .cap { text-align: center; font-variation-settings: var(--data); font-size: 0.78rem; margin-top: 5px; }
.mini.today .cap { font-variation-settings: var(--voice); font-size: 1.05rem; }
h1.hero { font-size: 2.65rem; line-height: 1.04; margin: 0 0 10px; }

/* ---------- Wow 2: drag the red thread to try a wig on ---------- */
.compare { position: relative; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; background: #dfe2dc; --cut: 50%; }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.compare .after { clip-path: inset(0 0 0 var(--cut)); }
.compare .divider { position: absolute; top: -4%; bottom: -4%; left: var(--cut); width: 2px; margin-left: -1px; background: var(--thread); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35); }
.compare .knot { position: absolute; top: 56%; left: var(--cut); width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; cursor: ew-resize;
  background: radial-gradient(circle at 35% 32%, #cf5a4c, var(--thread) 60%, #7e241c); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 -2px 3px rgba(0, 0, 0, 0.25); }
.compare .knot::after { content: "⟷"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 0.8rem; opacity: 0.9; }
.compare .side { position: absolute; bottom: 10px; font-variation-settings: var(--data); font-size: 0.7rem; background: rgba(255, 255, 255, 0.88); border-radius: 999px; padding: 3px 9px; }
.compare .side.l { left: 10px; } .compare .side.r { right: 10px; }
.compare .veil { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(236, 238, 234, 0.55); backdrop-filter: blur(2px); }
.compare .veil button { width: auto; padding: 0 22px; }
.stamp { position: absolute; top: 46px; right: 18px; z-index: 3; transform: rotate(-9deg); font-variation-settings: var(--data); font-weight: 600; color: var(--thread);
  border: 2.5px solid var(--thread); border-radius: 8px; padding: 4px 10px; background: rgba(255, 255, 255, 0.86); line-height: 1.2; text-align: center; animation: stampin 0.32s cubic-bezier(.2, .9, .3, 1.4) both; }
.stamp b { display: block; font-size: 1.5rem; font-variation-settings: "CASL" 0, "MONO" 1; }
.stamp small { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
@keyframes stampin { from { transform: rotate(-24deg) scale(1.9); opacity: 0; } to { transform: rotate(-9deg) scale(1); opacity: 1; } }
.duo { display: grid; grid-template-columns: 1fr 1fr; height: 22px; border-radius: 6px; overflow: hidden; margin: 8px 0 4px; font-variation-settings: var(--data); font-size: 0.66rem; color: #fff; }
.duo span { display: grid; place-items: center; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.reel { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 18px 2px 10px; margin: 0 -18px; padding-left: 18px; scrollbar-width: none; }
.reel::-webkit-scrollbar { display: none; }
.reel .mini { flex: 0 0 86px; scroll-snap-align: start; cursor: pointer; transition: transform 0.18s ease; }
.reel .mini.on { transform: translateY(-6px); }
.reel .mini.on .cap { color: var(--thread); font-weight: 700; }
.reel .mini .kept-dot { position: absolute; top: 4px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--thread); }
@media (prefers-reduced-motion: reduce) { .stamp { animation: none; } }

/* ---------- Desktop: two panes from 1024 px. Below that .split and .pane are plain blocks, so the phone layout is untouched. ---------- */
@media (min-width: 1024px) {
  main:has(.split) { max-width: 1120px; padding: 28px 40px 120px; }
  .split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 56px; align-items: start; }
  .split > .pane > :first-child { margin-top: 0; }
  .split > .pane:first-child { position: sticky; top: 20px; }
  .split .pane > .tag:first-child { margin-top: 30px; }

  /* Welcome: the hanging mobile gets a stage of its own, the words sit beside it. */
  .split.welcome { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); align-items: center; }
  .split.welcome .mobile { margin: 0; height: 420px; border-radius: 12px; zoom: 1.4; } /* the same mobile, larger: threads and tags scale together */
  .split.welcome h1.hero { font-size: 3.3rem; }

  /* Try on: the photo with the thread on the left, the whole catalogue visible on the right. */
  .split.tryon { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); }
  .split.tryon .reel { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 12px; overflow: visible; margin: 0; padding: 22px 0 6px; }
  .split.tryon .reel .mini { flex: none; }
  .split.tryon .actions { grid-template-columns: 1fr 1fr; }
}
@media print { .split { display: block; } .split > .pane { position: static; } }
