/* ============================================================================
   dudas (#dudas). Tranquilidad. Flow + in, compacto.
   Left: an engraved plate that redraws a small schematic for whichever answer
   is open. Right: the questions as native <details> (one open at a time).
   Every doubt is answered twice: in one sentence and in one drawing. The
   chapter is mirrored on purpose: puertas and tu turno carry their heavy
   panel on the right, so this one carries it on the left.
   ========================================================================== */

.faq {
  /* the plate's paper: a step lighter than the chapter ground in both worlds */
  --faq-sheet: color-mix(in oklab, var(--sc-surface) 70%, var(--ground));
  --faq-grid: color-mix(in oklab, var(--sc-ink) 5.5%, transparent);
}
:root[data-theme="night"] .faq {
  --faq-sheet: color-mix(in oklab, var(--sc-surface) 86%, var(--ground));
  /* ink, never teal: at night teal only ever means "runs on its own" */
  --faq-grid: color-mix(in oklab, var(--sc-ink) 6%, transparent);
}

/* pattern holder: never display:none, or the hatches stop painting */
.faq__defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.faq__inner {
  display: grid;
  grid-template-columns: minmax(0, 0.96fr) minmax(0, 1.04fr);
  grid-template-areas: "head head" "plate list";
  column-gap: clamp(2.5rem, 5.2vw, 5.5rem);
  row-gap: clamp(2rem, 4.6vh, 3.25rem);
  align-items: start;
  /* vertical padding is the shared .ch__inner rhythm; nothing overrides it */
}
.faq__inner > * { min-width: 0; }

/* ---------------------------------------------------------------- title -- */
.faq__head { grid-area: head; }
.faq__h { max-width: 24ch; }
.faq__x { position: relative; display: inline-block; white-space: nowrap; }
/* an editor's correction through "programador": a file being corrected */
.faq__xl {
  position: absolute; left: -0.06em; right: -0.08em; top: 50%; height: 0.24em;
  width: calc(100% + 0.14em); overflow: visible; pointer-events: none;
  clip-path: inset(0 100% 0 0);
  transition: clip-path 520ms var(--ease-out) 300ms;
}
.faq__xl path { fill: none; stroke: var(--accent-deep); stroke-width: 3.4px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
:root[data-theme="night"] .faq__xl path { stroke: var(--sc-accent); }
.faq__head.sc-in .faq__xl { clip-path: inset(0 0 0 0); }

/* weight and colour of the em come from the shared ".ch__h em" in core.css */
.faq__no {
  display: inline-block;
  opacity: 0; transform: translateY(0.14em) scale(0.96); transform-origin: 0 80%;
  transition: opacity 460ms var(--ease-out) 560ms, transform 560ms var(--ease-out) 560ms;
}
.faq__head.sc-in .faq__no { opacity: 1; transform: none; }
/* no JS, no engine: the sentence is simply complete */
:root:not(.js) .faq__xl { clip-path: none; }
:root:not(.js) .faq__no { opacity: 1; transform: none; }

/* ----------------------------------------------------------- questions -- */
.faq__list { grid-area: list; }
/* NOTE: .faq__item is a direct child of the stagger; the engine owns its
   opacity/transform transition, so nothing here sets `transition` on it. */
.faq__item { border-top: 1px solid var(--rule); }
.faq__item:last-child { border-bottom: 1px solid var(--rule); }

.faq__q {
  list-style: none; cursor: pointer;
  display: grid; grid-template-columns: 1.4rem minmax(0, 1fr) 1.9rem; align-items: center; gap: 1.1rem;
  padding: 1.08rem 0.1rem; border-radius: var(--sc-r-sm);
  -webkit-tap-highlight-color: transparent;
}
.faq__q::-webkit-details-marker { display: none; }
.faq__q::marker { content: ""; }
/* focus ring: the global two-tone ring in core.css, not overridden here */

.faq__ic {
  width: 1.4rem; height: 1.4rem; fill: none;
  stroke: var(--sc-ink-soft); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round;
  transition: stroke 200ms var(--ease-out), transform 240ms var(--ease-out);
}
.faq__qt {
  font: 400 clamp(1.1rem, 0.94rem + 0.42vw, 1.34rem)/1.28 var(--sc-font-display);
  letter-spacing: -0.012em; color: var(--sc-ink); text-wrap: balance;
  transition: color 200ms var(--ease-out);
}
:root[data-theme="night"] .faq__qt { font-weight: 420; letter-spacing: -0.006em; }

/* the "+" sits in a small instrument key; only the glyph turns */
.faq__pm {
  position: relative; width: 1.9rem; height: 1.9rem; justify-self: end;
  border: 1px solid var(--rule-strong); border-radius: var(--sc-r-sm);
  background: transparent;
  transition: background-color 200ms var(--ease-out), border-color 200ms var(--ease-out), transform 140ms var(--ease-out);
}
.faq__pm i { position: absolute; inset: 0; transition: transform 280ms var(--ease-out); }
.faq__pm i::before, .faq__pm i::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 11px; height: 1.5px; margin: -0.75px 0 0 -5.5px;
  background: var(--sc-ink); border-radius: 1px;
  transition: background-color 200ms var(--ease-out);
}
.faq__pm i::after { transform: rotate(90deg); }

