/* ============================================
   prototypic.dev — Victorian Patent Office
   ============================================ */

/* CSS Custom Properties */
:root {
    --parchment-base: #f5eed6;
    --ink-dark: #2a2118;
    --brass: #b8943e;
    --walnut: #5c3d2e;
    --candlelight: #e8c36a;
    --blueprint: #8ab4c7;
    --wax-red: #a04030;
    --wax-dark: #7a2820;
    --soot: #3d3832;
    --era1-bg: #f5eed6;
    --era2-bg: #f0e5c8;
    --era3-bg: #e8dbb8;
    --era4-bg: #ddd0a8;
    --era5-bg: #d4c498;
    --elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-out-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --spine-offset: 60px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.78;
    color: var(--ink-dark);
    background-color: var(--parchment-base);
    overflow-x: hidden;
}

/* Hidden SVG Definitions */
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Paper Grain Overlay */
.paper-grain-overlay {
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Ccircle cx='23' cy='14' r='0.6' fill='%232a2118' opacity='0.03'/%3E%3Ccircle cx='78' cy='42' r='0.4' fill='%232a2118' opacity='0.04'/%3E%3Ccircle cx='145' cy='28' r='0.5' fill='%232a2118' opacity='0.025'/%3E%3Ccircle cx='12' cy='89' r='0.7' fill='%232a2118' opacity='0.035'/%3E%3Ccircle cx='167' cy='73' r='0.3' fill='%232a2118' opacity='0.04'/%3E%3Ccircle cx='56' cy='112' r='0.5' fill='%232a2118' opacity='0.03'/%3E%3Ccircle cx='134' cy='98' r='0.6' fill='%232a2118' opacity='0.025'/%3E%3Ccircle cx='89' cy='156' r='0.4' fill='%232a2118' opacity='0.04'/%3E%3Ccircle cx='34' cy='178' r='0.5' fill='%232a2118' opacity='0.03'/%3E%3Ccircle cx='178' cy='145' r='0.7' fill='%232a2118' opacity='0.035'/%3E%3Ccircle cx='112' cy='189' r='0.3' fill='%232a2118' opacity='0.04'/%3E%3Ccircle cx='67' cy='67' r='0.5' fill='%232a2118' opacity='0.03'/%3E%3Ccircle cx='190' cy='190' r='0.4' fill='%232a2118' opacity='0.025'/%3E%3Ccircle cx='45' cy='134' r='0.6' fill='%232a2118' opacity='0.035'/%3E%3Ccircle cx='156' cy='56' r='0.5' fill='%232a2118' opacity='0.03'/%3E%3C/svg%3E") repeat;
    pointer-events: none;
    z-index: 1;
}

/* Era Background Overlay (vignetting) */
.era-bg-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(42, 33, 24, 0.08) 100%);
    pointer-events: none;
    z-index: 1;
}

/* ============================================
   Timeline Spine
   ============================================ */
.timeline-spine {
    position: fixed;
    left: var(--spine-offset);
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        var(--brass) 10%,
        var(--brass) 90%,
        transparent 100%
    );
    z-index: 100;
    opacity: 0.7;
}

.timeline-spine::before {
    content: '';
    position: absolute;
    top: 0;
    left: -2px;
    width: 6px;
    height: 100%;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(184, 148, 62, 0.15) 10%,
        rgba(184, 148, 62, 0.15) 90%,
        transparent 100%
    );
}

/* ============================================
   Era Sections
   ============================================ */
.era {
    position: relative;
    min-height: 100vh;
    padding: 80px 20px 80px calc(var(--spine-offset) + 40px);
    overflow: hidden;
}

.era-1 { background-color: var(--era1-bg); }
.era-2 { background-color: var(--era2-bg); }
.era-3 { background-color: var(--era3-bg); }
.era-4 { background-color: var(--era4-bg); }
.era-5 { background-color: var(--era5-bg); }

