/* ==========================================================================
   Emotion-Preserving Streaming Speaker Anonymization — Demo Page
   Clean academic design with warm accents
   ========================================================================== */

:root {
    --primary: #2c2c2c;
    --accent: #c4654a;
    --accent-subtle: rgba(196, 101, 74, 0.08);

    --angry: #b84233;
    --happy: #d4943a;
    --sad: #5a7f94;
    --neutral: #7a7672;

    --bg: #ffffff;
    --bg-alt: #f8f6f3;
    --text: #2c2c2c;
    --text-mid: #555;
    --text-light: #888;
    --border: #e5e0db;

    --shadow: 0 1px 4px rgba(0,0,0,0.06);
    --radius: 6px;

    --serif: 'Literata', Georgia, serif;
    --sans: 'Source Sans 3', system-ui, sans-serif;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--sans);
    color: var(--text);
    background: var(--bg);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 24px;
}

img { max-width: 100%; height: auto; }
strong { font-weight: 600; }

/* === Header === */
.header {
    padding: 56px 24px 40px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.header h1 {
    font-family: var(--serif);
    font-size: clamp(1.4rem, 3.5vw, 2rem);
    font-weight: 700;
    line-height: 1.25;
    color: var(--primary);
    max-width: 760px;
    margin: 0 auto 12px;
}

.subtitle {
    font-family: var(--sans);
    font-size: 0.95rem;
    color: var(--text-light);
    font-weight: 400;
}

.resource-links {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}

.resource-btn {
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 6px 16px;
    background: var(--accent-subtle);
    transition: background 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.resource-btn svg {
    flex-shrink: 0;
}

.resource-btn:hover {
    background: var(--accent);
    color: #fff;
}

/* === Sections === */
.section {
    padding: 48px 0;
}

.section-alt {
    background: var(--bg-alt);
}

.section h2 {
    font-family: var(--serif);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

.section-desc {
    color: var(--text-mid);
    margin-bottom: 20px;
    max-width: 700px;
    font-size: 0.93rem;
}

.subsection-heading {
    font-family: var(--serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    margin: 36px 0 12px;
}

.caption {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 10px;
    text-align: center;
    line-height: 1.5;
}

/* === Abstract === */
.abstract-text {
    font-family: var(--serif);
    font-size: 1rem;
    line-height: 1.75;
    max-width: 800px;
    color: var(--text);
}

/* === Architecture === */
.architecture-figure {
    text-align: center;
    margin-bottom: 28px;
}

.architecture-figure img {
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.method-points {
    max-width: 720px;
}

.method-point {
    display: flex;
    gap: 12px;
    align-items: baseline;
    margin-bottom: 12px;
}

.point-marker {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    background: var(--accent);
    border-radius: 50%;
    margin-top: 8px;
}

.method-point p {
    font-size: 0.93rem;
    line-height: 1.6;
    color: var(--text-mid);
}

.method-point strong {
    color: var(--text);
}

/* === Figures === */
.figure-full {
    text-align: center;
    max-width: 520px;
    margin: 0 auto;
}

.figure-full img {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* === Tables === */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    font-family: var(--sans);
}

.results-table thead {
    background: var(--primary);
    color: #fff;
}

.results-table th {
    padding: 10px 14px;
    text-align: center;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.results-table th:first-child,
.results-table th:nth-child(2) {
    text-align: left;
}

.results-table td {
    padding: 9px 14px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}

.results-table td:first-child,
.results-table td:nth-child(2) {
    text-align: left;
    font-weight: 500;
}

.results-table tbody tr:hover {
    background: var(--accent-subtle);
}

.highlight-row {
    background: var(--accent-subtle) !important;
}

.highlight-row td {
    border-bottom: 2px solid var(--accent) !important;
}

.table-note {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 8px;
    line-height: 1.5;
}

.grayed-row {
    opacity: 0.45;
}

.offline-row {
    background: #f9f7f4;
}

.indent-td {
    padding-left: 24px !important;
}

.results-table u {
    text-underline-offset: 2px;
}

.index-terms {
    font-size: 0.9rem;
    color: var(--text-mid);
    margin-top: 12px;
}

/* Ablation table with multi-row header */
.ablation-table th {
    font-size: 0.68rem;
    padding: 7px 6px;
}

.ablation-table td {
    font-size: 0.82rem;
    padding: 7px 6px;
}

.ablation-table thead tr:first-child th {
    border-bottom: none;
    padding-bottom: 2px;
}

.ablation-table thead tr:nth-child(2) th {
    padding-top: 2px;
}

/* === Spotlight === */
.spotlight {
    background: var(--primary);
    color: #fff;
}

.spotlight h2 {
    color: #fff;
    border-bottom-color: var(--accent);
}

.spotlight-desc {
    color: rgba(255,255,255,0.7);
    max-width: 700px;
    margin-bottom: 28px;
    font-size: 0.93rem;
    line-height: 1.65;
}

.spotlight-samples {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.sample-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
}

.spotlight-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.player-cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.player-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.player-label.accent {
    color: var(--accent);
    font-weight: 700;
}

.waveform {
    background: rgba(255,255,255,0.06);
    border-radius: var(--radius);
    min-height: 64px;
    cursor: pointer;
    position: relative;
    transition: background 0.15s;
}

.waveform:hover {
    background: rgba(255,255,255,0.1);
}

.waveform.no-audio {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.25);
    font-size: 0.75rem;
}

/* Play button overlay */
.wave-play-btn {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, transform 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    padding: 0;
}

.wave-play-btn:hover {
    transform: translateY(-50%) scale(1.1);
}

.grid-cell .wave-play-btn,
.ablation-row .wave-play-btn {
    background: var(--primary);
}

.grid-cell .wave-play-btn:hover,
.ablation-row .wave-play-btn:hover {
    background: var(--accent);
}

/* === Tabs === */
.emotion-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    width: fit-content;
}

.tab {
    padding: 8px 20px;
    border: none;
    background: transparent;
    font-family: var(--sans);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

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

.tab.active {
    font-weight: 600;
    border-bottom-color: currentColor;
}

.tab.active[data-emotion="angry"]  { color: var(--angry); }
.tab.active[data-emotion="happy"]  { color: var(--happy); }
.tab.active[data-emotion="sad"]    { color: var(--sad); }
.tab.active[data-emotion="neutral"]{ color: var(--neutral); }

/* === Comparison Grid === */
.comparison-grid {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    overflow-x: auto;
}

.grid-header {
    display: grid;
    grid-template-columns: 90px repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.header-cell {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
}

.highlight-header {
    color: var(--accent);
}

.grid-row {
    display: grid;
    grid-template-columns: 90px repeat(6, 1fr);
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0ece7;
}

.grid-row:last-child { border-bottom: none; }

.row-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.play-row-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 0.65rem;
    cursor: pointer;
    color: var(--text-light);
    font-family: var(--sans);
    transition: all 0.15s;
    white-space: nowrap;
}

.play-row-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.grid-cell .waveform {
    background: var(--bg-alt);
    min-height: 48px;
}

.grid-cell .waveform:hover {
    background: #ede9e3;
}

.grid-cell .waveform.no-audio {
    color: var(--text-light);
    opacity: 0.4;
}

/* === Ablation Audio === */
.ablation-grid {
    margin-top: 16px;
}

.ablation-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.ablation-row .waveform {
    background: var(--bg-alt);
    min-height: 48px;
}

.ablation-row .waveform:hover {
    background: #ede9e3;
}

.ablation-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
}

/* === Footer === */
.footer {
    border-top: 1px solid var(--border);
    padding: 32px 0;
    text-align: center;
}

.bibtex-details summary {
    cursor: pointer;
    color: var(--text-light);
    font-size: 0.85rem;
}

.bibtex-details summary:hover {
    color: var(--text-mid);
}

.bibtex {
    margin-top: 12px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: left;
    font-size: 0.8rem;
    overflow-x: auto;
    color: var(--text-mid);
    font-family: 'SF Mono', Consolas, monospace;
    line-height: 1.5;
    display: inline-block;
}

/* === Responsive === */
@media (max-width: 768px) {
    .header { padding: 40px 16px 28px; }
    .section { padding: 36px 0; }

    .spotlight-row { grid-template-columns: 1fr; }

    .emotion-tabs { width: 100%; }
    .tab { flex: 1; text-align: center; padding: 8px 10px; }

    .grid-header,
    .grid-row {
        grid-template-columns: 72px repeat(6, minmax(72px, 1fr));
    }

    .results-table { font-size: 0.8rem; }
    .results-table th, .results-table td { padding: 7px 8px; }
}

@media (max-width: 480px) {
    .container { padding: 0 16px; }
}
