/* ============================================================
   РЕЗОНАНС — журнал. Дизайн-система.
   Акцент и бумажный фон подобраны по факт. цветам обложки/вёрстки
   номера (bronze #a9794b, cream #f7eee0) — веб-обвязка читается
   как продолжение уже готового дизайна номера, а не поверх него.
   Зелёный (--sister) зарезервирован под кросс-промо книг Алёны.
   ============================================================ */

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

:root {
    --bg: #f7eee0;
    --bg-alt: #efe3cb;
    --surface: #fffdf8;
    --ink: #2a2620;
    --ink-soft: #6f6a5a;
    --ink-faint: #a39c88;
    --accent: #a9794b;
    --accent-dark: #7c5732;
    --accent-soft: #eeddc3;
    --line: #e4d6ba;
    --sister: #4f5c3f;
    --sister-dark: #3b4530;
    --sister-soft: #e4e6da;

    --radius-sm: 10px;
    --radius: 20px;
    --radius-lg: 30px;
    --shadow-sm: 0 4px 14px rgba(38, 36, 31, .07);
    --shadow: 0 14px 34px rgba(38, 36, 31, .10);

    --serif-display: "Fraunces", "Charter", "Georgia", serif;
    --serif-body: "Source Serif 4", "Charter", "Georgia", serif;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #1b1913;
    --bg-alt: #211f18;
    --surface: #242219;
    --ink: #ede7d8;
    --ink-soft: #b9b09a;
    --ink-faint: #8a8270;
    --accent: #d9a165;
    --accent-dark: #ecb87e;
    --accent-soft: #3a2c22;
    --line: #383327;
    --sister: #93a67e;
    --sister-dark: #a9bb95;
    --sister-soft: #2a2e21;
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, .28);
    --shadow: 0 14px 34px rgba(0, 0, 0, .38);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--serif-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background .25s ease, color .25s ease;
}

img { max-width: 100%; display: block; }
a { color: inherit; }

.wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 28px;
}

/* ---------- Masthead ---------- */

.masthead {
    position: sticky;
    top: 0;
    z-index: 40;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.masthead-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 28px;
    font-family: var(--sans);
}

.wordmark {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--serif-display);
    font-weight: 900;
    font-size: 1.35rem;
    letter-spacing: 0.02em;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
}

.wordmark svg { flex-shrink: 0; }

.masthead-nav {
    display: flex;
    gap: 22px;
    align-items: center;
    flex: 1;
}

.masthead-nav a {
    text-decoration: none;
    color: var(--ink-soft);
    font-size: 0.92rem;
    font-weight: 500;
}

.masthead-nav a:hover,
.masthead-nav a.is-active { color: var(--accent-dark); }

.masthead-cta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.pill-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--sister-dark);
    background: var(--sister-soft);
    border: 1px solid color-mix(in srgb, var(--sister) 30%, transparent);
    padding: 7px 14px;
    border-radius: 999px;
    text-decoration: none;
    white-space: nowrap;
}

.theme-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-alt);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px;
}

.theme-toggle button {
    border: none;
    background: transparent;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle button.is-active {
    background: var(--surface);
    color: var(--accent-dark);
    box-shadow: var(--shadow-sm);
}

.progress-rail {
    height: 3px;
    background: var(--line);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width .1s linear;
}

.menu-toggle {
    display: none;
    border: none;
    background: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--ink);
}

/* ---------- Hero ---------- */

.hero {
    padding: 64px 0 56px;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 56px;
    align-items: center;
}

.eyebrow {
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-dark);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
}

.eyebrow::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.hero h1 {
    font-family: var(--serif-display);
    font-weight: 600;
    font-size: clamp(2.3rem, 4.6vw, 3.6rem);
    line-height: 1.06;
    letter-spacing: -0.01em;
    margin: 0 0 20px;
}

.hero-dek {
    font-size: 1.15rem;
    color: var(--ink-soft);
    max-width: 46ch;
    margin: 0 0 30px;
}

