/* Sparkcast fx: the animated layer over the kit (system.css + motion.css).
   Everything here comes from the brand: the gold, and the three-bar stack mark. Bars fill as a loader,
   gold sweeps a button once on hover, a licence key decodes into place, and cards rise in as they reach the
   viewport. Under prefers-reduced-motion nothing moves: colours change, nothing slides, scales or spins. */

:root {
  --fx-gold: var(--p-accent, #c9a45a);
  --fx-gold-soft: color-mix(in oklab, var(--fx-gold) 22%, transparent);
  --fx-ok: #6fcf8f;
  --fx-warn: #e0a84f;
  --fx-bad: #ff6b5b;
  --fx-ease: cubic-bezier(.22, 1, .36, 1);
  --fx-spring: cubic-bezier(.34, 1.56, .64, 1);
}

/* ------------------------------------------------------------------ entrances */
@keyframes fx-rise { from { opacity: 0; transform: translateY(18px); filter: blur(6px); } }
@keyframes fx-fade { from { opacity: 0; } }
@keyframes fx-pop { 0% { opacity: 0; transform: scale(.92); } 60% { opacity: 1; transform: scale(1.02); } 100% { transform: none; } }
@keyframes fx-slide-down { from { opacity: 0; transform: translateY(-10px); clip-path: inset(0 0 100% 0); } }

/* a block that arrives on load: its children follow one after another */
.fx-rise > * { animation: fx-rise .7s var(--fx-ease) both; }
.fx-rise > *:nth-child(2) { animation-delay: .07s; }
.fx-rise > *:nth-child(3) { animation-delay: .14s; }
.fx-rise > *:nth-child(4) { animation-delay: .21s; }
.fx-rise > *:nth-child(n + 5) { animation-delay: .28s; }
.stack-form.fx-rise-fields > *, .auth .stack-form > * { animation: fx-rise .6s var(--fx-ease) both; }
.auth .stack-form > *:nth-child(1) { animation-delay: .18s; }
.auth .stack-form > *:nth-child(2) { animation-delay: .24s; }
.auth .stack-form > *:nth-child(3) { animation-delay: .30s; }
.auth .stack-form > *:nth-child(4) { animation-delay: .36s; }
.auth .stack-form > *:nth-child(n + 5) { animation-delay: .42s; }

/* list items rendered by the page scripts: they set --i on each */
.fx-item { animation: fx-rise .55s var(--fx-ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
.fx-out { transition: opacity .25s, transform .25s var(--fx-ease); opacity: 0; transform: translateX(16px); }

/* the page title of every inner page draws a short gold rule under itself */
main.page h1 { position: relative; }
main.page .page-head h1::after, main.page .auth h1::after, main.page .dash-head h1::after {
  content: ""; display: block; width: 56px; height: 3px; margin-top: var(--s-4, 16px); border-radius: 3px;
  background: var(--fx-gold); transform-origin: left; animation: fx-rule .9s .25s var(--fx-ease) both;
}
@keyframes fx-rule { from { transform: scaleX(0); } }

/* blocks further down rise as they scroll in (browsers with scroll-driven animations; others just show them) */
@supports (animation-timeline: view()) {
  main.page :is(.block, .panel-box, .release, .frame-16x9, .steps-list > li, .note, .prose > h2, .table-wrap),
  main > section :is(.card, .rows > *, .faq__item, .frame, .section-head) {
    animation: fx-rise linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 55%;
  }
}

/* ------------------------------------------------------------------ buttons */
/* gold sweep: a light band crosses the primary button once per hover */
.btn--primary, .btn.btn-primary { overflow: hidden; isolation: isolate; }
.btn--primary::before, .btn.btn-primary::before {
  content: ""; position: absolute; inset: -2px; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .55) 48%, rgba(255, 255, 255, .15) 54%, transparent 70%);
  transform: translateX(-120%); transition: transform 0s;
}
@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover::before, .btn.btn-primary:hover::before { transform: translateX(120%); transition: transform .75s var(--fx-ease); }
  .btn--primary:hover { box-shadow: 0 8px 28px -10px color-mix(in oklab, var(--fx-gold) 70%, transparent); }
}
.btn { transition: transform .12s var(--fx-ease), box-shadow .3s var(--fx-ease), background-color .15s, color .15s, border-color .15s, opacity .2s; }
.btn:active { transform: translateY(1px) scale(.97); }

