/* 1rem is 10px on a 1920 x 1080 TV and scales with the screen. */
:root {
  --blue: #01a7d9;      /* Maidan logo blue */
  --blue-shade: #009dcd;
  --blue-text: #00688a;
  --ink: #0f0609;       /* Maidan logo black */
  --white: #fff;
  --ball: #e2f23c;      /* only ever used for "minutes matter" */
  --cut: 2.6rem;        /* the 45 degree cut from the bars of the Maidan mark */
  --inset: 1.2rem;      /* distance from tile edge to the court's sideline */
  --out: cubic-bezier(.16, 1, .3, 1);
  font-size: min(calc(100vw / 192), calc(100vh / 108));
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  height: 100vh;
  overflow: hidden;
  background: var(--blue);
  color: var(--ink);
  font: 500 2.6rem/1.2 Saira, Changa, Bahnschrift, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
body.idle { cursor: none; }
img { display: block; }
ol { list-style: none; }

/* Ground: the logo's chevrons, very large, drifting slowly down the screen. */
.ground {
  position: fixed;
  left: 0; right: 0; top: -32rem; bottom: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 960 320' preserveAspectRatio='none'%3E%3Cpath d='M0-320 480 0 960-320v130L480 130 0-190zM0 0l480 320L960 0v130L480 450 0 130z' fill='%23009dcd'/%3E%3C/svg%3E") 0 0 / 96rem 32rem;
  animation: drift 48s linear infinite;
}
@keyframes drift { to { transform: translateY(32rem); } }

.board {
  position: relative;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

/* Header and footer */
.plate { background: var(--white); display: grid; place-items: center; flex: none; }
.plate-maidan {
  padding: 2rem 5rem 2rem 3.6rem;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 4rem), calc(100% - 4rem) 100%, 0 100%);
}
.plate-maidan img { height: 10rem; width: auto; }
.plate-encore {
  padding: 1.3rem 3.6rem 1.3rem 5rem;
  clip-path: polygon(0 3rem, 3rem 0, 100% 0, 100% 100%, 0 100%);
}
.plate-encore img { height: 5.4rem; width: auto; }

.top { display: flex; align-items: center; gap: 4rem; padding-right: 3.6rem; }
.venue { flex: 1; min-width: 0; padding-top: 1rem; }
.venue h1 { font-size: 5.6rem; white-space: nowrap; font-weight: 800; font-stretch: 112%; line-height: 1; letter-spacing: -.01em; }
.venue p { font-size: 3rem; margin-top: .8rem; }
.clock { text-align: right; padding-top: 1rem; }
.time { font-size: 8.4rem; font-weight: 700; font-stretch: 100%; line-height: .9; display: flex; justify-content: flex-end; white-space: pre; }
.time span { display: block; }
.clock p { font-size: 2.6rem; margin-top: .9rem; }

.bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 4rem; padding-left: 3.6rem; }
.status { display: flex; align-items: center; gap: 1.2rem; font-size: 2.4rem; padding: 0 0 2rem; }
.status-dot { width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--ink); flex: none; }
.status[data-tone="warn"] {
  background: var(--ink); color: var(--ball);
  padding: 1.1rem 2.4rem; margin-bottom: 1.3rem; font-weight: 600;
}
.status[data-tone="warn"] .status-dot { background: var(--ball); }
.status[data-tone="sample"] { background: var(--ball); padding: 1.1rem 2.4rem; margin-bottom: 1.3rem; font-weight: 600; }

.hint { background: var(--ink); color: var(--white); font-size: 2.6rem; font-weight: 600; padding: 1.1rem 2.4rem; margin-bottom: 1.3rem; }

/* Main area */
main { display: grid; grid-template-columns: minmax(0, 1fr) 56rem; gap: 2rem; padding: 2rem 3.6rem 1.6rem; min-height: 0; }

