/* ==========================================================================
   Қос тілді кітапхана / Двуязычная библиотека: editorial theme
   ========================================================================== */

/* ---- Fonts (self-hosted, OFL) -------------------------------------------
   *-core-*: one subset per face with Latin, Russian Cyrillic and every Kazakh letter
   (ә ғ қ ң ө ұ ү һ і); built with fontTools, see CHANGELOG. The stock latin-ext and
   cyrillic-ext files load only for rarer characters. Faces are checked last-defined
   first, so the core faces come last and win where ranges overlap. All faces of one
   family+style share identical descriptors, or the browser will not combine them. */
@font-face { font-family: "Literata"; font-style: normal; font-weight: 400 750; font-display: swap;
    src: url(fonts/literata-latin-ext-wght-normal.woff2) format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Literata"; font-style: normal; font-weight: 400 750; font-display: swap;
    src: url(fonts/literata-cyrillic-ext-wght-normal.woff2) format("woff2");
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "Literata"; font-style: italic; font-weight: 400 600; font-display: swap;
    src: url(fonts/literata-latin-ext-wght-italic.woff2) format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Literata"; font-style: italic; font-weight: 400 600; font-display: swap;
    src: url(fonts/literata-cyrillic-ext-wght-italic.woff2) format("woff2");
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
    src: url(fonts/inter-latin-ext-wght-normal.woff2) format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
    src: url(fonts/inter-cyrillic-ext-wght-normal.woff2) format("woff2");
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "Literata"; font-style: normal; font-weight: 400 750; font-display: swap;
    src: url(fonts/literata-core-normal.woff2) format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0301, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20B8, U+2116, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD, U+0400-045F, U+0490-0493, U+049A-049B, U+04A2-04A3, U+04AE-04B1, U+04BA-04BB, U+04D8-04D9, U+04E8-04E9; }
@font-face { font-family: "Literata"; font-style: italic; font-weight: 400 600; font-display: swap;
    src: url(fonts/literata-core-italic.woff2) format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0301, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20B8, U+2116, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD, U+0400-045F, U+0490-0493, U+049A-049B, U+04A2-04A3, U+04AE-04B1, U+04BA-04BB, U+04D8-04D9, U+04E8-04E9; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
    src: url(fonts/inter-core-normal.woff2) format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0301, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20B8, U+2116, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD, U+0400-045F, U+0490-0493, U+049A-049B, U+04A2-04A3, U+04AE-04B1, U+04BA-04BB, U+04D8-04D9, U+04E8-04E9; }
/* Metric-matched fallbacks so the swap does not reflow text. */
@font-face { font-family: "Literata Fallback"; src: local("Times New Roman"), local("Liberation Serif"), local("Georgia");
    size-adjust: 106%; ascent-override: 111%; descent-override: 29%; line-gap-override: 0%; }
@font-face { font-family: "Inter Fallback"; src: local("Arial"), local("Liberation Sans"), local("Helvetica");
    size-adjust: 94%; ascent-override: 103%; descent-override: 26%; line-gap-override: 0%; }

/* ---- Tokens -------------------------------------------------------------- */
:root {
    color-scheme: light;
    --bg: #FAF8F4;
    --surface: #FFFFFF;
    --text: #1B1B1B;
    --muted: #6B6B6B;
    --rule: #E6E1D8;
    --accent: #B3261E;
    --accent-ink: #FFFFFF;
    --accent-soft: rgba(179, 38, 30, .07);
    --tr-bg: #F2EFE8;
    --tr-text: #33302B;
    --hover: #F3EFE7;
    --mark: #F7E2B8;
    --shadow: 0 10px 30px rgba(27, 27, 27, .10), 0 1px 3px rgba(27, 27, 27, .08);

    --serif: "Literata", "Literata Fallback", Georgia, "Times New Roman", serif;
    --sans: "Inter", "Inter Fallback", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

    --reading-scale: 1;
    --fs-body: clamp(1.125rem, 1.06rem + .3vw, 1.25rem);
    --fs-lede: clamp(1.25rem, 1.12rem + .55vw, 1.5rem);
    --fs-h1: clamp(2rem, 1.45rem + 2.4vw, 3.25rem);
    --fs-h2: clamp(1.375rem, 1.2rem + .75vw, 1.75rem);
    --fs-ui: .9375rem;
    --measure: 680px;
    --gutter: clamp(16px, 4vw, 32px);
    --header-h: 60px;
    --header-offset: var(--header-h);
    --radius: 6px;
}
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #1A1815;
    --surface: #23201C;
    --text: #ECE6DC;
    --muted: #A39C91;
    --rule: #3A352E;
    --accent: #F0857A;
    --accent-ink: #1A1815;
    --accent-soft: rgba(240, 133, 122, .10);
    --tr-bg: #2A2621;
    --tr-text: #D9D2C6;
    --hover: #25221E;
    --mark: #5A4526;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .4);
}

