/* The tennis draw that builds itself on scroll. Colours in :root (the Playground palette): one accent, the yellow of the
   ball, for the ball, the winner marks, the trophy and the champion; everything else is a deep grass green with warm
   white hairlines. GSAP moves .frame and the parts of the draw, the CSS styles .panel and the foot inside it. */
:root {
  --page: #08130d;          /* the page, a very dark grass green */
  --page-lift: #12241a;     /* the soft lift of the page behind the panel */
  --panel: #0f1c15;         /* the panel */
  --box: #13251b;           /* the boxes of the draw */
  --ink: #eef0e4;           /* the words */
  --muted: #7d8f82;         /* the small words */
  --hair: rgba(232, 240, 222, 0.36);      /* the lines of the draw */
  --hair-soft: rgba(232, 240, 222, 0.12); /* the faint lines, the empty boxes */
  --ball: #dcef45;          /* the accent: the ball, the winners, the trophy */
  --ball-hi: #f6ffb0;       /* the light side of the ball */
  --ball-lo: #9fb21c;       /* the shade of the ball */
  --ball-ink: #1b2306;      /* the words on the accent */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--page); }
html, body { overflow-x: clip; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }

.draw { position: relative; height: 460vh; }
.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2.4vh, 40px) clamp(8px, 2vw, 24px);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 90% at 50% 40%, var(--page-lift), var(--page) 68%);
}
@supports (height: 100lvh) {
  .stage { height: 100lvh; }
}
/* the mown stripes of a grass court, barely there */
.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: 0.5;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0 7vw, transparent 7vw 14vw);
  -webkit-mask-image: radial-gradient(90% 80% at 50% 45%, #000, transparent 75%);
  mask-image: radial-gradient(90% 80% at 50% 45%, #000, transparent 75%);
}

/* one yellow light behind the panel: it grows with the final */
.light {
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 46%;
  width: min(70vw, 70vh, 600px);
  height: min(48vw, 48vh, 400px);
  margin: calc(min(48vw, 48vh, 400px) / -2) 0 0 calc(min(70vw, 70vh, 600px) / -2);
  border-radius: 50%;
  pointer-events: none;
  filter: blur(60px);
  opacity: 0;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--ball) 26%, transparent), color-mix(in srgb, var(--ball) 6%, transparent) 62%, transparent);
}
.grain {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- the panel (its width is set by the script) */
.frame { width: min(100%, 1040px); }
.panel {
  position: relative;
  border-radius: clamp(14px, 3.6vh, 26px);
  padding: clamp(10px, 2.4vh, 22px) clamp(10px, 2.4vw, 22px);
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 88%, white 4%), color-mix(in srgb, var(--panel) 96%, transparent));
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 10px 24px -10px rgba(0, 0, 0, 0.6),
    0 40px 80px -30px rgba(0, 0, 0, 0.75);
}
.panel__edge {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 0;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(240, 255, 200, 0.45), transparent);
}
.panel__glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.5s ease;
  background: radial-gradient(300px circle at var(--mx, 50%) var(--my, -30%), color-mix(in srgb, var(--ball) 6%, transparent), transparent 70%);
}
@media (hover: hover) {
  .panel:hover .panel__glow { opacity: 1; }
}

