/* ============================================
   COLOR PALETTE - EXACT HEX VALUES
   Compliance text: "IBM Plex Mono" (Google Fonts IntersectionObserver` (threshold: 0.15 IntersectionObserver` most recently fired with `isIntersecting: true`. The counter uses `IBM Plex Mono` at `0.75rem` "Lora" (Google Fonts
   ============================================ */

:root {
    --color-bg-page: #f5efe6;
    --color-bg-card: #faf6ef;
    --color-bg-middle: #f2ead8;
    --color-text-primary: #3d2b1f;
    --color-text-secondary: #5a4535;
    --color-accent-primary: #c8956c;
    --color-accent-secondary: #7a8c6e;
    --color-accent-tertiary: #b87d6b;
    --color-accent-metadata: #a67c52;
    --color-timeline-line: rgba(166, 124, 82, 0.4);

    --bg-warmth: 0%;
    --grain-x: 0px;
    --grain-y: 0px;
}

/* ============================================
   RESET AND BASE STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Lora", serif;
    background-color: color-mix(in srgb, #f5efe6, #efe4cc var(--bg-warmth));
    color: var(--color-text-primary);
    position: relative;
    overflow-x: hidden;
}

/* Grain Overlay - 40% opacity animated texture */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.045;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg width='150' height='150' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' /%3E%3CfeColorMatrix type='saturate' values='0' /%3E%3C/filter%3E%3Crect width='150' height='150' fill='black' filter='url(%23noise)' /%3E%3C/svg%3E");
    background-repeat: repeat;
    transform: translate(var(--grain-x), var(--grain-y));
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h2.specimen-name {
    font-family: "Barlow Condensed", sans-serif;
    font-size: clamp(1.8rem, 4.5vw, 3.6rem);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1.0;
    color: var(--color-text-primary);
    margin-bottom: clamp(1rem, 3vw, 2rem);
}

p {
    font-family: "Lora", serif;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}

p.italic {
    font-style: italic;
}

.specimen-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    color: var(--color-accent-metadata);
    opacity: 0.7;
}

.metadata-item {
    display: inline-block;
}

.metadata-item::before {
    content: '[ ';
}

.metadata-item::after {
    content: ' ]';
}

/* ============================================
   MAIN LAYOUT
   ============================================ */

main {
    position: relative;
    width: 100%;
    max-width: 100%;
    padding: 0;
}

/* Timeline SVG - Progressive Drawing */
.timeline-line {
    position: fixed;
    left: clamp(30px, 30%, 40%);
    top: 0;
    width: 1px;
    height: 100vh;
    z-index: 0;
    transform: translateX(-50%);
}

.timeline-line line {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0.1s linear;
}

/* ============================================
   PARTICLE CANVAS
   ============================================ */

#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* ============================================
   SPECIMEN ENTRIES
   ============================================ */

.specimen-entry {
    position: relative;
    margin: clamp(6rem, 12vh, 10rem) 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 0 clamp(1.5rem, 4vw, 3rem);
    z-index: 2;
}

@media (min-width: 769px) {
    .specimen-entry {
        grid-template-columns: 30% 1fr;
        align-items: center;
    }

    .specimen-entry:nth-child(even) {
        direction: rtl;
    }

    .specimen-entry:nth-child(even) > * {
        direction: ltr;
    }
}

/* ============================================
   TIMELINE CONNECTOR
   ============================================ */

