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

html {
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    color: #3d3225;
    background: #fdf6ec;
    line-height: 1.7;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
}

/* === Typography === */
h1, h2, h3 {
    font-family: 'Baloo 2', cursive;
    font-weight: 700;
    color: #264653;
    letter-spacing: -0.02em;
}

.section-heading {
    font-size: clamp(2rem, 4.5vw, 3.6rem);
    margin-bottom: 1rem;
}
.section-heading.accent { color: #e76f51; }

/* === Tray System === */
.tray {
    min-height: 100vh;
    scroll-snap-align: start;
    position: relative;
    padding: 12px;
    padding-right: 76px; /* margin almanac space */
}

/* === Title Tray === */
.tray-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding-right: 12px;
}

.duotone-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #264653 0%, #2a9d8f 30%, #f4a261 70%, #e76f51 100%);
    filter: saturate(1.2) contrast(0.95);
    z-index: 0;
}

.title-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.site-title {
    font-family: 'Baloo 2', cursive;
    font-size: clamp(4rem, 10vw, 8rem);
    color: #fdf6ec;
    text-shadow: 0 2px 20px rgba(38,70,83,0.4);
    line-height: 1.1;
}

.tagline {
    font-family: 'Nunito', sans-serif;
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    color: #e9c46a;
    margin-top: 0.5rem;
}

.scroll-chevron {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    animation: float 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(8px); }
}

/* === Bento Grid === */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto;
    gap: 12px;
    height: calc(100vh - 24px);
}

/* Tray 1 layout */
.tray1-grid .cell-large { grid-column: 1 / 8; grid-row: 1 / 4; }
.tray1-grid .cell-medium { grid-column: 8 / 13; grid-row: 1 / 3; }
.tray1-grid .cell-index:nth-child(3) { grid-column: 8 / 10; grid-row: 3 / 4; }
.tray1-grid .cell-index:nth-child(4) { grid-column: 10 / 13; grid-row: 3 / 4; }
.tray1-grid .cell-empty { grid-column: 1 / 4; grid-row: 4 / 5; }
.tray1-grid .cell-small { grid-column: 4 / 13; grid-row: 4 / 5; }

/* Tray 2 layout */
.tray2-grid .cell-medium { grid-column: 1 / 7; grid-row: 1 / 3; }
.tray2-grid .cell-tall { grid-column: 7 / 13; grid-row: 1 / 4; }
.tray2-grid .cell-index:nth-child(3) { grid-column: 1 / 4; grid-row: 3 / 4; }
.tray2-grid .cell-index:nth-child(4) { grid-column: 4 / 7; grid-row: 3 / 4; }
.tray2-grid .cell-empty { grid-column: 1 / 5; grid-row: 4 / 5; }
.tray2-grid .cell-small { grid-column: 5 / 13; grid-row: 4 / 5; }

/* Tray 3 layout */
.tray3-grid .cell-wide { grid-column: 1 / 8; grid-row: 1 / 3; }
.tray3-grid .cell-medium { grid-column: 8 / 13; grid-row: 1 / 3; }
.tray3-grid .cell-index:nth-child(3) { grid-column: 1 / 4; grid-row: 3 / 4; }
.tray3-grid .cell-index:nth-child(4) { grid-column: 4 / 7; grid-row: 3 / 4; }
.tray3-grid .cell-small { grid-column: 7 / 13; grid-row: 3 / 4; }

/* === Cell Base === */
.cell {
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    transition: transform 300ms ease-out, box-shadow 300ms ease-out;
    /* Stagger entrance initial state */
    opacity: 0;
    transform: translateY(24px) scale(0.97);
}

.cell.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.cell:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(61,50,37,0.12);
}

/* === Specimen Cell === */
.cell-specimen {
    background: #264653;
}

.duotone-image {
    position: absolute;
    inset: 0;
    filter: saturate(1.2) contrast(0.95);
}

.specimen-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50%;
    min-width: 200px;
    padding: 1.5rem;
    background: rgba(38,70,83,0.75);
    backdrop-filter: blur(4px);
    border-radius: 0 16px 0 16px;
}

.specimen-label {
    border: 1px solid #a57d60;
    padding: 0.75rem;
    position: relative;
}
.specimen-label::before {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1px solid #a57d60;
    pointer-events: none;
}

.label-title {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fdf6ec;
    display: block;
}
.label-rule {
    border: none;
    border-top: 1px solid #a57d60;
    margin: 0.4rem 0;
}
.label-meta {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    color: #a57d60;
    display: block;
}

