/* ============================================================
   LyraMind v2 overlay.

   The upstream design system (lyramind.css) is good: one stylesheet, pure
   white ground, an AA-checked ink ramp. This file deliberately does NOT
   restate those tokens, and borrows their names throughout, so an upstream
   change still propagates here.

   It adds only what upstream is missing:
     1. Light only, so a dark OS cannot flip the site.
     2. A real mobile menu. Upstream hides the nav entirely below 900px.
     3. Components upstream has no equivalent for: the ask box, the
        walkthrough band, and plain-English glosses.
   ============================================================ */

/* ---------- 1. Light, whatever the OS says ----------------- */
:root,
:root[data-theme="light"],
:root[data-theme="dark"] { color-scheme: light; }
:root[data-theme="dark"] body { background: var(--bg); color: var(--ink); }

/* ---------- 2. Mobile menu --------------------------------- */
.lyra-burger {
  display: none;
  width: 40px; height: 40px;
  margin-left: auto;
  align-items: center; justify-content: center;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  flex: none;
}
.lyra-burger svg { width: 19px; height: 19px; }
.lyra-menu { display: none; }

@media (max-width: 900px) {
  .nav { position: relative; }
  .lyra-burger { display: inline-flex; }

  .lyra-menu.open {
    display: block;
    position: absolute;
    top: 100%; left: 0; right: 0;
    max-height: calc(100vh - 66px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 20px 22px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 40px rgba(11, 18, 32, .13);
  }
  .lm-group { padding: 14px 0 4px; border-top: 1px solid var(--line); }
  .lm-group:first-child { border-top: none; }
  .lyra-menu .lm-head {
    margin: 0 0 8px;
    font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
    font-weight: 700; color: var(--accent);
  }
  .lyra-menu a.lm-link {
    display: block; padding: 9px 0;
    font-size: 16px; font-weight: 600; color: var(--ink); text-decoration: none;
  }
  .lyra-menu a.lm-link span {
    display: block; margin-top: 1px;
    font-size: 13px; font-weight: 400; color: var(--ink-3);
  }
  .lyra-menu a.lm-solo { border-top: 1px solid var(--line); padding-top: 14px; }
  .lyra-menu a.lm-cta {
    display: block; margin-top: 16px; padding: 13px 18px;
    background: var(--accent); color: #fff;
    border-radius: 10px; font-weight: 600; font-size: 15px;
    text-align: center; text-decoration: none;
  }
  .nav > a.btn { display: none; }
}

/* ---------- 3. Ask box ------------------------------------- */
#lyra-ask { max-width: 760px; }
.ask-form {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px;
  box-shadow: 0 1px 2px rgba(11,18,32,.04), 0 6px 22px rgba(11,18,32,.06);
}
.ask-label {
  display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 700; color: var(--accent); margin-bottom: 12px;
}
.ask-row { display: flex; gap: 10px; }
.ask-input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 13px 15px;
}
.ask-input::placeholder { color: var(--ink-3); }
.ask-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.ask-go {
  flex: none; padding: 13px 24px; font-size: 15px; font-weight: 600;
  border: 1px solid var(--accent); border-radius: 10px;
  background: var(--accent); color: var(--accent-on, #fff); cursor: pointer;
}
.ask-go:hover { background: var(--accent-2); border-color: var(--accent-2); }
.ask-hint { margin: 14px 0 0; font-size: 13px; color: var(--ink-3); line-height: 2.1; }
.ask-chip {
  font: inherit; font-size: 12.5px; color: var(--accent);
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 10px; cursor: pointer; transition: .14s;
}
.ask-chip:hover { border-color: var(--accent); }

.ask-out { margin-top: 16px; }
.ask-out.open {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px;
  box-shadow: 0 1px 2px rgba(11,18,32,.04), 0 6px 22px rgba(11,18,32,.06);
}
.ask-thinking { color: var(--ink-3); font-size: 14.5px; }
.ask-lead { font-size: 16px; margin: 0 0 14px; color: var(--ink); }
.ask-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ask-head b { font-size: 19px; letter-spacing: -.01em; color: var(--ink); }
.ask-px { font-family: var(--mono); font-size: 13px; color: var(--ink-3); }

.ask-lanes { display: flex; flex-direction: column; margin-bottom: 16px; }
.ask-lane {
  display: grid; grid-template-columns: 158px 108px 1fr; gap: 10px;
  align-items: baseline; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13.5px;
}
.ask-lane:first-child { border-top: none; }
.ask-lane .al { font-weight: 700; color: var(--ink); }
.ask-lane .av { font-weight: 700; font-size: 12.5px; }
.ask-lane .av.good { color: var(--good); }
.ask-lane .av.warn { color: var(--watch); }
.ask-lane .av.crit { color: var(--act); }
.ask-lane .av.mut  { color: var(--ink-3); }
.ask-lane .ae { color: var(--ink-2); }

.ask-block { font-size: 14px; color: var(--ink-2); margin-bottom: 12px; }
.ask-block .abt {
  display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 3px;
}
.ask-refuse {
  background: var(--bg-2); border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0; padding: 14px 16px; font-size: 14.5px;
  margin-bottom: 14px; color: var(--ink);
}
.ask-generic { font-size: 14.5px; color: var(--ink-2); }
.ask-note { font-size: 13px; color: var(--ink-3); margin: 10px 0 0; line-height: 2.1; }
.ask-foot {
  font-size: 12.5px; color: var(--ink-3); margin: 14px 0 0;
  padding-top: 12px; border-top: 1px solid var(--line);
}
@media (max-width: 640px) {
  .ask-row { flex-direction: column; }
  .ask-go { width: 100%; }
  .ask-lane { grid-template-columns: 1fr; gap: 2px; padding: 11px 0; }
}

/* ---------- 4. Plain-English glosses ----------------------- */
.lyra-term {
  position: relative;
  border-bottom: 1px dashed var(--line-2);
  cursor: help; color: inherit;
}
.lyra-term:hover { border-bottom-color: var(--accent); }
.lyra-tip {
  display: none;                 /* not just hidden: see note above */
  position: absolute; bottom: calc(100% + 9px); left: 50%;
  transform: translateX(-50%) translateY(3px);
  width: max-content; max-width: min(290px, 78vw);
  padding: 10px 13px;
  background: var(--ink); color: var(--bg);
  font-family: var(--sans); font-size: 13px; font-weight: 400;
  font-style: normal; line-height: 1.45; letter-spacing: 0; text-transform: none;
  border-radius: 9px; box-shadow: 0 6px 26px rgba(11,18,32,.28);
  opacity: 0; visibility: hidden;
  transition: opacity .14s ease, transform .14s ease, visibility .14s;
  z-index: 200; pointer-events: none; white-space: normal;
}
.lyra-tip::after {
  content: ""; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--ink);
}
.lyra-term:hover .lyra-tip,
.lyra-term:focus-visible .lyra-tip,
.lyra-term.open .lyra-tip {
  display: block;
  opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}
