/* ============================================================
   X402 — Shared Design System
   All multi-page site pages link this file.
   site/index.html (single-page) has its own inline copy.
   ============================================================ */

/* ---- CSS Reset ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* ---- Theme variables ---- */
:root {
    --paper: #faf9f6;
    --paper-2: #f3f1ea;
    --ink: #0e0d0a;
    --ink-soft: #45413a;
    --ink-muted: #8a8478;
    --amber: #e19e23;
    --amber-deep: #b87f15;
    --amber-wash: rgba(225, 158, 35, 0.1);
    --line: rgba(14, 13, 10, 0.14);
    --line-strong: rgba(14, 13, 10, 0.85);
    --atm-grid: rgba(14, 13, 10, 0.04);
    --panel-dark-bg: #0e0d0a;
    --nav-bg: rgba(250, 249, 246, 0.72);
    --nav-bg-scrolled: rgba(250, 249, 246, 0.92);
    --mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    --sans: 'Archivo', -apple-system, BlinkMacSystemFont, sans-serif;
    --black: 'Archivo Black', 'Archivo', sans-serif;
    color-scheme: light;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --paper: #100f0c;
    --paper-2: #17150f;
    --ink: #f4f2ec;
    --ink-soft: #c7c2b6;
    --ink-muted: #9a9488;
    --amber: #e8a93c;
    --amber-deep: #f0b755;
    --amber-wash: rgba(225, 158, 35, 0.14);
    --line: rgba(244, 242, 236, 0.16);
    --line-strong: rgba(244, 242, 236, 0.85);
    --atm-grid: rgba(250, 249, 246, 0.04);
    --panel-dark-bg: #0e0d0a;
    --nav-bg: rgba(16, 15, 12, 0.72);
    --nav-bg-scrolled: rgba(16, 15, 12, 0.92);
}

/* ---- Base ---- */
body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-weight: 400;
    line-height: 1.65;
    overflow-x: hidden;
}

::selection { background: var(--amber); color: var(--ink); }

/* ---- Focus ---- */
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; border-radius: 2px; }
*:focus:not(:focus-visible) { outline: none; }

/* ---- Skip link ---- */
.skip-link {
    position: fixed; left: -9999px; top: 0; z-index: 300;
    background: var(--ink); color: var(--paper);
    font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.06em;
    padding: 0.75rem 1.15rem; text-decoration: none;
    box-shadow: 4px 4px 0 var(--amber);
}
.skip-link:focus { left: 0.6rem; top: 0.6rem; }

/* ---- Scroll progress ---- */
.scroll-progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 0;
    background: var(--amber); z-index: 101;
    transition: width 0.08s linear; will-change: width;
}
@media (prefers-reduced-motion: reduce) { .scroll-progress { transition: none; } }

