/* =========================================================
   THE GREAT LIBRARY OF PHILOSOPHY
   HISTORY PAGE — REFINED LAYER

   Load AFTER:
       style.css

   Example:
       <link rel="stylesheet" href="style.css">
       <link rel="stylesheet" href="history-refine.css">

   This file refines ONLY the History page while borrowing
   the important visual/typographic refinements used by
   home-refine.css.

   No HTML structure changes required.
   ========================================================= */


/* =========================================================
   0. REFINEMENT VARIABLES + TYPOGRAPHY
   ========================================================= */

:root {
    --history-measure: 68ch;
    --history-lead: 1.75;
    --history-ease: cubic-bezier(0.22, 1, 0.36, 1);

    --history-rule-gold:
        linear-gradient(to right,
            transparent,
            var(--gold),
            transparent);
}


/* Improve text rendering consistently with Home */

body {
    text-rendering: optimizeLegibility;
    font-variant-numeric: oldstyle-nums proportional-nums;
}


/* Better heading wrapping */

.home-hero h1,
.history-section-title h2,
.era-content h2,
.philosopher-info h2,
.world-card h3,
.history-summary h2,
.quote h2 {
    text-wrap: balance;
}


/* Better paragraph wrapping */

.intro-text p,
.world-intro,
.era-content p,
.philosopher-info p,
.history-summary p {
    text-wrap: pretty;
}




/* =========================================================
   1. PAGE READING / ANCHOR BEHAVIOR
   ========================================================= */

html {
    scroll-behavior: smooth;
}

#timeline,
.era,
.philosopher,
section[id] {
    scroll-margin-top: clamp(72px, 12vh, 110px);
}


/* =========================================================
   2. HISTORY HERO
   IMPORTANT:
   History uses the same .home-hero structure as Home.
   These rules bring across the important Home refinement.
   ========================================================= */

.home-hero {
    position: relative;
    overflow: hidden;
}


/* Keep hero content above decorative overlay */

.home-hero .hero-content {
    position: relative;
    z-index: 1;
    max-width: 720px;
}


/* Hero heading refinement */

.home-hero h1 {
    line-height: 1.05;
    letter-spacing: -0.015em;
    text-wrap: balance;
}


/* Hero paragraph refinement */

.home-hero .hero-content>p {
    font-size: 1.15rem;
    color: var(--muted-light);
    max-width: 56ch;
    border-left: 2px solid var(--gold);
    padding-left: 1.2rem;
}



/* Same subtle atmospheric effect used by Home */

.home-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;

    opacity: 0.5;

    background-image:
        radial-gradient(circle at 20% 30%,
            rgba(211, 165, 101, 0.06),
            transparent 45%),
        radial-gradient(circle at 80% 70%,
            rgba(211, 165, 101, 0.05),
            transparent 40%);
}


/* =========================================================
   3. INTRODUCTION / LONG-FORM TEXT
   ========================================================= */

.intro-text {
    max-width: var(--history-measure);
    margin-left: auto;
    margin-right: auto;
    text-align: left;
}

.intro-text>p {
    margin-top: 0;
    margin-bottom: 1.4rem;
    line-height: var(--history-lead);
    text-wrap: pretty;
}


/* Prevent empty paragraphs from creating gaps */

.intro-text p:empty {
    display: none;
}


/* First introduction paragraph */

.intro-text>p:first-of-type {
    font-size: 1.08em;
}


/* First-letter treatment */

.intro-text>p:first-of-type::first-letter {
    float: left;

    font-family:
        "Cinzel",
        Georgia,
        serif;

    font-size: 3.1rem;
    line-height: 0.82;

    margin:
        0.18rem 0.55rem 0 0;

    color: var(--gold);
}


/* Separate civilization paragraphs */

.intro-text>p+p {
    padding-top: 1.2rem;

    border-top:
        1px solid rgba(184, 138, 68, 0.16);
}


/* Long-form links */

.intro-text a,
.era-content a,
.world-card a:not(.world-btn) {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;

    text-decoration-color:
        rgba(184, 138, 68, 0.55);

    transition:
        color 0.25s ease,
        text-decoration-color 0.25s ease;
}

.intro-text a:hover,
.era-content a:hover,
.world-card a:not(.world-btn):hover {
    text-decoration-color: var(--gold);
}


/* =========================================================
   4. SECTION RHYTHM
   ========================================================= */

