/* 🤖 The tour (/tour/): the homepage's look on a three-pane reading page.

   Fonts and colour tokens are the homepage's own, copied from home.css
   rather than linked: home.css is one hand-built page's stylesheet
   (gravel ground, hero, flags' canvas) and most of it would be dead
   weight here. Keep the two :root blocks in step with it.

   Layout, wide: the page is the window. Flags and top bar, then three
   columns that each scroll on their own: the step list (collapsible to a
   rail of numbers), the lesson with Back/Next pinned under it, and the
   editor. Narrow: the columns stack and the page scrolls as one.

   Script-dependent states hang off things /tour.js sets, never off the
   script merely being present: .steps-collapsed on <html>, .tabbed on
   the editor, and the hidden attribute on buttons and panels. If the
   script fails, the page stays fully open. */

@font-face { font-family: "Ibarra Real Nova"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(/fonts/ibarra-real-nova.woff2) format("woff2"); }
@font-face { font-family: "Chivo"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/fonts/chivo.woff2) format("woff2"); }
@font-face { font-family: "Chivo Mono"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/fonts/chivo-mono.woff2) format("woff2"); }

:root {
  --plaster: #F2EADB;
  --plaster-2: #E8DDC8;
  --bed: #D6C7AA;
  --edge: #FBF7EE;
  --ink: #1E2629;
  --muted: #4F5A5B;
  --acequia: #2F6F78;
  --chan: #2F6F78;
  --almagra: #A4442C;
  --cempa: #D9951A;
  --f0: #C81D6A;
  --f1: #E09A16;
  --f2: #1C9C9A;
  --f3: #4C9A35;
  --f4: #7B4BB3;
  --f5: #C8452B;
  --f6: #2C50B4;
  --on-almagra: #FBF5EA;
  --cobalt: #24448A;
  --screen: #FBF8F1;
  --hl: rgba(217, 149, 26, .14);   /* a changed line: cempasúchil, faint */

  --serif: "Ibarra Real Nova", "Iowan Old Style", Georgia, serif;
  --sans: "Chivo", "Segoe UI", system-ui, sans-serif;
  --mono: "Chivo Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --plaster: #0E191C;
    --plaster-2: #152429;
    --bed: #071012;
    --edge: #22363A;
    --ink: #ECE2D0;
    --muted: #A6B0AC;
    --acequia: #74B6BF;
    --chan: #5DA3AC;
    --almagra: #DB7A5A;
    --cempa: #E3A332;
    --f0: #C42C74;
    --f1: #D89A2A;
    --f2: #24A29D;
    --f3: #4F9B3D;
    --f4: #8A5CC4;
    --f5: #CC5238;
    --f6: #4067CC;
    --on-almagra: #1A0E09;
    --cobalt: #9DB2EA;
    --screen: #1B2B2F;
    --hl: rgba(227, 163, 50, .12);
  }
  /* The light theme's green strings would sit too dark on the screen. */
  .code .s { color: #8CC97A; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--plaster);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
  font-kerning: normal;
}
a { color: var(--acequia); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--almagra); outline-offset: 2px; border-radius: 2px; }
code, pre { font-family: var(--mono); font-variant-ligatures: none; font-variant-numeric: tabular-nums; }
:is(p, li, td) code { background: var(--plaster-2); padding: .1em .35em; border-radius: 2px; font-size: .84em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ai { font-family: var(--sans); font-size: .7em; vertical-align: .12em; }

/* ---------- Flags and top bar ---------- */
.flagrow { height: 14px; }
.flagrow svg { display: block; }
.f-0 { fill: var(--f0); } .f-1 { fill: var(--f1); } .f-2 { fill: var(--f2); } .f-3 { fill: var(--f3); }
.f-4 { fill: var(--f4); } .f-5 { fill: var(--f5); } .f-6 { fill: var(--f6); }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .7rem; padding: .5rem 1.5rem .6rem; border-bottom: 1.5px solid var(--bed); }
.top .mark { width: 28px; height: 28px; flex: none; }
.brandline { display: flex; gap: .5rem; align-items: baseline; font-size: 1rem; }
.brandline a { color: var(--ink); text-decoration: none; }
.brandline a:hover { text-decoration: underline; }
.brandline .carlos { font-weight: 600; letter-spacing: .06em; font-size: .9rem; }
.brandline .here { font: 600 1.35rem/1 var(--serif); letter-spacing: -.01em; }
.brandline .sep { color: var(--muted); }
.brandline .now { color: var(--acequia); font-weight: 600; }