/* ---- Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 var(--fs-body)/1.7 var(--serif);
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    overflow-wrap: break-word;
    min-height: 100vh;
    display: flex; flex-direction: column;
}
main { flex: 1 0 auto; padding-bottom: 4rem; outline: none; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:not(:hover) { text-decoration: none; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
img, svg { display: block; }
.icon { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--mark); color: var(--text); }
mark { background: var(--mark); color: var(--text); border-radius: 2px; padding: 0 .1em; }
[hidden] { display: none !important; }

.wrap { max-width: calc(var(--measure) + 2 * var(--gutter) + 80px); margin: 0 auto; padding: 0 var(--gutter); }
.wrap-wide { max-width: calc(1200px + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--muted); }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: var(--gutter); top: -100px; z-index: 200;
    background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: var(--radius);
    font: 600 var(--fs-ui) var(--sans);
}
.skip-link:focus { top: .5rem; }

/* Small letter-spaced sans labels */
.kicker, .label {
    font: 650 .75rem/1.4 var(--sans);
    letter-spacing: .12em; text-transform: uppercase;
}
.kicker { color: var(--accent); margin-bottom: .75rem; }
.kicker a { color: inherit; }
.label { color: var(--text); }
.meta { font: 400 .875rem/1.5 var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }
.subtitle {
    display: block; margin-top: .35em;
    font-size: .52em; font-weight: 400; line-height: 1.35; color: var(--muted); letter-spacing: 0;
}

/* ---- Buttons & controls -------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: .45em;
    padding: .6em 1.15em; border-radius: 999px; border: 1px solid var(--accent);
    background: var(--accent); color: var(--accent-ink);
    font: 600 var(--fs-ui)/1.2 var(--sans); cursor: pointer; text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn .icon { width: 18px; height: 18px; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--rule); }
.btn-ghost:hover { border-color: var(--text); filter: none; }
.link-quiet {
    display: inline-flex; align-items: center; gap: .35em;
    font: 500 var(--fs-ui) var(--sans); color: var(--text);
}
.link-quiet .icon { width: 18px; height: 18px; color: var(--accent); }
.link-quiet:hover { color: var(--accent); }

.icon-btn {
    display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
    border: 0; border-radius: 999px; background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn[aria-expanded="true"] { background: var(--hover); color: var(--accent); }
.aa { font: 600 1rem/1 var(--serif); letter-spacing: -.02em; }

.popover-wrap { position: relative; }
.popover {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
    min-width: 220px; padding: .75rem;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow);
    font: 400 var(--fs-ui)/1.4 var(--sans);
}
.popover-title { font-weight: 600; font-size: .8125rem; color: var(--muted); margin-bottom: .5rem; }

/* Font-size control */
.fontctl { display: inline-flex; align-items: center; gap: .25rem; font: 500 .875rem/1 var(--sans); }
.fontctl-btn {
    width: 36px; height: 34px; display: inline-grid; place-items: center; cursor: pointer;
    border: 1px solid var(--rule); background: var(--surface); color: var(--text); border-radius: var(--radius);
    font: 600 .875rem/1 var(--sans);
}
.fontctl-btn:hover:not(:disabled) { border-color: var(--text); }
.fontctl-btn:disabled { opacity: .4; cursor: not-allowed; }
.fontctl-val { min-width: 4.2em; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); }
.fontctl-reset {
    margin-left: .25rem; padding: .3rem .5rem; border: 0; background: none; cursor: pointer;
    color: var(--accent); font: 500 .8125rem/1 var(--sans); border-radius: var(--radius);
}
.fontctl-reset:hover { text-decoration: underline; text-underline-offset: .2em; }
.aa-panel .fontctl { flex-wrap: wrap; }

