/* ================================================================
   mujun.dev — Styles
   Grainy-textured industrial luxe. Chrome-metallic palette.
   Layered-depth layout with paper panels over brushed metal.
   ================================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Palette */
    --void-graphite: #0e0f11;
    --anvil-dark: #1c1e22;
    --gun-metal: #2a2d33;
    --oxidized-chrome: #6b7280;
    --mercury-silver: #c8ccd0;
    --polished-platinum: #e4e7eb;
    --aged-vellum: #ece5d8;
    --foxed-parchment: #d9cdb8;
    --incandescent-amber: #d4853a;
    --ember-glow: #b8692e;

    /* Gradients */
    --chrome-substrate: linear-gradient(135deg, #2a2d33 0%, #1c1e22 40%, #3a3d42 70%, #1c1e22 100%);
    --paper-aging: radial-gradient(ellipse at 30% 20%, rgba(236,229,216,1) 0%, rgba(217,205,184,0.8) 100%);
    --amber-glow: radial-gradient(circle, rgba(212,133,58,0.15) 0%, transparent 70%);

    /* Scroll-driven */
    --scroll-offset: 0;

    /* Typography scale */
    --hero-size: clamp(2.8rem, 7vw, 6rem);
    --section-heading: clamp(1.4rem, 3vw, 2.2rem);
    --body-size: clamp(0.95rem, 1.1vw, 1.1rem);
    --wordmark-size: clamp(1rem, 2vw, 1.3rem);
    --intro-wordmark-size: clamp(1.8rem, 4vw, 3rem);
}

html {
    scroll-behavior: smooth;
    background-color: var(--void-graphite);
}

body {
    font-family: "DM Sans", "Arial", sans-serif;
    font-weight: 400;
    color: var(--void-graphite);
    background-color: var(--void-graphite);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Layer 0: Chrome Substrate --- */
#chrome-substrate {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: var(--chrome-substrate);
    background-size: 200% 200%;
}

#chrome-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 1;
}

/* --- Layer 2: Particle Field --- */
#particle-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    pointer-events: none;
}

/* --- Grain Overlay --- */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 250;
    pointer-events: none;
    opacity: 0;
    mix-blend-mode: overlay;
    /* Grain pattern generated via JS with SVG feTurbulence */
}

/* --- Layer 3: Chrome Interface — Vertical Nav Rail --- */
#nav-rail {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100%;
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-wordmark {
    font-family: "Space Grotesk", "Arial", sans-serif;
    font-weight: 700;
    font-size: 0.6rem;
    letter-spacing: 0.2em;
    color: var(--mercury-silver);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    margin-bottom: auto;
    margin-top: 24px;
}

.nav-indicators {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.nav-dash {
    width: 16px;
    height: 2px;
    background: var(--gun-metal);
    border-radius: 1px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: background 0.3s ease;
}

.nav-dash::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--mercury-silver);
    border-radius: 1px;
    transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-dash.active::after {
    width: 100%;
}

.nav-dash.passed::after {
    width: 100%;
    background: var(--oxidized-chrome);
}

.nav-label {
    font-family: "Space Grotesk", "Arial", sans-serif;
    font-weight: 500;
    font-size: 0.6rem;
    letter-spacing: 0.16em;
    color: var(--oxidized-chrome);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    margin-top: auto;
    margin-bottom: 24px;
}

/* --- Mobile Bottom Nav --- */
#nav-bottom {
    display: none;
}

/* --- Intro Section --- */
#intro {
    position: relative;
    width: 100%;
    height: 100vh;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.intro-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.intro-wordmark {
    font-family: "Space Grotesk", "Arial", sans-serif;
    font-weight: 700;
    font-size: var(--intro-wordmark-size);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--polished-platinum);
    display: inline-flex;
    overflow: hidden;
}

