/* Layout, header, nav, footer and slide deck: owned by UI/UX. Mobile first.
   Colours come from the designer's tokens; fallbacks keep it readable until they land. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
img, svg { max-width: 100%; height: auto; }
main { flex: 1 0 auto; width: 100%; max-width: var(--content-width, 64rem); margin: 0 auto; padding: var(--space-5, 1.5rem) var(--space, 1rem) var(--space-6, 3rem); }
main p, main li { max-width: var(--measure, 65ch); }
main h1 { font-family: var(--font-display); font-size: var(--text-2xl, 2.2rem); line-height: 1.1; margin: 1rem 0 .75rem; }
main h1::after { content: ""; display: block; width: 5rem; height: 4px; margin-top: .75rem; background: var(--gradient-spark, var(--color-accent)); border-radius: 2px; }
main a:focus-visible, main button:focus-visible { outline: 3px solid var(--color-focus, var(--color-accent)); outline-offset: 3px; border-radius: 2px; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 10; background: var(--gradient-deep, #070a12); color: var(--color-on-deep, var(--color-text)); border-bottom: 2px solid var(--color-accent); box-shadow: var(--glow-green, 0 0 14px rgba(57,255,156,.45)); }
.brand { display: inline-flex; align-items: center; gap: .75rem; min-height: 44px; padding: .5rem var(--space, 1rem); font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace); font-size: 1.1rem; font-weight: 700; letter-spacing: .02em; color: var(--color-accent); text-decoration: none; }
.brand img { display: block; flex: none; }
.site-header a:focus-visible, .nav-toggle:focus-visible { outline: 3px solid var(--color-focus, var(--color-accent)); outline-offset: 2px; }
.site-header nav { border-top: 1px solid var(--color-line, rgba(255,255,255,.2)); }
.site-header nav ul { list-style: none; margin: 0; padding: 0; }
.site-header nav a { display: flex; align-items: center; min-height: 48px; padding: .5rem var(--space, 1rem); color: var(--color-text); text-decoration: none; font-weight: 600; border-left: 4px solid transparent; }
.site-header nav a:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.site-header nav a[aria-current="page"] { color: var(--color-accent); border-left-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); }

.nav-toggle { display: none; align-items: center; gap: .5rem; min-height: 44px; padding: .5rem 1rem; font: inherit; font-weight: 600; color: var(--color-accent); background: transparent; border: 2px solid var(--color-accent); border-radius: 6px; cursor: pointer; }
.nav-toggle .bars { width: 18px; height: 12px; background: linear-gradient(currentColor 0 0) 0 0/100% 2px no-repeat, linear-gradient(currentColor 0 0) 0 50%/100% 2px no-repeat, linear-gradient(currentColor 0 0) 0 100%/100% 2px no-repeat; }
.js .nav-toggle { display: inline-flex; }
.js .site-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding-right: var(--space, 1rem); }
.js .site-header nav { flex-basis: 100%; margin-right: calc(-1 * var(--space, 1rem)); }
.js .site-header nav[data-collapsed="true"] { display: none; }

/* ---------- Footer ---------- */
.site-footer { background: var(--color-deep, #070a12); color: var(--color-text); border-top: 1px solid var(--color-line, rgba(255,255,255,.2)); font-size: .925rem; }
.site-footer a { color: var(--color-primary-light, var(--color-accent)); }
.site-footer p { max-width: var(--content-width, 64rem); margin: 0 auto; padding: 1.5rem var(--space, 1rem); }

/* ---------- Slide deck ----------
   Markup: <div class="deck" aria-label="..."><section class="slide">...</section> ...</div>
   Without JavaScript every slide shows, stacked. nav.js shows one at a time. */
.deck { margin: 1.5rem 0; }
.slide { padding: 1.5rem; border: 1px solid var(--color-line, rgba(255,255,255,.25)); border-radius: var(--radius-md, 12px); background: var(--color-mist, #131a2b); margin-bottom: 1rem; }
.slide h2 { margin-top: 0; font-family: var(--font-display); color: var(--color-gold, inherit); font-size: var(--text-xl, 1.6rem); line-height: 1.15; }
.slide p, .slide li { max-width: none; font-size: var(--text-lg, 1.2rem); }
.deck.is-live .slide { min-height: 55vh; margin: 0; display: flex; flex-direction: column; justify-content: center; box-shadow: var(--shadow-card), var(--glow-cyan, none); touch-action: pan-y; }
.deck.is-live .slide[hidden] { display: none; }
.deck-controls { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: 1rem; }
.deck-controls button { min-width: 48px; min-height: 48px; padding: .5rem 1.1rem; font: inherit; font-weight: 700; color: var(--color-accent); background: transparent; border: 2px solid var(--color-accent); border-radius: 8px; cursor: pointer; }
.deck-controls button:hover:not([aria-disabled="true"]) { background: var(--color-accent); color: var(--color-on-primary, #05070d); box-shadow: var(--glow-green, none); }
.deck-controls button[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.deck-controls button:focus-visible { outline: 3px solid var(--color-focus, var(--color-accent)); outline-offset: 3px; }
.deck-count { font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace); font-size: 1rem; }
.deck-bar { height: 6px; margin-top: .75rem; background: var(--color-line, rgba(255,255,255,.2)); border-radius: 3px; overflow: hidden; }
.deck-bar span { display: block; height: 100%; width: 0; background: var(--color-accent); transition: width var(--motion-fast, .25s) ease; }
.deck-hint { margin: .75rem 0 0; font-size: .9rem; color: var(--color-ink-soft, inherit); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) { .deck-bar span { transition: none; } }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ---------- Wide screens: seven links fit in one row from 64rem ---------- */
@media (min-width: 64rem) {
  .site-header, .js .site-header { display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; padding: 0 max(1.5rem, calc((100vw - var(--content-width, 64rem)) / 2 + 1.5rem)); }
  .brand { padding-left: 0; }
  .site-header nav, .js .site-header nav { border-top: 0; flex-basis: auto; margin: 0; }
  .site-header nav ul { display: flex; gap: .15rem; }
  .site-header nav a { min-height: 44px; padding: .5rem .6rem; font-size: .9rem; border-left: 0; border-bottom: 3px solid transparent; border-radius: 6px 6px 0 0; }
  .site-header nav a[aria-current="page"] { border-bottom-color: var(--color-accent); }
  .js .nav-toggle { display: none; }
  .js .site-header nav[data-collapsed="true"] { display: block; }
}
@media (min-width: 48rem) {
  main { padding-left: 1.5rem; padding-right: 1.5rem; }
  .slide { padding: 2.5rem; }
  .deck.is-live .slide { min-height: 60vh; }
}

/* ---------- Code and tables: scroll inside the block, never the page ---------- */
main pre, main code, main kbd, main samp { font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace); font-size: .92em; }
main pre { max-width: 100%; margin: 1.25rem 0; padding: 1rem; overflow-x: auto; background: var(--color-mist, #131a2b); color: var(--color-ink, inherit); border: 1px solid var(--color-line, #3a4a6b); border-left: 4px solid var(--color-accent); border-radius: var(--radius-sm, 6px); line-height: 1.5; tab-size: 2; }
main pre code { font-size: 1em; background: none; padding: 0; }
main :not(pre) > code { padding: .1em .35em; background: var(--color-mist, #131a2b); border-radius: 4px; overflow-wrap: anywhere; }
main pre:focus-visible, .table-scroll:focus-visible { outline: 3px solid var(--color-focus, var(--color-accent)); outline-offset: 2px; }
.table-scroll { max-width: 100%; margin: 1.25rem 0; overflow-x: auto; }
main table { width: 100%; max-width: 100%; border-collapse: collapse; font-size: .95rem; }
main th, main td { padding: .6rem .75rem; text-align: left; vertical-align: top; border: 1px solid var(--color-line, #3a4a6b); }
main thead th, main tr:first-child th { background: var(--color-mist, #131a2b); color: var(--color-gold, inherit); font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace); white-space: nowrap; }
main tbody th { white-space: nowrap; }

/* ---------- Cards (home page) ---------- */
main .card-list { list-style: none; margin: 1.5rem 0; padding: 0; display: grid; gap: 1rem; }
main .card-list li { max-width: none; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: 1.25rem; background: var(--color-mist, #131a2b); border: 1px solid var(--color-line, #3a4a6b); border-radius: var(--radius-md, 12px); }
main .card-list img { width: 48px; height: 48px; flex: none; }
@media (min-width: 48rem) { main .card-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 64rem) { main .card-list { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Motion ----------
   Everything below only exists when the reader has not asked for reduced motion.
   Loops are slow and quiet; nothing flashes; only transform and opacity animate.
   Content never depends on motion: with it off, the page is simply still. */
@media (prefers-reduced-motion: no-preference) {
  /* Page arrives: header, then content rises in */
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
  @keyframes drop { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
  main > * { animation: rise var(--motion-slow, 600ms) var(--ease-out, ease-out) both; }
  main > :nth-child(2) { animation-delay: 80ms; }
  main > :nth-child(3) { animation-delay: 160ms; }
  main > :nth-child(4) { animation-delay: 240ms; }
  main > :nth-child(n+5) { animation-delay: 320ms; }
  .brand { animation: drop var(--motion-slow, 600ms) ease-out both; }

  /* Header: a soft light slowly travels along the neon edge (about 10s per pass) */
  .site-header { overflow-x: clip; }
  .site-header::after { content: ""; position: absolute; left: 0; bottom: -2px; width: 25%; height: 2px; pointer-events: none; background: linear-gradient(90deg, transparent, var(--color-gold, #ffe14d), transparent); opacity: .8; transform: translateX(-100%); animation: scan calc(var(--motion-ambient, 8s) + 2s) linear infinite; }
  @keyframes scan { to { transform: translateX(400%); } }

  /* Logo breathes very slightly */
  .brand img { animation: breathe 6s ease-in-out infinite; }
  @keyframes breathe { 50% { transform: scale(1.06); } }

  /* The hero art animates itself inside the image; the image only fades in with the page */

  /* Nav: underline grows in on hover and focus */
  .site-header nav a { position: relative; }
  @media (min-width: 64rem) {
    .site-header nav a::after { content: ""; position: absolute; left: .6rem; right: .6rem; bottom: 2px; height: 2px; background: var(--color-accent); transform: scaleX(0); transform-origin: left; transition: transform var(--motion-fast, 150ms) ease-out; }
    .site-header nav a:hover::after, .site-header nav a:focus-visible::after { transform: scaleX(1); }
  }
  /* Mobile menu opens with a short drop */
  .js .site-header nav[data-collapsed="false"] { animation: drop var(--motion-fast, 150ms) ease-out both; }

  /* Cards and buttons respond to the pointer */
  main .card-list li, .deck-controls button, .nav-toggle { transition: transform var(--motion-fast, 150ms) ease-out, background-color var(--motion-fast, 150ms) ease-out, color var(--motion-fast, 150ms) ease-out; }
  @media (hover: hover) { main .card-list li:hover { transform: translateY(-4px); } }
  .deck-controls button:active:not([aria-disabled="true"]), .nav-toggle:active { transform: scale(.95); }

  /* Scroll reveal: nav.js adds .reveal-ready, then .is-in as items scroll into view */
  .reveal-ready .reveal { opacity: 0; transform: translateY(18px); transition: opacity var(--motion-slow, 600ms) ease-out, transform var(--motion-slow, 600ms) ease-out; }
  .reveal-ready .reveal.is-in { opacity: 1; transform: none; }

  /* Slides glide in from the direction of travel */
  .deck.is-live .slide.enter-next { animation: slide-next var(--motion-base, 350ms) var(--ease-out, ease-out) both; }
  .deck.is-live .slide.enter-prev { animation: slide-prev var(--motion-base, 350ms) var(--ease-out, ease-out) both; }
  @keyframes slide-next { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
  @keyframes slide-prev { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal-ready .reveal { opacity: 1; transform: none; }
}
