/* ai-chatboxes · L0 "early print" sheet (two-layer mode, skaryna.ai)
 *
 * Paints .aic-l0-sheet — the wrapper aic_render_two_layer_tabs() and
 * aic_two_layer_l0_standalone() put around every L0 pix-article — as a leaf of
 * a Cyrillic early print: parchment ground, iron-gall ink, cinnabar rubrics.
 *
 * Type: "Fedorovsk CS" is self-hosted by the skaryna child theme (theme.json
 * font family, no external request) and covers the early-Cyrillic letters
 * (ѣ ѡ ѧ ѫ і ꙋ ѻ ѯ ѱ ѳ ѵ, titlo U+0483). Ponomar / Monomakh are named as
 * local fallbacks only; this sheet makes no font request of its own.
 *
 * L0 markup contract (written by bin/deploy_suite.php from L0.md):
 *   p.numbered-line > span.lnum[data-lnum] + span.ltext   one printed line each
 *   .l0-folio         folio / page reference ("л. 1 об.")
 *   .l0-rubric        text printed in red
 *   .l0-initial       a large initial letter
 *   figure.l0-facsimile > img + figcaption              facsimile page
 *   .l0-provenance    source / licence block (sans, small)
 */

.aic-l0-sheet {
    --l0-paper: #f3e8cf;
    --l0-paper-edge: #e4d3ad;
    --l0-ink: #2a1a0c;
    --l0-ink-soft: #5b4630;
    --l0-rubric: #9e2a1c;
    --l0-rule: rgba(94, 64, 32, .28);
    position: relative;
    margin: 0 0 2rem;
    padding: clamp(1.25rem, 4vw, 3rem) clamp(1rem, 5vw, 3.5rem);
    color: var(--l0-ink);
    background-color: var(--l0-paper);
    background-image:
        radial-gradient(ellipse at 50% 45%, rgba(255, 250, 235, .55) 0%, rgba(255, 250, 235, 0) 62%),
        radial-gradient(ellipse at 0% 0%, rgba(150, 105, 50, .16) 0%, rgba(150, 105, 50, 0) 38%),
        radial-gradient(ellipse at 100% 100%, rgba(150, 105, 50, .18) 0%, rgba(150, 105, 50, 0) 40%),
        repeating-linear-gradient(0deg, rgba(120, 90, 50, .025) 0 1px, transparent 1px 3px);
    border: 1px solid var(--l0-paper-edge);
    border-radius: 2px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 10px 28px -14px rgba(60, 35, 10, .45);
    font-family: "Fedorovsk CS", "Ponomar Unicode", "Ponomar", "Monomakh Unicode", "Monomakh", "Source Serif 4", Georgia, serif;
    font-size: clamp(1.12rem, 1.02rem + .45vw, 1.34rem);
    line-height: 1.72;
    font-feature-settings: "liga" 1, "dlig" 1;
    overflow-wrap: anywhere;
}

/* The theme may paint post content in dark mode; a sheet of paper stays paper. */
.aic-l0-sheet,
.aic-l0-sheet p,
.aic-l0-sheet li,
.aic-l0-sheet span { color: var(--l0-ink); }

.aic-l0-sheet a { color: var(--l0-rubric); text-decoration-thickness: 1px; }

/* Headings inside L0 are rewritten by aic_strip_headers() to .aic-stripped-header.hN */
.aic-l0-sheet .aic-stripped-header,
.aic-l0-sheet h1, .aic-l0-sheet h2, .aic-l0-sheet h3, .aic-l0-sheet h4 {
    font-family: inherit;
    color: var(--l0-rubric);
    font-weight: 400;
    letter-spacing: .04em;
    text-align: center;
    line-height: 1.35;
    margin: 1.6em 0 .8em;
}
.aic-l0-sheet .aic-stripped-header.h1, .aic-l0-sheet h1 { font-size: 1.7em; }
.aic-l0-sheet .aic-stripped-header.h2, .aic-l0-sheet h2 { font-size: 1.4em; }
.aic-l0-sheet .aic-stripped-header.h3, .aic-l0-sheet h3 { font-size: 1.18em; }

