/*
 * Shared look of the projector tab (TGG.Client BeamerView) and the public beamer page (TGG.Server
 * PublicBeamer) — the two must stay visually identical.
 *
 * Source of truth: TGG.Shared/Beamer/beamer.css. The build copies it to
 * TGG.Server/wwwroot/beamer.css and TGG.Client/wwwroot/css/beamer.css (see the CopyBeamerCss
 * target in both csproj files) — edit only this file, never the copies.
 */

:root {
    --bm-bg: #f2f3f8;
    --bm-logo-filter: invert(1); /* logo.png is white line-art */
    --bm-bg-panel: #ffffff;
    --bm-bg-panel-sunken: #f3f4f9;
    --bm-bg-chip: #eef0f8;
    --bm-border: #e1e3ee;
    --bm-border-soft: #e8eaf2;
    --bm-border-strong: #d6d9e6;
    --bm-connector: #c7cbdb;
    --bm-gold-strong: #ca8a04;
    --bm-text: #1a1a2e;
    --bm-text-muted: #666a88;
    --bm-text-faint: #8a8dab;
    --bm-text-ghost: #c7c9db;
    --bm-text-dim: #52566f;
    --bm-shadow-card: rgba(30, 32, 60, 0.08);
}

html[data-theme="dark"] {
    --bm-bg: #07070f;
    --bm-logo-filter: none;
    --bm-bg-panel: #0f0f1e;
    --bm-bg-panel-sunken: #111120;
    --bm-bg-chip: #16162a;
    --bm-border: #252545;
    --bm-border-soft: #1e1e35;
    --bm-border-strong: #282845;
    --bm-connector: #2c2c52;
    --bm-gold-strong: #92710a;
    --bm-text: #eeeeff;
    --bm-text-muted: #8888aa;
    --bm-text-faint: #55557a;
    --bm-text-ghost: #383855;
    --bm-text-dim: #aaaacc;
    --bm-shadow-card: transparent;
}

/* The public page follows the OS theme until a theme was picked explicitly (no data-theme on <html>). */
@media (prefers-color-scheme: dark) {
    html:not([data-theme]) .bm-root--os {
        --bm-bg: #07070f;
        --bm-logo-filter: none;
        --bm-bg-panel: #0f0f1e;
        --bm-bg-panel-sunken: #111120;
        --bm-bg-chip: #16162a;
        --bm-border: #252545;
        --bm-border-soft: #1e1e35;
        --bm-border-strong: #282845;
        --bm-connector: #2c2c52;
        --bm-gold-strong: #92710a;
        --bm-text: #eeeeff;
        --bm-text-muted: #8888aa;
        --bm-text-faint: #55557a;
        --bm-text-ghost: #383855;
        --bm-text-dim: #aaaacc;
        --bm-shadow-card: transparent;
    }
}

/* ── Full-screen dark overlay (covers the normal app shell) ───────────── */
.bm-root {
    position: fixed;
    inset: 0;
    background: var(--bm-bg);
    color: var(--bm-text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 9999;
}


/* ── Header ──────────────────────────────────────────────────────────── */
.bm-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .75rem 2.5rem;
    background: var(--bm-bg-panel);
    border-bottom: 1px solid var(--bm-border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.bm-header__name  {
    font-size: clamp(1rem, 2vw, 1.6rem);
    font-weight: 800;
    color: #6366f1;
    letter-spacing: .03em;
}

.bm-header__round {
    font-size: clamp(.85rem, 1.5vw, 1.2rem);
    font-weight: 700;
    color: var(--bm-text-muted);
    background: var(--bm-bg-chip);
    border: 1px solid var(--bm-border);
    padding: .3rem .9rem;
    border-radius: 999px;
}

.bm-header__count {
    font-size: clamp(.75rem, 1.2vw, 1rem);
    color: var(--bm-text-muted);
    margin-left: auto;
}

/* ── Timer section ───────────────────────────────────────────────────── */
.bm-timer-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    padding: 1.5rem 2rem 1.25rem;
    background: var(--bm-bg-panel);
    border-bottom: 2px solid var(--bm-border);
    flex-shrink: 0;
}

.bm-timer {
    font-size: 10vw;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    letter-spacing: .06em;
    line-height: 1;
    color: var(--bm-text);
    transition: color .4s;
    user-select: none;
}

.bm-timer--warning { color: #f59e0b; }
.bm-timer--danger  { color: #ef4444; animation: bm-pulse 1s ease-in-out infinite; }

@keyframes bm-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .65; }
}

/* ── Pairings scroll area ─────────────────────────────────────────────── */
.bm-pairings {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem 2.5rem;
}

.bm-status {
    text-align: center;
    color: var(--bm-text-muted);
    font-size: clamp(1rem, 2vw, 1.4rem);
    margin-top: 4rem;
    line-height: 1.7;
}

.bm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(280px, 30vw, 420px), 1fr));
    gap: 1rem;
}

