/* ==========================================================================
   RONDO · Shared design tokens and component styles
   ========================================================================== */

/* ===== RESET ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ==========================================================================
   DESIGN TOKENS
   3-tier architecture: Primitive → Semantic (alias) → Legacy alias
   Breakpoints (documented, used directly in @media):
     sm 520 · md 768 · lg 960 · xl 1280
   ========================================================================== */
:root {
    /* --- PRIMITIVE · Neutral scale (monotone palette, mode-independent) --- */
    --neutral-50:  #F4F4F2;  /* warm off-white · page bg (light) */
    --neutral-100: #E5E5E5;  /* pat-soft (light) */
    --neutral-200: #D4D4D4;  /* hairline (light) */
    --neutral-300: #A3A3A3;  /* pat-mid (light) · fg-muted (dark) */
    --neutral-400: #9A9A9A;  /* fg-dim (light) */
    --neutral-500: #737373;  /* fg-muted (light) */
    --neutral-550: #6B6B6B;  /* pat-mid (dark) */
    --neutral-600: #525252;  /* fg-dim (dark) */
    --neutral-700: #404040;
    --neutral-800: #262626;  /* hairline (dark) · pat-soft (dark) */
    --neutral-900: #1A1A1A;  /* phone bezel */
    --neutral-950: #0A0A0A;  /* page bg (dark) · fg (light) · pat-hard (light) */

    /* --- SEMANTIC · Color (mode-aware aliases) --- */
    --color-surface-page:    var(--neutral-50);
    --color-surface-inset:   var(--neutral-100);
    --color-surface-inverse: var(--neutral-950);

    --color-text-primary:    var(--neutral-950);
    --color-text-muted:      var(--neutral-500);
    --color-text-dim:        var(--neutral-400);
    --color-text-inverse:    var(--neutral-50);

    --color-border-hair:     var(--neutral-200);
    --color-border-strong:   var(--neutral-950);

    --color-action-primary-bg: var(--neutral-950);
    --color-action-primary-fg: var(--neutral-50);

    /* --- SEMANTIC · Pattern tile tiers --- */
    --pat-soft: var(--neutral-100);
    --pat-mid:  var(--neutral-300);
    --pat-hard: var(--neutral-950);

    /* --- LEGACY · Back-compat aliases (existing code uses these) --- */
    --bg:        var(--color-surface-page);
    --fg:        var(--color-text-primary);
    --fg-muted:  var(--color-text-muted);
    --fg-dim:    var(--color-text-dim);
    --rule:      var(--color-border-hair);
    --accent-bg: var(--color-action-primary-bg);
    --accent-fg: var(--color-action-primary-fg);

    /* --- Typography stacks --- */
    --stack-sans: 'Helvetica Neue', Helvetica, Arial, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, sans-serif;
    --stack-jp:   'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, 'Helvetica Neue', sans-serif;
    --stack-latin:'Helvetica Neue', Helvetica, Arial, sans-serif;
    --stack-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Courier New', monospace;

    /* --- Radius · Apple-style corner scale --- */
    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --radius-full: 9999px;

    /* --- Border --- */
    --border-hair: 1px;

    /* --- Elevation · Shadow scale --- */
    --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 20px 40px -20px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.25);
    --shadow-xl: 0 40px 80px -20px rgba(0, 0, 0, 0.3);

    /* --- Motion · Timing functions --- */
    --ease-primary: cubic-bezier(0.22, 1, 0.36, 1);   /* decel, used for reveals */
    --ease-ui:      ease;                              /* hover, toggles */
    --ease-linear:  linear;

    /* --- Motion · Durations --- */
    --dur-instant: 0.15s;
    --dur-fast:    0.3s;
    --dur-base:    0.9s;
    --dur-slow:    1.2s;

    /* --- Z-index scale --- */
    --z-base:     1;
    --z-docked:  10;
    --z-masthead:40;
    --z-controls:50;
    --z-modal:  100;

    /* --- Opacity utility --- */
    --opacity-disabled: 0.4;
    --opacity-watermark: 0.08;

    /* --- Layout / Grid --- */
    --wrap-max: 1280px;
    --gutter:   24px;
    --tap-size: 44px; /* a11y minimum touch target */
}
.dark {
    --color-surface-page:    var(--neutral-950);
    --color-surface-inset:   var(--neutral-900);
    --color-surface-inverse: var(--neutral-50);

    --color-text-primary:    var(--neutral-50);
    --color-text-muted:      var(--neutral-300);
    --color-text-dim:        var(--neutral-600);
    --color-text-inverse:    var(--neutral-950);

    --color-border-hair:     var(--neutral-800);
    --color-border-strong:   var(--neutral-50);

    --color-action-primary-bg: var(--neutral-50);
    --color-action-primary-fg: var(--neutral-950);

    --pat-soft: var(--neutral-800);
    --pat-mid:  var(--neutral-550);
    --pat-hard: var(--neutral-50);

    --shadow-md: 0 20px 40px -20px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
    --shadow-xl: 0 40px 100px -20px rgba(0, 0, 0, 0.9);
}

