/* ============================================
   op9.rs -- Botanical Herbarium Stylesheet
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --burgundy: #3A0820;
    --gold: #C8A048;
    --parchment: #F0E8D0;
    --violet: #7848A0;
    --sage: #608858;
    --brown: #8A6840;
    --maroon: #200010;

    --font-display: 'Poiret One', cursive;
    --font-body: 'Cormorant Garamond', serif;

    --column-width: 720px;
    --section-gap: 72px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--burgundy);
    color: var(--parchment);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(15px, 1vw, 17px);
    line-height: 1.85;
    overflow-x: hidden;
}

/* --- Paper Texture (Global) --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* ============================================
   HERBARIUM COVER
   ============================================ */
#herbarium-cover {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--burgundy);
    overflow: hidden;
}

.cover-border {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    bottom: 16px;
    border: 2px solid var(--gold);
    pointer-events: none;
    opacity: 0;
    animation: borderFadeIn 1000ms 400ms ease-out forwards;
}

.cover-border::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    border: 1px solid var(--gold);
    opacity: 0.4;
}

.cover-border::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 1px solid var(--gold);
    opacity: 0.2;
}

.paper-texture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    animation: textureFadeIn 300ms ease-out forwards;
    background: repeating-conic-gradient(
        var(--maroon) 0% 25%,
        transparent 0% 50%
    ) 0 0 / 3px 3px;
    mix-blend-mode: overlay;
    pointer-events: none;
}

.cover-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
}

.cover-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(42px, 6vw, 80px);
    letter-spacing: 0.06em;
    color: var(--parchment);
    opacity: 0;
    animation: titleFadeIn 800ms 200ms ease-out forwards;
    text-align: center;
}

.cover-subtitle {
    position: absolute;
    bottom: -48px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-body);
    font-style: italic;
    font-size: 14px;
    letter-spacing: 0.04em;
    color: var(--brown);
    white-space: nowrap;
    opacity: 0;
    animation: titleFadeIn 800ms 600ms ease-out forwards;
}

.crystal-left,
.crystal-right {
    width: 80px;
    height: 140px;
    opacity: 0;
    animation: crystalDraw 1200ms 300ms ease-out forwards;
}

.crystal-left {
    transform: scaleX(-1);
}

.crystal-left polygon,
.crystal-left line,
.crystal-right polygon,
.crystal-right line {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    animation: strokeDraw 1200ms 400ms ease-out forwards;
}

/* Scroll indicator */
.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0;
    animation: titleFadeIn 800ms 1200ms ease-out forwards;
}

.scroll-label {
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
}

.scroll-arrow {
    width: 24px;
    height: 24px;
    animation: bounceArrow 2s ease-in-out infinite;
}

/* ============================================
   CRYSTALLINE DIVIDERS
   ============================================ */
.crystal-divider {
    display: flex;
    justify-content: center;
    padding: 20px 0;
    margin: var(--section-gap) auto 0;
    max-width: var(--column-width);
}

.crystal-divider svg {
    width: 100%;
    max-width: 500px;
    height: 40px;
    overflow: visible;
}

.crystal-divider polygon,
.crystal-divider line {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1200ms ease-out;
}

.crystal-divider.in-view polygon,
.crystal-divider.in-view line {
    stroke-dashoffset: 0;
}

/* ============================================
   SPECIMEN PAGES
   ============================================ */
.specimen-page {
    max-width: var(--column-width);
    margin: var(--section-gap) auto 0;
    padding: 0 20px;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 500ms cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.specimen-page.in-view {
    opacity: 1;
    transform: translateY(0);
}

.specimen-border {
    border: 2px solid var(--gold);
    padding: 3px;
    background: linear-gradient(135deg, rgba(200, 160, 72, 0.05), transparent);
    transition: border-color 400ms ease, box-shadow 400ms ease;
}

.specimen-border::before {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.specimen-page:hover .specimen-border {
    border-color: #D4B060;
    box-shadow: 0 0 20px rgba(200, 160, 72, 0.15);
}

.specimen-inner {
    border: 1px solid rgba(200, 160, 72, 0.3);
    padding: 40px;
    position: relative;
    background-color: rgba(58, 8, 32, 0.6);
}

/* Art-deco corner accents */
.specimen-inner::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    width: 30px;
    height: 30px;
    border-top: 2px solid var(--gold);
    border-left: 2px solid var(--gold);
}

.specimen-inner::after {
    content: '';
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border-bottom: 2px solid var(--gold);
    border-right: 2px solid var(--gold);
}

.specimen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(200, 160, 72, 0.3);
}

.specimen-label {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gold);
}

.specimen-catalog {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 12px;
    color: var(--brown);
    letter-spacing: 0.04em;
}

.specimen-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(28px, 3.5vw, 56px);
    letter-spacing: 0.06em;
    color: var(--parchment);
    margin-bottom: 28px;
}

