/* =============================================
   lupin.day — Surrealist Technical Dossier
   ============================================= */

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
    overflow-x: hidden;
}

body {
    background-color: #F5F0E6;
    color: #4A3F35;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.85;
    overflow-x: hidden;
    /* Grid lines as background pattern */
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent calc(100% / 12 - 1px),
            #D4C5A9 calc(100% / 12 - 1px),
            #D4C5A9 calc(100% / 12),
            transparent calc(100% / 12)
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 99px,
            #D4C5A9 99px,
            #D4C5A9 100px
        );
    background-size: 100% 100px;
    background-position: 60px 0;
}

/* Grid lines should be faint */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent calc((100% - 60px) / 12 - 1px),
            rgba(212, 197, 169, 0.25) calc((100% - 60px) / 12 - 1px),
            rgba(212, 197, 169, 0.25) calc((100% - 60px) / 12),
            transparent calc((100% - 60px) / 12)
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 99px,
            rgba(212, 197, 169, 0.2) 99px,
            rgba(212, 197, 169, 0.2) 100px
        );
    background-position: 60px 0;
    pointer-events: none;
    z-index: 0;
}

/* Remove the body background image, use only the pseudo-element */
body {
    background-image: none;
}

/* ---- Dossier Spine ---- */
.dossier-spine {
    position: fixed;
    left: 0;
    top: 0;
    width: 60px;
    height: 100vh;
    border-right: 1px solid #D4C5A9;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 24px;
    background-color: rgba(245, 240, 230, 0.9);
}

.spine-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 9px;
    color: #9C8B7A;
    letter-spacing: 0.08em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    transition: color 0.4s ease, transform 0.6s ease;
    cursor: default;
    opacity: 0.5;
}

.spine-label.active {
    color: #5C4A3A;
    opacity: 1;
    transform: rotate(180deg) scale(1.1);
}

/* ---- Navigation ---- */
.plate-nav {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 200;
}

.plate-nav-current {
    background: none;
    border: none;
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    color: #5C4A3A;
    letter-spacing: 0.1em;
    cursor: pointer;
    position: relative;
    padding: 4px 0;
    display: block;
}

.nav-underline {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background-color: #5C4A3A;
    transition: width 0.6s ease-out;
}

.plate-nav-current:hover .nav-underline {
    width: 100%;
}

.plate-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(245, 240, 230, 0.96);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    z-index: 199;
}

.plate-nav-overlay.open {
    opacity: 1;
    visibility: visible;
}

.nav-item {
    font-family: 'Share Tech Mono', monospace;
    font-size: 16px;
    color: #5C4A3A;
    text-decoration: none;
    letter-spacing: 0.12em;
    position: relative;
    padding-bottom: 4px;
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background-color: #B8846C;
    transition: width 0.6s ease-out;
}

.nav-item:hover::after {
    width: 100%;
}

/* ---- Plates (sections) ---- */
.plate {
    position: relative;
    min-height: 100vh;
    padding: 80px 80px 80px 100px;
    z-index: 1;
}

.plate:nth-child(even of .plate) {
    background-color: rgba(237, 229, 213, 0.5);
}

/* Plate overlap with diagonal clip */
.plate-02 {
    margin-top: -10vh;
    clip-path: polygon(0 3%, 100% 0%, 100% 100%, 0% 100%);
    padding-top: calc(80px + 3vh);
}

.plate-03 {
    margin-top: -8vh;
    clip-path: polygon(0 0%, 100% 2%, 100% 100%, 0% 100%);
    padding-top: calc(80px + 2vh);
}

.plate-04 {
    margin-top: -12vh;
    clip-path: polygon(0 2.5%, 100% 0%, 100% 100%, 0% 100%);
    padding-top: calc(80px + 2.5vh);
}

.plate-05 {
    margin-top: -10vh;
    clip-path: polygon(0 0%, 100% 3%, 100% 100%, 0% 100%);
    padding-top: calc(80px + 3vh);
}

.plate-06 {
    margin-top: -8vh;
    clip-path: polygon(0 2%, 100% 0%, 100% 100%, 0% 100%);
    padding-top: calc(80px + 2vh);
}

.plate-07 {
    margin-top: -10vh;
    clip-path: polygon(0 0%, 100% 2.5%, 100% 100%, 0% 100%);
    padding-top: calc(80px + 2.5vh);
    background-color: #EDE5D5;
}

/* ---- Classification Stamps ---- */
.stamp {
    position: absolute;
    top: 30px;
    right: 40px;
    border: 1.5px solid #D4C5A9;
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 8px;
    color: #9C8B7A;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    z-index: 5;
}

