/* Home page (/): the site drawn as a transit map, its legend, and a first-stop ticket. */

.home { flex: 1; min-height: 0; overflow-y: auto; }
.home-section { max-width: 1080px; margin: 0 auto; padding: 96px 28px 0; }

.section-head { max-width: 640px; margin-bottom: 34px; }
.section-head h2 {
  margin-top: 10px;
  font-family: var(--font-display); font-size: clamp(30px, 4vw, 44px); font-weight: 600;
  line-height: 1.08; letter-spacing: -0.025em; color: var(--text);
}

/* ── Hero ── */
.hero { max-width: 1160px; margin: 0 auto; padding: 64px 28px 0; }
.hero h1 {
  margin-top: 16px; max-width: 900px;
  font-family: var(--font-display); font-size: clamp(42px, 6.4vw, 80px); font-weight: 600;
  line-height: .98; letter-spacing: -0.035em; color: var(--text);
}
.hero h1 em { font-style: italic; }
.hero h1 .marker {
  background-size: 0% 100%; background-repeat: no-repeat;
  animation: marker-sweep .9s cubic-bezier(.6, .1, .2, 1) .4s forwards;
}
@keyframes marker-sweep { to { background-size: 100% 100%; } }
.hero-sub { margin-top: 22px; max-width: 600px; font-size: 19px; line-height: 1.6; color: var(--body-text); }
.hero-actions { margin-top: 30px; display: flex; gap: 14px; flex-wrap: wrap; }

/* ── The map sheet ── */
.map-sheet {
  position: relative;
  margin-top: 52px;
  background-color: var(--surface);
  background-image:
    linear-gradient(var(--dot) 1px, transparent 1px),
    linear-gradient(90deg, var(--dot) 1px, transparent 1px);
  background-size: 40px 40px;
  border: 2px solid var(--ink); border-radius: 6px;
  box-shadow: var(--shadow-lg);
}
.map-area { position: relative; }
.map-scroll { overflow-x: auto; padding: 26px 18px 18px; }

/* ── Split-flap departure board ── */
.board {
  --flap-bg: #1f252d; --flap-fg: #f3d27a;
  margin: 18px 18px 0;
  padding: 12px 14px 14px;
  background: #171c22;
  border: 2px solid var(--ink); border-radius: 6px;
  box-shadow: 3px 3px 0 var(--shadow-color);
  color: var(--flap-fg);
  font-family: var(--font-mono);
  overflow-x: auto;
}
.board-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.board-title { font-size: 12px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: #e8edf2; }
.board-title i { margin-right: 6px; color: var(--flap-fg); }
.board-clock { font-size: 20px; font-weight: 600; letter-spacing: .08em; color: var(--flap-fg); font-variant-numeric: tabular-nums; }
.board-row {
  display: grid; grid-template-columns: 70px 290px 72px 190px; gap: 28px; justify-content: start;
  align-items: center; padding: 4px 0;
  border-top: 1px solid #262d36;
}
.board-cols { border-top: 0; padding-bottom: 6px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: #8d97a3; }
.flap { font-size: 16px; font-weight: 500; letter-spacing: .04em; white-space: pre; }
/* once home.js has split a field into character tiles */
.flap.tiles { display: inline-flex; gap: 2px; letter-spacing: 0; }
.flap .tile {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.05em; height: 1.55em;
  background: var(--flap-bg); border-radius: 2px;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .5);
}
.flap .tile::after {   /* the hinge line across the middle of each flap */
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0, 0, 0, .55);
}
.flap .tile.flip { animation: flap .09s linear; }
@keyframes flap { 50% { transform: scaleY(.15); } }
.board-status.arrived { color: #9fd4b3; }
.board-status.boarding { color: var(--flap-fg); animation: blink 1.6s steps(1) infinite; }
.board-soon .flap { color: #9aa4b0; }
@keyframes blink { 50% { opacity: .45; } }

/* ── The train ── */
.train { display: none; transition: opacity .6s ease; }
.train.running { display: inline; }
.train.away { opacity: 0; }
.train-body rect:first-child { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.train-window { fill: var(--marker); }
.train-light { fill: var(--marker); }
.train.moving .train-body { animation: bob .5s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-1.2px); } }
.map { display: block; width: 100%; min-width: 760px; height: auto; overflow: visible; }

.map-cartouche {
  position: absolute; top: 16px; right: 16px; z-index: 1;
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 14px;
  background: var(--bg); border: 1.5px solid var(--ink); border-radius: 3px;
  box-shadow: 2px 2px 0 var(--shadow-color);
}
.cartouche-title { font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 16px; color: var(--text); }
.cartouche-sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }
.compass { position: absolute; left: 18px; bottom: 16px; width: 46px; height: 46px; color: var(--muted); }
.compass text { font-family: var(--font-mono); font-size: 8px; fill: currentColor; }

