/*
 * The interactive lessons' design system (#181).
 *
 * Part 1 is lesson 1's own stylesheet, moved here unchanged so all four lessons
 * share one language: Archivo for the interface, IBM Plex Mono for every price
 * and number, the exchange-floor palette, the 3-panel stage and the narrator.
 * Part 2 adds what the lessons share beyond lesson 1: the nav strip, the
 * fictional-token badge, the language switcher, the footer bridge and its call
 * to action, and the P&L figures.
 */

/* ---- part 1: lesson 1, unchanged ---- */
:root{
  --floor:#EDF0F3;        /* exchange floor */
  --panel:#FFFFFF;
  --ink:#1B2430;
  --ink-soft:#5C6774;
  --line:#D8DEE5;
  --bid:#0E8A5F;
  --bid-bg:#E3F3EC;
  --ask:#C6403C;
  --ask-bg:#FAE9E8;
  --match:#C77D11;
  --match-bg:#FBF0DC;
  --hold:#4A3FBF;
  --hold-bg:#EBE9FA;
  --radius:10px;
}
*{box-sizing:border-box; margin:0; padding:0;}
html{font-size:16px;}
body{
  font-family:'Archivo',sans-serif;
  background:var(--floor);
  color:var(--ink);
  min-height:100vh;
  padding:clamp(16px,4vw,48px);
}
.mono{font-family:'IBM Plex Mono',monospace; font-variant-numeric:tabular-nums;}

header{max-width:1060px; margin:0 auto 28px;}
.kicker{font-size:14px; color:var(--ink-soft); letter-spacing:.02em; margin-bottom:6px;}
h1{
  font-size:clamp(26px,4vw,40px);
  font-weight:700;
  font-stretch:80%;
  line-height:1.1;
  max-width:22ch;
}
.lede{margin-top:10px; font-size:16px; color:var(--ink-soft); max-width:58ch; line-height:1.55;}

.stage{
  max-width:1060px; margin:0 auto;
  display:grid;
  grid-template-columns:250px minmax(0,1fr) 250px;
  gap:18px;
  align-items:start;
}
@media (max-width:860px){
  .stage{grid-template-columns:1fr 1fr;}
  .book-wrap{grid-column:1 / -1; order:-1;}
}
@media (max-width:560px){
  .stage{grid-template-columns:1fr;}
}

.panel{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:18px;
}
.panel h2{font-size:13px; font-weight:600; color:var(--ink-soft); margin-bottom:12px;}

.cash{font-size:30px; font-weight:600;}
.cash-label{font-size:12px; color:var(--ink-soft); margin-top:2px; margin-bottom:16px;}