@media (max-width: 560px) {
  .lyra-tip { left: 0; transform: translateX(0) translateY(3px); max-width: 76vw; }
  .lyra-tip::after { left: 22px; }
  .lyra-term:hover .lyra-tip,
  .lyra-term:focus-visible .lyra-tip,
  .lyra-term.open .lyra-tip { transform: translateX(0) translateY(0); }
}

/* ---------- 5. Walkthrough band ---------------------------- */
.lyra-flow {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: rgba(255,255,255,.94);
  -webkit-backdrop-filter: saturate(1.5) blur(14px);
  backdrop-filter: saturate(1.5) blur(14px);
  border-top: 1px solid var(--line);
  transform: translateY(105%);
  transition: transform .28s cubic-bezier(.22, 1, .36, 1);
}
.lyra-flow.show { transform: translateY(0); }
.lf-inner {
  max-width: var(--wrap, 1120px); margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 18px;
}
.lf-back { font-size: 13px; color: var(--ink-3); font-weight: 500; white-space: nowrap; flex: none; text-decoration: none; }
.lf-back:hover { color: var(--ink); }
.lf-empty { visibility: hidden; }
.lf-next {
  position: relative; margin-left: auto;
  display: grid; gap: 1px;
  padding: 11px 22px 13px; min-width: 268px;
  border: 1px solid var(--accent); border-radius: 12px;
  background: var(--accent); color: var(--accent-on, #fff);
  overflow: hidden; text-align: left; text-decoration: none;
  box-shadow: 0 2px 6px rgba(15,76,129,.2), 0 10px 26px rgba(15,76,129,.18);
}
.lf-step { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; opacity: .78; }
.lf-label { font-size: 15.5px; font-weight: 600; letter-spacing: -.005em; }
.lf-hint { font-size: 11.5px; opacity: .8; }
.lf-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.22); }
.lf-fill { display: block; height: 100%; width: 0; background: #fff; transition: width .12s linear; }
@media (max-width: 640px) {
  .lf-inner { padding: 10px 16px; gap: 10px; }
  .lf-back { font-size: 12px; }
  .lf-next { min-width: 0; flex: 1; padding: 10px 16px 12px; }
  .lf-label { font-size: 14.5px; }
  .lf-hint { display: none; }
}

/* ---------- 6. Safety nets --------------------------------- */
/* Deliberately no overflow rule here.
     - `overflow-x:hidden` on <html> creates a scroll container and breaks
       position:sticky.
     - `overflow-x:clip` on <html> propagates to the viewport and stops the
       page scrolling at all.
     - the same applies from <body>, because when the root is `visible` the
       body's overflow propagates to the viewport instead.
   The real overflow sources are fixed where they occur, so no net is needed. */
body { max-width: 100%; }
body:has(.lyra-flow) { padding-bottom: 84px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}


/* ---------- 7. Wide content scrolls inside its own box ----- */
/* Diagrams and tables wider than the phone used to push the whole page
   sideways. lyra.js wraps them; this styles the wrapper. */
.lyra-scroller {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.lyra-scroller > * { flex: none; }

/* ---------- 8. Keep the enhanced header on one row --------- */
@media (max-width: 900px) {
  /* Upstream hides `.nav ul` on mobile. Pages with a flat <nav> have no list to
     hide, so their links stayed visible and the added button pushed the row
     past the viewport. Hide them the same way once our menu exists. */
  .nav:has(.lyra-menu) > a:not(.brand):not(.lyra-burger),
  header nav:has(.lyra-menu) > a:not(.brand):not(.lyra-burger) { display: none; }

  /* nothing in the header row may exceed the viewport */
  header .nav, header nav { max-width: 100%; flex-wrap: nowrap; }

  /* tables in long documents */
  table { max-width: 100%; display: block; overflow-x: auto; }
}

/* ---------- 9. Walkthrough grid ---------------------------- */
/* upstream's .four expects <div> children; ours are links */
.walksteps { grid-template-columns: repeat(4, 1fr); }
.walksteps > a {
  background: var(--bg); padding: 26px 24px; display: block;
  text-decoration: none; color: inherit; transition: background .16s;
}
.walksteps > a:hover { background: var(--bg-2); }
.walksteps > a .k {
  display: block; font-family: var(--mono); font-size: 11.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 12px;
}
.walksteps > a h3 { font-size: 16.5px; font-weight: 640; margin-bottom: 8px; line-height: 1.3; }
.walksteps > a p { font-size: 14px; color: var(--ink-2); line-height: 1.5; }
@media (max-width: 900px) { .walksteps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .walksteps { grid-template-columns: 1fr; } }

/* ---------- 10. Cross-blur to the next step ---------------- */
/* No overlay card. The page you are on blurs out while the real next page
   blurs in behind it, both driven by how far you have scrolled past the end.
   --lyra-out runs 0 -> 1. */
:root { --lyra-out: 0; }

/* Everything the page itself renders, minus what we inject.
   Gated behind .lyra-turning so this only exists during a transition. Ungated,
   `body > *:not(...)` is specificity (0,2,1) and beats a plain `.scrim{opacity:0}`
   at (0,1,0), which pinned the demo's modal backdrop permanently on and greyed
   the whole page. A rule this broad must not be live at rest. */
html.lyra-turning body > *:not(.lyra-next):not(.lyra-flow) {
  filter: blur(calc(var(--lyra-out) * 16px));
  opacity: calc(1 - var(--lyra-out) * 0.6);
  transition: filter .09s linear, opacity .09s linear;
  will-change: filter, opacity;
}

/* the next step, actually rendered, resolving as the current one dissolves */
.lyra-next {
  position: fixed; inset: 0; z-index: 78;
  border: 0; width: 100%; height: 100%;
  pointer-events: none;
  visibility: hidden;
  opacity: var(--lyra-out);
  filter: blur(calc((1 - var(--lyra-out)) * 18px));
  transition: filter .09s linear, opacity .09s linear;
  will-change: filter, opacity;
}
.lyra-next.active { visibility: visible; }

/* the prompt steps out of the way as the next page comes forward */
html.lyra-turning .lyra-flow { opacity: calc(1 - var(--lyra-out) * 0.85); }

@media (prefers-reduced-motion: reduce) {
  html.lyra-turning body > *:not(.lyra-next):not(.lyra-flow) { filter: none; opacity: 1; }
  .lyra-next { display: none; }
}

/* ---------- 11. Walkthrough entry cue ---------------------- */
.walk-start { margin-top: 28px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.walk-cue { font-size: 13.5px; color: var(--ink-3); }
@media (max-width: 560px) { .walk-start { gap: 10px; } }

/* ---------- 12. Walkthrough step bar ----------------------- */
/* Carries .wrap, so the left edge sits exactly where the brand does. The step
   number is inline rather than a badge: a badge pushed the label right and
   broke the alignment with the header above it. */
.walkbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-top: 26px;
}
.wb-step {
  font-family: var(--mono); font-size: 12px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 700;
}
.walkbar a {
  font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none;
}
.walkbar a:hover { text-decoration: underline; }

/* ---------- 13. Scroll cue --------------------------------- */
.scrollcue {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 4px 0 8px;
  font-size: 14px; font-weight: 600; color: var(--accent);
  text-decoration: none;
}
.scrollcue svg { width: 17px; height: 17px; animation: lyra-nudge 1.9s ease-in-out infinite; }
@keyframes lyra-nudge {
  0%, 100% { transform: translateY(0); opacity: .75; }
  50%      { transform: translateY(4px); opacity: 1; }
}
.scrollcue:hover span { text-decoration: underline; }
@media (prefers-reduced-motion: reduce) { .scrollcue svg { animation: none; } }
