/* Ace of Fades — Style Finder
   Palette taken from the shop itself: midnight walls, cobalt LED cove light, oak panelling, the amber from their own posts. */
:root {
  --midnight: #0E1424;
  --raised: #161D33;
  --line: #2A3352;
  --cobalt: #4F5DFF;
  --cobalt-glow: rgba(79, 93, 255, 0.35);
  --oak: #B9834F;
  --amber: #F3AE45;
  --bone: #F1ECE4;
  --smoke: #A3A9BC;
  --display: 'Ultra', 'Rockwell Extra Bold', 'Clarendon', Georgia, serif;
  --text: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter: clamp(16px, 4vw, 40px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--midnight);
  color: var(--bone);
  font: 400 1.0625rem/1.55 var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 3px; border-radius: 4px; }

/* The shared site header, footer and bottom bar come from /css/site.css.
   Rules below are scoped to .sf so they don't restyle the shared parts. */

/* Layout */
.sf {
  flex: 1;
  width: 100%; max-width: 1180px; margin: 0 auto;
  padding: clamp(20px, 4vw, 56px) var(--gutter) 48px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}
@media (min-width: 880px) {
  .sf { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); column-gap: 56px; row-gap: 56px; align-items: start; }
  .stage-col { position: sticky; top: 24px; }
  .cuts { grid-column: 1 / -1; }
}

/* Stage: where the photo and the face map appear */
.stage {
  position: relative;
  aspect-ratio: 3 / 4;
  max-height: 68vh;
  margin-inline: auto;
  width: 100%;
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(120% 60% at 50% -10%, var(--cobalt-glow), transparent 60%),
    var(--raised);
  border: 1px solid var(--line);
  display: grid; place-items: center;
}
.guide { width: 72%; height: auto; }
.guide ellipse { fill: none; stroke: var(--oak); stroke-width: 2; stroke-dasharray: 6 8; opacity: 0.8; }
.stage[data-state="photo"] .guide,
.stage[data-state="result"] .guide { display: none; }
.stage-hint {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0;
  padding: 14px 18px; font-size: 0.9rem; color: var(--smoke); text-align: center;
}
.stage[data-state="photo"] .stage-hint,
.stage[data-state="result"] .stage-hint,
.stage[data-state="error"] .stage-hint,
.stage[data-state="error"] .guide { display: none; }
.stage[data-state="error"] .frame { opacity: 0.45; }
[tabindex="-1"]:focus { outline: none; }

.frame { position: absolute; inset: 0; }
.frame canvas, .frame svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.frame canvas { object-fit: cover; }

.overlay .oval { fill: none; stroke: var(--cobalt); stroke-width: 3; stroke-linejoin: round; filter: drop-shadow(0 0 6px var(--cobalt)); }
.overlay .dot { fill: var(--bone); opacity: 0.55; }
.overlay .measure { stroke: var(--amber); stroke-width: 2.5; stroke-linecap: round; }
.overlay .tick { fill: var(--amber); }
.overlay .tag rect { fill: rgba(14, 20, 36, 0.82); }
.overlay .tag text { fill: var(--bone); font-family: var(--text); font-weight: 600; }

/* Scanning sweep while the face is mapped */
.scanline { position: absolute; left: 0; right: 0; top: 0; height: 22%; pointer-events: none; opacity: 0;
  background: linear-gradient(to bottom, transparent, rgba(79, 93, 255, 0.28) 70%, var(--cobalt) 100%); }
.stage[data-state="photo"] .scanline { opacity: 1; animation: sweep 1.6s ease-in-out infinite alternate; }
@keyframes sweep { from { transform: translateY(-30%); } to { transform: translateY(380%); } }

/* Text column */
.sf h1, .sf h2 { font-family: var(--display); font-weight: 400; letter-spacing: 0.005em; margin: 0; }
.sf h1 { font-size: clamp(2.4rem, 6.4vw, 4.1rem); line-height: 1.02; max-width: 12ch; }
.sf .lede { margin: 18px 0 26px; max-width: 46ch; color: var(--smoke); font-size: 1.125rem; }

.seg { border: 0; padding: 0; margin: 0 0 22px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg legend { float: left; margin-right: 6px; color: var(--smoke); font-size: 0.95rem; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: inline-block; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); font-weight: 500; }
.seg input:checked + span { background: var(--bone); color: var(--midnight); border-color: var(--bone); }
.seg input:focus-visible + span { outline: 3px solid var(--cobalt); outline-offset: 2px; }

