/**
 * Chairside — component layer
 *
 * Consumes the --ch-* tokens declared in main.css. Nothing here touches the
 * emerald system; both coexist until the migration finishes.
 *
 * Scope so far: the two signature partials (stamp, ledger) and the landing
 * hero. Sections are added one at a time, per the handoff's build order.
 *
 * The two hard rules from design review are load-bearing here:
 *   1. --ch-muted-on-paper and --ch-muted-on-ink never swap surfaces.
 *   2. Pinned width + padding always carries box-sizing: border-box.
 */

/* ============================================
   1. STAMP CHIP  —  partials/stamp.html
   ============================================ */

.ch-stamp {
    display: inline-block;
    font-family: var(--ch-font-text);
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.2;
    padding: 5px 10px;
    border-radius: var(--ch-radius-pill);
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.ch-stamp--verified {
    background: var(--ch-teal);
    color: var(--ch-paper);
}

.ch-stamp--estimate {
    background: var(--ch-clay-bg);
    color: var(--ch-clay-text);
}

.ch-stamp--lg {
    font-size: 12px;
    padding: 6px 12px;
}

/* ============================================
   2. LEDGER LINE  —  partials/ledger.html
   ============================================ */

.ch-ledger {
    display: flex;
    align-items: baseline;
    gap: 8px;
    border-top: 1px dotted var(--ch-rule);
    padding-top: 10px;
    font-family: var(--ch-font-mono);
    font-size: 10.5px;
    line-height: 1.4;
    color: var(--ch-muted-on-paper);
}

.ch-ledger--flush {
    border-top: 0;
    padding-top: 0;
}

.ch-ledger__source,
.ch-ledger__time {
    flex: 0 0 auto;
}

/* The leader carries the dots and rides up onto the text baseline. */
.ch-ledger__leader {
    flex: 1 1 auto;
    min-width: 12px;
    border-bottom: 1px dotted var(--ch-rule);
    transform: translateY(-3px);
}

/* On ink surfaces the muted token flips — rule 1. */
.ch-ledger--on-ink {
    border-top-color: var(--ch-rule-dark);
    color: var(--ch-muted-on-ink);
}

.ch-ledger--on-ink .ch-ledger__leader {
    border-bottom-color: var(--ch-rule-dark);
}

/* ============================================
   3. LANDING HERO
   ============================================ */

.ch-hero {
    position: relative;
    background: var(--ch-ink);
    color: var(--ch-paper);
    overflow: hidden;
    font-family: var(--ch-font-text);

    /* The shared site header is position:fixed and overlays the hero, so the
       grid reserves its height. 56px logo + 2x12px padding. In the design the
       nav lives inside the ink block; this reproduces that spacing against the
       real header. Retiring the logo PNG for the Newsreader wordmark is brand
       foundation work (handoff §1) and lands with the header, not here. */
    --ch-header-h: 80px;
}

/* Map plate sits behind everything at 0.16, then a 105deg wash keeps the
   left column readable while the right stays open enough to read as a map. */
.ch-hero__map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.16;
    pointer-events: none;
}

.ch-hero__wash {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        #211d18 0%,
        #211d18 42%,
        rgba(33, 29, 24, 0.72) 72%,
        rgba(33, 29, 24, 0.55) 100%
    );
    pointer-events: none;
}

/* Grid is 600 / 64 gap / rest. Left padding tracks the 1440 content edge on
   wide screens so the copy column never drifts away from the page gutter. */
.ch-hero__grid {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 600px 1fr;
    gap: 64px;
    align-items: start;
    padding: calc(56px + var(--ch-header-h)) 0 88px;
    padding-left: max(64px, calc((100% - 1440px) / 2 + 64px));
}

.ch-hero__copy {
    padding-top: 24px;
    min-width: 0;
}

.ch-hero__eyebrow {
    font-family: var(--ch-font-mono);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ch-teal-on-ink);
    margin-bottom: 22px;
}

.ch-hero__headline {
    font-family: var(--ch-font-display);
    font-weight: 400;
    font-size: 68px;
    line-height: 1;
    letter-spacing: -0.02em;
    margin: 0 0 24px;
    color: var(--ch-paper);
}

