/* ============================================================================
   Academic Gates — "The Gate" design system
   Pure-black cosmic canvas · spectrum particle glow · light geometric type.
   Token definitions live at the top; everything else is grouped under
   clearly-labelled section comments.
   ============================================================================ */

/* ---------------------------------------------------------------------------
   1. TOKENS
   --------------------------------------------------------------------------- */
:root {
    /* Base & surfaces */
    --bg: #000000;
    --surface: rgba(255, 255, 255, 0.02);
    --surface-hover: rgba(255, 255, 255, 0.04);
    /* 押せる面にカーソルを当てたときだけの面（§71）。.02 → .045 では
       地が黒すぎて差が読み取れなかったので、もう一段上を作ってある。 */
    --surface-hot: rgba(255, 255, 255, 0.07);
    --nav-bg: rgba(10, 10, 14, 0.60);
    --hairline: rgba(255, 255, 255, 0.14);
    --hairline-strong: rgba(255, 255, 255, 0.24);

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.62);
    --text-tertiary: rgba(255, 255, 255, 0.40);

    /* The spectrum (particles + accents) — teal-dominant, warm at cores only */
    --spec-blue-deep: #0b3be0;
    --spec-teal: #2bd9c4;
    /* ★ 今回足した唯一の色（§73）。ホバーの光専用の蛍光の青。
       色相 198°—— --spec-blue（#3d8bff、217°）よりシアン寄りで明るく、
       --spec-teal（170°）よりはっきり青側。170°は画面で緑に見えた。 */
    --spec-glow: #5fd0ff;
    --spec-cyan: #00c2cb;
    --spec-blue: #3d8bff;
    --spec-violet: #7b4dff;
    --spec-magenta: #ff3d8b;
    --spec-ember: #ff5a3c;

    /* Derived UI accents */
    --accent: #3d8bff;
    --accent-warm: #ff3d8b;
    --glow-cool: rgba(61, 139, 255, .26);
    --glow-warm: rgba(255, 61, 139, 0.20);
    /* Ambient background pools (body::before) — matched to the lesson pages
       ("1-1 微分の基礎") so the site and the教材 read as one surface. Every page loads
       this file, so these three tokens are the single place the background is tinted. */
    --spill-blue: rgba(61, 139, 255, .13);
    /* 216° — upper right */
    --spill-blue-deep: rgba(34, 78, 190, .13);
    /* 223° — lower left */
    --spill-violet: rgba(120, 90, 255, .07);
    /* 251° — top centre */

    /* Stars — white only, static (see starfield.js). The blue/red tints the field
       used to mix in are gone; the lesson pages paint a plain white sky. */
    --star-white: rgba(255, 255, 255, 0.55);

    /* Typography */
    --font-display: 'Inter Tight', 'Noto Sans JP', system-ui, sans-serif;
    --font-body: 'Inter Tight', 'Noto Sans JP', system-ui, sans-serif;
    /* Page-title tier: interior page + section titles. > stage heading (3rem), on-scale. */
    --fs-page-title: clamp(2rem, 4vw, 3.25rem);

    /* Spacing scale (8px base) */
    --space-1: 0.5rem;
    --space-2: 1rem;
    --space-3: 1.5rem;
    --space-4: 2rem;
    --space-6: 3rem;
    --space-8: 4rem;
    --space-12: 6rem;
    --space-16: 8rem;
    --gutter: clamp(1.25rem, 5vw, 6rem);

    /* Floating-nav clearance: pill offset (20px) + pill height (~52px) + margin (20px).
       Any content that can land at the top of the viewport reserves this much. */
    --nav-clearance: 92px;

    /* Radii */
    --radius-pill: 999px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;

    /* Motion */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --dur: 0.32s;
}

/* ---------------------------------------------------------------------------
   2. RESET & BASE
   --------------------------------------------------------------------------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--nav-clearance);
    -webkit-text-size-adjust: 100%;
}

/* Shared floating-nav clearance. Applied to the scroll-target elements THEMSELVES
   (every heading, eyebrow, and section) regardless of nesting depth — not via a
   `main > section` child combinator, which silently misses nested sections (that was
   the .final-message bug). Any element that can rest at the top of the viewport keeps
   clearance below the pill so its first line never hides under the nav. */
section,
.page-header,
h1, h2, h3, h4,
.eyebrow {
    scroll-margin-top: var(--nav-clearance);
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* Round 14 — proximity scroll-snap on the hero (stages 01–04) only.
   Native CSS snap (NOT a JS scroll hijack): the browser keeps ownership of
   inertia, momentum, and mid-transition stops. `proximity` (never `mandatory`)
   settles a deliberate scroll onto a motif but always leaves an escape, so
   find-in-page, anchor jumps, keyboard scrolling, and resting between stages
   all still work. Only elements with scroll-snap-align become snap points, so
   the index blocks 05–10 (card grids + body copy people are reading) are left
   as free scroll by simply never opting in.
   Gated to (no-preference) so reduced-motion gets plain scrolling — snapping is
   motion — and to (min-width:601px) so mobile gets the free-scroll version
   (iOS momentum + snap is historically janky; pending the device pass this is
   the safe default). Each .scene is 120vh, so its centre is exactly the peak-w
   position; snap-align:center lands the form fully resolved. */
@media (prefers-reduced-motion: no-preference) and (min-width: 601px) {
    html {
        scroll-snap-type: y proximity;
    }

    .hero .scene {
        scroll-snap-align: center;
    }
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text-primary);
    background: var(--bg);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Ambient light spill — matched value-for-value to the lesson pages so the two
   surfaces line up: three large, very-low-opacity radials over the black canvas
   (blue upper-right, deeper blue lower-left, a violet breath up top). Also the
   JS-disabled / no-WebGL fallback. Sits BELOW the star canvas (z-index -3 vs
   #starfield's -2), so it can never cover the stars. Nothing repaints. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -3;
    pointer-events: none;
    background:
        radial-gradient(70% 70% at 80% 22%, var(--spill-blue), transparent 66%),
        radial-gradient(85% 75% at 10% 86%, var(--spill-blue-deep), transparent 70%),
        radial-gradient(55% 50% at 55% 6%, var(--spill-violet), transparent 74%);
}

/* Bracketed micro-labels along the bottom edge (reference detail) */
.stage-labels {
    position: fixed;
    left: var(--gutter);
    bottom: 16px;
    z-index: 900;
    display: flex;
    gap: 1.1rem;
    flex-wrap: wrap;
    font-size: 0.6rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    pointer-events: none;
}

/* Live telemetry (particles · frame budget · fps) — reference detail */
#telemetry {
    position: fixed;
    right: var(--gutter);
    bottom: 16px;
    z-index: 900;
    display: flex;
    gap: 1rem;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    text-transform: uppercase;
}

