/* genpatsu.quest - Scholarly Codex on Nuclear Energy */
/* Flat-design over leather texture */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    box-shadow: none;
    text-shadow: none;
    border-radius: 0;
}

:root {
    --blue: #1B3F8B;
    --amber: #D4820A;
    --red: #B52038;
    --leather: #C4A882;
    --parchment: #F5F0E6;
    --ink: #1A1612;
    --gray: #6B5E50;
    --gold: #ECD9A0;
    --elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --content-width: 680px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Libre Baskerville', Georgia, serif;
    color: var(--ink);
    background-color: var(--leather);
    background-attachment: fixed;
    background-size: cover;
    line-height: 1.72;
    overflow-x: hidden;
}

/* Chapter Navigation Indicator */
.chapter-nav {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    background: var(--parchment);
    padding: 8px 16px;
    border: 2px solid var(--ink);
}

.chapter-label {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-style: italic;
    font-size: 0.85rem;
    color: var(--blue);
    transition: transform 300ms var(--elastic);
    display: inline-block;
}

.chapter-label.updating {
    transform: scale(1.1);
}

/* Chapter Plates */
.chapter-plate {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    position: relative;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 700ms var(--elastic), transform 700ms var(--elastic);
}

.chapter-plate.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Parchment content background */
.chapter-plate::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: calc(var(--content-width) + 120px);
    height: 100%;
    background: rgba(245, 240, 230, 0.92);
    z-index: -1;
}

/* Atom ornament */
.atom-ornament {
    margin-bottom: 24px;
}

/* Chapter heading */
.chapter-heading {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3rem);
    color: var(--ink);
    text-align: center;
    margin-bottom: 48px;
    letter-spacing: normal;
}

/* Section Dividers */
.section-divider {
    width: 100%;
    height: 60px;
    transform: scaleX(0);
    transition: transform 600ms var(--elastic);
}

.section-divider.visible {
    transform: scaleX(1);
}

.divider-blue { background: var(--blue); }
.divider-amber { background: var(--amber); }
.divider-red { background: var(--red); }

/* Title Page */
.title-page {
    min-height: 100vh;
}

.title-cartouche {
    position: relative;
    padding: 60px 80px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.cartouche-frame {
    position: absolute;
    border: 3px solid;
}

.frame-outer {
    inset: 0;
    border-color: var(--blue);
}

.frame-mid {
    inset: 12px;
    border-color: var(--amber);
}

.frame-inner {
    inset: 24px;
    border-color: var(--red);
}

.site-title {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 700;
    font-size: clamp(3.5rem, 9vw, 7rem);
    color: var(--ink);
    line-height: 1.1;
    position: relative;
    z-index: 1;
}

.subtitle {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-variant: small-caps;
    font-size: clamp(0.85rem, 2vw, 1.1rem);
    color: var(--gray);
    margin-top: 16px;
    letter-spacing: 0.15em;
    position: relative;
    z-index: 1;
}

/* Isotope Grid */
.isotope-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-width: var(--content-width);
    width: 100%;
}

.isotope-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--ink);
    cursor: pointer;
    transition: transform 400ms var(--elastic), border-color 400ms var(--elastic);
    position: relative;
    overflow: hidden;
}

.isotope-cell:hover {
    transform: scale(1.15);
    border-color: var(--gold);
    z-index: 10;
}

.isotope-cell:hover::after {
    content: attr(data-desc);
    position: absolute;
    bottom: 4px;
    left: 4px;
    right: 4px;
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 0.55rem;
    color: var(--parchment);
    line-height: 1.3;
    opacity: 1;
    transition: opacity 300ms ease;
}

.isotope-symbol {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 700;
    font-size: 2rem;
    color: var(--parchment);
    line-height: 1;
}

.isotope-mass {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1rem;
    color: var(--parchment);
    line-height: 1;
    margin-top: 4px;
}

/* Chain Reaction Diagram */
.chain-diagram-container {
    max-width: var(--content-width);
    width: 100%;
}

.chain-svg {
    width: 100%;
    height: auto;
}

.chain-atom {
    transform-origin: center;
    transform: scale(0);
    transition: transform 500ms var(--elastic);
}

.chain-line {
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 500ms ease;
}

