/* ============================================================
   Artifact-Bench — Interactive Companion
   Design: editorial long-form, warm cream, NYT/FT feel
   ============================================================ */

:root {
    --bg: #fbfaf7;
    --bg-elevated: #ffffff;
    --ink: #15212e;
    --ink-soft: #3a4a5c;
    --ink-muted: #6b7785;
    --rule: #e3e0d8;
    --upstream: #1f3a52;
    --midmarket: #4a7396;
    --downstream: #7aa6cc;
    --feedback: #16a085;
    --accent: #c8392c;

    /* artifact-domain colours */
    --surface: #d4883a;
    --structural: #5b7fa5;
    --temporal: #7a5fa5;

    --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --max-w: 920px;
    --nav-h: 56px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
    font-family: var(--serif);
    font-size: 18px;
    line-height: 1.7;
    color: var(--ink);
    background: var(--bg);
}

/* ---------- NAV ---------- */
.nav-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--nav-h);
    background: rgba(251,250,247,0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--rule);
    display: flex; align-items: center;
}
.nav-inner {
    width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px;
    display: flex; align-items: center; justify-content: space-between;
}
.nav-title { display: flex; flex-direction: column; }
.nav-paper {
    font-family: var(--sans);
    font-weight: 600; font-size: 14px; color: var(--ink);
    letter-spacing: 0.02em;
}
.nav-sub {
    font-family: var(--sans);
    font-weight: 400; font-size: 12px; color: var(--ink-muted);
}
.nav-progress {
    width: 120px; height: 3px; background: var(--rule); border-radius: 2px;
    overflow: hidden;
}
.nav-progress-fill {
    height: 100%; width: 0%; background: var(--accent);
    transition: width 0.15s ease;
}

/* ---------- CHAPTER RAIL ---------- */
.chapter-rail {
    position: fixed; left: 24px; top: 50%; transform: translateY(-50%);
    z-index: 90; list-style: none;
}
.chapter-rail ol { list-style: none; }
.chapter-rail li {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 12px; cursor: pointer;
    font-family: var(--sans); font-size: 11px; font-weight: 500;
    color: var(--ink-muted);
    transition: color 0.2s;
}
.chapter-rail li:hover { color: var(--ink); }
.chapter-rail li.active { color: var(--accent); }
.chapter-rail .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--rule);
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}
.chapter-rail li.active .dot {
    background: var(--accent); transform: scale(1.4);
}
.chapter-rail .label { white-space: nowrap; }

@media (max-width: 1100px) {
    .chapter-rail { display: none; }
}

/* ---------- CHAPTER BASE ---------- */
.chapter {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 7rem 24px 3rem;
    scroll-margin-top: calc(var(--nav-h) + 32px);
}
.chapter-head { margin-bottom: 2rem; }
.chapter-num {
    font-family: var(--sans);
    font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--accent); margin-bottom: 0.5rem;
}
.chapter h2 {
    font-size: 2.2rem; font-weight: 700; line-height: 1.15;
    margin-bottom: 1rem; color: var(--ink);
}
.lede {
    font-size: 1.15rem; color: var(--ink-soft);
    line-height: 1.65; font-style: italic;
}

/* ---------- PLAIN CARD ---------- */
.plain-card {
    background: var(--bg);
    border-left: 4px solid #c9a84c;
    padding: 1.5rem 1.75rem;
    margin: 2rem 0;
    border-radius: 0 8px 8px 0;
}
.plain-label {
    font-family: var(--sans);
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: #c9a84c; margin-bottom: 0.75rem;
}
.plain-card p {
    font-size: 1rem; line-height: 1.65; color: var(--ink-soft);
    margin-bottom: 0.65rem;
}
.plain-card p:last-child { margin-bottom: 0; }

/* ---------- CALLOUT ---------- */
.callout {
    background: rgba(200,57,44,0.06);
    border-left: 4px solid var(--accent);
    padding: 1.25rem 1.5rem;
    margin: 2rem 0;
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: var(--ink-soft);
    line-height: 1.6;
}
.callout strong { color: var(--accent); font-style: normal; }

/* ---------- PROSE ---------- */
.prose { margin: 1.5rem 0; }
.prose p { margin-bottom: 1rem; line-height: 1.7; }
.prose p:last-child { margin-bottom: 0; }

/* ---------- EQUATION BLOCK ---------- */
.equation-block {
    background: var(--bg-elevated);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    text-align: center;
    overflow-x: auto;
}
.equation-block .eq-label {
    font-family: var(--sans);
    font-size: 11px; font-weight: 600;
    color: var(--ink-muted); text-align: left;
    margin-bottom: 0.5rem;
}