/* SVG map parts */
.track { fill: none; stroke-width: 9; stroke-linecap: round; }
.line-name { font-family: var(--font-display); font-size: 22px; font-weight: 600; font-style: italic; }
.tick { stroke: var(--surface); stroke-width: 3; stroke-linecap: round; opacity: .85; }
.tick.done { stroke: var(--done); opacity: 1; stroke-width: 4; }
.station { fill: var(--surface); stroke: var(--ink); stroke-width: 4; transition: r .15s, fill .15s; }
.station-link:hover .station, .station-link:focus-visible .station { r: 16; fill: var(--marker); }
.station-link { outline: none; }
.st-name { font-family: var(--font-display); font-size: 19px; font-weight: 600; fill: var(--text); text-anchor: middle; }
.st-num { font-family: var(--font-mono); font-size: 12px; fill: var(--faint); text-anchor: middle; letter-spacing: .06em; }
.terminus circle { fill: var(--surface); stroke: var(--ink); stroke-width: 4; }
.terminus .terminus-dot { fill: var(--ink); stroke: none; }

.hub circle { fill: var(--ink); }
.hub text {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: .1em;
  fill: var(--on-ink); text-anchor: middle;
}

.soon-line path { fill: none; stroke: var(--muted); stroke-width: 4; stroke-dasharray: 2 9; stroke-linecap: round; }
.soon-line .barrier rect { fill: var(--marker); stroke: var(--ink); stroke-width: 1.5; }
.soon-line .barrier path { stroke: var(--ink); stroke-width: 2.5; stroke-dasharray: none; }
.soon-name { font-family: var(--font-display); font-size: 18px; font-weight: 600; fill: var(--body-text); }
.soon-tag { font-family: var(--font-mono); font-size: 11px; fill: var(--faint); letter-spacing: .06em; }

.pin { display: none; }
.pin.show { display: inline; }
.pin path { fill: var(--warm); stroke: var(--ink); stroke-width: 2; }
.pin circle { fill: var(--surface); }
.pin text { font-family: var(--font-display); font-style: italic; font-size: 17px; font-weight: 600; fill: var(--text); }

/* Map motion: the track draws itself, then stations and the pin drop in */
.track { stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: draw-track 1.4s cubic-bezier(.5, 0, .2, 1) .3s forwards; }
@keyframes draw-track { to { stroke-dashoffset: 0; } }
.station-link, .terminus { animation: pop-in .4s cubic-bezier(.3, 1.6, .5, 1) backwards; transform-box: fill-box; transform-origin: center; }
.station-link:nth-of-type(1) { animation-delay: .6s; }
.station-link:nth-of-type(2) { animation-delay: .95s; }
.station-link:nth-of-type(3) { animation-delay: 1.3s; }
.station-link:nth-of-type(4) { animation-delay: 1.5s; }
.terminus { animation-delay: 1.6s; }
.tick { animation: fade-in .3s ease backwards; animation-delay: 1.2s; }
/* animate the pin's parts, not the group: a CSS transform on the group would
   replace its SVG transform="translate(...)" and lose its position */
