/* card-demo.css — the "How it works" card builder (index.html / index-es.html #how).
 *
 * Split out of index.css so it is not render-blocking for the hero: the pages link it from
 * <body>, immediately before <section id="how">. Browsers paint everything above that <link>
 * without waiting for it and hold only the content after it until it arrives, so first paint
 * gets cheaper and the section still never renders unstyled (no layout shift). The card faces
 * reuse the hero card's `.card …` rules, which stay in index.css; the --note-* swatch tokens
 * stay in site.css with every other colour.
 */

/* ── CARD DEMO ─────────────────────────────────────
 * A simplified Add Card Manually sheet (the app's FaintManualEntry flow): Origin → Sensory →
 * Notes → Review, beside a live tasting card that turns over once it is added.
 * Without JavaScript only the card shows — a finished example, centred under the steps.
 * With it, the inline stamp in <head> puts `js` on <html> before first paint, so the
 * two-column layout and the builder (whose markup is already the script's first render) are
 * there from the first frame: card-demo.js changes text, never layout, so CLS stays 0.
 * The card faces reuse the hero card's `.card …` face rules; `.demo-flip .card` below undoes
 * the hero's absolute fan pose so the faces fill the flip box instead.
 */
.demo {
  --demo-s: 1.1;
  margin-top: 48px;
  display: grid; grid-template-columns: 1fr; justify-items: center; gap: 48px;
}
.js .demo { grid-template-columns: minmax(300px, 380px) 1fr; justify-items: stretch; align-items: start; }
.demo-stage { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.js .demo .demo-stage { position: sticky; top: 24px; }

/* The layout box is the scaled card; the 260×478 flip box is centred in it and scaled, so
   the card's fixed-pixel type shrinks with its box (see the ≤480px hero note). */
.demo-card {
  position: relative; flex: none;
  width: calc(260px * var(--demo-s)); height: calc(478px * var(--demo-s));
  perspective: 1400px;
}
.demo-flip {
  position: absolute; left: 50%; top: 50%;
  width: 260px; height: 478px; margin: -239px 0 0 -130px;
  transform-style: preserve-3d;
  transform: scale(var(--demo-s)) translateY(var(--demo-lift, 0px)) rotateY(var(--demo-turn, 0deg));
  /* PoFlipCard's turn: 350ms, no bounce. */
  transition: transform 350ms cubic-bezier(.4,0,.2,1);
}
.demo-card.is-turned { --demo-turn: 180deg; }
.demo-card.is-created { --demo-lift: -6px; cursor: pointer; }
.demo-flip .card {
  position: absolute; inset: 0; width: 100%; height: 100%;
  transform: none; animation: none; transition: none;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.demo-flip .card.back { transform: rotateY(180deg); }
/* The back's map: one drawn terrain per origin (the app's map is the region at ~5 km, so each
   is a regional landscape, not the country's outline). The picked origin's group is `is-on`;
   the swap is a short crossfade, instant under reduced motion. */
.demo .map-terrain [data-terrain] { opacity: 0; transition: opacity 200ms ease; }
.demo .map-terrain [data-terrain].is-on { opacity: 1; }
.demo .map-terrain .lake { fill: var(--map-water); }
@media (prefers-reduced-motion: reduce) {
  .demo .map-terrain [data-terrain] { transition: none; }
}
/* Two sample polaroids fill the Memories strip; the third slot stays the app's "+", and this
   line says where your own photos go. No file input, no camera: nothing is asked of the visitor. */
.card .photo-hint {
  margin: 6px 0 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 8px; font-weight: 700; letter-spacing: 0.12em;
  color: var(--muted); text-transform: uppercase;
}
/* The app's empty LABEL block: a dashed "+" frame in place of roaster and farm. */
.card .label-add {
  display: flex; align-items: center; justify-content: center; min-height: 52px;
  border: 1px dashed var(--photo-add-border); border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 9px; font-weight: 700; letter-spacing: 0.12em;
  color: var(--muted); text-transform: uppercase;
}
/* A value the last pick changed flashes once, the way the app marks an auto-filled field. */
@keyframes demo-fresh { from { background: var(--accent); color: var(--on-accent); } }
.card .is-fresh { animation: demo-fresh 700ms ease-out; }

.builder { display: none; min-width: 0; }
/* Under `.js` the builder holds its place from first paint (no layout shift), but stays
   invisible — and out of the tab order — until card-demo.js has wired it and added
   `is-ready`. If the script never runs, the example card stands alone. */
.js .builder { display: block; visibility: hidden; }
.js .demo.is-ready .builder { visibility: visible; }
/* `display` on these would beat the [hidden] attribute the script toggles. */
.js .builder[hidden], .demo-after[hidden] { display: none; }
.builder-kicker {
  margin: 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent);
}
.builder-kicker span:last-child { color: var(--muted); }
.pills { margin-top: 16px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.pill {
  flex: none; min-height: 44px; padding: 0 16px;
  background: transparent; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer;
}
.pill:hover { border-color: var(--ink); }
.pill[aria-current="step"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }

.panel { margin: 20px 0 0; padding: 0; border: 0; min-width: 0; min-height: 352px; }
.panel legend {
  padding: 0;
  font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1;
}
.panel-hint { margin: 8px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); }

.chips { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.chips.origins { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Scoped to .chips: index.css's .btn-primary arrow is also a .chip, and a bare .chip here
   would give it this pill's border, padding and height. */
.chips .chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 14px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 14px; font-weight: 600; text-align: left;
  cursor: pointer;
  transition: border-color 150ms, background-color 150ms, opacity 150ms;
}
.chips .chip:hover { border-color: var(--ink); }
.chips .chip .cc {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em; color: var(--accent);
}
.chips .chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chips .chip[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.chips .chip[aria-disabled="true"]:hover { border-color: var(--line); }
.chips .chip .sw { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.sw-fruity { background: var(--note-fruity); }
.sw-citrus { background: var(--note-citrus); }
.sw-floral { background: var(--note-floral); }
.sw-sweet  { background: var(--note-sweet); }
.sw-nuts   { background: var(--note-nuts); }
.sw-wild   { background: var(--note-wild); }
.sw-green  { background: var(--note-green); }

.auto-line {
  margin: 16px 0 0; min-height: 18px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em; line-height: 1.6;
  color: var(--muted); text-transform: uppercase;
}
.auto-line .spark, .auto-line .auto-tag { color: var(--accent); }

.slider-row {
  margin-top: 18px;
  display: grid; grid-template-columns: 88px 1fr 48px; align-items: center; gap: 16px;
}
.slider-row label, .slider-row output {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
}
.slider-row output { color: var(--muted); text-align: right; }
.slider-row input { width: 100%; height: 44px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.slider-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* The Sensory step's slot grid (the app's, four to a line): a filled box is a row — its name
   over a mini meter — and makes that row active; the first empty box is `+`, the rest wait. */
.slots { margin-top: 18px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.slot {
  min-height: 52px; padding: 8px 10px;
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
  background: transparent; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; text-align: left;
}
.slot:disabled { opacity: 0.45; }
.slot-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-meter { display: block; height: 2px; background: var(--hairline); }
.slot-fill { display: block; height: 100%; width: 0; background: var(--accent); }
.slot.is-filled { border-style: solid; background: var(--surface); color: var(--ink); cursor: pointer; }
.slot.is-filled:hover { border-color: var(--ink); }
.slot.is-filled[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.slot.is-add { align-items: center; color: var(--ink); font-size: 18px; font-weight: 400; cursor: pointer; }
.slot.is-add:hover { border-color: var(--ink); }
.slot.is-add .slot-meter { visibility: hidden; }

.rate { margin-top: 20px; display: flex; gap: 4px; }
.rate-star {
  width: 48px; height: 48px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 6px; cursor: pointer;
}
.rate-star:hover .star.empty { stroke: var(--accent); }

/* Back and Next rest on a single hairline below them, which closes the builder; nothing
   divides them from the step above. */
.builder-foot {
  margin-top: 24px; padding: 20px 0;
  border-bottom: 1px solid var(--hairline);
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
.builder-foot .btn-primary { min-width: 180px; justify-content: center; }
.builder-foot .btn-primary.is-final { background: var(--accent); box-shadow: var(--shadow-accent); }
.builder-foot .btn-primary.is-final:hover { box-shadow: var(--shadow-accent-hover); }
.btn-ghost {
  min-height: 44px; padding: 0 18px;
  background: transparent; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--ink); }
/* Back keeps its slot on the first step, like the app's footer. */
.btn-ghost[data-demo-back][aria-hidden="true"] { visibility: hidden; }

.demo-after {
  width: 100%; max-width: 460px;
  display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center;
}
.demo-legend { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); text-wrap: pretty; }
/* The first <strong> is the legend's heading line; any later one is ordinary inline bold. */
.demo-legend strong:first-child { display: block; margin-bottom: 4px; font-size: 18px; letter-spacing: -0.01em; color: var(--ink); }
.demo-after .store-buttons { justify-content: center; }
.demo-again {
  min-height: 44px; padding: 0 8px; background: transparent; border: 0; cursor: pointer;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); text-decoration: underline; text-underline-offset: 4px;
}
.demo-again:hover { color: var(--accent); }
/* Once the card is added the builder steps aside and the stage takes the whole row. */
.js .demo.is-done { grid-template-columns: 1fr; justify-items: center; }
.js .demo.is-done .demo-stage { position: static; }

@media (max-width: 880px) {
  .demo { --demo-s: 0.82; margin-top: 36px; gap: 28px; }
  .js .demo { grid-template-columns: 1fr; justify-items: stretch; }
  .js .demo .demo-stage { position: static; }
  .panel { min-height: 0; }
  .chips.origins { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .demo { --demo-s: 0.74; }
  .slider-row { grid-template-columns: 72px 1fr 44px; gap: 10px; }
  .slot { padding: 8px 6px; font-size: 9px; letter-spacing: 0.02em; }
  .builder-foot .btn-primary { min-width: 0; flex: 1; }
}