/* ── Match card ──────────────────────────────────────────────────────── */
.bm-card {
    background: var(--bm-bg-panel);
    border: 2px solid var(--bm-border);
    border-radius: 14px;
    padding: 1.25rem 1.5rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: .85rem;
    box-shadow: 0 2px 10px var(--bm-shadow-card);
    transition: border-color .2s, box-shadow .2s;
}

.bm-card:hover      { border-color: #6366f1; box-shadow: 0 0 24px rgba(99,102,241,.25); }
.bm-card--bye       { border-color: #a855f7; }
.bm-card--bye:hover { box-shadow: 0 0 24px rgba(168,85,247,.2); }
.bm-card--done      { border-color: #22c55e; }
.bm-card--done:hover { box-shadow: 0 0 24px rgba(34,197,94,.2); }
.bm-card--result    { border-color: #f59e0b; }
.bm-card--result:hover { box-shadow: 0 0 24px rgba(245,158,11,.2); }

.bm-card__header { display: flex; align-items: baseline; gap: .6rem; }

.bm-card__table {
    font-size: clamp(1.8rem, 3.5vw, 4rem);
    font-weight: 900;
    color: #6366f1;
    line-height: 1;
}

.bm-card--bye .bm-card__table { color: #a855f7; }

.bm-card__type {
    font-size: clamp(.6rem, .9vw, .85rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--bm-text-muted);
}

.bm-card__players { display: flex; flex-direction: column; gap: .5rem; }
.bm-card__player  { display: flex; align-items: baseline; gap: .55rem; }
.bm-card__player--winner .bm-card__pname { color: #22c55e; }

.bm-card__pname {
    font-size: clamp(1.3rem, 2.6vw, 2.8rem);
    font-weight: 700;
    color: var(--bm-text);
    line-height: 1.1;
}

.bm-card__bye-label {
    font-size: clamp(1rem, 1.8vw, 1.8rem);
    font-weight: 700;
    color: #a855f7;
    font-style: italic;
}

.bm-card__vs {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: clamp(.65rem, 1vw, 1rem);
    font-weight: 800;
    color: var(--bm-text-muted);
    letter-spacing: .12em;
}

.bm-card__vs::before,
.bm-card__vs::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--bm-border);
}

.bm-card__vs-score {
    font-size: clamp(1.4rem, 2.8vw, 2.8rem);
    font-weight: 900;
    letter-spacing: .06em;
    font-variant-numeric: tabular-nums;
}
.bm-card__vs-score--done    { color: #22c55e; }
.bm-card__vs-score--pending { color: #f59e0b; }

/* ── Roster (pre-round player list) ──────────────────────────────────── */
.bm-roster-title {
    text-align: center;
    font-size: clamp(.85rem, 1.4vw, 1.2rem);
    font-weight: 700;
    color: var(--bm-text-muted);
    margin-bottom: 1.25rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.bm-roster {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(200px, 22vw, 340px), 1fr));
    gap: .75rem;
}

.bm-roster-card {
    background: var(--bm-bg-panel);
    border: 2px solid var(--bm-border);
    border-radius: 12px;
    padding: .85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .9rem;
    box-shadow: 0 1px 6px var(--bm-shadow-card);
    transition: border-color .2s;
}

.bm-roster-card:hover { border-color: #6366f1; }

.bm-roster-card__num {
    font-size: clamp(1rem, 1.8vw, 1.8rem);
    font-weight: 900;
    color: #6366f1;
    min-width: 2rem;
    text-align: right;
    line-height: 1;
    flex-shrink: 0;
}

.bm-roster-card__name {
    font-size: clamp(1.2rem, 2.2vw, 2.2rem);
    font-weight: 700;
    color: var(--bm-text);
    line-height: 1.2;
}

/* ── Between-rounds idle screen ─────────────────────────────────────── */
.bm-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 5rem 2rem;
    text-align: center;
}

.bm-idle__icon {
    font-size: clamp(4rem, 10vw, 9rem);
    animation: bm-idle-pulse 2s ease-in-out infinite;
}

.bm-idle__title {
    font-size: clamp(2rem, 5vw, 5rem);
    font-weight: 900;
    color: #6366f1;
    letter-spacing: .03em;
}

.bm-idle__subtitle {
    font-size: clamp(1.1rem, 2.2vw, 2rem);
    color: var(--bm-text-muted);
    font-weight: 500;
}

/* ── Next-round countdown on beamer idle screen ──────────────────── */
.bm-nextround-countdown {
    font-size: clamp(4rem, 14vw, 13rem);
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    letter-spacing: .06em;
    line-height: 1;
    color: #6366f1;
    transition: color .4s;
    user-select: none;
}

.bm-nextround-countdown--warning { color: #f59e0b; }
.bm-nextround-countdown--danger  { color: #ef4444; animation: bm-pulse 1s ease-in-out infinite; }

@keyframes bm-idle-pulse {
    0%, 100% { opacity: 1;  transform: scale(1); }
    50%       { opacity: .6; transform: scale(.92); }
}

/* ── Scrollbar ───────────────────────────────────────────────────────── */
.bm-root::-webkit-scrollbar,
.bm-pairings::-webkit-scrollbar       { width: 6px; }
.bm-root::-webkit-scrollbar-track,
.bm-pairings::-webkit-scrollbar-track { background: var(--bm-bg); }
.bm-root::-webkit-scrollbar-thumb,
.bm-pairings::-webkit-scrollbar-thumb { background: var(--bm-border); border-radius: 3px; }

/* ══════════════════════════════════════════════════════════════════════
   BRACKET VIEW  (Elite / Top-cut phase)
   ══════════════════════════════════════════════════════════════════════ */

/* ── Header extras for bracket ───────────────────────────────────────── */
.bm-header__label {
    font-size: clamp(.8rem, 1.4vw, 1.1rem);
    font-weight: 700;
    color: var(--bm-text-muted);
    background: var(--bm-bg-chip);
    border: 1px solid var(--bm-border);
    padding: .3rem .9rem;
    border-radius: 999px;
}

.bm-header__champion {
    margin-left: auto;
    font-size: clamp(.9rem, 1.7vw, 1.4rem);
    font-weight: 800;
    color: #fbbf24;
    background: rgba(251,191,36,.08);
    border: 1px solid rgba(251,191,36,.25);
    padding: .3rem 1rem;
    border-radius: 999px;
    animation: champion-glow 2.5s ease-in-out infinite;
}

@keyframes champion-glow {
    0%, 100% { box-shadow: 0 0 0   rgba(251,191,36,0); }
    50%       { box-shadow: 0 0 20px rgba(251,191,36,.3); }
}

/* ── Bracket viewport ────────────────────────────────────────────────── */
.bm-bracket {
    flex: 1;
    display: flex;
    align-items: stretch;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1.25rem 2rem 1.5rem;
    min-height: 0;
    gap: 0;
}

/* ── Round column ────────────────────────────────────────────────────── */
.bm-round-col {
    display: flex;
    flex-direction: column;
    min-width: 260px;
    max-width: 380px;
    flex: 1;
}

.bm-round-col--final {
    min-width: 290px;
    max-width: 430px;
}

.bm-round-hdr {
    height: 2.5rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(.85rem, 1.3vw, 1.2rem);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: #6366f1;
    margin-bottom: .25rem;
}

.bm-slots {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.bm-slot {
    display: flex;
    align-items: center;
    padding: .3rem .5rem;
    min-height: 0;
}

/* ── Bracket match card (scoped to bracket context) ──────────────────── */
.bm-slot .bm-card {
    width: 100%;
    background: var(--bm-bg-panel-sunken);
    border: 2px solid var(--bm-border-soft);
    border-radius: 11px;
    padding: .95rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.bm-slot .bm-card--pending { border-color: var(--bm-border-soft); }
.bm-slot .bm-card--done    { border-color: var(--bm-border-strong); }

.bm-slot .bm-card--final {
    border-color: var(--bm-gold-strong);
    box-shadow: 0 0 28px rgba(251,191,36,.18), inset 0 0 20px rgba(251,191,36,.04);
}

/* ── Player row ──────────────────────────────────────────────────────── */
.bm-player {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .3rem .4rem;
    border-radius: 6px;
    transition: background .15s;
}

.bm-player--winner { background: rgba(34,197,94,.14); }
.bm-player--loser  { opacity: .38; }

.bm-trophy {
    font-size: clamp(.85rem, 1.2vw, 1.4rem);
    flex-shrink: 0;
}

.bm-seed {
    font-size: clamp(.7rem, 1vw, 1.05rem);
    font-weight: 700;
    color: var(--bm-text-faint);
    background: var(--bm-bg-chip);
    border: 1px solid var(--bm-border);
    border-radius: 4px;
    padding: .05rem .3rem;
    flex-shrink: 0;
    letter-spacing: .02em;
}

.bm-pname {
    font-size: clamp(1.1rem, 1.9vw, 1.85rem);
    font-weight: 700;
    color: var(--bm-text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bm-pname--tbd {
    color: var(--bm-text-ghost);
    font-style: italic;
    font-weight: 400;
}

.bm-score {
    font-size: clamp(.95rem, 1.5vw, 1.5rem);
    font-weight: 900;
    color: var(--bm-text-muted);
    flex-shrink: 0;
    min-width: 1.6rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.bm-score--win { color: #22c55e; }

.bm-sep {
    height: 1px;
    background: var(--bm-border-soft);
    margin: .05rem .1rem;
}

/* ── Connector column ────────────────────────────────────────────────── */
.bm-conn-col {
    width: 2.25rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding-top: 2.75rem;
}

.bm-ci {
    position: relative;
    min-height: 0;
}

.bm-ci::before {
    content: '';
    position: absolute;
    top: 25%;
    left: 0;
    right: 0;
    height: 25%;
    border-top:   2px solid var(--bm-connector);
    border-right: 2px solid var(--bm-connector);
}

.bm-ci::after {
    content: '';
    position: absolute;
    bottom: 25%;
    left: 0;
    right: 0;
    height: 25%;
    border-bottom: 2px solid var(--bm-connector);
    border-right:  2px solid var(--bm-connector);
}

/* ── Bracket scrollbar ───────────────────────────────────────────────── */
.bm-bracket::-webkit-scrollbar             { height: 5px; }
.bm-bracket::-webkit-scrollbar-track       { background: var(--bm-bg); }
.bm-bracket::-webkit-scrollbar-thumb       { background: var(--bm-border); border-radius: 3px; }
.bm-bracket::-webkit-scrollbar-thumb:hover { background: #6366f1; }

/* ══════════════════════════════════════════════════════════════════════
   STANDINGS VIEW  (pre-top-cut or TNM final)
   ══════════════════════════════════════════════════════════════════════ */

.bm-standings {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 4vw 3rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.bm-st-table {
    width: 100%;
    max-width: 900px;
    border-collapse: collapse;
}

.bm-st-th {
    padding: .6rem 1rem;
    font-size: clamp(.65rem, 1vw, .9rem);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #6366f1;
    border-bottom: 2px solid var(--bm-border);
    text-align: left;
}

.bm-st-th--rank { width: 4rem; text-align: center; }
.bm-st-th--num  { width: 8rem; text-align: right; }

.bm-st-tr {
    border-bottom: 1px solid var(--bm-border-soft);
    transition: background .15s;
}

.bm-st-tr:hover { background: rgba(99,102,241,.06); }

.bm-st-tr--cut {
    background: rgba(99,102,241,.08);
}

.bm-st-tr--bubble {
    opacity: .72;
}

/* TNM winner row — gold glow */
.bm-st-tr--winner {
    background: rgba(251,191,36,.1);
    animation: bm-winner-glow 2.5s ease-in-out infinite;
}

@keyframes bm-winner-glow {
    0%, 100% { box-shadow: none; }
    50%       { box-shadow: inset 0 0 30px rgba(251,191,36,.15); }
}

/* Standings reveal: places not revealed yet, and the entrance of a newly revealed one */
.bm-st-tr--hidden .bm-st-td { color: var(--bm-text-dim); opacity: .35; }
.bm-st-tr--hidden .bm-st-td--name { letter-spacing: .3em; }

.bm-st-tr--revealed { animation: bm-reveal .7s ease-out backwards; }
.bm-st-tr--revealed.bm-st-tr--winner {
    animation: bm-reveal .7s ease-out backwards, bm-winner-glow 2.5s ease-in-out .7s infinite;
}

@keyframes bm-reveal {
    0%   { opacity: 0; transform: translateX(-2rem); background: rgba(99,102,241,.35); }
    60%  { opacity: 1; transform: none; }
    100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .bm-st-tr--revealed, .bm-st-tr--revealed.bm-st-tr--winner { animation: none; }
}

.bm-st-td {
    padding: .75rem 1rem;
    font-size: clamp(1rem, 2.2vw, 2rem);
    font-weight: 700;
    color: var(--bm-text);
    vertical-align: middle;
}

.bm-st-td--rank {
    text-align: center;
    font-size: clamp(1rem, 2vw, 1.8rem);
    color: #6366f1;
    font-weight: 900;
    width: 4rem;
}

.bm-st-tr--winner .bm-st-td--rank { color: #fbbf24; font-size: clamp(1.2rem, 2.4vw, 2.2rem); }
.bm-st-tr--winner .bm-st-td--name { color: #fbbf24; }

.bm-st-td--name {
    font-size: clamp(1.1rem, 2.4vw, 2.2rem);
}

.bm-st-td--num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--bm-text-dim);
    font-size: clamp(.9rem, 1.8vw, 1.6rem);
}

/* Cut line separator row */
.bm-st-cutrow td {
    padding: .3rem 1rem;
    text-align: center;
}

.bm-st-cutlabel {
    display: inline-block;
    font-size: clamp(.55rem, .9vw, .85rem);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: #ef4444;
    border-top: 2px dashed #ef4444;
    padding: .25rem 2rem 0;
}

/* Logo + title, same pairing as the public beamer header */
.bm-header__brand {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.bm-header__logo {
    width: clamp(1.8rem, 3vw, 2.6rem);
    height: clamp(1.8rem, 3vw, 2.6rem);
    flex: 0 0 auto;
    filter: var(--bm-logo-filter);
}

/* ── Phones (the public page is opened on them) ──────────────────────── */
@media (max-width: 640px) {
    .bm-header { padding: .6rem 1rem; gap: .6rem; }
    .bm-pairings { padding: 1rem 1rem 2rem; }
    .bm-grid { grid-template-columns: 1fr; }
}

.bm-footer {
    text-align: center;
    padding: 1rem;
    font-size: .8rem;
    color: var(--bm-text-faint);
    font-variant-numeric: tabular-nums;
}