/* The project download looks like the editor's copy buttons: it is a
   tool, not the page's main action (that is Next). */
.dl, .copy {
  display: inline-flex; gap: .4rem; align-items: center; white-space: nowrap;
  font: 600 .74rem/1.2 var(--sans); color: var(--ink); text-decoration: none;
  border: 1.5px solid var(--ink); border-radius: 3px; padding: .3rem .6rem; background: var(--edge); cursor: pointer;
}
.dl { margin-left: auto; }
.dl svg.i, .copy svg.i { width: 14px; height: 14px; }
.dl:hover, .copy:hover { background: var(--plaster-2); }
.copy[hidden] { display: none; }
.copy .i-done { display: none; color: var(--acequia); }
.copy.done .i-copy { display: none; }
.copy.done .i-done { display: block; }

.prog { margin: 0 0 0 auto; display: flex; align-items: center; gap: .6rem; font: 500 .8rem var(--mono); color: var(--muted); }
.dl + .prog { margin-left: 1.2rem; }
.prog .bar { display: flex; gap: 3px; }
.prog .bar b { width: 16px; height: 6px; border-radius: 3px; background: var(--bed); }
.prog .bar b.on { background: var(--chan); }

/* ---------- Buttons (the homepage's, a size smaller) ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .55rem;
  min-height: 2.75rem; padding: .6rem 1.1rem;
  border-radius: 3px; border: 1.5px solid var(--ink);
  font: 600 .95rem/1.2 var(--sans); text-decoration: none; color: var(--ink);
  background: var(--plaster);
}
.btn.primary { background: var(--almagra); border-color: var(--almagra); color: var(--on-almagra); }
.btn:hover { background: var(--plaster-2); }
.btn.primary:hover { background: var(--ink); border-color: var(--ink); color: var(--plaster); }

/* ---------- Step list ---------- */
.steplist { display: flex; flex-direction: column; min-height: 0; width: 15rem; background: var(--plaster-2); border-right: 1.5px solid var(--bed); }
.steplist .head { display: flex; align-items: center; justify-content: space-between; min-height: 3.2rem; padding: 1rem 1rem .4rem 1.5rem; }
.steplist h2 { margin: 0; font: 600 .74rem var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.steplist ol { list-style: none; margin: 0; padding: 0 .5rem 1rem; overflow: auto; }
.steplist li a { display: flex; gap: .6rem; align-items: center; padding: .42rem .5rem; border-radius: 3px; font-size: .9rem; line-height: 1.3; color: var(--muted); text-decoration: none; }
.steplist li a:hover { background: var(--plaster); color: var(--ink); }
.n { width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; flex: none; font: 600 .72rem var(--mono); background: var(--plaster); box-shadow: inset 0 0 0 2px var(--bed); color: var(--acequia); }
.steplist li.ok a { color: var(--ink); }
.steplist li.ok .n { background: var(--chan); color: var(--edge); box-shadow: none; }
.steplist li.cur a { background: var(--edge); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--almagra); }
.steplist li.cur .n { box-shadow: inset 0 0 0 2px var(--almagra); color: var(--almagra); }
.tgl { display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0; border: 1.5px solid var(--bed); border-radius: 3px; background: var(--plaster); color: var(--ink); cursor: pointer; }
.tgl[hidden] { display: none; }
.tgl:hover { border-color: var(--ink); }
.tgl .ico-open { display: none; }
.steps-collapsed .tgl .ico-open { display: block; }
.steps-collapsed .tgl .ico-close { display: none; }

