/* The Uncomfortable Math of UGC - mirettes.io Style */

@import url('https://fonts.googleapis.com/css2?family=Work+Sans:wght@400;500;600;700&display=swap');

:root {
    /* mirettes.io palette */
    --color-bg: #F0EEE8;
    --color-bg-warm: #E8E4DC;
    --color-text: #7A7068;
    --color-text-muted: #9A958D;
    --color-text-light: #B5B0A8;
    --color-accent: #7A7068;
    --color-border: rgba(122, 112, 104, 0.2);
    --color-border-strong: rgba(122, 112, 104, 0.4);

    /* Functional colors for charts - more saturated */
    --color-phase-1: #D4854A;
    --color-phase-2: #4A9B5A;
    --color-phase-3: #C45040;

    --color-viewers: #D4854A;
    --color-creators: #C45040;
    --color-platform: #9B6BAB;
    --color-revenue: #4A9B5A;

    --font-main: 'Work Sans', -apple-system, system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    font-weight: 400;
    line-height: 1.7;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

/* Selection */
::selection {
    background: var(--color-text);
    color: var(--color-bg);
}

/* Layout */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 clamp(1.5rem, 5vw, 4rem);
}

/* Header */
header {
    background: var(--color-bg-warm);
    color: var(--color-text);
    padding: clamp(0.6rem, 1.8vw, 1.2rem) 0;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.header-bg-chart {
    position: absolute;
    top: 60%;
    left: 0;
    transform: translateY(-50%);
    width: 100%;
    height: 200px;
    opacity: 0.12;
    pointer-events: none;
}

header .container {
    position: relative;
    z-index: 1;
}

header h1 {
    font-size: clamp(1.6rem, 4vw, 2.8rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 0.25em;
}

header .subtitle {
    font-size: clamp(1rem, 2vw, 1.4rem);
    font-weight: 400;
    opacity: 0.85;
}

/* Navigation */
nav {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 1rem;
    padding: 0.75rem 0;
    max-width: 900px;
    margin: 0 auto;
    padding-left: clamp(1rem, 3vw, 2rem);
    padding-right: clamp(1rem, 3vw, 2rem);
    overflow-x: auto;
}

nav a {
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
    transition: opacity 0.2s;
    white-space: nowrap;
}

nav a:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* Sections */
section {
    margin: 0 auto;
    padding: clamp(2rem, 5vw, 4rem) clamp(1.5rem, 5vw, 4rem);
    max-width: 900px;
    border-bottom: 1px solid var(--color-border);
}

section:last-of-type {
    border-bottom: none;
}

section h2 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 1.5rem;
    letter-spacing: -0.01em;
}

section h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 2rem 0 1rem;
}

section h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 1.5rem 0 0.75rem;
}

p {
    margin-bottom: 1rem;
    color: var(--color-text);
}

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

a:hover {
    text-decoration: none;
}

ul, ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
}

strong {
    font-weight: 600;
}

/* Visualization Section */
#visualization-section {
    padding-top: 2rem;
    padding-bottom: 2rem;
    background: rgba(122, 112, 104, 0.06);
    max-width: 100%;
    border-bottom: none;
}

#visualization-section .container,
#visualization-section > * {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

#visualization {
    width: 100%;
    min-height: 500px;
    background: transparent;
}

#visualization svg {
    width: 100%;
    height: auto;
}

/* Chart Tooltip */
.chart-tooltip {
    position: absolute;
    background: var(--color-text);
    color: var(--color-bg);
    padding: 12px 16px;
    border-radius: 0;
    font-size: 0.8rem;
    font-weight: 500;
    pointer-events: none;
    z-index: 1000;
    line-height: 1.6;
}

/* Controls */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(190, 52, 85, 0.08);
    border-radius: 0;
}

.controls button {
    padding: 0.6rem 1.5rem;
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 600;
    border: 2px solid var(--color-text);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: var(--color-text);
}

.controls button:hover {
    background: var(--color-text);
    color: var(--color-bg);
}

#play-btn {
    background: var(--color-text);
    color: var(--color-bg);
    min-width: 100px;
}

#play-btn:hover {
    background: transparent;
    color: var(--color-text);
}

#play-btn.active {
    background: var(--color-phase-3);
    border-color: var(--color-phase-3);
}

