/* ==========================================================================
   Corvus Library additions to the Corvus design system v2.
   corvus.css is a byte-for-byte copy of the Hub's (the upstream) and is never
   edited here. This file loads after it and holds only what the Library adds.
   Never restyle a corvus.css class here; add a Library class instead.
   Every colour comes from a corvus.css token. Nothing here names a hue except
   the creator tokens in section 1, which are copied from Command.

   Sections
     1. Tokens: the eight creator colours corvus.css does not define
     2. Global fixes
     3. Admin: shared bits
     4. Admin: language chips (shared with the reader)
     5. Admin: pages, page editor, tracker, creators, bundles, activity
     6. Reader: the public reading page
     7. Reader: bundle
     8. Reader: link unavailable
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Creator tokens.

   corvus.css defines and binds six: Lucia, Lexie, Romy, Kayla, Cherry,
   Katherine. The other eight are copied unchanged from Command's command.css
   (which took Tyra from Studio and Sofia and Yumi from Socials), so a creator
   has one colour in every Corvus app. Anyone without a token keeps the grey
   dot: --creator falls back to --ink-3 in corvus.css. Never add a colour here
   that the design system (docs/Corvus_Design_System_v2.md, section 2.3) does
   not list.

   Keys: data-creator is the `ckey` filter of the creator RECORD's name
   (app/filters.py). A link with only a typed label and no creator record is
   given an empty key on purpose, and so the grey dot.
   -------------------------------------------------------------------------- */
:root {
    --c-tyra: #9b8cff;
    --c-sofia: #17a9cb;
    --c-yumi: #f17c43;
    --c-evie: #ff63a3;
    --c-kada: #00b086;
    --c-leah: #00b512;
    --c-sara: #c778ff;
    --c-vanessa: #f751ff;
}
html[data-theme="light"] {
    --c-tyra: #5b48c9;
    --c-sofia: #02657c;
    --c-yumi: #9e3f00;
    --c-evie: #b60064;
    --c-kada: #006a50;
    --c-leah: #006c06;
    --c-sara: #9300d4;
    --c-vanessa: #a400ac;
}
[data-creator="tyra"]    { --creator: var(--c-tyra); }
[data-creator="sofia"]   { --creator: var(--c-sofia); }
[data-creator="yumi"]    { --creator: var(--c-yumi); }
[data-creator="evie"]    { --creator: var(--c-evie); }
[data-creator="kada"]    { --creator: var(--c-kada); }
[data-creator="leah"]    { --creator: var(--c-leah); }
[data-creator="sara"]    { --creator: var(--c-sara); }
[data-creator="vanessa"] { --creator: var(--c-vanessa); }

/* --------------------------------------------------------------------------
   2. Global fixes (the same two Command, Studio and Socials carry).
   -------------------------------------------------------------------------- */

/* The hidden attribute must beat component display values. */
[hidden] { display: none !important; }

/* Upstream declares `.show-sm { display: none; }` after the 699px rule that
   shows it, so the utility never appears. Restated here until the Hub
   corrects the order. */
@media (max-width: 699px) {
    .show-sm { display: block; margin-top: 4px; }
}

/* --------------------------------------------------------------------------
   3. Admin: shared bits.
   -------------------------------------------------------------------------- */

