/* ============================================================
   SQE1 Lex Prep — Editorial Layer (supplemental)
   Parchment-and-law-library treatment lifted from the reference
   mockup. Opt-in via classes prefixed `editorial-`, `lex-` and
   the bare utility classes `.eyebrow`, `.cite`, `.pilcrow`.
   Loaded AFTER main.css and components.css so it can layer a
   serif+mono editorial skin on top of the existing UI without
   rewriting any component.
   ============================================================ */

:root {
    --ed-serif: "Instrument Serif", "Cormorant Garamond", Georgia, 'Baloo 2', serif;
    --ed-sans:  "Inter Tight", 'Urbanist', ui-sans-serif, system-ui, sans-serif;
    --ed-mono:  "JetBrains Mono", ui-monospace, Menlo, monospace;
    --ed-accent:       var(--accent);
    --ed-accent-soft:  var(--accent-soft);
    --ed-rule:         var(--border);
    --ed-rule-soft:    var(--border-light);
    --ed-ink:          var(--text);
    --ed-ink-soft:     var(--text-secondary);
    --ed-ink-muted:    var(--text-muted);
    --ed-panel:        var(--card);
    --ed-panel-2:      var(--bg-subtle);
    --ed-paper:        var(--card);
}

/* ── Eyebrow pattern ─────────────────────────────────────────
   Small mono uppercase label preceded by a short horizontal
   rule. Used above big serif headings. */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--ed-mono);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ed-ink-muted);
    line-height: 1;
    margin-bottom: 14px;
}
.eyebrow::before {
    content: "";
    display: inline-block;
    width: 24px;
    height: 1px;
    background: var(--ed-rule);
    flex: none;
}
.eyebrow em {
    font-family: var(--ed-serif);
    font-style: italic;
    color: var(--ed-accent);
    font-size: 13px;
    letter-spacing: 0;
    text-transform: none;
}

/* ── Editorial display heading ───────────────────────────────
   Big serif h1 with italic em-accent. Paired with `.eyebrow`
   above and `.lede` below. */
.editorial-display,
.editorial-page-head h1.editorial-display,
.page-header h1.editorial-display,
.dashboard-greeting h1.editorial-display {
    font-family: var(--ed-serif);
    font-size: clamp(36px, 5vw, 72px);
    line-height: 0.98;
    letter-spacing: -0.02em;
    font-weight: 400;
    color: var(--ed-ink);
    margin: 0;
    max-width: 22ch;
}
.editorial-display em {
    font-style: italic;
    color: var(--ed-accent);
    font-weight: 400;
}
.editorial-display .case,
.editorial-display .statute,
.editorial-display .rule {
    font-style: italic;
    color: var(--ed-accent);
}
.editorial-display-sm {
    font-family: var(--ed-serif);
    font-size: clamp(28px, 3.2vw, 44px);
    line-height: 1.05;
    letter-spacing: -0.015em;
    font-weight: 400;
    color: var(--ed-ink);
    margin: 0;
}
.editorial-display-sm em {
    font-style: italic;
    color: var(--ed-accent);
    font-weight: 400;
}

.lede,
.editorial-page-head .lede,
.page-header .lede,
.dashboard-greeting p.lede {
    font-size: 15px;
    line-height: 1.55;
    color: var(--ed-ink-soft);
    max-width: 56ch;
    margin: 14px 0 0;
    font-family: var(--ed-sans);
}
.lede em,
.editorial-page-head .lede em {
    font-family: var(--ed-serif);
    font-style: italic;
    color: var(--ed-accent);
}

/* ── Editorial page-header ───────────────────────────────────
   Drop-in replacement for `.page-header` when you want the
   parchment-and-serif treatment. Kept tight so it sits well
   above the vitals strip and the priority ledger. */