.ch-hero__lede {
    font-size: 20px;
    line-height: 1.55;
    color: var(--ch-body-on-ink);
    margin: 0 0 36px;
    max-width: 44ch;
}

.ch-hero__actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

/* The microline comes home: provenance under the copy column, below a rule,
   instead of orphaned beneath the media column as it was before. */
.ch-hero__provenance {
    font-family: var(--ch-font-mono);
    font-size: 12px;
    line-height: 1.5;
    color: var(--ch-muted-on-ink);
    margin: 34px 0 0;
    padding-top: 22px;
    border-top: 1px solid var(--ch-rule-dark);
    max-width: 46ch;
}

/* --- Buttons --- */

.ch-btn {
    display: inline-block;
    font-family: var(--ch-font-text);
    border-radius: var(--ch-radius-pill);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease,
        transform 0.08s ease;
}

.ch-btn:active {
    transform: translateY(1px);
}

.ch-btn--primary {
    background: var(--ch-teal);
    color: var(--ch-paper);
    border: 0;
    padding: 19px 36px;
    font-size: 17px;
    font-weight: 700;
}

.ch-btn--primary:hover {
    background: var(--ch-teal-hover);
    color: var(--ch-paper);
}

.ch-btn--secondary {
    background: transparent;
    color: var(--ch-paper);
    border: 1px solid var(--ch-border-on-ink);
    padding: 18px 30px;
    font-size: 17px;
    font-weight: 600;
}

.ch-btn--secondary:hover {
    border-color: var(--ch-muted-on-ink);
    color: var(--ch-paper);
}

.ch-btn:focus-visible {
    outline: 2px solid var(--ch-teal-on-ink);
    outline-offset: 3px;
}

/* ============================================
   4. HERO REPORT PANEL
   ============================================
   Rule 2 lives here: pinned width + padding => border-box.

   The panel is 760px at the 1440 reference width and bleeds exactly 48px past
   the content edge at every viewport, so the crop always reads as a surface
   continuing rather than a broken layout. calc(100% + 48px) keeps that bleed
   constant while the column flexes; at 1440 it resolves to exactly 760px.

   The crop may only ever eat panel edge and whitespace. Any right-aligned
   child needs the bleed as padding-right or its content clips — that is what
   .ch-report__bleedsafe is for. */

.ch-hero__panel {
    width: calc(100% + 48px);
    box-sizing: border-box;
    min-width: 0;
}

.ch-report {
    box-sizing: border-box;
    background: var(--ch-paper);
    color: var(--ch-ink);
    border-radius: var(--ch-radius-panel) 0 0 var(--ch-radius-panel);
    padding: 24px 32px 0;
    box-shadow: var(--ch-shadow-hero-report);
}

.ch-report__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--ch-rule);
}

/* Right-aligned content must clear the 48px bleed or the crop eats it. */
.ch-report__bleedsafe {
    padding-right: 48px;
}

.ch-report__practice {
    font-family: var(--ch-font-display);
    font-size: 23px;
    line-height: 1.2;
}

.ch-report__meta {
    font-size: 13.5px;
    color: var(--ch-muted-on-paper);
    margin-top: 4px;
}

.ch-report__live {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--ch-font-mono);
    font-size: 11.5px;
    color: var(--ch-muted-on-paper);
    white-space: nowrap;
}

.ch-report__live-dot {
    width: 7px;
    height: 7px;
    border-radius: var(--ch-radius-pill);
    background: var(--ch-teal);
    display: block;
    animation: ch-live-pulse 2.4s ease-in-out infinite;
}

/* --- The scrolling viewport --- */

.ch-report__window {
    height: 520px;
    overflow: hidden;
    position: relative;
}