/* The app name beside the wordmark in the narrow-screen top bar (as Command). */
.wordmark-app { color: var(--ink-3); font-weight: 500; margin-left: 4px; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The KPI strip declares how many figures it carries (copied from Socials:
   upstream `.kpis` is a fixed 6-up grid). Only above 1180px, so upstream's
   own 3-up and 2-up steps keep winning below it. */
@media (min-width: 1181px) {
    .kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 901px) and (max-width: 1180px) {
    .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpis-4 .kpi:nth-child(n) { box-shadow: none; }
    .kpis-4 .kpi:nth-child(even) { box-shadow: inset 1px 0 0 var(--line); }
    .kpis-4 .kpi:nth-child(n+3) { box-shadow: inset 0 1px 0 var(--line); }
    .kpis-4 .kpi:nth-child(even):nth-child(n+3) { box-shadow: inset 1px 0 0 var(--line), inset 0 1px 0 var(--line); }
}
@media (max-width: 900px) {
    .kpis-3 .kpi:last-child { grid-column: 1 / -1; }
}
.kpi-note { font-size: var(--t-sm); color: var(--ink-3); min-height: 17px; }

/* Creator label: the name beside the dot, and the quiet line under it. */
.who-name { font-weight: 600; color: var(--ink); }
.who-sub { display: block; margin-top: 2px; font-size: var(--t-xs); color: var(--ink-3); white-space: normal; }

/* A status that is over (revoked, expired): the word stays, the tint goes. */
.st-off { box-shadow: inset 0 0 0 1px var(--line); }
.st-off b { color: var(--ink-3); font-weight: 500; }

/* Empty state: a short bold line, then one muted sentence saying what to do. */
.empty-lead { display: block; margin-bottom: 4px; color: var(--ink); font-weight: 600; }

/* A share address. Mono is for URLs only. */
.link-url {
    display: inline-block; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    vertical-align: middle;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: var(--t-sm); color: var(--ink-2);
}

/* Copy button: the label turns to "Copied" for a moment (the script toggles .done). */
.copybtn.done { color: var(--good); }
.copybtn.done svg { color: var(--good); }

/* A form that sits under a table inside the same panel. */
.panel-sep { padding: var(--s-4); box-shadow: inset 0 1px 0 var(--line); }
.panel-pad { padding: var(--s-2) var(--s-4) var(--s-4); }

/* Rows that are switched off or not counted (inactive creator, robot preview). */
.tbl tr.is-off td { opacity: 0.55; }

/* Table cells that may wrap: page titles, what was sent. */
.tbl td.wrap { white-space: normal; min-width: 180px; }
.tbl th.check-col, .tbl td.check-col { width: 40px; padding-right: 0; }
.pick { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); cursor: pointer; vertical-align: -3px; }
.flags { letter-spacing: 3px; font-size: var(--t-md); line-height: 1; }

/* --------------------------------------------------------------------------
   4. Language chips. Flags stay (a deliberate exception to section 6 of the
   design system). Inactive: outlined. Active: solid ink, the treatment of
   .btn-primary. Used large on the reader, small in the page editor.
   -------------------------------------------------------------------------- */
.langbar { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.langbar::-webkit-scrollbar { display: none; }
.langchip {
    flex: none; display: inline-flex; align-items: center; gap: 8px;
    height: 38px; padding: 0 14px; border-radius: var(--r-pill);
    font-size: 15px; font-weight: 500; line-height: 1; color: var(--ink-2);
    background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-strong);
    transition: color var(--dur-1), box-shadow var(--dur-1);
}
.langchip:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink-3); }
.langchip[aria-current="true"], .langchip[aria-current="true"]:hover {
    background: var(--ink); color: var(--ink-inverse); box-shadow: none;
}
.langchip .flag { font-size: 17px; line-height: 1; }
.langbar-sm { flex-wrap: wrap; overflow: visible; align-items: center; }
.langbar-sm .langchip { height: 30px; padding: 0 12px; font-size: var(--t-base); background: var(--panel); }
.langbar-sm .langchip[aria-current="true"] { background: var(--ink); }
.langbar-sm .langchip .flag { font-size: 15px; }
.lang-add { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; }

/* --------------------------------------------------------------------------
   5. Admin pages.
   -------------------------------------------------------------------------- */

/* Pages: each topic is its own table, so the columns are fixed or every
   topic would size them differently and nothing would line up down the page. */
.pages-tbl { table-layout: fixed; }
.pages-tbl .col-langs { width: 200px; }
.pages-tbl .col-links { width: 76px; }
.pages-tbl td.wrap { min-width: 0; }
@media (max-width: 699px) { .pages-tbl .col-langs { width: 132px; } }

/* A filter form in the page head wraps on narrow screens instead of clipping. */
@media (max-width: 900px) { .page-head > .head-filter { flex-wrap: wrap; } }
.tbl td.wrap .who { white-space: normal; }
@media (max-width: 699px) { .tbl td.wrap { min-width: 112px; } .tbl td.tight, .tbl th.tight { padding-left: 4px; padding-right: 8px; } }

/* Pages: the topic head carries the icon, the count and the move buttons. */
.topic-ico { font-size: 16px; line-height: 1; }
.topic-tools { display: inline-flex; align-items: center; gap: 6px; }

/* Page editor */
.note-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: var(--s-3); }
.editor-form { margin-top: var(--s-3); }
textarea.control.editor { min-height: 420px; }
textarea.control.cover-box { min-height: 150px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s-3); align-items: start; }
.field-grid .field-wide { grid-column: span 2; }
@media (max-width: 699px) { .field-grid .field-wide { grid-column: auto; } }