/* Numbered printed lines */
.aic-l0-sheet p.numbered-line {
    display: grid;
    grid-template-columns: 2.4em 1fr;
    column-gap: .8em;
    margin: 0 0 .9em;
}
.aic-l0-sheet p.numbered-line > .lnum {
    grid-column: 1;
    text-align: right;
    font-family: "Source Serif 4", Georgia, serif;
    font-size: .62em;
    line-height: 2.8;
    color: var(--l0-ink-soft);
    opacity: .75;
    font-variant-numeric: tabular-nums;
    user-select: none;
}
.aic-l0-sheet p.numbered-line > .lnum::before { content: attr(data-lnum); }
.aic-l0-sheet p.numbered-line > .ltext { grid-column: 2; }
.aic-l0-sheet p.numbered-line > br { display: none; }

.aic-l0-sheet .l0-folio {
    display: block;
    margin: 1.4em 0 .6em;
    text-align: center;
    font-family: "Source Serif 4", Georgia, serif;
    font-size: .7em;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--l0-ink-soft);
}
.aic-l0-sheet .l0-folio::before,
.aic-l0-sheet .l0-folio::after { content: " \2767 "; color: var(--l0-rubric); }

.aic-l0-sheet .l0-rubric { color: var(--l0-rubric); }

.aic-l0-sheet .l0-initial {
    float: left;
    font-size: 3.1em;
    line-height: .9;
    margin: .06em .12em 0 0;
    padding: .06em .1em;
    color: var(--l0-rubric);
    border: 1px solid var(--l0-rule);
    background: rgba(158, 42, 28, .05);
}

/* Facsimile pages */
.aic-l0-sheet figure.l0-facsimile {
    margin: 1.8em auto;
    max-width: 640px;
    text-align: center;
}
.aic-l0-sheet figure.l0-facsimile img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--l0-rule);
    box-shadow: 0 6px 18px -10px rgba(60, 35, 10, .55);
    background: #fff;
}
.aic-l0-sheet figure.l0-facsimile figcaption {
    margin-top: .6em;
    font-family: "Source Serif 4", Georgia, serif;
    font-size: .68em;
    line-height: 1.5;
    color: var(--l0-ink-soft);
}

.aic-l0-sheet hr { border: 0; border-top: 1px solid var(--l0-rule); margin: 2em 15%; }

/* Provenance / licence: plain modern type, clearly not part of the print */
.aic-l0-sheet .l0-provenance {
    clear: both;
    margin-top: 2.2em;
    padding-top: 1em;
    border-top: 1px solid var(--l0-rule);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: .64em;
    line-height: 1.55;
    color: var(--l0-ink-soft);
}
.aic-l0-sheet .l0-provenance p { margin: 0 0 .5em; color: var(--l0-ink-soft); }

/* Standalone L0 URL: "back to the reading" line above the sheet */
.aic-l0-backlink {
    font-family: "Source Serif 4", Georgia, serif;
    font-size: .95rem;
    margin: 0 0 1rem;
}
.aic-l0-backlink__layer {
    display: inline-block;
    padding: .05em .5em;
    margin-right: .35em;
    border: 1px solid currentColor;
    border-radius: 2px;
    font-size: .8em;
    letter-spacing: .08em;
}

@media (max-width: 600px) {
    .aic-l0-sheet p.numbered-line { grid-template-columns: 1.6em 1fr; column-gap: .5em; }
}

