/* ObfusBench — clean, academic styling */

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    --color-bg: #ffffff;
    --color-fg: #1a1a1a;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-accent: #2563eb;
    --color-accent-hover: #1d4ed8;
    --color-row-hover: #f9fafb;
    --color-card-bg: #f3f4f6;
    --max-width: 1100px;
}

html {
    font-size: 15px;
    line-height: 1.6;
}

body {
    margin: 0;
    font-family: var(--font-stack);
    color: var(--color-fg);
    background: var(--color-bg);
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    color: var(--color-accent-hover);
}

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--color-card-bg);
    padding: 0.15em 0.35em;
    border-radius: 3px;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.site-header {
    border-bottom: 1px solid var(--color-border);
    padding: 1.5rem 0 1rem;
}

.site-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.site-header h1 a {
    color: var(--color-fg);
}

.site-header .tagline {
    margin: 0.25rem 0 0;
    color: var(--color-muted);
    font-size: 0.95rem;
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 0;
    margin-top: 3rem;
    color: var(--color-muted);
    font-size: 0.85rem;
}

/* Leaderboard */
.leaderboard {
    margin-top: 2rem;
}

/* Target tabs (top-level switch between benchmark targets) */
.target-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.5rem;
}

.target-tab {
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    color: var(--color-muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.target-tab:hover {
    color: var(--color-accent);
}

.target-tab.is-active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.leaderboard h2 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.impl-count {
    color: var(--color-muted);
    font-size: 0.9rem;
    margin-top: 0;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    white-space: nowrap;
}

thead th {
    position: sticky;
    top: 0;
    background: var(--color-bg);
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--color-fg);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

thead th.numeric {
    text-align: right;
}

thead th .unit {
    font-weight: 400;
    color: var(--color-muted);
    font-size: 0.85em;
}

thead th[aria-sort="ascending"]::after {
    content: " \25B2";
    font-size: 0.7em;
}

thead th[aria-sort="descending"]::after {
    content: " \25BC";
    font-size: 0.7em;
}

tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

tbody td.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Derived cost (price x total time), shown under the total-time value. */
.cell-cost {
    display: block;
    font-size: 0.8em;
    color: var(--color-text-muted, #6b7280);
}

tbody tr:hover {
    background: var(--color-row-hover);
}

/* Spotlight — disabled for now; re-enable together with the markup in
   templates/index.html and the code in static/app.js.
.spotlight {
    margin-bottom: 2rem;
    border: 2px solid var(--color-accent);
    border-radius: 8px;
    background: linear-gradient(135deg, #eff6ff, #f8fafc);
    overflow: hidden;
}

.spotlight-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 0;
}

.spotlight-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    text-align: center;
}

.spotlight-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-accent);
    margin-bottom: 0.25rem;
}

.spotlight-value {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--color-fg);
    font-variant-numeric: tabular-nums;
}

.spotlight-unit {
    font-size: 1rem;
    color: var(--color-muted);
    margin-bottom: 0.5rem;
}

.spotlight-name {
    font-size: 1rem;
    font-weight: 600;
}

.spotlight-details {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    border-left: 1px solid var(--color-border);
}

.spotlight-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    white-space: normal;
}

.spotlight-table td {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.spotlight-table td:first-child {
    color: var(--color-muted);
    font-weight: 600;
    white-space: nowrap;
}

.spotlight-table td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.spotlight-table tr:last-child td {
    border-bottom: none;
}

@media (max-width: 600px) {
    .spotlight-inner {
        grid-template-columns: 1fr;
    }

    .spotlight-details {
        border-left: none;
        border-top: 1px solid var(--color-border);
    }

    .spotlight-hero {
        padding: 1.5rem 1rem;
    }

    .spotlight-value {
        font-size: 2.2rem;
    }
}
*/

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-muted);
}

.empty-state p {
    margin: 0.5rem 0;
}

/* Detail page */
.detail {
    margin-top: 2rem;
}

.back-link {
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.detail h2 {
    margin-bottom: 1.5rem;
}

.metadata {
    margin-bottom: 2rem;
}

.metadata dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.4rem 1.5rem;
    margin: 0;
}

.metadata dt {
    font-weight: 600;
    color: var(--color-muted);
}

.metadata dd {
    margin: 0;
}

.metrics-section {
    margin-bottom: 2rem;
}

.metrics-section h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.4rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.metric-card {
    background: var(--color-card-bg);
    border-radius: 6px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--color-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

.metric-value {
    font-size: 1.3rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.metric-value .unit {
    font-size: 0.65em;
    font-weight: 400;
    color: var(--color-muted);
}

/* Time / size breakdown (detail page): 100% stacked bar + share table */
.breakdown {
    margin-top: 1.5rem;
}

.breakdown-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.4rem;
}

.breakdown-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-muted);
}

.breakdown-total {
    font-size: 0.85rem;
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.breakdown-total .unit {
    font-size: 0.85em;
}

.breakdown-bar {
    display: flex;
    width: 100%;
    height: 14px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--color-card-bg);
}

.breakdown-seg {
    height: 100%;
    min-width: 1px;
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 0.6rem;
    white-space: normal;
}

.breakdown-table th,
.breakdown-table td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}

.breakdown-table th {
    position: static;
    top: auto;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
    color: var(--color-muted);
    cursor: default;
    border-bottom: 1px solid var(--color-border);
}

.breakdown-table th.numeric,
.breakdown-table td.numeric {
    text-align: right;
}

.breakdown-table td {
    font-variant-numeric: tabular-nums;
}

.breakdown-table tr:last-child td {
    border-bottom: none;
}

.swatch {
    display: inline-block;
    width: 0.7em;
    height: 0.7em;
    border-radius: 2px;
    margin-right: 0.45em;
}

.share-cell {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.share-track {
    display: inline-block;
    width: 70px;
    height: 8px;
    background: var(--color-card-bg);
    border-radius: 2px;
    overflow: hidden;
}

.share-fill {
    display: block;
    height: 100%;
    min-width: 1px;
}

.share-pct {
    min-width: 3.4em;
    text-align: right;
}

/* Charts */
.charts {
    margin: 1.5rem 0 2.5rem;
}

.charts h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.chart-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.chart-tab {
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chart-tab:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.chart-tab.is-active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #ffffff;
}

/* View controls float over the top-right of the chart so it reads as "this
   changes the chart view", visually distinct from the tab-style selectors. */
.chart-controls {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 2;
    display: flex;
    gap: 0.4rem;
}

.chart-action {
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(2px);
    color: var(--color-fg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.chart-action:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.chart-canvas-wrap {
    position: relative;
    height: 380px;
    width: 100%;
}

.chart-canvas {
    cursor: grab;
}

.chart-canvas:active {
    cursor: grabbing;
}

.chart-hint {
    margin: 0.4rem 0 0;
    font-size: 0.8rem;
    color: var(--color-muted);
}

/* 404 */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

/* Responsive */
@media (max-width: 600px) {
    html {
        font-size: 14px;
    }

    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }

    .metadata dl {
        grid-template-columns: 1fr;
    }
}