/* Registration marks */
.reg-mark {
    position: absolute;
    z-index: 2;
    opacity: 0.6;
}
.reg-mark.top-left { top: 8px; left: 8px; }
.reg-mark.top-right { top: 8px; right: 8px; }
.reg-mark.bottom-left { bottom: 8px; left: 8px; }
.reg-mark.bottom-right { bottom: 8px; right: 8px; }

/* === Text Cell === */
.cell-text {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.bg-amber { background: #f4a261; }
.bg-cream { background: #fdf6ec; }
.bg-teal { background: #264653; }
.bg-amber-light { background: #e9c46a; }

.light-text { color: #fdf6ec; }

.halftone {
    background-image: radial-gradient(circle, #a57d60 0.8px, transparent 0.8px);
    background-size: 8px 8px;
}
.halftone.bg-cream {
    background-color: #fdf6ec;
    background-image: radial-gradient(circle, rgba(165,125,96,0.06) 0.8px, transparent 0.8px);
    background-size: 8px 8px;
}

/* === Index Card Cell === */
.cell-index {
    background: #fff8f0;
    box-shadow: 2px 3px 0 #d4a574;
    border-top: 4px solid #264653;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-radius: 8px;
    animation: borderShift 8s linear infinite;
}

.cell-index.card-0 { animation-delay: 0s; }
.cell-index.card-1 { animation-delay: 1.5s; }
.cell-index.card-2 { animation-delay: 3s; }
.cell-index.card-3 { animation-delay: 4.5s; }
.cell-index.card-4 { animation-delay: 6s; }
.cell-index.card-5 { animation-delay: 7.5s; }

.cell-index:hover {
    animation-play-state: paused;
    border-top-color: #e76f51;
}

@keyframes borderShift {
    0%   { border-top-color: #264653; }
    20%  { border-top-color: #2a9d8f; }
    40%  { border-top-color: #e9c46a; }
    60%  { border-top-color: #f4a261; }
    80%  { border-top-color: #e76f51; }
    100% { border-top-color: #264653; }
}

.index-label {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.65rem, 1vw, 0.8rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #a57d60;
}
.index-rule {
    border: none;
    border-top: 1px solid #d4a574;
    margin: 0.3rem 0;
}
.index-value {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    letter-spacing: 0.04em;
    color: #264653;
    font-weight: 400;
}

/* === Empty Cell === */
.cell-empty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lupine-watermark {
    opacity: 0.1;
}

/* === Margin Almanac === */
.margin-almanac {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 64px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(253,246,236,0.7);
    backdrop-filter: blur(2px);
}

.margin-text {
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.04em;
    color: #a57d60;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    position: absolute;
    transition: opacity 200ms ease;
    opacity: 0;
}
.margin-text.active { opacity: 1; }

/* === Sunset Tray === */
.tray-sunset {
    background: linear-gradient(180deg, #264653 0%, #2a9d8f 25%, #e9c46a 50%, #f4a261 75%, #e76f51 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-right: 12px;
    overflow: hidden;
}

.sunset-content {
    text-align: center;
    z-index: 1;
    max-width: 700px;
    padding: 2rem;
}

.sunset-quote {
    font-family: 'Baloo 2', cursive;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    color: #fff8f0;
    line-height: 1.3;
    margin-bottom: 1.5rem;
}

.sunset-credit {
    font-family: 'Nunito', sans-serif;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    color: rgba(255,248,240,0.7);
}

.sunset-lupine {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    opacity: 0.15;
    animation: slowSpin 120s linear infinite;
}

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

/* === Signature Gradient Rule (below headings) === */
.section-heading::after {
    content: '';
    display: block;
    height: 3px;
    margin-top: 0.5rem;
    background: linear-gradient(90deg, #264653, #2a9d8f, #e9c46a, #f4a261, #e76f51);
    border-radius: 2px;
}

/* === Mobile === */
@media (max-width: 768px) {
    .tray { padding-right: 12px; }
    .margin-almanac { display: none; }

    .bento-grid {
        display: flex;
        flex-direction: column;
        gap: 12px;
        height: auto;
        min-height: 100vh;
    }

    .cell-specimen,
    .cell-text,
    .cell-index,
    .cell-empty {
        min-height: 200px;
    }

    .cell-specimen { min-height: 300px; }
    .specimen-overlay { width: 80%; }
}