/* loading: the label keeps the width, the stack-mark loader runs over it */
.btn--fx { position: relative; }
.btn--fx .spark-loader { position: absolute; left: 50%; top: 50%; translate: -50% -50%; opacity: 0; transition: opacity .15s; }
.btn--fx .btn__label { transition: opacity .15s, transform .25s var(--fx-ease); }
.btn--fx.is-busy .btn__label { opacity: 0; transform: translateY(-6px); }
.btn--fx.is-busy .spark-loader { opacity: 1; }
.btn--fx.is-busy::after { opacity: 0; }
.btn.is-busy { cursor: progress; }
.btn:disabled:not(.is-busy) { opacity: .55; }

/* ------------------------------------------------------------------ the stack-mark loader */
.spark-loader { display: inline-grid; gap: 3px; width: 26px; }
.spark-loader i { display: block; height: 5px; border-radius: 3px; background: currentColor; transform-origin: left;
  animation: fx-bar 1.1s var(--fx-ease) infinite; }
.spark-loader i:nth-child(1) { width: 100%; }
.spark-loader i:nth-child(2) { width: 70%; animation-delay: .12s; }
.spark-loader i:nth-child(3) { width: 40%; animation-delay: .24s; }
@keyframes fx-bar { 0% { transform: scaleX(.15); opacity: .35; } 45% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(.15); opacity: .35; } }
.verify-state > .spark-loader { width: 48px; gap: 6px; color: var(--fx-gold); margin-bottom: var(--s-6, 24px); }
.verify-state > .spark-loader i { height: 9px; border-radius: 5px; }

/* the logo mark in the nav breathes once on load, its bars arriving in order */
.nav__logo .mark { animation: fx-pop .6s .1s var(--fx-spring) both; }

/* ------------------------------------------------------------------ form fields */
.field label, .field legend { transition: color .2s; }
.field:focus-within > label { color: var(--fx-gold); }
.field :is(input, select, textarea), .inline-form input, .toolbar input {
  transition: border-color .2s, box-shadow .3s var(--fx-ease), background-color .2s;
}
.field :is(input, select, textarea):hover:not(:disabled), .inline-form input:hover, .toolbar input:hover { border-color: color-mix(in oklab, var(--fx-gold) 45%, var(--line-strong)); }
.field :is(input, select, textarea):focus, .inline-form input:focus, .toolbar input:focus {
  outline: none; border-color: var(--fx-gold); box-shadow: 0 0 0 4px var(--fx-gold-soft);
}
.field input:disabled { opacity: .6; cursor: not-allowed; }

/* password: show/hide button inside the field */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 48px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; translate: 0 -50%; width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; transition: color .2s, background-color .2s; }
.pw-toggle:hover { color: var(--ink); background: var(--surface); }
.pw-toggle svg { width: 20px; height: 20px; }
.pw-toggle[aria-pressed="true"] { color: var(--fx-gold); }
.pw-toggle[aria-pressed="true"] svg path { stroke-dasharray: 2 2.4; }

/* password meter: four segments fill and recolour */
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 2px; }
.pw-meter i { height: 4px; border-radius: 2px; background: var(--line-strong); position: relative; overflow: hidden; }
.pw-meter i::after { content: ""; position: absolute; inset: 0; background: var(--meter, var(--fx-gold)); transform: scaleX(0); transform-origin: left;
  transition: transform .35s var(--fx-ease), background-color .3s; }