@media print {
    .aic-l0-sheet { box-shadow: none; background: #fff; }
}

/* ---------------------------------------------------------------------------
 * Two-layer tab bar (.aic-two-layer). The Kant chrome in aic-tabs.css is a
 * 50px round-pill column hung 65px into the left margin and coloured with
 * PixTheme's --pix-main-color, which skaryna.ai does not define (the active
 * pill rendered white-on-cream). Here the nav is a plain segmented bar above
 * the text, in the page's own ink and gold.
 * ------------------------------------------------------------------------- */
.aic-two-layer.aic-vertical-tabs-container {
    display: block;
    margin: 1.25rem 0 0;
    width: auto !important;
}
.aic-two-layer .aic-vertical-tabs-nav {
    position: static;
    display: flex;
    flex-direction: row;
    gap: 0;
    max-height: none;
    overflow: visible;
    margin: 0 0 1.5rem;
    border-bottom: 1px solid #b8963e;
}
.aic-two-layer .aic-vertical-tab-link {
    width: auto;
    height: auto;
    margin: 0 .25rem -1px 0;
    padding: .55rem 1rem .5rem;
    border-radius: 2px 2px 0 0;
    border: 1px solid transparent;
    border-bottom: 1px solid #b8963e;
    background: transparent;
    color: #5b4630;
    font-family: "Source Serif 4", Georgia, serif;
    font-weight: 400;
    font-size: .95rem;
    line-height: 1.2;
    gap: .5rem;
    justify-content: flex-start;
}
.aic-two-layer .aic-vertical-tab-link:hover { background: rgba(184, 150, 62, .10); }
.aic-two-layer .aic-vertical-tab-link:focus-visible { outline: 2px solid #9e2a1c; outline-offset: 2px; }
.aic-two-layer .aic-vertical-tab-link.active {
    background: #f3e8cf;
    color: #1b130b;
    border-color: #b8963e #b8963e #f3e8cf;
}
.aic-two-layer .aic-vertical-tab-link[data-target="tab-l1"].active { background: transparent; border-bottom-color: var(--wp--preset--color--base, #f6efe1); }
.aic-two-layer .aic-layer-code {
    font-family: "Share Tech Mono", ui-monospace, monospace;
    font-size: .78em;
    letter-spacing: .06em;
    padding: .1em .4em;
    border: 1px solid currentColor;
    border-radius: 2px;
}
.aic-two-layer .aic-vertical-tab-link.active .aic-layer-code { color: #9e2a1c; }
.aic-two-layer .aic-vertical-tabs-content { padding: 0; }
.aic-two-layer #tab-l0.aic-tab-pane { margin-right: 0; }
@media (max-width: 600px) {
    .aic-two-layer .aic-vertical-tab-link { padding: .5rem .6rem; font-size: .88rem; }
}

/* The skaryna long-form sheet sets a ch-based measure + justification on body
 * paragraphs; inside the L0 sheet the measure is the sheet itself, and printed
 * lines stay ragged-right as they are transcribed. */
.aic-l0-sheet p,
.aic-l0-sheet p.numbered-line,
.aic-l0-sheet .ltext {
    max-width: none;
    width: auto;
    text-align: left;
    word-spacing: normal;
    hyphens: manual;
}

/* Paragraph marks (¶N) and source-page markers from the transcription */
.aic-l0-sheet .l0-pmark {
    display: block;
    margin: 1.2em 0 .3em;
    font-family: "Source Serif 4", Georgia, serif;
    font-size: .62em;
    letter-spacing: .1em;
    color: var(--l0-rubric);
    opacity: .8;
}
.aic-l0-sheet .l0-page {
    display: inline-block;
    margin: 0 .2em;
    padding: 0 .3em;
    font-family: "Source Serif 4", Georgia, serif;
    font-size: .5em;
    line-height: 1.4;
    vertical-align: .6em;
    color: var(--l0-ink-soft);
    border: 1px solid var(--l0-rule);
    border-radius: 2px;
}

.aic-l0-sheet sup { font-size: .62em; line-height: 0; }

/* L1: early-Cyrillic quotations inside the English reading use the L0 face
 * (the body serif has no ꙋ ѧ ѫ ꙗ, which rendered as tofu), plus a quote figure. */
.aic-two-layer .l1-cu,
.aic-two-layer em.l1-cu {
    font-family: "Fedorovsk CS", "Ponomar Unicode", "Monomakh", "Source Serif 4", serif;
    font-style: normal;
    font-size: 1.08em;
    color: #3a2512;
}
.aic-two-layer figure.l1-quote {
    margin: 1.6em 0;
    padding: 1em 1.25em;
    border-left: 3px solid #9e2a1c;
    background: #f3e8cf;
}
.aic-two-layer figure.l1-quote p.l1-cu { margin: 0 0 .5em; font-size: 1.3em; line-height: 1.5; }
.aic-two-layer figure.l1-quote figcaption { font-style: italic; font-size: .95em; color: #5b4630; }