/* Tracker: the delivered tick. Empty with a hairline, or a tick on the good tint. */
.tick {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: var(--r-sm);
    background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--good);
    transition: box-shadow var(--dur-1), background var(--dur-1);
}
.tick:hover { box-shadow: inset 0 0 0 1px var(--ink-3); }
.tick.on { background: var(--good-bg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--good) 45%, transparent); }
.tick svg { width: 14px; height: 14px; stroke-width: 2.5; }
.tbl td form { margin: 0; }

/* Bundles: one entry per bundle, hairline between entries. */
.bundle { padding: var(--s-4); box-shadow: inset 0 -1px 0 var(--line); display: flex; flex-direction: column; gap: 8px; scroll-margin-top: 72px; }
.bundle:last-child { box-shadow: none; }
.bundle-top { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.bundle-title { font-size: var(--t-md); font-weight: 600; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.bundle-top .row-actions { margin-left: auto; }
.bundle-meta { font-size: var(--t-sm); color: var(--ink-2); }
.bundle-pages { font-size: var(--t-sm); color: var(--ink-3); line-height: 1.5; }
.bundle .link-url { max-width: 100%; }
.cover-edit > summary { display: inline-block; cursor: pointer; list-style: none; }
.cover-edit > summary::-webkit-details-marker { display: none; }
.cover-edit[open] > summary { margin-bottom: var(--s-3); }

@media (max-width: 900px) {
    .bundle { padding: var(--s-3); }
    .bundle-top .row-actions { margin-left: 0; width: 100%; }
    .link-url { max-width: 200px; }
}

/* --------------------------------------------------------------------------
   6. Reader. A reading page, not a dashboard: one column, 17px body, 1.6
   line height, at most 600px wide (about 65 characters a line; about 40 on a
   phone). Dark only, no scripts. corvus.css sets the dashboard base (13.5px,
   zero margins on headings and paragraphs); everything below is scoped to
   body.reader and puts the reading scale back.
   -------------------------------------------------------------------------- */
body.reader { font-size: 17px; line-height: 1.6; }

.reader .wrap {
    width: 100%; max-width: 600px; margin-inline: auto;
    padding-left: max(20px, var(--safe-left)); padding-right: max(20px, var(--safe-right));
}

.sheet-head { padding-top: calc(28px + var(--safe-top)); box-shadow: inset 0 -1px 0 var(--line); }

/* The mark (the real file, never drawn) beside the document label. */
.doc-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; color: var(--ink-3); font-size: 13.5px; font-weight: 500; line-height: 1; }
.doc-brand img { display: block; width: 33px; height: 28px; flex: none; }

.sheet-title { margin: 0 0 20px; font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; overflow-wrap: anywhere; }
.sheet-head .langbar { padding-bottom: 14px; }

/* "Need another language?" */
.translate { padding-bottom: 16px; }
.translate > summary {
    display: inline-block; padding: 2px 0; cursor: pointer; list-style: none;
    font-size: 14px; color: var(--ink-2);
    text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px;
}
.translate > summary::-webkit-details-marker { display: none; }
.translate > summary:hover { color: var(--ink); text-decoration-color: var(--ink); }
.translate-list { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; }
.translate-list a {
    display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border-radius: var(--r-pill);
    font-size: 14px; font-weight: 500; color: var(--ink-2);
    background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-strong);
}
.translate-list a:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink-3); }
.translate-note { margin: 12px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink-3); }

/* Body copy */
.sheet-body { padding-top: 28px; padding-bottom: 56px; overflow-wrap: break-word; }

.sheet-body h2 {
    margin: 40px 0 12px; padding-top: 28px; box-shadow: inset 0 1px 0 var(--line);
    font-size: 21px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25;
}
.sheet-body h2:first-child { margin-top: 0; padding-top: 0; box-shadow: none; }
.sheet-body h3 { margin: 30px 0 8px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }

/* Take headings ("4 · After the cut — ~3:00–4:00"). The only raised bar on the
   page, so a take is found by shape while scrolling: raised surface, an ink
   rule down the left edge, tabular figures so durations line up. No colour. */
