/* Lamp Bristol — PR Analysis design system (see style/README.md for the spec). */

:root {
    --bg: #F7F6F1;
    --card: #FFFFFF;
    --border: rgba(35, 34, 29, .1);
    --border-soft: rgba(35, 34, 29, .06);
    --border-strong: rgba(35, 34, 29, .14);
    --ink: #23221D;
    --body: #4A473F;
    --secondary: #6E6A60;
    --muted: #8A867B;
    --faint: #B7B2A4;
    --accent: #3D63C9;
    --accent-tint: rgba(61, 99, 201, .1);
    --green: #2E8B6B;
    --red: #BF4E30;
    --amber: #C9962E;
    --orange: #CE7231;
    --dark: #23221D;
    --on-dark: #D8D5CB;
    --font-ui: 'Schibsted Grotesk', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
    --page-pad: clamp(14px, 3vw, 28px);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--body);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3 { color: var(--ink); margin: 0; }
p { margin: 0 0 14px; }

.wrap {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 var(--page-pad) 60px;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .1em;
    color: var(--muted);
    margin: 0 0 14px;
}

/* ---------- Top bar (landing) ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px var(--page-pad);
    background: var(--card);
    border-bottom: 1px solid rgba(35, 34, 29, .09);
}

.topbar-left { display: flex; align-items: center; gap: 10px; }

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
}

.logo-name { font-size: 15.5px; font-weight: 700; color: var(--ink); }

.logo-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.logo-link:hover .logo-name { text-decoration: underline; }

/* Sits right up against the product name it annotates, so it overrides the
 * row's gap rather than reading as a separate item. */
.logo-credit {
    margin-left: -4px;
    font-size: 11.5px;
    color: var(--muted);
}

.logo-credit a { color: inherit; text-decoration: underline; }
.logo-credit a:hover { color: var(--ink); }

.topbar-note { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }

/* ---------- Hero ---------- */

.hero { padding: clamp(28px, 6vw, 56px) 0 26px; }

.hero h1 {
    font-size: clamp(30px, 5.5vw, 46px);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.05;
    margin-bottom: 16px;
    /* When it has to wrap on narrow screens, split the lines evenly
     * rather than stranding a single word. */
    text-wrap: balance;
}

/* Runs the full width of the chart grid below it, rather than the narrower
 * measure a lone paragraph would normally take. */
.hero p { font-size: 16.5px; color: var(--secondary); }

/* ---------- Cards ---------- */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
}

.landing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
    gap: 14px;
    align-items: start;
}

.side-col { display: grid; gap: 14px; }

/* Grid items default to min-width auto, letting wide content (the CLI pre,
 * chart canvases) blow the track out past the viewport on phones. */
.landing-grid > *,
.side-col > *,
.chart-grid > *,
.stat-grid > * { min-width: 0; }

.error-card {
    background: var(--card);
    border: 1px solid rgba(191, 78, 48, .4);
    border-radius: 12px;
    padding: 16px 22px;
    margin-bottom: 16px;
}

.error-card h3 { color: var(--red); font-size: 14.5px; margin-bottom: 6px; }
.error-card p { margin: 0; }

/* ---------- Upload card ---------- */

.dropzone {
    position: relative;
    border: 1.5px dashed rgba(35, 34, 29, .22);
    border-radius: 10px;
    background: #FBFAF7;
    padding: 30px 20px;
    text-align: center;
    transition: border-color .15s, background .15s;
}

.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-tint); }

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: var(--accent-tint);
    color: var(--accent);
    font-size: 16px;
    margin-bottom: 10px;
}

.dropzone-text { color: var(--ink); font-weight: 500; margin-bottom: 4px; }
.dropzone-text .browse { color: var(--accent); text-decoration: underline; cursor: pointer; }
.dropzone-hint { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); margin: 0; }

.file-confirm[hidden] { display: none; }

.file-confirm {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #F2F6EF;
    border: 1px solid rgba(46, 139, 107, .25);
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 12px;
}

.file-confirm-tick { color: var(--green); font-weight: 700; }
.file-confirm-name { font-family: var(--font-mono); font-size: 12px; color: var(--ink); font-weight: 600; }
.file-confirm-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); flex: 1; }