/* ---- Header -------------------------------------------------------------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--rule);
    transition: transform .28s ease;
}
.site-header.is-hidden { transform: translateY(-100%); }
.header-bar {
    display: flex; align-items: center; gap: .5rem 1.5rem;
    min-height: var(--header-h);
}
.brand {
    font: 700 clamp(1.05rem, .95rem + .5vw, 1.3rem)/1.15 var(--serif);
    letter-spacing: -.01em; color: var(--text); text-decoration: none; margin-right: auto;
    min-width: 0;
}
.brand:hover { color: var(--accent); }
.header-menu { display: flex; align-items: center; gap: 1.5rem; }
.nav { display: flex; gap: 1.25rem; font: 500 var(--fs-ui) var(--sans); }
.nav a { color: var(--text); padding: .25rem 0; }
.nav a:hover { color: var(--accent); }
.header-tools { display: flex; align-items: center; gap: .125rem; }

.lang-switch {
    display: inline-flex; padding: 2px; border: 1px solid var(--rule); border-radius: 999px;
    font: 600 .75rem/1 var(--sans); letter-spacing: .06em;
}
.lang-switch a { padding: .4rem .65rem; border-radius: 999px; color: var(--muted); }
.lang-switch a:hover { color: var(--text); text-decoration: none; }
.lang-switch a.active { background: var(--text); color: var(--bg); }

.theme-toggle .icon + .icon { display: none; }
[data-theme="dark"] .theme-toggle .icon { display: none; }
[data-theme="dark"] .theme-toggle .icon + .icon { display: block; }
.menu-toggle { display: none; }
.menu-toggle .icon + .icon { display: none; }
.menu-toggle[aria-expanded="true"] .icon { display: none; }
.menu-toggle[aria-expanded="true"] .icon + .icon { display: block; }

.header-search { display: flex; gap: .5rem; padding-bottom: .75rem; }
.js .search-toggle { display: inline-grid; }
.search-toggle { display: none; }
.js .header-search { display: none; }
.js .site-header.search-open .header-search { display: flex; }
.header-search input, .search-big input, .goto input {
    min-width: 0; font: 400 1rem/1.4 var(--sans); color: var(--text); background: var(--surface);
}
.header-search input {
    flex: 1; padding: .6rem .9rem; border: 1px solid var(--rule); border-radius: 999px;
}

@media (max-width: 859px) {
    .js .menu-toggle { display: inline-grid; }
    .js .header-menu {
        display: none; position: absolute; left: 0; right: 0; top: 100%;
        flex-direction: column; align-items: stretch; gap: 1rem;
        padding: 1rem var(--gutter) 1.5rem; background: var(--bg);
        border-bottom: 1px solid var(--rule); box-shadow: var(--shadow);
    }
    .js .site-header.menu-open .header-menu { display: flex; }
    .js .nav { flex-direction: column; gap: 0; }
    .js .nav a { padding: .75rem 0; border-bottom: 1px solid var(--rule); font-size: 1.0625rem; }
    .js .lang-switch { align-self: flex-start; }
    html:not(.js) .header-bar { flex-wrap: wrap; padding: .5rem 0; }
    html:not(.js) .header-menu { flex-wrap: wrap; gap: .75rem; }
}
@media (max-width: 400px) {
    .header-bar { gap: .25rem; }
    .icon-btn { width: 36px; height: 36px; }
    .brand { font-size: 1rem; }
}

/* ---- Footer -------------------------------------------------------------- */
.site-footer {
    border-top: 1px solid var(--rule); padding: 2.5rem 0 3rem;
    font: 400 .875rem/1.6 var(--sans); color: var(--muted);
}
.footer-grid { display: grid; gap: 1.5rem; }
.footer-brand { font: 700 1.25rem/1.2 var(--serif); color: var(--text); margin-bottom: .5rem; }
.footer-about { max-width: 42ch; }
.footer-links, .footer-langs { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.footer-links a, .footer-langs a { color: var(--text); }
.footer-langs a[aria-current] { color: var(--accent); }
@media (min-width: 860px) {
    .footer-grid { grid-template-columns: 2fr 1fr 1fr; align-items: start; }
    .footer-links { flex-direction: column; }
}

/* ---- Shared page pieces -------------------------------------------------- */
.page-head { padding: clamp(2rem, 5vw, 3.5rem) 0 1.5rem; }
.page-head h1 { font-size: var(--fs-h1); }
.page-head .meta { margin-top: .5rem; }
.empty {
    padding: 2.5rem 0; text-align: center; color: var(--muted);
    font: italic 1.125rem/1.6 var(--serif); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.empty p + p { margin-top: .5rem; font-style: normal; font-family: var(--sans); font-size: var(--fs-ui); }

.search-big {
    display: flex; align-items: center; gap: .5rem; max-width: 640px;
    padding: .375rem .375rem .375rem 1rem; margin-top: 1.5rem;
    background: var(--surface); border: 1px solid var(--rule); border-radius: 999px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.search-big:focus-within { border-color: var(--text); }
.search-big-icon { color: var(--muted); }
.search-big input { flex: 1; border: 0; background: transparent; padding: .55rem 0; font-size: 1.0625rem; }
.search-big input:focus { outline: none; }
.search-big input::-webkit-search-cancel-button { cursor: pointer; }

.chip-grid { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
    display: inline-flex; align-items: center; gap: .4em;
    padding: .4em .9em; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface);
    font: 500 .875rem/1.3 var(--sans); color: var(--text);
}
.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pill {
    display: inline-block; flex: none; white-space: nowrap; min-width: 1.9em; padding: .1em .5em; border-radius: 999px;
    background: var(--tr-bg); color: var(--muted); text-align: center;
    font: 500 .75rem/1.5 var(--sans); font-variant-numeric: tabular-nums;
}

.card-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .card-grid { grid-template-columns: repeat(3, 1fr); } }
.card-link {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    padding: 1.1rem 1.25rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
    color: var(--text);
}
.card-link:hover { border-color: var(--text); text-decoration: none; }
.card-link:hover .card-arrow { color: var(--accent); transform: translateX(3px); }
.card-arrow { font: 400 1.25rem/1 var(--sans); color: var(--muted); transition: transform .2s; }

.pager {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    margin: 2rem 0; padding: 1rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
    font: 500 var(--fs-ui) var(--sans);
}
.pager a { color: var(--text); }
.pager a:hover { color: var(--accent); }

.goto { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; font: 400 .875rem var(--sans); }
.goto label { color: var(--muted); }
.goto input { width: 8.5rem; padding: .35rem .6rem; border: 1px solid var(--rule); border-radius: var(--radius); font-size: .875rem; }
.goto button {
    padding: .35rem .8rem; border: 1px solid var(--rule); border-radius: var(--radius);
    background: transparent; color: var(--text); cursor: pointer; font: 500 .875rem var(--sans);
}
.goto button:hover { border-color: var(--text); }

/* ---- Home ---------------------------------------------------------------- */
.btn-lg { padding: .8em 1.5em; font-size: 1rem; }

/* ---- Home: landing ------------------------------------------------------- */
.landing-hero {
    text-align: center; padding: clamp(2.5rem, 7vw, 5rem) 0 clamp(2rem, 5vw, 3rem);
}
.landing-title {
    max-width: 16em; margin: 0 auto;
    font-size: clamp(2.25rem, 1.3rem + 4.2vw, 4.25rem); font-weight: 750; letter-spacing: -.025em; line-height: 1.06;
    text-wrap: balance;
}
.landing-sub {
    max-width: 34em; margin: 1.25rem auto 0;
    font: italic 400 var(--fs-lede)/1.5 var(--serif); color: var(--muted); text-wrap: pretty;
}
.cta-row { display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem; margin-top: 2rem; }
.landing-hero .search-big { margin: 1.75rem auto 0; }

.stats { border-block: 3px double var(--rule); }
.stats dl { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; }
.stats dl > div {
    display: flex; flex-direction: column-reverse; align-items: center; gap: .15rem;
    padding: 1.25rem .5rem; text-align: center;
}
.stats dl > div + div { border-left: 1px solid var(--rule); }
.stats dd { margin: 0; font: 700 clamp(1.3125rem, 1rem + 2vw, 2.5rem)/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.stats dt { font: 500 .8125rem/1.3 var(--sans); color: var(--muted); }

.demo {
    display: grid; gap: 1.25rem 3rem; max-width: 1040px;
    margin: clamp(2.5rem, 6vw, 4rem) auto 0; padding: clamp(1.25rem, 4vw, 2.5rem);
    background: var(--surface); border: 1px solid var(--rule); border-top: 3px solid var(--accent);
    border-radius: 0 0 var(--radius) var(--radius);
}
@media (min-width: 900px) { .demo { grid-template-columns: 15rem 1fr; } }
.demo-head .kicker { margin-bottom: .5rem; }
.demo-hint { font: 400 .9375rem/1.55 var(--sans); color: var(--muted); }
.demo-source { color: var(--muted); margin-bottom: .6rem; }
.demo-body { font-size: calc(var(--fs-body) * var(--reading-scale)); min-width: 0; }
.demo-body p.para { margin-bottom: 1.1em; }
.demo-more { display: inline-flex; margin-top: .25rem; font: 500 var(--fs-ui) var(--sans); }

.steps, .benefits { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.5rem 2rem; }
@media (min-width: 640px) { .benefits { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.steps { counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding-left: 3.25rem; }
.steps li::before {
    content: counter(step); position: absolute; left: 0; top: 0;
    display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent); font: 700 1rem/1 var(--sans);
}
.steps h3, .benefits h3 { font-size: 1.25rem; margin-bottom: .4rem; }
.steps p, .benefits p { font: 400 .9375rem/1.6 var(--sans); color: var(--muted); }
.benefits li { padding: 1.25rem 1.5rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }

.hero {
    margin: clamp(2rem, 5vw, 3.5rem) auto 0; max-width: 880px;
    padding: clamp(1.5rem, 5vw, 3rem); background: var(--surface);
    border: 1px solid var(--rule); border-top: 3px solid var(--accent); border-radius: 0 0 var(--radius) var(--radius);
}
.hero .kicker { display: flex; flex-wrap: wrap; gap: .5em; }
.hero .kicker-label { color: var(--muted); }
.hero-title { font-size: clamp(1.75rem, 1.2rem + 2.3vw, 2.875rem); line-height: 1.12; }
.hero-title a { color: var(--text); }
.hero-title a:hover { color: var(--accent); }
.hero .subtitle { font-size: 1.125rem; }
.hero-lede { margin-top: 1rem; font: italic 400 var(--fs-lede)/1.55 var(--serif); color: var(--muted); }
.hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.5rem; margin-top: 1.75rem; }

.home-section { margin-top: clamp(2.5rem, 6vw, 4rem); }
.section-head {
    display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
    padding-top: .75rem; margin-bottom: 1.25rem; border-top: 1px solid var(--text);
}
.home-links .goto { margin-top: 1.5rem; justify-content: center; }

/* ---- Editorial list rows ------------------------------------------------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row { padding: 1.35rem 0; border-bottom: 1px solid var(--rule); }
.row:first-child { border-top: 1px solid var(--rule); }
.row .kicker { margin-bottom: .4rem; }
.row-title { font-size: clamp(1.1875rem, 1.1rem + .4vw, 1.375rem); font-weight: 600; line-height: 1.3; }
.row-title a { color: var(--text); }
.row-title a:hover { color: var(--accent); text-decoration: underline; }
.row-title .subtitle { font-size: .75em; }
.row-lede {
    margin-top: .35rem; color: var(--muted); font-size: 1rem; line-height: 1.55;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
@media (min-width: 640px) { .row-lede { -webkit-line-clamp: 1; line-clamp: 1; } }
.row .meta { margin-top: .4rem; }
.row-id { font-variant-numeric: tabular-nums; }
.results-block { margin-top: 2rem; }
.results-block > .label { margin-bottom: 1rem; }

/* ---- Topics index -------------------------------------------------------- */
.page-topics .search-big { max-width: none; margin-top: 0; padding-block: .6rem; }
.page-topics .search-big input { font-size: 1.1875rem; }
.alpha {
    display: flex; flex-wrap: wrap; gap: .25rem; margin: 1.5rem 0 1rem;
    font: 600 .8125rem/1 var(--sans);
}
.alpha a {
    display: inline-grid; place-items: center; min-width: 2rem; height: 2rem; padding: 0 .35rem;
    border-radius: var(--radius); color: var(--text); border: 1px solid var(--rule); background: var(--surface);
}
.alpha a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.letter-group { scroll-margin-top: calc(var(--header-offset) + 1rem); }
.letter {
    position: sticky; top: var(--header-offset); z-index: 5;
    padding: .6rem 0 .35rem; margin-top: 1.25rem;
    background: var(--bg); border-bottom: 1px solid var(--rule);
    font: 650 1.5rem/1.2 var(--serif); color: var(--accent);
    transition: top .28s ease;
}
.topic-list { list-style: none; margin: .5rem 0 0; padding: 0; columns: 1; column-gap: 2.5rem; }
@media (min-width: 640px) { .topic-list { columns: 2; } }
@media (min-width: 1024px) { .topic-list { columns: 3; } }
.topic-list li {
    break-inside: avoid; display: flex; justify-content: space-between; align-items: baseline; gap: .75rem;
    padding: .4rem 0; border-bottom: 1px dotted var(--rule); font-size: 1rem; line-height: 1.4;
}
.topic-list a { color: var(--text); }
.topic-list a:hover { color: var(--accent); }
/* Only the first topics come with the page; app.js fills the rest (see _topic_list.php).
   --n1..3 = the group's rows at 1, 2 and 3 columns, so a pending list keeps its final height,
   and off-screen groups skip layout entirely once filled. */
.page-topics { --topic-row: calc(2.2rem + 1px); }
.page-topics .letter-group { --topic-rows: var(--n1); }
@media (min-width: 640px) { .page-topics .letter-group { --topic-rows: var(--n2); } }
@media (min-width: 1024px) { .page-topics .letter-group { --topic-rows: var(--n3); } }
.letter-group { content-visibility: auto; contain-intrinsic-block-size: auto calc(var(--topic-rows) * var(--topic-row) + 4.5rem); }
.topic-list[aria-busy="true"] {
    /* A fixed height with column-fill: auto keeps inline items in the first column, where they end up. */
    height: calc(var(--topic-rows) * var(--topic-row)); column-fill: auto; overflow: hidden;
    background: repeating-linear-gradient(to bottom, transparent 0 calc(var(--topic-row) - 1px), var(--rule) calc(var(--topic-row) - 1px) var(--topic-row));
}
.topic-list[aria-busy="true"] li { background: var(--bg); }
.topic-list .topic-list-error { justify-content: flex-start; gap: 1rem; color: var(--muted); font-family: var(--sans); }
.topic-filter-form.is-loading .search-big-icon { animation: topics-loading 1s ease-in-out infinite alternate; }
@keyframes topics-loading { to { opacity: .3; } }

/* ---- Article ------------------------------------------------------------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 100; pointer-events: none; }
.progress-bar {
    display: block; height: 100%; background: var(--accent);
    transform: scaleX(0); transform-origin: 0 50%; will-change: transform;
}

.article-layout { padding-top: clamp(1.75rem, 5vw, 3.5rem); }
.article { max-width: var(--measure); margin: 0 auto; }
.toc-side { display: none; }
@media (min-width: 1200px) {
    .article-layout.has-toc {
        display: grid; grid-template-columns: minmax(0, 1fr) var(--measure) minmax(0, 1fr); gap: 0 3rem;
    }
    .has-toc .article { grid-column: 2; margin: 0; }
    .toc-side {
        display: block; grid-column: 1; grid-row: 1; justify-self: end; width: 100%; max-width: 240px;
        position: sticky; top: calc(var(--header-offset) + 4.5rem); align-self: start;
        max-height: calc(100vh - var(--header-offset) - 6rem); overflow: auto;
        padding-top: .5rem; transition: top .28s ease;
    }
    .has-toc .toc-inline { display: none; }
}
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; font: 400 .875rem/1.4 var(--sans); }
.toc li { counter-increment: toc; }
.toc a {
    display: flex; gap: .6rem; padding: .4rem 0 .4rem .75rem; color: var(--muted);
    border-left: 2px solid var(--rule);
}
.toc a::before { content: counter(toc, decimal-leading-zero); font-variant-numeric: tabular-nums; opacity: .7; }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--text); border-left-color: var(--accent); font-weight: 600; }
.toc-side .label { margin-bottom: .75rem; color: var(--muted); }
.toc-inline { margin: 1.5rem 0 0; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
.toc-inline summary {
    padding: .8rem 1rem; cursor: pointer; list-style-position: inside;
    font: 650 .75rem/1.4 var(--sans); letter-spacing: .12em; text-transform: uppercase;
}
.toc-inline nav { padding: 0 1rem 1rem; }

.article-title {
    font-size: calc(var(--fs-h1) * var(--reading-scale)); font-weight: 700; line-height: 1.12; letter-spacing: -.02em;
}
.article-title .subtitle { font-size: .5em; font-weight: 400; font-style: italic; }
.lede {
    margin-top: 1.25rem;
    font: italic 400 calc(var(--fs-lede) * var(--reading-scale))/1.5 var(--serif); color: var(--muted);
}
.tags { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
.tags a { font: 500 .8125rem/1.6 var(--sans); color: var(--muted); }
.tags a:hover { color: var(--accent); }
.meta-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem;
    margin-top: 1.5rem; padding: .75rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.meta-row .meta { margin-right: auto; }
.meta-row .btn { padding: .45em .9em; font-size: .875rem; }
@media (max-width: 639px) {
    .meta-row .fontctl { order: 3; flex-basis: 100%; }
    .alpha { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .5rem; scrollbar-width: thin; }
    .alpha a { flex: none; }
}
.source { margin-top: .75rem; font-size: .8125rem; }
.source a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--rule); }
.source a:hover { color: var(--accent); }

.readbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
    margin-top: 1.25rem; padding: .55rem 0;
    background: var(--bg); border-bottom: 1px solid var(--rule);
    font: 400 .8125rem/1.4 var(--sans); color: var(--muted);
}
.readbar-hint { flex: 1 1 14rem; }
.toggle-all {
    padding: .35rem .8rem; border-radius: 999px; cursor: pointer;
    background: transparent; border: 1px solid var(--accent); color: var(--accent);
    font: 600 .8125rem/1.2 var(--sans);
}
.toggle-all:hover { background: var(--accent-soft); }
.toggle-all[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.article-body { font-size: calc(var(--fs-body) * var(--reading-scale)); margin-top: 1.5rem; }
.article-body section { scroll-margin-top: calc(var(--header-offset) + 1rem); }
.article-body h2 {
    font-size: calc(var(--fs-h2) * var(--reading-scale)); font-weight: 650;
    margin: 2.25em 0 .8em; padding-top: 1em; border-top: 1px solid var(--rule);
}
.article-body section:first-child h2 { margin-top: .75em; padding-top: 0; border-top: 0; }

/* Clickable paragraphs */
.para {
    cursor: pointer; border-radius: 4px;
    margin-inline: -.5rem; padding-inline: .5rem;
    transition: background-color .15s ease;
}
.para:hover { background: var(--hover); }
.para:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.para.is-tr-open { background: var(--hover); }
p.para { margin-block: 0 1.1em; padding-block: .1em; }
.title-toggle { display: block; padding-block: .05em; }

/* Translation margin-note: grid-rows 0fr→1fr gives a smooth height transition */
.tr {
    display: grid; grid-template-rows: 0fr; opacity: 0;
    transition: grid-template-rows .3s ease, opacity .25s ease;
}
.tr.is-open { grid-template-rows: 1fr; opacity: 1; }
.tr-inner { min-height: 0; overflow: hidden; }
.tr-box {
    margin: -.4em 0 1.25em; padding: .85em 1.1em .9em;
    background: var(--tr-bg); border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
    font: 400 .875em/1.65 var(--sans); color: var(--tr-text);
}
.article-head .tr-box { margin-top: .6em; font-size: calc(1.0625rem * var(--reading-scale)); font-weight: 500; }

/* EN button under each paragraph: shows the translation inline (hidden while it is open) */
.tr-tools { display: flex; justify-content: flex-end; margin: -1em 0 .35em; }
.article-head .tr-tools { margin: .25em 0 0; }
.tr-btn {
    min-width: 28px; min-height: 24px; padding: .2em .5em; cursor: pointer;
    border: 1px solid var(--rule); border-radius: 3px; background: transparent; color: var(--muted);
    font: 700 .6875rem/1 var(--sans); letter-spacing: .1em;
    transition: color .15s ease, border-color .15s ease;
}
.tr-btn:hover, .tr-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }

/* Translation modal: a paragraph click shows its translation here */
.tr-modal {
    width: min(36rem, calc(100vw - 2rem)); max-height: 80vh; overflow: auto;
    margin: auto; padding: 0;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow);
    animation: tr-modal-in .2s ease;
}
.tr-modal::backdrop { background: rgba(0, 0, 0, .45); }
@keyframes tr-modal-in { from { opacity: 0; transform: translateY(8px); } }
.tr-modal-head {
    position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .5rem .5rem .5rem 1.1rem; background: var(--surface); border-bottom: 1px solid var(--rule);
}
.tr-modal-head .label { margin: 0; }
.tr-modal-body {
    padding: 1rem 1.1rem 1.25rem;
    font: 400 calc(1rem * var(--reading-scale))/1.65 var(--sans); color: var(--tr-text);
}

