/* ============================================
   The 2nd & 10 Dip
   Page styles only. Tokens (--bg-*, --text-*, --border, --font-*) come from
   style.css, which is dark only. The chart colors below are a validated,
   colorblind-safe palette on the dark surface: use them as they are.
   second-and-ten.js reads them from here, so they are defined once.
   ============================================ */

.dip-page {
    --dip-ten: #c48800;
    --dip-context: #8b90a8;
    --dip-run: #1f9e88;
    --dip-dropback: #5b8def;
    --dip-first: #e8e8f0;
    --dip-grid: rgba(255, 255, 255, 0.06);
    --dip-tick: #9090a8;
}

/* --- Page frame --- */
.dip-main {
    flex: 1 0 auto;
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

.dip-hero {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.dip-eyebrow {
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.dip-hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 4rem);
    letter-spacing: 0.02em;
    line-height: 0.95;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.dip-lede {
    max-width: 70ch;
    font-size: 1.0625rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.dip-lede:empty {
    display: none;
}

.dip-num {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

/* --- Failure state: the message replaces everything that needs the data --- */
.dip-error {
    display: none;
    max-width: 70ch;
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--rating-poor);
    border-radius: var(--radius-md);
}

.dip-failed .dip-error {
    display: block;
}

.dip-failed [data-needs-data] {
    display: none;
}

/* --- Sections --- */
.dip-section {
    margin-bottom: 3.5rem;
    min-width: 0;
}

.dip-section h2,
.dip-explorer h2 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    letter-spacing: 0.03em;
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.dip-note {
    max-width: 70ch;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.dip-takeaway {
    max-width: 70ch;
    margin-top: 0.875rem;
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text-primary);
}

.dip-takeaway:empty {
    display: none;
}

/* --- Legends (HTML, not canvas) --- */
.dip-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem 1.25rem;
    list-style: none;
    margin: 0.5rem 0 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.dip-legend li {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.dip-legend li[hidden] {
    display: none;
}

.dip-swatch {
    display: inline-block;
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--dip-context);
}

.dip-swatch-ten { background: var(--dip-ten); }
.dip-swatch-context { background: var(--dip-context); }
.dip-swatch-run { background: var(--dip-run); }
.dip-swatch-dropback { background: var(--dip-dropback); }

.dip-swatch-bar {
    width: 10px;
    height: 12px;
    border-radius: 3px 3px 0 0;
}

.dip-swatch-tick {
    width: 14px;
    height: 0;
    border-radius: 0;
    border-top: 2px solid var(--dip-first);
    background: none;
}

.dip-swatch-dash {
    width: 16px;
    height: 0;
    border-radius: 0;
    border-top: 2px dashed var(--dip-context);
    background: none;
}

/* --- Chart frames: fixed height, so the responsive canvas never grows on its own --- */
.dip-chart {
    position: relative;
    width: 100%;
    min-width: 0;
    height: 320px;
}

.dip-chart-panel {
    height: 240px;
}

.dip-chart-bars {
    height: 340px;
}

.dip-chart canvas {
    display: block;
}

/* --- Four quarter panels: one column on a phone, two at 720px and up --- */
.dip-panels {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    margin: 1rem 0 0.5rem;
}

.dip-panel {
    min-width: 0;
    margin: 0;
}

.dip-panel h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

@media (min-width: 720px) {
    .dip-panels {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* --- Explorer card --- */
.dip-explorer {
    min-width: 0;
    margin-bottom: 3.5rem;
    padding: 1.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.dip-subsection {
    min-width: 0;
    margin-top: 2rem;
}

.dip-subsection h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    letter-spacing: 0.03em;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.dip-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem 1.5rem;
    margin-top: 1rem;
}

.dip-control {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.dip-control > label,
.dip-control > legend {
    display: block;
    margin-bottom: 0.375rem;
    padding: 0;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.dip-control-seasons {
    flex: 1 1 22rem;
}

.dip-seasons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
}

/* Down and quarter: real radio inputs, hidden but still focusable, with the labels as
   the buttons. The checked label is the light one; focus shows as an amber ring. */
.dip-segmented {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

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

.dip-segmented label {
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.dip-segmented label:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dip-segmented input:checked + label {
    color: var(--bg-deep);
    background: var(--text-primary);
    border-color: var(--text-primary);
}

.dip-segmented input:focus-visible + label {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Score: while a band's numbers load, the group is marked busy (the charts keep the band
   they show) and one line under the controls says which band is loading; the same line says
   when a band could not be loaded. The line stays in the page when empty, with nothing
   visible, so a screen reader announces it. */
.dip-control[aria-busy="true"] .dip-segmented {
    opacity: 0.6;
}

.dip-control[aria-busy="true"] .dip-segmented label {
    cursor: progress;
}

.dip-score-message {
    margin: 0;
}

.dip-score-message:not(:empty) {
    margin-top: 1rem;
    padding-left: 0.75rem;
    color: var(--text-primary);
    border-left: 3px solid var(--rating-poor);
}

/* Loading is not a failure: the same line, with the page's accent where a failure has red. */
.dip-score-message.dip-score-loading {
    color: var(--text-secondary);
    border-left-color: var(--accent);
}

.dip-select {
    min-width: 7.5rem;
    padding: 0.4rem 0.6rem;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color-scheme: dark;
}

.dip-slider {
    flex: 1 1 180px;
    min-width: 0;
    accent-color: var(--accent);
}

.dip-selected {
    min-width: 5.5em;
    font-family: var(--font-display);
    font-size: 1.5rem;
    letter-spacing: 0.03em;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.dip-button {
    min-width: 8.5rem;
    padding: 0.5rem 1rem;
    text-align: center;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.dip-button:hover:not(:disabled) {
    background: var(--bg-hover);
}

@media (prefers-reduced-motion: reduce) {
    .dip-button,
    .dip-segmented label {
        transition: none;
    }
}

.dip-button:disabled,
.dip-select:disabled,
.dip-slider:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.dip-slider:focus-visible,
.dip-select:focus-visible,
.dip-button:focus-visible,
.dip-details summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* --- Details: the numbers table and the method list --- */
.dip-details {
    margin-top: 2rem;
}

.dip-details summary {
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
}

.dip-details[open] summary {
    margin-bottom: 0.75rem;
}

.dip-table-wrap {
    overflow-x: auto;
}

.dip-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.dip-table th,
.dip-table td {
    padding: 0.5rem 0.75rem;
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

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

.dip-table th {
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom-color: var(--border-light);
}

.dip-table td {
    color: var(--text-secondary);
}

.dip-table .dip-row-hl td {
    color: var(--text-primary);
    font-weight: 700;
    background: rgba(196, 136, 0, 0.1);
}

.dip-method {
    margin-top: 0;
}

.dip-method ul {
    max-width: 70ch;
    padding-left: 1.25rem;
    font-size: 0.9375rem;
    line-height: 1.65;
    color: var(--text-secondary);
}

.dip-method li + li {
    margin-top: 0.5rem;
}

/* --- Phones --- */
@media (max-width: 600px) {
    .dip-main {
        padding: 1.5rem 1rem 3rem;
    }

    .dip-explorer {
        padding: 1rem;
    }

    .dip-chart {
        height: 280px;
    }

    .dip-chart-panel {
        height: 230px;
    }

    .dip-chart-bars {
        height: 300px;
    }

    .dip-table th,
    .dip-table td {
        padding: 0.375rem 0.5rem;
    }
}