/* Wave-form background texture */
.era-2::before,
.era-3::before,
.era-4::before,
.era-5::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 40px,
        rgba(184, 148, 62, 0.04) 40px,
        rgba(184, 148, 62, 0.04) 41px
    );
    pointer-events: none;
    z-index: 0;
}

.era-content {
    position: relative;
    z-index: 2;
    max-width: 1100px;
}

/* ============================================
   ERA I — Conception
   ============================================ */
.era-1-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 80vh;
    padding-left: 60px;
}

.domain-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(2.4rem, 6vw, 4.8rem);
    color: var(--ink-dark);
    letter-spacing: 0.02em;
    margin-bottom: 40px;
}

.domain-title .letter {
    display: inline-block;
    opacity: 0;
    transform: scale(0);
    animation: letterElastic 0.6s var(--elastic) forwards;
}

@keyframes letterElastic {
    0% {
        opacity: 0;
        transform: scale(0) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.wave-form-container {
    width: 100%;
    max-width: 800px;
    margin-bottom: 40px;
}

.wave-form-container canvas {
    width: 100%;
    height: 120px;
    display: block;
}

.conception-quote {
    max-width: 520px;
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 0.85rem;
    color: var(--walnut);
    line-height: 1.8;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeSlideUp 0.8s var(--ease-out-smooth) 1.5s forwards;
}

@keyframes fadeSlideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Wax Seals
   ============================================ */
.wax-seal {
    width: 80px;
    height: 80px;
    margin: 30px 0;
    filter: drop-shadow(2px 3px 4px rgba(42, 33, 24, 0.3));
}

.wax-seal .seal-svg {
    width: 80px;
    height: 80px;
}

.wax-seal .seal-gradient-defs {
    position: absolute;
    width: 0;
    height: 0;
}

.wax-seal-right {
    position: absolute;
    right: 15%;
    top: 40px;
}

.wax-seal-left {
    position: absolute;
    left: calc(var(--spine-offset) + 20px);
    top: 40px;
}

.wax-seal-center {
    margin: 20px auto;
    display: block;
}

.wax-seal-cracked .seal-svg {
    filter: contrast(1.1);
}

/* ============================================
   Era Headers
   ============================================ */
.era-header {
    margin-bottom: 60px;
    padding-top: 20px;
}

.era-header-left {
    text-align: left;
    padding-left: 20px;
}

.era-header-right {
    text-align: right;
    padding-right: 20px;
    margin-left: auto;
    max-width: 600px;
}

.era-header-center {
    text-align: center;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.era-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(2.4rem, 6vw, 4.8rem);
    color: var(--ink-dark);
    line-height: 1.2;
    margin-bottom: 8px;
}

.era-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 3vw, 2rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--walnut);
    margin-bottom: 6px;
}

.era-label {
    display: block;
}

/* Annotation text */
.annotation {
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 0.85rem;
    color: var(--soot);
    opacity: 0.75;
}

/* ============================================
   Patent Cards
   ============================================ */
.patent-card {
    position: relative;
    background: linear-gradient(135deg, rgba(245, 238, 214, 0.9), rgba(240, 229, 200, 0.95));
    border: 2px solid var(--walnut);
    border-radius: 2px;
    padding: 32px 28px;
    margin: 30px 0;
    max-width: 55%;
    box-shadow:
        3px 4px 12px rgba(42, 33, 24, 0.15),
        1px 1px 3px rgba(42, 33, 24, 0.1);
}

.patent-card::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(92, 61, 46, 0.3);
    border-radius: 1px;
    pointer-events: none;
}

.patent-card-right {
    margin-left: auto;
    margin-right: 5%;
}

.patent-card-left {
    margin-left: 5%;
    margin-right: auto;
}

.patent-card-legacy {
    max-width: 65%;
    margin-left: auto;
    margin-right: auto;
    border-width: 3px;
    padding: 40px 36px;
}

.patent-card-testing {
    border-style: dashed;
}

