/* ipsLiveOverlay — broadcast styling. Transparent body so OBS/vMix composites it. */

:root {
  --accent: #00e0ff;          /* primary brand accent */
  --accent-2: #ff007a;        /* secondary accent */
  --bg: rgba(10, 13, 20, 0.86);
  --bg-2: rgba(18, 23, 34, 0.92);
  --row: rgba(14, 18, 28, 0.82);
  --row-alt: rgba(22, 28, 42, 0.82);
  --line: rgba(255, 255, 255, 0.08);
  --txt: #f3f6fb;
  --txt-dim: #9aa6b8;
  --purple: #b15cff;          /* session-best lap */
  --green: #1fd14e;
  --gain: #1fd14e;
  --loss: #ff4d57;
  --pit: #ffb020;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --scale: 1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: transparent;     /* critical for OBS browser source */
  font-family: 'Barlow', system-ui, sans-serif;
  color: var(--txt);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* When previewing in a normal browser, ?bg=1 paints a dark backdrop. */
body.preview { background: radial-gradient(120% 120% at 30% 0%, #1a2030 0%, #06080d 70%); }

#root { position: fixed; inset: 0; transform: scale(var(--scale)); transform-origin: top left; }

/* show only the active layout */
.layout-tower #lower, .layout-tower #f1 { display: none; }
.layout-lower #tower, .layout-lower #f1 { display: none; }
.layout-f1 #tower, .layout-f1 #lower { display: none; }
.chrome-off .conn { display: none !important; }

.tabular { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

/* ===================== brand logo (RMC) ===================== */
.logo { display: block; width: auto; object-fit: contain; }
.brandbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: #000;            /* matches the logo's black bg seamlessly */
  border-bottom: 1px solid var(--line);
}
.brandbar .logo { height: 34px; }
.lower__brand {
  display: flex; align-items: center; padding: 0 16px;
  background: #000; border-right: 1px solid var(--line);
}
.lower__brand .logo { height: 46px; }
.logo-off { display: none !important; }

/* ===================== connection pill ===================== */
.conn {
  position: absolute; top: 12px; right: 14px; z-index: 50;
  font: 700 12px 'Barlow', sans-serif; letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255, 77, 87, .16); color: #ff8b92;
  border: 1px solid rgba(255, 77, 87, .4); backdrop-filter: blur(6px);
}

/* ============================================================
   FULL TIMING TOWER
   ============================================================ */
.tower {
  position: absolute; top: 28px; left: 28px;
  width: 430px; max-height: calc(100% - 56px);
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: var(--radius);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  overflow: hidden; backdrop-filter: blur(10px);
}

.tower__head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px;
  background: linear-gradient(100deg, rgba(0, 224, 255, .14), rgba(255, 0, 122, .10));
  border-bottom: 1px solid var(--line);
}
.tower__title { display: flex; flex-direction: column; min-width: 0; }
.tower__session {
  font-family: 'Barlow Semi Condensed', sans-serif; font-weight: 800;
  font-size: 18px; letter-spacing: .01em; line-height: 1.05;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px;
}
.tower__event { font-size: 11px; color: var(--txt-dim); text-transform: uppercase; letter-spacing: .12em; margin-top: 2px; }
.tower__status { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.laps { font: 700 13px 'JetBrains Mono', monospace; color: var(--txt); background: rgba(255,255,255,.07); padding: 3px 8px; border-radius: 6px; }
.laps:empty { display: none; }

/* flag chip */
.flag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 6px; font: 800 12px 'Barlow', sans-serif; letter-spacing: .1em; }
.flag i { width: 11px; height: 11px; border-radius: 3px; background: var(--green); box-shadow: 0 0 8px currentColor; }
.flag b { line-height: 1; }
.flag--green  { color: var(--green);  background: rgba(31,209,78,.14); }
.flag--green i { background: var(--green); color: var(--green); }
.flag--yellow { color: #ffd000; background: rgba(255,208,0,.14); }
.flag--yellow i { background: #ffd000; color: #ffd000; animation: blink 1s steps(2) infinite; }
.flag--red    { color: #ff4d57; background: rgba(255,77,87,.16); }
.flag--red i  { background: #ff4d57; color: #ff4d57; animation: blink .6s steps(2) infinite; }
.flag--finish { color: #fff; background: rgba(255,255,255,.12); }
.flag--finish i { background: repeating-conic-gradient(#fff 0 90deg, #000 0 180deg) 0 0 / 6px 6px; box-shadow: none; }
.flag--live   { color: var(--green); background: rgba(31,209,78,.14); }
.flag--live i { background: var(--green); color: var(--green); animation: pulse 1.6s ease-in-out infinite; }
.flag--stop, .flag--unknown { color: var(--txt-dim); background: rgba(255,255,255,.06); }
.flag--stop i, .flag--unknown i { background: var(--txt-dim); box-shadow: none; }

/* column header */
.tower__cols { display: grid; padding: 6px 14px; gap: 8px; font: 700 10px 'Barlow', sans-serif; letter-spacing: .1em; color: var(--txt-dim); text-transform: uppercase; border-bottom: 1px solid var(--line); }
.tower__cols span:not(:first-child):not(:nth-child(2)):not(:nth-child(3)) { text-align: right; }

/* rows */
.rows { list-style: none; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.rows::-webkit-scrollbar { width: 5px; }
.rows::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }

.row {
  display: grid; align-items: center; gap: 8px;
  padding: 7px 14px; min-height: 38px;
  background: var(--row); border-bottom: 1px solid var(--line);
  transition: transform .45s cubic-bezier(.22,.61,.36,1), background .3s;
  will-change: transform;
}
.row:nth-child(even) { background: var(--row-alt); }
.row.is-leader { background: linear-gradient(90deg, rgba(0,224,255,.16), transparent 60%); }
.row.flash-up  { animation: flashUp .9s ease-out; }
.row.flash-down{ animation: flashDown .9s ease-out; }

.cell-pos { display: flex; align-items: center; justify-content: center; font: 800 15px 'Barlow Semi Condensed', sans-serif; width: 26px; height: 26px; border-radius: 6px; background: rgba(255,255,255,.08); }
.row.is-leader .cell-pos { background: var(--accent); color: #03121a; }
.cell-no { font: 700 13px 'JetBrains Mono', monospace; color: var(--accent); text-align: center; }
.cell-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 7px; }
.cell-name .badge { font: 800 9px 'Barlow', sans-serif; letter-spacing: .06em; padding: 2px 5px; border-radius: 4px; }
.badge.pit { background: rgba(255,176,32,.2); color: var(--pit); }
.badge.out { background: rgba(255,77,87,.2); color: var(--loss); }
.cell-name .chg { font: 700 11px 'JetBrains Mono', monospace; }
.chg.up { color: var(--gain); } .chg.down { color: var(--loss); }

.cell-num { text-align: right; font: 600 14px 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.cell-gap { color: var(--txt-dim); }
.cell-best.pb { color: var(--purple); text-shadow: 0 0 10px rgba(177,92,255,.5); }
.cell-last.pb { color: var(--purple); }

.tower__foot { display: flex; align-items: center; justify-content: space-between; padding: 7px 14px; border-top: 1px solid var(--line); background: var(--bg-2); }
.fastest { font: 700 12px 'Barlow', sans-serif; color: var(--purple); display: flex; align-items: center; gap: 6px; }
.fastest::before { content: '⚡'; }
.fastest:empty { visibility: hidden; }
.fastest:empty::before { content: ''; }
.brand { font: 600 10px 'Barlow', sans-serif; letter-spacing: .14em; color: var(--txt-dim); text-transform: uppercase; }

/* ============================================================
   COMPACT LOWER-THIRD
   ============================================================ */
.lower {
  position: absolute; left: 50%; bottom: 42px; transform: translateX(-50%);
  display: flex; align-items: stretch; gap: 0;
  background: var(--bg); border-radius: 12px; border: 1px solid var(--line);
  box-shadow: var(--shadow); overflow: hidden; backdrop-filter: blur(10px);
  min-width: 720px;
}
.lower__flag { display: flex; align-items: center; padding: 0 16px; background: linear-gradient(180deg, rgba(0,224,255,.16), rgba(0,224,255,.04)); border-right: 1px solid var(--line); }
.lower__flag .flag { font-size: 13px; }
.lower__main { flex: 1; padding: 9px 16px; }
.lower__session { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.lower__session span:first-child { font: 800 13px 'Barlow Semi Condensed', sans-serif; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.lower__rows { list-style: none; display: flex; gap: 10px; }
.lrow { display: flex; align-items: center; gap: 9px; padding: 6px 12px; border-radius: 8px; background: var(--row); border: 1px solid var(--line); transition: transform .45s cubic-bezier(.22,.61,.36,1); }
.lrow.is-leader { background: linear-gradient(90deg, rgba(0,224,255,.2), rgba(0,224,255,.05)); }
.lrow .p { font: 800 16px 'Barlow Semi Condensed', sans-serif; min-width: 20px; text-align: center; }
.lrow.is-leader .p { color: var(--accent); }
.lrow .no { font: 700 12px 'JetBrains Mono', monospace; color: var(--accent); }
.lrow .nm { font-weight: 700; font-size: 15px; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .gp { font: 600 13px 'JetBrains Mono', monospace; color: var(--txt-dim); margin-left: 2px; }
.lower__fl { display: flex; flex-direction: column; justify-content: center; align-items: flex-end; padding: 9px 18px; border-left: 1px solid var(--line); background: rgba(177,92,255,.08); }
.lower__fl-label { font: 800 9px 'Barlow', sans-serif; letter-spacing: .14em; color: var(--purple); }
.lower__fl-time { font: 700 20px 'JetBrains Mono', monospace; color: var(--purple); line-height: 1.1; text-shadow: 0 0 12px rgba(177,92,255,.5); }
.lower__fl-time:empty::after { content: '—'; color: var(--txt-dim); }
.lower__fl-who { font: 600 11px 'Barlow', sans-serif; color: var(--txt-dim); max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   FORMULA 1 STYLE TOWER  (?layout=f1)
   narrow left tower · team-colour bar · 3-letter codes · purple FL banner
   ============================================================ */
.f1 {
  position: absolute; top: 28px; left: 28px;
  width: 300px; max-height: calc(100% - 56px);
  display: flex; flex-direction: column; gap: 3px;
}
.f1__head {
  display: flex; align-items: center; gap: 8px;
  background: #000; border-radius: 6px; padding: 6px 10px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.f1__head .logo { height: 24px; }
.f1__head .flag { margin-left: auto; padding: 3px 7px; font-size: 11px; }
.f1__head .laps { font-size: 12px; padding: 2px 7px; }

.f1__rows { list-style: none; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.f1row {
  display: grid; grid-template-columns: 30px 6px 1fr auto; align-items: center;
  height: 30px; border-radius: 4px; overflow: hidden;
  background: rgba(8, 10, 16, 0.9); border: 1px solid rgba(255,255,255,.05);
  transition: transform .45s cubic-bezier(.22,.61,.36,1), background .3s;
  will-change: transform;
}
.f1row .pos { font: 800 15px 'Barlow Semi Condensed', sans-serif; text-align: center; }
.f1row .bar { width: 6px; height: 100%; background: var(--accent); }
.f1row .who { display: flex; align-items: baseline; gap: 6px; padding-left: 10px; min-width: 0; }
.f1row .code { font: 800 15px 'Barlow Semi Condensed', sans-serif; letter-spacing: .04em; }
.f1row .num { font: 700 11px 'JetBrains Mono', monospace; color: var(--txt-dim); }
.f1row .val { font: 700 13px 'JetBrains Mono', monospace; padding-right: 12px; text-align: right; white-space: nowrap; }
.f1row .val.pb { color: var(--purple); text-shadow: 0 0 10px rgba(177,92,255,.5); }
.f1row.is-leader { background: linear-gradient(90deg, rgba(0,224,255,.18), rgba(8,10,16,.92) 70%); }
.f1row.is-leader .val { color: var(--accent); font-weight: 800; }
.f1row .val.lead { color: var(--accent); font: 800 10px 'Barlow', sans-serif; letter-spacing: .12em; }
.f1row.flash-up { animation: flashUp .9s ease-out; }
.f1row.flash-down { animation: flashDown .9s ease-out; }
.f1row.enter { animation: fadeIn .5s ease-out; }

.f1__fl {
  display: flex; align-items: center; gap: 9px; margin-top: 2px;
  background: linear-gradient(90deg, var(--purple), #7a2fd0);
  color: #fff; border-radius: 5px; padding: 6px 11px; box-shadow: var(--shadow);
}
.f1__fl .lbl { font: 800 9px 'Barlow', sans-serif; letter-spacing: .14em; }
.f1__fl .t { font: 700 15px 'JetBrains Mono', monospace; }
.f1__fl .w { font: 700 11px 'Barlow', sans-serif; margin-left: auto; opacity: .95; }

.layout-f1 .ticker { left: 28px; }   /* F1 tower is narrow, ticker can span normally */

/* ============================================================
   shared ticker
   ============================================================ */
.ticker {
  position: absolute; left: 28px; bottom: 14px; right: 28px;
  background: rgba(255,77,87,.92); color: #fff; border-radius: 7px;
  padding: 7px 14px; font: 700 13px 'Barlow', sans-serif; letter-spacing: .03em;
  box-shadow: var(--shadow); overflow: hidden; white-space: nowrap;
}
.layout-tower .ticker { left: 478px; }   /* clear the tower */

/* ============================================================
   animations
   ============================================================ */
@keyframes blink { 50% { opacity: .25; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes flashUp { 0% { background: rgba(31,209,78,.5); } 100% {} }
@keyframes flashDown { 0% { background: rgba(255,77,87,.45); } 100% {} }
.row.enter, .lrow.enter { animation: fadeIn .5s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; } }