.schools,
.world-philosophy,
.history-section-title,
.era,
.philosopher,
.quote,
.history-summary {
    padding-top: clamp(3rem, 7vw, 5.5rem);
    padding-bottom: clamp(3rem, 7vw, 5.5rem);
}


/* Timeline heading */

.history-section-title {
    text-align: center;
}

.history-section-title .section-label {
    display: inline-block;

    font-family:
        var(--mono,
            monospace);

    font-size: 0.72rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;

    color: var(--gold);

    margin-bottom: 0.9rem;
}

.history-section-title h2 {
    font-size: clamp(2rem, 4.5vw, 3.2rem);
    line-height: 1.15;
    margin-bottom: 1.1rem;
}

.history-section-title>p,
.world-intro {
    max-width: 66ch;

    margin-left: auto;
    margin-right: auto;

    line-height: var(--history-lead);

    text-wrap: pretty;
}


/* =========================================================
   5. DIVIDERS
   ========================================================= */

.philosophy-divider {
    height: 1px;

    width: min(240px, 45%);

    margin-left: auto;
    margin-right: auto;

    border: 0;

    background:
        var(--history-rule-gold);

    opacity: 0.75;
}


/* =========================================================
   6. WORLD PHILOSOPHY GRID
   ========================================================= */

.world-grid {
    display: grid;

    grid-template-columns:
        repeat(auto-fit,
            minmax(270px, 1fr));

    gap:
        clamp(1.1rem,
            2.4vw,
            1.8rem);

    max-width: 1180px;

    margin-left: auto;
    margin-right: auto;

    align-items: stretch;
}

.world-card {
    display: flex;
    flex-direction: column;

    height: 100%;

    transition:
        transform 0.4s var(--history-ease),
        box-shadow 0.4s var(--history-ease),
        border-color 0.4s ease;
}

.world-card p {
    flex: 1 1 auto;
    line-height: 1.7;
}

.world-card .world-btn {
    margin-top: 1.3rem;

    align-self: flex-start;

    display: inline-block;
}

.world-card:hover,
.world-card:focus-within {
    transform: translateY(-6px);

    border-color:
        rgba(184, 138, 68, 0.45);
}

.world-icon {
    font-size: 2rem;
    line-height: 1;
    margin-bottom: 0.85rem;
}

.world-card h3 {
    line-height: 1.25;
    margin-bottom: 0.6rem;
}


/* =========================================================
   7. BUTTON / LINK BEHAVIOR
   ========================================================= */

.world-card .world-btn button,
.history-summary button,
.home-hero button {
    pointer-events: none;
}

.world-card .world-btn,
.history-summary a,
.home-hero a {
    display: inline-block;
}


/* =========================================================
   8. ERA SECTIONS
   ========================================================= */

.era {
    display: grid;

    grid-template-columns:
        minmax(0, 0.95fr) minmax(0, 1.05fr);

    gap:
        clamp(1.5rem,
            4vw,
            3.5rem);

    align-items: center;

    max-width: 1120px;

    margin-left: auto;
    margin-right: auto;
}


/*
   IMPORTANT:
   No automatic nth-of-type alternation.

   Your History page contains other sections between eras,
   so nth-of-type would not reliably alternate the images.
*/


/* Era image */

.era-image {
    margin: 0;

    overflow: hidden;

    border-radius: 10px;

    border:
        1px solid rgba(184, 138, 68, 0.22);

    box-shadow:
        0 18px 40px -28px rgba(0, 0, 0, 0.6);
}

.era-image img {
    display: block;

    width: 100%;
    height: 100%;

    aspect-ratio: 4 / 3;

    object-fit: cover;

    transition:
        transform 0.7s var(--history-ease),
        filter 0.5s ease;
}

.era:hover .era-image img {
    transform: scale(1.025);
}


/* Era heading */

.era-content h2 {
    font-size:
        clamp(1.5rem,
            2.6vw,
            2.1rem);

    line-height: 1.2;

    margin-bottom: 0.9rem;
}

.era-content p {
    max-width: 60ch;

    line-height: var(--history-lead);

    text-wrap: pretty;
}


/* Era subheading */

.era-content h3 {
    font-family:
        var(--mono,
            monospace);

    font-size: 0.75rem;

    letter-spacing: 0.24em;

    text-transform: uppercase;

    color: var(--gold);

    margin-top: 1.6rem;
    margin-bottom: 0.7rem;
}