#telemetry b {
    color: var(--spec-teal);
    font-weight: 500;
    margin-right: 0.25em;
}

@media (max-width: 600px) {

    .stage-labels,
    #telemetry {
        display: none;
    }
}

/* Hero-only readouts: fade out once the hero has scrolled past, so they never sit
   over the footer (Round-12 bug 3). position:fixed → no layout shift either way.
   JS toggles body.hero-passed (scroll-scenes.js). */
body.hero-passed .stage-labels,
body.hero-passed #telemetry {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s var(--ease);
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Universal visible focus ring */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ---------------------------------------------------------------------------
   3. COSMIC LAYERS (star field + WebGL scene canvas)
   --------------------------------------------------------------------------- */
#starfield {
    position: fixed;
    inset: 0;
    z-index: -2;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Reading pages (教材 / 記事, body.is-article) — the sky steps back so it never
   competes with body copy or MathJax. Two halves that have to stay in sync:
   this rule softens and dims the whole canvas, and starfield.js separately thins
   the stars that would land behind the text column (COLUMN_* there). Everything
   outside the column keeps a faint sky, so the page still reads as the same site. */
body.is-article #starfield {
    filter: blur(1.2px);
    opacity: .6;
}

#scene-canvas {
    position: fixed;
    inset: 0;
    z-index: -1;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Fades in only once the first frame has rendered (§G: no blank-then-pop) */
    opacity: 0;
    transition: opacity 1.2s ease;
}

#scene-canvas.is-ready {
    opacity: 1;
}

/* Fades out once the hero leaves the viewport so the calm card/footer region
   settles onto pure black + the star field (motion stops, fully readable). */
#scene-canvas.is-dormant {
    opacity: 0;
}

/* ---------------------------------------------------------------------------
   4. TYPOGRAPHY
   --------------------------------------------------------------------------- */
h1,
h2,
h3,
h4 {
    font-family: var(--font-display);
    font-weight: 300;
    color: var(--text-primary);
}

/* Page-title tier (interior page + section-title headings). One value, one token —
   larger than a stage heading (3rem) but on the system, not a one-off page rule. */
h1 {
    font-size: var(--fs-page-title);
    line-height: 1.05;
    letter-spacing: -0.02em;
}

/* Sub-heading tier. Index stage headings override to 3rem via .scene h2; interior
   section titles that are h2 opt into the page-title tier explicitly (below). */
h2 {
    font-size: clamp(1.4rem, 2.4vw, 1.9rem);
    line-height: 1.1;
    letter-spacing: -0.01em;
}

h3 {
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

h4 {
    font-size: 1.1rem;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

p {
    max-width: 62ch;
    color: var(--text-secondary);
    line-height: 1.75;
}

/* Japanese needs more weight and air on pure black. Latin headings stay 300;
   .jp (or :lang(ja)) headings go 400. Both faces coexist in one heading. */
.jp,
:lang(ja) {
    line-break: strict;
    word-break: normal;
}

h1 .jp,
h2 .jp,
h3 .jp,
h1:lang(ja),
h2:lang(ja),
h3:lang(ja),
.heading-jp {
    font-weight: 400;
}

p:lang(ja),
.jp-body {
    line-height: 1.9;
    word-break: normal;
    line-break: strict;
}

/* Eyebrow labels — signature detail: "01 — LABEL" */
.eyebrow {
    display: block;
    max-width: none;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: var(--space-3);
}

.eyebrow__num {
    color: var(--text-secondary);
}

/* パンくず（`<nav class="eyebrow" aria-label="パンくず">`）。グローバルの
   `a{color:inherit}` のままだと、リンクの区間と現在地の区間が同じ色になって
   区別できない。サイト共通のリンク扱い（アクセント色）を当てるだけで、
   新しい見た目は足していない（§37）。 */
.eyebrow a {
    color: var(--accent);
}

.eyebrow a:hover {
    color: var(--text-primary);
}

/* ---------------------------------------------------------------------------
   5. FLOATING NAV (pill) — reuses <header>/.menu-toggle/.nav-menu for main.js
   --------------------------------------------------------------------------- */
/* JS-disabled fallback nav (rendered from <noscript> inside #site-nav / #site-footer
   when layout.js can't inject the real header). Plain, always-visible, navigable. */
.noscript-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    padding: 1rem var(--gutter);
    border-bottom: 1px solid var(--hairline);
}
.noscript-nav a {
    color: var(--text-secondary);
}
.noscript-nav a:hover {
    color: var(--text-primary);
}

header {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: min(1080px, calc(100% - 32px));
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0.55rem 0.7rem 0.55rem 1.25rem;
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-pill);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Small ring glyph echoing THE GATE */
.logo::before {
    content: '';
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    box-shadow: 0 0 8px var(--glow-cool);
    flex: none;
}

header nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.nav-menu {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.nav-menu a {
    position: relative;
    display: inline-block;
    font-size: 0.8rem;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-pill);
    transition: color var(--dur) var(--ease);
    white-space: nowrap;
}

.nav-menu a:hover {
    color: var(--text-primary);
}

.nav-menu a.active {
    color: var(--text-primary);
}

.nav-menu a.active::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -2px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--accent);
    transform: translateX(-50%);
}

.btn-nav-cta {
    flex: none;
}

/* Hamburger */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.menu-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.menu-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ---------------------------------------------------------------------------
   6. BUTTONS
   --------------------------------------------------------------------------- */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    padding: 0.6rem 0.7rem 0.6rem 1.15rem;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-pill);
    background: transparent;
    cursor: pointer;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
    white-space: nowrap;
}