.sheet-body h4 {
    margin: 32px 0 12px; padding: 10px 14px; border-radius: var(--r-sm);
    background: var(--raised); box-shadow: var(--shadow-1), inset 3px 0 0 var(--ink);
    font-size: 16px; font-weight: 600; line-height: 1.35; color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.sheet-body p { margin: 0 0 16px; }
.sheet-body ul, .sheet-body ol { margin: 0 0 20px; padding-left: 22px; }
.sheet-body li { margin-bottom: 7px; }
.sheet-body li::marker { color: var(--ink-3); }
.sheet-body li > ul, .sheet-body li > ol { margin: 7px 0 0; }
.sheet-body strong { font-weight: 600; color: var(--ink); }
.sheet-body em { color: var(--ink-2); }

/* Callouts: a plain panel, muted text, the bold lead in ink. */
.sheet-body blockquote {
    margin: 0 0 24px; padding: 14px 16px; border-radius: var(--r-md);
    background: var(--panel); box-shadow: var(--shadow-1);
    font-size: 16px; color: var(--ink-2);
}
.sheet-body blockquote p:last-child { margin-bottom: 0; }

.sheet-body hr { margin: 36px 0; border: 0; height: 1px; background: var(--line); }

.sheet-body a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--ink-3); text-underline-offset: 3px; overflow-wrap: anywhere; }
.sheet-body a:hover { text-decoration-color: var(--ink); }

.sheet-body code {
    padding: 1px 6px; border-radius: 4px; background: var(--raised);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.875em;
}

/* Reference photos: the full column, nothing drawn round them. */
.sheet-body img {
    display: block; width: 100%; max-width: 100%; height: auto;
    border-radius: var(--r-md); background: var(--panel); margin-bottom: 8px;
}

/* A wide table scrolls inside itself; the page never scrolls sideways. */
.sheet-body table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; margin: 0 0 24px; font-size: 15px; -webkit-overflow-scrolling: touch; }
.sheet-body th, .sheet-body td { padding: 9px 12px 9px 0; text-align: left; vertical-align: top; }
.sheet-body th { font-size: 13px; font-weight: 500; color: var(--ink-3); box-shadow: inset 0 -1px 0 var(--line-strong); }
.sheet-body td { box-shadow: inset 0 -1px 0 var(--line); }
.sheet-body tr:last-child td { box-shadow: none; }

.sheet-foot { padding: 24px 0 calc(44px + var(--safe-bottom)); box-shadow: inset 0 1px 0 var(--line); }
.sheet-foot p { margin: 0; font-size: 14px; color: var(--ink-3); }

.reader ::selection { background: color-mix(in srgb, var(--ink) 28%, transparent); }

@media (max-width: 480px) {
    .sheet-title { font-size: 26px; }
}

/* --------------------------------------------------------------------------
   7. Reader: bundle. Cover note, contents list, then each page as a section.
   -------------------------------------------------------------------------- */
.sheet-body.cover { padding-bottom: 8px; }

.toc { padding-top: 24px; padding-bottom: 8px; }
.toc-label { margin: 0 0 10px; font-size: 13.5px; font-weight: 500; color: var(--ink-3); }
.toc-list {
    margin: 0; padding: 0; list-style: none; counter-reset: toc;
    background: var(--panel); border-radius: var(--r-md); box-shadow: var(--shadow-1); overflow: hidden;
}
.toc-list li { counter-increment: toc; box-shadow: inset 0 -1px 0 var(--line); }
.toc-list li:last-child { box-shadow: none; }
.toc-list a {
    display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 10px 16px;
    font-size: 16px; line-height: 1.35; color: var(--ink);
    transition: background var(--dur-1);
}
.toc-list a::before {
    content: counter(toc, decimal-leading-zero); flex: none;
    font-size: 13.5px; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.toc-list a:hover { background: var(--hover); }

.bundle-section { scroll-margin-top: 12px; padding-top: 36px; }
.bundle-section + .bundle-section { margin-top: 8px; box-shadow: inset 0 1px 0 var(--line); }
.section-head { display: flex; align-items: baseline; gap: 12px; }
.section-n { flex: none; font-size: 15px; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.section-title { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; overflow-wrap: anywhere; }
.bundle-section .sheet-body { padding-top: 20px; padding-bottom: 40px; }

/* --------------------------------------------------------------------------
   8. Reader: link unavailable. English and Spanish as two equal blocks.
   -------------------------------------------------------------------------- */
.gone {
    min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 24px; text-align: center;
    padding: calc(32px + var(--safe-top)) 24px calc(32px + var(--safe-bottom));
}
.gone-mark { display: block; width: 66px; height: 56px; }
.gone-block { max-width: 420px; }
.gone-block h1, .gone-block h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; color: var(--ink); }
.gone-block p { margin: 0; font-size: 16px; line-height: 1.55; color: var(--ink-2); }
.gone-rule { width: 40px; height: 1px; background: var(--line-strong); }