/* Keep historical lists as normal educational lists */

.era-content ul {
    padding-left: 1.2rem;
    margin-top: 0.5rem;
}

.era-content li {
    margin-bottom: 0.4rem;
    line-height: 1.6;
}


/* =========================================================
   9. PHILOSOPHER SECTIONS
   ========================================================= */

.philosopher {
    display: grid;

    grid-template-columns:
        minmax(160px, 220px) minmax(0, 1fr);

    gap:
        clamp(1.2rem,
            3vw,
            2.5rem);

    align-items: center;

    max-width: 900px;

    margin-left: auto;
    margin-right: auto;
}

.philosopher>img {
    width: 100%;

    aspect-ratio: 1 / 1;

    object-fit: cover;

    border-radius: 50%;

    border:
        1px solid rgba(184, 138, 68, 0.35);

    box-shadow:
        0 14px 34px -24px rgba(0, 0, 0, 0.65);
}

.philosopher-info h2 {
    font-size:
        clamp(1.35rem,
            2.2vw,
            1.85rem);

    line-height: 1.2;

    margin-bottom: 0.6rem;
}

.philosopher-info p {
    max-width: 58ch;
    line-height: var(--history-lead);
}


/* Philosopher quote */

.philosopher-info blockquote {
    position: relative;

    margin-top: 1.2rem;
    margin-bottom: 0;

    padding-left: 1.4rem;

    border-left:
        2px solid var(--gold);

    font-family:
        "Cormorant Garamond",
        Georgia,
        serif;

    font-style: italic;

    font-size:
        clamp(1.05rem,
            1.6vw,
            1.3rem);

    line-height: 1.55;
}


/* =========================================================
   10. HISTORY QUOTE
   ========================================================= */

.quote {
    text-align: center;
}

.quote blockquote {
    position: relative;

    max-width: 62ch;

    margin-left: auto;
    margin-right: auto;

    margin-top: 1.2rem;

    padding-left: 0;

    border-left: 0;

    font-family:
        "Cormorant Garamond",
        Georgia,
        serif;

    font-style: italic;

    font-size:
        clamp(1.25rem,
            2.6vw,
            1.9rem);

    line-height: 1.65;

    text-wrap: pretty;
}

.quote blockquote::before {
    content: "\201C";

    display: block;

    font-size: 3rem;

    line-height: 0.6;

    color: var(--gold);

    opacity: 0.6;

    margin-bottom: 0.4rem;
}

.quote>p {
    font-family:
        var(--mono,
            monospace);

    font-size: 0.78rem;

    letter-spacing: 0.2em;

    text-transform: uppercase;

    color: var(--gold);

    margin-top: 1rem;
}


/* =========================================================
   11. CLOSING SECTION
   ========================================================= */

.history-summary {
    text-align: center;
}

.history-summary p {
    max-width: 58ch;

    margin-left: auto;
    margin-right: auto;

    margin-bottom: 2rem;

    line-height: var(--history-lead);

    text-wrap: pretty;
}


/* =========================================================
   12. KEYBOARD ACCESSIBILITY
   Borrowed from Home refinement
   ========================================================= */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline:
        2px solid var(--gold-bright, var(--gold));

    outline-offset: 3px;

    border-radius: 3px;
}


/* =========================================================
   13. TOUCH TARGETS
   Borrowed from Home refinement
   ========================================================= */

@media (pointer: coarse) {

    .menu-toggle,
    .appearance-toggle,
    .search-toggle,
    .language-toggle {
        min-width: 44px;
        min-height: 44px;
    }

    .world-btn,
    .history-summary a,
    .home-hero a {
        min-height: 44px;

        display: inline-flex;

        align-items: center;
        justify-content: center;
    }
}


/* =========================================================
   14. RESPONSIVE — TABLET
   ========================================================= */

@media (max-width: 900px) {

    .home-hero .hero-content>p {
        max-width: 60ch;
    }

    .intro-text {
        padding-left: 5vw;
        padding-right: 5vw;
    }

    .era,
    .philosopher {
        grid-template-columns: 1fr;
        text-align: left;
    }

    .era-image img {
        aspect-ratio: 16 / 9;
    }

    .philosopher {
        justify-items: center;
        text-align: center;
    }

    .philosopher>img {
        max-width: 170px;
    }

    .philosopher-info blockquote {
        text-align: left;
    }
}