/* Soft colored glow behind, revealed on hover */
.btn::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: radial-gradient(120% 120% at 80% 50%, var(--glow-cool), transparent 70%);
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
    pointer-events: none;
    z-index: -1;
}

.btn:hover {
    color: var(--text-primary);
    border-color: var(--hairline-strong);
}

.btn:hover::before {
    opacity: 1;
}

/* Small circular icon disc on the right */
.btn-disc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--hairline);
    font-size: 0.85rem;
    line-height: 1;
    flex: none;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

/* Primary — filled disc, warm glow */
.btn-primary .btn-disc {
    background: var(--accent);
    border-color: transparent;
    color: #fff;
}

.btn-primary::before {
    background: radial-gradient(120% 120% at 80% 50%, var(--glow-warm), transparent 70%);
}

/* Secondary — no border, label + disc only */
.btn-secondary {
    border-color: transparent;
    padding-left: 0.4rem;
}

.btn-secondary:hover {
    border-color: transparent;
}

/* ---------------------------------------------------------------------------
   7. CARDS
   --------------------------------------------------------------------------- */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4);
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
        transform var(--dur) var(--ease);
    color: inherit;
}

/* Faint blue→violet gradient bleeding in from one edge on hover */
.card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--glow-cool), transparent 55%);
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
    pointer-events: none;
}

a.card:hover,
.card:hover {
    background: var(--surface-hover);
    border-color: var(--hairline-strong);
}

a.card:hover::before,
.card:hover::before {
    opacity: 1;
}

.card>* {
    position: relative;
    z-index: 1;
}

.card h4 {
    color: var(--text-primary);
}

.card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.card .meta,
.card .card-date {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

/* Spectrum media placeholder (thumbnails etc.) — teal/cyan register with a faint warm
   accent only (§2.3: warm confined to hot cores; was a saturated blue+magenta block). */
.media-placeholder {
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-md);
    background:
        linear-gradient(135deg, rgba(43, 217, 196, 0.34), rgba(0, 194, 203, 0.12) 55%, transparent 82%),
        radial-gradient(120% 130% at 22% 18%, rgba(43, 217, 196, 0.62), transparent 60%),
        radial-gradient(110% 120% at 82% 84%, rgba(0, 194, 203, 0.5), transparent 64%),
        radial-gradient(50% 50% at 60% 45%, rgba(255, 90, 60, 0.1), transparent 72%),
        #0a161a;
    opacity: 0.9;
}

/* ---------------------------------------------------------------------------
   8. LAYOUT HELPERS
   --------------------------------------------------------------------------- */
main {
    position: relative;
    z-index: 1;
}

.section {
    padding: var(--space-16) var(--gutter);
    max-width: 1200px;
    margin: 0 auto;
}

.grid {
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

/* ---------------------------------------------------------------------------
   9. REVEAL UTILITIES
   Content is visible by default. JS opts-in (html.js) to animate; reduced-motion
   forces it visible with no motion. So the page is fully readable with JS off.
   --------------------------------------------------------------------------- */
.reveal {
    opacity: 1;
    transform: none;
}

html.js .reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
    will-change: opacity, transform;
}