/* Card rotations */
.card-rotate-1 { transform: rotate(0.8deg); }
.card-rotate-neg1 { transform: rotate(-1deg); }
.card-rotate-05 { transform: rotate(0.5deg); }

/* Card overlaps for Era III */
.card-overlap-2 {
    margin-top: -20px;
    z-index: 2;
}

.card-overlap-3 {
    margin-top: -15px;
    z-index: 3;
}

/* Card corners — ornamental brackets */
.card-corner {
    position: absolute;
    width: 16px;
    height: 16px;
}

.card-corner::before,
.card-corner::after {
    content: '';
    position: absolute;
    background: var(--brass);
}

.card-corner-tl {
    top: -2px;
    left: -2px;
}
.card-corner-tl::before {
    top: 0;
    left: 0;
    width: 16px;
    height: 2px;
}
.card-corner-tl::after {
    top: 0;
    left: 0;
    width: 2px;
    height: 16px;
}

.card-corner-tr {
    top: -2px;
    right: -2px;
}
.card-corner-tr::before {
    top: 0;
    right: 0;
    width: 16px;
    height: 2px;
}
.card-corner-tr::after {
    top: 0;
    right: 0;
    width: 2px;
    height: 16px;
}

.card-corner-bl {
    bottom: -2px;
    left: -2px;
}
.card-corner-bl::before {
    bottom: 0;
    left: 0;
    width: 16px;
    height: 2px;
}
.card-corner-bl::after {
    bottom: 0;
    left: 0;
    width: 2px;
    height: 16px;
}

.card-corner-br {
    bottom: -2px;
    right: -2px;
}
.card-corner-br::before {
    bottom: 0;
    right: 0;
    width: 16px;
    height: 2px;
}
.card-corner-br::after {
    bottom: 0;
    right: 0;
    width: 2px;
    height: 16px;
}

/* Ornate corners for Legacy card */
.card-corner-ornate {
    width: 24px;
    height: 24px;
}

.card-corner-ornate::before {
    width: 24px;
}

.card-corner-ornate::after {
    height: 24px;
}

/* Card filigree border for Legacy */
.card-filigree-border {
    position: absolute;
    inset: 8px;
    border: 1px solid var(--brass);
    border-radius: 1px;
    pointer-events: none;
    opacity: 0.6;
}

.card-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    color: var(--ink-dark);
    margin-bottom: 16px;
    letter-spacing: 0.04em;
}

.card-title-legacy {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    text-align: center;
}

.card-body {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.05rem);
    line-height: 1.78;
    color: var(--ink-dark);
    margin-bottom: 16px;
}

.card-body:last-of-type {
    margin-bottom: 12px;
}

.card-date {
    display: block;
    text-align: right;
    margin-top: 12px;
}

/* ============================================
   Scroll Reveal Animation
   ============================================ */
.scroll-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s var(--ease-out-smooth), transform 0.8s var(--ease-out-smooth);
}

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

/* Preserve card rotations when revealed */
.card-rotate-1.scroll-reveal.revealed { transform: rotate(0.8deg); }
.card-rotate-neg1.scroll-reveal.revealed { transform: rotate(-1deg); }
.card-rotate-05.scroll-reveal.revealed { transform: rotate(0.5deg); }

/* ============================================
   Timeline Nodes & Gears
   ============================================ */
.timeline-node {
    position: absolute;
    left: calc(var(--spine-offset) - 18px);
    top: 80px;
    width: 40px;
    height: 40px;
    z-index: 10;
}

.gear-icon {
    width: 40px;
    height: 40px;
}

.gear-large {
    width: 50px;
    height: 50px;
}

.gear-spin {
    transform-origin: 20px 20px;
    animation: gearRotate 30s linear infinite;
}

.gear-spin-reverse {
    animation: gearRotateReverse 25s linear infinite;
}

@keyframes gearRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes gearRotateReverse {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}

/* ============================================
   Filigree Connectors
   ============================================ */