/* ===== BASE ===== */
::selection { background: var(--fg); color: var(--bg); }

html {
    scroll-behavior: smooth;
    scroll-padding-top: 24px;
    background: var(--bg);
    overscroll-behavior: none;
}

body {
    font-family: var(--stack-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
    overflow-x: hidden;
    overscroll-behavior: none;
    transition: background-color 0.3s ease, color 0.3s ease;
    /* Japanese natural line breaks (Chrome 119+ auto-phrase uses bunsetsu) */
    word-break: auto-phrase;
    line-break: strict;
    overflow-wrap: break-word;
    hanging-punctuation: allow-end;
    text-wrap: pretty;
}

/* Display titles: balance line lengths instead of greedy wrap */
h1, h2, .feature-title, .changelog-title, .version-title, .page-title,
.cta h2, .story-card-title, .hero-display h1 {
    text-wrap: balance;
}

/* ===== LAYOUT ===== */
main { position: relative; padding: 0 24px; }
.wrap { max-width: 1280px; margin: 0 auto; position: relative; }

/* ===== MOTION ===== */
/* .aos is the intersection-observer trigger; children animate in with stagger. */
.aos { /* no visual — trigger only */ }

/* Standard reveal: rise + fade */
.aos .feature-head,
.aos .feature-text > *,
.aos .feature-visual,
.aos .changelog-head,
.aos .changelog-grid > *,
.aos .changelog-imp,
.aos .changelog-more,
.aos .index-header,
.aos .index-list > li,
.aos .story-head,
.aos .story-grid > *,
.aos .version-head,
.aos .version-intro,
.aos .page-meta,
.aos .v10-image,
.aos .feature-grid > *,
.aos .plain-list > li,
.aos .changelog-imp ul > li,
.aos .block-label,
.aos .cta-row > * {
    opacity: 0;
    transform: translateY(28px);
    transition:
        opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform, opacity;
}
.aos.visible .feature-head,
.aos.visible .feature-text > *,
.aos.visible .feature-visual,
.aos.visible .changelog-head,
.aos.visible .changelog-grid > *,
.aos.visible .changelog-imp,
.aos.visible .changelog-more,
.aos.visible .index-header,
.aos.visible .index-list > li,
.aos.visible .story-head,
.aos.visible .story-grid > *,
.aos.visible .version-head,
.aos.visible .version-intro,
.aos.visible .page-meta,
.aos.visible .v10-image,
.aos.visible .feature-grid > *,
.aos.visible .plain-list > li,
.aos.visible .changelog-imp ul > li,
.aos.visible .block-label,
.aos.visible .cta-row > * {
    opacity: 1;
    transform: translateY(0);
}

/* Display titles: larger movement for impact */
.aos .feature-title,
.aos .changelog-title,
.aos .version-title,
.aos .cta h2,
.aos .page-title {
    opacity: 0;
    transform: translateY(56px);
    transition:
        opacity 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.05s,
        transform 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.05s;
    will-change: transform, opacity;
}
.aos.visible .feature-title,
.aos.visible .changelog-title,
.aos.visible .version-title,
.aos.visible .cta h2,
.aos.visible .page-title {
    opacity: 1;
    transform: translateY(0);
}

/* Section header rule-line draws in */
.aos .feature-head .dash,
.aos .changelog-head .dash,
.aos .story-head .dash,
.aos .version-head .dash {
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.15s;
}
.aos.visible .feature-head .dash,
.aos.visible .changelog-head .dash,
.aos.visible .story-head .dash,
.aos.visible .version-head .dash { transform: scaleX(1); }

/* Block-label rule draws in after label appears */
.aos .block-label::after {
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.35s;
}
.aos.visible .block-label::after { transform: scaleX(1); }

/* ===== STAGGER DELAYS ===== */
.aos.visible .feature-text > *:nth-child(1) { transition-delay: 0.15s; }
.aos.visible .feature-text > *:nth-child(2) { transition-delay: 0.26s; }
.aos.visible .feature-text > *:nth-child(3) { transition-delay: 0.36s; }
.aos.visible .feature-text > *:nth-child(4) { transition-delay: 0.46s; }
.aos.visible .feature-visual { transition-delay: 0.3s; }

.aos.visible .index-list > li:nth-child(1) { transition-delay: 0.1s; }
.aos.visible .index-list > li:nth-child(2) { transition-delay: 0.18s; }
.aos.visible .index-list > li:nth-child(3) { transition-delay: 0.26s; }
.aos.visible .index-list > li:nth-child(4) { transition-delay: 0.34s; }
.aos.visible .index-list > li:nth-child(5) { transition-delay: 0.42s; }

.aos.visible .changelog-grid > *:nth-child(1) { transition-delay: 0.28s; }
.aos.visible .changelog-grid > *:nth-child(2) { transition-delay: 0.38s; }
.aos.visible .changelog-grid > *:nth-child(3) { transition-delay: 0.48s; }
.aos.visible .changelog-imp { transition-delay: 0.55s; }
.aos.visible .changelog-more { transition-delay: 0.7s; }

.aos.visible .story-grid > *:nth-child(1) { transition-delay: 0.2s; }
.aos.visible .story-grid > *:nth-child(2) { transition-delay: 0.34s; }

.aos.visible .cta-row > *:nth-child(1) { transition-delay: 0.25s; }
.aos.visible .cta-row > *:nth-child(2) { transition-delay: 0.4s; }

.aos.visible .feature-grid > *:nth-child(1) { transition-delay: 0.3s; }
.aos.visible .feature-grid > *:nth-child(2) { transition-delay: 0.4s; }
.aos.visible .feature-grid > *:nth-child(3) { transition-delay: 0.5s; }
.aos.visible .feature-grid > *:nth-child(4) { transition-delay: 0.6s; }

.aos.visible .plain-list > li:nth-child(1),
.aos.visible .changelog-imp ul > li:nth-child(1) { transition-delay: 0.1s; }
.aos.visible .plain-list > li:nth-child(2),
.aos.visible .changelog-imp ul > li:nth-child(2) { transition-delay: 0.16s; }
.aos.visible .plain-list > li:nth-child(3),
.aos.visible .changelog-imp ul > li:nth-child(3) { transition-delay: 0.22s; }
.aos.visible .plain-list > li:nth-child(4),
.aos.visible .changelog-imp ul > li:nth-child(4) { transition-delay: 0.28s; }
.aos.visible .plain-list > li:nth-child(5),
.aos.visible .changelog-imp ul > li:nth-child(5) { transition-delay: 0.34s; }
.aos.visible .plain-list > li:nth-child(6),
.aos.visible .changelog-imp ul > li:nth-child(6) { transition-delay: 0.4s; }
.aos.visible .plain-list > li:nth-child(7),
.aos.visible .changelog-imp ul > li:nth-child(7) { transition-delay: 0.46s; }
.aos.visible .plain-list > li:nth-child(8) { transition-delay: 0.52s; }

/* ===== HERO INITIAL REVEAL (page load) ===== */
.fade-in { opacity: 0; animation: fadeIn 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.d1 { animation-delay: 0.1s; }
.d2 { animation-delay: 0.25s; }
.d3 { animation-delay: 0.4s; }
.d4 { animation-delay: 0.55s; }
.d5 { animation-delay: 0.7s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .aos *, .aos.visible *, .fade-in { transition: none !important; animation: none !important; transform: none !important; opacity: 1 !important; }
}

/* ===== EDITORIAL PRIMITIVES ===== */
.eyebrow {
    font-family: var(--stack-latin);
    font-size: 11px; font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fg-muted);
}
.eyebrow .num { color: var(--fg); }

.rule { height: 1px; background: var(--rule); width: 100%; }

.block-label {
    font-family: var(--stack-latin);
    font-size: 11px; font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fg-muted);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
}
.block-label::after {
    content: '';
    height: 1px;
    background: var(--rule);
}

