/* Home dashboard — components layered on top of design-system.css.
 * Reuses ww-* primitives (ww-card, ww-podium-1/2/3, ww-tag-win/loss/tie,
 * ww-live-dot, ww-btn, ww-meta, ww-h1/h2/h3, ww-accent-line) wherever they
 * already match. Net-new components use a home- prefix so nothing here can
 * collide with design-system.css's own class names.
 *
 * Wordle score-bucket colors are page-specific (ported from the Visualizer's
 * /wordle infographic) and live here, not in design-system.css.
 */

.hidden { display: none !important; }

:root {
    --score-1: #2e7d46;
    --score-2: #6aaa64;
    --score-3: #c9b458;
    --score-4: #e8a33d;
    --score-5: #e2703a;
    --score-6: #c0392b;
}

/* ============================================================
   Latest-battle hero
   ============================================================ */

.home-latest-hero {
    background: var(--bg-800);
    border: 1px solid var(--border-default);
    border-bottom: 1px solid var(--border-subtle);
    border-radius: 0;
    padding: clamp(28px, 5vw, 56px) clamp(16px, 4vw, 40px);
    position: relative;
    overflow: hidden;
}

.home-latest-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(110% 80% at 20% 0%, rgba(59, 130, 246, 0.14), transparent 62%),
        radial-gradient(90% 70% at 95% 10%, rgba(20, 184, 166, 0.09), transparent 58%);
    pointer-events: none;
}

.home-latest-hero-inner {
    max-width: 1160px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: clamp(24px, 4vw, 48px);
    align-items: center;
    position: relative;
}

.home-latest-hero-inner > * {
    flex: 1 1 320px;
    min-width: 0;
}

.home-latest-hero-title {
    margin: 14px 0 12px;
    font-size: clamp(32px, 5.5vw, 54px);
    line-height: 1.04;
    letter-spacing: -0.02em;
    font-weight: 700;
    color: var(--text-strong);
    text-wrap: pretty;
}

.home-latest-hero-desc {
    margin: 0 0 22px;
    font-size: clamp(15px, 1.6vw, 17px);
    line-height: 1.55;
    color: var(--text-default);
    max-width: 46ch;
    text-wrap: pretty;
}

.home-latest-hero-desc strong { color: var(--text-strong); font-weight: 600; }

.home-latest-hero-winner-line {
    display: inline-block;
    margin-top: 8px;
}

.home-latest-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.home-hero-podium-blurb { margin: 0 0 22px; }
.home-hero-podium-blurb p { margin: 0 0 10px; }
.home-hero-podium-blurb .home-podium-list { margin-top: 0; }

.home-podium-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-default);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-podium-name:hover { color: var(--accent-teal); }

.home-podium-points {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-default);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.home-podium-row.ww-podium-1 .home-podium-name,
.home-podium-row.ww-podium-2 .home-podium-name,
.home-podium-row.ww-podium-3 .home-podium-name,
.home-podium-row.ww-podium-1 .home-podium-points,
.home-podium-row.ww-podium-2 .home-podium-points,
.home-podium-row.ww-podium-3 .home-podium-points { color: var(--text-strong); }

.home-tiles { display: flex; gap: clamp(5px, 1.2vw, 9px); perspective: 800px; }

.home-tile {
    flex: 1;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: var(--score-2);
    color: #0b0b0b;
    font-size: clamp(24px, 4.5vw, 38px);
    font-weight: 700;
    text-transform: uppercase;
    animation: homeFlip 380ms ease-out both;
}

.home-hero-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    margin-top: 22px;
    background: var(--border-default);
    border-radius: 10px;
    overflow: hidden;
}

.home-stat-cell { background: var(--bg-800); padding: 14px 12px; }

.home-stat-value {
    font-family: var(--font-mono);
    font-size: clamp(20px, 2.6vw, 26px);
    font-weight: 700;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
}

.home-stat-win { color: var(--color-win); }
.home-stat-loss { color: var(--color-loss); }
.home-stat-blue { color: var(--accent-blue); }
.home-stat-teal { color: var(--accent-teal); }
.home-stat-gold { color: var(--medal-gold); }