/* ---- Atmosphere ---- */
.atmosphere {
    position: fixed; inset: 0; z-index: -2;
    background:
        radial-gradient(1000px 600px at 90% -5%, var(--amber-wash), transparent 60%),
        linear-gradient(var(--paper), var(--paper-2));
    pointer-events: none;
}
.atmosphere::before {
    content: ''; position: absolute; inset: 0;
    background-image:
        linear-gradient(var(--atm-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--atm-grid) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: linear-gradient(180deg, rgba(0,0,0,0.8), rgba(0,0,0,0.2) 55%, rgba(0,0,0,0.5));
    -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,0.8), rgba(0,0,0,0.2) 55%, rgba(0,0,0,0.5));
}
.atmosphere::after {
    content: ''; position: absolute; inset: 0; opacity: 0.6;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.025 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- Wordmark ---- */
.wordmark {
    font-family: var(--black);
    font-weight: 400; letter-spacing: 0.01em;
    color: var(--ink); text-decoration: none;
    display: inline-flex; align-items: baseline; line-height: 1;
}
.wordmark .zero {
    font-family: 'Inter', var(--sans); font-weight: 900;
    font-feature-settings: 'zero' 1; font-variant-numeric: slashed-zero;
    color: var(--amber); margin: 0 0.01em;
}

/* ---- Theme toggle ---- */
.theme-toggle {
    background: none; border: none; padding: 0.3rem; cursor: pointer;
    color: var(--ink-muted); display: inline-flex; align-items: center;
    transition: color 0.2s;
}
.theme-toggle:hover { color: var(--ink); }

/* ---- Nav ---- */
nav#nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.1rem 5%;
    background: var(--nav-bg);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease, background 0.3s ease;
}
nav#nav.scrolled {
    border-bottom-color: var(--line-strong);
    background: var(--nav-bg-scrolled);
}
.logo-group { display: flex; flex-direction: column; gap: 0.18rem; }
nav#nav .wordmark { font-size: 1.9rem; }
.logo-slogan {
    font-family: var(--mono); font-size: 0.56rem; color: var(--ink-muted);
    font-weight: 500; letter-spacing: 0.24em; text-transform: uppercase;
    white-space: nowrap; margin-left: 0.1rem;
}
.nav-links {
    display: flex; gap: 1.5rem; list-style: none; align-items: center;
}
.nav-links a {
    font-family: var(--mono); font-size: 0.72rem; font-weight: 500;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--ink-soft); text-decoration: none;
    white-space: nowrap; transition: color 0.2s ease;
}
.nav-links a::before {
    content: '/'; color: var(--amber); margin-right: 0.45em;
    opacity: 0; transition: opacity 0.2s ease;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a:hover::before { opacity: 1; }
.nav-links a.active { color: var(--amber-deep); }
.nav-links a.active::before { opacity: 1; }

.lang-switch {
    display: grid;
    grid-template-columns: repeat(4, auto);
    gap: 0.3rem 0.7rem;
    align-items: center; justify-items: start;
    padding-left: 0.7rem; margin-left: 0.2rem;
    border-left: 1px solid var(--line-strong);
}
.lang-switch a {
    font-family: var(--mono); font-size: 0.66rem; font-weight: 600;
    letter-spacing: 0.08em; color: var(--ink-muted);
    text-decoration: none; transition: color 0.2s ease;
}
.lang-switch a::before { content: none; }
.lang-switch a:hover { color: var(--ink); }
.lang-switch a.active { color: var(--amber-deep); }

.nav-cta-btn {
    display: inline-block;
    padding: 0.5rem 1.1rem;
    background: var(--ink); color: var(--paper) !important;
    font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase;
    text-decoration: none; border: none; cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}
.nav-cta-btn:hover { background: var(--amber); color: var(--ink) !important; }
.nav-cta-btn::before { content: none !important; }

.nav-toggle {
    display: none;
    background: none; border: 1px solid var(--line-strong); border-radius: 6px;
    color: var(--ink); font-family: var(--mono); font-size: 0.7rem;
    letter-spacing: 0.1em; padding: 0.5rem 0.8rem; cursor: pointer;
}

/* ---- Section scaffolding ---- */
.page-main { padding-top: 5rem; }

section {
    padding: 7.5rem 5%; max-width: 1280px; margin: 0 auto;
}

.section-header { margin-bottom: 4rem; }

.section-label {
    font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
    letter-spacing: 0.28em; text-transform: uppercase;
    color: var(--amber-deep); display: flex; align-items: center;
    gap: 1rem; margin-bottom: 1.4rem;
}
.section-label::after {
    content: ''; height: 3px; width: 64px; background: var(--ink);
}

.section-title {
    font-family: var(--black); font-weight: 400;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    letter-spacing: -0.01em; line-height: 1.1;
    max-width: 24ch; margin-bottom: 1.1rem; text-transform: uppercase;
}

.section-subtitle {
    color: var(--ink-soft); max-width: 58ch; font-size: 1.02rem;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 0.55rem;
    padding: 0.85rem 1.7rem;
    font-family: var(--mono); font-size: 0.78rem; font-weight: 700;
    letter-spacing: 0.12em; text-transform: uppercase;
    text-decoration: none; border: none; cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.btn-primary {
    background: var(--ink); color: var(--paper);
}
.btn-primary:hover { background: var(--amber); color: var(--ink); transform: translateX(2px); }
.btn-ghost {
    background: transparent; color: var(--ink);
    border: 1px solid var(--line-strong);
}
.btn-ghost:hover { background: var(--ink); color: var(--paper); }

/* ---- Tags ---- */
.tag {
    display: inline-block; font-family: var(--mono);
    font-size: 0.66rem; font-weight: 600; letter-spacing: 0.1em;
    text-transform: uppercase; padding: 0.3rem 0.7rem;
    border: 1px solid var(--line-strong); color: var(--ink-muted);
    border-radius: 3px;
}
.cs-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.5rem 0; }

/* ---- Case-study common ---- */
.cs-tag {
    font-family: var(--mono); font-size: 0.7rem; font-weight: 700;
    letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--amber-deep); margin-bottom: 0.65rem;
}
.cs-step { margin-bottom: 2.2rem; }
.cs-step p { color: var(--ink-soft); font-size: 0.98rem; line-height: 1.7; }
.cs-step p b { color: var(--ink); font-weight: 700; }