/* the head: mark, name and draw, the surface */
.head { position: relative; display: flex; align-items: center; gap: 9px; }
.mark {
  flex: none;
  display: grid;
  place-items: center;
  width: clamp(22px, 6vh, 30px);
  height: clamp(22px, 6vh, 30px);
  border-radius: 8px;
  background: linear-gradient(150deg, var(--ball-hi), var(--ball) 55%, var(--ball-lo));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 6px 14px -6px color-mix(in srgb, var(--ball) 70%, transparent);
}
.mark svg { width: 15px; height: 15px; fill: none; stroke: var(--ball-ink); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.brand {
  font-size: clamp(12px, 3.2vh, 15px);
  font-weight: 640;
  font-stretch: 108%;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand__sub { font-weight: 450; font-stretch: 100%; margin-left: 6px; }
.meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  font-size: clamp(10px, 2.8vh, 12.5px);
  font-weight: 520;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.meta svg { width: 13px; height: 13px; fill: none; stroke: var(--ball); stroke-width: 1.3; stroke-linecap: round; opacity: 0.85; }
.meta__sep { width: 1px; height: 10px; background: rgba(255, 255, 255, 0.16); }

/* ---------------------------------------------------------------- the draw */
.map {
  position: relative;
  margin-top: clamp(6px, 2vh, 18px);
  border-radius: clamp(10px, 2.6vh, 16px);
  padding: clamp(4px, 1.4vh, 14px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 40%),
    rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), inset 0 10px 30px -14px rgba(0, 0, 0, 0.6);
}
.bracket { display: block; width: 100%; height: auto; overflow: visible; }
.bracket text { font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif; }
.bracket .base { fill: none; stroke: var(--hair-soft); stroke-width: 1; stroke-linejoin: round; }
.bracket .link { fill: none; stroke: var(--hair); stroke-width: 1.15; stroke-linejoin: round; stroke-linecap: round; }
.bracket .box { fill: var(--box); stroke: var(--hair-soft); stroke-width: 1; }
.bracket .box-edge { fill: none; stroke: var(--hair); stroke-width: 1; }
.bracket .sep { stroke: var(--hair-soft); stroke-width: 0.8; }
.bracket .hit { fill: transparent; }
.bracket .row-bg { fill: #fff; opacity: 0; transition: opacity 0.3s ease; }
.bracket .name { font-size: 10.5px; font-weight: 560; font-stretch: 102%; fill: var(--ink); letter-spacing: -0.005em; }
.bracket .seed { font-size: 7.5px; font-weight: 600; font-stretch: 112%; fill: var(--muted); text-anchor: middle; }
.bracket .digit { font-size: 10.5px; font-weight: 600; fill: var(--ink); text-anchor: middle; font-variant-numeric: tabular-nums; }
.bracket .digit.is-lost { fill: var(--muted); font-weight: 480; }
.bracket .wait { fill: var(--hair-soft); }
.bracket .win { fill: var(--ball); }
.bracket .label { font-size: 7.5px; font-weight: 600; font-stretch: 116%; letter-spacing: 0.14em; fill: var(--muted); }
.bracket .label.is-now { fill: var(--ink); }
.bracket .shelf { stroke: var(--hair); stroke-width: 1; stroke-linecap: round; }
.bracket .cup { fill: none; stroke: var(--hair); stroke-width: 1.15; stroke-linejoin: round; stroke-linecap: round; }
.bracket .cup-fill { fill: var(--ball); opacity: 0; }
.bracket .cup-glow { opacity: 0; }
.bracket .sheen { fill: url(#sheen); opacity: 0; }
.bracket .ball-seam { fill: none; stroke: rgba(255, 255, 255, 0.85); stroke-width: 0.9; stroke-linecap: round; }
.bracket .ball-shadow { fill: #000; }
.bracket .slot.is-path .row-bg { opacity: 0.045; }
.bracket .link.is-path { stroke: var(--ball); }
@media (hover: hover) {
  .bracket .slot { cursor: default; }
  .bracket .slot:hover .row-bg { opacity: 0.06; }
}

/* ---------------------------------------------------------------- the foot: the rounds and the champion */
.foot {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 18px);
  margin-top: clamp(6px, 2vh, 18px);
}
.rounds {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.rounds__pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.05));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 4px 10px -4px rgba(0, 0, 0, 0.6);
}
.rounds__tab {
  position: relative;
  padding: clamp(4px, 1.3vh, 7px) clamp(8px, 2vh, 13px);
  font-size: clamp(10px, 2.7vh, 12px);
  font-weight: 540;
  white-space: nowrap;
  color: var(--muted);
  transition: color 0.4s ease, font-stretch 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.rounds__tab .short { display: none; }
.rounds__tab.is-now { color: var(--ink); font-stretch: 108%; }

.champ {
  position: relative;
  margin-left: auto;
  min-width: 0;
  flex: 0 1 auto;
  display: flex;
  justify-content: flex-end;
}
.champ__wait { position: absolute; right: 0; top: 50%; width: clamp(90px, 26vh, 170px); transform: translateY(-50%); display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.bar {
  display: block;
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 30%, rgba(255, 255, 255, 0.13) 50%, rgba(255, 255, 255, 0.05) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.8s linear infinite;
}
.bar--a { width: 40%; }
.bar--b { width: 78%; height: 9px; }
@keyframes shimmer { to { background-position: -150% 0; } }
.champ__line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  font-size: clamp(10px, 2.7vh, 12px);
}
.champ__label { font-weight: 600; font-stretch: 116%; letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.82em; }
.champ__name { font-size: clamp(13px, 3.8vh, 18px); font-weight: 640; letter-spacing: -0.015em; color: var(--ball); }
.champ__score { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- the phone and short screens */
@media (max-width: 600px) {
  .brand__sub { display: none; }
  .champ__label { display: none; }
}
@media (max-width: 460px) {
  .rounds__tab .long { display: none; }
  .rounds__tab .short { display: inline; }
}
@media (max-width: 380px) {
  .meta__sep, .meta .muted { display: none; }
  .rounds__tab { padding-left: 7px; padding-right: 7px; }
  .champ__score { display: none; }
}