.pin.show > * { animation: pin-drop .55s cubic-bezier(.3, 1.5, .5, 1) 1.9s backwards; }
@keyframes pop-in { from { opacity: 0; transform: scale(.3); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pin-drop { from { opacity: 0; transform: translateY(-40px); } }
.soon-line { animation: fade-in .6s ease 1.4s backwards; }

/* ── Legend ── */
.legend-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 48px; border-top: 2px solid var(--ink); }
.legend-list li { display: flex; gap: 20px; align-items: flex-start; padding: 22px 0; border-bottom: 1px solid var(--border); }
.legend-list svg { flex-shrink: 0; width: 56px; height: 38px; margin-top: 4px; overflow: visible; }
.legend-list h3 { font-family: var(--font-display); font-size: 21px; font-weight: 600; color: var(--text); }
.legend-list p { margin-top: 4px; font-size: 16px; line-height: 1.6; color: var(--body-text); }
.lg-track { stroke: #3776ab; stroke-width: 7; stroke-linecap: round; }
.lg-station { fill: var(--surface); stroke: var(--ink); stroke-width: 3.5; }
.lg-tick { stroke: var(--surface); stroke-width: 3; stroke-linecap: round; }
.lg-tick.done { stroke: var(--done); stroke-width: 3.5; }
.lg-pin { fill: var(--warm); stroke: var(--ink); stroke-width: 1.8; }
.lg-pin-dot { fill: var(--surface); }
.lg-soon { stroke: var(--muted); stroke-width: 4; stroke-dasharray: 2 8; stroke-linecap: round; }
.lg-barrier { fill: var(--marker); stroke: var(--ink); stroke-width: 1.5; }

/* ── First stop: a ticket ── */
.ticket {
  position: relative;
  display: grid; grid-template-columns: 220px 1fr;
  background: var(--surface);
  border: 2px solid var(--ink); border-radius: 8px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.ticket-stub {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  padding: 28px 24px;
  background: var(--accent-soft);
  border-right: 2px dashed var(--ink);
}
/* punched holes on the perforation */
.ticket-stub::before, .ticket-stub::after {
  content: ""; position: absolute; right: -13px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--ink);
}
.ticket-stub::before { top: -13px; }
.ticket-stub::after { bottom: -13px; }
/* hover: the stub starts to tear off along the perforation */
.ticket-stub { transition: transform .35s cubic-bezier(.3, 1.4, .5, 1); transform-origin: top right; }
.ticket:hover .ticket-stub { transform: rotate(-1.6deg) translate(-3px, 4px); }

/* "VALIDATED" stamp once the learner has passed the first exercise */
.ticket-stamp {
  position: absolute; left: 26px; bottom: 34px; z-index: 2;
  padding: 3px 12px;
  font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 26px;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--done); border: 4px double var(--done); border-radius: 6px;
  transform: rotate(-14deg); opacity: 0; pointer-events: none;
}
.ticket.validated .ticket-stamp { animation: stamp-in .6s cubic-bezier(.2, 1.4, .4, 1) .3s forwards; }
@keyframes stamp-in {
  from { opacity: 0; transform: rotate(-14deg) scale(2); }
  to   { opacity: .9; transform: rotate(-14deg) scale(1); }
}

.stub-label { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--accent); }
.stub-num { font-family: var(--font-display); font-size: 84px; font-weight: 600; line-height: .9; letter-spacing: -0.04em; color: var(--text); }
.stub-route { font-family: var(--font-display); font-size: 19px; font-style: italic; color: var(--text); line-height: 1.3; }
.stub-fine { margin-top: auto; padding-top: 18px; font-family: var(--font-mono); font-size: 10.5px; line-height: 1.5; color: var(--faint); }

