/* Motion Lab, gallery + previews. Every animation is written here; the registry
   in src/recipes.js holds the copyable version. */

:root {
  --motion-dur: 600ms;
  --motion-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --accent-text: #f5c26b;
}
.theme-light { --accent-text: #7a4d00; }
a, .eyebrow { color: var(--accent-text); }
body { overflow-x: hidden; }

.lab-main { max-width: 1240px; margin: 0 auto; padding: 28px 32px 90px; }
.lab-nav { display: flex; gap: 20px; margin-left: 18px; }
.lab-nav a { color: var(--muted); font-size: 13px; font-weight: 500; }
.lab-nav a.active, .lab-nav a:hover { color: var(--text); text-decoration: none; }

.eyebrow { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; font-weight: 600; margin-bottom: 10px; }
.lab-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr); gap: 34px; align-items: center; }
.lab-hero h1 { font-size: clamp(34px, 3.9vw, 52px); line-height: 1.04; letter-spacing: -0.035em; margin: 6px 0 14px; }
.lab-hero h1 em { font-style: normal; color: var(--accent-text); }
.lab-hero .lede { font-size: 16.5px; max-width: 54ch; }
.lab-facts { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 20px; font-size: 12px; color: var(--muted); }
.lab-facts b { color: var(--text); font-family: var(--font-display); font-size: 16px; margin-right: 4px; }

.stage-card { border: 1px solid var(--line-strong); border-radius: 18px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); box-shadow: var(--shadow); overflow: hidden; }
.stage-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: 11px; color: var(--muted); }
.stage-head .spacer { flex: 1; }
.stage { position: relative; min-height: 230px; display: grid; place-items: center; padding: 22px; background: radial-gradient(440px 200px at 50% 0%, rgba(245, 194, 107, 0.06), transparent 70%), var(--bg); overflow: hidden; }
.stage-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--surface); font-size: 11.5px; color: var(--muted); }
.stage-controls label { display: flex; align-items: center; gap: 7px; }
.stage-controls input[type="range"] { width: 120px; accent-color: var(--gold); }
.stage-controls select { width: auto; padding: 5px 26px 5px 8px; font-size: 11.5px; }
.stage-controls .val { font-family: var(--font-mono); color: var(--text-2); min-width: 44px; }
.stage-controls .spacer { flex: 1; }
.reduced-note { position: absolute; inset: auto 10px 8px 10px; text-align: center; font-size: 10px; color: var(--muted); }

.section-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 42px 0 14px; }
.section-head h2 { margin: 0; font-size: clamp(22px, 2.2vw, 28px); }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); font: 600 12px/1 var(--font-sans); cursor: pointer; }
.chip.active { color: var(--accent-text); border-color: var(--gold-line); background: var(--gold-soft); }

.recipe-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.recipe-card { display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; cursor: pointer; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; transition: border-color 0.15s, transform 0.15s; }
.recipe-card:hover { border-color: var(--gold-line); transform: translateY(-2px); }
.recipe-card .pv { width: 100%; height: 132px; display: flex; align-items: center; justify-content: center; padding: 14px; background: radial-gradient(220px 120px at 50% 0%, rgba(58, 123, 255, 0.06), transparent 70%), var(--bg); border-bottom: 1px solid var(--line); overflow: hidden; }
.recipe-card .pv > * { width: 100%; max-width: 230px; }
.recipe-body { padding: 11px 13px 13px; display: flex; flex-direction: column; gap: 4px; }
.recipe-body h3 { margin: 0; font-size: 13.5px; color: var(--text); }
.recipe-body p { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recipe-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.recipe-foot .dot { color: var(--gold); }

/* ---------------------------------------------------------------- playground */
.play-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 18px; align-items: start; margin-top: 18px; }
.play-stage { min-height: 470px; background: radial-gradient(520px 260px at 50% 0%, rgba(245, 194, 107, 0.07), transparent 70%), var(--bg); }
.play-side { display: flex; flex-direction: column; gap: 14px; }
.play-side .card { padding: 16px; }
.play-side h3 { margin: 0 0 6px; font-size: 14px; }
.play-side p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.play-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.play-head h2 { margin: 0; font-size: clamp(22px, 2.2vw, 28px); }
.play-head .badge { margin-left: 0; }
.code-wrap { position: relative; }
.code-wrap pre.code { margin: 0; max-height: 320px; font-size: 11.5px; }
.copy-btn { position: absolute; top: 8px; right: 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: rgba(10, 14, 23, 0.9); color: var(--text-2); font: 600 11px/1 var(--font-sans); padding: 5px 8px; cursor: pointer; }
.copy-btn:hover { color: var(--text); border-color: var(--gold-line); }
.play-pager { display: flex; gap: 8px; margin-top: 12px; }
.play-pager .btn { flex: 1; }
.recipe-note { border-left: 2px solid var(--gold-line); padding-left: 10px; font-size: 12px; color: var(--muted); }
.trigger-pill { font-family: var(--font-mono); font-size: 10.5px; color: var(--accent-text); }