.editorial-page-head {
    background: transparent;
    padding: 36px 0 24px;
    margin: -32px 0 28px;
    border-bottom: 1px solid var(--ed-rule);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 32px;
}
.editorial-page-head > :first-child { min-width: 0; }
.editorial-page-head .kpis {
    display: flex;
    gap: 28px;
    font-family: var(--ed-mono);
    font-size: 10px;
    color: var(--ed-ink-muted);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    align-self: end;
    padding-bottom: 6px;
}
.editorial-page-head .kpi .n {
    display: block;
    font-family: var(--ed-serif);
    font-size: 36px;
    line-height: 1;
    color: var(--ed-ink);
    font-weight: 400;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.editorial-page-head .kpi .n em {
    color: var(--ed-accent);
    font-style: italic;
}
@media (max-width: 780px) {
    .editorial-page-head { grid-template-columns: 1fr; }
    .editorial-page-head .kpis { flex-wrap: wrap; gap: 18px; padding-top: 6px; padding-bottom: 0; }
}

/* ── Inline citation chip ────────────────────────────────────
   Mono in a 1px border. Wrap statute refs / section numbers
   inside running prose: "codified in <span class='cite'>s.33 CA 2006</span>". */
.cite {
    display: inline-block;
    font-family: var(--ed-mono);
    font-size: 11px;
    padding: 1px 6px;
    border: 1px solid var(--ed-rule);
    border-radius: 3px;
    color: var(--ed-ink-muted);
    margin: 0 2px;
    background: var(--ed-panel-2);
    letter-spacing: 0;
    line-height: 1.4;
    white-space: nowrap;
}

/* ── Pilcrow / section-mark glyph ────────────────────────────
   Small serif italic character used as a visual marker in
   eyebrows and source-grid cells. `.pilcrow` = ¶ (case),
   `.section-mark` = § (statute/rule). */
.pilcrow,
.section-mark {
    font-family: var(--ed-serif);
    font-style: italic;
    color: var(--ed-accent);
    font-size: 1.1em;
    line-height: 1;
    display: inline-block;
    vertical-align: baseline;
    margin-right: 2px;
    font-weight: 400;
}
.pilcrow::before  { content: "\00B6"; }   /* ¶ */
.section-mark::before { content: "\00A7"; }   /* § */

/* ── KPI / Stat strip ────────────────────────────────────────
   8-column strip of serif numbers + mono labels; hairline
   accent top border on each cell. `1px gap on a border-coloured
   background` fakes the dividers without separate rules. */
.editorial-stat-strip {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 1px;
    background: var(--ed-rule);
    border: 1px solid var(--ed-rule);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 0 32px;
}
.editorial-stat-strip .stat {
    background: var(--ed-panel);
    padding: 20px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    min-width: 0;
}
.editorial-stat-strip .stat::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0; right: 0;
    height: 2px;
    background: var(--ed-accent);
    opacity: 0.55;
}
.editorial-stat-strip .stat .n {
    font-family: var(--ed-serif);
    font-size: 32px;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--ed-ink);
    font-weight: 400;
}
.editorial-stat-strip .stat .n em {
    font-style: italic;
    color: var(--ed-accent);
}
.editorial-stat-strip .stat .l {
    font-family: var(--ed-mono);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ed-ink-muted);
    line-height: 1.3;
}
@media (max-width: 1100px) {
    .editorial-stat-strip { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 620px) {
    .editorial-stat-strip { grid-template-columns: repeat(2, 1fr); }
}

/* ── Subject grid ────────────────────────────────────────────
   7-column grid of subject tiles, 1px gap on border bg. Used
   as an at-a-glance subject jumper. */
.editorial-subj-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--ed-rule);
    border: 1px solid var(--ed-rule);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 32px;
}
.editorial-subj-grid .subj {
    background: var(--ed-panel);
    padding: 16px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 110px;
    cursor: pointer;
    transition: background .15s ease;
    text-decoration: none;
    color: inherit;
}
.editorial-subj-grid .subj:hover { background: var(--ed-panel-2); }
.editorial-subj-grid .subj .idx {
    font-family: var(--ed-mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    color: var(--ed-ink-muted);
    text-transform: uppercase;
}
.editorial-subj-grid .subj .nm {
    font-family: var(--ed-serif);
    font-size: 17px;
    line-height: 1.1;
    color: var(--ed-ink);
    letter-spacing: -0.005em;
}
.editorial-subj-grid .subj .cnt {
    font-family: var(--ed-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--ed-accent);
    margin-top: auto;
    text-transform: uppercase;
}
@media (max-width: 1100px) { .editorial-subj-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 620px)  { .editorial-subj-grid { grid-template-columns: repeat(2, 1fr); } }

/* ── Source grid (Case / Statute / Rule list preview) ────────
   4-column tiles, glyph + serif name + mono citation. Used at
   the bottom of a landing or empty state to show the stock. */
.editorial-source-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--ed-rule);
    border: 1px solid var(--ed-rule);
    border-radius: 10px;
    overflow: hidden;
}
.editorial-source-grid .src {
    background: var(--ed-panel);
    padding: 16px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-decoration: none;
    color: inherit;
    transition: background .15s ease;
}
.editorial-source-grid .src:hover { background: var(--ed-panel-2); }
.editorial-source-grid .src .s-k {
    font-family: var(--ed-mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ed-accent);
}
.editorial-source-grid .src .s-n {
    font-family: var(--ed-serif);
    font-size: 17px;
    line-height: 1.15;
    color: var(--ed-ink);
    letter-spacing: -0.005em;
}
.editorial-source-grid .src .s-n em { font-style: italic; }
.editorial-source-grid .src .s-c {
    font-family: var(--ed-mono);
    font-size: 11px;
    color: var(--ed-ink-muted);
    letter-spacing: 0.05em;
}
@media (max-width: 1100px) { .editorial-source-grid { grid-template-columns: repeat(2, 1fr); } }