.stamp-rotate {
    animation: drift 120s linear infinite;
}

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

.stamp-large {
    position: relative;
    top: auto;
    right: auto;
    margin: 0 auto;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    justify-content: center;
    border-width: 2px;
    border-color: #B8846C;
}

.stamp-large .stamp-border {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.stamp-classification {
    font-size: 14px;
    color: #A06B50;
    letter-spacing: 0.2em;
}

/* ---- Plate Headings ---- */
.plate-heading {
    position: relative;
    margin-bottom: 60px;
}

.plate-title {
    font-family: 'Share Tech Mono', monospace;
    font-size: 60px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #5C4A3A;
    line-height: 1.1;
    transform: rotate(-1.5deg);
}

.plate-title br + span,
.plate-title {
    /* Occasional highlighted character effect handled via JS or manual spans */
}

.plate-number {
    font-family: 'Share Tech Mono', monospace;
    font-size: 200px;
    color: rgba(212, 197, 169, 0.25);
    position: absolute;
    right: 0;
    top: -40px;
    letter-spacing: 0.1em;
    z-index: -1;
    font-weight: 400;
}

/* ---- PLATE 01: Cover Sheet ---- */
.plate-01 {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    min-height: 100vh;
    position: relative;
}

.plate-01-content {
    position: absolute;
    left: 35%;
    top: 40%;
    transform: translate(-50%, -50%);
}

.title-main {
    font-family: 'Share Tech Mono', monospace;
    font-size: 80px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #5C4A3A;
    line-height: 1;
    margin-bottom: 20px;
}

.subtitle {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 11px;
    font-weight: 300;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9C8B7A;
}

.lupin-silhouette {
    position: absolute;
    right: 5%;
    top: 10%;
    width: 30%;
    height: 80%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lupin-flower-large {
    width: 100%;
    height: 100%;
}

/* ---- PLATE 02: Specimen Index ---- */
.specimen-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px 30px;
    max-width: 900px;
    margin: 0 auto;
}

.specimen-grid .specimen-item:nth-child(4) {
    grid-column: 1 / 2;
}

.specimen-grid .specimen-item:nth-child(5) {
    grid-column: 2 / 3;
}

.specimen-item {
    text-align: center;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.specimen-item.visible {
    opacity: 1;
}

.specimen-svg {
    width: 160px;
    height: 160px;
    margin-bottom: 12px;
}

.specimen-caption {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: #5C4A3A;
    letter-spacing: 0.05em;
    position: relative;
    display: inline-block;
    padding-bottom: 3px;
}

/* ---- Underline Draw Animation ---- */
.underline-draw::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background-color: #B8846C;
    transition: width 0.6s ease-out;
}

.underline-draw.drawn::after {
    width: 100%;
}

/* ---- PLATE 03: Circuit Analysis ---- */
.circuit-container {
    position: relative;
    width: 70%;
    margin: 0 auto;
    max-width: 800px;
}

.circuit-svg {
    width: 100%;
    height: auto;
}

.draw-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 3s ease-in-out;
}

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

.circuit-annotations {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.annotation {
    position: absolute;
    font-family: 'Josefin Sans', sans-serif;
    font-size: 11px;
    font-weight: 300;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9C8B7A;
    max-width: 220px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.annotation.visible {
    opacity: 0.7;
}

/* ---- PLATE 04: Waveform Data ---- */
.waveform-container {
    max-width: 700px;
    width: 65%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 50px;
    transform: rotate(0.5deg);
}

.waveform-item {
    position: relative;
}

.waveform-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.waveform-freq,
.waveform-amp {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: #9C8B7A;
    letter-spacing: 0.05em;
}

.waveform-svg {
    width: 100%;
    height: 80px;
}

.waveform-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2.5s ease-in-out;
}

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

.waveform-species {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 10px;
    font-weight: 300;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9C8B7A;
    margin-top: 6px;
    text-align: right;
}

.poetic-intrusion {
    font-family: 'Cormorant Garamond', serif;
    font-size: 30px;
    font-weight: 300;
    font-style: italic;
    color: #B8846C;
    margin-top: 60px;
    transform: rotate(-1deg);
    padding-left: 10%;
}

/* ---- PLATE 05: Cross-Reference Table ---- */
.table-container {
    max-width: 850px;
    width: 70%;
    margin: 0 auto;
    overflow: visible;
    transform: rotate(-0.5deg);
}

.dossier-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
}

