/* ================================================================
   DiceDecay — Hypergeometric Damage Engine
   Crimson / blood-red wargaming dark theme
   ================================================================ */

/* -- Design Tokens ------------------------------------------------ */
:root {
    --color-bg: #0a0608;
    --color-surface: #12090d;
    --color-surface-alt: #1a0f14;
    --color-border: rgba(148, 80, 100, 0.1);
    --color-text: #e8d8de;
    --color-text-muted: #6b4a58;
    --color-accent: #e63946;
    --color-accent-glow: rgba(230, 57, 70, 0.12);
    --color-accent-bright: #ff6b6b;
    --color-attacks: #e63946;
    --color-hits: #f4845f;
    --color-wounds: #f7b731;
    --color-damage: #22c55e;
    --color-lost: #3a2a30;
    --color-safe: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.3s ease;
}

/* -- Reset -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    -webkit-font-smoothing: antialiased;
}

/* -- Header ------------------------------------------------------- */
.app-header { text-align: center; margin-bottom: 1.5rem; }
.app-header h1 { font-size: 1.8rem; font-weight: 800; letter-spacing: 0.02em; }
.app-header .accent { color: var(--color-accent); }
.app-header p { font-size: 0.85rem; color: var(--color-text-muted); margin-top: 0.3rem; }

/* -- Ad Placeholders ---------------------------------------------- */
.ad-placeholder {
    display: flex; align-items: center; justify-content: center;
    border: 2px dashed rgba(107, 74, 88, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: var(--color-text-muted); font-size: 0.75rem; font-weight: 600;
    margin: 0 auto; width: 100%;
}
.ad-mobile { height: 50px; max-width: 320px; }
.ad-desktop { display: none; height: 90px; max-width: 728px; }

/* -- Layout ------------------------------------------------------- */
.app-main { width: 100%; max-width: 1200px; display: flex; flex-direction: column; gap: 1rem; }
.dashboard { display: flex; flex-direction: column; gap: 1rem; }

/* -- Sidebar ------------------------------------------------------ */
.sidebar { width: 100%; }

.input-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 0.6rem;
}

.input-panel h2 {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--color-accent);
    margin-bottom: 0.75rem; padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--color-border);
}

.input-group { margin-bottom: 0.65rem; }
.input-group label {
    display: block; font-size: 0.75rem; font-weight: 600;
    color: var(--color-text-muted); margin-bottom: 0.2rem;
}

.input-group select,
.input-group input[type="number"] {
    width: 100%;
    background: var(--color-surface-alt);
    border: 1px solid rgba(148, 80, 100, 0.15);
    color: var(--color-text);
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: inherit;
    transition: border-color var(--transition);
}

.input-group select:focus,
.input-group input[type="number"]:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-glow);
}

/* Info Panel */
.info-panel { border-color: rgba(230, 57, 70, 0.15); }
.info-text {
    font-size: 0.78rem; color: var(--color-text-muted);
    line-height: 1.55;
}

/* -- Metric Strip (Gamble vs Guarantee) --------------------------- */
.metric-strip {
    display: grid; grid-template-columns: 1fr;
    gap: 0.6rem; margin-bottom: 0.75rem;
}

.metric-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.metric-card::before {
    content: '';
    position: absolute; inset: 0;
    opacity: 0.04; pointer-events: none;
}

.gamble-card { border-left: 3px solid var(--color-attacks); }
.gamble-card::before { background: var(--color-attacks); }
.guarantee-card { border-left: 3px solid var(--color-damage); }
.guarantee-card::before { background: var(--color-damage); }
.upside-card { border-left: 3px solid var(--color-wounds); }
.upside-card::before { background: var(--color-wounds); }

.metric-icon { font-size: 1.5rem; display: block; margin-bottom: 0.35rem; }

.metric-label {
    display: block; font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--color-text-muted); margin-bottom: 0.15rem;
}

.metric-value {
    display: block; font-size: 1.8rem; font-weight: 800;
    font-variant-numeric: tabular-nums; color: var(--color-text);
    line-height: 1.2;
}

.gamble-card .metric-value { color: var(--color-accent-bright); }
.guarantee-card .metric-value { color: var(--color-safe); }
.upside-card .metric-value { color: var(--color-wounds); }

.metric-sub {
    display: block; font-size: 0.7rem;
    color: var(--color-text-muted); margin-top: 0.15rem;
}

/* -- Main View ---------------------------------------------------- */
.main-view { width: 100%; }

/* SVG Viewport */
.svg-viewport {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.section-title {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--color-accent);
    margin-bottom: 0.4rem; text-align: center;
}

#waterfallSvg { width: 100%; height: auto; min-height: 260px; }
#distSvg { width: 100%; height: auto; min-height: 180px; }

/* Legend */
.legend {
    display: flex; flex-wrap: wrap; gap: 0.75rem;
    justify-content: center; margin-top: 0.5rem; padding: 0.5rem;
}

.legend-item {
    display: flex; align-items: center; gap: 0.35rem;
    font-size: 0.72rem; color: var(--color-text-muted); font-weight: 500;
}

.legend-swatch { width: 14px; height: 10px; border-radius: 2px; }
.swatch-attacks { background: var(--color-attacks); }
.swatch-hits { background: var(--color-hits); }
.swatch-wounds { background: var(--color-wounds); }
.swatch-damage { background: var(--color-damage); }
.swatch-lost { background: var(--color-lost); border: 1px dashed rgba(255,255,255,0.15); }

/* Tier Table */
.table-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.table-section h3 {
    font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--color-accent);
    margin-bottom: 0.75rem;
}

.tier-table {
    width: 100%; border-collapse: collapse; font-size: 0.82rem;
}

.tier-table th {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.tier-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(148, 80, 100, 0.06);
    color: var(--color-text); font-variant-numeric: tabular-nums;
}

.tier-table tr:nth-child(1) td:first-child { color: var(--color-attacks); font-weight: 700; }
.tier-table tr:nth-child(2) td:first-child { color: var(--color-hits); font-weight: 700; }
.tier-table tr:nth-child(3) td:first-child { color: var(--color-wounds); font-weight: 700; }
.tier-table tr:nth-child(4) td:first-child { color: var(--color-damage); font-weight: 700; }

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.metric-card { animation: fadeInUp 0.5s ease backwards; }
.metric-card:nth-child(2) { animation-delay: 0.1s; }
.metric-card:nth-child(3) { animation-delay: 0.2s; }

/* -- Footer ------------------------------------------------------- */
.app-footer {
    margin-top: 2rem; text-align: center;
    font-size: 0.75rem; color: var(--color-text-muted);
}

/* ================================================================
   RESPONSIVE — Desktop
   ================================================================ */
@media (min-width: 768px) {
    .ad-mobile { display: none; }
    .ad-desktop { display: flex; }

    .dashboard { flex-direction: row; align-items: flex-start; }

    .sidebar { width: 300px; flex-shrink: 0; position: sticky; top: 1rem; }
    .main-view { flex: 1; min-width: 0; }
    .metric-strip { grid-template-columns: repeat(3, 1fr); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb { background: var(--color-surface-alt); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ═══════════════ AFFILIATE & SEO ═══════════════ */
.seo-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 2rem 0;
}
.seo-card h2 {
    color: var(--color-accent);
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}
.seo-card p {
    color: var(--color-text-muted);
    line-height: 1.6;
}
.affiliate-gear a {
    color: var(--color-accent);
    font-weight: 600;
    text-decoration: none;
}
.affiliate-gear a:hover {
    color: var(--color-text);
    text-decoration: underline;
}