.intro-wordmark .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.intro-rule {
    width: 60vw;
    max-width: 600px;
    height: 1px;
    background: var(--mercury-silver);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.intro-rule.visible {
    transform: scaleX(1);
}

.intro-subtitle {
    font-family: "DM Sans", "Arial", sans-serif;
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--oxidized-chrome);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.intro-subtitle.visible {
    opacity: 1;
}

/* Intro lift animation */
#intro.lifting .intro-content {
    animation: liftIntro 0.8s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

@keyframes liftIntro {
    to {
        transform: translateY(-100vh);
        opacity: 0;
    }
}

/* --- Chrome Gap Between Sections --- */
.chrome-gap {
    position: relative;
    height: 20vh;
    z-index: 1;
}

/* --- Paper Panel (Layer 1) --- */
.paper-panel {
    position: relative;
    z-index: 100;
    margin: 0 6vw;
    padding: 0;
    border-radius: 2px;
    box-shadow: 8px 12px 40px rgba(0,0,0,0.35);
    background: var(--aged-vellum);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
}

.paper-panel:hover {
    box-shadow: 12px 18px 56px rgba(0,0,0,0.45);
}

.paper-texture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    /* Vignette darkening for aged paper */
    background:
        radial-gradient(ellipse at 25% 15%, transparent 40%, rgba(180,165,140,0.12) 100%);
}

.paper-inner {
    position: relative;
    z-index: 2;
    padding: clamp(2rem, 5vw, 4rem);
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

/* --- Section Entry Animations --- */
.content-section {
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease, filter 0.3s ease;
}

.content-section[data-direction="right"] {
    transform: translateX(60px);
}

.content-section[data-direction="left"] {
    transform: translateX(-60px);
}

.content-section[data-direction="below"] {
    transform: translateY(60px);
}

.content-section.in-view {
    opacity: 1;
    transform: translateX(0) translateY(0);
    transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.content-section.retreated {
    transform: translateZ(-40px) scale(0.98);
    filter: blur(2px);
    opacity: 0.7;
}

/* --- Reveal Items --- */
.reveal-item {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

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

/* --- Typography --- */
h2 {
    font-family: "Space Grotesk", "Arial", sans-serif;
    font-weight: 700;
    font-size: var(--section-heading);
    color: var(--void-graphite);
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
}

p {
    font-family: "DM Sans", "Arial", sans-serif;
    font-weight: 400;
    font-size: var(--body-size);
    line-height: 1.72;
    color: var(--void-graphite);
}

.section-lead {
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    color: var(--oxidized-chrome);
    color: #4a4e56;
}

em {
    font-style: italic;
}

blockquote {
    font-family: "DM Sans", "Arial", sans-serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.1rem, 1.4vw, 1.3rem);
    line-height: 1.72;
    color: var(--void-graphite);
    padding-left: 1.5rem;
    border-left: 3px solid var(--oxidized-chrome);
}

code {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: -0.01em;
    background: rgba(28,30,34,0.06);
    padding: 0.15em 0.4em;
    border-radius: 3px;
}

/* --- Code Block --- */
.code-block {
    background: var(--anvil-dark);
    border-radius: 4px;
    padding: 1.5rem;
    overflow-x: auto;
}

.code-block code {
    background: none;
    padding: 0;
    color: var(--mercury-silver);
    font-size: 0.85rem;
    line-height: 1.7;
    display: block;
    white-space: pre;
}

.code-comment {
    color: var(--oxidized-chrome);
}

.code-keyword {
    color: var(--incandescent-amber);
}

.code-fn {
    color: var(--polished-platinum);
}

/* --- Domain Items --- */
.domain-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(42,45,51,0.12);
}

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

.domain-label {
    font-family: "Space Grotesk", "Arial", sans-serif;
    font-weight: 600;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    color: var(--void-graphite);
}

.domain-meta {
    font-family: "DM Sans", "Arial", sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    color: var(--oxidized-chrome);
}

/* --- Signal Entries --- */
.signal-entry {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(42,45,51,0.08);
}

.signal-entry:last-child {
    border-bottom: none;
}

.signal-date {
    flex-shrink: 0;
}

.signal-date code {
    font-size: 0.8rem;
    color: var(--oxidized-chrome);
    background: rgba(28,30,34,0.06);
}

.signal-text {
    font-family: "DM Sans", "Arial", sans-serif;
    font-weight: 400;
    font-size: var(--body-size);
    line-height: 1.6;
    color: var(--void-graphite);
}

/* --- Contact Links --- */
.contact-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.contact-link {
    font-family: "Space Grotesk", "Arial", sans-serif;
    font-weight: 500;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    color: var(--incandescent-amber);
    text-decoration: none;
    position: relative;
    display: inline-block;
    transition: color 0.2s ease;
    background-image: linear-gradient(var(--incandescent-amber), var(--incandescent-amber));
    background-size: 0% 1px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: color 0.2s ease, background-size 0.3s ease;
    padding-bottom: 2px;
}

.contact-link:hover {
    color: var(--ember-glow);
    background-size: 100% 1px;
}

/* --- Footer --- */
#site-footer {
    position: relative;
    z-index: 100;
    padding: 3rem 6vw;
    background: var(--anvil-dark);
}