/* End of article */
.article-end { margin-top: 3.5rem; padding-top: 2rem; border-top: 3px double var(--rule); }
.end-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.article-end .chips { margin-top: 1.5rem; }
.more { margin-top: 2.5rem; }
.more > .label { padding-top: .75rem; border-top: 1px solid var(--text); margin-bottom: 1.25rem; }
.more .card-grid { grid-template-columns: 1fr; gap: 0; }
@media (min-width: 640px) { .more .card-grid { grid-template-columns: repeat(2, 1fr); gap: 0 2rem; } }
.card { padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.card-title { font: 600 1.125rem/1.3 var(--serif); color: var(--text); }
.card-title:hover { color: var(--accent); }
.card-lede {
    margin-top: .35rem; font-size: .9375rem; line-height: 1.5; color: var(--muted);
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.card .meta { margin-top: .35rem; font-size: .8125rem; }

/* Share popover */
.share-panel { min-width: 230px; padding: .4rem; display: grid; }
.share-panel[hidden] { display: none; }
.share-item {
    display: flex; align-items: center; gap: .6rem; width: 100%; padding: .6rem .75rem;
    border: 0; border-radius: var(--radius); background: none; cursor: pointer; text-align: left;
    color: var(--text); font: 500 var(--fs-ui)/1.3 var(--sans);
}
.share-item:hover, .share-item:focus-visible { background: var(--hover); text-decoration: none; }
.share-item .icon { width: 18px; height: 18px; color: var(--accent); }
.article-end .share-panel { right: auto; left: 0; top: auto; bottom: calc(100% + 8px); }

.toast {
    position: fixed; left: 50%; bottom: 1.5rem; z-index: 150; transform: translateX(-50%);
    padding: .7rem 1.1rem; border-radius: 999px; background: var(--text); color: var(--bg);
    font: 500 .875rem/1.3 var(--sans); box-shadow: var(--shadow);
    animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* 404 */
.page-404 { padding-top: clamp(3rem, 10vw, 6rem); text-align: center; }
.page-404 h1 { font-size: var(--fs-h1); }
.page-404 .lede { margin-bottom: 2rem; }
.page-404 .end-actions { justify-content: center; }

/* ---- Motion & print ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
    :root, [data-theme="dark"] {
        --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --rule: #bbb;
        --accent: #000; --tr-bg: #fff; --tr-text: #222; --hover: transparent; --reading-scale: 1;
    }
    body { font-size: 11.5pt; display: block; }
    .site-header, .site-footer, .skip-link, .progress, .readbar, .toc, .popover-wrap,
    .fontctl, .article-end, .toast, .tags, .tr-tools, .tr-modal, .cta-row, .search-big { display: none !important; }
    .article-layout { display: block !important; padding: 0; }
    .article { max-width: none; }
    .article-title { font-size: 22pt; }
    .article-body { font-size: 11.5pt; }
    .meta-row { border: 0; padding: 0; }
    .para { margin-inline: 0; padding-inline: 0; background: none !important; }
    .tr, .tr[hidden] { display: block !important; opacity: 1 !important; }
    .tr-box { margin: 0 0 1em; padding: .2em 0 .2em .8em; border-left: 1.5pt solid #999; font-size: 10pt; break-inside: avoid; }
    a { color: #000; }
    .source a::after { content: " (" attr(href) ")"; font-size: 9pt; }
    h2 { break-after: avoid; }
}