.hero-actions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.btn {
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 13px 26px;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--accent);
    color: #fff8ef;
}
.btn-primary:hover { background: var(--accent-dark); }

.btn-ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--ink);
}
.btn-ghost:hover { border-color: var(--ink-faint); }

/* Typographic "cover" placeholder — used in place of real photography */
.cover-plate {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 30px;
    color: #fbf3e6;
    font-family: var(--sans);
}

.cover-photo {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    line-height: 0;
}
.cover-photo img { width: 100%; display: block; }

/* Обложка А4 (портрет) в hero: фиксированная ширина задана прямо на
   <img> (не на grid-колонке/wrapper) — самый надёжный вариант, без
   пересчёта grid-track от резиновых/auto значений. */
.cover-photo.hero-cover {
    justify-self: end;
}
.cover-photo.hero-cover img {
    width: 380px;
    max-width: 100%;
    height: auto;
}

.cover-plate.tone-a { background: linear-gradient(155deg, #c1552f, #7c351b 78%); }
.cover-plate.tone-b { background: linear-gradient(155deg, #4f5c3f, #2c331f 82%); }
.cover-plate.tone-c { background: linear-gradient(155deg, #6c5b8f, #3a2f52 82%); }
.cover-plate.tone-d { background: linear-gradient(155deg, #a37b3d, #5c4520 82%); }

.cover-plate-top {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.85;
}

.cover-plate-number {
    font-family: var(--serif-display);
    font-weight: 900;
    font-size: clamp(3.2rem, 9vw, 5.2rem);
    line-height: 0.9;
    opacity: 0.92;
}

.cover-plate-title {
    font-family: var(--serif-display);
    font-weight: 600;
    font-size: 1.3rem;
    line-height: 1.15;
}

.cover-plate.is-compact { padding: 20px; }
.cover-plate.is-compact .cover-plate-number { font-size: clamp(2.2rem, 6vw, 3rem); }
.cover-plate.is-compact .cover-plate-title { font-size: 1.02rem; }

/* ---------- Section headings ---------- */

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 26px;
}

.section-head h2 {
    font-family: var(--serif-display);
    font-weight: 600;
    font-size: 1.7rem;
    margin: 0;
}

.section-head .section-link {
    font-family: var(--sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-dark);
    text-decoration: none;
    white-space: nowrap;
}

section.block { padding: 20px 0 64px; }

/* ---------- Contents grid (bento) ---------- */

.toc-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-flow: dense;
    gap: 20px;
}

.toc-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 26px;
    text-decoration: none;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform .18s ease, box-shadow .18s ease;
}

.toc-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.toc-card.feature {
    grid-column: span 4;
    grid-row: span 2;
    padding: 36px;
    justify-content: flex-end;
    min-height: 380px;
    background: linear-gradient(180deg, transparent 45%, rgba(38,36,31,.06)), var(--surface);
}

.toc-card.feature.has-photo {
    background-image: linear-gradient(180deg, rgba(20,17,12,0) 22%, rgba(20,17,12,.9) 95%), var(--photo);
    background-size: cover;
    background-position: center 15%;
    color: #fbf4e8;
    border-color: transparent;
}
.toc-card.feature.has-photo .rubric-tag { background: rgba(255,255,255,.18); color: #fff; }
.toc-card.feature.has-photo h3 { color: #fff; }
.toc-card.feature.has-photo p { color: rgba(255,246,232,.85); }
.toc-card.feature.has-photo .toc-meta { color: rgba(255,246,232,.65); }

.toc-card.tall { grid-column: span 2; grid-row: span 2; }
.toc-card:not(.feature):not(.tall) { grid-column: span 2; }

.rubric-tag {
    font-family: var(--sans);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--accent-dark);
    background: var(--accent-soft);
    padding: 5px 11px;
    border-radius: 999px;
    align-self: flex-start;
}

.toc-card h3 {
    font-family: var(--serif-display);
    font-weight: 600;
    margin: 0;
    line-height: 1.18;
}

.toc-card.feature h3 { font-size: clamp(1.5rem, 2.6vw, 2.15rem); }
.toc-card:not(.feature) h3 { font-size: 1.15rem; }

.toc-card p {
    color: var(--ink-soft);
    margin: 0;
    font-size: 0.96rem;
    line-height: 1.5;
}

.toc-meta {
    font-family: var(--sans);
    font-size: 0.8rem;
    color: var(--ink-faint);
    margin-top: auto;
    padding-top: 6px;
}

/* ---------- Cross-promo / рекомендация автора ---------- */

.promo {
    background: var(--sister-soft);
    border: 1px solid color-mix(in srgb, var(--sister) 25%, transparent);
    border-radius: var(--radius-lg);
    padding: 40px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 28px;
    align-items: center;
}

.promo-badge {
    font-family: var(--sans);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--sister-dark);
    margin-bottom: 10px;
    display: block;
}

.promo-plate {
    width: 92px;
    aspect-ratio: 3/4;
    border-radius: 12px;
    background: linear-gradient(155deg, var(--sister), var(--sister-dark));
    flex-shrink: 0;
}

.promo-plate.has-img {
    width: 110px;
    aspect-ratio: auto;
    background: none;
    border-radius: 0;
    display: flex;
    align-items: center;
}
.promo-plate.has-img img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 10px 18px rgba(38, 36, 31, .25));
}

.promo h3 {
    font-family: var(--serif-display);
    font-size: 1.3rem;
    margin: 0 0 8px;
    color: var(--ink);
}

.promo p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.98rem;
    max-width: 52ch;
}

.promo .btn-primary { background: var(--sister); }
.promo .btn-primary:hover { background: var(--sister-dark); }

/* ---------- Archive grid ---------- */

.archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
}

.archive-card {
    text-decoration: none;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.archive-card h3 {
    font-family: var(--serif-display);
    font-size: 1.05rem;
    margin: 0;
}

.archive-card .archive-date {
    font-family: var(--sans);
    font-size: 0.8rem;
    color: var(--ink-faint);
}

.archive-card.is-soon .cover-plate { opacity: 0.55; filter: grayscale(0.4); }
.archive-card.is-soon { pointer-events: none; }

/* ---------- Footer ---------- */

.site-footer {
    border-top: 1px solid var(--line);
    background: var(--bg-alt);
    margin-top: 40px;
}

.footer-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 56px 28px 28px;
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 40px;
}

.footer-brand .wordmark { margin-bottom: 12px; }
.footer-brand p { color: var(--ink-soft); font-size: 0.92rem; max-width: 40ch; }

.footer-col-title {
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 14px;
}

.footer-col a, .footer-col span {
    display: block;
    font-family: var(--sans);
    font-size: 0.92rem;
    color: var(--ink-soft);
    text-decoration: none;
    margin-bottom: 10px;
}
.footer-col a:hover { color: var(--accent-dark); }

.footer-bottom {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px 28px 32px;
    font-family: var(--sans);
    font-size: 0.8rem;
    color: var(--ink-faint);
    border-top: 1px solid var(--line);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
    .hero-grid { grid-template-columns: 1fr; }
    .hero .cover-plate { max-width: 340px; }
    .cover-photo.hero-cover { justify-self: center; }
    .cover-photo.hero-cover img { width: 280px; }
    .toc-grid { grid-template-columns: repeat(2, 1fr); }
    .toc-card.feature { grid-column: span 2; min-height: 300px; }
    .toc-card.tall { grid-column: span 2; grid-row: span 1; }
    .footer-inner { grid-template-columns: 1fr 1fr; }
    .footer-brand { grid-column: span 2; }
}

@media (max-width: 640px) {
    .masthead-nav { display: none; }
    .menu-toggle { display: block; }
    .masthead-inner { flex-wrap: wrap; }
    .toc-grid { grid-template-columns: 1fr; }
    .toc-card.feature, .toc-card.tall, .toc-card { grid-column: span 1; }
    .promo, .promo.inline { grid-template-columns: 1fr; text-align: center; }
    .promo-plate { margin: 0 auto; }
    .footer-inner { grid-template-columns: 1fr; }
    .footer-brand { grid-column: span 1; }
}

.masthead-nav.is-open {
    display: flex;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 18px 28px 22px;
    gap: 16px;
}

/* ============================================================
   Ридер номера — постраничный просмотр реальных полос PDF
   ============================================================ */

.reader-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.reader-bar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    font-family: var(--sans);
}