.specimen-body {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.specimen-text {
    flex: 1;
}

.specimen-text p {
    margin-bottom: 16px;
    color: var(--parchment);
}

.specimen-text p em {
    font-style: italic;
    color: var(--gold);
}

.specimen-illustration {
    flex: 0 0 180px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 10px;
    border-left: 1px solid rgba(200, 160, 72, 0.2);
}

.specimen-illustration svg {
    width: 160px;
    height: auto;
}

.specimen-notes {
    margin-top: 24px;
    padding-top: 16px;
}

.ruled-line {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--brown), transparent);
    margin-bottom: 12px;
}

.note-text {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 14px;
    color: var(--brown);
    line-height: 1.7;
}

/* Staggered content fade-in */
.specimen-page.in-view .specimen-header {
    animation: contentFadeIn 400ms ease-out forwards;
    animation-delay: 100ms;
    opacity: 0;
}

.specimen-page.in-view .specimen-title {
    animation: contentFadeIn 400ms ease-out forwards;
    animation-delay: 200ms;
    opacity: 0;
}

.specimen-page.in-view .specimen-body {
    animation: contentFadeIn 400ms ease-out forwards;
    animation-delay: 300ms;
    opacity: 0;
}

.specimen-page.in-view .specimen-notes {
    animation: contentFadeIn 400ms ease-out forwards;
    animation-delay: 400ms;
    opacity: 0;
}

/* Hover: slight letter-spacing increase on body text */
.specimen-page:hover .specimen-text p {
    letter-spacing: 0.01em;
    transition: letter-spacing 200ms ease;
}

/* ============================================
   APPENDIX (FOOTER)
   ============================================ */
#appendix {
    max-width: var(--column-width);
    margin: var(--section-gap) auto 0;
    padding: 0 20px 60px;
}

.appendix-border {
    border: 2px solid var(--gold);
    padding: 3px;
}

.appendix-inner {
    border: 1px solid rgba(200, 160, 72, 0.3);
    padding: 48px 40px;
    position: relative;
    background-color: rgba(32, 0, 16, 0.4);
}

/* Art-deco top ornament */
.appendix-inner::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: var(--gold);
}

.appendix-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(28px, 3.5vw, 44px);
    letter-spacing: 0.06em;
    color: var(--parchment);
    text-align: center;
    margin-bottom: 36px;
}

.appendix-content {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.appendix-section {
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(200, 160, 72, 0.15);
}

.appendix-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.appendix-heading {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gold);
    margin-bottom: 12px;
}

.appendix-text {
    color: var(--parchment);
    font-size: 15px;
}

.appendix-text em {
    color: var(--gold);
}

.appendix-list {
    list-style: none;
    padding: 0;
}

.appendix-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    color: var(--parchment);
    font-size: 15px;
}

.crystal-bullet {
    display: inline-block;
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    position: relative;
}

.crystal-bullet::before {
    content: '';
    position: absolute;
    top: 0;
    left: 2px;
    width: 6px;
    height: 10px;
    border: 1px solid var(--violet);
    transform: rotate(45deg);
}

.appendix-colophon {
    margin-top: 36px;
    padding-top: 20px;
    border-top: 1px solid rgba(200, 160, 72, 0.3);
    text-align: center;
}

.appendix-colophon p {
    font-family: var(--font-display);
    font-size: 14px;
    letter-spacing: 0.08em;
    color: var(--brown);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes textureFadeIn {
    from { opacity: 0; }
    to { opacity: 0.08; }
}

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

/* Override for subtitle which already has translateX */
.cover-subtitle {
    animation-name: subtitleFadeIn;
}

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

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

@keyframes crystalDraw {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Crystal left needs to keep scaleX(-1) */
.crystal-left {
    animation-name: crystalDrawLeft;
}

@keyframes crystalDrawLeft {
    from {
        opacity: 0;
        transform: scaleX(-1) scale(0.9);
    }
    to {
        opacity: 1;
        transform: scaleX(-1) scale(1);
    }
}

@keyframes strokeDraw {
    from { stroke-dashoffset: 300; }
    to { stroke-dashoffset: 0; }
}

@keyframes bounceArrow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

@keyframes contentFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .cover-content {
        flex-direction: column;
        gap: 20px;
    }

    .crystal-left,
    .crystal-right {
        width: 60px;
        height: 100px;
    }

    .cover-subtitle {
        position: relative;
        bottom: auto;
        left: auto;
        transform: none;
        text-align: center;
        margin-top: 16px;
        animation-name: subtitleFadeIn;
    }

    .specimen-body {
        flex-direction: column;
    }

    .specimen-illustration {
        flex: 0 0 auto;
        border-left: none;
        border-top: 1px solid rgba(200, 160, 72, 0.2);
        padding-top: 20px;
        justify-content: center;
    }

    .specimen-inner {
        padding: 24px;
    }

    .specimen-border {
        position: relative;
    }

    .cover-border {
        top: 8px;
        left: 8px;
        right: 8px;
        bottom: 8px;
    }
}

@media (max-width: 480px) {
    .crystal-left,
    .crystal-right {
        display: none;
    }

    .specimen-inner {
        padding: 16px;
    }

    .appendix-inner {
        padding: 24px 16px;
    }
}