.pw-meter[data-level="1"] { --meter: var(--fx-bad); }
.pw-meter[data-level="2"] { --meter: var(--fx-warn); }
.pw-meter[data-level="3"] { --meter: var(--fx-gold); }
.pw-meter[data-level="4"] { --meter: var(--fx-ok); }
.pw-meter[data-level="1"] i:nth-child(-n + 1)::after,
.pw-meter[data-level="2"] i:nth-child(-n + 2)::after,
.pw-meter[data-level="3"] i:nth-child(-n + 3)::after,
.pw-meter[data-level="4"] i::after { transform: scaleX(1); }
.pw-meter i:nth-child(2)::after { transition-delay: .04s; }
.pw-meter i:nth-child(3)::after { transition-delay: .08s; }
.pw-meter i:nth-child(4)::after { transition-delay: .12s; }

/* custom checkbox: a gold box that ticks itself */
.check input[type="checkbox"] { appearance: none; -webkit-appearance: none; flex: none; width: 20px; height: 20px; margin: 0; border-radius: 6px;
  border: 1.5px solid var(--line-strong); background: var(--bg); display: grid; place-items: center; cursor: pointer;
  transition: background-color .2s, border-color .2s, box-shadow .3s var(--fx-ease); }
.check input[type="checkbox"]::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--p-accent-ink, #0c0a08); border-top: 0; border-right: 0;
  transform: translateY(-1px) rotate(-45deg) scale(0); transition: transform .25s var(--fx-spring); }
.check input[type="checkbox"]:checked { background: var(--fx-gold); border-color: var(--fx-gold); }
.check input[type="checkbox"]:checked::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
.check input[type="checkbox"]:focus-visible { box-shadow: 0 0 0 4px var(--fx-gold-soft); }
.check--terms { align-items: flex-start; margin: 0; font-size: var(--t-small); line-height: 1.5; }
.check--terms .link::after { content: none; }
.check--terms .link { display: inline; min-height: 0; }

/* messages slide in; an error shakes its form once */
.form-msg.is-in { animation: fx-slide-down .35s var(--fx-ease) both; }
.form-msg.ok::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--fx-ok); vertical-align: middle; }
@keyframes fx-shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); } }
.fx-shake { animation: fx-shake .45s both; }

/* ------------------------------------------------------------------ badges */
.badge.ok { background: color-mix(in oklab, var(--fx-ok) 16%, var(--bg)); color: var(--ink); gap: 7px; }
.badge.ok::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--fx-ok); animation: fx-ping 2.2s infinite; }
@keyframes fx-ping { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--fx-ok) 70%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }
.badge.warn { background: color-mix(in oklab, var(--fx-warn) 20%, var(--bg)); color: var(--ink); }
.badge.bad { background: color-mix(in oklab, var(--fx-bad) 25%, var(--bg)); color: var(--ink); }

/* ------------------------------------------------------------------ licences and cards */
.lic { position: relative; transition: transform .35s var(--fx-ease), box-shadow .35s var(--fx-ease); }
.lic::before { content: ""; position: absolute; left: 0; top: 18%; bottom: 18%; width: 3px; border-radius: 3px; background: var(--fx-gold);
  transform: scaleY(0); transition: transform .4s var(--fx-ease); }
@media (hover: hover) and (pointer: fine) {
  .lic:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -24px rgba(0, 0, 0, .9), 0 0 0 1px var(--line); }
  .lic:hover::before { transform: scaleY(1); }
}
.machines-head { display: flex; align-items: center; gap: 6px; }
.slots { display: inline-flex; gap: 4px; margin-left: 6px; }
.slots i { width: 18px; height: 6px; border-radius: 3px; background: var(--line-strong); }
.slots i.on { background: var(--fx-gold); animation: fx-fill .6s var(--fx-ease) both; transform-origin: left; }
.slots i.on:nth-child(2) { animation-delay: .1s; }
.slots i.on:nth-child(3) { animation-delay: .2s; }
@keyframes fx-fill { from { transform: scaleX(0); } }
.lic .machines ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; }
.lic .machines li { align-items: center; padding-block: var(--s-2); }

/* ------------------------------------------------------------------ verification */
.verify-banner { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-7);
  padding: var(--s-5) var(--s-6); border-radius: var(--r-lg); background: color-mix(in oklab, var(--fx-gold) 12%, var(--surface));
  box-shadow: inset 3px 0 0 var(--fx-gold); animation: fx-slide-down .5s .2s var(--fx-ease) both; }