.cs-stats {
    display: flex; flex-wrap: wrap; gap: 2rem 3rem;
    padding: 2rem 0; border-top: 1px solid var(--line);
    margin-top: 0.5rem;
}
.cs-stat { display: flex; flex-direction: column; gap: 0.2rem; }
.cs-stat b {
    font-family: var(--black); font-size: 2rem; line-height: 1;
    color: var(--amber-deep); font-weight: 400;
}
.cs-stat span {
    font-family: var(--mono); font-size: 0.68rem; color: var(--ink-muted);
    letter-spacing: 0.08em; text-transform: uppercase;
}

/* ---- Fade-in animation ---- */
.fade-in {
    opacity: 0; transform: translateY(20px);
    transition: opacity 0.55s ease, transform 0.55s ease;
}
.fade-in.visible { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
    .fade-in { opacity: 1; transform: none; transition: none; }
}

/* ---- Always-dark panel ---- */
.dark-panel {
    background: var(--panel-dark-bg);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 4px; overflow: hidden;
}
.dark-panel .panel-bar {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.65rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.03);
}
.panel-dot { width: 9px; height: 9px; border-radius: 50%; }
.panel-dot-r { background: #ff5f57; }
.panel-dot-y { background: #febc2e; }
.panel-dot-g { background: #28c840; }
.panel-bar-title {
    font-family: var(--mono); font-size: 0.65rem;
    color: rgba(255,255,255,0.38); letter-spacing: 0.1em;
    text-transform: uppercase; margin-left: 0.4rem;
}

/* ---- Pulsing dot ---- */
.dot {
    display: inline-block; width: 8px; height: 8px;
    border-radius: 50%; background: var(--amber);
    animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

.live-badge {
    display: inline-flex; align-items: center; gap: 0.4rem;
    font-family: var(--mono); font-size: 0.65rem;
    color: rgba(255,255,255,0.5); letter-spacing: 0.1em;
    text-transform: uppercase;
}
.live-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #22c55e;
    animation: pulse 2s ease-in-out infinite;
}

/* ---- Footer ---- */
footer {
    border-top: 1px solid var(--line);
    padding: 3rem 5%; margin-top: 0;
}
.footer-inner {
    max-width: 1280px; margin: 0 auto;
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 1.5rem;
}
.footer-left { display: flex; flex-direction: column; gap: 0.4rem; }
.footer-copy {
    font-family: var(--mono); font-size: 0.68rem;
    color: var(--ink-muted); letter-spacing: 0.06em;
}
.footer-links {
    display: flex; gap: 1.5rem; list-style: none; flex-wrap: wrap;
}
.footer-links a {
    font-family: var(--mono); font-size: 0.68rem;
    color: var(--ink-muted); text-decoration: none;
    letter-spacing: 0.08em; text-transform: uppercase;
    transition: color 0.2s;
}
.footer-links a:hover { color: var(--ink); }

/* ---- Mobile nav ---- */
@media (max-width: 900px) {
    nav#nav { flex-wrap: wrap; }
    .nav-toggle { display: block; }
    .nav-links {
        display: none; flex-direction: column; align-items: flex-start;
        gap: 0.9rem; width: 100%; padding: 1rem 0 0.5rem;
    }
    .nav-links.open { display: flex; }
    .lang-switch {
        border-left: none; padding-left: 0; margin-left: 0;
        border-top: 1px solid var(--line); padding-top: 0.6rem; width: 100%;
    }
}

@media (max-width: 640px) {
    section { padding: 5rem 5%; }
    .section-title { font-size: clamp(1.5rem, 5vw, 2.2rem); }
}
