/* ============================================
   p9r.dev - Precision Engineering Aesthetic
   Gold-Black Monochromatic / Circuit Trace Motifs
   Zero chromatic color. Zero gradients. Zero rounded corners.
   ============================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: #0A0A0A;
    color: #B8B0A0;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Noise Texture Overlay --- */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    mix-blend-mode: overlay;
}

/* --- Typography --- */
.vertical-headline,
.showcase-title,
.close-monogram {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: #C9A84C;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sub-headline {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 500;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.04em;
    color: #D4C5A0;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.body-text {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.75;
    color: #B8B0A0;
    margin-bottom: 1.25rem;
}

.mono-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.8rem;
    color: #6B6354;
    border-bottom: 1px solid #2A2520;
    display: inline-block;
    padding-bottom: 2px;
    margin-bottom: 0.5rem;
}

/* --- Gold Underline Animation --- */
.gold-underline {
    position: relative;
    display: inline;
}

.gold-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: #C9A84C;
    transition: width 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.gold-underline.revealed::after {
    width: 100%;
}

/* --- Corner Brackets --- */
.corner-bracket {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: #8B7535;
    border-style: solid;
    border-width: 0;
    z-index: 2;
    transition: border-color 400ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.corner-tl {
    top: 12px;
    left: 12px;
    border-top-width: 2px;
    border-left-width: 2px;
}

.corner-tr {
    top: 12px;
    right: 12px;
    border-top-width: 2px;
    border-right-width: 2px;
}

.corner-bl {
    bottom: 12px;
    left: 12px;
    border-bottom-width: 2px;
    border-left-width: 2px;
}

.corner-br {
    bottom: 12px;
    right: 12px;
    border-bottom-width: 2px;
    border-right-width: 2px;
}

/* Corner bracket hover brightening on parent */
.module:hover .corner-bracket,
.showcase-block:hover .corner-bracket {
    border-color: #C9A84C;
}

/* --- Module Base --- */
.module {
    position: relative;
    width: 100%;
    overflow: hidden;
    border: 1px solid transparent;
}

.module.border-flash {
    animation: borderPulse 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0) forwards;
}