.timeline-connector {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

@media (max-width: 768px) {
    .timeline-connector {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        width: 12%;
    }
}

.connector-line {
    width: 32px;
    height: 1px;
    background-color: var(--color-timeline-line);
    position: relative;
    transform-origin: left center;
    transform: scaleX(0);
}

@keyframes connector-draw {
    to {
        transform: scaleX(1);
    }
}

.timeline-node {
    width: 8px;
    height: 8px;
    background-color: var(--color-accent-primary);
    border-radius: 50%;
    position: absolute;
    right: -4px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    box-shadow: 0 0 0 2px var(--color-bg-page);
}

@keyframes node-scale {
    to {
        transform: translateY(-50%) scale(1);
    }
}

.timeline-node.pulse {
    animation: node-pulse 1s ease-in-out infinite;
}

@keyframes node-pulse {
    0%, 100% {
        box-shadow: 0 0 0 2px var(--color-bg-page),
                    0 0 6px 0 rgba(200, 149, 108, 0.3);
    }
    50% {
        box-shadow: 0 0 0 2px var(--color-bg-page),
                    0 0 12px 0 rgba(200, 149, 108, 0.6);
    }
}

/* ============================================
   SPECIMEN CARD
   ============================================ */

.specimen-card {
    background-color: var(--color-bg-card);
    border: 1px solid rgba(166, 124, 82, 0.15);
    padding: clamp(1.5rem, 4vw, 3rem);
    position: relative;
    opacity: 0;
    transform: translateY(24px);
    overflow: hidden;
    background-image: url("data:image/svg+xml,%3Csvg width='150' height='150' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='paper'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.58' numOctaves='3' /%3E%3CfeColorMatrix type='saturate' values='0' /%3E%3C/filter%3E%3Crect width='150' height='150' fill='%23a67c52' filter='url(%23paper)' opacity='0.09' /%3E%3C/svg%3E");
    background-blend-mode: multiply;
}

@keyframes card-fade-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Botanical Decoration Background Pattern */
.botanical-decoration {
    position: absolute;
    top: -10%;
    right: -10%;
    width: 40%;
    height: 40%;
    opacity: 0.08;
    pointer-events: none;
}

.botanical-decoration::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 1px solid var(--color-accent-secondary);
    border-left-color: transparent;
    border-bottom-color: transparent;
    border-radius: 50%;
    transform: rotate(var(--rotation));
    transition: transform 2s ease-in-out;
}

@keyframes decoration-rotate {
    from {
        transform: rotate(var(--rotation));
    }
    to {
        transform: rotate(calc(var(--rotation) + 15deg));
    }
}

.botanical-decoration::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: conic-gradient(from 0deg at 50% 50%,
                                var(--color-accent-secondary) 0deg,
                                transparent 60deg,
                                transparent 120deg,
                                var(--color-accent-secondary) 180deg,
                                transparent 240deg,
                                transparent 300deg);
    opacity: 0.6;
    transform: rotate(calc(0deg - var(--rotation)));
    transition: transform 2s ease-in-out;
}

/* ============================================
   SPECIMEN COUNTER (Fixed Position)
   ============================================ */

.specimen-counter {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--color-accent-metadata);
    z-index: 1000;
    user-select: none;
}

.counter-number {
    display: inline-block;
    min-width: 1.5em;
    text-align: right;
    animation: counter-slide-down 0.2s ease-out;
}

.counter-divider {
    margin: 0 0.25em;
    opacity: 0.6;
}

.counter-total {
    display: inline-block;
    min-width: 1.5em;
    text-align: left;
}

@keyframes counter-slide-down {
    from {
        opacity: 0;
        transform: translateY(-1em);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes counter-slide-up {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(1em);
    }
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE
   ============================================ */

@media (max-width: 768px) {
    main {
        padding: 2rem 0;
    }

    .specimen-entry {
        padding-left: clamp(4rem, 18%, 6rem);
        margin-left: 0;
    }

    .timeline-line {
        left: 12%;
    }

    .specimen-counter {
        bottom: 1rem;
        right: 1rem;
        font-size: 0.65rem;
    }
}

/* ============================================
   INTERSECTION OBSERVER INITIAL STATE
   ============================================ */

.specimen-entry {
    --entry-opacity: 0;
}

.specimen-entry.in-view .timeline-node {
    animation: node-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.specimen-entry.in-view .connector-line {
    animation: connector-draw 0.3s ease-in-out 0.1s forwards;
}

.specimen-entry.in-view .specimen-card {
    animation: card-fade-in 0.6s ease-out 0.2s forwards;
}

.specimen-entry.in-view .botanical-decoration::before {
    transform: rotate(calc(var(--rotation) + 15deg));
}

.specimen-entry.in-view .botanical-decoration::after {
    transform: rotate(calc(0deg - var(--rotation) - 15deg));
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    body::before {
        display: none;
    }

    #particle-canvas {
        display: none;
    }

    .specimen-counter {
        display: none;
    }

    .timeline-line {
        position: static;
        height: auto;
        width: auto;
        border-left: 1px solid var(--color-timeline-line);
        padding-left: 2rem;
        margin-left: 2rem;
    }
}