fieldset{border:none; margin-bottom:14px;}
legend{font-size:13px; font-weight:600; margin-bottom:8px;}
.order-type{display:flex; gap:6px;}
.order-type label{
  flex:1; text-align:center; font-size:13px; font-weight:600;
  border:1px solid var(--line); border-radius:8px; padding:8px 4px;
  cursor:pointer; color:var(--ink-soft); background:var(--floor);
}
.order-type input{position:absolute; opacity:0; pointer-events:none;}
.order-type input:checked + span{color:var(--ink);}
.order-type label:has(input:checked){background:#fff; border-color:var(--ink); color:var(--ink);}
.order-type label:has(input:focus-visible){outline:2px solid var(--ink); outline-offset:2px;}

.limit-price{margin-bottom:14px;}
.limit-price .row{display:flex; justify-content:space-between; align-items:baseline; margin-bottom:6px;}
.limit-price .row span:first-child{font-size:13px; font-weight:600;}
input[type=range]{width:100%; accent-color:var(--ink);}

.place{
  width:100%; font:inherit; font-weight:600; font-size:15px;
  background:var(--ink); color:#fff; border:none; border-radius:8px;
  padding:12px; cursor:pointer;
}
.place:hover{background:#2B3648;}
.place:disabled{background:var(--line); color:var(--ink-soft); cursor:default;}
.place:focus-visible{outline:2px solid var(--ink); outline-offset:2px;}
.reset{
  width:100%; font:inherit; font-size:13px; margin-top:10px;
  background:none; border:1px solid var(--line); border-radius:8px;
  padding:8px; cursor:pointer; color:var(--ink-soft);
}
.reset:hover{border-color:var(--ink-soft); color:var(--ink);}

/* ---- the book ---- */
.book-head{display:flex; justify-content:space-between; align-items:baseline; margin-bottom:12px;}
.book-head .pair{font-size:15px; font-weight:700;}
.book-head .last{font-size:13px; color:var(--ink-soft);}
.side-label{font-size:12px; color:var(--ink-soft); margin:2px 0 6px;}
.rows{display:flex; flex-direction:column; gap:5px;}
.order-row{
  position:relative;
  display:grid; grid-template-columns:70px 1fr auto;
  align-items:center; gap:10px;
  padding:8px 12px; border-radius:7px;
  font-size:14px;
  overflow:hidden;
  transition:transform .45s ease, opacity .45s ease, background .3s ease;
}
.order-row .depth{
  position:absolute; inset:0 auto 0 0; opacity:.55; z-index:0;
  transition:width .4s ease;
}
.order-row > span{position:relative; z-index:1;}
.order-row .price{font-weight:600;}
.order-row .qty{font-size:13px; text-align:right;}
.order-row .who{font-size:12px; color:inherit; opacity:.75; text-align:right;}
.ask-row{background:var(--ask-bg); color:#7E2A27;}
.ask-row .depth{background:#F2C9C7;}
.bid-row{background:var(--bid-bg); color:#0A5C40;}
.bid-row .depth{background:#BFE5D3;}
.mine{box-shadow:inset 0 0 0 2px var(--bid);}
.matched{background:var(--match-bg) !important; color:#7A4C08 !important; box-shadow:inset 0 0 0 2px var(--match);}
.matched .depth{background:#F1DCB6 !important;}
.enter-left{transform:translateX(-36px); opacity:0;}
.enter-right{transform:translateX(36px); opacity:0;}
.leave{transform:scale(.85); opacity:0;}

.spread-band{
  display:flex; align-items:center; gap:10px; margin:10px 0;
}
.spread-band .rule{flex:1; border-top:1px dashed var(--line);}
.spread-band .val{font-size:12px; color:var(--ink-soft);}

/* ---- narrator ---- */
.narrator{
  max-width:1060px; margin:18px auto 0;
  background:var(--ink); color:#fff;
  border-radius:var(--radius);
  padding:14px 18px;
  display:flex; gap:12px; align-items:baseline;
  min-height:52px;
}
.narrator .step{
  font-family:'IBM Plex Mono',monospace; font-size:12px;
  color:#9FB0C3; white-space:nowrap;
}
.narrator .text{font-size:15px; line-height:1.5;}

/* ---- portfolio ---- */
.pile{display:flex; flex-direction:column; gap:8px; min-height:64px;}
.cert{
  background:var(--hold-bg); color:var(--hold);
  border-radius:7px; padding:10px 12px;
  font-size:13px; font-weight:600;
  display:flex; justify-content:space-between; gap:8px;
  transition:transform .45s ease, opacity .45s ease;
}
.cert small{font-weight:400; opacity:.8;}
.empty{font-size:13px; color:var(--ink-soft);}
.holdings-total{margin-top:14px; padding-top:12px; border-top:1px solid var(--line);
  display:flex; justify-content:space-between; font-size:13px;}
.holdings-total b{font-weight:600;}

footer{max-width:1060px; margin:26px auto 0; font-size:13px; color:var(--ink-soft); line-height:1.6; max-width:70ch;}

@media (prefers-reduced-motion:reduce){
  *{transition:none !important;}
}

/* ---- part 2: shared by all four lessons ---- */

/* The nav strip and the language switcher sit above the header. */
.lesson-top{max-width:1060px; margin:0 auto 18px; display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap;}
.lesson-nav{display:flex; align-items:center; gap:6px; font-size:13px; color:var(--ink-soft);}
.lesson-nav .brand{font-weight:700; color:var(--ink); text-decoration:none; margin-right:6px;}
.lesson-nav a.num{
  display:inline-flex; align-items:center; justify-content:center;
  min-width:28px; height:28px; padding:0 6px; border-radius:7px;
  border:1px solid var(--line); background:var(--panel);
  color:var(--ink); text-decoration:none; font-family:'IBM Plex Mono',monospace; font-size:13px;
}
.lesson-nav a.num[aria-current="page"]{background:var(--ink); color:#fff; border-color:var(--ink);}
.lesson-nav a:focus-visible, .lang select:focus-visible{outline:2px solid var(--ink); outline-offset:2px;}
.lang{font-size:13px; color:var(--ink-soft); display:flex; align-items:center; gap:6px;}
.lang select{font:inherit; font-size:13px; padding:4px 6px; border:1px solid var(--line); border-radius:7px; background:var(--panel); color:var(--ink);}

/* DEMO is fictional, and the page says so beside the pair. */
.token-badge{
  display:inline-block; margin-left:8px; padding:2px 7px; border-radius:6px;
  border:1px dashed var(--hold); color:var(--hold); background:var(--hold-bg);
  font-family:'IBM Plex Mono',monospace; font-size:10.5px; font-weight:600;
  letter-spacing:.04em; text-transform:uppercase; vertical-align:middle;
}

/* The footer bridge and its one call to action. */
.bridge{max-width:1060px; margin:26px auto 0;}
.bridge p{font-size:13px; color:var(--ink-soft); line-height:1.6; max-width:70ch; margin-bottom:10px;}
.cta{
  display:inline-block; margin-top:6px; font-weight:600; font-size:15px;
  background:var(--hold); color:#fff; text-decoration:none; border:none;
  border-radius:8px; padding:11px 18px; cursor:pointer;
}
.cta:hover{background:#3B31A0;}
.cta:focus-visible{outline:2px solid var(--ink); outline-offset:2px;}

/* P&L: green for a gain, red for a loss, ink at zero. */
.pnl{font-family:'IBM Plex Mono',monospace; font-variant-numeric:tabular-nums; font-weight:600;}
.pnl.up{color:var(--bid);}
.pnl.down{color:var(--ask);}

/* A refusal in the narrator reads as a warning, not a step. */
.narrator.refused .step{color:#F2C9C7;}

/* Lesson 3: the total line under the fills. */
.fill-total{font-weight:600;}

/* Lesson 4: the bot's code, and the tick strip under it. */
.code{
  background:#141B24; color:#D8DEE5; border-radius:8px; padding:12px 14px;
  font-family:'IBM Plex Mono',monospace; font-size:12.5px; line-height:1.55;
  overflow-x:auto; white-space:pre; margin-bottom:12px; tab-size:4;
}
.code .kw{color:#B9A8FF;}
.code .str{color:#9FE0B8;}
.code .num{color:#F2C27A;}
.code .cmt{color:#9AA0B4; font-style:italic;}
.code .self{color:#8FC7FF;}
.code .line-hot{background:rgba(199,125,17,.28); border-radius:3px;}
.run{background:var(--hold);}
.run:hover{background:#3B31A0;}
.ticks{display:flex; flex-wrap:wrap; gap:5px; margin-top:12px;}
.tick-chip{font-family:'IBM Plex Mono',monospace; font-size:11.5px; padding:3px 7px; border-radius:6px;
  border:1px solid var(--line); background:var(--floor); color:var(--ink-soft);}
.tick-chip.now{border-color:var(--ink); color:var(--ink); background:#fff;}
.tick-chip.fired{border-color:var(--hold); color:var(--hold); background:var(--hold-bg); font-weight:600;}
.status{font-size:13px; line-height:1.5; color:var(--ink-soft);}

/* Grid items default to min-width:auto, so the widest unbreakable child sets
   the column: lesson 4's longest code line pushed the stage to ~560px on a
   390px phone. Let the panels shrink; the code block scrolls inside itself. */
.stage > *{min-width:0;}