@keyframes borderPulse {
    0% { border-color: #2A2520; }
    40% { border-color: #FFD700; }
    100% { border-color: #8B7535; }
}

/* --- Module 0: Hero --- */
.module-hero {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #0A0A0A;
}

.hero-border-frame {
    position: absolute;
    top: 24px;
    left: 24px;
    right: 24px;
    bottom: 24px;
    border: 1px solid #C9A84C;
    opacity: 0;
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    width: 80%;
    max-width: 720px;
}

.hero-logo {
    width: 100%;
    height: auto;
    overflow: visible;
}

/* Letter trace paths - circuit-trace style lettering */
.letter-trace {
    fill: none;
    stroke: #C9A84C;
    stroke-width: 2;
    stroke-linecap: square;
    stroke-linejoin: miter;
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
}

.letter-dot {
    fill: #C9A84C;
    opacity: 0;
}

.connector-trace {
    fill: none;
    stroke: #8B7535;
    stroke-width: 1;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
}

.via-point {
    fill: #C9A84C;
    opacity: 0;
}

/* Hero background traces */
.hero-bg-traces {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.hero-bg-trace {
    fill: none;
    stroke: #8B7535;
    stroke-width: 0.5;
    opacity: 0.15;
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
}

.hero-bg-via {
    fill: #C9A84C;
    opacity: 0;
}

.hero-chevron {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    animation: breathe 3s ease-in-out infinite;
    opacity: 0;
}

@keyframes breathe {
    0%, 100% { transform: translateX(-50%) scale(1.0); }
    50% { transform: translateX(-50%) scale(1.05); }
}

/* --- Junction Blocks --- */
.junction-block {
    position: relative;
    height: 8vh;
    min-height: 50px;
    background-color: #050505;
    overflow: hidden;
    border-top: 1px solid #2A2520;
    border-bottom: 1px solid #2A2520;
}

.junction-svg {
    width: 100%;
    height: 100%;
}

.junction-trace {
    fill: none;
    stroke: #8B7535;
    stroke-width: 1.5;
    stroke-dasharray: 2400;
    stroke-dashoffset: 2400;
}

.junction-trace.animated {
    animation: traceFlow 10s linear infinite;
}

@keyframes traceFlow {
    0% { stroke-dashoffset: 2400; }
    50% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -2400; }
}

.junction-via {
    fill: #C9A84C;
    opacity: 0.6;
}

/* Pad Array Background Pattern */
.junction-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, #C9A84C 0.5px, transparent 0.5px);
    background-size: 12px 12px;
    opacity: 0.04;
    pointer-events: none;
}

/* Gold Particles */
.gold-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.gold-particle {
    position: absolute;
    width: 1px;
    height: 1px;
    background-color: #FFD700;
    opacity: 0;
    bottom: 0;
}

@keyframes particleRise {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(-80px) translateX(20px);
        opacity: 0;
    }
}

/* --- Module 1: Statement --- */
.module-statement {
    min-height: 100vh;
    background-color: #141210;
    padding: 80px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid #2A2520;
}

.module-grid {
    display: grid;
    grid-template-columns: 1fr auto 1.618fr;
    gap: 40px;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.statement-left {
    display: flex;
    align-items: center;
    justify-content: center;
}

.vertical-headline {
    writing-mode: vertical-rl;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.12em;
    line-height: 1;
    text-orientation: mixed;
}

.statement-trace {
    display: flex;
    align-items: center;
    justify-content: center;
}

.vertical-trace {
    width: 20px;
    height: 400px;
}

.trace-line {
    fill: none;
    stroke: #C9A84C;
    stroke-width: 1;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
}

.trace-via {
    fill: #C9A84C;
    opacity: 0;
}

.pad-element {
    fill: #C9A84C;
    opacity: 0;
}

.statement-right {
    padding: 20px 0;
}

.measurement-annotation {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

.annotation-right {
    justify-content: flex-end;
}

.annotation-bottom {
    justify-content: center;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.dimension-line-h {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dim-cap {
    display: inline-block;
    width: 1px;
    height: 10px;
    background-color: #6B6354;
}

.dim-line {
    display: inline-block;
    width: 40px;
    height: 1px;
    background-color: #6B6354;
    opacity: 0.5;
}

.dimension-line {
    width: 300px;
    height: 20px;
}

/* --- Module 2: Showcase --- */
.module-showcase {
    min-height: 140vh;
    background-color: #0A0A0A;
    padding: 100px 48px;
    position: relative;
}

.showcase-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 48px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.showcase-block {
    position: relative;
    background-color: #141210;
    border: 1px solid #2A2520;
    padding: 48px 36px;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 1200ms cubic-bezier(0.25, 0.1, 0.25, 1.0),
                transform 1200ms cubic-bezier(0.25, 0.1, 0.25, 1.0),
                border-color 400ms cubic-bezier(0.25, 0.1, 0.25, 1.0),
                box-shadow 400ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.showcase-block.revealed {
    opacity: 1;
    transform: translateY(0);
}

.showcase-block:hover {
    border-color: #C9A84C;
    box-shadow: 0 0 20px rgba(201, 168, 76, 0.15);
}

/* Staggered diagonal arrangement */
.block-1 {
    margin-top: 0;
}

.block-2 {
    margin-top: 120px;
}

.block-3 {
    margin-top: 240px;
}

/* Per-block noise texture variants */
.block-noise {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    mix-blend-mode: overlay;
}

.noise-dense {
    opacity: 0.04;
}

.noise-medium {
    opacity: 0.03;
}

.noise-fine {
    opacity: 0.02;
}

.showcase-title {
    font-size: clamp(1.4rem, 3vw, 2rem);
    margin-bottom: 1.5rem;
    letter-spacing: 0.12em;
    position: relative;
    z-index: 1;
}

.showcase-block .body-text {
    position: relative;
    z-index: 1;
}

.showcase-block .mono-label {
    display: block;
    margin-top: 1.5rem;
    position: relative;
    z-index: 1;
}

.showcase-traces {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.4;
}

.showcase-trace-path {
    fill: none;
    stroke: #8B7535;
    stroke-width: 1;
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
}

.showcase-trace-path.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 2000ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

/* --- Module 3: Detail --- */
.module-detail {
    min-height: 100vh;
    background-color: #141210;
    padding: 100px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.detail-border {
    position: absolute;
    top: 40px;
    left: 40px;
    right: 40px;
    bottom: 40px;
    border: 1px solid #C9A84C;
    opacity: 0;
    transition: opacity 1500ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.detail-border.visible {
    opacity: 1;
}

.detail-layout {
    display: grid;
    grid-template-columns: 120px 1fr 120px;
    gap: 60px;
    max-width: 1000px;
    width: 100%;
    align-items: start;
    position: relative;
    z-index: 2;
}

.detail-meta-left,
.detail-meta-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 8px;
}

.detail-meta-right {
    text-align: right;
}

.detail-meta-right .mono-label {
    margin-left: auto;
}

.detail-content {
    padding: 0 20px;
}

/* --- Module 4: Close --- */
.module-close {
    min-height: 100vh;
    background-color: #050505;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.converging-traces {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 800px;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.converge-path {
    fill: none;
    stroke: #8B7535;
    stroke-width: 1;
    stroke-dasharray: 1600;
    stroke-dashoffset: 1600;
    transition: stroke-dashoffset 2000ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.converge-path.drawn {
    stroke-dashoffset: 0;
}

.converge-via {
    fill: #C9A84C;
    opacity: 0;
    transition: opacity 600ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.converge-via.visible {
    opacity: 0.6;
}

.converge-center {
    fill: #FFD700;
    opacity: 0;
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0) 1800ms;
}

.converge-center.visible {
    opacity: 1;
}

/* White Gold highlight - rare emphasis / active states (#F5ECDA) */
.converge-center.visible {
    fill: #F5ECDA;
}

.converge-center-ring {
    fill: none;
    stroke: #FFD700;
    stroke-width: 1;
    opacity: 0;
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0) 2000ms;
}

.converge-center-ring.visible {
    opacity: 0.4;
}

.close-content {
    position: relative;
    z-index: 2;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1500ms cubic-bezier(0.25, 0.1, 0.25, 1.0),
                transform 1500ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.close-content.revealed {
    opacity: 1;
    transform: translateY(0);
}

.close-monogram {
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: 0.2em;
    margin-bottom: 1rem;
}

.close-dot-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 1.5rem;
}

.close-dot {
    display: inline-block;
    width: 4px;
    height: 4px;
    background-color: #C9A84C;
}

.close-line {
    display: inline-block;
    width: 60px;
    height: 1px;
    background-color: #8B7535;
}

.close-statement {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 500;
    font-size: clamp(1rem, 2vw, 1.4rem);
    letter-spacing: 0.04em;
    color: #D4C5A0;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .module-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .statement-left {
        order: -1;
    }

    .vertical-headline {
        writing-mode: horizontal-tb;
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .statement-trace {
        display: none;
    }

    .showcase-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .block-1, .block-2, .block-3 {
        margin-top: 0;
    }

    .detail-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .detail-meta-left,
    .detail-meta-right {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 16px;
    }

    .detail-meta-right {
        text-align: left;
    }

    .detail-meta-right .mono-label {
        margin-left: 0;
    }

    .module-statement,
    .module-showcase,
    .module-detail {
        padding: 60px 24px;
    }

    .hero-border-frame {
        top: 12px;
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .corner-bracket {
        width: 14px;
        height: 14px;
    }

    .converging-traces {
        width: 100%;
    }

    .detail-border {
        top: 20px;
        left: 20px;
        right: 20px;
        bottom: 20px;
    }

    .showcase-traces {
        display: none;
    }

    .hero-bg-traces {
        display: none;
    }
}

@media (max-width: 480px) {
    .showcase-title {
        font-size: 1.2rem;
    }

    .close-monogram {
        font-size: 2.5rem;
    }

    .module-showcase {
        min-height: auto;
        padding: 40px 16px;
    }

    .module-detail {
        padding: 40px 16px;
    }
}
