/* Affection Style Quiz (Tool 10, prefix aq-) — the stepped quiz and the funnel: sigil and verdict, the four-axis Affection Matrix, micro-insights, proof.
   Loaded through the `styles:` list in affection-style.njk, so it sits in <head>, BEFORE the tool kit's inline <style> blocks.
   Rules are scoped `.aq .x`; where one restyles a kit class it adds a class (`.aq .rk-bento.aq-bento`) so it outranks the kit's
   `.tk .x`. Token overrides use `.tk.aq`. Depends on tokens.css, partials/tool-kit-css.njk and partials/result-kit-css.njk.

   The page accent is Cinnabar (--c-accent), and the sigil is drawn in it. Four tones carry the strength of a lean and the dynamics:
   flow (cyan, a triangle), friction (amber, a square), fusion (violet, a circle) and quiet (slate, a ring). Colour and shape always travel together. */
.tk.aq {
  --tk-accent: var(--accent-love, #E11D48);
  --tone-flow: #0284C7;
  --tone-friction: #D97706;
  --tone-fusion: #7C3AED;
  --tone-quiet: #94A3B8;
  --g-cut: #fff;
}

/* ---- The sigil's colour roles (core/affection-glyph.js writes classes, not colours) ---- */
.aq .g-fill-accent { fill: var(--c-accent); }
.aq .g-stroke-accent { stroke: var(--c-accent); }
.aq .g-fill-ink { fill: var(--c-ink); }
.aq .g-stroke-ink { stroke: var(--c-ink); }
.aq .g-fill-cut { fill: var(--g-cut); }

/* ---- Shapes: colour never works alone ---- */
.aq .aq-sh { display: inline-block; flex: none; width: 11px; height: 11px; background: var(--tone); }
.aq .aq-sh.fusion { --tone: var(--tone-fusion); border-radius: 50%; }
.aq .aq-sh.flow { --tone: var(--tone-flow); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.aq .aq-sh.friction { --tone: var(--tone-friction); border-radius: 2px; }
.aq .aq-sh.quiet { --tone: var(--tone-quiet); background: transparent; border: 2.5px solid var(--tone); border-radius: 50%; }

.aq .aq-kick { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c-accent-ink); margin-bottom: 4px; }
.aq .aq-funnel { container: aqfunnel / inline-size; }

/* ---- Intro: one field, one button ---- */
.aq .aq-intro { max-width: 640px; margin: 0 auto 20px; }
.aq .aq-go { display: flex; width: min(100%, 380px); margin: 22px auto 0; }
.aq .aq-hint { margin-top: 10px; text-align: center; }
.aq .aq-intro .form-error { margin-top: 12px; text-align: center; }
.aq .tk-layout.aq-layout { grid-template-columns: minmax(0, 1fr); }

/* a result folds the form into one bar; Retake is one tap away */
.aq .aq-strip { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 16px; padding: 12px 12px 12px 20px; border: 1px solid var(--c-line); border-radius: var(--r-card); background: var(--c-card); }
.aq .aq-strip-name { min-width: 0; font-size: 1.0625rem; font-weight: 800; letter-spacing: -0.01em; overflow-wrap: anywhere; }

/* ---- The empty state's sigil ---- */
.aq .aq-today { margin: 0 auto; width: 100%; max-width: 240px; }
.aq .aq-today svg { display: block; width: 100%; height: auto; }
.aq .aq-t-wall { fill: none; stroke: var(--c-accent); stroke-width: 7; }
.aq .aq-t-wall.thin { stroke-width: 2.5; opacity: 0.45; }
.aq .aq-t-orbit { fill: none; stroke: var(--c-accent); stroke-width: 1.5; stroke-dasharray: 3 7; opacity: 0.3; }
.aq .aq-t-core, .aq .aq-t-dot { fill: var(--c-accent); }
.aq .aq-t-cut { fill: var(--c-card); }

/* ================= Phase A: the quiz ================= */
.aq .aq-quiz { max-width: 760px; width: 100%; margin: 0 auto; display: grid; gap: 22px; padding: 22px 16px 20px; }
@media (min-width: 720px) { .aq .aq-quiz { padding: 32px 36px 26px; } }
.aq .aq-prog { display: grid; gap: 10px; }
.aq .aq-count { display: flex; align-items: baseline; gap: 4px; font-size: 0.9375rem; font-weight: 600; color: var(--c-muted); letter-spacing: 0.04em; }
.aq .aq-count b { font-size: 1.375rem; font-weight: 800; color: var(--c-ink); letter-spacing: 0; }
.aq .aq-meter { height: 6px; border-radius: 999px; background: #EEF2F6; overflow: hidden; }
.aq .aq-meter i { display: block; width: 0; height: 100%; border-radius: 999px; background: var(--c-accent); transition: width 0.35s var(--ease); }
.aq .aq-fs { border: 0; margin: 0; padding: 0; min-width: 0; }
.aq .aq-q { padding: 0; margin-bottom: 18px; font-size: clamp(1.375rem, 1.1rem + 1.2vw, 1.875rem); font-weight: 800; line-height: 1.2; letter-spacing: -0.025em; text-wrap: balance; }
.aq .aq-fs .aq-q:focus, .aq .aq-fs .aq-q:focus-visible { outline: none; }
.aq .aq-opts { display: grid; gap: 10px; }
.aq .aq-opt { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 14px; align-items: start; width: 100%; min-height: 56px; padding: 14px 16px; border: 1.5px solid var(--c-line); border-radius: var(--r-box); background: #fff; font-size: 1.0625rem; line-height: 1.4; font-weight: 500; cursor: pointer; transition: border-color 0.15s, background 0.15s, transform 0.15s var(--ease); }
.aq .aq-opt kbd { display: grid; place-items: center; width: 28px; height: 28px; margin-top: -1px; border-radius: 8px; background: #EEF2F6; font-size: 0.875rem; font-weight: 700; font-style: normal; color: var(--c-muted); }
.aq .aq-opt:hover { border-color: color-mix(in srgb, var(--c-accent) 50%, #fff); background: var(--c-accent-tint); }
.aq .aq-opt:focus-visible { outline: 3px solid color-mix(in srgb, var(--c-accent) 55%, transparent); outline-offset: 2px; }
.aq .aq-opt:active { transform: translateY(1px); }
.aq .aq-opt.is-on { border-color: var(--c-accent); background: var(--c-accent-tint); }
.aq .aq-opt.is-on kbd { background: var(--c-accent); color: #fff; }
.aq .aq-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 18px; border-top: 1px solid var(--c-line); }
.aq .aq-nav .hint { text-align: right; }
.aq .aq-nav .btn-sm:disabled { opacity: 0.4; cursor: default; }
@media (max-width: 520px) { .aq .aq-nav .hint { display: none; } }

/* ================= Level 1: the core result ================= */
.aq .aq-hero { --g-cut: #fff; }
.aq .aq-hero .rk-top { position: relative; }
.aq .aq-hero .rk-ribbon { white-space: normal; height: auto; min-height: 28px; padding: 4px 12px; }
.aq .aq-mark { position: absolute; right: -14%; top: -12%; width: min(70%, 520px); height: auto; fill: none; stroke: var(--c-accent); stroke-width: 1.5; opacity: 0.1; pointer-events: none; }
.aq .aq-stage { position: relative; display: grid; justify-items: center; margin-top: 12px; text-align: center; }

/* the sigil: the archetype as geometry, in the page accent */
.aq .aq-sigil { width: min(100%, 340px); aspect-ratio: 1; }
.aq .aq-sigil .aq-glyph { display: block; width: 100%; height: 100%; overflow: visible; }

/* the verdict: the loudest type on the page, the last word on a marker */
.aq .aq-verdict { margin-top: 18px; font-size: clamp(2.5rem, 13.5cqw, 5.75rem); font-weight: 800; letter-spacing: -0.045em; line-height: 1; text-wrap: balance; color: var(--c-ink); }
.aq .aq-vw { display: inline-block; }
.aq .aq-vw.hl > span {
  display: inline-block; margin-left: -0.05em; padding: 0 0.07em; border-radius: 0.08em;
  background: linear-gradient(transparent 52%, color-mix(in srgb, var(--c-accent) 38%, #fff) 52%, color-mix(in srgb, var(--c-accent) 38%, #fff) 93%, transparent 93%) no-repeat 0 0 / 100% 100%;
}
.aq .aq-drive { margin-top: 18px; max-width: 28ch; font-size: clamp(1.25rem, 1rem + 1.4vw, 1.875rem); font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; text-wrap: balance; }
.aq .aq-hero .rk-actions { justify-content: center; }

/* ================= Level 2: the Affection Matrix ================= */
.aq .aq-axes { display: grid; gap: 26px; margin-top: 6px; container: axes / inline-size; }
.aq .aq-axis { --tone: var(--tone-fusion); display: grid; gap: 10px; }
.aq .aq-axis.flow, .aq .aq-axis.clear { --tone: var(--tone-flow); }
.aq .aq-axis.quiet, .aq .aq-axis.slight { --tone: var(--tone-quiet); }
.aq .aq-ax-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; }
.aq .aq-ax-name { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-width: 0; }
.aq .aq-ax-name b { font-size: 1.1875rem; font-weight: 800; letter-spacing: -0.015em; }
.aq .aq-ax-name small { flex-basis: 100%; font-size: 0.8125rem; font-weight: 600; color: var(--c-muted); }
.aq .aq-ax-val { display: inline-flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.aq .aq-ax-val b { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.aq .aq-ax-val small { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-muted); }
/* labels at either end of the bar; on a narrow card they sit above it */
.aq .aq-bar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "l r" "t t"; gap: 8px 12px; align-items: center; }
.aq .aq-pole { font-size: 0.9375rem; font-weight: 600; color: var(--c-muted); line-height: 1.2; }
.aq .aq-pole.l { grid-area: l; text-align: left; }
.aq .aq-pole.r { grid-area: r; text-align: right; }
.aq .aq-pole.on { font-weight: 800; color: var(--c-ink); }
.aq .aq-track { grid-area: t; position: relative; display: block; height: 14px; border-radius: 999px; background: #EEF2F6; overflow: hidden; }
.aq .aq-fill { position: absolute; top: 0; bottom: 0; width: var(--w); border-radius: 999px; background: var(--c-accent); }
.aq .aq-axis.left .aq-fill { left: 0; }
.aq .aq-axis.right .aq-fill { right: 0; }
.aq .aq-axis.slight .aq-fill { opacity: 0.62; }
.aq .aq-axis.clear .aq-fill { opacity: 0.85; }
.aq .aq-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; opacity: 0.9; }
@container axes (min-width: 560px) {
  .aq .aq-bar { grid-template-columns: minmax(7.5rem, auto) minmax(0, 1fr) minmax(7.5rem, auto); grid-template-areas: "l t r"; gap: 16px; }
}
.aq .aq-legend { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--c-line); font-size: 0.8125rem; font-weight: 600; color: var(--c-muted); }

/* ================= Level 3: micro-insights ================= */
.aq .rk-bento.aq-bento { grid-template-columns: minmax(0, 1fr); margin-top: 14px; }
@container aqfunnel (min-width: 760px) { .aq .rk-bento.aq-bento { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.aq .aq-tile { --tone: var(--tone-quiet); display: flex; flex-direction: column; border-top: 3px solid var(--tone); }
.aq .aq-tile.flow { --tone: var(--tone-flow); }
.aq .aq-tile.fusion { --tone: var(--tone-fusion); }
.aq .aq-tile.friction { --tone: var(--tone-friction); }
.aq .aq-tile h3 { display: flex; align-items: center; gap: 8px; }
.aq .aq-tile-line { margin-top: 12px; font-size: 1.125rem; font-weight: 700; letter-spacing: -0.012em; line-height: 1.32; }
.aq .aq-tile-fact { margin-top: auto; padding-top: 16px; font-size: 0.8125rem; font-weight: 600; line-height: 1.4; color: var(--c-muted); }

/* ================= Level 4: the proof of math ================= */
.aq .aq-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 16px; }
.aq .aq-grid { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.aq .aq-grid caption { text-align: left; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-muted); padding-bottom: 6px; }
.aq .aq-grid th { font-weight: 500; vertical-align: middle; }
.aq .aq-grid thead th { padding: 0 2px 6px; text-align: center; }
.aq .aq-grid th b { display: block; font-size: 0.8125rem; font-weight: 800; letter-spacing: -0.01em; }
.aq .aq-grid th small { display: block; margin-top: 1px; font-size: 0.625rem; font-weight: 600; line-height: 1.2; color: var(--c-muted); }
.aq .aq-grid tbody th { width: 21%; padding-right: 4px; text-align: left; }
.aq .aq-cell { position: relative; padding: 6px; border: 1px solid var(--c-line); border-radius: 10px; background: #F8FAFC; text-align: center; }
.aq .aq-cell .aq-mini { display: block; width: 100%; max-width: 64px; height: auto; margin: 0 auto; opacity: 0.45; }
.aq .aq-cell { --g-cut: #F8FAFC; }
.aq .aq-cell.is-you { --g-cut: color-mix(in srgb, var(--c-accent) 9%, #fff); background: var(--c-accent-tint); border-color: var(--c-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c-accent) 20%, transparent); }
.aq .aq-cell.is-you .aq-mini { opacity: 1; }
.aq .aq-you { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); padding: 1px 8px; border-radius: 999px; background: var(--c-accent); color: #fff; font-size: 0.625rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.aq .aq-sig { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--c-line); }
.aq .aq-sig-k { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--c-muted); }
.aq .aq-totals { display: grid; gap: 8px; margin-top: 8px; }
.aq .aq-totals li { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; font-size: 0.9375rem; }
.aq .aq-totals li b { min-width: 5.5rem; font-weight: 800; }
.aq .aq-totals li .num { font-weight: 800; font-size: 1.0625rem; }
.aq .aq-totals li span:last-child { color: var(--c-muted); font-weight: 600; }
.aq .aq-sigline { margin-top: 10px; font-size: 0.9375rem; }
.aq .aq-sigline b { display: inline-block; padding: 3px 10px; border-radius: 8px; background: var(--c-accent-tint); color: var(--c-accent-ink); letter-spacing: 0.06em; }
.aq .aq-note { margin-top: 12px; font-size: 0.875rem; line-height: 1.45; color: #475569; max-width: 70ch; }
.aq .aq-review { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--c-line); }
.aq .aq-review summary { cursor: pointer; font-size: 0.9375rem; font-weight: 700; color: var(--c-accent-ink); min-height: 32px; }
.aq .aq-rtable { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.aq .aq-rtable caption { text-align: left; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-muted); padding-bottom: 6px; }
.aq .aq-rtable th, .aq .aq-rtable td { padding: 8px 8px; text-align: left; border-top: 1px solid var(--c-line); vertical-align: top; font-weight: 500; }
.aq .aq-rtable thead th { border-top: 0; font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--c-muted); }
.aq .aq-rtable td:last-child { white-space: nowrap; font-weight: 700; }

.aq .aq-nexts { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .aq .aq-nexts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- Motion: the question slides in, the sigil draws, the verdict rises and its marker sweeps, the bars fill ---- */
@keyframes aq-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes aq-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes aq-word { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes aq-sweep { from { background-size: 0 100%; } to { background-size: 100% 100%; } }
@keyframes aq-grow { from { width: 0; } }
@keyframes aq-draw { from { opacity: 0; transform: scale(0.94); } to { opacity: 0.1; transform: none; } }
@keyframes aq-sigil { from { opacity: 0; transform: scale(0.9) rotate(-6deg); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .aq .aq-step.is-in { animation: aq-in 0.32s var(--ease) both; }
  .aq .aq-step.is-out { animation: aq-out 0.22s ease-in both; }
  .aq .results.is-in .aq-mark { animation: aq-draw 1.1s var(--ease) 0.1s backwards; transform-origin: 70% 40%; }
  .aq .results.is-in .aq-sigil { animation: aq-sigil 0.9s var(--ease) 0.2s backwards; }
  .aq .results.is-in .aq-verdict .aq-vw:not(.hl), .aq .results.is-in .aq-verdict .aq-vw.hl > span { animation: aq-word 0.6s var(--ease) 0.55s backwards; }
  .aq .results.is-in .aq-vw.hl > span { animation: aq-word 0.6s var(--ease) 0.65s backwards, aq-sweep 0.7s var(--ease) 1.05s backwards; }
  .aq .results.is-in .aq-fill { animation: aq-grow 0.9s var(--ease) 0.4s backwards; }
}