/* ---------- Lesson ---------- */
.lesson { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1.5px solid var(--bed); }
.lesson .scroll { flex: 1; overflow: auto; padding: 1.8rem 2rem 1rem; }
.lesson-in { max-width: 42rem; }
.kicker { margin: 0; font: 600 .78rem var(--mono); color: var(--almagra); letter-spacing: .04em; }
h1 { font: 600 2.3rem/1.08 var(--serif); letter-spacing: -.015em; text-wrap: balance; margin: .3rem 0 1rem; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 .9rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose h2, .prose h3 { font: 600 1.3rem/1.2 var(--serif); margin: 1.4rem 0 .5rem; }
.prose pre { margin: 0 0 .9rem; padding: .8rem 1rem; background: var(--plaster-2); border-radius: 3px; font-size: .82rem; line-height: 1.65; overflow-x: auto; }
.done { margin-top: 1.2rem; padding: .8rem 1rem; background: var(--edge); border-left: 3px solid var(--chan); border-radius: 2px; }
.done h2 { display: flex; gap: .4rem; align-items: center; margin: 0 0 .25rem; font: 600 .9rem var(--sans); color: var(--acequia); }
.done p { margin: 0; }
.done p + p { margin-top: .5rem; }
.llm { margin: 2rem 0 0; padding-top: .8rem; border-top: 1.5px solid var(--bed); font-size: .85rem; color: var(--muted); }
.navbar { display: flex; justify-content: space-between; gap: .75rem; padding: .9rem 2rem; border-top: 1.5px solid var(--bed); background: var(--plaster); }
.navbar .btn { max-width: 48%; }

/* ---------- Editor: the homepage's markup-window grammar ---------- */
.codepane { display: flex; flex-direction: column; gap: 1rem; min-height: 0; min-width: 0; overflow: auto; padding: 1.25rem 1.5rem; background: var(--plaster-2); }
.mk { display: flex; flex-direction: column; min-height: 0; border: 1.5px solid var(--ink); border-radius: 4px; background: var(--screen); overflow: hidden; flex: none; }
.mk-tabs { display: flex; flex-wrap: wrap; border-bottom: 1.5px solid var(--ink); background: var(--plaster-2); }
.mk-tabs[hidden] { display: none; }
.mk-tab { display: flex; align-items: center; gap: .45rem; margin: 0; padding: .5rem .9rem; font: 500 .78rem/1.3 var(--mono); color: var(--muted); background: none; border: 0; border-right: 1.5px solid var(--bed); }
button.mk-tab { cursor: pointer; }
button.mk-tab:hover { color: var(--ink); }
.mk-tab.on, .mk-tab[aria-selected="true"] { background: var(--screen); color: var(--ink); font-weight: 600; margin-bottom: -1.5px; border-bottom: 1.5px solid var(--screen); }
.tag { font: 700 .62rem/1.2 var(--sans); letter-spacing: .06em; padding: .1rem .35rem; border-radius: 2px; color: var(--ink); }
.tag.new { background: var(--cempa); color: #1E2629; }
.tag.edit { background: var(--bed); }
.mk-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 2.2rem; padding: .25rem .5rem .25rem .9rem; background: var(--plaster-2); border-bottom: 1.5px solid var(--ink); font: 500 .74rem var(--mono); color: var(--muted); }
.mk-bar .path { display: flex; align-items: center; gap: .45rem; min-width: 0; overflow-wrap: anywhere; }
.mk-bar .path svg.i { width: 14px; height: 14px; }
.file + .file { border-top: 1.5px solid var(--ink); }
pre { margin: 0; tab-size: 4; }
pre.code { padding: .9rem 1rem; font-size: .82rem; line-height: 1.65; overflow: auto; color: var(--ink); }
pre.code code { display: block; min-width: max-content; }
.code .ln { display: block; padding: 0 1rem; margin: 0 -1rem; }
.code .ln.hl { background: var(--hl); box-shadow: inset 3px 0 0 var(--cempa); }
.code .k { color: var(--cobalt); font-weight: 500; }
.code .s { color: var(--f3); }
.code .c { color: var(--muted); font-style: italic; }
pre.cmd { padding: .9rem 1rem; font-size: .82rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
pre.cmd .p { color: var(--acequia); user-select: none; }

/* With tabs (set by /tour.js once it has built them), one file shows at
   a time, its head moves into the tab strip, and the open file fills
   the pane above the terminal, scrolling inside its own box. */
.editor.tabbed .file-head { display: none; }
.editor.tabbed .file + .file { border-top: 0; }
.file[hidden] { display: none; }

/* ---------- Index page ----------
   The hero shows the finished app working: Ada's and Bob's windows on
   one room, and the message Bob sends arriving in both. It plays once,
   about three seconds in, and stays; reduced motion shows the end. */
.index { max-width: 72rem; margin: 0 auto; padding: 3rem 1.5rem 3rem; }
.index-hero { display: grid; gap: 2.5rem; align-items: center; }
.index h1 { font: 600 clamp(2.8rem, 1.7rem + 3.6vw, 4.6rem)/1.02 var(--serif); letter-spacing: -.02em; margin: 0 0 1.1rem; text-wrap: balance; }
.index .lede { font: 400 1.32rem/1.55 var(--serif); max-width: 30em; margin: 0 0 1.6rem; text-wrap: pretty; }
.index .lede .ai { font-size: .8em; margin-right: .2em; }
.index-go { display: flex; flex-wrap: wrap; gap: .75rem; margin: 0 0 1rem; }
.index-go .btn { min-height: 3rem; padding: .65rem 1.2rem; font-size: 1rem; }
.needs { margin: 0; color: var(--muted); font-size: .92rem; max-width: 34em; }

.demo { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.demo-win { min-width: 0; background: var(--screen); border: 1.5px solid var(--ink); border-radius: 6px; box-shadow: 0 10px 0 -4px var(--bed); overflow: hidden; font-size: .84rem; }
.demo-bob { margin-top: 2.6rem; }
.demo-bar { display: flex; align-items: center; gap: .3rem; padding: .45rem .7rem; background: var(--plaster-2); border-bottom: 1.5px solid var(--ink); font: 500 .74rem var(--mono); color: var(--muted); }
.demo-bar i { width: .55rem; height: .55rem; border-radius: 50%; background: var(--bed); }
.demo-bar span { margin-left: .4rem; }
.demo-room { padding: .7rem .7rem .3rem; }
.demo-room p { margin: 0 0 .45rem; padding: .1rem .3rem; border-radius: 3px; }
.demo-room b { font-weight: 700; color: var(--acequia); margin-right: .35rem; }
.demo-box { display: flex; align-items: center; gap: .5rem; margin: .2rem .7rem .7rem; padding: .35rem .35rem .35rem .6rem; border: 1.5px solid var(--bed); border-radius: 4px; background: var(--edge); min-height: 2.3rem; }
.demo-field { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.demo-typed { display: inline-block; vertical-align: bottom; overflow: hidden; max-width: 0; }
.demo-send { padding: .2rem .6rem; border-radius: 3px; background: var(--almagra); color: var(--on-almagra); font-weight: 600; font-size: .8rem; }
.demo figcaption { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; max-width: 30em; }

.demo-bob .demo-typed { animation: demo-type 2.6s .4s linear both; }
.demo-new { animation: demo-arrive .45s 3s ease-out both; }
.demo-ada .demo-new { animation: demo-arrive .45s 3s ease-out both, demo-glow 1.8s 3s ease-out both; }
@keyframes demo-type { 0% { max-width: 0; } 70% { max-width: 32ch; } 90% { max-width: 32ch; } 100% { max-width: 0; } }
@keyframes demo-arrive { from { opacity: 0; transform: translateY(.4rem); } to { opacity: 1; transform: none; } }
@keyframes demo-glow { from { background: var(--hl); box-shadow: inset 3px 0 0 var(--cempa); } 60% { background: var(--hl); box-shadow: inset 3px 0 0 var(--cempa); } to { background: transparent; box-shadow: none; } }
@media (prefers-reduced-motion: reduce) {
  .demo-bob .demo-typed, .demo-new, .demo-ada .demo-new { animation: none; }
}

.index-stages { margin-top: 4rem; padding-top: 2rem; border-top: 1.5px solid var(--bed); }
.index-stages h2 { font: 600 1.9rem/1.2 var(--serif); margin: 0 0 1.4rem; }
.stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 2rem; counter-reset: stage; }
.stage h3 { display: flex; align-items: center; gap: .6rem; font: 600 1.3rem/1.2 var(--serif); margin: 0 0 .4rem; }
.stage h3::before { content: ""; flex: none; width: 1rem; height: 1.15rem; clip-path: polygon(0 0, 100% 0, 50% 100%); background: var(--f0); }
.stage:nth-child(2) h3::before { background: var(--f2); }
.stage:nth-child(3) h3::before { background: var(--f1); }
.stage > p { margin: 0 0 .8rem; color: var(--muted); max-width: 26em; }
.index-steps { list-style: none; margin: 0; padding: 0; }
.index-steps a { display: flex; gap: .7rem; align-items: center; padding: .38rem 0; color: var(--ink); text-decoration: none; }
.index-steps a:hover .t { text-decoration: underline; text-underline-offset: .2em; }
.index-steps .n { flex: none; width: 1.7rem; height: 1.7rem; border-radius: 50%; display: grid; place-items: center; font: 600 .72rem var(--mono); color: var(--acequia); background: var(--plaster); box-shadow: inset 0 0 0 2px var(--bed); }
.index .llm { margin-top: 3rem; }

.demo-bar span { white-space: nowrap; }
@media (max-width: 36rem) {
  .demo { grid-template-columns: minmax(0, 1fr); }
  .demo-bob { margin: 0 0 0 1.5rem; }
}
@media (min-width: 56rem) {
  .index { padding-top: 4rem; }
  .index-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 3.5rem; }
  .stages { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Wide: the page is the window ---------- */
@media (min-width: 60.01rem) {
  body.tour-step { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  .tour-step .main { flex: 1; min-height: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.25fr); }
  /* With tabs, the open file grows to fill the pane and scrolls itself. */
  .editor.tabbed { flex: 1 1 auto; }
  .editor.tabbed .file:not([hidden]) { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .editor.tabbed pre.code { flex: 1; min-height: 0; }

  .steplist { transition: width .18s ease; }
  .steps-collapsed .steplist { width: 3.6rem; }
  .steps-collapsed .steplist h2, .steps-collapsed .steplist .t { display: none; }
  .steps-collapsed .steplist .head { justify-content: center; padding: 1rem 0 .4rem; }
  .steps-collapsed .steplist ol { padding: 0 .45rem 1rem; }
  .steps-collapsed .steplist li a { justify-content: center; padding: .35rem 0; }
  .steps-collapsed .steplist li.cur a { box-shadow: none; background: none; }
}
@media (prefers-reduced-motion: reduce) { .steplist { transition: none; } }

/* ---------- Narrow: stacked, the page scrolls ----------
   Order: steps, lesson, editor, then Back/Next, so the reader meets the
   code before the way on. The lesson box steps aside (display: contents)
   to let its two parts take places either side of the editor. */
@media (max-width: 60rem) {
  .top { padding-inline: 1rem; }
  .dl { margin-left: 0; }
  .prog { margin-left: auto; }
  .tour-step .main { display: flex; flex-direction: column; }
  .steplist { width: auto; border-right: 0; border-bottom: 1.5px solid var(--bed); }
  .steplist .head { padding: .7rem 1rem .3rem; min-height: 0; }
  .lesson { display: contents; }
  .lesson .scroll { order: 1; overflow: visible; padding: 1.4rem 1rem 1rem; }
  .codepane { order: 2; overflow: visible; padding: 1rem; }
  .codepane.empty { display: none; }
  .navbar { order: 3; padding: .9rem 1rem; }
  h1 { font-size: 2rem; }
  pre.code { max-height: 70vh; }

  /* Collapsed, the list is a row of numbers. */
  .steps-collapsed .steplist { flex-direction: row; align-items: center; }
  .steps-collapsed .steplist .head { order: 2; padding: .5rem 1rem .5rem 0; }
  .steps-collapsed .steplist h2, .steps-collapsed .steplist .t { display: none; }
  .steps-collapsed .steplist ol { display: flex; flex-wrap: wrap; gap: .2rem; flex: 1; padding: .5rem 1rem; }
  .steps-collapsed .steplist li a { padding: .2rem; }
  .steps-collapsed .steplist li.cur a { box-shadow: none; background: none; }
}