.reader-back {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--ink-soft);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}
.reader-back:hover { color: var(--accent-dark); }

.reader-title {
    font-family: var(--serif-display);
    font-weight: 600;
    font-size: 1rem;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reader-toc-toggle {
    font-family: var(--sans);
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ink-soft);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 16px;
    cursor: pointer;
    white-space: nowrap;
}
.reader-toc-toggle:hover { border-color: var(--ink-faint); }

.reader-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.reader-page-count {
    font-family: var(--sans);
    font-size: 0.86rem;
    color: var(--ink-faint);
    white-space: nowrap;
    min-width: 64px;
    text-align: right;
}

.reader-stage {
    max-width: 880px;
    margin: 0 auto;
    padding: 34px 20px 30px;
}

.reader-page-frame {
    position: relative;
    background: var(--surface);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
    line-height: 0;
}

.reader-page-frame img {
    width: 100%;
    height: auto;
    display: block;
}

.reader-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    margin-top: 22px;
}

.reader-nav-btn {
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.92rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 11px 20px;
    cursor: pointer;
    color: var(--ink);
}
.reader-nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); }
.reader-nav-btn:disabled { opacity: 0.35; cursor: default; }

.reader-jump {
    font-family: var(--sans);
    font-size: 0.86rem;
    color: var(--ink-faint);
}

