/* Shared shell for the standalone demo pages.
   The site's header, intro and footer frame a dark stage that keeps each
   demo's own amber-and-teal look. Inside the site's demo player (iframe),
   pages add .embedded to <html>: the shell hides and only the stage shows.
   Shell classes are prefixed ml- so they never collide with demo styles. */

:root {
  --ml-canvas: #F7F9FC; --ml-surface: #FFFFFF; --ml-line: #DCE3EE;
  --ml-accent: #2457E5; --ml-accent-hover: #1944BE; --ml-teal: #006E68;
  --ml-ink: #152235; --ml-muted: #536174;
  --ml-gutter: clamp(20px, 5vw, 48px);
}

body.ml-page { margin: 0; }
html:not(.embedded) body.ml-page { background: var(--ml-canvas); color: var(--ml-ink); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.ml-container { width: 100%; max-width: 1280px; margin-inline: auto; padding-inline: var(--ml-gutter); }
.ml-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Light regions: give the demo's own colour tokens light-page values, so any
   demo rule or inline style that uses them stays readable here. */
.ml-header, .ml-intro, .ml-footer, html:not(.embedded) .ml-after {
  --ink: var(--ml-ink); --text: var(--ml-ink); --muted: var(--ml-muted); --dim: var(--ml-muted);
  --faint: var(--ml-muted); --teal: var(--ml-teal); --amber: var(--ml-accent); --line: var(--ml-line);
  --border: var(--ml-line); --panel: var(--ml-surface); --void2: var(--ml-canvas);
}
.ml-header :focus-visible, .ml-intro :focus-visible, .ml-footer :focus-visible, html:not(.embedded) .ml-after :focus-visible { outline: 2px solid var(--ml-accent); outline-offset: 4px; }

.ml-skip { position: fixed; top: -100px; left: 1rem; z-index: 200; padding: .8rem 1.2rem; border-radius: 8px; background: var(--ml-accent); color: #FFF; font: 600 .875rem/1.4 Inter, system-ui, sans-serif; text-decoration: none; }
.ml-skip:focus { top: 1rem; }

/* Header: the site's logo, name and navigation. */
.ml-header { position: relative; z-index: 20; background: rgba(255, 255, 255, .97); border-bottom: 1px solid var(--ml-line); font-family: Inter, ui-sans-serif, system-ui, sans-serif; }
.ml-nav { display: flex; align-items: center; justify-content: space-between; gap: 20px; height: 80px; }
.ml-brand { display: flex; flex-shrink: 0; align-items: center; gap: 12px; color: var(--ml-ink); text-decoration: none; }
.ml-brand img { display: block; }
.ml-header a:hover { text-decoration: none; }
.ml-brand span { font: 600 1.125rem/1.2 "Space Grotesk", ui-sans-serif, sans-serif; letter-spacing: -.025em; }
.ml-links, .ml-menu-panel { margin: 0; padding: 0; list-style: none; }
.ml-links { display: flex; align-items: center; gap: 28px; }
.ml-links a { display: flex; align-items: center; min-height: 44px; font-size: .875rem; color: var(--ml-muted); text-decoration: none; transition: color .15s; }
.ml-links a:hover { color: var(--ml-ink); }
.ml-links a[aria-current] { color: var(--ml-accent); }
a.ml-cta, .ml-links a.ml-cta { justify-content: center; padding: 12px 20px; border-radius: 10px; background: var(--ml-accent); color: #FFF; font-size: .875rem; font-weight: 600; line-height: 1.45; box-shadow: 0 3px 8px #2457E518; text-decoration: none; }
a.ml-cta:hover, .ml-links a.ml-cta:hover { background: var(--ml-accent-hover); color: #FFF; }
.ml-menu { display: none; }
.ml-menu > summary { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--ml-line); border-radius: 10px; color: var(--ml-ink); cursor: pointer; list-style: none; }
.ml-menu > summary::-webkit-details-marker { display: none; }
.ml-menu .ml-icon-close, .ml-menu[open] .ml-icon-open { display: none; }
.ml-menu[open] .ml-icon-close { display: block; }
.ml-menu[open] > summary { border-color: var(--ml-accent); }
.ml-menu-panel { position: absolute; top: calc(100% + 8px); left: var(--ml-gutter); right: var(--ml-gutter); display: grid; gap: 2px; padding: 8px; background: var(--ml-surface); border: 1px solid var(--ml-line); border-radius: 16px; box-shadow: 0 18px 50px #172A4026; }
.ml-menu-panel a { display: flex; align-items: center; min-height: 48px; padding: 0 14px; border-radius: 10px; color: var(--ml-ink); font: 600 1.15rem/1.2 "Space Grotesk", ui-sans-serif, sans-serif; text-decoration: none; }
.ml-menu-panel a:hover { background: #F0F5FF; }
.ml-menu-panel a[aria-current] { color: var(--ml-accent); }
.ml-menu-panel a.ml-cta { margin-top: 6px; color: #FFF; font: 600 1rem/1.45 Inter, system-ui, sans-serif; }

/* Intro: back link, kicker, title, description and book credit. */
.ml-intro { padding-block: clamp(16px, 3vw, 32px) clamp(24px, 3.5vw, 40px); font-family: Inter, ui-sans-serif, system-ui, sans-serif; }
.ml-back { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 4px; color: var(--ml-accent); font-size: .875rem; font-weight: 500; text-decoration: none; }
.ml-back:hover { text-decoration: underline; text-underline-offset: 4px; }
.ml-intro .kicker { margin: 0; color: var(--ml-accent); font: 500 .75rem/1.8 "JetBrains Mono", ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
.ml-intro h1 { margin: .5rem 0 0; color: var(--ml-ink); font: 600 clamp(2rem, 4vw, 3rem)/1.12 "Space Grotesk", ui-sans-serif, sans-serif; letter-spacing: -.035em; text-wrap: balance; }
.ml-intro .lede, .ml-intro .desc { max-width: 46rem; margin: 1rem 0 0; color: var(--ml-muted); font-size: 1.0625rem; line-height: 1.7; }
.ml-credit { display: inline-flex; align-items: center; gap: 10px; margin-top: 18px; padding: 6px 14px 6px 6px; border: 1px solid var(--ml-line); border-radius: 999px; background: var(--ml-surface); color: var(--ml-muted); font-size: .875rem; line-height: 1.4; text-decoration: none; transition: border-color .15s; }
.ml-credit img { display: block; width: 22px; height: auto; border-radius: 2px; box-shadow: 0 1px 3px #172A4033; }
.ml-credit strong { color: var(--ml-accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.ml-credit:hover { border-color: var(--ml-accent); }

/* Stage: the play area keeps the demo's own dark palette. */
.ml-stage { background: var(--void, var(--bg)); color: var(--ink, var(--text)); }

/* After: notes and explanations below the play area, on the light page. */
html:not(.embedded) .ml-after { padding-block: 8px clamp(32px, 5vw, 56px); }
html:not(.embedded) .ml-after a { color: var(--ml-accent); text-decoration: underline; text-underline-offset: 3px; }
html:not(.embedded) .ml-after .footnote, html:not(.embedded) .ml-after .note { max-width: 72ch; margin: 1.1rem 0 0; padding: 0; border: 0; color: var(--ml-muted); font-size: .875rem; line-height: 1.65; }
html:not(.embedded) .ml-after .explain .body > * { max-width: 78ch; }

/* Footer: a light version of the site footer. */
.ml-footer { padding-block: 32px; background: var(--ml-surface); border-top: 1px solid var(--ml-line); color: var(--ml-muted); font: .875rem/1.5 Inter, ui-sans-serif, system-ui, sans-serif; }
.ml-footer-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 20px 40px; }
.ml-footer-brand { color: var(--ml-ink); font: 600 1.125rem/1.3 "Space Grotesk", ui-sans-serif, sans-serif; text-decoration: none; }
.ml-footer p { margin: 6px 0 0; }
.ml-footer nav { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.ml-footer nav a { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; color: var(--ml-ink); text-decoration: none; }
.ml-footer a:hover { text-decoration: underline; text-underline-offset: 4px; }
.ml-footer-mail { display: inline-flex; align-items: center; min-height: 32px; color: var(--ml-teal); overflow-wrap: anywhere; text-decoration: none; }

@media (max-width: 639px) {
  .ml-nav { height: 68px; }
  .ml-intro .lede, .ml-intro .desc { margin-top: .75rem; font-size: 1rem; line-height: 1.65; }
  .ml-back { min-height: 40px; }
  .ml-links { display: none; }
  .ml-menu { display: block; }
  .ml-footer-row { flex-direction: column; }
}

/* Embedded in the site's demo player: show only the stage. */
.embedded .ml-skip, .embedded .ml-header, .embedded .ml-intro, .embedded .ml-footer { display: none; }

@media (prefers-reduced-motion: reduce) {
  .ml-links a, .ml-credit { transition: none; }
}