html.js .reveal.is-visible {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {

    html.js .reveal,
    html.js .reveal.is-visible {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* Progressive enhancement: native scroll-driven fade where supported */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        html.js .reveal-scroll {
            opacity: 1;
            transform: none;
            transition: none;
            animation: reveal-fade linear both;
            animation-timeline: view();
            animation-range: entry 5% cover 25%;
        }
    }
}

@keyframes reveal-fade {
    from {
        opacity: 0;
        transform: translateY(22px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ---------------------------------------------------------------------------
   10. INDEX — HERO SCENES (cosmic-origin → society, six-stage choreography)
   A fixed WebGL canvas morphs behind. Each stage's text is faded in by JS only
   while its scene is centered (one stage on screen at a time); it is fully
   visible by default (CSS) so the page reads with JS off. Text-block-local
   scrims hold ≥4.5:1 as the particles sweep past.
   Heights: BEGINNING 100vh + five stages × 44vh = 320vh (DESIGN.md §6).
   --------------------------------------------------------------------------- */
.hero {
    position: relative;
    z-index: 1;
}

/* Hero copy sits over the particle field, so it uses full white (not the
   secondary body tint) to hold 4.5:1 against the brightest frame. */
.hero p {
    color: var(--text-primary);
}

/* Four text stages × 120vh = 480vh (Round-12 Part 6 — longer scenes, slower reveal).
   Each text block is position:sticky so it holds pinned near centre for the whole
   stage while the flow field forms and releases under it — a long, steady read. */
.scene {
    position: relative;
    height: 120vh;
    padding: 0 var(--gutter);
}

/* Left-aligned column on the dark left; the formation sits on the right (§comp).
   .scene prefix raises specificity above .hero-scrim (which also sets position). */
.scene .scene__content {
    position: sticky;
    top: 22vh;
    z-index: 1;
    width: 100%;
    max-width: 30rem;
    margin: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: var(--space-3);
    /* Visible by default (JS off); JS drives opacity so one block reads at a time. */
    transition: opacity 0.3s linear;
}

.scene-list {
    list-style: none;
    margin-top: var(--space-3);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
}

.scene-list li {
    position: relative;
    padding-left: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.scene-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.6em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
}

.cta-row {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    justify-content: flex-start;
    margin-top: var(--space-2);
}

/* Per-glyph contrast comes from a DARK text-shadow (legibility, not glow) so
   there is no panel behind the text. The local scrim below is only soft ambient
   support — it feathers smoothly to transparent with no detectable edge. */
.hero h1,
.hero h2,
.hero .gate-subtitle,
.hero p,
.hero .eyebrow,
.hero .scene-list li {
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 0 18px rgba(0, 0, 0, 0.6);
}

/* The BEGINNING subtitle sits over the bright ring's inner bloom — a tighter
   stacked shadow fills the gaps between its small glyphs, and a tighter
   line-height removes the inter-line band a bright particle could show through. */
.hero .gate-subtitle {
    text-shadow: 0 0 6px #000, 0 0 14px rgba(0, 0, 0, 0.85), 0 0 24px rgba(0, 0, 0, 0.6);
    line-height: 1.5;
}

.hero-scrim {
    position: relative;
}

/* Dark enough over the text for ≥4.5:1, but a CONTINUOUS falloff (no shoulder/
   plateau) plus a large blur means there is no detectable edge — it reads as a
   soft vignette, not a panel. */
.hero-scrim::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: -1.2rem -2rem;
    /* Lighter now — left-aligned text sits on the dark left, so this is just a
       gentle safety pool biased to the text (left), fully feathered, no edge. */
    background: radial-gradient(ellipse 120% 130% at 35% 50%,
            rgba(0, 0, 0, 0.70) 0%,
            rgba(0, 0, 0, 0.42) 52%,
            rgba(0, 0, 0, 0.14) 78%,
            transparent 100%);
    filter: blur(20px);
    pointer-events: none;
}

/* Reference-aligned: moderate size, more weight (was oversized + thin at 300). */
.gate-title {
    font-size: clamp(2rem, 4.5vw, 3.4rem);
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.02;
}

/* Stage headings: moderate + weight 500 (Latin and JP). */
.scene h2 {
    font-size: clamp(1.9rem, 3.4vw, 3rem);
    font-weight: 500;
    line-height: 1.08;
    letter-spacing: -0.01em;
}

.scene h2:lang(ja) {
    font-weight: 500;
}

.gate-subtitle {
    margin: 0;
    color: var(--text-primary);
    max-width: 42ch;
    text-align: left;
}

/* Persistent scroll affordance — fades out by progress ~0.12 (JS sets --scroll-hint) */
.scroll-hint {
    position: absolute;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.65rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    opacity: var(--scroll-hint, 1);
    transition: opacity 0.4s var(--ease);
    z-index: 2;
}

.scroll-hint__arrow {
    animation: hint-bob 1.8s var(--ease) infinite;
}

@keyframes hint-bob {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(6px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .scroll-hint__arrow {
        animation: none;
    }
}

/* ---------------------------------------------------------------------------
   11. INDEX — THE INDEX region (calm card grids, motion at rest)
   --------------------------------------------------------------------------- */
.index-region {
    position: relative;
    z-index: 1;
    /* Semi-transparent veil (not solid #000) so the calm below-hero flow field shows
       through behind the cards while card text keeps its contrast (Round-12 Part 2). */
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.42) 16%);
}

.index-block {
    padding: var(--space-8) var(--gutter);
    max-width: 1200px;
    margin: 0 auto;
    /* Even out the per-stage scroll dwell (Round-13 item 3): card heights are
       content-dependent (blog/videos grids are taller), which made stages 05–10 morph
       at uneven speeds. A min-height evens the block spans so each stage gets a
       comparable scroll window; the flow field fills the added space (never empty). */
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.index-block__head {
    margin-bottom: var(--space-6);
    max-width: 62ch;
    position: relative;
}

/* §20.2 (Round-31): a soft scrim behind the index-block heading column — a feathered
   radial like .hero-scrim::before, lighter. Index-block headings had no scrim, so a
   full-bleed bright motif (waveforms under 最新動画) dropped to 3.71:1 / 19-of-24 frames
   below AA at 1440×900. This lifts it to 6.2:1 (0 below, all viewports) with no motif
   change (an overlay, not a field edit). z-index -1 sits above the fixed canvas, below
   the text. The gradient fades fully to transparent at 88% (INSIDE the -1.6rem/-2.6rem
   inset box), so the box edge is transparent and it reads as a vignette, not a panel —
   the earlier 0.52/transparent-at-100% version clipped a still-visible gradient at the
   small box edge and read as a box (§31.2a). Scoped to .index-block__head — which exists
   ONLY on index.html (0 matches on the other 10 pages). Reversible: delete this rule. */
.index-block__head::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: -1.6rem -2.6rem;
    pointer-events: none;
    background: radial-gradient(ellipse 80% 95% at 26% 40%,
            rgba(0, 0, 0, 0.40) 0%,
            rgba(0, 0, 0, 0.22) 42%,
            rgba(0, 0, 0, 0.06) 70%,
            transparent 88%);
}

.index-block__head h2 {
    margin-bottom: var(--space-2);
}

.note-grid {
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.final-message {
    text-align: center;
    /* Normal section rhythm — the old var(--space-16) (128px each side) isolated the
       one line in a large black void (Round-12 bug 2). */
    padding: var(--space-8) var(--gutter);
}

/* Round-23: give stage 7 a viewport-tall section so sceneF can REACH 7.0 at a true rest
   on tall viewports. Reachability needs  FM_height + 2·footer + 92 ≥ viewport_height
   (see DESIGN.md §26); at the old ~204px height that failed above 1188px tall, leaving the
   closing region resting at a dissolved videos↔orbits blend (fc 0.477, w≈0.02). 100vh makes
   the condition hold at every height. The text is BOTTOM-anchored (flex column, justify-end)
   so the closing line stays exactly where it was on short viewports — the particle field fills
   the space above it, so this is NOT the Round-12 bug-2 void (a lone line centred in black).
   Gated to min-width:769px (the isMobile boundary): phones suppress the stage-7 motif and
   already reach 7.0 via their short layout, so a full-height section there would only add an
   empty region above the line. Not a snap point and not scroll-padding — pure document height. */
@media (min-width: 769px) {
    .final-message {
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
    }
}

/* Round-24: wide/landscape composition for stage 7 — centred, footer kept (see DESIGN.md §27).
   On a SHORT viewport the footer (a fixed ~446px) eats half the frame at the page-bottom rest,
   so the Round-23 bottom-anchor leaves only a 240px band. Centring the closing line and holding
   the rest at the FM-centre lifts the footer off the fold's pressure, opening the band to ~360px
   while keeping motif → message → footer in one frame (closing 16:1, footer 19:1, both visible).
   The snap point is LOAD-BEARING, not decorative: without it the page rests at the absolute bottom,
   where the centred message rides to the top and TOUCHES the motif under the nav (order flips to
   message → motif → footer) — the rejected Option-1 collision. scroll-snap-align holds the rest at
   the FM-centre so the approved order survives. Boundary is a MAX-HEIGHT, not a width: the problem
   is the footer's fixed px eating a SHORT viewport, i.e. a height problem; above 1100px the
   bottom-anchor already gives ≥440px (growing to 1140px on tall), so tall/portrait keep §26 exactly
   (measured Δ0). Overrides only min-height + justify-content; display/flex-direction carry from §26. */
@media (min-width: 769px) and (max-height: 1100px) {
    .final-message {
        min-height: 70vh;
        justify-content: center;
        scroll-snap-align: center;
    }
}

.final-message p {
    max-width: none;
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(1.5rem, 3.5vw, 2.5rem);
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* ---------------------------------------------------------------------------
   12. FOOTER (unified across all pages)
   --------------------------------------------------------------------------- */
footer {
    position: relative;
    z-index: 1;
    border-top: 1px solid var(--hairline);
    padding: var(--space-8) var(--gutter) var(--space-6);
    background: rgba(0, 0, 0, 0.6);
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-6);
    justify-content: space-between;
    align-items: flex-start;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.footer-brand .logo {
    font-size: 1rem;
}

.footer-tagline {
    font-size: 0.8rem;
    /* §20.1 (Round-31): --text-tertiary is rgba(255,255,255,0.40); at ~40% opacity over
       the near-black footer panel the tagline composites to ~3.7:1 on EVERY viewport (not
       just mobile — measured wide 3.68 / tall 3.71 / mobile 3.66; the cause is the text
       opacity, not body::before ambient, which barely reaches: bg ~0.001). Raised to 0.55
       here (scoped to the tagline, not the shared token) → ~6:1, clearing AA on all pages.
       Reversible: restore `color: var(--text-tertiary)`. */
    color: rgba(255, 255, 255, 0.55);
    max-width: 32ch;
}

.footer-nav,
.footer-social {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-col-label {
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 0.3rem;
}

footer a {
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: color var(--dur) var(--ease);
}

footer a:hover {
    color: var(--text-primary);
}

.footer-copy {
    max-width: 1200px;
    margin: var(--space-8) auto 0;
    padding-top: var(--space-4);
    border-top: 1px solid var(--hairline);
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* ---------------------------------------------------------------------------
   13. INTERIOR-PAGE BASELINE (refined fully in step 3; kept coherent for now)
   These selectors belong to the other 10 pages. They are given system-consistent
   baseline styling here so the shared stylesheet does not leave them unstyled.
   --------------------------------------------------------------------------- */
.page-header {
    padding: calc(var(--space-16) + 40px) var(--gutter) var(--space-8);
    max-width: 1200px;
    margin: 0 auto;
}

.page-header h1 {
    margin-bottom: var(--space-2);
}

.page-header p {
    color: var(--text-secondary);
}

/* Generic grids used by blog / videos / sns / study（分野カード）。
   `auto-fill` のままにしてあるのは意図的：`auto-fit` は「トラック数より要素が
   少ない」ときに空トラックを潰すため、カードが1枚だけの節（03 — TRAINING）で
   その1枚が全幅（1056px）に伸びて他と揃わなくなる。実測差は §38.2。 */
.blog-grid,
.video-grid,
.sns-container,
.study-grid {
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--gutter) var(--space-16);
}

.blog-card,
.video-card,
.sns-link,
.note-card,
.study-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4);
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    color: inherit;
    overflow: hidden;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

/* ホバーが付くのは a.study-card だけ。div のカードは反応しないことで
   「行き先がない」と分かる。枠線を薄くする案は採らない — 3つ目のヘアライン値を
   作ることになり、かつ disabled と同じ記号になってしまうため（§38.3）。 */
/* タッチ端末ではタップ後に :hover が張り付く（戻ってきたとき、最後に触った
   カードだけが明るいままになる）ので、(hover: hover) の中に置く（§68.4）。 */
@media (hover: hover) {

    .blog-card:hover,
    .video-card:hover,
    .sns-link:hover,
    .note-card:hover,
    a.study-card:hover {
        background: var(--surface-hover);
        border-color: var(--hairline-strong);
    }
}

/* ★ 見出しの色は §75 で逆にした。以前は「行き先がある＝最初から青、触ると白」
   だったが、青から白へ**落ちる**のが不自然だった。いまはどのカードも
   平常は白で、触れると枠の光と同じ蛍光の青になる（光り方と文字が同じ動きをする）。 */
.study-card h3 {
    color: var(--text-primary);
}

@media (hover: hover) {
    a.study-card:hover h3 {
        color: var(--spec-glow);
    }
}

/* --- まだ行き先が無いカード（§75）------------------------------------------
   「準備中」の札は layout.js が入れる（手書きしない）。押せないので、光らない・
   拡大しない・カーソルも変えない（ホバーのルールはもともと a.study-card にしか
   かからないので、打ち消しは不要）。
   ★ 枠は三つ目のヘアラインの値を作らず、**破線**で薄く見せる—— 前後リンクの
   「準備中」がすでに border-style: dashed を使っており、サイト内の既存の合図だから
   （§38.3 は「薄い罫線は disabled に見える」として避けていたが、今回は
   押せないことを見せるのが目的なので、その判断をひっくり返している）。 */
.study-card.is-soon {
    border-style: dashed;
    cursor: default;
}

.study-card.is-soon h3 {
    color: var(--text-secondary);
}

.card-soon {
    align-self: flex-start;
    margin-top: auto;
    padding-top: var(--space-2);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    /* ★ --text-tertiary（.40）だと 12px で 3.71:1 で AA を割る。地がほぼ黒なので
       .62 に上げて 7.79:1（§75.3）。小さいので見た目は十分静か。 */
    color: var(--text-secondary);
}

/* 節の見出しはグリッドの中に全幅のアイテムとして置く。グリッド自身の箱
   （max-width と gutter）に載るので、カードと左端が必ず揃う。 */
.study-grid > .eyebrow,
.study-grid > h2 {
    grid-column: 1 / -1;
}

.study-grid > .eyebrow {
    margin-bottom: 0;
}

.blog-image.placeholder,
.video-thumbnail.placeholder,
.video-thumbnail {
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-md);
    /* Teal/cyan register (calm reading region) with warm only as a faint accent — §2.3 confines
       warm to hot cores. Was a saturated blue+magenta block, the most warm thing on the page. */
    background:
        linear-gradient(135deg, rgba(43, 217, 196, 0.34), rgba(0, 194, 203, 0.12) 55%, transparent 82%),
        radial-gradient(120% 130% at 22% 18%, rgba(43, 217, 196, 0.62), transparent 60%),
        radial-gradient(110% 120% at 82% 84%, rgba(0, 194, 203, 0.5), transparent 64%),
        radial-gradient(50% 50% at 60% 45%, rgba(255, 90, 60, 0.1), transparent 72%),
        #0a161a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-icon {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.blog-category {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent);
}

.blog-meta,
.blog-date,
.video-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.sns-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

/* Self-intro */
.self-intro {
    max-width: 1000px;
    margin: 0 auto;
    padding: calc(var(--space-16) + 40px) var(--gutter) var(--space-16);
}

.profile-container {
    display: flex;
    gap: var(--space-8);
    flex-wrap: wrap;
}

.profile-image img {
    width: 220px;
    height: 220px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    border: 1px solid var(--hairline);
}

.profile-content {
    flex: 1;
    min-width: 260px;
}

.profile-text h2 {
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    margin: var(--space-6) 0 var(--space-2);
}

.profile-text ul {
    margin: var(--space-2) 0 var(--space-2) var(--space-3);
    color: var(--text-secondary);
}

.affiliation {
    color: var(--text-tertiary);
    margin-top: var(--space-2);
}

/* 記事 / 教材ページ (body.is-article) の本文列。ページ固有のクラスではなく
   body.is-article に紐づくので、新しい記事は <body class="is-article"> を
   付けるだけでこの体裁になる（starfield.js の星の間引きも同じ合図を見ている）。
   `:not(.rail)` — 目次レールなど main 直下に並ぶ非本文要素は 900px の列に
   閉じ込めない。2カラム構成では main 側が grid/flex を決め、この規則は本文
   セクションの最大幅だけを担当する。
   ナビ分の上余白は最初の本文セクションだけが払う（セクションを複数並べる教材で、
   節ごとに 160px の空白が入らないように）。 */
body.is-article main > section:not(.rail) {
    max-width: 900px;
    margin: 0 auto;
    padding: calc(var(--space-16) + 40px) var(--gutter) var(--space-8);
}

/* 2つ目以降の本文セクションはナビ分の余白を払わない。`:first-of-type` ではなく
   一般兄弟セレクタを使う理由: レールが <section class="rail"> だと、それが
   :first-of-type を取ってしまい本文が誰もナビ分の余白を払わなくなる。この形なら
   「自分より前に本文セクションがあるか」で判定するのでレールの有無に左右されない。 */
body.is-article main > section:not(.rail) ~ section:not(.rail) {
    padding-top: var(--space-8);
}

/* 勉強の軌跡の3ページ（study / study_physics / phys-math）はいずれも .study-grid
   （1200px）で、.page-header の既定と同じ幅。列幅を合わせる規則も、読み幅 900px の
   .study-path も、アコーディオン一式も、カード化で役目を終えたので削除した（§39.3）。
   章を折りたたみたくなったら §37.6 の accordion.js ごと git 履歴から戻せる。 */

body.is-article main a:not(.btn) {
    color: var(--accent);
}

body.is-article main a:not(.btn):hover {
    color: var(--text-primary);
}

body.is-article main hr {
    border: none;
    border-top: 1px solid var(--hairline);
    margin: var(--space-4) 0;
}

/* Article vertical rhythm: h1 記事タイトル → h2 節見出し (§01…) → h3 小見出し.
   h1/h2 keep the global heading tiers; h3 is pulled down here because the global
   h3 (28px @1440) sits only 2.4px under h2 (30.4px) — fine on a two-level interior
   page, but it collapses a three-level article hierarchy. Shipped tiers: 52 / 30.4
   / 20px.
   The small uppercase label role is NOT a heading tier: use the `.eyebrow`
   component, which every page (and the retired section notes) already used. */
body.is-article main h1 {
    margin-bottom: var(--space-4);
}

body.is-article main h2 {
    margin: var(--space-8) 0 var(--space-3);
}

body.is-article main h3 {
    font-size: clamp(1.05rem, 1.5vw, 1.25rem);
    margin: var(--space-6) 0 var(--space-2);
}

body.is-article main p {
    margin-bottom: var(--space-4);
}

body.is-article main ul {
    color: var(--text-secondary);
    margin-left: var(--space-3);
    line-height: 1.9;
}

/* PDF embed wrapper (§G: never filter the iframe; keep white bg, pad inside frame) */
/* Reliable PDF access on every browser — iOS Safari renders PDFs in an <iframe>
   poorly (first page only, no scroll), so a primary "open" link sits above the embed
   as the guaranteed path; the iframe stays for browsers that handle it inline. */
.pdf-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-3);
}

.pdf-frame {
    padding: 24px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.pdf-frame iframe {
    display: block;
    width: 100%;
    border: 0;
    border-radius: var(--radius-sm);
    background: #fff;
}

/* Any checkbox/slider on the site takes the site accent (blue). This used to be
   --spec-teal, the hero palette's teal, which was the last teal left in the UI
   chrome — the particle field keeps it, the controls do not (§47). Changed while
   no page shipped a checkbox yet, so nothing visible moved. */
input[type="checkbox"],
input[type="range"] {
    accent-color: var(--accent);
}

/* ---------------------------------------------------------------------------
   14. RESPONSIVE
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
    header {
        top: 12px;
        width: calc(100% - 24px);
        padding: 0.5rem 0.6rem 0.5rem 1rem;
    }

    .menu-toggle {
        display: flex;
    }

    header nav {
        position: static;
        flex: none;
    }

    /* Collapsed menu drops into a blurred rounded panel below the pill */
    .nav-menu {
        position: absolute;
        top: calc(100% + 10px);
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
        padding: var(--space-2);
        background: var(--nav-bg);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid var(--hairline);
        border-radius: var(--radius-md);
        opacity: 0;
        transform: translateY(-8px);
        pointer-events: none;
        transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
    }

    .nav-menu.active {
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }

    .nav-menu a {
        display: block;
        padding: 0.7rem 0.9rem;
    }

    .btn-nav-cta {
        display: none;
    }

    /* Mobile hero: the four text stages at ~55vh each (~220vh). MATTER + SOLAR
       are skipped entirely (the JS builds only the four formations). */
    .scene {
        height: 90vh;   /* Round-12 Part 6 — longer mobile stages (4 × 90vh = 360vh) */
    }

    /* Head + tail spacers push the first/last scene centres off the 0/1 ends so the four
       scene centres land at 12.5 / 37.5 / 62.5 / 87.5% of scroll — i.e. exactly the
       evenly-spaced sample offsets. For 90vh scenes the even-tp math gives a 50vh spacer
       (was 51vh at 55vh). Each stage's text-centre then coincides with its formation peak.
       Canvas layers are fixed, so padding moves only the flowing scenes. */
    .hero {
        padding-block: 50vh;
    }

    .scene .scene__content {
        top: 14vh;
    }

    .profile-container {
        gap: var(--space-6);
    }
}

/* Hero text must never clip on narrow phones */
@media (max-width: 480px) {
    .gate-title {
        font-size: clamp(1.85rem, 9vw, 2.4rem);
        letter-spacing: -0.02em;
    }

    .gate-subtitle {
        font-size: 0.9rem;
        max-width: 100%;
    }

    .scene--split .scene__lead {
        max-width: none;
    }
}

@media (max-width: 375px) {
    :root {
        --gutter: 1.1rem;
    }

    .profile-image img {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }
}

/* ---------------------------------------------------------------------------
   15. REDUCED MOTION (global belt-and-braces)
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ★ この2つの部品は「一覧ページ（style.css だけ）」と「教材ページ（＋lesson-theme.css）」
   の両方で使う。--ink / --line などは lesson-theme.css にしか無いトークンなので、
   var() の第2引数に style.css 側の同等トークンを置いてある。これが無いと、一覧
   ページでは無効値になり、文字が真っ白・罫線が真っ白になる（§67.1）。 */
/* --- 一覧ページの「← 一つ上」（§67 / 枠は §69）。レールのある記事では
   .rail-up が同じ役目をする。形も光り方もそちらと揃えてある。行き先は layout.js が
   CRUMBS の親から決める。幅は文字なり（inline-flex）で、横いっぱいには伸ばさない。 */
.page-up {
    margin: 0 0 26px;
    font-size: 12.5px;
    line-height: 1.6;
}
.page-up a {
    display: inline-flex;
    align-items: center;
    gap: .45em;
    padding: 5px 13px;
    border: 1px solid var(--line, var(--hairline));
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--ink-faint, var(--text-tertiary));
    text-decoration: none;
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease),
        border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