.reader-thumbs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    max-width: 1180px;
    margin: 0 auto;
    padding: 4px 24px 40px;
    scrollbar-width: thin;
}

.reader-thumb {
    flex-shrink: 0;
    width: 64px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.55;
    line-height: 0;
    transition: opacity .15s ease, border-color .15s ease;
}
.reader-thumb img { width: 100%; display: block; }
.reader-thumb:hover { opacity: 0.85; }
.reader-thumb.is-active { opacity: 1; border-color: var(--accent); }

.reader-toc-panel {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(20, 18, 14, .38);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 8vh 20px;
}
.reader-toc-panel.is-open { display: flex; }

.reader-toc-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 460px;
    width: 100%;
    max-height: 78vh;
    overflow-y: auto;
    padding: 30px;
}

.reader-toc-card h3 {
    font-family: var(--serif-display);
    margin: 0 0 6px;
    font-size: 1.2rem;
}
.reader-toc-card .toc-note {
    font-family: var(--sans);
    font-size: 0.84rem;
    color: var(--ink-faint);
    margin: 0 0 18px;
}

.reader-toc-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.reader-toc-item {
    display: flex;
    align-items: baseline;
    gap: 12px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-radius: 8px;
    padding: 10px 10px;
    cursor: pointer;
    font-family: var(--sans);
    color: var(--ink);
}
.reader-toc-item:hover { background: var(--bg-alt); }
.reader-toc-item .n {
    font-family: var(--serif-display);
    font-weight: 600;
    color: var(--accent-dark);
    font-size: 0.9rem;
    min-width: 34px;
}
.reader-toc-item .label { font-size: 0.94rem; }

.reader-toc-close {
    display: block;
    margin: 18px auto 0;
    background: none;
    border: none;
    color: var(--ink-faint);
    font-family: var(--sans);
    font-size: 0.86rem;
    cursor: pointer;
}

@media (max-width: 640px) {
    .reader-title { display: none; }
    .reader-page-count { min-width: auto; }
    .reader-thumb { width: 48px; }
}
