/* ABOUTME: Warm-cream theme for deco-patterns.moves.cloud — Petrie plate archive. */
/* ABOUTME: Light paper palette, Fraunces display type, card plates, zoom lightbox. */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,600;1,9..144,400&family=Inter:wght@300;400;500&display=swap');

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

:root {
    /* Warm cream paper — the tone the scan was cleaned *away* from, put back
       deliberately under the plates instead of soaked into them. */
    --paper: #F7F2E6;
    --paper-deep: #EFE7D6;
    --card: #FFFCF4;
    --ink: #2B2419;
    --ink-soft: #6B5F4C;
    --ink-faint: #94886F;
    --line: #E2D7C0;
    --line-soft: #EDE4D2;
    --accent: #8A6334;
    --accent-soft: #F0E4CE;
    --display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --shadow: 0 1px 2px rgba(43, 36, 25, .05), 0 8px 24px rgba(43, 36, 25, .07);
    --shadow-sm: 0 1px 2px rgba(43, 36, 25, .05), 0 3px 10px rgba(43, 36, 25, .05);
    --wrap: 940px;
}

html { scroll-behavior: smooth; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-weight: 300;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.5rem; }

/* --- Top bar --- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(247, 242, 230, .88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    max-width: var(--wrap);
    margin: 0 auto;
    padding: .7rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-home {
    font-family: var(--display);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
}

.topbar-spacer { flex: 1; }

/* Language selector */
.lang {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
    background: var(--card);
    flex-shrink: 0;
}

.lang button {
    font-family: var(--sans);
    font-size: .74rem;
    font-weight: 500;
    letter-spacing: .06em;
    padding: .34rem .72rem;
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background .18s ease, color .18s ease;
}

.lang button[aria-pressed="true"] {
    background: var(--accent);
    color: #FFFDF6;
}

/* --- Hero --- */

.hero {
    text-align: center;
    padding: 4.5rem 1.5rem 3rem;
    border-bottom: 1px solid var(--line);
}

.hero-plate {
    font-family: var(--sans);
    font-size: .7rem;
    letter-spacing: .28em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 1.4rem;
}

.hero h1 {
    font-family: var(--display);
    font-size: clamp(2.1rem, 5.2vw, 3.6rem);
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -.015em;
    margin-bottom: .6rem;
    /* A measure, so the title wraps deliberately. The Ukrainian title is much
       longer than the English and otherwise fills the viewport edge to edge. */
    max-width: 16em;
    margin-inline: auto;
    text-wrap: balance;
}

.hero-sub {
    font-family: var(--display);
    font-style: italic;
    font-size: clamp(1rem, 2.4vw, 1.28rem);
    color: var(--accent);
    margin-bottom: 1.6rem;
}

.hero-blurb {
    max-width: 560px;
    margin: 0 auto;
    font-size: .95rem;
    color: var(--ink-soft);
    line-height: 1.8;
}

.hero-meta {
    margin-top: 1.8rem;
    font-size: .76rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

/* --- Contents grid --- */

.contents { padding: 3.5rem 0 4rem; }

.section-label {
    font-size: .72rem;
    letter-spacing: .24em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 1.6rem;
    text-align: center;
}

.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
    gap: 1.4rem;
}

.chapter-card {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 5px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.chapter-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
    color: inherit;
}

.chapter-card:hover .chapter-thumb img { transform: scale(1.04); }

.chapter-thumb {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--paper-deep);
    border-bottom: 1px solid var(--line-soft);
}

.chapter-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Crop into the middle of the plate: the top of every page is running head
       and margin, which reads as a blank card. */
    object-position: center 45%;
    display: block;
    transition: transform .35s ease;
}

.chapter-body { padding: 1.1rem 1.25rem 1.35rem; }

.chapter-classes {
    font-size: .68rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: .35rem;
}

.chapter-title {
    font-family: var(--display);
    font-size: 1.32rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: .45rem;
}

.chapter-blurb {
    font-size: .86rem;
    color: var(--ink-soft);
    line-height: 1.6;
}