/* ---------------------------------------------------------------- preview primitives */
.pv { display: flex; flex-direction: column; gap: 7px; align-items: center; justify-content: center; width: 100%; max-width: 230px; }
.docs-footer { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.docs-footer a { color: var(--muted); font-weight: 600; }
.docs-footer a:hover { color: var(--accent-text); }
.pv-card { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); padding: 10px 11px; }
.pv-line { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.18); }
.pv-line.short { width: 55%; }
.pv-line.gold { background: linear-gradient(90deg, #e0a94a, var(--gold)); }
.pv-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); white-space: nowrap; }
.pv-sub { font-size: 10px; color: var(--muted); }
.pv-row { display: flex; align-items: center; gap: 8px; width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: var(--surface); }
.pv-row .dotmark { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-3); flex: none; }
.pv-row .bar { height: 5px; border-radius: 99px; background: var(--surface-3); flex: 1; }
.pv-row .bar.gold { background: var(--gold); }
.pv-btn { padding: 9px 18px; border: 0; border-radius: 99px; background: var(--gold); color: #1a1405; font: 700 12px/1 var(--font-sans); cursor: pointer; position: relative; overflow: hidden; }
.pv-btn.blue { background: var(--blue); color: #fff; }
.pv-plus { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line-strong); display: grid; place-items: center; color: var(--gold); font-size: 20px; transition: transform var(--motion-dur) var(--motion-ease); }
.pv-plus:hover { transform: rotate(45deg); }
.pv-mini { width: 100%; height: 26px; border-radius: 7px; background: var(--surface-3); overflow: hidden; }
.pv-mini > i { display: block; height: 100%; width: 40%; border-radius: inherit; background: linear-gradient(90deg, #e0a94a, var(--gold)); }
.pv-skeleton { width: 100%; display: flex; flex-direction: column; gap: 7px; }
.pv-skeleton .sk { height: 9px; border-radius: 5px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: labShimmer 1.4s linear infinite; }
.pv-spinner { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--surface-3); border-top-color: var(--gold); animation: labSpin 0.9s linear infinite; position: relative; }
.pv-spinner::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; border: 1px solid transparent; border-bottom-color: var(--blue); animation: labSpin 1.4s linear infinite reverse; }
.pv-dots { display: flex; gap: 6px; }
.pv-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); animation: labTyping 1.1s var(--motion-ease) infinite; }
.pv-dots i:nth-child(2) { animation-delay: 120ms; }
.pv-dots i:nth-child(3) { animation-delay: 240ms; }
.pv-tl { display: flex; flex-direction: column; gap: 0; width: 70%; }
.pv-tl .tl-step { display: flex; gap: 9px; align-items: flex-start; }
.pv-tl .tl-mark { display: flex; flex-direction: column; align-items: center; }
.pv-tl .tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }
.pv-tl .tl-line { width: 1px; height: 20px; background: var(--line-strong); transform-origin: top; }
.pv-tl .tl-label { font-size: 10px; color: var(--muted); }
.pv-tabs { display: flex; flex-direction: column; gap: 8px; width: 75%; }
.pv-tabhead { display: flex; gap: 5px; }
.pv-tabhead i { flex: 1; height: 18px; border-radius: 5px; background: var(--surface-3); }
.pv-tabhead i.on { background: var(--gold-soft); border: 1px solid var(--gold-line); }
.pv-tabpanels { position: relative; height: 52px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.pv-tabpanels div { position: absolute; inset: 9px; border-radius: 5px; background: var(--surface-2); opacity: 0; transition: opacity var(--motion-dur) var(--motion-ease); }
.pv-tabpanels div:first-child { opacity: 1; }
.pv-tabs:hover .pv-tabpanels div:first-child { opacity: 0; }
.pv-tabs:hover .pv-tabpanels div:last-child { opacity: 1; }
.pv-bars { display: flex; align-items: flex-end; gap: 6px; height: 64px; }
.pv-bars i { width: 14px; border-radius: 3px 3px 1px 1px; background: linear-gradient(180deg, var(--gold), rgba(245, 194, 107, 0.25)); transform-origin: bottom; }
.pv-number { font-family: var(--font-display); font-size: 34px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.pv-chart { width: 120px; height: 62px; overflow: visible; }
.pv-chart path { fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linecap: round; }
.pv-page { width: 130px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface-2); padding: 8px; display: flex; flex-direction: column; gap: 5px; }
.pv-modal { width: 150px; border: 1px solid var(--gold-line); border-radius: 10px; background: var(--surface-2); padding: 10px; box-shadow: var(--shadow-soft); }
.pv-accordion { width: 170px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface-2); overflow: hidden; }
.pv-accordion .acc-head { display: flex; justify-content: space-between; padding: 9px 11px; font-size: 11px; color: var(--text-2); }
.pv-accordion .acc-head span { transition: transform var(--motion-dur) var(--motion-ease); }
.pv-accordion .acc-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--motion-dur) var(--motion-ease); }
.pv-accordion:hover .acc-body { grid-template-rows: 1fr; }
.pv-accordion:hover .acc-head span { transform: rotate(180deg); }
.pv-accordion .acc-body > div { overflow: hidden; font-size: 10px; color: var(--muted); padding: 0 11px; }
.pv-accordion:hover .acc-body > div { padding-bottom: 10px; }