/* ===== CONTROLS (top-right, fixed) ===== */
.controls {
    position: fixed; z-index: 60;
    top: 16px; right: 16px;
    display: flex; align-items: center; gap: 4px;
}
.ctrl-btn {
    font-family: var(--stack-latin);
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--fg);
    border-radius: var(--radius-xs);
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.ctrl-btn:hover { background: var(--fg); color: var(--bg); }
.ctrl-btn svg { width: 16px; height: 16px; }
.icon-sun { display: none; }
.icon-moon { display: block; }
.dark .icon-sun { display: block; }
.dark .icon-moon { display: none; }
.lang-menu-wrap { position: relative; }
.lang-menu {
    position: absolute; top: calc(100% + 4px); right: 0;
    min-width: 160px;
    border: 1px solid var(--fg);
    border-radius: var(--radius-sm);
    background: var(--bg);
    overflow: hidden;
    opacity: 0; pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.2s, transform 0.2s;
}
.lang-menu.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.lang-menu button {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 10px 14px;
    background: none; border: none; cursor: pointer;
    font-family: var(--stack-sans);
    font-size: 13px; font-weight: 500;
    color: var(--fg-muted);
}
.lang-menu button:hover { background: var(--fg); color: var(--bg); }
.lang-menu button.active { color: var(--fg); font-weight: 700; }
.lang-menu button:hover.active { color: var(--bg); }
.lang-menu button .lang-code {
    font-family: var(--stack-latin);
    font-size: 10.5px; letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.55;
}