/* ── Continuous rule/case marquee ────────────────────────────
   Decorative ticker of legal references. Good for empty states
   or under a hero. */
.editorial-marquee {
    overflow: hidden;
    border: 1px solid var(--ed-rule);
    border-radius: 10px;
    background: var(--ed-panel);
    padding: 14px 0;
    margin-bottom: 32px;
    position: relative;
}
.editorial-marquee::before,
.editorial-marquee::after {
    content: "";
    position: absolute;
    top: 0; bottom: 0;
    width: 72px;
    z-index: 2;
    pointer-events: none;
}
.editorial-marquee::before { left: 0;  background: linear-gradient(to right, var(--ed-panel), transparent); }
.editorial-marquee::after  { right: 0; background: linear-gradient(to left,  var(--ed-panel), transparent); }
.editorial-marquee .track {
    display: flex;
    gap: 44px;
    white-space: nowrap;
    width: max-content;
    animation: editorial-marq 60s linear infinite;
}
.editorial-marquee .track span {
    font-family: var(--ed-serif);
    font-size: 20px;
    color: var(--ed-ink-soft);
    letter-spacing: -0.01em;
    display: inline-flex;
    gap: 10px;
    align-items: center;
}
.editorial-marquee .track span em {
    color: var(--ed-accent);
    font-style: italic;
}
.editorial-marquee .track span::after {
    content: "\00A7";
    color: var(--ed-ink-muted);
    font-family: var(--ed-mono);
    font-size: 13px;
    margin-left: 44px;
    opacity: 0.5;
}
@keyframes editorial-marq {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
    .editorial-marquee .track { animation: none; }
}

/* ── A–Z letter jumper (big serif italic letters) ────────────
   A row of 13 big italic serif letters used above a rules/cases
   list so the user can jump by initial. */
.editorial-az-letters {
    display: grid;
    grid-template-columns: repeat(13, 1fr);
    gap: 4px;
    margin-bottom: 20px;
}
.editorial-az-letters button {
    font-family: var(--ed-serif);
    font-size: 22px;
    font-style: italic;
    font-weight: 400;
    letter-spacing: -0.01em;
    color: var(--ed-ink-soft);
    background: transparent;
    border: 1px solid var(--ed-rule);
    border-radius: 6px;
    padding: 8px 0;
    cursor: pointer;
    transition: all .15s ease;
}
.editorial-az-letters button:hover,
.editorial-az-letters button.on {
    color: var(--ed-paper, #fff);
    background: var(--ed-accent);
    border-color: var(--ed-accent);
}
.editorial-az-letters button.empty {
    color: var(--ed-ink-muted);
    opacity: .35;
    cursor: default;
    pointer-events: none;
}
@media (max-width: 720px) {
    .editorial-az-letters { grid-template-columns: repeat(9, 1fr); }
    .editorial-az-letters button { font-size: 18px; padding: 6px 0; }
}

/* ── Stacked-paper card stage ────────────────────────────────
   Adds two offset paper layers behind the target element.
   Wrap your flashcard / hero card in `.editorial-card-stage`. */
.editorial-card-stage {
    position: relative;
    margin: 0 auto;
}
.editorial-card-stage::before,
.editorial-card-stage::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px solid var(--ed-rule);
    border-radius: inherit;
    background: var(--ed-panel);
    pointer-events: none;
    z-index: 0;
    transition: transform .4s ease, opacity .4s ease;
}
.editorial-card-stage::before {
    transform: translate(8px, 8px) rotate(0.6deg);
    opacity: 0.55;
}
.editorial-card-stage::after {
    transform: translate(4px, 4px) rotate(-0.3deg);
    opacity: 0.8;
}
.editorial-card-stage > * {
    position: relative;
    z-index: 1;
}