.filigree-connector {
    width: 200px;
    height: 100px;
    position: relative;
    margin: 10px 0;
}

.filigree-left {
    margin-left: 0;
}

.filigree-right {
    margin-left: auto;
}

.filigree-path {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 1.5s var(--ease-out-smooth);
}

.filigree-connector.drawn .filigree-path {
    stroke-dashoffset: 0;
}

/* ============================================
   Ink Splatters
   ============================================ */
.ink-splatter {
    position: absolute;
    pointer-events: none;
    z-index: 3;
}

.ink-splatter-1 {
    width: 50px;
    height: 50px;
    right: 20%;
    bottom: 25%;
}

.ink-splatter-2 {
    width: 60px;
    height: 60px;
    left: 15%;
    bottom: 20%;
}

.ink-splatter-3 {
    width: 40px;
    height: 40px;
    right: 30%;
    top: 40%;
}

/* ============================================
   Section Dividers
   ============================================ */
.section-divider {
    position: relative;
    width: 100%;
    height: 60px;
    z-index: 5;
    overflow: visible;
}

.divider-svg {
    width: 100%;
    height: 60px;
    display: block;
}

.divider-wave {
    animation: waveShift 8s ease-in-out infinite alternate;
}

.divider-wave:nth-child(2) {
    animation-delay: -2s;
}

.divider-wave:nth-child(3) {
    animation-delay: -4s;
}

@keyframes waveShift {
    0% { transform: translateX(0); }
    100% { transform: translateX(10px); }
}

/* ============================================
   Oscilloscope (Era IV)
   ============================================ */
.oscilloscope-container {
    position: relative;
    max-width: 700px;
    margin: 30px auto 40px;
    padding: 12px;
    border: 2px solid var(--walnut);
    border-radius: 2px;
    background: rgba(42, 33, 24, 0.04);
}

.oscilloscope-container canvas {
    width: 100%;
    height: 200px;
    display: block;
}

.oscilloscope-label {
    display: block;
    text-align: center;
    margin-top: 8px;
}

/* ============================================
   Crosshatch Background (Era III)
   ============================================ */
.crosshatch-bg {
    position: absolute;
    top: 30%;
    left: 10%;
    width: 300px;
    height: 300px;
    opacity: 0.08;
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   Timeline Finial (Era V)
   ============================================ */
.timeline-finial {
    width: 40px;
    margin: 60px 0 20px calc(var(--spine-offset) - 38px);
    position: relative;
    z-index: 10;
}

.finial-svg {
    width: 40px;
    height: 80px;
    display: block;
}

/* ============================================
   Final Wave Container
   ============================================ */
.final-wave-container {
    width: 100%;
    max-width: 800px;
    margin: 40px auto 0;
}

.final-wave-container canvas {
    width: 100%;
    height: 100px;
    display: block;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    :root {
        --spine-offset: 30px;
    }

    .era {
        padding: 60px 15px 60px calc(var(--spine-offset) + 25px);
    }

    .era-1-content {
        padding-left: 20px;
    }

    .patent-card {
        max-width: 85%;
    }

    .patent-card-right {
        margin-right: 2%;
    }

    .patent-card-left {
        margin-left: 2%;
    }

    .patent-card-legacy {
        max-width: 90%;
    }

    .wax-seal-right {
        right: 5%;
    }

    .era-header-right {
        padding-right: 10px;
    }

    .oscilloscope-container {
        max-width: 100%;
    }

    .timeline-node {
        left: calc(var(--spine-offset) - 15px);
    }

    .timeline-finial {
        margin-left: calc(var(--spine-offset) - 20px);
    }
}

@media (max-width: 480px) {
    .patent-card {
        max-width: 95%;
        padding: 24px 20px;
    }

    .domain-title {
        font-size: clamp(1.8rem, 8vw, 3rem);
    }

    .wax-seal-right,
    .wax-seal-left {
        position: relative;
        right: auto;
        left: auto;
        top: auto;
    }
}