/* ===== MASTHEAD LOGO (absolute, inside hero/page-header) ===== */
.mast {
    position: absolute;
    z-index: 40;
    font-family: var(--stack-latin);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg);
    pointer-events: none;
}
.mast-tl { top: 24px; left: 0; pointer-events: auto; }
.mast-tr { top: 24px; right: 0; text-align: right; }
.mast-bl { bottom: 24px; left: 0; }
.mast-br { bottom: 24px; right: 0; text-align: right; }
.mast .dim { color: var(--fg-dim); }

.mast-logo {
    display: block;
    text-decoration: none;
    color: var(--fg);
}
.mast-logo .logotype {
    height: 32px;
    width: auto;
    display: block;
    color: var(--fg);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 14px;
    padding: 18px 28px;
    font-family: var(--stack-latin);
    font-size: 14px; font-weight: 700;
    letter-spacing: 0.02em;
    text-decoration: none;
    background: var(--accent-bg);
    color: var(--accent-fg);
    border: 1px solid var(--accent-bg);
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s;
}
.btn:hover { background: transparent; color: var(--fg); border-color: var(--fg); }
.btn svg { width: 18px; height: 18px; }
.btn .arrow { display: inline-block; transition: transform 0.3s; }
.btn:hover .arrow { transform: translateX(4px); }

.btn-ghost {
    display: inline-flex; align-items: center; gap: 14px;
    padding: 18px 28px;
    font-family: var(--stack-latin);
    font-size: 14px; font-weight: 700;
    text-decoration: none;
    background: transparent;
    color: var(--fg);
    border: 1px solid var(--fg);
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s;
}
.btn-ghost:hover { background: var(--fg); color: var(--bg); }