/* ── Dashed divider ───────────────────────────────────────── */
.editorial-dashed {
    border-top: 1px dashed var(--ed-rule);
    height: 0;
    margin: 24px 0;
}

/* ── Heatmap ─────────────────────────────────────────────────
   14-column grid of tiny squares, accent opacity steps. */
.editorial-heatmap {
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    gap: 3px;
    margin-top: 12px;
}
.editorial-heatmap i {
    aspect-ratio: 1;
    background: var(--ed-rule-soft);
    border-radius: 2px;
}
.editorial-heatmap i.l1 { background: color-mix(in oklch, var(--ed-accent) 20%, transparent); }
.editorial-heatmap i.l2 { background: color-mix(in oklch, var(--ed-accent) 45%, transparent); }
.editorial-heatmap i.l3 { background: color-mix(in oklch, var(--ed-accent) 70%, transparent); }
.editorial-heatmap i.l4 { background: var(--ed-accent); }

/* ── Tag / chip row (eyebrow-level subject chips) ─────────── */
.editorial-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 12px;
}
.editorial-chip-row .label {
    font-family: var(--ed-mono);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ed-ink-muted);
    margin-right: 6px;
}
.editorial-chip-row .chip {
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--ed-rule);
    background: transparent;
    color: var(--ed-ink-soft);
    cursor: pointer;
    font-family: var(--ed-sans);
    font-weight: 500;
    transition: all .15s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}
.editorial-chip-row .chip:hover {
    color: var(--ed-ink);
    border-color: var(--ed-ink-muted);
}
.editorial-chip-row .chip.on {
    background: var(--ed-ink);
    color: var(--bg);
    border-color: var(--ed-ink);
}
.editorial-chip-row .chip .n {
    font-family: var(--ed-mono);
    font-size: 10px;
    opacity: 0.65;
}

/* ── Source row (compact, one-per-line) ──────────────────────
   Used inside the cases/statutes lists as a tighter alternative
   to the tile grid. */
.editorial-source-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    align-items: baseline;
    padding: 12px 0;
    border-bottom: 1px solid var(--ed-rule-soft);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}
.editorial-source-row:hover .r-n { color: var(--ed-accent); }
.editorial-source-row .r-k {
    font-family: var(--ed-mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ed-ink-muted);
}
.editorial-source-row .r-n {
    font-family: var(--ed-serif);
    font-size: 18px;
    line-height: 1.25;
    color: var(--ed-ink);
    letter-spacing: -0.005em;
    transition: color .15s ease;
}
.editorial-source-row .r-n em { font-style: italic; color: var(--ed-accent); }
.editorial-source-row .r-c {
    font-family: var(--ed-mono);
    font-size: 11px;
    color: var(--ed-ink-muted);
    letter-spacing: 0.05em;
}

/* ── Utility: italicise any case citation inline ─────────── */
.case-cite {
    font-family: var(--ed-serif);
    font-style: italic;
    color: var(--ed-accent);
}

/* ── Selection polish ─────────────────────────────────────── */
.editorial-page-head ::selection,
.editorial-display ::selection {
    background: color-mix(in oklch, var(--ed-accent) 22%, transparent);
    color: var(--ed-ink);
}