.dossier-table th,
.dossier-table td {
    border: 1px solid #D4C5A9;
    padding: 10px 14px;
    text-align: left;
    vertical-align: top;
}

.dossier-table th {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9C8B7A;
    border-bottom-width: 2px;
}

.dossier-table td {
    color: #4A3F35;
}

.cell-accent {
    color: #A06B50;
}

/* Dusty rose accent for specific table highlights */
.dossier-table tr:last-child td {
    border-bottom-color: #C49B8A;
}

/* Broken table rows */
.table-break-right {
    transform: translateX(15px);
}

.table-break-left {
    transform: translateX(-12px);
}

.table-row {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.table-row.visible {
    opacity: 1;
}

/* ---- PLATE 06: Field Notes ---- */
.field-notes-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: start;
}

.field-notes-text {
    transform: rotate(0.8deg);
}

.body-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.85;
    color: #4A3F35;
    margin-bottom: 24px;
    text-indent: 2em;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.body-text.visible {
    opacity: 1;
}

.body-text em {
    font-family: 'Cormorant Garamond', serif;
    font-size: 18px;
    font-weight: 300;
    color: #B8846C;
    font-style: italic;
}

.field-notes-illustration {
    position: relative;
    transform: rotate(-1deg);
}

.exploded-diagram {
    width: 100%;
    height: auto;
    max-width: 400px;
}

/* ---- PLATE 07: Appendix ---- */
.plate-07 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.plate-07-content {
    margin-top: 40px;
}

.document-ends {
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    color: #5C4A3A;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 30px;
}

.appendix-note {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 11px;
    font-weight: 300;
    letter-spacing: 0.06em;
    color: #9C8B7A;
    line-height: 2;
    max-width: 500px;
    margin: 0 auto;
}

/* Vortex grid effect */
.vortex-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: -1;
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 49px,
            rgba(212, 197, 169, 0.15) 49px,
            rgba(212, 197, 169, 0.15) 50px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 49px,
            rgba(212, 197, 169, 0.15) 49px,
            rgba(212, 197, 169, 0.15) 50px
        );
    background-size: 50px 50px;
    background-position: center center;
    /* The radial convergence effect is done via a radial gradient mask */
    mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, rgba(0,0,0,1) 0%, rgba(0,0,0,0.6) 40%, rgba(0,0,0,0.2) 70%, rgba(0,0,0,0) 100%);
    -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, rgba(0,0,0,1) 0%, rgba(0,0,0,0.6) 40%, rgba(0,0,0,0.2) 70%, rgba(0,0,0,0) 100%);
}

/* ---- Fade-in utility ---- */
.fade-in {
    opacity: 0;
    transition: opacity 0.8s ease;
}

.fade-in.visible {
    opacity: 1;
}

/* ---- Responsive adjustments ---- */
@media (max-width: 900px) {
    .plate {
        padding: 60px 30px 60px 70px;
    }

    .plate-title {
        font-size: 40px;
    }

    .title-main {
        font-size: 48px;
    }

    .plate-01-content {
        left: 50%;
        top: 35%;
    }

    .lupin-silhouette {
        opacity: 0.2;
        right: 0;
        width: 50%;
    }

    .specimen-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .specimen-grid .specimen-item:nth-child(4),
    .specimen-grid .specimen-item:nth-child(5) {
        grid-column: auto;
    }

    .field-notes-layout {
        grid-template-columns: 1fr;
    }

    .field-notes-illustration {
        order: -1;
        max-width: 300px;
        margin: 0 auto;
    }

    .circuit-container {
        width: 90%;
    }

    .waveform-container {
        width: 85%;
    }

    .table-container {
        width: 90%;
    }

    .plate-number {
        font-size: 100px;
    }

    .poetic-intrusion {
        font-size: 22px;
    }
}

@media (max-width: 600px) {
    .dossier-spine {
        width: 40px;
    }

    .plate {
        padding: 50px 20px 50px 50px;
    }

    .plate-title {
        font-size: 28px;
    }

    .title-main {
        font-size: 36px;
    }

    .specimen-grid {
        grid-template-columns: 1fr;
        max-width: 300px;
    }

    .plate-number {
        font-size: 60px;
        top: -10px;
    }

    .dossier-table {
        font-size: 10px;
    }

    .dossier-table th,
    .dossier-table td {
        padding: 6px 8px;
    }

    .table-break-right {
        transform: translateX(8px);
    }

    .table-break-left {
        transform: translateX(-6px);
    }

    .stamp-large {
        width: 180px;
        height: 180px;
    }
}