/* ===== PLAIN LIST (+ marker) ===== */
.plain-list {
    list-style: none;
    margin-bottom: 48px;
}
.plain-list li {
    padding: 16px 0;
    border-bottom: 1px solid var(--rule);
    display: grid;
    grid-template-columns: 24px 1fr;
    gap: 16px;
    align-items: baseline;
}
.plain-list li:last-child { border-bottom: none; }
.plain-list li::before {
    content: '+';
    font-family: var(--stack-latin);
    color: var(--fg);
    font-weight: 500;
    font-size: 12px;
}
.plain-list li strong {
    font-family: var(--stack-jp);
    display: block;
    font-size: 14px; font-weight: 700;
    color: var(--fg);
    margin-bottom: 4px;
    letter-spacing: 0.01em;
}
.plain-list li span {
    font-family: var(--stack-sans);
    font-size: 13px; font-weight: 300;
    line-height: 1.75;
    color: var(--fg-muted);
}
.plain-list.single-line li { grid-template-columns: 24px 1fr; }
.plain-list.single-line li::before { align-self: baseline; }
.plain-list.single-line li > * {
    font-family: var(--stack-sans);
    font-size: 14px; font-weight: 300;
    line-height: 1.75;
    color: var(--fg);
}

/* ===== CTA BLOCK ===== */
.cta {
    padding: 128px 0 160px;
    border-top: 1px solid var(--rule);
}
.cta h2 {
    font-family: var(--stack-latin);
    font-size: clamp(44px, 7vw, 96px);
    font-weight: 900;
    letter-spacing: -0.05em;
    line-height: 0.95;
    margin-bottom: 48px;
}
.cta h2 .dim { color: var(--fg-dim); }
.cta-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--fg);
}
.cta-imprint {
    display: flex; flex-direction: column; gap: 8px;
    font-family: var(--stack-latin);
    font-size: 12px; font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fg);
}
.cta-imprint-line.dim { color: var(--fg-muted); font-weight: 400; }

/* ===== COLOPHON ===== */
.colophon {
    padding: 80px 0 48px;
    border-top: 1px solid var(--fg);
    position: relative;
}
.colophon-mark {
    display: flex; align-items: center; gap: 24px;
    margin-bottom: 64px;
}
.colophon-mark .logotype {
    height: clamp(48px, 7vw, 80px);
    width: auto;
    color: var(--fg);
    flex-shrink: 0;
    display: block;
}
.colophon-mark-text {
    font-family: var(--stack-latin);
    font-size: clamp(32px, 5vw, 56px);
    font-weight: 300;
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--fg-dim);
}
.colophon-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 32px;
    margin-bottom: 48px;
}
.colophon-col h4 {
    font-family: var(--stack-latin);
    font-size: 10.5px; font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fg-muted);
    margin-bottom: 12px;
}
.colophon-col p, .colophon-col a {
    font-family: var(--stack-sans);
    font-size: 13px;
    line-height: 1.6;
    color: var(--fg);
    text-decoration: none;
    display: block;
}
.colophon-col a:hover { opacity: 0.6; }
.colophon-col a + a { margin-top: 4px; }
.colophon-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 24px;
    border-top: 1px solid var(--rule);
    font-family: var(--stack-latin);
    font-size: 10.5px; font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fg-muted);
}
.colophon-bottom a {
    color: var(--fg-muted); text-decoration: none;
}
.colophon-bottom a:hover { color: var(--fg); }

/* ===== BACKGROUND-ONLY MODE (for screenshots) ===== */
body.bg-only > *:not(#bg-canvas):not(#bg-hint) { visibility: hidden !important; }
body.bg-only #bg-canvas { opacity: 1 !important; }

/* ===== SHARED RESPONSIVE ===== */
@media (max-width: 960px) {
    .cta { padding: 96px 0 120px; }
    .cta-row { grid-template-columns: 1fr; gap: 24px; align-items: start; justify-items: start; }
    .colophon-grid { grid-template-columns: repeat(2, 1fr); gap: 24px; }
}

@media (max-width: 520px) {
    main { padding: 0 16px; }
    .controls { top: 12px; right: 12px; }
    .mast-tl { top: 16px; }
    .mast-tr { top: 16px; }
    .mast-bl { bottom: 16px; }
    .mast-br { bottom: 16px; }
    .cta h2 { letter-spacing: -0.045em; }
    .colophon-grid { grid-template-columns: 1fr; }
}