.file-confirm-clear {
    background: none;
    border: 0;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    padding: 2px 6px;
}

.file-confirm-clear:hover { color: var(--red); }

/* ---------- GitHub fetch ---------- */

.field input[type="text"],
.field input[type="password"] {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 9px 12px;
    font: inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: #FBFAF7;
}

.field input[type="text"]:focus,
.field input[type="password"]:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.or-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0 14px;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.or-divider::before,
.or-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }

.token-details { margin-top: 10px; }

.token-details summary {
    font-size: 12.5px;
    color: var(--secondary);
    cursor: pointer;
}

.token-details input,
.token-panel input {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 9px 12px;
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--ink);
    background: #FBFAF7;
}

.token-hint { font-size: 11px; color: var(--muted); margin: 6px 0 0; }

.token-panel {
    border: 1px solid rgba(61, 99, 201, .4);
    background: var(--accent-tint);
    border-radius: 10px;
    padding: 14px 16px;
    margin-top: 12px;
}

.token-panel h3 { font-size: 13.5px; margin-bottom: 6px; }
.token-panel p { font-size: 12.5px; margin-bottom: 8px; }

.token-steps {
    margin: 0 0 4px;
    padding-left: 20px;
    font-size: 12.5px;
    color: var(--body);
}

.token-steps li { margin-bottom: 5px; }
.token-steps a { color: var(--accent); }

/* ---------- Optional fields ---------- */

.optional-fields {
    border: 0;
    border-top: 1px solid var(--border-soft);
    margin: 20px 0 0;
    padding: 16px 0 0;
}

.optional-fields legend { padding: 0 0 4px; }

.field { margin-bottom: 14px; }

.field-label {
    display: block;
    font-size: 13px;
    color: var(--body);
    margin-bottom: 6px;
}

.rating-pills { display: flex; gap: 8px; }

.rating-pill input { position: absolute; opacity: 0; pointer-events: none; }

.rating-pill span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    padding: 6px 0;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--body);
    cursor: pointer;
    transition: all .12s;
}

.rating-pill input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.rating-pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.rating-pill span:hover { border-color: var(--ink); }

.field textarea,
.field input[type="email"] {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 9px 12px;
    font: inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: #FBFAF7;
}

.field textarea:focus,
.field input[type="email"]:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; flex-wrap: wrap; }

.btn-primary {
    background: var(--ink);
    color: #fff;
    border: 0;
    border-radius: 9px;
    padding: 12px 30px;
    font: inherit;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
}

.btn-primary:hover { background: var(--accent); }

.actions-hint { font-size: 12px; color: var(--muted); }

/* ---------- CSV spec card ---------- */

.spec-list {
    display: grid;
    grid-template-columns: 88px 1fr;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 11.5px;
}

.spec-list dt {
    font-weight: 600;
    color: var(--ink);
    padding: 8px 0;
    border-bottom: 1px solid var(--border-soft);
}

.spec-list dd {
    margin: 0;
    color: var(--secondary);
    padding: 8px 0;
    border-bottom: 1px solid var(--border-soft);
}

.spec-list dt:last-of-type,
.spec-list dd:last-of-type { border-bottom: 0; }

/* ---------- CLI card ---------- */

.card-dark { background: var(--dark); border-color: var(--dark); }

.cli-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.eyebrow-dark { color: var(--faint); }

.copy-btn {
    background: transparent;
    border: 1px solid rgba(247, 246, 241, .2);
    border-radius: 5px;
    color: var(--on-dark);
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 4px 10px;
    cursor: pointer;
}

.copy-btn:hover { border-color: rgba(247, 246, 241, .45); }

/* Light-background variant of the copy button, for the permalink note. */
.copy-btn-light {
    border-color: rgba(35, 34, 29, .25);
    color: var(--ink);
}

.copy-btn-light:hover { border-color: rgba(35, 34, 29, .55); }

.permalink-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 18px;
    font-size: 12px;
    color: var(--muted);
}

.permalink-note code {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink);
    background: rgba(35, 34, 29, .05);
    border-radius: 5px;
    padding: 3px 8px;
    overflow-wrap: anywhere;
}