.footer-inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.footer-mark {
    font-family: "Space Grotesk", "Arial", sans-serif;
    font-weight: 700;
    font-size: var(--wordmark-size);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--mercury-silver);
    border-bottom: 1px solid var(--mercury-silver);
    padding-bottom: 2px;
}

.footer-divider {
    width: 1px;
    height: 16px;
    background: var(--gun-metal);
}

.footer-tagline {
    font-family: "DM Sans", "Arial", sans-serif;
    font-weight: 400;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    color: var(--oxidized-chrome);
}

.footer-year {
    margin-left: auto;
}

.footer-year code {
    font-size: 0.8rem;
    color: var(--oxidized-chrome);
    background: rgba(200,204,208,0.06);
}

/* --- Ripple Container --- */
#ripple-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 350;
    pointer-events: none;
    overflow: hidden;
}

.ripple-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--incandescent-amber);
    opacity: 0.8;
    transform: scale(0);
    pointer-events: none;
    animation: rippleExpand 0.5s ease-out forwards;
}

.ripple-ring.secondary {
    animation: rippleExpandSmall 0.5s ease-out 0.1s forwards;
}

.ripple-ring.chrome-ripple {
    border-color: var(--mercury-silver);
}

@keyframes rippleExpand {
    to {
        transform: scale(1);
        opacity: 0;
    }
}

@keyframes rippleExpandSmall {
    to {
        transform: scale(1);
        opacity: 0;
    }
}

/* --- Chrome Reflection on Interactive Elements --- */
.chrome-reflect {
    background-image: linear-gradient(
        calc(90deg + var(--scroll-offset, 0) * 0.1deg),
        var(--gun-metal) 0%,
        var(--mercury-silver) calc(50% + var(--scroll-offset, 0) * 0.1px),
        var(--gun-metal) 100%
    );
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .content-section {
        opacity: 1;
        transform: none;
    }

    .reveal-item {
        opacity: 1;
        transform: none;
    }

    #grain-overlay {
        opacity: 0.035;
    }

    #intro .intro-wordmark .char {
        opacity: 1;
        transform: none;
    }

    .intro-rule {
        transform: scaleX(1);
    }

    .intro-subtitle {
        opacity: 1;
    }
}

/* --- Responsive: Below 768px --- */
@media (max-width: 768px) {
    #nav-rail {
        display: none;
    }

    #nav-bottom {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 40px;
        z-index: 300;
        background: var(--anvil-dark);
        border-top: 1px solid var(--gun-metal);
        align-items: center;
        justify-content: center;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .nav-bottom-inner {
        display: flex;
        gap: 16px;
        align-items: center;
    }

    #nav-bottom .nav-dash {
        width: 20px;
        height: 2px;
    }

    .paper-panel {
        margin: 0 3vw;
    }

    .paper-inner {
        padding: clamp(1.5rem, 4vw, 2.5rem);
    }

    .chrome-gap {
        height: 12vh;
    }

    .signal-entry {
        flex-direction: column;
        gap: 0.25rem;
    }

    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .footer-year {
        margin-left: 0;
    }

    body {
        padding-bottom: 40px;
    }
}

/* --- Selection --- */
::selection {
    background: rgba(212,133,58,0.25);
    color: var(--void-graphite);
}