/* 矢印だけを包むのは、ホバーでこれだけを動かすため（§68.2）。
   間隔は gap が持つので margin は持たせない。 */
.page-up .ar {
    display: inline-block;
    transition: transform var(--dur) var(--ease);
}

/* ホバーの応答はすべて (hover: hover) の中に置く。タッチ端末では
   :hover がタップ後に張り付くため（§68.4）。外側の光は第1回の天体カードと
   同じ系統を弱めたもの（向こうは 0 0 24px / .24、こちらは 0 0 14px / .12）。 */
@media (hover: hover) {
    .page-up a:hover {
        color: var(--ink, var(--text-primary));
        background: var(--surface-2, var(--surface-hover));
        border-color: var(--line-strong, var(--hairline-strong));
        box-shadow: 0 0 14px rgba(61, 139, 255, .12);
    }
    .page-up a:hover .ar { transform: translateX(-3px); }
}
.page-up a:focus-visible { color: var(--ink, var(--text-primary)); outline: 2px solid var(--accent); outline-offset: 3px; }

/* ===========================================================================
   右側のサイトナビ（§66）。左のレールは「記事内の目次」、こちらは「サイト全体の
   階層」。中身は layout.js の CRUMBS から組み立てる（テーブルに1行足せば出る）。
   面と罫線はヘッダーと同じ --nav-bg ＋ぼかし。新しい色は足していない。
   =========================================================================== */
