/* ==========================================================================
   BASE STYLES, TYPOGRAPHY, SCROLLBARS, MARGINALIA RULER & KEYFRAMES
   ========================================================================== */

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

html {
    scroll-behavior: smooth;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-elev);
    border-left: 1px solid var(--border-color);
}

::-webkit-scrollbar-thumb {
    background: var(--ink);
    border: 2px solid var(--bg-elev);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

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

body {
    background-color: var(--bg);
    background-image:
        linear-gradient(to right, var(--grid-major) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-major) 1px, transparent 1px),
        linear-gradient(to right, var(--grid-fine) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-fine) 1px, transparent 1px);
    background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
    background-position: -1px -1px;
    color: var(--ink);
    font-family: var(--font-sans);
    line-height: 1.55;
    overflow-x: clip;
    transition: background-color 0.22s ease, color 0.22s ease;
    position: relative;
}

/* Subtle top archival spotlight */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background: radial-gradient(920px 440px at 14% 0%, var(--accent-soft), transparent 72%);
}

/* Architectural marginalia drafting rail on wide viewports */
@media (min-width: 1360px) {
    body::after {
        content: "";
        position: fixed;
        top: 0;
        bottom: 0;
        left: 14px;
        width: 10px;
        pointer-events: none;
        z-index: 40;
        background-image: repeating-linear-gradient(
            to bottom,
            var(--hairline-strong) 0 1px,
            transparent 1px 16px,
            var(--hairline) 16px 17px,
            transparent 17px 32px
        );
        opacity: 0.72;
    }
}

body.tab-hidden *,
body.tab-hidden {
    animation-play-state: paused !important;
}

body.modal-open {
    overflow: hidden;
}

code,
pre,
.mono {
    font-family: var(--font-mono);
}

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

button,
input,
textarea {
    font: inherit;
    color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ZERO-SHIFT SCRAMBLE LAYER */
.scramble {
    position: relative;
    display: inline-block;
    vertical-align: top;
    max-width: 100%;
}

.scramble-ghost {
    display: block;
    visibility: hidden;
    pointer-events: none;
    user-select: none;
}

.scramble-live {
    position: absolute;
    inset: 0;
    display: block;
    overflow: hidden;
    pointer-events: none;
}

.hero h1 .scramble-ghost,
.hero h1 .scramble-live,
.brand .scramble-ghost,
.brand .scramble-live {
    white-space: nowrap;
}

/* REVEALS & 3D TILT */
.reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.55s var(--ease-snappy), transform 0.55s var(--ease-snappy);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.stagger-item {
    opacity: 0;
    transform: translateY(16px);
    transition:
        opacity 0.45s var(--ease-snappy),
        transform 0.45s var(--ease-snappy),
        box-shadow 0.16s ease,
        border-color 0.16s ease;
}

.reveal.visible .stagger-item {
    opacity: 1;
    transform: translateY(0);
}

.tilt-card {
    position: relative;
    transform-style: preserve-3d;
    will-change: transform;
}

.tilt-card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.16), transparent 54%);
    transition: opacity 0.22s ease;
}

[data-theme="dark"] .tilt-card::after {
    background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.08), transparent 54%);
}

.tilt-card:hover::after {
    opacity: 1;
}

/* SHARED BUTTON SYSTEM */
.btn {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.73rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.52rem 0.88rem;
    background: var(--surface);
    color: var(--ink);
    border: var(--border);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    transition:
        transform 0.12s var(--ease-snappy),
        box-shadow 0.12s ease,
        background-color 0.12s ease,
        color 0.12s ease,
        border-color 0.12s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.36rem;
    line-height: 1.2;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--border-color);
}

.btn:active {
    transform: translate(2px, 2px) !important;
    box-shadow: var(--shadow-active);
}

.btn-accent {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--border-color);
}

.btn-accent:hover {
    background: var(--ink);
    color: var(--bg);
}

.btn-sm {
    font-size: 0.68rem;
    padding: 0.34rem 0.62rem;
    box-shadow: 2px 2px 0px var(--shadow-color);
}

.btn.is-on {
    background: var(--ink);
    color: var(--bg);
}

/* KEYFRAMES */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.38;
        transform: scale(0.8);
    }
}

@keyframes caretBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

@keyframes badgePop {
    0% { transform: scale(1); }
    45% { transform: scale(1.16); }
    100% { transform: scale(1); }
}

@keyframes floatY {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}

@keyframes stampRock {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

@keyframes lineSlide {
    from {
        opacity: 0;
        transform: translateX(-5px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes dashFlow {
    to { stroke-dashoffset: -24; }
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cardFlash {
    0%, 40% {
        outline: 4px solid var(--accent);
        outline-offset: 4px;
    }
    100% {
        outline: 0 solid transparent;
        outline-offset: 0;
    }
}

@keyframes floatPop {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.9);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -145%) scale(1.1);
    }
}

@keyframes eqBounce {
    0%, 100% { transform: scaleY(0.32); }
    50% { transform: scaleY(1); }
}