.status-card .permalink-note {
    justify-content: center;
    margin: 14px 0 0;
}

/* First-render-only variant on a freshly submitted dashboard: a call to
   action, so it gets the accent treatment the plain note stays clear of. */
.permalink-flash {
    background: var(--accent-tint);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--body);
}

.permalink-flash strong { color: var(--accent); }

.permalink-flash code { background: var(--card); }

.cli-command {
    margin: 8px 0 0;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.65;
    color: var(--on-dark);
    overflow-x: auto;
    white-space: pre;
}

/* ---------- Waiting / failed status pages ---------- */

.status-card {
    max-width: 560px;
    margin: clamp(40px, 12vh, 120px) auto 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 36px 32px;
    text-align: center;
}

.status-card h1 { font-size: 22px; margin-bottom: 10px; }
.status-card p { color: var(--secondary); }

.status-card-failed { border-color: rgba(191, 78, 48, .4); }
.status-card-failed h1 { color: var(--red); }
.status-card .actions { justify-content: center; }

.status-hint { font-size: 12px; color: var(--muted); }

.status-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    margin-bottom: 14px;
    border: 3px solid var(--accent-tint);
    border-top-color: var(--accent);
    border-radius: 999px;
    animation: status-spin 0.9s linear infinite;
}

@keyframes status-spin {
    to { transform: rotate(360deg); }
}

.include-lines { margin-top: 8px; font-size: 12px; color: var(--secondary); }

/* ---------- Landing: teaser + mode toggle ---------- */

.chart-box-teaser { cursor: default; }

.demo-actions { margin-top: 18px; }

.mode-toggle { margin-bottom: 18px; }

.mode-toggle .segment { padding: 8px 16px; font-size: 12px; }

.info-steps {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    color: var(--body);
}

.info-steps li { margin-bottom: 10px; }

.privacy-line {
    margin: 16px 0 0;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--border-soft);
    padding-top: 12px;
}

.scale-hint { color: var(--muted); font-size: 12px; }

/* ---------- Results: sticky header ---------- */

.results-head {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--card);
    border-bottom: 1px solid rgba(35, 34, 29, .09);
    padding: 10px var(--page-pad);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.results-head-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn-ghost {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 7px 12px;
    transition: border-color .15s;
}

.btn-ghost:hover { border-color: var(--ink); }

.file-chip {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink);
    background: #F2F1EB;
    border-radius: 6px;
    padding: 3px 8px;
}

.results-meta { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

.results-controls { justify-content: flex-end; }

.checkbox-control {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: var(--body);
    cursor: pointer;
}

.checkbox-control input { width: 14px; height: 14px; accent-color: var(--accent); }

.segmented {
    display: inline-flex;
    background: #F2F1EB;
    border-radius: 8px;
    padding: 2px;
}

.segment {
    border: 0;
    background: transparent;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--body);
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.segment.is-active { background: var(--ink); color: #fff; }

/* ---------- Stat cards ---------- */

.results { padding-top: 22px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
    gap: 12px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .06em;
    color: var(--muted);
    margin: 0 0 6px;
}

.stat-value {
    font-size: 27px;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    margin: 0 0 4px;
    line-height: 1.1;
}

.stat-sub { font-size: 11px; font-weight: 500; margin: 0; }
.stat-sub-bad { color: var(--red); }
.stat-sub-good { color: var(--green); }
.stat-sub-neutral { color: var(--muted); }

/* ---------- Chart sections ---------- */

.chart-section { margin-top: 28px; }

.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

.section-head .eyebrow {
    font-size: 10.5px;
    letter-spacing: .12em;
    color: var(--ink);
    margin: 0;
}

.section-rule { flex: 1; height: 1px; background: var(--border); }

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
    gap: 13px;
}

.chart-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 15px 17px 12px;
    transition: border-color .15s;
}

.chart-card:hover { border-color: rgba(61, 99, 201, .45); }

.chart-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.chart-card h3 { font-size: 13.5px; font-weight: 700; margin-bottom: 2px; }

.chart-desc { font-size: 11px; color: var(--muted); margin: 0; }