.faq__item[open] .faq__pm { background: var(--action); border-color: color-mix(in oklab, var(--action) 55%, var(--sc-ink)); }
.faq__item[open] .faq__pm i { transform: rotate(135deg); }
.faq__item[open] .faq__pm i::before, .faq__item[open] .faq__pm i::after { background: var(--action-ink); }
.faq__item[open] .faq__ic { stroke: var(--accent-deep); }
:root[data-theme="night"] .faq__item[open] .faq__ic { stroke: var(--sc-accent); }

@media (hover: hover) and (pointer: fine) {
  .faq__q:hover .faq__pm { border-color: var(--sc-ink-soft); background: color-mix(in oklab, var(--sc-accent) 14%, transparent); }
  .faq__item[open] .faq__q:hover .faq__pm { background: var(--action-hover); }
  .faq__q:hover .faq__ic { stroke: var(--sc-ink); transform: translateY(-1px); }
  .faq__item[open] .faq__q:hover .faq__ic { stroke: var(--accent-deep); }
}
.faq__q:active .faq__pm { transform: scale(0.94); }

.faq__a { padding: 0 3rem 1.45rem 2.5rem; }
.faq__a p { font-size: 1.02rem; line-height: 1.62; color: var(--sc-ink-soft); max-width: 50ch; }
.faq__item[open] .faq__a { animation: faq-open 460ms var(--ease-out) both; }
@keyframes faq-open {
  from { opacity: 0; transform: translateY(-6px); clip-path: inset(0 0 100% 0); }
  to   { opacity: 1; transform: none; clip-path: inset(0 0 0 0); }
}

/* --------------------------------------------------------------- plate -- */
.faq__plate {
  grid-area: plate; margin: 0; padding: 7px;
  width: 100%; max-width: 38rem; justify-self: start;
}
.faq__sheet {
  position: relative; border-radius: 2px; overflow: hidden;
  background-color: var(--faq-sheet);
  background-image:
    linear-gradient(var(--faq-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--faq-grid) 1px, transparent 1px);
  background-size: 22px 22px; background-position: -1px -1px;
  box-shadow: var(--sc-e2), var(--sc-edge);
  transition: background-color var(--theme-dur) var(--ease-out);
}
.faq__cap {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.8rem 1rem 0.7rem; border-bottom: 1px solid var(--rule);
  background: color-mix(in oklab, var(--faq-sheet) 88%, transparent);
}
.faq__tagwrap { overflow: hidden; display: inline-flex; }
.faq__tag {
  display: inline-block;
  font: 500 0.72rem/1.2 var(--sc-font-mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--sc-ink);
  transition: opacity 220ms var(--ease-out), color 180ms var(--ease-out);
}
/* peeking a closed question: the caption names the preview in a softer ink */
.faq__tag.is-peek { color: var(--sc-ink-soft); }
.faq__tag.is-roll { animation: faq-roll 420ms var(--ease-out) both; }
@keyframes faq-roll { from { opacity: 0; transform: translateY(70%); } to { opacity: 1; transform: none; } }
.faq__ticks { display: inline-flex; align-items: center; gap: 4px; }
.faq__ticks i { width: 9px; height: 3px; border-radius: 1px; background: var(--rule-strong); transition: background-color 220ms var(--ease-out), transform 260ms var(--ease-out); transform-origin: 50% 50%; }
.faq__ticks i.is-on { background: var(--accent-deep); transform: scaleX(1.9); margin: 0 4px; }
:root[data-theme="night"] .faq__ticks i.is-on { background: var(--sc-accent); }
.faq__ticks i.is-peek { background: var(--sc-ink-soft); }

.faq__figs { position: relative; aspect-ratio: 440 / 400; transition: opacity 260ms var(--ease-out); }
.faq__fig {
  position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible;
  font-family: var(--sc-font-mono);
  opacity: 0; visibility: hidden;
  transition: opacity 220ms var(--ease-out), visibility 0s linear 220ms;
}
.faq__fig.is-on { opacity: 1; visibility: visible; transition: opacity 320ms var(--ease-out) 90ms, visibility 0s; }