/* ---------- INTERACTIVE SECTION ---------- */
.interactive-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--bg-elevated);
    border: 1px solid var(--rule);
    border-radius: 10px;
}
.interactive-section .hint {
    font-family: var(--sans);
    font-size: 12px; color: var(--ink-muted);
    margin-bottom: 1rem;
    display: flex; align-items: center; gap: 6px;
}
.interactive-section .hint::before {
    content: ''; display: inline-block;
    width: 16px; height: 16px;
    background: var(--accent); border-radius: 50%;
    opacity: 0.6;
}
.slider-group {
    display: flex; flex-wrap: wrap; gap: 1rem 2rem;
    margin-bottom: 1.25rem;
}
.slider-item {
    flex: 1 1 200px; min-width: 180px;
}
.slider-item label {
    display: block;
    font-family: var(--sans);
    font-size: 12px; font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 4px;
}
.slider-item input[type="range"] {
    width: 100%; accent-color: var(--accent);
}
.slider-item .slider-val {
    font-family: var(--mono);
    font-size: 12px; color: var(--ink-muted);
    text-align: right;
}
.chart-grid {
    display: grid; gap: 1rem;
}
.chart-grid.g2 { grid-template-columns: 1fr 1fr; }
.chart-grid.g1 { grid-template-columns: 1fr; }
.chart-grid .chart-box {
    min-height: 300px;
    border: 1px solid var(--rule);
    border-radius: 6px;
    overflow: hidden;
}

/* ---------- READOUT CARDS ---------- */
.readout-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem; margin-top: 1rem;
}
.readout-card {
    background: var(--bg);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    text-align: center;
}
.readout-card .rc-label {
    font-family: var(--sans);
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--ink-muted);
}
.readout-card .rc-value {
    font-family: var(--mono);
    font-size: 1.4rem; font-weight: 600;
    color: var(--accent);
    margin-top: 2px;
}

/* ---------- COVER ---------- */
.cover {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding-top: calc(var(--nav-h) + 2rem);
    padding-bottom: 4rem;
    position: relative;
}
.cover-inner {
    max-width: 720px; text-align: center;
}
.cover-eyebrow {
    font-family: var(--sans);
    font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.15em;
    color: var(--accent); margin-bottom: 1rem;
}
.cover-title {
    font-size: 2.8rem; font-weight: 700; line-height: 1.15;
    margin-bottom: 0.5rem; color: var(--ink);
}
.cover-title em { color: var(--accent); }
.cover-subtitle {
    font-size: 1.15rem; color: var(--ink-muted);
    font-style: italic; margin-bottom: 1.5rem;
}
.cover-byline {
    font-family: var(--sans);
    font-size: 14px; color: var(--ink-soft);
    margin-bottom: 0.5rem; line-height: 1.6;
}
.cover-byline .muted { color: var(--ink-muted); font-size: 13px; }

.cover-abstract {
    background: var(--bg);
    border-left: 4px solid #c9a84c;
    padding: 1.5rem 1.75rem;
    margin: 2rem auto;
    border-radius: 0 8px 8px 0;
    text-align: left;
    max-width: 660px;
}
.cover-abstract-label {
    font-family: var(--sans);
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: #c9a84c; margin-bottom: 0.75rem;
}
.cover-abstract p {
    font-size: 1rem; line-height: 1.65; color: var(--ink-soft);
    margin-bottom: 0.75rem;
}
.cover-abstract p:last-child { margin-bottom: 0; }

.cover-pillars {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 1rem; margin: 2rem auto; max-width: 720px;
}
.pillar {
    background: var(--bg-elevated);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 1.25rem;
    text-align: left;
}
.pillar-num {
    font-family: var(--sans);
    font-size: 13px; font-weight: 700;
    color: var(--accent); margin-bottom: 0.35rem;
}
.pillar-title {
    font-family: var(--sans);
    font-size: 13px; font-weight: 700;
    color: var(--ink); margin-bottom: 0.4rem;
}
.pillar-text {
    font-size: 0.9rem; color: var(--ink-soft); line-height: 1.5;
}
.pillar-text em { font-style: italic; }

.cover-cta {
    margin-top: 2rem;
    display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
}
.primary-btn {
    font-family: var(--sans);
    font-size: 14px; font-weight: 600;
    padding: 12px 32px;
    background: var(--accent); color: #fff;
    border: none; border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}
