:root {
    --felt: #3a3028;
    --case-interior: #f8f4ec;
    --index-card: #f5f0e8;
    --frame-border: #c4b8a0;
    --pin-copper: #9a7a58;
    --ink-sepia: #4a3a28;
    --specimen-accent: #6a8a7a;
    --stain-wash: #c4a878;
}

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

body {
    background-color: var(--felt);
    color: var(--ink-sepia);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    line-height: 1.8;
    overflow-x: hidden;
}

/* Felt texture */
.felt-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.04;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23f)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

/* Sections */
.section {
    position: relative;
    z-index: 1;
    padding: 80px 40px;
}

/* Typography */
.handwritten {
    font-family: 'Caveat', cursive;
    font-weight: 400;
}

.taxonomy-name {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    color: var(--ink-sepia);
    margin-bottom: 8px;
    line-height: 1.2;
}

.taxonomy-latin {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(1rem, 1.4vw, 1.2rem);
    color: var(--specimen-accent);
    margin-bottom: 16px;
}

.specimen-description {
    color: var(--ink-sepia);
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    line-height: 1.8;
}

.catalog-number {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--pin-copper);
    position: absolute;
    top: 12px;
    right: 16px;
    z-index: 3;
}

/* Index Card */
.section-index {
    min-height: 60vh;
    display: flex;
    align-items: center;
    padding-left: 20%;
}

.index-card {
    width: 300px;
    height: 200px;
    background-color: var(--index-card);
    border: 1px solid var(--frame-border);
    border-radius: 4px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    opacity: 0;
    transform: translateY(20px);
    animation: card-entrance 1.2s ease-out forwards;
}

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

.card-catalog {
    font-size: 0.85rem;
    color: var(--pin-copper);
    margin-bottom: 8px;
}

.card-title {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    color: var(--ink-sepia);
    margin-bottom: 8px;
}

.card-date {
    font-size: 0.8rem;
    color: var(--frame-border);
}

/* Vitrines */
.vitrine {
    background-color: var(--case-interior);
    border: 1px solid var(--frame-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 40px;
    position: relative;
    /* Ruled lines inside */
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 31px,
        rgba(196, 184, 160, 0.08) 31px,
        rgba(196, 184, 160, 0.08) 32px
    );
}

.vitrine-wide {
    min-height: 350px;
}

.vitrine-tall {
    min-height: 500px;
}

.vitrine-narrow {
    min-height: 300px;
}

.vitrine-grid {
    display: grid;
    gap: 30px;
    align-items: center;
}

.specimen-left {
    grid-template-columns: 55% 1fr;
}

.specimen-right {
    grid-template-columns: 1fr 55%;
}

.specimen-bottom {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
}

.specimen-top {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
}

.label-right {
    text-align: right;
}

.label-minimal {
    text-align: center;
    padding: 16px 0;
}

/* Specimen zone */
.specimen-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.specimen-svg {
    width: 100%;
    max-width: 200px;
    height: auto;
}

.waveform {
    max-width: 180px;
}

/* Pin */
.pin {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--pin-copper);
    position: relative;
    margin-bottom: 12px;
    align-self: center;
}

.pin::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: 1px;
    height: 1px;
    border-radius: 50%;
    background-color: var(--case-interior);
}

/* Stitch lines */
.stitch-line {
    position: absolute;
    border: none;
}

.stitch-bottom {
    bottom: 0;
    left: 20px;
    right: 20px;
    height: 0;
    border-bottom: 2px dashed var(--pin-copper);
}

.stitch-left {
    top: 20px;
    bottom: 20px;
    left: 0;
    width: 0;
    border-left: 2px dashed var(--pin-copper);
}

.stitch-right {
    top: 20px;
    bottom: 20px;
    right: 0;
    width: 0;
    border-right: 2px dashed var(--pin-copper);
}

/* Vitrine IV: Damaged */
.vitrine-damaged {
    border-top-right-radius: 0;
    border-image: none;
}

.vitrine-damaged::before {
    content: '';
    position: absolute;
    top: -1px;
    right: -1px;
    width: 40px;
    height: 40px;
    background-color: var(--felt);
    z-index: 2;
}

.coffee-stain {
    position: absolute;
    top: 30%;
    right: 20%;
    width: 120px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(196, 168, 120, 0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
}

/* Error specimen */
.error-specimen {
    background: var(--case-interior);
    border: 1px solid var(--frame-border);
    padding: 20px;
    max-width: 280px;
}

.error-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--ink-sepia);
    margin-bottom: 8px;
}

.error-message {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--ink-sepia);
}

/* Delay bar */
.delay-bar-track {
    width: 160px;
    height: 4px;
    background-color: var(--frame-border);
    border-radius: 2px;
    overflow: hidden;
}

.delay-bar-fill {
    width: 0%;
    height: 100%;
    background-color: var(--specimen-accent);
    border-radius: 2px;
    animation: delay-progress 8s cubic-bezier(0.25, 0.1, 0.25, 1) infinite;
}

@keyframes delay-progress {
    0% { width: 0%; }
    55% { width: 60%; }
    72% { width: 60%; }
    100% { width: 100%; }
}

/* Felt spacer */
.felt-spacer {
    height: 80vh;
    position: relative;
    z-index: 1;
}

/* The Drawer */
.section-drawer {
    padding-bottom: 120px;
}

.specimen-drawer {
    background-color: var(--case-interior);
    border: 1px solid var(--frame-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 30px 40px;
    max-width: 700px;
    margin: 0 auto;
}

.drawer-items {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.drawer-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.drawer-pin {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--pin-copper);
}

.drawer-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--ink-sepia);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.drawer-catalog {
    font-size: 0.85rem;
    color: var(--pin-copper);
    text-align: center;
}

/* Mobile */
@media (max-width: 768px) {
    .section {
        padding: 40px 20px;
    }

    .section-index {
        padding-left: 10%;
    }

    .vitrine {
        width: 90% !important;
        margin: 0 auto !important;
        padding: 24px;
    }

    .vitrine-grid {
        grid-template-columns: 1fr !important;
    }

    .label-right {
        text-align: left;
    }

    .felt-spacer {
        height: 40vh;
    }

    .index-card {
        width: 260px;
        height: 180px;
    }

    .specimen-drawer {
        max-width: 95%;
    }

    .drawer-items {
        flex-wrap: wrap;
        gap: 16px;
        justify-content: center;
    }
}