.home-stat-label {
    margin-top: 4px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.home-hero-dist { margin-top: 20px; }

/* ============================================================
   Stacked score-distribution bars (hero + big board + community)
   ============================================================ */

.home-stack {
    display: flex;
    height: 16px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
    transform-origin: left center;
    animation: homeGrow 900ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.home-stack-tall { height: 34px; border-radius: 6px; }
.home-stack-seg { min-width: 0; }
.home-stack-seg-empty { background: var(--bg-700); flex: 1; }

.home-stack-axis {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.home-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; }

.home-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-default);
}

.home-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }

/* ============================================================
   Stat grid (Big Board / community stat cards)
   ============================================================ */

.home-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.home-stat-card {
    background: var(--bg-800);
    border: 1px solid var(--border-default);
    border-radius: 14px;
    padding: 18px;
    animation: homeRise 400ms ease-out both;
}

/* ============================================================
   Dashboard row: Daily Tournament + analytics column
   ============================================================ */

.home-dashboard-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.home-daily-tournament {
    flex: 1 1 340px;
    display: flex;
    flex-direction: column;
}

.home-daily-tournament .ww-card { display: flex; flex-direction: column; height: 100%; }

.home-lb-list {
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
    gap: 2px;
}

.home-lb-row {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 6px;
}

.home-lb-rank {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-soft);
    align-self: center;
}

.home-lb-row.ww-podium-1 .home-lb-rank { color: var(--medal-gold); }
.home-lb-row.ww-podium-2 .home-lb-rank { color: var(--medal-silver); }
.home-lb-row.ww-podium-3 .home-lb-rank { color: var(--medal-bronze); }

.home-lb-main {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.home-lb-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-strong);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-lb-name:hover { color: var(--accent-teal); }

.home-lb-points {
    font-weight: 700;
    font-size: 1.0625rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-strong);
    flex: none;
}

.home-lb-matchup {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    min-width: 0;
}

.home-lb-chip {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    flex: none;
}

.home-lb-vs {
    font-size: 0.5625rem;
    text-transform: uppercase;
    color: var(--text-muted);
    flex: none;
}

.home-lb-opponent {
    font-size: 0.75rem;
    color: var(--text-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   Difficulty-over-time line chart
   ============================================================ */

.home-chart-wrap { display: flex; gap: 10px; }

.home-chart-yaxis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: clamp(150px, 22vw, 200px);
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.home-chart-svg { flex: 1 1 0; min-width: 0; }
.home-chart-svg svg {
    width: 100%;
    min-width: 0;
    height: clamp(150px, 22vw, 200px);
    display: block;
    overflow: visible;
}

.home-chart-line { animation: homeTrace 2600ms ease-out 300ms both; }
.home-chart-marker { animation: homeFade 400ms ease-out 2400ms both; }

.home-chart-xaxis {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding-left: 34px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.home-chart-notes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
}

.home-chart-note { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-default); }
.home-chart-note strong { color: var(--text-strong); font-weight: 600; text-transform: capitalize; }
.home-dot { width: 8px; height: 8px; border-radius: 999px; flex: none; }

/* ============================================================
   Letter heat map (keyboard)
   ============================================================ */

.home-keyboard { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.home-keyboard-row { display: flex; gap: 4px; justify-content: center; }

.home-key {
    width: clamp(24px, 6.5vw, 40px);
    height: clamp(24px, 6.5vw, 40px);
    min-width: 0;
    display: grid;
    place-items: center;
    border-radius: 6px;
    font-size: clamp(11px, 2.6vw, 16px);
    font-weight: 600;
    color: #fff;
    animation: homeFlip 300ms ease-out both;
}

.home-key-thin { opacity: 0.45; }

.home-scale { display: flex; align-items: center; gap: 10px; margin-top: 12px; justify-content: center; }
.home-scale-ramp {
    width: clamp(90px, 30vw, 160px);
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, hsl(130, 55%, 38%), hsl(65, 55%, 38%), hsl(0, 55%, 38%));
}

/* ============================================================
   Hardest / easiest podiums
   ============================================================ */

.home-podium-two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.home-podium-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.home-podium-row {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    border-left: 3px solid transparent;
    animation: homeRise 350ms ease-out both;
}

.home-podium-rank { font-family: var(--font-mono); font-size: 11px; color: var(--text-soft); }

.home-podium-word {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-default);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.home-podium-num {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-soft);
}