.primary-btn:hover { background: #a82d23; }
.cover-meta {
    font-family: var(--sans);
    font-size: 12px; color: var(--ink-muted);
}

/* ---------- CHAPTER FOOT LINK ---------- */
.chapter-foot {
    display: flex; align-items: center; justify-content: flex-end;
    gap: 6px;
    font-family: var(--sans);
    font-size: 14px; font-weight: 600;
    color: var(--ink-muted);
    text-decoration: none;
    margin-top: 2rem;
    transition: color 0.2s;
}
.chapter-foot:hover { color: var(--accent); }
.chapter-foot .arrow {
    transition: transform 0.2s;
}
.chapter-foot:hover .arrow { transform: translateX(4px); }

/* ---------- PROPERTY / CARD GRID ---------- */
.property-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem; margin: 1.5rem 0;
}
.property-card {
    background: var(--bg-elevated);
    border: 1px solid var(--rule);
    border-radius: 8px; padding: 1.25rem;
}
.property-card .property-icon {
    font-size: 1.5rem; margin-bottom: 0.5rem;
}
.property-card .property-name {
    font-family: var(--sans);
    font-size: 14px; font-weight: 700;
    color: var(--ink); margin-bottom: 0.35rem;
}
.property-card .property-detail {
    font-size: 0.9rem; color: var(--ink-soft); line-height: 1.5;
}
.property-card .property-tech {
    font-family: var(--sans);
    font-size: 12px; color: var(--ink-muted);
    margin-top: 0.5rem;
}
.tag {
    font-family: var(--sans);
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--feedback);
}

/* ---------- TAXONOMY TREE ---------- */
.taxonomy-tree { margin: 1.5rem 0; }
.taxonomy-tree svg { width: 100%; }
.tree-node circle { stroke-width: 2px; }
.tree-node text {
    font-family: var(--sans);
    font-size: 12px; fill: var(--ink);
}
.tree-link { fill: none; stroke: var(--rule); stroke-width: 1.5px; }

/* ---------- STRATEGY CARDS ---------- */
.strategy-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem; margin: 1rem 0;
}
.strategy-card {
    background: var(--bg);
    border: 2px solid var(--rule);
    border-radius: 8px; padding: 1rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.strategy-card:hover { border-color: var(--midmarket); }
.strategy-card.selected {
    border-color: var(--accent);
    background: rgba(200,57,44,0.04);
}
.strategy-card .sc-title {
    font-family: var(--sans);
    font-size: 13px; font-weight: 700;
    color: var(--ink); margin-bottom: 0.25rem;
}
.strategy-card .sc-desc {
    font-size: 0.85rem; color: var(--ink-muted); line-height: 1.4;
}

/* ---------- TABLE STYLE ---------- */
.results-table-wrapper {
    overflow-x: auto; margin: 1.5rem 0;
}
.results-table {
    width: 100%; border-collapse: collapse;
    font-family: var(--sans);
    font-size: 13px;
}
.results-table th {
    background: var(--upstream);
    color: #fff; font-weight: 600;
    padding: 8px 10px; text-align: center;
    font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.05em;
}
.results-table td {
    padding: 6px 10px; text-align: center;
    border-bottom: 1px solid var(--rule);
    font-family: var(--mono);
    font-size: 12px;
}
.results-table tr:hover td { background: rgba(0,0,0,0.02); }
.results-table .model-name {
    text-align: left; font-family: var(--sans);
    font-weight: 600; color: var(--ink);
    white-space: nowrap;
}
.results-table .best-cell { color: var(--feedback); font-weight: 700; }
.results-table .section-header td {
    background: rgba(31,58,82,0.06);
    font-weight: 700; color: var(--upstream);
    font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 6px 10px;
}

/* ---------- HEATMAP LEGEND ---------- */
.legend-bar {
    display: flex; align-items: center; gap: 8px;
    font-family: var(--sans); font-size: 11px; color: var(--ink-muted);
    margin: 0.5rem 0 1rem;
}
.legend-gradient {
    width: 120px; height: 10px; border-radius: 3px;
    background: linear-gradient(to right, #e8e4dc, var(--feedback));
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
    .cover-title { font-size: 2rem; }
    .cover-pillars { grid-template-columns: 1fr; }
    .chapter h2 { font-size: 1.6rem; }
    .chart-grid.g2 { grid-template-columns: 1fr; }
    .slider-group { flex-direction: column; }
    .property-grid { grid-template-columns: 1fr; }
    .interactive-section { padding: 1rem; }
}