.chart-note { font-size: 10.5px; color: var(--amber); margin: 4px 0 0; }

/* Sits below the canvas rather than in the card head, and states a fact
 * about the sample rather than warning about missing data — so it drops
 * the amber for the muted grey the other captions use. */
.chart-note-under { margin-top: 10px; color: var(--muted); }

.chart-box { position: relative; height: 200px; margin-top: 12px; cursor: zoom-in; }

/* ---------- Expanded chart modal ---------- */

.chart-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(35, 34, 29, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 3vw, 32px);
}

.chart-modal[hidden] { display: none; }

.chart-modal-card {
    background: var(--card);
    border-radius: 12px;
    width: min(1200px, 100%);
    height: min(780px, 100%);
    display: flex;
    flex-direction: column;
    padding: 18px 22px 20px;
}

.chart-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.chart-modal-head h3 { font-size: 16px; font-weight: 700; }

.chart-modal-close {
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--muted);
    font-size: 13px;
    padding: 5px 10px;
    cursor: pointer;
}

.chart-modal-close:hover { color: var(--ink); border-color: var(--ink); }

.chart-modal-box { position: relative; flex: 1; min-height: 0; margin-top: 14px; }

.chart-toggle {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.toggle-btn {
    background: transparent;
    border: 0;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 10.5px;
    padding: 4px 10px;
    cursor: pointer;
}

.toggle-btn:hover { color: var(--ink); }
.toggle-btn.is-active { background: var(--accent-tint); color: var(--ink); }

.toggle-pill {
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 10.5px;
    padding: 4px 10px;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-pill:hover { color: var(--ink); }
.toggle-pill.is-active { background: var(--accent-tint); color: var(--ink); border-color: rgba(61, 99, 201, .4); }

/* ---------- Summary table ---------- */

.table-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.table-scroll { overflow-x: auto; }

.summary-table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
}

.summary-table th {
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .05em;
    color: var(--muted);
    text-align: right;
    padding: 12px 14px 8px;
    border-bottom: 1px solid var(--border);
}

.summary-table td {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--body);
    text-align: right;
    font-variant-numeric: tabular-nums;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-soft);
}

.summary-table th:first-child,
.summary-table td:first-child { text-align: left; }

.summary-table tbody tr:last-child td { border-bottom: 0; }
.summary-table tbody tr:hover { background: #FBFAF7; }

.cell-month { font-weight: 600; color: var(--ink); }
.net-bad { color: var(--red); }
.net-good { color: var(--green); }

/* ---------- Submission details (results) ---------- */

.submission-details {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.submission-details > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 13px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    list-style: none;
}

.submission-details > summary::-webkit-details-marker { display: none; }

.submission-details > summary::before {
    content: '▸';
    font-size: 10px;
    color: var(--muted);
}

.submission-details[open] > summary::before { content: '▾'; }
.submission-details > summary:hover { color: var(--accent); }

.detail-list {
    display: grid;
    grid-template-columns: 104px 1fr;
    margin: 0;
    padding: 0 16px 4px;
    font-size: 12.5px;
}

.detail-list dt {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    padding: 9px 0;
    border-top: 1px solid var(--border-soft);
}

.detail-list dd {
    margin: 0;
    padding: 9px 0;
    color: var(--body);
    border-top: 1px solid var(--border-soft);
    overflow-wrap: anywhere;
}

.detail-notes { line-height: 1.6; }

/* ---------- AI analysis (results) ---------- */

/* The results header is sticky, so an unadjusted jump would park the section
 * heading underneath it. */
#ai-analysis { scroll-margin-top: 100px; }

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

.ai-analysis h3 { font-size: 17px; margin: 0 0 8px; }
.ai-analysis p { color: var(--secondary); }
.ai-analysis .actions { margin-bottom: 0; }
.ai-analysis .actions-hint a { color: var(--accent); }

/* ---------- Methodology page ---------- */

.methodology-note {
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-soft);
}

.methodology-note a { color: var(--accent); }

/* The methodology is one markdown file, shown as it is written: the page and
 * the .md endpoint serve the same characters, so neither can drift. */
.methodology {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.75;
    color: var(--body);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
