/* Swiss Bracket Future — public bracket page
   Every size is in dp (Figma pixels). --u is the length of one dp on screen:
   page scale (viewport height / 1753) × the frame's own hover scale.
   Frames re-lay out at their real size instead of being bitmap-scaled, so text and logos stay crisp. */
:root {
  /* Josefin Sans weights (variable font: any value from 100 to 700) */
  --w-score-title: 600;     /* "0:0" / "3:0" titles */
  --w-frame-label: 350;     /* ADVANCED … / ELIMINATED */
  --w-round-stage: 100;     /* ROUND n and STAGE n */
  --win: #01dff9;
  --lose: #ff7466;
  --glass-tint: rgba(184, 255, 197, 0.05);
  --muted: rgba(255, 255, 255, 0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: #fff; overflow: hidden; }
/* Stop mobile browsers from enlarging "small" text (Chrome's font boosting), which pulled text off the glass */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: 'Jost', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { -webkit-user-drag: none; user-select: none; }

/* Same box as #scroller (inset: 0 = the layout viewport). 100vw/100vh would include the hidden URL bar on phones. */
#glass { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; display: block; }

/* The page scrolls inside this box so mobile browsers never zoom the layout out */
#scroller {
  position: fixed; inset: 0; overflow-x: auto; overflow-y: hidden; z-index: 1;
  overscroll-behavior: none; -webkit-overflow-scrolling: touch;
}
#page { position: relative; --u: calc(var(--dp, 1) * 1px); }


/* Dimming: 20% black multiplied over everything except the active frame and highlighted matches.
   The WebGL layer dims the background/glass; these filters dim the DOM content to match. */
#page { --dimb: 1; }
.header, .frame:not(.front) .info, .frame:not(.front) .matchup, .frame:not(.front) .slot, .frame:not(.front) > .ghost {
  filter: brightness(var(--dimb));
}
.frame .hl { filter: brightness(var(--hl, 1.15)); }

/* ---------- Header ---------- */
.header { position: absolute; z-index: 2; pointer-events: none; padding-top: calc(12 * var(--u)); }
.header .l1, .header .l2 { font-family: 'Familjen Grotesk', sans-serif; font-weight: 500; white-space: nowrap; margin: 0; }
.header .l1, .header .l2 { color: #f4ff3a; }               /* fallback; WebGL draws the vivid-light version */
.gl-title .header .l1, .gl-title .header .l2 { color: transparent; }
.header .l1 { font-size: calc(78 * var(--u)); line-height: 0.971; }
.header .l2 { font-size: calc(112 * var(--u)); line-height: 0.7769; }
.header .stage {
  position: absolute; top: calc(204 * var(--u)); left: 0; margin: 0; white-space: nowrap;
  font-family: 'Josefin Sans', sans-serif; font-weight: var(--w-round-stage);
  font-size: calc(75 * var(--u)); line-height: 0.971;
}
.header .stage-text { opacity: 0.6; }
/* Stage change: "STAGE N" slides inside this window; its sides fade out over --fw dp (and blur, with WebGL glass) */
.header .stage-window {
  position: absolute; left: calc(var(--fw) * -1 * var(--u)); top: calc(var(--fw) * -1 * var(--u));
  height: calc(100% + var(--fw) * 2 * var(--u)); overflow: hidden; opacity: 0.6; pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 calc(var(--fw) * var(--u)), #000 calc(100% - var(--fw) * var(--u)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 calc(var(--fw) * var(--u)), #000 calc(100% - var(--fw) * var(--u)), transparent 100%);
}
.header .stage-window[hidden] { display: none; }
.stage-window .st-lane { position: absolute; inset: 0; }
.stage-window .st { position: absolute; left: calc(var(--fw) * var(--u)); top: calc(var(--fw) * var(--u)); white-space: nowrap; will-change: transform; }
/* Stage navigation (Figma "Next Stage button"): 68×70dp, 6dp from the title */
.stage-nav {
  position: absolute; top: calc(7 * var(--u)); width: calc(68 * var(--u)); height: calc(70 * var(--u));
  pointer-events: auto; color: #fff; opacity: var(--nav-rest, .33); text-decoration: none;
  transition: opacity var(--nav-ease, 500ms ease);
}
.stage-nav[hidden] { display: none; }
.stage-nav.next { left: calc(100% + 6 * var(--u)); }
.stage-nav.prev { right: calc(100% + 6 * var(--u)); transform: scaleX(-1); }
.stage-nav svg { position: absolute; left: 0; top: calc(9 * var(--u)); width: 100%; height: calc(40 * var(--u)); overflow: visible; mix-blend-mode: plus-lighter; }
.stage-nav path { fill: none; stroke: currentColor; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.stage-nav-label {
  position: absolute; left: calc(4 * var(--u)); top: calc(47 * var(--u)); white-space: nowrap;
  font-family: 'Red Hat Display', sans-serif; font-weight: 400; font-size: calc(12 * var(--u)); line-height: normal;
  opacity: 0; transform: translateY(calc(var(--nav-drop, 8) * -1 * var(--u)));
  transition: opacity var(--nav-ease, 500ms ease), transform var(--nav-ease, 500ms ease);
}
.stage-nav:hover, .stage-nav:focus-visible { opacity: var(--nav-hover, .67); outline: none; }
.stage-nav:hover .stage-nav-label, .stage-nav:focus-visible .stage-nav-label { opacity: 1; transform: none; }

/* Round indicator (Figma "Round Indicator") */
.round-ind {
  position: absolute; z-index: 3; transform: translateX(-50%); white-space: nowrap; cursor: default;
  font-family: 'Josefin Sans', sans-serif; font-weight: var(--w-round-stage); line-height: 1;
  color: #fff; opacity: var(--round-opacity, .67);
}
.gl-round .round-ind { color: transparent; opacity: 1; }          /* WebGL draws it with Vivid Light */
.css-glass .round-ind { color: rgb(230, 230, 230); mix-blend-mode: color-dodge; }

/* Up / down arrows between columns: drawn below the frames */
#arrows { position: absolute; inset: 0; pointer-events: none; z-index: 0; filter: brightness(var(--dimb, 1)); }
.gl-arrows #arrows { display: none; }
.arrow { position: absolute; left: 0; top: 0; }   /* colour = background + arrow colour (plus-lighter), set from JS */
.arrow svg { display: block; width: 100%; height: 100%; }


/* ---------- Frames (glass panels) ---------- */
.frame {
  --u: calc(var(--k, 1) * 1px);
  position: absolute;
  border-radius: calc(32 * var(--u));
  cursor: default;
}
/* Frost, tint, stroke and glow are drawn by the WebGL layer. A frame that is scaled up (or returning)
   also frosts the DOM content of the frames it overlaps, so it gets a backdrop-filter and its own crisp stroke. */
.frame.lifted, .frame.front {
  -webkit-backdrop-filter: blur(calc(var(--lift-blur, 8) * var(--u))) saturate(1.1);
  backdrop-filter: blur(calc(var(--lift-blur, 8) * var(--u))) saturate(1.1);
}
.frame.lifted::after, .frame.front::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.55);
}
.frame.lifted { z-index: 30; }
.frame.front { z-index: 31; }
/* ---------- Cheap CSS glass (phones/tablets, or no WebGL). Values come from MOBILE in settings.js ---------- */
.css-glass #page { background: #000 var(--bg-img) center / cover no-repeat; }
.css-glass #dim { position: absolute; inset: 0; z-index: 20; background: #000; opacity: 0; pointer-events: none; }
.css-glass .frame {
  /* tint over a pre-blurred copy of the page background, positioned so it lines up with the page */
  background-image: linear-gradient(rgba(184,255,197,var(--tint)), rgba(184,255,197,var(--tint))), var(--frost-img);
  background-size: 100% 100%, var(--pw) var(--ph);
  background-position: 0 0, var(--bx, 0) var(--by, 0);
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,var(--stroke));
}
.css-glass .frame.lit {
  /* --light (0..1) shrinks the neon to nothing and grows it back when the stage changes */
  --lu: calc(var(--u) * var(--light, 1));
  box-shadow:
    inset 0 0 0 1px rgba(255,255,240,calc(.95 * var(--light, 1))),
    0 0 0 1px rgba(255,255,240,calc(.55 * var(--light, 1))),
    0 0 calc(12 * var(--lu)) calc(3 * var(--lu)) var(--glow, transparent),
    inset 0 0 calc(14 * var(--lu)) calc(1 * var(--lu)) var(--glow-soft, transparent),
    0 0 calc(140 * var(--lu)) calc(40 * var(--lu)) var(--glow-faint, transparent),
    inset 0 0 calc(90 * var(--lu)) var(--glow-faint, transparent);
}
.css-glass .frame.lifted, .css-glass .frame.front { -webkit-backdrop-filter: none; backdrop-filter: none; }
.css-glass.lift-blur .frame.lifted, .css-glass.lift-blur .frame.front {
  -webkit-backdrop-filter: blur(calc(var(--lift-blur, 8) * var(--u))); backdrop-filter: blur(calc(var(--lift-blur, 8) * var(--u)));
}
.css-glass .frame::after { display: none; }
.css-glass .header .l1, .css-glass .header .l2 { color: var(--title-color, #f0ff3c); }
/* Highlighted matches sit above the dim overlay */
.css-glass .hl { position: relative; z-index: 25; }

.contents {
  position: absolute; left: calc(32 * var(--u)); top: 0; width: calc(192 * var(--u));
  display: flex; flex-direction: column; gap: calc(16 * var(--u));
}
.info { height: calc(59 * var(--u)); display: flex; align-items: center; justify-content: space-between; white-space: nowrap; }
.info .bo, .info .date { font-size: calc(14 * var(--u)); color: var(--muted); width: calc(52 * var(--u)); }
.info .date { text-align: right; }
/* Ghost labels: colour is computed in JS from the glass behind them (colour-dodge, as in Figma) */
.ghost { font-family: 'Josefin Sans', sans-serif; font-weight: var(--w-score-title); color: var(--ghost, rgba(255,255,255,.3)); text-align: center; }
.round-label { font-size: calc(48 * var(--u)); line-height: normal; }

.matchup { display: flex; align-items: center; height: calc(64 * var(--u)); }
.seed { width: calc(64 * var(--u)); height: calc(64 * var(--u)); flex: none; display: grid; place-items: center; }
.seed img, .slot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.seed { position: relative; }
/* Placeholder shape: shown on empty seeds; logos shrink into it / grow out of it when the stage changes */
.seed .ph {
  position: absolute; left: 30%; top: 30%; width: 40%; height: 40%; border-radius: calc(12 * var(--u));
  border: 1px dashed rgba(255,255,255,.14); background: rgba(255,255,255,.03);
}
.seed[data-team] .ph { opacity: 0; }
.seed img { position: relative; }
.stats {
  width: calc(64 * var(--u)); padding: 0 calc(8 * var(--u)); display: flex; justify-content: center; align-items: center;
  font-size: calc(16 * var(--u)); white-space: nowrap; color: rgba(255,255,255,.6);
}
.stats { position: relative; }
.stats .vs-x { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.stats .score.win { color: var(--win); }
.stats .score.lose { color: var(--lose); }
.stats .sep { padding: 0 calc(1 * var(--u)); }
.stats.has-maps { position: relative; align-self: center; height: calc(20 * var(--u)); }
.stats.has-maps > span { transition: opacity var(--fade, 500ms ease); }
/* Hover target: grows to an invisible 80×80dp box when open (doesn't move the layout).
   The visible highlight (::before) stays 62dp wide so it never overlaps the team logos. */
.stats .hitbox { position: absolute; left: 50%; top: 50%; width: 100%; height: 100%; transform: translate(-50%, -50%); }
.stats .hitbox::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: calc(63 * var(--u)); height: calc(63 * var(--u));
  transform: translate(-50%, -50%); border-radius: calc(14 * var(--u));
  background: rgba(255,255,255,0); box-shadow: inset 0 0 0 1px rgba(255,255,255,0);
  transition: background var(--fade, 500ms ease), box-shadow var(--fade, 500ms ease);
}
.stats.maps-open { z-index: 2; }
.stats.maps-open .hitbox { width: calc(80 * var(--u)); height: calc(80 * var(--u)); }
.stats.maps-open .hitbox::before { background: rgba(255,255,255,0.07); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16); }
.stats.maps-open > span { opacity: 0; }

/* Map rows fly out from the centre: name (left-aligned) | score (centred), centred as a pair in the box */
.map-layer { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
.map-line {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); opacity: 0;
  /* name 22.5dp + gap 1.5dp + score 37dp = 61dp, inside the 62dp highlight.
     Widest real cases at these sizes: "anub" 22.1dp, "22:20" 36.5dp. */
  display: grid; grid-template-columns: calc(20 * var(--u)) calc(36 * var(--u)); column-gap: 0;
  align-items: center; white-space: nowrap;
  font-size: calc(14 * var(--u)); line-height: calc(16 * var(--u)); color: rgba(255,255,255,.6);
}
.map-line.no-names { grid-template-columns: calc(37 * var(--u)); }
.map-line .sep { padding: 0; }
.map-name { text-align: left; font-size: calc(9 * var(--u)); overflow: hidden; padding-left: calc(3 * var(--u)); }   
.map-score { display: flex; justify-content: center; }
.map-score .tbd { opacity: .6; }
.map-line .score.win { color: var(--win); }
.map-line .score.lose { color: var(--lose); }

.slot { position: absolute; left: calc(32 * var(--u)); width: calc(128 * var(--u)); height: calc(128 * var(--u)); }
.vertical-label {
  position: absolute; left: calc(208.5 * var(--u)); width: calc(192 * var(--u));
  transform: translate(-50%, -50%) rotate(-90deg);
  font-size: calc(32 * var(--u)); line-height: 1.05; font-weight: var(--w-frame-label);
}
.count-label { position: absolute; left: 50%; transform: translate(-50%, -50%); white-space: nowrap; font-size: calc(48 * var(--u)); }

[data-team] { cursor: pointer; }

/* ---------- Tooltip (Figma: Frame 1 > Sample Tooltip) ----------
   The logo is the hovered logo itself (same size and spot); the glass bubble forms around it. */
#tooltip {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
  display: flex; align-items: center; gap: calc(5 * var(--u));
  padding: calc(9 * var(--u)) calc(15 * var(--u));
  border-radius: calc(32 * var(--u)); opacity: 0;
  background: rgba(0, 0, 0, 0.3);                       /* rgba(39,39,39,.2) multiply */
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 calc(62.1 * var(--u)) calc(20 * var(--u)) rgba(255, 255, 255, 0.07);
  -webkit-backdrop-filter: blur(calc(var(--tip-blur, 3.5) * var(--u)));
  backdrop-filter: blur(calc(var(--tip-blur, 3.5) * var(--u)));
  font-family: 'Inter', system-ui, sans-serif; color: #fff; white-space: nowrap;
}
#tooltip.show { opacity: 1; }
#tooltip.flip { flex-direction: row-reverse; }
#tooltip img { display: block; object-fit: contain; flex: none; }
.tt-info { min-width: calc(149 * var(--u)); display: flex; flex-direction: column; gap: calc(6 * var(--u)); padding: 0 calc(1 * var(--u)); }
.tt-head { display: flex; justify-content: space-between; gap: calc(23 * var(--u)); padding: 0 calc(4 * var(--u)); font-weight: 700; font-size: calc(14 * var(--u)); }
.tt-row { display: flex; justify-content: space-between; width: calc(132 * var(--u)); padding: calc(1 * var(--u)) calc(4 * var(--u)); font-size: calc(10 * var(--u)); }
.tt-opps {
  display: grid; grid-template-columns: repeat(3, max-content); justify-content: space-between; gap: calc(3 * var(--u)) calc(16 * var(--u));
  padding: calc(3 * var(--u)) calc(4 * var(--u)); font-size: calc(10 * var(--u)); opacity: 0.5;
}
.tt-opps[hidden] { display: none; }

/* Series hover: align map scores on the colon, pad map names off the box edge */

/* Score as three columns: left score right-aligned | colon | right score left-aligned,
   so the colon sits in the same place on every row */
.map-score {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.map-score .score:first-child { text-align: right; }
.map-score .score:last-child  { text-align: left; }
.map-score .sep { padding: 0; }
.map-score .tbd { grid-column: 2; }   /* an unplayed map's "–" sits on the colon line */