.verify-banner > div:first-child { flex: 1 1 320px; }
.dev-link { flex-basis: 100%; display: grid; gap: var(--s-1); margin-top: var(--s-4); padding: var(--s-4); border-radius: var(--r-md);
  border: 1px dashed color-mix(in oklab, var(--fx-gold) 50%, transparent); font-size: var(--t-small); word-break: break-all;
  animation: fx-rise .5s var(--fx-ease) both; }
.dev-link .t-label { color: var(--fx-gold); }

.verify-state { display: grid; justify-items: start; gap: var(--s-4); }
.verify-state[hidden] { display: none; }
.fx-check { width: 64px; height: 64px; }
.fx-check circle { fill: none; stroke: var(--fx-ok); stroke-width: 2.5; stroke-dasharray: 151; stroke-dashoffset: 151;
  animation: fx-draw .7s var(--fx-ease) forwards; }
.fx-check path { fill: none; stroke: var(--fx-ok); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40; animation: fx-draw .45s .55s var(--fx-ease) forwards; }
@keyframes fx-draw { to { stroke-dashoffset: 0; } }

.trial-card { position: relative; display: grid; gap: var(--s-3); width: 100%; padding: var(--s-6); border-radius: var(--r-lg);
  background: var(--surface); overflow: hidden; isolation: isolate; animation: fx-pop .6s .35s var(--fx-spring) both; }
.trial-card::before { content: ""; position: absolute; inset: 0; z-index: -1; padding: 1px; border-radius: inherit;
  background: linear-gradient(120deg, transparent 20%, var(--fx-gold) 45%, transparent 70%) 0 0 / 300% 100%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: fx-border 2.4s .6s var(--fx-ease) both; }
@keyframes fx-border { from { background-position: 100% 0; } to { background-position: 0 0; } }
.trial-card .t-label { color: var(--fx-gold); }
.trial-card { container-type: inline-size; }
.key-reveal { font-size: min(28px, 6cqi); letter-spacing: .04em; white-space: nowrap; color: var(--ink); min-height: 1.3em; }

/* ------------------------------------------------------------------ account settings */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); }
.settings-grid .panel-box + .panel-box { margin-top: 0; }
.settings-wide { grid-column: 1 / -1; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }
.settings-grid h3 { margin-bottom: var(--s-5); }
.row-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); margin-bottom: var(--s-4); }
.row-head h3 { margin: 0; }
.sessions { list-style: none; margin: 0; padding: 0; display: grid; }
.sessions li { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); flex-wrap: wrap; padding: var(--s-3) 0; border-top: 1px solid var(--line); }
.sessions li > span:first-child { display: inline-flex; align-items: center; gap: var(--s-3); }
.danger-zone { box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--fx-bad) 30%, transparent); }
.danger-zone h3 { color: color-mix(in oklab, var(--fx-bad) 80%, var(--ink)); margin-bottom: var(--s-3); }
.danger-zone .inline-form { margin-top: var(--s-4); }
.forgot { justify-self: end; margin-top: calc(var(--s-3) * -1); }

/* admin users table */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); background: var(--surface); margin-bottom: var(--s-4); }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--t-small); }
.data-table th { text-align: left; font-weight: 500; color: var(--muted); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table td .badge { margin-left: var(--s-2); }
.data-table tbody tr { transition: background-color .2s; }
.data-table tbody tr:hover { background: color-mix(in oklab, var(--fx-gold) 6%, transparent); }

/* ------------------------------------------------------------------ links */
.footer__col a, .footer__legal a { background: linear-gradient(currentColor 0 0) left bottom / 0 1px no-repeat; transition: background-size .35s var(--fx-ease), color .2s; }
.footer__col a:hover, .footer__legal a:hover { background-size: 100% 1px; color: var(--fx-gold); }

/* ------------------------------------------------------------------ reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .spark-loader i { transform: none; opacity: 1; }
}
