/* ============================================================
   PROJECT GRAVITY — style.css
   Minimal developer-guide theme. Slate + blue, no effects.
   ============================================================ */

/* ---------- Design tokens ---------- */

:root {
    --bg: #050507;
    --surface: #0d0d12;
    --border: #1b1b23;
    --border-strong: #2a2a35;

    --text: #e6e9ef;
    --muted: #8b93a5;
    --dim: #5d6472;

    --accent: #c9cdd6;

    --warning: #8b93a5;
    --error: #c9cdd6;

    --code-bg: #09090d;

    --font-sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    --max-w: 680px;
    --radius: 8px;
}

body.light-mode {
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --text: #0f172a;
    --muted: #526075;
    --dim: #7d8ba1;

    --accent: #475569;

    --warning: #6b7280;
    --error: #374151;

    --code-bg: #f8fafc;
}

/* ---------- Reset ---------- */

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

/* ---------- Base ---------- */

html {
    scroll-behavior: smooth;
    scroll-padding-top: 72px;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color 0.2s ease, color 0.2s ease;
}

::selection {
    background-color: var(--text);
    color: var(--bg);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--text);
    text-decoration: underline;
}

button {
    font-family: inherit;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- Nav ---------- */

.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: var(--bg);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0.9rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

.logo-badge {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 0.08rem 0.35rem;
    border-radius: 999px;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#themeToggleBtn {
    background: none;
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--muted);
    padding: 0.38rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, border-color 0.15s ease;
}

#themeToggleBtn:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

body.dark-mode .sun-icon {
    display: block;
}

body.dark-mode .moon-icon {
    display: none;
}

body.light-mode .sun-icon {
    display: none;
}

body.light-mode .moon-icon {
    display: block;
}

/* ---------- Layout ---------- */

.container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 4.5rem 1.25rem 6rem;
}

/* ---------- Hero ---------- */

.hero {
    min-height: calc(100vh - 57px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 0 7rem;
    border-bottom: 1px solid var(--border);
    position: relative;
    will-change: opacity, transform;
}

.hero-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1.4rem;
}

.hero h1 {
    font-size: clamp(2.6rem, 8vw, 4.6rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.04;
    margin-bottom: 1.5rem;
}

.hero-accent {
    color: var(--accent);
}

.hero-sub {
    font-size: 1.05rem;
    color: var(--muted);
    max-width: 30rem;
}

/* Scroll hint */

.scroll-hint {
    position: absolute;
    bottom: 2.2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.28em;
    color: var(--dim);
    transition: opacity 0.3s ease;
}

.scroll-hint i {
    width: 1px;
    height: 44px;
    background: var(--border-strong);
    position: relative;
    overflow: hidden;
}

.scroll-hint i::after {
    content: "";
    position: absolute;
    left: 0;
    top: -50%;
    width: 1px;
    height: 50%;
    background: var(--text);
    animation: hint-drop 2.2s ease-in-out infinite;
}

@keyframes hint-drop {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(300%);
    }
}

body.faded .scroll-hint {
    opacity: 0;
}

/* ---------- Table of contents ---------- */

.toc {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.6rem;
    padding: 1.4rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4.5rem;
}

.toc a {
    display: inline-flex;
    align-items: baseline;
    gap: 0.45rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--muted);
    transition: color 0.15s ease;
}

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

.toc a span {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--accent);
}

/* ---------- Sections ---------- */

.sec {
    margin-bottom: 4.5rem;
    scroll-margin-top: 72px;
}

.h2-step {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 1.2rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
}

.step-num {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--accent);
}

.sec p {
    font-size: 0.95rem;
    color: var(--muted);
    margin-bottom: 1.25rem;
}

.sec p strong {
    color: var(--text);
    font-weight: 600;
}

.sec code {
    font-family: var(--font-mono);
    font-size: 0.84em;
    background-color: var(--surface);
    border: 1px solid var(--border);
    padding: 0.12rem 0.36rem;
    border-radius: 4px;
    color: var(--accent);
    white-space: nowrap;
}

/* ---------- Note boxes ---------- */

.note-box {
    margin: 1.5rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--surface);
}

.note-box-inline {
    margin-top: 1.2rem;
}

.note-item {
    padding: 1.05rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.note-item:last-child {
    border-bottom: none;
}

.note-item span {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.1em;
    display: block;
    margin-bottom: 0.45rem;
}

.label-warn {
    color: var(--warning);
}

.label-err {
    color: var(--error);
}

.note-item p {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 0;
}

/* ---------- Code boxes ---------- */

.code-box {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--code-bg);
    margin: 1.5rem 0;
    overflow: hidden;
}