.courts { display: grid; gap: 1.6rem; min-height: 0; --name: 4.8rem; --court: 3.4rem; transition: opacity .6s; }
.courts[data-rows="2"], .courts[data-cols="2"] { --name: 5.6rem; --court: 3.8rem; }
.courts[data-cols="1"] { --name: 6.4rem; --court: 4.4rem; }
.waiting .courts { opacity: 0; }
.courts, .message { grid-area: 1 / 1; }
.side { grid-area: 1 / 2; }
.message { align-self: center; max-width: 100rem; }
.message h2 { font-size: 7rem; font-weight: 800; line-height: 1.05; text-wrap: balance; }
.message p { font-size: 3.4rem; margin-top: 2rem; max-width: 28em; }

/* Court tile: the court itself, and a strip for who is next.
   A tile can briefly hold two faces while one wipes over the other. */
.court { position: relative; min-width: 0; min-height: 0; overflow: hidden; clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%); }
.face { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: grid; grid-template: minmax(0, 1fr) 4.8rem / minmax(0, 1fr); }
.face.play { background: var(--ink); color: var(--white); --line: rgba(255, 255, 255, .17); --side: rgba(255, 255, 255, .4); --strip: #33252b; }
.face.soon { background: var(--white); color: var(--ink); --line: rgba(1, 167, 217, .3); --side: rgba(1, 167, 217, .6); --strip: #d5eef6; }
.face.free { background: #12b2e2; color: var(--ink); --line: rgba(255, 255, 255, .5); --side: rgba(255, 255, 255, .9); --strip: #008fbc; }

.pitch {
  position: relative; min-height: 0;
  display: grid; grid-template: auto minmax(0, 1fr) auto / minmax(0, 1fr);
  padding: calc(var(--inset) + .9rem) calc(var(--inset) + 1.7rem) calc(var(--inset) + 1.1rem);
}
.lines { position: absolute; top: 0; left: 0; width: 100%; height: 100%; fill: none; stroke: var(--line); stroke-width: .3rem; }
.pitch > :not(.lines):not(.track) { position: relative; }

.head { display: flex; align-items: baseline; justify-content: space-between; gap: 1.6rem; }
.head h3 { font-size: var(--court); font-weight: 800; font-stretch: 108%; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head h3 small { font-size: .7em; font-weight: 500; font-stretch: 90%; margin-left: .5em; opacity: .85; }
.head h3 small:empty { display: none; }
.left { font-size: calc(var(--court) * .8); font-weight: 600; white-space: nowrap; flex: none; }
.face.play .left { color: #7fd6f0; }
.court[data-state="ending"] .left { color: var(--ball); }
.face.soon .left { background: var(--ball); padding: .05em .5em; margin: -.05em 0; }

.who { align-self: center; min-width: 0; font-size: var(--name); line-height: 1.12; display: grid; }
.name { font-weight: 700; font-stretch: 88%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.name.long { font-size: .66em; line-height: 1.06; font-stretch: 78%; white-space: normal; text-wrap: balance; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.who .rest { font-size: .66em; font-weight: 500; opacity: .85; line-height: 1.3; }

.note { display: flex; align-items: center; gap: 1.2rem; font-size: 2.4rem; line-height: 1.2; margin-top: .5rem; min-width: 0; white-space: nowrap; }
.kind { font-weight: 500; font-stretch: 90%; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Payment: two colours for the two answers, settled or something left to pay. */
.pay { flex: none; display: inline-flex; align-items: center; gap: .5em; padding: .08em .55em; font-weight: 700; font-stretch: 90%; color: var(--ink); white-space: nowrap; }
.pay.paid { background: #7fd9b4; }
.pay.due { background: #ffb547; }
.dots { display: inline-flex; gap: .2em; }
.dots i { width: .62em; height: .62em; border-radius: 50%; border: .11em solid var(--ink); }
.dots .on { background: var(--ink); }

.times { display: flex; justify-content: space-between; align-items: baseline; gap: 1.2rem; white-space: nowrap; z-index: 1; font-size: calc(var(--court) * .88); font-weight: 600; line-height: 1; }

/* Room for tall Arabic letters and tails, which hidden overflow would otherwise clip. */
.head h3, .name:not(.long), .kind, .then-name, .next strong { padding-block: .2em; margin-block: -.2em; }

/* The bottom sideline is the session's timeline, and the ball marks now. */
.track { position: absolute; left: var(--inset); right: var(--inset); bottom: calc(var(--inset) - .3rem); height: .6rem; background: var(--side); }
.bar { height: 100%; background: var(--blue); transform: scaleX(var(--p, 0)); transform-origin: 0 50%; transition: transform 1.6s var(--out); }
.roll { position: absolute; top: 0; left: 0; width: 100%; transform: translateX(calc(var(--p, 0) * 100%)); transition: transform 1.6s var(--out); }
.ball { position: absolute; left: -1.3rem; top: -1rem; width: 2.6rem; height: 2.6rem; display: block; }
.court[data-state="ending"] .ball { animation: pulse .9s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.35); } }

.then { background: var(--strip); display: flex; align-items: center; gap: 1rem; padding: 0 calc(var(--inset) + .6rem) 0 calc(var(--inset) + 1.7rem); font-size: 2.6rem; white-space: nowrap; min-width: 0; }
.then b { font-weight: 500; font-stretch: 84%; flex: none; }
.then-name { font-weight: 700; font-stretch: 88%; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Side of the screen: the rest of today's bookings, with adverts under or over them */
.side { position: relative; min-height: 0; }
.next {
  position: absolute; top: 0; left: 0; right: 0; bottom: var(--ad, 0px);
  background: var(--white); padding: 2rem 2.8rem 1.2rem;
  display: grid; grid-template: auto minmax(0, 1fr) / minmax(0, 1fr);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  transition: bottom .9s var(--out), opacity .5s;
}
.side.full .next { opacity: 0; }
.next-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 1.4rem 1.2rem 0; }
.next h2 { font-size: 3.4rem; font-weight: 800; font-stretch: 108%; line-height: 1; }
.next-head span { font-size: 2.2rem; color: var(--blue-text); font-weight: 600; }
.next ol { position: relative; overflow: hidden; grid-area: 2 / 1; }
.next li { height: var(--row, 8.6rem); border-top: .2rem solid #d5eef6; display: grid; grid-template-columns: 15.6rem minmax(0, 1fr); align-items: center; background: var(--white); }
.side[data-clock="24"] .next li { grid-template-columns: 12rem minmax(0, 1fr); }
.when { display: grid; white-space: nowrap; }
.when time { font-size: 3.5rem; font-weight: 700; font-stretch: 90%; line-height: 1.1; }
.when small { font-size: 2.2rem; font-weight: 500; line-height: 1.25; }
.what { min-width: 0; }
.next strong { display: block; font-size: 3.1rem; font-weight: 700; font-stretch: 88%; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.next li p { font-size: 2.4rem; font-weight: 600; color: var(--blue-text); display: flex; justify-content: space-between; align-items: center; line-height: 1.25; margin-top: .3rem; }
.top-line { display: flex; align-items: center; gap: 1.2rem; }
.top-line strong { flex: 1; min-width: 0; }
.top-line .pay { font-size: 2.1rem; }
.place { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next li mark { flex: none; margin-left: 1rem; background: var(--ball); color: var(--ink); padding: 0 .5em; font-size: 2.2rem; }
.next-none { grid-area: 2 / 1; font-size: 2.8rem; color: var(--blue-text); border-top: .2rem solid #d5eef6; padding-top: 1.8rem; }

.ad { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--ad, 0px) - 1.8rem); overflow: hidden; transition: height .9s var(--out); }
.side.full .ad { height: var(--ad); }
.ad-layer { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: var(--ink); }
.ad-layer > * { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Shown on the website version until the TV has the private code */
.locked { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 6; background: var(--white); display: grid; place-content: center; justify-items: center; gap: 7rem; }
.locked img { width: 60rem; height: auto; }
.locked form { display: grid; gap: 2rem; width: 70rem; text-align: center; }
.locked label { font-size: 4.4rem; font-weight: 800; }
.locked input { font: 700 5.4rem Saira, Bahnschrift, sans-serif; text-align: center; padding: 1.6rem; border: .4rem solid var(--ink); color: var(--ink); background: var(--white); }
.locked button { font: 700 3.4rem Saira, Bahnschrift, sans-serif; padding: 1.8rem; border: 0; background: var(--ink); color: var(--white); cursor: pointer; }
.locked :focus-visible { outline: .6rem solid var(--blue); outline-offset: .4rem; }
.locked p { font-size: 2.8rem; min-height: 3.6rem; }

/* Chevron transition after the opening */
.sweep { position: fixed; left: 0; top: 0; width: 100vw; height: 300vh; transform: translateY(-300vh); pointer-events: none; will-change: transform; z-index: 5; }
.sweep-ink { fill: var(--ink); }
.sweep-blue { fill: var(--blue); }
.sweep-white { fill: var(--white); }

/* Opening: the Maidan mark builds itself from its own chevrons */
.intro { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: var(--white); display: grid; place-items: center; z-index: 4; }
.intro-logo { position: relative; width: 92rem; }
.intro-logo img { width: 100%; height: auto; clip-path: inset(0 100% 0 28%); animation: reveal .9s 1s var(--out) forwards; }
.intro-logo svg { position: absolute; left: 0; top: 0; width: 26.66%; overflow: visible; fill: var(--blue); }
.intro-logo .ink { fill: var(--ink); }
.chevron { opacity: 0; animation: drop .7s var(--out) forwards; }
.chevron:nth-of-type(3) { animation-delay: .15s; }
.chevron:nth-of-type(4) { animation-delay: .3s; }
.chevron:nth-of-type(5) { animation-delay: .45s; }
.post { opacity: 0; animation: rise .7s .6s var(--out) forwards; }
@keyframes drop { from { opacity: 0; transform: translateY(-190px); } 40% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(150px); } to { opacity: 1; transform: none; } }
@keyframes reveal { to { clip-path: inset(0 0 0 28%); } }

/* Portrait screens and phones */
@media (max-aspect-ratio: 1/1) {
  :root { font-size: calc(100vw / 108); }
  body { height: auto; overflow: auto; }
  .board { height: auto; min-height: 100vh; }
  main { grid-template-columns: minmax(0, 1fr); }
  .courts { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; grid-template-rows: none !important; grid-auto-rows: 27rem; --name: 4.6rem; --court: 3.2rem; }
  .court { grid-column: auto !important; }
  .side { grid-area: 2 / 1; display: flex; flex-direction: column; gap: 2rem; }
  .next, .ad { position: relative; bottom: auto; }
  .next ol { height: auto; }
  .ad { height: calc(var(--ad, 0px)); }
  .top { gap: 2.4rem; }
  .venue h1 { font-size: 3.8rem; white-space: normal; }
  .venue p { font-size: 2.4rem; }
  .time { font-size: 6.2rem; }
  .clock p { white-space: nowrap; }
}
@media (max-aspect-ratio: 1/1) and (max-width: 700px) {
  :root { font-size: calc(100vw / 62); }
  .top { flex-wrap: wrap; gap: 0 2rem; padding-right: 2rem; }
  .plate-maidan { padding: 1.4rem 4rem 1.4rem 2rem; }
  .plate-maidan img { height: 7rem; }
  .venue { order: 3; flex-basis: 100%; padding: 2rem 2rem 0; }
  .venue h1 { font-size: 5.2rem; }
  .clock { flex: 1; }
  .time { font-size: 5.4rem; }
  main { padding: 2rem; }
  .courts { grid-template-columns: minmax(0, 1fr) !important; }
  .bottom { flex-wrap: wrap; gap: 1.6rem; padding-left: 2rem; }
  .intro-logo { width: 46rem; }
  .locked form, .locked img { width: 50rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ground, .ball, .intro * { animation-duration: .01s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
  .bar, .roll, .next, .ad { transition: none; }
}