.ticket-main { padding: 30px 34px 32px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.ticket-main h3 { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.ticket-main h3 span { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: 12.5px; font-weight: 400; letter-spacing: 0; color: var(--faint); }
.ticket-desc { font-size: 17px; line-height: 1.6; color: var(--body-text); max-width: 640px; }
.ticket-lesson { width: 100%; font-size: 15.5px; line-height: 1.65; color: var(--body-text); }
.ticket-task { width: 100%; padding: 14px 18px; background: color-mix(in srgb, var(--marker) 30%, var(--surface)); border-left: 4px solid var(--warm); border-radius: 3px; font-size: 15.5px; color: var(--body-text); }
.ticket-task-label { display: block; margin-bottom: 6px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--text); }

/* Markdown inside the ticket (same look as lesson pages) */
.home .md p { margin-bottom: 10px; }
.home .md > :last-child { margin-bottom: 0; }
.home .md ol { list-style: decimal; padding-left: 1.4em; }
.home .md li { margin-bottom: 4px; }
.home .md li::marker { color: var(--accent); font-family: var(--font-mono); }
.home .md strong { color: var(--text); font-weight: 600; }
.home .md :not(pre) > code { font-family: var(--font-mono); font-size: .88em; background: var(--inline-code-bg); color: var(--inline-code-fg); padding: 1px 5px; border-radius: 3px; }
.home .code-block {
  margin: 4px 0 12px; padding: 14px 16px;
  font-family: var(--font-mono); font-size: 14px; line-height: 1.6; color: var(--text);
  background: var(--bg); border: 1.5px solid var(--ink); border-radius: 4px;
  overflow-x: auto;
}
.home .code-block pre, .home .code-block code { font: inherit; color: inherit; white-space: pre; }
.home .code-block .k, .home .code-block .kn, .home .code-block .kc, .home .code-block .ow { color: #a64c36; font-weight: 500; }
.home .code-block .nf, .home .code-block .nb { color: #2d6a8a; }
.home .code-block .s, .home .code-block .s1, .home .code-block .s2, .home .code-block .sb { color: #3d7650; }
.home .code-block .m, .home .code-block .mi, .home .code-block .mf { color: #8a6516; }
.home .code-block .c, .home .code-block .c1 { color: #6e747d; font-style: italic; }
[data-theme="dark"] .home .code-block .k, [data-theme="dark"] .home .code-block .kn,
[data-theme="dark"] .home .code-block .kc, [data-theme="dark"] .home .code-block .ow { color: #f0a98f; }
[data-theme="dark"] .home .code-block .nf, [data-theme="dark"] .home .code-block .nb { color: #9cc8e8; }
[data-theme="dark"] .home .code-block .s, [data-theme="dark"] .home .code-block .s1,
[data-theme="dark"] .home .code-block .s2, [data-theme="dark"] .home .code-block .sb { color: #9fd4b3; }
[data-theme="dark"] .home .code-block .m, [data-theme="dark"] .home .code-block .mi { color: #edd28a; }
[data-theme="dark"] .home .code-block .c, [data-theme="dark"] .home .code-block .c1 { color: #7f8a96; }

/* ── End of the line ── */
.end-of-line {
  max-width: 1080px; margin: 88px auto 80px; padding: 0 28px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  font-family: var(--font-display); font-style: italic; font-size: 20px; color: var(--text);
}
.eol-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 5px var(--bg), 0 0 0 7px var(--ink); margin-right: 10px; }
.soon-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px;
  font-family: var(--font-body); font-style: normal; font-size: 14px; font-weight: 500; color: var(--body-text);
  border: 1.5px dashed var(--muted);
}
.soon-pill i { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Small screens ── */
@media (max-width: 860px) {
  .hero { padding-top: 40px; }
  .map-cartouche { position: static; margin: 14px 14px 0; display: inline-flex; }
  .board-row { grid-template-columns: 60px 280px 64px 180px; gap: 14px; }
  .compass { display: none; }
  .legend-list { grid-template-columns: 1fr; }
  .ticket { grid-template-columns: 1fr; }
  .ticket-stub { border-right: 0; border-bottom: 2px dashed var(--ink); flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 12px; }
  .ticket-stub::before, .ticket-stub::after { display: none; }
  .stub-num { font-size: 56px; }
  .home-section { padding-top: 72px; }
}