.mini-code {
    margin-top: 1rem;
}

.code-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
}

.file-name {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--dim);
}

.copy-btn {
    flex: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 0.22rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-sans);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.copy-btn::before {
    content: "";
    width: 10px;
    height: 10px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4'%3E%3Crect x='9' y='9' width='12' height='12' rx='2'/%3E%3Cpath d='M5 15V5a2 2 0 0 1 2-2h10'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4'%3E%3Crect x='9' y='9' width='12' height='12' rx='2'/%3E%3Cpath d='M5 15V5a2 2 0 0 1 2-2h10'/%3E%3C/svg%3E") center / contain no-repeat;
}

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

.copy-btn.copied {
    color: var(--accent);
    border-color: var(--accent);
}

.copy-btn.copied::before {
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.8'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.8'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.code-box pre {
    padding: 1.25rem 1.4rem;
    overflow-x: auto;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.code-box code {
    background: none;
    border: none;
    padding: 0;
    border-radius: 0;
    font-size: 0.82rem;
    line-height: 1.65;
    color: var(--text);
    white-space: pre;
}

/* Syntax tokens (dark) */
.token.keyword {
    color: #e6e9ef;
}

.token.function {
    color: #c9cdd6;
}

.token.string {
    color: #a8adb8;
}

.token.number {
    color: #c9cdd6;
}

.token.comment {
    color: #5d6472;
    font-style: italic;
}

.token.operator {
    color: #c9cdd6;
}

.token.punctuation {
    color: #8b93a5;
}

.token.boolean {
    color: #c9cdd6;
}

.token.variable {
    color: #e6e9ef;
}

/* Syntax tokens (light) */
body.light-mode .token.keyword {
    color: #0f172a;
}

body.light-mode .token.function {
    color: #334155;
}

body.light-mode .token.string {
    color: #475569;
}

body.light-mode .token.number {
    color: #334155;
}

body.light-mode .token.comment {
    color: #94a3b8;
}

body.light-mode .token.operator {
    color: #334155;
}

body.light-mode .token.punctuation {
    color: #64748b;
}

body.light-mode .token.boolean {
    color: #334155;
}

body.light-mode .token.variable {
    color: #0f172a;
}

/* ---------- Variable reference grid ---------- */

.grid {
    margin: 1.5rem 0;
}

.grid-item {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 1rem;
    padding: 0.85rem 0;
    border-top: 1px solid var(--border);
}

.grid-item:last-child {
    border-bottom: 1px solid var(--border);
}

.grid-term code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--accent);
}

.grid-desc {
    font-size: 0.9rem;
    color: var(--muted);
}

/* ---------- Spec list ---------- */

.spec-list {
    margin: 1.5rem 0;
}

.spec-item {
    padding: 1.35rem 0 1.5rem;
    border-top: 1px solid var(--border);
}

.spec-item:last-child {
    border-bottom: 1px solid var(--border);
}

.spec-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.spec-title {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.95rem;
}

.spec-meta {
    font-family: var(--font-mono);
    font-size: 0.64rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--dim);
}

.spec-item p {
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* ---------- Rules ---------- */

.bullet-rules {
    list-style-type: none;
    margin: 1.5rem 0;
}

.bullet-rules li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.9rem;
    font-size: 0.95rem;
    color: var(--muted);
}

.bullet-rules li strong {
    color: var(--text);
    font-weight: 600;
}

.bullet-rules li::before {
    content: "";
    position: absolute;
    left: 0.2rem;
    top: 0.62rem;
    width: 6px;
    height: 6px;
    background: var(--accent);
}

/* ---------- Footer ---------- */

.footer {
    border-top: 1px solid var(--border);
    padding: 2.2rem 1.25rem 3rem;
}

.footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    justify-content: center;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 0.82rem;
    font-weight: 500;
}

.footer-links a {
    color: var(--muted);
}

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

/* ---------- Scroll reveal (enabled only when JS is present) ---------- */

body.js .reveal {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

body.js .reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Responsive ---------- */

@media (min-width: 640px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .container {
        padding-top: 3rem;
    }

    .hero {
        min-height: calc(100vh - 57px);
        padding: 2rem 0 6rem;
    }

    .grid-item {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }
}

/* ---------- Reduced motion ---------- */

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

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    body.js .reveal {
        opacity: 1;
        transform: none;
    }
}