.chapter-count {
    margin-top: .8rem;
    font-size: .72rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

/* --- Chapter page --- */

.chapter-head {
    padding: 3.4rem 0 2.2rem;
    border-bottom: 1px solid var(--line);
    text-align: center;
}

.chapter-head h1 {
    font-family: var(--display);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 400;
    line-height: 1.1;
    margin-bottom: .5rem;
}

.chapter-head .chapter-blurb {
    max-width: 560px;
    margin: .8rem auto 0;
    font-size: .95rem;
    line-height: 1.8;
}

.plates { padding: 2.6rem 0 3rem; }

.plate {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 5px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2.6rem;
    overflow: hidden;
}

.plate-figure {
    margin: 0;
    background: var(--paper-deep);
    cursor: zoom-in;
    position: relative;
}

.plate-figure img {
    display: block;
    width: 100%;
    height: auto;
}

.plate-zoomhint {
    position: absolute;
    right: .7rem;
    bottom: .7rem;
    background: rgba(43, 36, 25, .72);
    color: #FFFCF4;
    font-size: .68rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: .3rem .6rem;
    border-radius: 3px;
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
}

.plate-figure:hover .plate-zoomhint { opacity: 1; }

.plate-body { padding: 1.3rem 1.5rem 1.5rem; }

.plate-no {
    font-size: .7rem;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: .3rem;
}

.plate-title {
    font-family: var(--display);
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: .7rem;
}

.plate-note {
    font-size: .92rem;
    color: var(--ink);
    line-height: 1.78;
}

.plate-note p { margin-bottom: .8rem; }
.plate-note p:last-child { margin-bottom: 0; }

.plate-aside {
    margin-top: .9rem;
    padding-top: .9rem;
    border-top: 1px solid var(--line-soft);
    font-size: .88rem;
    font-style: italic;
    color: var(--ink-soft);
    line-height: 1.7;
}

/* --- Prose (about page) --- */

.prose { padding: 2.6rem 0 3rem; max-width: 680px; margin: 0 auto; }
.prose h2 {
    font-family: var(--display);
    font-size: 1.7rem;
    font-weight: 600;
    margin: 2.2rem 0 .8rem;
}
.prose h3 {
    font-family: var(--display);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 1.6rem 0 .5rem;
}
.prose p { margin-bottom: 1rem; font-size: .95rem; line-height: 1.85; }
.prose em { color: var(--ink-soft); }

.figure-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .9rem;
    margin: 1.6rem 0 2rem;
}

.figure-strip figure { margin: 0; cursor: zoom-in; }

.figure-strip img {
    width: 100%;
    display: block;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: var(--card);
    box-shadow: var(--shadow-sm);
}

.figure-strip figcaption {
    margin-top: .4rem;
    font-size: .72rem;
    color: var(--ink-soft);
    text-align: center;
}

/* Classes table */
.classes-table { width: 100%; border-collapse: collapse; font-size: .86rem; margin: 1rem 0 2rem; }
.classes-table th {
    text-align: left;
    font-weight: 500;
    font-size: .7rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--line);
    padding: .5rem .6rem;
}
.classes-table td { padding: .38rem .6rem; border-bottom: 1px solid var(--line-soft); }
.classes-table tr.class-row td {
    font-family: var(--display);
    font-weight: 600;
    font-size: .98rem;
    padding-top: 1.1rem;
    color: var(--ink);
}
.classes-table td.num, .classes-table td.plate { text-align: right; color: var(--ink-soft); white-space: nowrap; }
.table-scroll { overflow-x: auto; }

/* --- Chapter footer nav --- */

.pager {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 2rem 0 4rem;
    border-top: 1px solid var(--line);
    font-size: .88rem;
}

.pager a { text-decoration: none; display: block; max-width: 45%; }
.pager .pager-dir {
    font-size: .68rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: .15rem;
}
.pager .pager-name { font-family: var(--display); font-size: 1.02rem; font-weight: 600; color: var(--ink); }
.pager a:hover .pager-name { color: var(--accent); }
.pager .pager-next { text-align: right; margin-left: auto; }

/* --- Lightbox --- */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    background: rgba(30, 25, 17, .93);
}

.lightbox.open { display: block; }

/* Native scroll + pinch-zoom inside the overlay: the image is placed at its
   natural size and the container pans, which is what mobile users expect. */
.lightbox-scroll {
    position: absolute;
    inset: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pinch-zoom pan-x pan-y;
}

.lightbox img {
    display: block;
    margin: auto;
    background: var(--paper);
    max-width: 100%;
    max-height: 100vh;
    object-fit: contain;
    cursor: zoom-in;
}

/* Zoomed: natural size, container scrolls */
.lightbox.zoomed .lightbox-scroll { display: block; }
.lightbox.zoomed img {
    max-width: none;
    max-height: none;
    width: auto;
    cursor: zoom-out;
}

.lightbox-close {
    position: absolute;
    top: .8rem;
    right: .9rem;
    z-index: 2;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 252, 244, .16);
    color: #FFFCF4;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.lightbox-close:hover { background: rgba(255, 252, 244, .3); }

.lightbox-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: .75rem 1rem;
    text-align: center;
    font-size: .8rem;
    color: #EFE7D6;
    background: linear-gradient(transparent, rgba(30, 25, 17, .85));
    pointer-events: none;
}

/* --- Footer --- */

.site-footer {
    border-top: 1px solid var(--line);
    padding: 2.6rem 1.5rem 3.4rem;
    text-align: center;
    font-size: .8rem;
    color: var(--ink-soft);
    line-height: 1.8;
}

.site-footer a { color: var(--accent); }

/* --- Responsive --- */

@media (max-width: 720px) {
    .wrap { padding: 0 1rem; }
    .hero { padding: 3rem 1rem 2.4rem; }
    .chapter-grid { grid-template-columns: 1fr; gap: 1.1rem; }
    .plate-body { padding: 1.1rem 1.1rem 1.3rem; }
    .plate-zoomhint { opacity: 1; }
    .topbar-home { font-size: .92rem; }
}