.sitenav-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1200;
    writing-mode: vertical-rl;
    font-family: inherit;
    font-size: 12px;
    letter-spacing: .18em;
    padding: 18px 8px;
    color: var(--ink-soft, var(--text-secondary));
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--line, var(--hairline));
    border-right: 0;
    border-radius: 12px 0 0 12px;
    cursor: pointer;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
        transform var(--dur) var(--ease);
}
@media (hover: hover) {
    .sitenav-tab:hover {
        color: var(--ink, var(--text-primary));
        border-color: var(--line-strong, var(--hairline-strong));
        transform: translateY(-50%) translateX(-2px);
    }
}
.sitenav-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sitenav-scrim {
    position: fixed;
    inset: 0;
    z-index: 1205;
    background: rgba(0, 0, 0, .55);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
}
body.sitenav-open .sitenav-scrim { opacity: 1; pointer-events: auto; }

.sitenav {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1210;
    width: min(380px, 88vw);
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--line, var(--hairline));
    transform: translateX(101%);
    transition: transform var(--dur) var(--ease);
}
body.sitenav-open .sitenav { transform: none; }
.sitenav__hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 20px 14px;
    border-bottom: 1px solid var(--line, var(--hairline));
    font-size: 11px;
    letter-spacing: .2em;
    color: var(--ink-faint, var(--text-tertiary));
}
.sitenav__x {
    background: none;
    border: 0;
    color: var(--ink-faint, var(--text-tertiary));
    font-size: 15px;
    line-height: 1;
    padding: 4px;
    cursor: pointer;
    transition: color var(--dur) var(--ease);
}
@media (hover: hover) { .sitenav__x:hover { color: var(--ink, var(--text-primary)); } }
.sitenav__body { overflow-y: auto; padding: 14px 18px 40px; }