.home-podium-score {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-default);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.home-podium-row.ww-podium-1 .home-podium-word,
.home-podium-row.ww-podium-2 .home-podium-word,
.home-podium-row.ww-podium-3 .home-podium-word,
.home-podium-row.ww-podium-1 .home-podium-score,
.home-podium-row.ww-podium-2 .home-podium-score,
.home-podium-row.ww-podium-3 .home-podium-score { color: var(--text-strong); }

/* ============================================================
   Current streaks histogram
   ============================================================ */

.home-histogram { display: flex; align-items: flex-end; gap: 2px; height: clamp(120px, 16vw, 170px); }
.home-histogram-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }

.home-histogram-bar {
    border-radius: 3px 3px 0 0;
    background: var(--accent-blue);
    transform-origin: bottom center;
    animation: homeGrowY 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.home-histogram-bar-gold { background: var(--medal-gold); }

/* ============================================================
   Raw board — disclosure + sortable/filterable table
   ============================================================ */

.home-disclosure {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    background: var(--bg-800);
    color: var(--text-strong);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 200ms ease, border-color 200ms ease;
}

.home-disclosure:hover { background: var(--bg-700); border-color: var(--border-strong); }

.home-table-panel { padding: 0; overflow: hidden; }

.home-table-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-default);
}

.home-table-controls input {
    flex: 1;
    min-width: 180px;
    padding: 9px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-default);
    background: var(--bg-900);
    color: var(--text-strong);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

.home-table-controls input:focus { border-color: var(--accent-blue); }

.home-table-header,
.home-table-row {
    display: grid;
    grid-template-columns: 62px minmax(72px, 1fr) 2fr 62px 70px;
    gap: 10px;
    align-items: center;
}

.home-table-header { padding: 10px 16px; border-bottom: 1px solid var(--border-default); background: var(--bg-900); }

.home-th {
    text-align: left;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.home-th:hover { color: var(--text-strong); }
.home-th-right { text-align: right; }
.home-th-static { cursor: default; }
.home-th-active { color: var(--text-strong); }

.home-table-body { max-height: 560px; overflow-y: auto; }

.home-table-row { padding: 9px 16px; border-bottom: 1px solid var(--border-subtle); transition: background 120ms ease; }
.home-table-row:hover { background: var(--bg-700); }

.home-row-num { font-family: var(--font-mono); font-size: 12px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.home-row-word { font-size: 14px; font-weight: 600; color: var(--text-strong); text-transform: uppercase; letter-spacing: 0.06em; }
.home-row-bar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; background: var(--bg-700); }
.home-row-avg { text-align: right; font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.home-row-players { text-align: right; font-family: var(--font-mono); font-size: 12px; color: var(--text-soft); font-variant-numeric: tabular-nums; }

/* ============================================================
   Section-local layout helpers
   ============================================================ */

.home-card-head {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 14px;
}

.home-two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; }
.home-preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-4); }

@media (max-width: 900px) {
    .home-daily-tournament { order: -1; }
}

/* ============================================================
   Motion
   ============================================================ */

[data-reveal] * { animation-play-state: paused; }

@keyframes homeFlip {
    0% { transform: rotateX(-92deg); opacity: 0; }
    60% { opacity: 1; }
    100% { transform: rotateX(0deg); opacity: 1; }
}
@keyframes homeGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes homeGrowY { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes homeRise { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes homeTrace { from { stroke-dashoffset: 8000; } to { stroke-dashoffset: 0; } }
@keyframes homeFade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .home-latest-hero *,
    .home-dashboard-row *,
    .home-stat-grid *,
    #ww-community-section * {
        animation: none !important;
    }
}