#reset-btn {
    background: transparent;
}

#time-slider {
    flex: 1;
    max-width: 400px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--color-border-strong);
    border-radius: 0;
    cursor: pointer;
}

#time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--color-text);
    border-radius: 50%;
    cursor: pointer;
}

/* Metrics Display */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    margin: 1rem 0;
}

.metric-card {
    background: rgba(255, 255, 255, 0.6);
    padding: 0.4rem 0.25rem;
    border-radius: 0;
    text-align: center;
    border-left: 2px solid var(--color-border);
}

.metric-card.viewers { border-left-color: var(--color-viewers); }
.metric-card.viewers .value { color: var(--color-viewers); }
.metric-card.creators { border-left-color: var(--color-creators); }
.metric-card.creators .value { color: var(--color-creators); }
.metric-card.platform { border-left-color: var(--color-platform); }
.metric-card.platform .value { color: var(--color-platform); }

.metric-card .value {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
    white-space: nowrap;
}

.metric-card .label {
    font-size: 0.55rem;
    color: var(--color-text-muted);
    margin-top: 0.1rem;
    font-weight: 500;
    white-space: nowrap;
}


/* Trend Indicators */
.trend-indicator {
    display: inline-block;
    font-weight: 700;
    font-size: 0.9em;
    margin-left: 2px;
}

.trend-up { color: var(--color-revenue); }
.trend-down { color: var(--color-creators); }
.trend-stable { color: var(--color-text-light); font-size: 0.8em; }

/* Horizon Bar */
.trend-horizon {
    position: relative;
    width: 100%;
    height: 3px;
    background: var(--color-border);
    border-radius: 0;
    margin-top: 4px;
    overflow: hidden;
}

.trend-horizon-center {
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    background: var(--color-text-muted);
    transform: translateX(-50%);
    z-index: 2;
}

.trend-horizon-bar {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 0;
    transition: width 0.3s ease;
}

/* Concentration Effect Badges */
.conc-effect {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 0;
    margin-left: 2px;
    vertical-align: middle;
}

.conc-gain {
    background: rgba(39, 174, 96, 0.2);
    color: var(--color-revenue);
}

.conc-loss {
    background: rgba(190, 52, 85, 0.2);
    color: var(--color-creators);
}

/* Phase Cards */
.phases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.phase-card {
    padding: 1.25rem;
    background: transparent;
    border: 1px solid var(--color-border-strong);
}

.phase-card h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.phase-card p {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: 0;
}


/* Math Equations */
.equation {
    background: rgba(190, 52, 85, 0.06);
    padding: 1.25rem;
    margin: 1.5rem 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    overflow-x: auto;
    border-left: 3px solid var(--color-border-strong);
}

.equation-label {
    font-family: var(--font-main);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* Parameter Controls */
.parameters {
    background: rgba(190, 52, 85, 0.06);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-left: 3px solid var(--color-border-strong);
}

.parameters h4 {
    margin-bottom: 1rem;
    margin-top: 0;
    font-weight: 600;
}

.param-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.param-row label {
    min-width: 200px;
    font-size: 0.85rem;
    font-weight: 500;
}

.param-row input {
    width: 100px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--color-border-strong);
    border-radius: 0;
    font-family: var(--font-main);
    font-size: 0.85rem;
    background: white;
    color: var(--color-text);
}

.param-row input:focus {
    outline: none;
    border-color: var(--color-text);
}

.param-row .unit {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

#update-params {
    margin-top: 1rem;
    padding: 0.6rem 1.2rem;
    background: var(--color-text);
    color: var(--color-bg);
    border: 2px solid var(--color-text);
    border-radius: 0;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

#update-params:hover {
    background: transparent;
    color: var(--color-text);
}

/* Key Insight Box */
.insight-box {
    background: rgba(190, 52, 85, 0.08);
    border-left: 3px solid var(--color-text);
    padding: 1.25rem;
    margin: 2rem 0;
}

.insight-box h4 {
    color: var(--color-text);
    margin-bottom: 0.5rem;
    margin-top: 0;
    font-weight: 700;
}

.insight-box p {
    margin-bottom: 0.75rem;
}

.insight-box p:last-child {
    margin-bottom: 0;
}