.ch-report__track {
    animation: ch-report-scroll 34s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

/* Stops default to the authored values and are recomputed from real child
   offsetTop by hero-report.js, clamped to trackHeight - viewportHeight. */
@keyframes ch-report-scroll {
    0%,
    9% {
        transform: translateY(0);
    }
    16%,
    30% {
        transform: translateY(var(--ch-stop-1, -120px));
    }
    37%,
    51% {
        transform: translateY(var(--ch-stop-2, -404px));
    }
    58%,
    72% {
        transform: translateY(var(--ch-stop-3, -678px));
    }
    79%,
    93% {
        transform: translateY(var(--ch-stop-4, -741px));
    }
    100% {
        transform: translateY(0);
    }
}

@keyframes ch-live-pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.25;
    }
}

/* --- Cards inside the report --- */

.ch-report__view {
    padding: 12px 0 0;
}

.ch-report__view:first-child {
    padding-top: 20px;
}

.ch-report__view:last-child {
    padding-bottom: 24px;
}

.ch-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

/* min-width:0 — without it the 1fr tracks refuse to shrink below their
   content and the stamps overflow the panel on narrow viewports. */
.ch-metric {
    background: var(--ch-card);
    border-radius: var(--ch-radius-md);
    padding: 18px;
    min-width: 0;
}

.ch-metric__top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.ch-metric__value {
    font-family: var(--ch-font-display);
    font-size: 38px;
    line-height: 1;
    color: var(--ch-ink);
}

.ch-metric__value--estimate {
    color: var(--ch-clay);
}

.ch-metric__value--good {
    color: var(--ch-teal);
}

.ch-metric__label {
    font-size: 13.5px;
    color: var(--ch-body-on-paper);
    margin-top: 10px;
}

.ch-card {
    background: var(--ch-card);
    border-radius: var(--ch-radius-md);
    padding: 20px 24px;
}

.ch-card__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 14px;
    padding-right: 24px;
}

.ch-card__title {
    font-size: 16px;
    font-weight: 700;
}

.ch-card__note {
    font-family: var(--ch-font-mono);
    font-size: 11px;
    color: var(--ch-muted-on-paper);
    white-space: nowrap;
}

/* --- Rank table --- */

.ch-rank-row {
    display: grid;
    grid-template-columns: 28px 1fr 118px 70px 70px;
    gap: 14px;
    padding: 10px 0;
    border-top: 1px solid var(--ch-rule-soft);
    font-size: 14.5px;
    align-items: center;
}

.ch-rank-row__index,
.ch-rank-row__num {
    font-family: var(--ch-font-mono);
    font-size: 13px;
}

.ch-rank-row__index {
    font-size: 12px;
    color: var(--ch-muted-on-paper);
}

.ch-rank-row__dist {
    font-family: var(--ch-font-mono);
    font-size: 13px;
    color: var(--ch-muted-on-paper);
}

.ch-rank-row__type {
    font-size: 13px;
    color: var(--ch-muted-on-paper);
}

.ch-rank-row .ch-stamp {
    justify-self: start;
    padding: 4px 9px;
}

/* --- Keyword table --- */

.ch-kw-row {
    display: grid;
    grid-template-columns: 1fr 90px 90px 96px;
    gap: 14px;
    padding: 10px 0;
    border-top: 1px solid var(--ch-rule-soft);
    font-size: 14.5px;
    align-items: center;
}

.ch-kw-row__vol,
.ch-kw-row__pos {
    font-family: var(--ch-font-mono);
    font-size: 13px;
}

.ch-kw-row__vol {
    color: var(--ch-muted-on-paper);
}

.ch-kw-row__status {
    font-size: 12.5px;
    font-weight: 700;
}

.ch-kw-row__status--bad {
    color: var(--ch-clay-text);
}

.ch-kw-row__status--ok {
    color: var(--ch-teal);
}

/* --- Review themes --- */

.ch-themes {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ch-theme {
    display: grid;
    grid-template-columns: 1fr 78px;
    gap: 14px;
    align-items: center;
    border-radius: var(--ch-radius-sm);
    padding: 13px 16px;
    font-size: 14.5px;
}

.ch-theme--positive {
    background: var(--ch-teal-bg-row);
}

.ch-theme--negative {
    background: var(--ch-clay-bg-row);
}

.ch-theme__count {
    font-family: var(--ch-font-mono);
    font-size: 12px;
    font-weight: 600;
}

.ch-theme--positive .ch-theme__count {
    color: var(--ch-teal);
}

.ch-theme--negative .ch-theme__count {
    color: var(--ch-clay-text);
}

/* --- Fix-first list --- */

.ch-fix-row {
    display: grid;
    grid-template-columns: 28px 1fr 110px;
    gap: 14px;
    padding: 12px 0;
    border-top: 1px solid var(--ch-rule-soft);
    align-items: start;
}

.ch-fix-row__index {
    font-family: var(--ch-font-mono);
    font-size: 12px;
    color: var(--ch-teal);
    padding-top: 3px;
}

.ch-fix-row__title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 3px;
}