.chain-plate.visible .chain-atom.gen-0 {
    transform: scale(1);
    transition-delay: 0ms;
}
.chain-plate.visible .chain-atom.gen-1 {
    transform: scale(1);
    transition-delay: 300ms;
}
.chain-plate.visible .chain-line.gen-1 {
    stroke-dashoffset: 0;
    transition-delay: 100ms;
}
.chain-plate.visible .chain-atom.gen-2 {
    transform: scale(1);
    transition-delay: 600ms;
}
.chain-plate.visible .chain-line.gen-2 {
    stroke-dashoffset: 0;
    transition-delay: 400ms;
}
.chain-plate.visible .chain-atom.gen-3 {
    transform: scale(1);
    transition-delay: 900ms;
}
.chain-plate.visible .chain-line.gen-3 {
    stroke-dashoffset: 0;
    transition-delay: 700ms;
}

.chain-caption {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--gray);
    text-align: center;
    margin-top: 32px;
    max-width: var(--content-width);
}

/* Timeline */
.timeline {
    position: relative;
    max-width: var(--content-width);
    width: 100%;
    padding: 40px 0;
}

.timeline-center-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--blue);
    transform: translateX(-50%);
}

.timeline-entry {
    display: flex;
    align-items: center;
    margin-bottom: 48px;
    position: relative;
    opacity: 0;
    transition: opacity 600ms var(--elastic), transform 600ms var(--elastic);
}

.timeline-entry.left {
    flex-direction: row-reverse;
    transform: translateX(-60px);
}

.timeline-entry.right {
    transform: translateX(60px);
}

.timeline-entry.visible {
    opacity: 1;
    transform: translateX(0);
}

.timeline-marker {
    width: 60px;
    height: 60px;
    background: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.timeline-year {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--parchment);
    font-weight: 400;
}

.timeline-connector {
    flex-grow: 1;
    height: 2px;
    background: var(--gray);
    min-width: 20px;
}

.timeline-content {
    width: calc(50% - 60px);
    padding: 16px;
    background: var(--parchment);
    border: 2px solid var(--ink);
}

.timeline-entry.left .timeline-content {
    text-align: right;
    margin-right: auto;
}

.timeline-entry.right .timeline-content {
    text-align: left;
    margin-left: auto;
}

.timeline-content h3 {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--ink);
    margin-bottom: 8px;
}

.timeline-content p {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 0.85rem;
    color: var(--gray);
    line-height: 1.6;
}

/* Colophon */
.colophon-plate {
    padding-bottom: 120px;
}

.colophon-plate::before {
    background: rgba(245, 240, 230, 0.95);
}

.colophon-emblem {
    margin-bottom: 32px;
}

.colophon-content {
    max-width: 480px;
    text-align: center;
}

.colophon-divider {
    width: 120px;
    height: 2px;
    background: var(--gold);
    margin: 0 auto 24px;
}

.colophon-text {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 0.8rem;
    color: var(--gray);
    line-height: 1.8;
    margin-bottom: 16px;
}

.edition-mark {
    font-size: 1.5rem;
    color: var(--ink);
    margin-top: 24px;
}

/* Marginalia */
.marginalia {
    position: fixed;
    z-index: 50;
    display: none;
}

.left-margin {
    left: 24px;
    transform: rotate(-90deg);
    transform-origin: left center;
}

.right-margin {
    right: 24px;
    transform: rotate(90deg);
    transform-origin: right center;
}

.margin-text {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-style: italic;
    font-size: 0.75rem;
    color: var(--gray);
    white-space: nowrap;
    opacity: 0.6;
}

@media (min-width: 1200px) {
    .marginalia {
        display: block;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .chapter-plate {
        padding: 48px 24px;
    }

    .title-cartouche {
        padding: 32px 24px;
    }

    .isotope-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .timeline-entry.left,
    .timeline-entry.right {
        flex-direction: row;
    }

    .timeline-entry.left .timeline-content,
    .timeline-entry.right .timeline-content {
        text-align: left;
        margin-left: 80px;
        width: calc(100% - 80px);
    }

    .timeline-marker {
        left: 0;
        transform: none;
    }

    .timeline-center-line {
        left: 30px;
    }

    .timeline-connector {
        display: none;
    }

    .chapter-nav {
        bottom: 12px;
        right: 12px;
        padding: 4px 10px;
    }
}

@media (max-width: 480px) {
    .isotope-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .site-title {
        font-size: clamp(2rem, 12vw, 3.5rem);
    }
}