/* ツリー。字下げは階層ごとに、開閉は grid-template-rows で滑らかに。 */
.sitenav .tree, .sitenav .tree ul { list-style: none; margin: 0; padding: 0; }
.sitenav .tree ul { padding-left: 16px; }
.sitenav .rw { display: flex; align-items: flex-start; gap: 2px; }
.sitenav .rw a, .sitenav .rw .hd {
    flex: 1 1 auto;
    display: block;
    font-family: inherit;
    font-size: 14.5px;
    line-height: 1.65;
    text-align: left;
    padding: 5px 8px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--ink-soft, var(--text-secondary));
    text-decoration: none;
    cursor: pointer;
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
/* 行の反応は「行き先がある行」だけ。章の見出し（.hd）は開閉しかしないので、
   リンクと同じ反応を与えない—— 代わりに三角だけが明るくなる（§68.3）。 */
@media (hover: hover) {
    .sitenav .rw a:hover { color: var(--ink, var(--text-primary)); background: var(--surface-2, var(--surface-hover)); }
    .sitenav .rw:has(> .hd:hover) > .tw::before { border-color: var(--ink-soft, var(--text-secondary)); }
}
.sitenav .rw .hd { color: var(--ink-faint, var(--text-tertiary)); }
.sitenav .rw .soon { flex: 1 1 auto; padding: 5px 8px; font-size: 14.5px; line-height: 1.65; color: var(--ink-faint, var(--text-tertiary)); opacity: .55; }
.sitenav .rw a.cur { color: var(--accent); background: var(--accent-tint, rgba(61, 139, 255, .12)); }
.sitenav .tw {
    flex: 0 0 auto;
    width: 22px;
    height: 32px;
    margin-top: 1px;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    position: relative;
}
.sitenav .tw::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 13px;
    width: 6px;
    height: 6px;
    border-right: 1.5px solid var(--ink-faint, var(--text-tertiary));
    border-bottom: 1.5px solid var(--ink-faint, var(--text-tertiary));
    transform: rotate(-45deg);
    transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.sitenav .nd.open > .rw > .tw::before { transform: rotate(45deg); }