.ch-fix-row__detail {
    font-size: 13.5px;
    color: var(--ch-muted-on-paper);
}

.ch-cost {
    font-size: 12px;
    font-weight: 700;
    justify-self: start;
    padding: 4px 10px;
    border-radius: var(--ch-radius-pill);
    white-space: nowrap;
}

.ch-cost--free {
    color: var(--ch-teal);
    background: var(--ch-teal-bg);
}

.ch-cost--low {
    color: var(--ch-clay-text);
    background: var(--ch-clay-bg);
}

/* ============================================
   5. RESPONSIVE
   ============================================
   Mobile has its own design (Mobile Landing.dc.html, option 2b) and is not a
   breakpoint of desktop. Until that lands, these rules keep the hero honest
   on narrow screens rather than pretending to be the mobile design. */

@media (max-width: 1200px) {
    .ch-hero__grid {
        grid-template-columns: 1fr;
        gap: 48px;
        padding: calc(40px + var(--ch-header-h)) 0 72px;
        padding-left: 40px;
    }

    .ch-hero__copy {
        padding-top: 0;
        max-width: 640px;
    }

    .ch-hero__headline {
        font-size: 54px;
    }

    /* Panel keeps its bleed but is capped so it cannot exceed the viewport. */
    .ch-hero__panel {
        width: calc(100% - 40px + 48px);
        max-width: 760px;
    }
}

@media (max-width: 767px) {
    .ch-hero__grid {
        padding: calc(28px + var(--ch-header-h)) 0 56px;
        padding-left: 20px;
    }

    .ch-hero__headline {
        font-size: 38px;
        letter-spacing: -0.01em;
    }

    .ch-hero__lede {
        font-size: 17px;
        margin-bottom: 28px;
    }

    .ch-hero__actions {
        gap: 10px;
    }

    .ch-btn--primary,
    .ch-btn--secondary {
        padding: 16px 26px;
        font-size: 16px;
    }

    .ch-hero__panel {
        width: calc(100% - 20px + 24px);
    }

    .ch-report {
        padding: 20px 20px 0;
    }

    .ch-report__bleedsafe {
        padding-right: 24px;
    }

    .ch-report__window {
        height: 420px;
    }

    .ch-metrics {
        gap: 8px;
    }

    .ch-metric {
        padding: 14px;
    }

    /* Three metrics side by side cannot carry a 38px numeral and a chip on one
       line at this width, so the chip drops under the number. */
    .ch-metric__top {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .ch-metric__value {
        font-size: 26px;
    }

    .ch-metric__label {
        font-size: 12.5px;
        margin-top: 8px;
    }

    .ch-stamp {
        font-size: 9.5px;
        padding: 4px 8px;
    }

    /* Drop the columns the narrow panel cannot carry. */
    .ch-rank-row {
        grid-template-columns: 22px 1fr 60px;
    }

    .ch-rank-row__type,
    .ch-rank-row .ch-stamp,
    .ch-kw-row__pos {
        display: none;
    }

    .ch-kw-row {
        grid-template-columns: 1fr 70px 80px;
    }
}

/* ============================================
   6. REDUCED MOTION
   ============================================
   Every animation above must respect this. The report parks on the first
   view rather than freezing mid-scroll. */

@media (prefers-reduced-motion: reduce) {
    .ch-report__track {
        animation: none;
        transform: translateY(0);
    }

    .ch-report__live-dot {
        animation: none;
        opacity: 1;
    }

    .ch-btn {
        transition: none;
    }

    .ch-btn:active {
        transform: none;
    }
}