/* Phase Indicator */
.phase-indicator {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid;
}

.phase-indicator.phase-1 { border-color: var(--color-phase-1); color: var(--color-phase-1); }
.phase-indicator.phase-2 { border-color: var(--color-phase-2); color: var(--color-phase-2); }
.phase-indicator.phase-3 { border-color: var(--color-phase-3); color: var(--color-phase-3); }

/* References */
.references-list {
    padding-left: 1.5rem;
}

.references-list li {
    margin-bottom: 1rem;
    font-size: 0.85rem;
    line-height: 1.6;
}

.references-list li em {
    font-style: italic;
}

.references-list li a {
    color: var(--color-text);
    word-break: break-all;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.85rem;
}

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

.data-table th {
    background: rgba(190, 52, 85, 0.06);
    font-weight: 600;
}

.data-table tr:hover {
    background: rgba(190, 52, 85, 0.04);
}

.data-table a {
    color: var(--color-text);
}

.table-note {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: -0.5rem;
}

/* FAQ Section */
.faq-item {
    margin-bottom: 0.75rem;
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.faq-item summary {
    padding: 1rem 1.25rem;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: var(--color-text);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--color-text);
    transition: transform 0.2s;
}

.faq-item[open] summary::after {
    content: '−';
}

.faq-item summary:hover {
    background: rgba(190, 52, 85, 0.06);
}

.faq-answer {
    padding: 1.25rem;
    border-top: 1px solid var(--color-border);
    background: rgba(190, 52, 85, 0.03);
}

.faq-answer ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.faq-answer li {
    margin-bottom: 0.75rem;
}

.faq-simulation-stats {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* Dashboard Styles */
#visualization {
    min-height: 500px;
}

.dashboard-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
    max-width: 900px !important;
    margin: 0 auto !important;
}

.dashboard-chart {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--color-border);
    padding: 12px;
    min-height: 200px;
    transition: all 0.2s ease;
}

.dashboard-chart:hover {
    border-color: var(--color-border-strong);
}

.dashboard-chart:hover .expand-hint {
    opacity: 1 !important;
    color: var(--color-text) !important;
}

.dashboard-chart.expanded {
    border-color: var(--color-text);
}

.income-toggle rect {
    transition: fill 0.2s ease;
}

.income-toggle text {
    user-select: none;
}

.dashboard-chart svg {
    width: 100%;
    height: auto;
    display: block;
}

/* Axis styling */
.axis-label {
    font-size: 11px;
    fill: var(--color-text-muted);
}

.x-axis, .y-axis {
    font-size: 10px;
}

.x-axis path, .y-axis-left path, .y-axis-right path,
.x-axis line, .y-axis-left line, .y-axis-right line {
    stroke: var(--color-border);
}

.y-axis-left text { fill: var(--color-viewers); }
.y-axis-right text { fill: var(--color-creators); }
.y-axis-rc text { fill: var(--color-revenue); }

/* Legend */
.legend text {
    fill: var(--color-text);
}

/* Chart Note */
.chart-note {
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin: 1rem 0;
    padding: 0.5rem;
}

/* Concentration Controls */
#concentration-bar-container {
    font-family: var(--font-main);
}

#concentration-controls {
    font-family: var(--font-main);
}

#concentration-controls input {
    font-family: var(--font-main);
    color: var(--color-text);
}

#concentration-controls input:focus {
    outline: none;
    border-color: var(--color-text);
}

.conc-btn {
    font-family: var(--font-main) !important;
    transition: all 0.2s !important;
    border-radius: 0 !important;
}

.conc-btn.active {
    color: white !important;
}

.conc-btn:not(.active):hover {
    opacity: 0.8;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.4rem;
    }

    section {
        padding: 1.5rem 1rem;
    }

    nav ul {
        gap: 1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .controls {
        flex-direction: column;
        gap: 1rem;
    }

    #time-slider {
        width: 100%;
        max-width: none;
    }

    .metrics-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.4rem;
    }

    .metric-card .value {
        font-size: 0.7rem;
    }

    .metric-card .label {
        font-size: 0.5rem;
    }

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

    .param-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .param-row label {
        min-width: auto;
    }

    .param-row input {
        width: 100%;
    }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    .data-table {
        font-size: 0.75rem;
    }

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