/* animations used by previews (the registry ships the copyable version) */
@keyframes labFade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes labClip { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes labScale { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes labBlur { from { opacity: 0; filter: blur(6px); } to { opacity: 1; filter: blur(0); } }
@keyframes labStagger { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes labCascade { from { opacity: 0; transform: translateY(14px) rotate(-3deg); } to { opacity: 1; transform: none; } }
@keyframes labGrowLine { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes labShimmer { to { background-position: -400% 0; } }
@keyframes labSpin { to { transform: rotate(360deg); } }
@keyframes labTyping { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(-4px); } }
@keyframes labIndeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(380%); } }
@keyframes labPageIn { from { transform: translateX(22px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes labModalIn { from { transform: translateY(12px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes labBarGrow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes labDraw { to { stroke-dashoffset: 0; } }

.pv.go .a-fade { animation: labFade var(--motion-dur) var(--motion-ease) both; }
.pv.go .a-clip { animation: labClip var(--motion-dur) var(--motion-ease) both; }
.pv.go .a-scale { animation: labScale var(--motion-dur) var(--motion-ease) both; }
.pv.go .a-blur { animation: labBlur var(--motion-dur) var(--motion-ease) both; }
.pv.go .a-stagger { animation: labStagger var(--motion-dur) var(--motion-ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
.pv.go .a-cascade { animation: labCascade var(--motion-dur) var(--motion-ease) both; animation-delay: calc(var(--i, 0) * 100ms); }
.pv.go .a-growline { animation: labGrowLine var(--motion-dur) var(--motion-ease) both; }
.pv.go .a-page { animation: labPageIn var(--motion-dur) var(--motion-ease) both; }
.pv.go .a-modal { animation: labModalIn var(--motion-dur) var(--motion-ease) both; }
.pv.go .a-bar { animation: labBarGrow var(--motion-dur) var(--motion-ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
.pv.go .a-draw { stroke-dasharray: 220; stroke-dashoffset: 220; animation: labDraw var(--motion-dur) var(--motion-ease) forwards; }
.pv .a-magnet { transition: transform var(--motion-dur) var(--motion-ease); }
.pv .a-magnet:hover { transform: translate(4px, -3px); }
.pv .a-squish:active { transform: scale(0.94); }
.pv .a-shine::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.45) 50%, transparent 65%); transform: translateX(-130%); transition: transform var(--motion-dur) var(--motion-ease); }
.pv .a-shine:hover::after { transform: translateX(130%); }
.pv .a-progressbar { width: 70%; }
.pv.go .a-progressbar > i { animation: labIndeterminate 1.4s var(--motion-ease) infinite; }
.pv .a-tab { opacity: 1; transition: opacity var(--motion-dur) var(--motion-ease); }
.pv .a-tab:hover { opacity: 0.55; }

/* reduced motion: same rule the docs promise, demonstrated by the toggle */
.reduced .pv *, .reduced .stage * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .lab-hero { grid-template-columns: 1fr; }
  .recipe-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .play-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .lab-nav { display: none; }
  .lab-main { padding: 22px 16px 70px; }
  .recipe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lab-topbar .badge { display: none; }
}
@media (max-width: 520px) {
  .recipe-grid { grid-template-columns: 1fr; }
  .stage-controls label.speed { flex: 1; }
  .stage-controls input[type="range"] { width: 100%; }
  .lab-hero h1 { font-size: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  .pv *, .stage * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* Playground stage scales the preview so it reads at the larger size. */
.play-stage .pv { transform: scale(1.7); max-width: 260px; }
.play-stage .pv-title { font-size: 28px; }
@media (max-width: 820px) { .play-stage .pv { transform: scale(1.2); } }