.sf .actions { display: flex; flex-wrap: wrap; gap: 12px; }
.sf .btn {
  appearance: none; border: 0; cursor: pointer; font: 600 1rem var(--text);
  padding: 15px 24px; border-radius: 12px; min-height: 52px;
}
.sf .btn-primary { background: var(--amber); color: var(--midnight); }
.sf .btn-primary:hover { background: #F7BE62; }
.sf .btn-quiet { background: transparent; color: var(--bone); border: 1px solid var(--line); }
.sf .btn-quiet:hover { border-color: var(--bone); }
.sf .privacy { margin: 18px 0 0; font-size: 0.92rem; color: var(--smoke); padding-left: 14px; border-left: 2px solid var(--oak); max-width: 44ch; }

.sf .status { font-size: 1.25rem; margin: 8px 0; }

#error h2 { font-size: clamp(1.8rem, 4.5vw, 2.6rem); line-height: 1.08; }
#error p { color: var(--smoke); margin: 14px 0 24px; max-width: 46ch; }

/* Result */
.result-intro { margin: 0; color: var(--smoke); font-size: 1.1rem; }
/* Sized to the column so the longest name ("Diamond") never overflows */
.copy-col { container-type: inline-size; }
.shape-name { font-size: clamp(3rem, 10vw, 6rem); font-size: clamp(3rem, 17cqi, 8rem); line-height: 0.95; color: var(--amber); margin: 6px 0 4px; }
.shape-hint { margin: 0 0 6px; color: var(--bone); font-weight: 500; }
.about { margin: 16px 0 26px; max-width: 48ch; font-size: 1.1rem; }

.measures { margin: 0; display: grid; grid-template-columns: max-content 1fr; border-top: 1px solid var(--line); max-width: 520px; }
.measures dt, .measures dd { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line); }
.measures dt { color: var(--smoke); padding-right: 24px; }
.measures dd { font-weight: 500; }

/* Cuts */
.cuts h2 { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.05; margin-bottom: 22px; }
.cut-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
@media (min-width: 880px) { .cut-list { grid-template-columns: repeat(3, 1fr); gap: 22px; } }
.cut {
  display: grid; grid-template-columns: 104px 1fr; gap: 16px; align-items: start;
  padding: 12px; border-radius: 16px; background: var(--raised); border: 1px solid var(--line);
}
@media (min-width: 880px) { .cut { grid-template-columns: 1fr; padding: 0 0 18px; overflow: hidden; } }
.cut img { width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 10px; background: var(--line); }
@media (min-width: 880px) { .cut img { border-radius: 0; } .cut .cut-body { padding: 0 18px; } }
.cut h3 { margin: 2px 0 6px; font-size: 1.1rem; line-height: 1.3; }
.cut p { margin: 0 0 12px; color: var(--smoke); font-size: 0.97rem; }
.cut a { color: var(--amber); font-weight: 600; text-decoration: none; display: inline-block; padding: 6px 0; }
.cut a:hover { text-decoration: underline; text-underline-offset: 4px; }
.cut .first { display: inline-block; font-size: 0.82rem; color: var(--midnight); background: var(--bone); padding: 2px 8px; border-radius: 999px; margin-bottom: 6px; }
.sf .note { color: var(--smoke); font-size: 0.95rem; margin: 22px 0; max-width: 60ch; }

/* The one orchestrated moment: the face map draws itself */
.overlay.animate .oval { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: trace 1.1s ease-out forwards; }
.overlay.animate .dot { opacity: 0; animation: appear 0.6s ease-out forwards; }
.overlay.animate .m { opacity: 0; animation: appear 0.35s ease-out forwards; }
.result-reveal { animation: rise 0.5s ease-out both; }
@keyframes trace { to { stroke-dashoffset: 0; } }
@keyframes appear { to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .stage[data-state="photo"] .scanline { animation: none; opacity: 0.6; top: 39%; }
  .overlay.animate .oval, .overlay.animate .dot, .overlay.animate .m, .result-reveal { animation: none; opacity: 1; stroke-dashoffset: 0; }
  .overlay.animate .dot { opacity: 0.55; }
}
