/* tanso.day - Sepia-toned geological chronicle */
/* Palette: #F5F0E8 #FFFAF0 #BF6A30 #D4C5A0 #C9A84C #8D6E63 #8B7355 #4E342E #5D4037 #3E2723 #D7CCC8 #2C2C2C */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #F5F0E8;
    color: #2C2C2C;
    overflow-x: hidden;
    line-height: 1.6;
}

/* === Parchment Texture (CSS-only foxing) === */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background-image:
        radial-gradient(ellipse at 15% 25%, rgba(191, 106, 48, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 60%, rgba(141, 110, 99, 0.05) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 90%, rgba(212, 197, 160, 0.06) 0%, transparent 45%),
        radial-gradient(circle at 30% 70%, rgba(78, 52, 46, 0.03) 0%, transparent 30%);
}

/* === Epoch Progress Bar === */
#epoch-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(212, 197, 160, 0.4);
    z-index: 9999;
}

#epoch-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #8D6E63, #BF6A30, #C9A84C);
    transition: width 0.15s ease-out;
}

#epoch-label {
    position: fixed;
    top: 10px;
    right: 20px;
    font-family: 'Caveat', cursive;
    font-size: 0.95rem;
    color: #8D6E63;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 9999;
}

#epoch-label.visible {
    opacity: 1;
}

/* === Typography === */
.title-engraved {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #3E2723;
    text-shadow: 1px 1px 0 #D7CCC8, 2px 2px 0 rgba(0, 0, 0, 0.05);
    text-align: center;
}

.title-engraved .char {
    display: inline-block;
    opacity: 0;
    animation: engrave 0.3s ease forwards;
}

@keyframes engrave {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.epoch-heading {
    font-family: 'Lora', serif;
    font-weight: 600;
    font-size: clamp(1.8rem, 4vw, 3rem);
    color: #4E342E;
    margin-bottom: 0.5rem;
    letter-spacing: 0.02em;
}

.epoch-subtitle {
    font-family: 'Caveat', cursive;
    font-size: 1.3rem;
    color: #8D6E63;
    margin-bottom: 2rem;
    font-style: italic;
}

.body-text {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    color: #2C2C2C;
    line-height: 1.85;
    margin-bottom: 1.5rem;
    text-align: justify;
    hyphens: auto;
}

.caveat-text {
    font-family: 'Caveat', cursive;
}

.subtitle {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    color: #8B7355;
    text-align: center;
    margin-top: 1rem;
    opacity: 0;
    transition: opacity 1s ease 2s;
}

.subtitle.visible {
    opacity: 1;
}

/* === Chapter Layout === */
.chapter {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4rem 2rem;
}

/* === Title Plate === */
#title-plate {
    background: #FFFAF0;
    transition: background-color 2s ease;
}

#title-plate.settled {
    background-color: #F5F0E8;
}

.parchment-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(191, 106, 48, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 75% 30%, rgba(201, 168, 76, 0.04) 0%, transparent 40%);
    pointer-events: none;
}

#carbon-atom {
    margin-bottom: 2rem;
    opacity: 0;
    transition: opacity 1s ease 0.5s;
}

#carbon-atom.visible {
    opacity: 1;
}

.orbital {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 2s ease;
}

.orbital.drawn {
    stroke-dashoffset: 0;
}

.electron {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.electron.visible {
    opacity: 1;
}

.scroll-hint {
    position: absolute;
    bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: #8D6E63;
    font-size: 1rem;
    opacity: 0;
    animation: fadeInUp 1s ease 3s forwards;
}

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

.scroll-hint svg {
    animation: bobDown 2s ease-in-out infinite;
}

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

/* === Strata Bands === */
.strata-band {
    position: relative;
    height: 120px;
    overflow: hidden;
    background: transparent;
}

.strata-band svg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* === Epoch Sections === */
.epoch-section {
    background: #F5F0E8;
    align-items: flex-start;
    padding: 6rem 2rem;
}

.epoch-marker {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.epoch-date {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #BF6A30;
    white-space: nowrap;
}

.epoch-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, #BF6A30, transparent);
}

.chapter-content {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.chapter-content.in-view {
    opacity: 1;
    transform: translateY(0);
}

.diary-entry {
    padding: 2rem 0;
    border-left: 2px solid #D4C5A0;
    padding-left: 2rem;
    margin-top: 1rem;
    background: linear-gradient(135deg, transparent 95%, rgba(93, 64, 55, 0.02));
}

.diary-entry::first-line {
    color: #5D4037;
}

/* === Marginalia === */
.marginalia {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    color: #8D6E63;
    font-size: 0.95rem;
    opacity: 0;
    transition: opacity 0.6s ease 0.4s;
    max-width: 150px;
}

.marginalia.in-view {
    opacity: 0.7;
}

.marginalia-right {
    right: -180px;
    top: 50%;
    transform: translateY(-50%);
}

.marginalia-left {
    left: -180px;
    top: 50%;
    transform: translateY(-50%);
}

.annotation-arrow {
    opacity: 0.6;
}

/* === Colophon === */
#colophon {
    background: #3E2723;
    color: #D7CCC8;
    padding: 4rem 2rem;
    text-align: center;
    min-height: auto;
}

.colophon-content {
    max-width: 600px;
    margin: 0 auto;
}

.colophon-domain {
    font-size: 2rem;
    color: #C9A84C;
    margin-bottom: 1rem;
}

.colophon-note {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: 0.9rem;
    color: #D7CCC8;
    line-height: 1.8;
    margin-bottom: 0.5rem;
    text-align: center;
}

/* === Sepia Grain Overlay === */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* === Responsive === */
@media (max-width: 1100px) {
    .marginalia {
        position: relative;
        right: auto;
        left: auto;
        top: auto;
        transform: none;
        flex-direction: row;
        max-width: 100%;
        margin-top: 1.5rem;
        padding-left: 2rem;
    }
}

@media (max-width: 768px) {
    .chapter {
        padding: 3rem 1.5rem;
    }

    .epoch-section {
        padding: 4rem 1.5rem;
    }

    .diary-entry {
        padding-left: 1.2rem;
    }

    .epoch-marker {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .epoch-line {
        width: 80px;
    }
}

@media (max-width: 480px) {
    .title-engraved {
        letter-spacing: 0.04em;
    }

    .chapter {
        padding: 2rem 1rem;
    }
}