/* nothing open: the plate stops claiming an answer. The last drawing stays,
   dimmed, and its loop rests until a question opens again */
.faq__plate.is-idle:not(.is-peek) .faq__figs { opacity: 0.38; }
.faq__plate.is-idle .faq__tag { opacity: 0.5; }

/* hover preview (fine pointer): a closed question shows its drawing as a
   ghost, already drawn and still, and the open one steps aside until the
   pointer leaves */
.faq__fig.is-ghost { opacity: 0.36; visibility: visible; transition: opacity 180ms var(--ease-out), visibility 0s; }
.faq__plate.is-peek .faq__fig.is-on:not(.is-ghost) { opacity: 0; transition: opacity 160ms var(--ease-out), visibility 0s; }

/* strokes and fills, all from tokens so the day/night swap needs no JS */
.faq__fig .s   { fill: none; stroke: var(--sc-ink); stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }
.faq__fig .s2  { fill: none; stroke: var(--sc-ink-soft); stroke-width: 1.05; stroke-linecap: round; stroke-linejoin: round; }
.faq__fig .sa  { fill: none; stroke: var(--accent-deep); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.faq__fig .sg  { fill: none; stroke: var(--signal); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.faq__fig .sa--w { stroke-width: 2.4; }
.faq__fig .s--w, .faq__fig .sg--w { stroke-width: 2.2; }
.faq__fig .dash { stroke-dasharray: 3 4.5; }
.faq__fig .pp  { fill: var(--faq-sheet); }
.faq__fig .pp.s, .faq__fig .pp.s2, .faq__fig .pp.sg { fill: var(--faq-sheet); }
.faq__fig .hf  { fill: url(#faq-hatch); }
.faq__fig .ha  { fill: url(#faq-hatch-a); }
.faq__fig .fa  { fill: var(--sc-accent); }
.faq-hp  { stroke: var(--sc-ink); stroke-width: 0.8; opacity: 0.34; }
.faq-hpa { stroke: var(--sc-accent); stroke-width: 1.2; opacity: 0.9; }
:root[data-theme="night"] .faq-hp { stroke: var(--signal); opacity: 0.3; }
:root[data-theme="night"] .faq-hpa { opacity: 0.62; }

.faq__fig .t {
  font-size: 12.5px; fill: var(--sc-ink-soft); letter-spacing: 0.02em;
  /* a paper halo knocks lines and grid out behind every label, like an engraver's cartouche */
  paint-order: stroke; stroke: var(--faq-sheet); stroke-width: 5px; stroke-linejoin: round;
}
.faq__fig .rc .t, .faq__fig .t--big { stroke: none; }
.faq__fig .ti { fill: var(--sc-ink); }
.faq__fig .ta { fill: var(--accent-deep); }
:root[data-theme="night"] .faq__fig .ta { fill: var(--sc-accent); }
.faq__fig .t--node { font-size: 13.5px; font-weight: 500; }
.faq__fig .t--q { font-size: 14px; font-weight: 500; }
.faq__fig .t--zero { font-size: 14px; font-weight: 500; }
.faq__fig .t--big {
  font: 400 31px/1 var(--sc-font-display);
  letter-spacing: -0.02em; fill: var(--sc-ink);
}

/* moving parts */
.faq__fig .pk { fill: var(--sc-ink); }
.faq__fig .pk--a { fill: var(--sc-accent); stroke: var(--accent-deep); stroke-width: 1.2; }
.faq__fig .dots .pk { opacity: 0; }
.faq__fig .mk-dot { fill: var(--sc-accent); stroke: var(--accent-deep); stroke-width: 1.4; }
.faq__fig .mk-ring { fill: none; stroke: var(--accent-deep); stroke-width: 1; opacity: 0.45; }
.faq__fig [data-okmark] { opacity: 0; }
.faq__fig [data-arm] { transform-box: view-box; transform-origin: 220px 236px; }
.faq__fig .sat__box, .faq__fig .sat__ic, .faq__fig .spoke, .faq__fig .sat__t { transition: stroke 200ms var(--ease-out), fill 200ms var(--ease-out); }
.faq__fig .sat.is-ping .sat__box { stroke: var(--signal); }
@media (hover: hover) and (pointer: fine) {
  .faq__fig .sat:hover .spoke { stroke: var(--accent-deep); }
  .faq__fig .sat:hover .sat__box { stroke: var(--accent-deep); }
  .faq__fig .sat:hover .sat__t { fill: var(--sc-ink); }
}

/* draw-in: .d strokes are drawn (pathLength=1), .f parts fade in, both keyed
   to --d so each schematic assembles in reading order. The way back is
   instant but delayed past the figure's own fade-out, so an outgoing drawing
   crossfades whole instead of losing its parts first. The loops wait for the
   last part (--d:8, about 1150ms: see DRAW in faq.js). */
/* gap 2 and offset 1.001: an undrawn stroke has no zero-length dash left at
   its start, so round caps leave no speck on the paper while it waits */
.faq__fig .d { stroke-dasharray: 1 2; stroke-dashoffset: 1.001; transition: stroke-dashoffset 0s linear 260ms; }
.faq__fig.is-on .d { stroke-dashoffset: 0; transition: stroke-dashoffset 820ms var(--ease-out) calc(var(--d, 0) * 70ms + 100ms); }
.faq__fig .f { opacity: 0; transition: opacity 0s linear 260ms; }
.faq__fig.is-on .f { opacity: 1; transition: opacity 440ms var(--ease-out) calc(var(--d, 0) * 70ms + 180ms); }

/* the receipt prints: rows feed out of the printer top to bottom */
.faq__fig .rc__paper, .faq__fig .rc__shadow { opacity: 0; transition: opacity 0s linear 260ms; }
.faq__fig .rc__row { opacity: 0; transform: translateY(-6px); transition: opacity 0s linear 260ms, transform 0s linear 260ms; }
.faq__fig .rc__hl { fill: var(--sc-accent); opacity: 0.5; transform-box: fill-box; transform-origin: 0 50%; transform: scaleX(0); transition: transform 0s linear 260ms; }
:root[data-theme="night"] .faq__fig .rc__hl { opacity: 0.26; }
.faq__fig.is-on .rc__paper, .faq__fig.is-on .rc__shadow { opacity: 1; transition: opacity 360ms var(--ease-out) 100ms; }
.faq__fig.is-on .rc__row {
  opacity: 1; transform: none;
  transition: opacity 360ms var(--ease-out) calc(var(--r, 0) * 95ms + 220ms), transform 420ms var(--ease-out) calc(var(--r, 0) * 95ms + 220ms);
}
.faq__fig.is-on .rc__hl { transform: scaleX(1); transition: transform 520ms var(--ease-out) 680ms; }

/* a ghost is already drawn: no draw-in, no print, nothing moving */
.faq__fig.is-ghost .d { stroke-dashoffset: 0; transition: none; }
.faq__fig.is-ghost .f, .faq__fig.is-ghost .rc__paper, .faq__fig.is-ghost .rc__shadow { opacity: 1; transition: none; }
.faq__fig.is-ghost .rc__row { opacity: 1; transform: none; transition: none; }
.faq__fig.is-ghost .rc__hl { transform: none; transition: none; }

/* ---------------------------------------------------------- responsive -- */
@media (max-width: 1100px) {
  .faq__inner { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "plate" "list"; }
  .faq__plate { width: min(100%, 30rem); }
}
@media (max-width: 700px) {
  .faq__h { max-width: none; }
  .faq__q { gap: 0.8rem; grid-template-columns: 1.25rem minmax(0, 1fr) 1.75rem; }
  .faq__pm { width: 1.75rem; height: 1.75rem; }
  .faq__a { padding: 0 0.25rem 1.3rem 2.05rem; }
}

/* ------------------------------------------------------ reduced motion -- */
@media (prefers-reduced-motion: reduce) {
  .faq__xl { clip-path: none; transition: none; }
  .faq__no { transform: none; transition: opacity 220ms var(--ease-out) 120ms; }
  .faq__item[open] .faq__a { animation: faq-fade 220ms var(--ease-out) both; }
  .faq__tag.is-roll { animation: faq-fade 220ms var(--ease-out) both; }
  .faq__pm i, .faq__ic { transition-property: stroke, background-color; }
  .faq__fig .d { stroke-dashoffset: 0 !important; transition: none !important; }
  .faq__fig.is-on .f, .faq__fig.is-on .rc__row, .faq__fig.is-on .rc__paper, .faq__fig.is-on .rc__shadow { transition: opacity 220ms var(--ease-out) !important; }
  .faq__fig .rc__hl, .faq__fig .rc__row { transform: none !important; }
  .faq__fig .rc__hl { transition: none !important; }
  .faq__fig .dots .pk, .faq__fig [data-pk] { display: none; }
}
@keyframes faq-fade { from { opacity: 0; } to { opacity: 1; } }