/* =========================================================
   15. RESPONSIVE — MOBILE
   ========================================================= */

@media (max-width: 620px) {

    .home-hero h1 {
        font-size:
            clamp(2.1rem,
                9vw,
                3rem);
    }

    .intro-text>p:first-of-type::first-letter {
        font-size: 2.6rem;
    }

    .world-grid {
        grid-template-columns: 1fr;
    }

    .era-content h2 {
        font-size: 1.55rem;
    }

    .era-content ul {
        padding-left: 1.1rem;
    }

    .quote blockquote {
        font-size: 1.15rem;
    }

    .philosopher>img {
        max-width: 145px;
    }

    .home-hero .hero-content>p {
        max-width: 100%;
    }
}


/* =========================================================
   16. LIGHT THEME — PROSE READABILITY
   Adapted from Home refinement
   ========================================================= */

body:not(.theme-dark) .intro-text>p,
body:not(.theme-dark) .era-content p,
body:not(.theme-dark) .philosopher-info p,
body:not(.theme-dark) .history-summary p,
body:not(.theme-dark) .world-card p {
    color: #332f29;
    font-weight: 500;
}

body:not(.theme-dark) .intro-text a,
body:not(.theme-dark) .era-content a,
body:not(.theme-dark) .world-card a:not(.world-btn) {
    color: #8a5a24;
    font-weight: 600;
}


/* =========================================================
   17. DARK THEME COMPATIBILITY
   ========================================================= */

body.theme-dark .home-hero::after {
    opacity: 0.65;
}

body.theme-dark .intro-text a,
body.theme-dark .era-content a {
    text-decoration-color:
        var(--gold-bright,
            var(--gold));
}

body.theme-dark .quote blockquote,
body.theme-dark .philosopher-info blockquote {
    text-shadow:
        0 1px 12px rgba(0, 0, 0, 0.18);
}


/* =========================================================
   18. LINK HOVER REFINEMENT
   ========================================================= */

.intro-text a:hover,
.era-content a:hover,
.world-card a:not(.world-btn):hover {
    text-decoration-thickness: 2px;
}


/* =========================================================
   19. REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

    .home-hero::after {
        transition: none !important;
    }

    .era-image img,
    .world-card {
        transition: none !important;
    }

    .era:hover .era-image img {
        transform: none;
    }

    .world-card:hover {
        transform: none;
    }
}


/* =========================================================
   PHILOSOPHER PORTRAIT — FORCE TRUE CIRCLE
   ========================================================= */

.philosopher>img {
    width: 190px;
    height: 190px;
    aspect-ratio: 1 / 1;

    max-width: none;

    object-fit: cover;
    object-position: center;

    border-radius: 50%;
}


/* Tablet */
@media (max-width: 860px) {

    .philosopher>img {
        width: 170px;
        height: 170px;
        max-width: none;
    }

}


/* Mobile */
@media (max-width: 620px) {

    .philosopher>img {
        width: 145px;
        height: 145px;
        max-width: none;
    }

}

/* HISTORY PAGE — darker body paragraphs */
/* HISTORY PAGE — darker body paragraphs */

body:not(.theme-dark) .intro-text>p,
body:not(.theme-dark) .era-content p,
body:not(.theme-dark) .philosopher-info p,
body:not(.theme-dark) .history-summary p,
body:not(.theme-dark) .world-card p,
body:not(.theme-dark) .world-intro,
body:not(.theme-dark) .history-section-title>p {
    color: #2f2b25;
    font-weight: 500;
}

/* =========================================================
   MOBILE — KEEP ALL ERAS IN THE SAME ORDER
   IMAGE → TEXT
   ========================================================= */

@media (max-width: 700px) {

    .era {
        grid-template-columns: 1fr;
        width: 100%;
    }

    /* Cancel the old alternating desktop rules */
    .era:nth-of-type(even) {
        grid-template-columns: 1fr;
    }

    .era:nth-of-type(even) .era-image,
    .era:nth-of-type(even) .era-content {
        order: initial;
    }

    /* Full-width mobile image */
    .era-image {
        width: 100%;
        max-width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }

    .era-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Prevent text from becoming squeezed */
    .era-content {
        width: 100%;
        min-width: 0;
    }

    .era-content>p {
        max-width: 100%;
    }
}