@media (hover: hover) { .sitenav .tw:hover::before { border-color: var(--ink, var(--text-primary)); } }
.sitenav .tw--leaf { cursor: default; }
.sitenav .tw--leaf::before { display: none; }
.sitenav .kids { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--dur) var(--ease); }
.sitenav .nd.open > .kids { grid-template-rows: 1fr; }
.sitenav .kids > ul { overflow: hidden; min-height: 0; }

@media (max-width: 900px) {
    .sitenav { width: 100%; border-left: 0; }
}
@media print {
    .sitenav, .sitenav-tab, .sitenav-scrim { display: none !important; }
}

/* --- 動きを減らす設定では、移動だけをやめる（§68.4）。§15 の全体ルールは
   transition-duration を 0 にするだけなので「瞬間移動」になってしまう。
   明度の変化は残す（それが「押せる」という情報そのものだから）。 */
@media (prefers-reduced-motion: reduce) {
    .page-up a:hover .ar { transform: none; }
    .sitenav-tab:hover { transform: translateY(-50%); }
}

/* ===========================================================================
   70. 押せる面のホバーをひとつの形に揃える（§70 → §73 → §74）
   拡大（1.012）＋ **枠全体が蛍光の青で一様に光る** ＋ 背景がひと段明るく
   ＋ 同じ色の外側のにじみ。文字の明度は要素ごとに元から決まっているものを使う。

   ★ 光り方はこの1種類だけ（§74）。以前は「戻る＝全体」「進む＝弧が回る」と
   分けていたが、回転をやめて全部を一様な光にした。conic-gradient と
   @property（--edge-a / edgeSpin）は使う箇所が無くなったので削除してある。
   （第1回の天体カードの環 .ring は別物。memoryverse_1-1.html に残っている）

   ★ position は「まだ持っていないもの」だけに与える。.study-card は既に relative、
   .sitenav-tab は fixed なので、まとめて relative を書くとタブが固定を失って
   ページ末尾に落ちる（§70.4）。
   =========================================================================== */
.page-up a,
.rail-up a,
.lesson-nav a:not(.btn) {
    position: relative;
}

.page-up a,
.rail-up a,
a.study-card,
.lesson-nav a:not(.btn),
.sitenav-tab {
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease),
        border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
        transform var(--dur) var(--ease);
}

/* 枠線そのものとして光る 1.5px のリング。要素の border の上に重なる。 */
.page-up a::before,
.rail-up a::before,
a.study-card::before,
.lesson-nav a:not(.btn)::before,
.sitenav-tab::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    /* 1px では細すぎて黒に負けるので 1.5px。 */
    padding: 1.5px;
    background: color-mix(in srgb, var(--spec-glow) 92%, transparent);
    filter: drop-shadow(0 0 6px color-mix(in srgb, var(--spec-glow) 55%, transparent));
    /* 枠線の幅（padding）だけを残して中身を抜く。 */
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
}

@media (hover: hover) {

    .page-up a:hover,
    .rail-up a:hover,
    a.study-card:hover,
    .lesson-nav a:not(.btn):hover,
    .sitenav-tab:hover {
        background: var(--surface-hot, rgba(255, 255, 255, .07));
        border-color: color-mix(in srgb, var(--spec-glow) 55%, transparent);
        box-shadow: 0 0 22px color-mix(in srgb, var(--spec-glow) 34%, transparent);
        transform: scale(1.012);
    }

    /* タブは中央寄せの translate を持っているので、その後ろに足す。 */
    .sitenav-tab:hover {
        transform: translateY(-50%) translateX(-2px) scale(1.012);
    }

    /* 触れた1枚だけが光る（:hover の中でしか opacity を上げない）。 */
    .page-up a:hover::before,
    .rail-up a:hover::before,
    a.study-card:hover::before,
    .lesson-nav a:not(.btn):hover::before,
    .sitenav-tab:hover::before {
        opacity: 1;
    }
}

/* 動きを減らす設定では、拡大をやめて光だけを残す（§73.4）。
   光は元々回らないので、ここで止めるものは拡大だけになった。 */
@media (prefers-reduced-motion: reduce) {

    .page-up a:hover,
    .rail-up a:hover,
    a.study-card:hover,
    .lesson-nav a:not(.btn):hover {
        transform: none;
    }

    .sitenav-tab:hover {
        transform: translateY(-50%);
    }
}
