/* GGC Cup — house style of the GGC beamer app (ggc-monorepo: packages/ui/src/base.css + apps/beamer/src/styles.css).
   Two contexts share the same component markup:
   - .stage  the 1920×1080 hall screen (/beamer), scaled by js/ggc.js;
   - .web    the public pages (/ and /teams), responsive. */

/* ── Fonts (Mulish = body/display, Work Sans = UI labels; both OFL, self-hosted) ── */
@font-face { font-family: "Mulish"; font-weight: 300; src: url("../fonts/Mulish-Light.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Mulish"; font-weight: 400; src: url("../fonts/Mulish-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Mulish"; font-weight: 600; src: url("../fonts/Mulish-SemiBold.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Mulish"; font-weight: 700; src: url("../fonts/Mulish-Bold.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Mulish"; font-weight: 800; src: url("../fonts/Mulish-ExtraBold.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Mulish"; font-weight: 900; src: url("../fonts/Mulish-Black.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Work Sans"; font-weight: 500; src: url("../fonts/WorkSans-500.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Work Sans"; font-weight: 600; src: url("../fonts/WorkSans-600.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Work Sans"; font-weight: 700; src: url("../fonts/WorkSans-700.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Work Sans"; font-weight: 800; src: url("../fonts/WorkSans-800.woff2") format("woff2"); font-display: swap; }

/* ── Tokens (delaware dark theme) ── */
:root {
  --dlw-dark-bg: #05080b;
  --dlw-dark-surface: #0c1116;
  --dlw-dark-surface-2: #161e26;
  --dlw-dark-card-1: #19232d;
  --dlw-dark-card-2: #121a22;
  --dlw-dark-line: #25323d;
  --dlw-dark-line-2: #243039;
  --dlw-dot-red: #EF463C;
  --dlw-primary-red: #C42828;
  --ggc-red: var(--dlw-dot-red);
  --ggc-amber: rgba(178,106,0,.92);
  --dlw-font-display: "Mulish", "Avenir Next", system-ui, sans-serif;
  --dlw-font-ui: "Work Sans", "Avenir Next", "Mulish", sans-serif;
  --dlw-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --muted: #9aa3ab;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--dlw-dark-bg); color: #fff; font-family: var(--dlw-font-display); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.ggc-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.ggc-spacer { flex: 1; }

/* Flag (flag-icons 4:3 SVG); grey block for an unknown country. */
.fl { display: inline-block; flex: 0 0 auto; width: var(--fl-w, 30px); height: calc(var(--fl-w, 30px) * .68); border-radius: 3px;
  background: #8a929a center / cover no-repeat; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }

/* Score lines (= @ggc/ui ScoreBreakdown "inline" and "cols"). */
.ggc-sb-line { font-family: var(--dlw-font-ui); color: #fff; white-space: nowrap; }
.ggc-sb-line--vault { font-weight: 700; font-size: var(--ggc-cat3); }
.ggc-sb-line--aa { font-weight: 600; font-size: var(--ggc-cat4); opacity: .9; }
.ggc-sb-line.is-invalid { color: var(--ggc-red); }
.ggc-sb-col { font-weight: 700; font-size: var(--ggc-cat3); text-align: right; color: #fff; }
.lbl { display: none; }

/* Club logo: white rounded frame, otherwise a dark logo disappears on the dark background. */
.team-chip { height: var(--chip-h, 40px); width: auto; max-width: calc(var(--chip-h, 40px) * 2.4); object-fit: contain; background: #fff; border-radius: 6px; padding: 3px; flex: 0 0 auto; align-self: center; }

/* Status badge shown after 30 s without an answer from the backend. */
.stale-badge { position: fixed; top: 16px; right: 16px; z-index: 50; pointer-events: none; display: flex; align-items: center; gap: 10px;
  background: var(--ggc-amber); color: #fff; padding: 10px 18px; border-radius: 999px; font-family: var(--dlw-font-ui); font-size: 16px; font-weight: 700; box-shadow: 0 4px 20px rgba(0,0,0,.35); }
.stale-badge::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #fff; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; padding: 12px 20px; background: var(--ggc-amber); color: #fff; font-family: var(--dlw-font-ui); font-weight: 600; }
#blazor-error-ui .reload { color: #fff; font-weight: 800; margin-left: 8px; }

/* ── Rankings: shared row anatomy ── */
.rk { display: grid; gap: var(--rk-gap); }
.rk-row, .rk-head { display: grid; align-items: center; gap: var(--col-gap); padding: var(--row-pad); }
.rk-row { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); border-radius: var(--row-radius); }
.rk-head { border: 1px solid transparent; padding-top: 0; padding-bottom: 0; margin-bottom: 8px; font-family: var(--dlw-font-ui); font-weight: 700;
  font-size: var(--head-size); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.rk-head .r { text-align: right; }
.rk-head .c { text-align: center; }
.rk-head > :first-child { text-align: center; }
.rk-rank { font-weight: 900; font-size: var(--ggc-cat2); text-align: center; color: #fff; }
.rk-name { font-weight: 700; font-size: var(--ggc-cat2); display: flex; align-items: center; gap: var(--name-gap); color: #fff; min-width: 0; overflow: hidden; }
.rk-name .nm { display: flex; flex-direction: column; min-width: 0; }
.rk-name .nm-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-name .nm-club { font-weight: 600; font-size: var(--ggc-cat4); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-final { font-weight: 900; font-size: var(--ggc-cat2); text-align: right; color: #fff; }
.rk-row.p1 { background: linear-gradient(90deg, rgba(239,70,60,.22), rgba(239,70,60,.04)); border-color: rgba(239,70,60,.5); }
.rk-row.p1 .rk-rank, .rk-row.p1 .rk-final, .rk-row.p1 .aa-total { color: var(--ggc-red); }
.rk-vlt { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rk-bonus { font-weight: 800; font-size: var(--ggc-cat3); text-align: center; color: var(--ggc-red); }
.aa-cell { text-align: right; min-width: 0; }
.aa-cell .ggc-sb-line--aa { white-space: normal; }
.aa-final { font-weight: 800; font-size: var(--ggc-cat3); color: #fff; }
.aa-total { font-weight: 900; font-size: var(--ggc-cat2); text-align: right; color: #fff; }
.aa-row .rk-rank, .aa-row .rk-name { font-size: var(--ggc-cat3); }
.tm-mem { font-weight: 500; font-size: var(--ggc-cat3); color: #fff; opacity: .8; flex: 0 0 auto; }
.tbl-pinned { margin-bottom: var(--rk-gap); }
.tbl-empty { padding: 48px 0; text-align: center; font-weight: 700; font-size: var(--ggc-cat3); color: var(--muted); }

/* ════════════════ HALL SCREEN (.stage) ════════════════ */
.stagewrap { position: fixed; inset: 0; overflow: hidden; background: var(--dlw-dark-bg); }
.stage { width: 1920px; height: 1080px; transform-origin: center center; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(.5);
  background: radial-gradient(1400px 900px at 50% 0%, #18222c 0%, #0a0e13 55%, var(--dlw-dark-bg) 100%); color: #fff; overflow: hidden;
  --ggc-cat1: 104px; --ggc-cat2: 64px; --ggc-cat3: 42px; --ggc-cat4: 28px;
  --rk-gap: 12px; --col-gap: 20px; --row-pad: 16px 28px; --row-radius: 12px; --name-gap: 18px; --head-size: 22px; --fl-w: 44px; --chip-h: 52px; }
.stage .nm-club, .stage .tm-ap, .stage .lbl { display: none; }
.stage .tm-mem { display: inline; }

.stage-head { position: absolute; top: 56px; left: 72px; right: 72px; height: 110px; display: flex; align-items: center; gap: 24px; }
.stage-head .ev { font-family: var(--dlw-font-ui); font-weight: 600; font-size: 36px; letter-spacing: .04em; text-transform: uppercase; max-width: calc(50% - 90px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-head .ap-logo { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: inline-flex; }
.stage-head .ap-logo img { height: 104px; width: auto; }
.stage-head .ap-logo img.ap-logo-ggc { height: 80px; opacity: .9; }
.head-cat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; max-width: calc(50% - 90px); min-width: 0; }
.head-cat .lab { font-family: var(--dlw-font-ui); font-weight: 700; font-size: var(--ggc-cat4); letter-spacing: .1em; text-transform: uppercase; color: var(--ggc-red); }
.head-cat .nm { font-weight: 800; font-size: var(--ggc-cat3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stage .tbl-wrap { position: absolute; left: 72px; right: 72px; top: 196px; bottom: 120px; display: flex; flex-direction: column; }
.stage .tbl-title { flex: 0 0 auto; font-weight: 800; font-size: var(--ggc-cat2); margin: 0 0 18px; }
.stage .tbl-scroll { flex: 1 1 auto; min-height: 0; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 40px, #000 calc(100% - 60px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 40px, #000 calc(100% - 60px), transparent 100%); }
.stage .tbl-scroll > .rk { padding: 20px 0 60px; }

.stage .rk-row, .stage .rk-head { grid-template-columns: 92px 1fr 120px 150px 150px 220px; }
.stage .rk-row--vault { grid-template-columns: 92px 1fr auto 170px 220px; }
.stage .aa-row { grid-template-columns: 74px minmax(240px, 1.7fr) repeat(var(--aa-n, 4), minmax(0, 1fr)) 200px; gap: 16px; }
.stage .aa-cell .ggc-sb-line--aa { font-size: 19px; white-space: nowrap; }
.stage .aa-row .rk-name { gap: 14px; }
.stage .rk-row--team { grid-template-columns: 92px 1fr 240px; }

.stage-foot { position: absolute; left: 72px; right: 72px; bottom: 36px; height: 56px; display: flex; align-items: center; justify-content: space-between; }
.stage-foot .foot-ggc { height: 40px; opacity: .85; }
.stage-foot .foot-dlw { height: 52px; opacity: .85; }
.rot-dots { display: flex; gap: 12px; }
.rot-dots span { width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,.18); transition: background .3s; }
.rot-dots span.on { background: var(--ggc-red); }

.stage-idle { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; text-align: center; }
.stage-idle img { height: 140px; opacity: .9; }
.stage-idle .t { font-weight: 800; font-size: var(--ggc-cat1); max-width: 80%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-idle .s { font-weight: 600; font-size: var(--ggc-cat3); opacity: .7; }
.stagewrap .stale-badge { font-size: 20px; }

/* ════════════════ PUBLIC PAGES (.web) ════════════════ */
.web { min-height: 100vh; display: flex; flex-direction: column; max-width: 1280px; margin: 0 auto; padding: 0 24px 24px;
  background: radial-gradient(1200px 600px at 50% -200px, #18222c 0%, transparent 70%);
  --ggc-cat1: 40px; --ggc-cat2: 22px; --ggc-cat3: 17px; --ggc-cat4: 13px;
  --rk-gap: 8px; --col-gap: 14px; --row-pad: 12px 18px; --row-radius: 10px; --name-gap: 12px; --head-size: 12px; --fl-w: 26px; --chip-h: 30px; }
body:has(.web) { background: var(--dlw-dark-bg); }

.web-head { display: flex; align-items: center; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--dlw-dark-line); }
.web-brand img { height: 44px; display: block; }
.web-ev { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.web-ev-nm { font-family: var(--dlw-font-ui); font-weight: 700; font-size: 20px; letter-spacing: .04em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.web-nav { display: flex; gap: 4px; background: var(--dlw-dark-surface-2); border-radius: 8px; padding: 3px; }
.web-nav a { text-decoration: none; font-family: var(--dlw-font-ui); font-weight: 600; font-size: 14px; color: var(--muted); padding: 8px 14px; border-radius: 6px; white-space: nowrap; }
.web-nav a.on { background: var(--ggc-red); color: #fff; }
.web-nav a:hover:not(.on) { color: #fff; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-family: var(--dlw-font-ui); font-weight: 700; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; background: var(--dlw-dark-surface-2); color: var(--muted); }
.pill--live { background: rgba(239,70,60,.16); color: var(--ggc-red); }
.pill--done { color: #cdd3d8; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ggc-red); animation: ggcPulse 1.4s ease-in-out infinite; }
@keyframes ggcPulse { 50% { opacity: .35; } }

.web-note { margin-top: 18px; padding: 10px 16px; border-radius: 8px; background: var(--dlw-dark-surface); border: 1px solid var(--dlw-dark-line); color: var(--muted); font-weight: 600; font-size: 14px; }
.web-sec { margin-top: 22px; }
.web-h2 { margin: 0 0 10px; font-family: var(--dlw-font-ui); font-weight: 700; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.latest { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.latest-card { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px;
  background: linear-gradient(180deg, var(--dlw-dark-card-1), var(--dlw-dark-card-2)); border: 1px solid var(--dlw-dark-line); border-radius: 12px; }
.latest-card.is-empty { opacity: .55; }
.latest-ap { width: 40px; height: 40px; object-fit: contain; }
.latest-txt { min-width: 0; }
.latest-nm { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; --fl-w: 20px; }
.latest-nm .nm-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.latest-sub { font-size: 12px; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.latest-score { font-weight: 900; font-size: 22px; color: var(--ggc-red); }

.tiles { display: flex; gap: 10px; margin-top: 24px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.tile { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 16px; min-width: 170px; text-align: left; cursor: pointer;
  background: var(--dlw-dark-surface); border: 1px solid var(--dlw-dark-line); border-radius: 12px; transition: border-color .15s, background .15s; }
.tile:hover { border-color: #3a4a57; }
.tile.on { border-color: var(--ggc-red); background: linear-gradient(180deg, rgba(239,70,60,.14), rgba(239,70,60,.03)); }
.tile-nm { font-weight: 800; font-size: 15px; }
.tile-sub { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }

.tabs { display: flex; gap: 2px; margin-top: 16px; background: var(--dlw-dark-surface-2); border-radius: 8px; padding: 3px; overflow-x: auto; width: fit-content; max-width: 100%; }
.tab { display: inline-flex; align-items: center; gap: 8px; background: transparent; border: 0; color: var(--muted); font-family: var(--dlw-font-ui); font-weight: 600; font-size: 14px;
  padding: 8px 14px; border-radius: 6px; cursor: pointer; white-space: nowrap; transition: all .15s; }
.tab img { height: 20px; width: auto; opacity: .8; }
.tab.on { background: var(--ggc-red); color: #fff; }
.tab.on img { opacity: 1; }
.tab:hover:not(.on) { color: #fff; }

.tbl-card { margin-top: 16px; padding: 20px; background: var(--dlw-dark-surface); border: 1px solid var(--dlw-dark-line); border-radius: 14px; }
.web .tbl-title { margin: 0 0 16px; font-weight: 800; font-size: 24px; }
.web .tbl-sub { color: var(--muted); font-weight: 700; }

.web .rk-row, .web .rk-head { grid-template-columns: 52px minmax(0, 1fr) 70px 90px 70px 100px; }
.web .rk-row--vault { grid-template-columns: 52px minmax(0, 1fr) auto 80px 100px; }
.web .aa-row { grid-template-columns: 44px minmax(200px, 1.4fr) repeat(var(--aa-n, 4), minmax(0, 1fr)) 100px; gap: 12px; }
.web .rk-row--team { grid-template-columns: 52px minmax(0, 1fr) repeat(4, 80px) 100px; }
.web .aa-row .rk-rank, .web .aa-row .rk-name { font-size: 17px; }
.web .rk-name .nm-txt { font-size: 17px; }
.web .rk-rank { font-size: 20px; }
.web .rk-final, .web .aa-total { font-size: 20px; }
.web .tm-mem { display: none; }
.web .ggc-sb-line--aa { font-size: 11px; }

.web-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 80px 0; text-align: center; }
.web-empty img { height: 72px; opacity: .9; }
.web-empty .t { font-weight: 800; font-size: 26px; }
.web-empty .s { color: var(--muted); font-weight: 600; }

.web-foot { margin-top: auto; padding-top: 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.web-foot img { display: block; }
.web-foot-gym { height: 36px; }
.web-foot-dlw { height: 34px; max-width: 70%; object-fit: contain; }

/* Tablet: the team per-apparatus columns go. */
@media (max-width: 1000px) {
  .latest { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .web .rk-row--team, .web .rk-head.rk-row--team { grid-template-columns: 52px minmax(0, 1fr) 100px; }
  .web .tm-ap { display: none; }
}

/* Phone: D / E / ND (and the all-around cells) drop under the name, with their labels. */
@media (max-width: 720px) {
  .web { padding: 0 12px 16px; --col-gap: 8px; --row-pad: 10px 12px; --name-gap: 10px; --fl-w: 22px; }
  .web-head { flex-wrap: wrap; gap: 12px; padding: 14px 0; }
  .web-brand img { height: 34px; }
  .web-ev-nm { font-size: 16px; }
  .web-nav { width: 100%; }
  .web-nav a { flex: 1; text-align: center; padding: 8px 6px; }
  .latest { grid-template-columns: minmax(0, 1fr); }
  .tbl-card { padding: 12px; }
  .web .tbl-title { font-size: 19px; }
  .web .rk-head { display: none; }
  .lbl { display: inline; color: var(--muted); font-weight: 600; }

  .web .rk-row { grid-template-columns: 34px repeat(3, minmax(0, 1fr)) 76px; row-gap: 4px; }
  .web .rk-row > .rk-rank { grid-column: 1; grid-row: 1 / 3; }
  .web .rk-row > .rk-name { grid-column: 2 / 5; grid-row: 1; }
  .web .rk-row > .rk-final, .web .rk-row > .aa-total { grid-column: -2; grid-row: 1 / 3; }
  .web .rk-row > .ggc-sb-col { grid-row: 2; font-size: 13px; text-align: left; }

  .web .rk-row--vault { grid-template-columns: 34px minmax(0, 1fr) 76px; }
  .web .rk-row--vault > .rk-name { grid-column: 2; }
  .web .rk-row--vault > .rk-vlt { grid-column: 2; grid-row: 2; }
  .web .rk-row--vault > .rk-bonus { grid-column: 2; grid-row: 3; text-align: left; font-size: 13px; }
  .web .rk-row--vault > .rk-rank, .web .rk-row--vault > .rk-final { grid-row: 1 / 4; }
  .web .ggc-sb-line--vault { font-size: 12px; white-space: normal; }

  .web .aa-row { grid-template-columns: 34px repeat(var(--aa-n, 4), minmax(0, 1fr)) 76px; }
  .web .aa-row > .rk-name { grid-column: 2 / -2; }
  .web .aa-row > .aa-cell { grid-row: 2; text-align: left; }
  .web .aa-final { font-size: 13px; }
  .web .aa-final .lbl { display: block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
  .web .aa-cell .ggc-sb-line--aa { display: none; }

  .web .rk-row--team { grid-template-columns: 34px minmax(0, 1fr) 76px; }
  .web .rk-row--team > .rk-name { grid-column: 2; }
  .web .rk-row--team > .rk-rank, .web .rk-row--team > .rk-final { grid-row: 1; }
  .web .rk-final, .web .aa-total, .web .rk-rank { font-size: 18px; }
}
