/* Tulemid look: an archery range on competition day.
   - range green for the frame (top bar, main buttons), target gold for what matters most (leader, current step)
   - the target face is the one bold motif: the brand mark, the ring bands under the top bar, faint rings behind headings
   - target plates: the numbered boards above each target (mat), dark with a big condensed numeral
   - scorecard grid: arrow boxes joined like a printed card
   - ring colours (gold, red, blue, black, white) on a value always mean that score
   - motion only answers something that happened: a value entered, a row saved, a page changed, a place won */
@import url("fonts/fonts.css");

:root {
  --page: #edf1ea;     /* light field green-grey */
  --sheet: #ffffff;    /* the score card */
  --ink: #15241d;      /* text: deep green-black */
  --slate: #5a6a61;    /* secondary text */
  --rule: #c5cfc3;     /* card grid lines */
  --hair: #dce3d9;     /* light dividers */
  --lane: #f5f8f3;     /* alternate lane */
  --brand: #1d4a37;    /* range green */
  --brand-2: #275f47;
  --brand-ink: #f3f6ef;
  --plate: #15241d; --plate-ink: #f3f6ef;
  --focus: #1a7fd0;
  --ok: #1d7a43; --warn: #a65d00; --bad: #c0262d;
  --gold: #ffd22e; --gold-ink: #2a2100; --red: #e0353b; --blue: #1e9bd7; --black: #1f1f1f; --white: #ffffff;
  --silver: #c9d0d6; --bronze: #d79a62;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif-condensed, sans-serif;
  --text: "Barlow Semi Condensed", "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0e1612; --sheet: #16211b; --ink: #e5ece6; --slate: #95a59b; --rule: #2f3e35; --hair: #233029; --lane: #1a2620;
    --brand: #173d2d; --brand-2: #22543e; --brand-ink: #eef3ec;
    --plate: #e5ece6; --plate-ink: #0e1612; --focus: #5fb1ff; --ok: #5cc584; --warn: #f2a941; --bad: #ff7b74;
    --white: #f4f4f4;
    color-scheme: dark;
  }
}
/* a competition can fix its page to one theme (design.js); .tm-dark / .tm-light do the same for one box (the host page's preview) */
:root[data-theme="dark"], .tm-dark {
  --page: #0e1612; --sheet: #16211b; --ink: #e5ece6; --slate: #95a59b; --rule: #2f3e35; --hair: #233029; --lane: #1a2620;
  --brand: #173d2d; --brand-2: #22543e; --brand-ink: #eef3ec;
  --plate: #e5ece6; --plate-ink: #0e1612; --focus: #5fb1ff; --ok: #5cc584; --warn: #f2a941; --bad: #ff7b74;
  --white: #f4f4f4;
  color-scheme: dark;
}
.tm-light, .tm-dark { --display: "Barlow Condensed", "Arial Narrow", sans-serif-condensed, sans-serif; }
.tm-light {
  --page: #edf1ea; --sheet: #ffffff; --ink: #15241d; --slate: #5a6a61; --rule: #c5cfc3; --hair: #dce3d9; --lane: #f5f8f3;
  --brand: #1d4a37; --brand-2: #275f47; --brand-ink: #f3f6ef;
  --plate: #15241d; --plate-ink: #f3f6ef; --focus: #1a7fd0; --ok: #1d7a43; --warn: #a65d00; --bad: #c0262d;
  --white: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 17px/1.45 var(--text); font-variant-numeric: tabular-nums; }
a { color: inherit; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.05; margin: 0 0 .4em; letter-spacing: .005em; }
h1 { font-size: 2.6rem; } h2 { font-size: 1.65rem; } h3 { font-size: 1.3rem; }
p { margin: 0 0 .8em; max-width: 72ch; }
.muted { color: var(--slate); }
.small { font-size: .88rem; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }

/* ---- top bar: range green, with the target's ring colours as a thin band underneath ---- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; min-height: 58px; padding: 8px 20px;
  background: var(--brand); color: var(--brand-ink); }
.top::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 4px;
  background: linear-gradient(90deg, var(--gold) 0 25%, var(--red) 25% 50%, var(--blue) 50% 75%, #1f1f1f 75% 100%); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 800 1.5rem/1 var(--display); letter-spacing: .01em; color: inherit; }
.brand svg { width: 34px; height: 34px; flex: none; }
.top .grow { flex: 1; min-width: 0; }
.top .sub { font: 600 1.05rem/1.2 var(--display); opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top nav { display: flex; gap: 4px; }
.top nav a { text-decoration: none; font: 700 1.1rem/1 var(--display); letter-spacing: .01em; color: inherit; opacity: .78; padding: 8px 12px; border-radius: 6px; transition: background .15s, opacity .15s; }
.top nav a:hover { opacity: 1; background: rgba(255, 255, 255, .08); }
.top nav a[aria-current="page"] { opacity: 1; background: rgba(255, 255, 255, .14); box-shadow: inset 0 -3px 0 var(--gold); }
.top .who-me { font-size: .88rem; opacity: .75; }
.lang { display: inline-flex; flex: none; border: 1px solid rgba(255, 255, 255, .3); border-radius: 6px; padding: 2px; gap: 2px; }
.lang button { border: 0; background: transparent; padding: 3px 9px; border-radius: 4px; font: 700 .9rem/1.2 var(--display); letter-spacing: .04em; cursor: pointer; color: inherit; opacity: .75; }
.lang button[aria-pressed="true"] { background: var(--brand-ink); color: var(--brand); opacity: 1; }
.top .btn.quiet { color: inherit; }
.top .btn.quiet:hover { background: rgba(255, 255, 255, .1); }

main { max-width: 1240px; margin: 0 auto; padding: 28px 20px 40px; overflow-x: clip; isolation: isolate; }

/* faint target rings behind a heading area (the one decorative device). They sit at the bottom of main's own layer
   (main isolates), so the cards and tables under the heading cover them; right: 0 keeps the whole circle inside
   main's overflow clip */
.rings { position: relative; }
.rings::before { content: ""; position: absolute; z-index: -1; right: 0; top: -90px; width: 360px; height: 360px; border-radius: 50%; pointer-events: none;
  background: repeating-radial-gradient(circle, transparent 0 22px, color-mix(in srgb, var(--brand) 9%, transparent) 22px 24px);
  -webkit-mask: radial-gradient(circle, #000 55%, transparent 72%); mask: radial-gradient(circle, #000 55%, transparent 72%); }

/* ---- the competition's own design (design.js): logo in the top bar, a background colour or picture with the
   content on a box over it (how solid the box is, is the organiser's choice), no rings, no ring band ---- */
.brand-logo { height: 38px; width: auto; max-width: 180px; object-fit: contain; flex: none; }
.tm-bg { background-color: var(--tm-bg-color, var(--page)); background-image: var(--tm-bg-img, none); background-repeat: no-repeat; background-position: center; background-size: cover; }
body.tm-bg { background-attachment: fixed; }
.tm-bg.tm-tile { background-repeat: repeat; background-size: auto; background-attachment: scroll; }
body.tm-bg main, .tm-bg .tm-box { background: color-mix(in srgb, var(--page) var(--tm-box, 92%), transparent); border-radius: 14px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
body.tm-bg main { width: calc(100% - 48px); margin: 26px auto; box-shadow: 0 10px 40px rgba(0, 0, 0, .22); }
.tm-norings .rings::before { content: none; }
.tm-noband .top::after { content: none; }
/* the band in the colours of the Estonian flag instead, sinimustvalge from left to right (design "Triibu värvid") */
.tm-est .top::after { background: linear-gradient(90deg, #0072ce 0 33.34%, #000 33.34% 66.67%, #fff 66.67% 100%); }

/* ---- surfaces ---- */
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 20px; }
.sheet + .sheet { margin-top: 16px; }
.section { padding: 22px 0; border-top: 1px solid var(--rule); }
.section:first-child { border-top: 0; padding-top: 0; }
.section > h2 { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 18px; }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 8px 16px;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); cursor: pointer; text-decoration: none;
  font-weight: 600; line-height: 1.1; white-space: nowrap; transition: border-color .15s, background .15s, transform .1s, filter .15s; }
.btn:hover { border-color: var(--slate); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.go { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: transparent; }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.quiet:hover { background: var(--lane); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.big { min-height: 56px; padding: 12px 24px; font: 700 1.3rem/1 var(--display); letter-spacing: .01em; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; font-weight: 600; color: var(--slate); }
.field input, .field select, .field textarea, .inp { color: var(--ink); background: var(--sheet); border: 1px solid var(--rule);
  border-radius: 4px; padding: 8px 10px; min-height: 42px; font-size: 1rem; font-weight: 400; width: 100%; transition: border-color .15s, box-shadow .15s; }
.field input:hover, .field select:hover, .inp:hover { border-color: var(--slate); }
.field input:focus, .field select:focus, .field textarea:focus, .inp:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.field input:disabled, .field select:disabled { background: var(--lane); color: var(--slate); }
textarea { min-height: 120px; resize: vertical; line-height: 1.4; }
.check { display: inline-flex; gap: 10px; align-items: center; cursor: pointer; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.note { padding: 10px 14px; border-radius: 6px; background: var(--lane); border: 1px solid var(--hair); font-size: .95rem; max-width: 72ch; }
.note.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 9%, var(--sheet)); }
.note.bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); background: color-mix(in srgb, var(--bad) 8%, var(--sheet)); }
.note.ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); background: color-mix(in srgb, var(--ok) 8%, var(--sheet)); }

/* status: a coloured dot + word; only "live" moves */
.status { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: .95rem; white-space: nowrap; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--slate); }
.status.live { color: var(--ok); } .status.live::before { background: var(--ok); animation: live 2s ease-out infinite; }
.status.done::before { background: var(--ink); }
@keyframes live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 80%, 100% { box-shadow: 0 0 0 7px transparent; } }

/* segmented choice */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border: 1px solid var(--rule); border-radius: 8px; background: var(--sheet); }
.seg button { border: 0; background: transparent; border-radius: 5px; padding: 6px 14px; cursor: pointer; font: 600 1.05rem/1.2 var(--display); letter-spacing: .01em; color: var(--slate); transition: background .18s var(--ease), color .18s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }

/* ---- the target plate ---- */
.plate { display: inline-flex; align-items: baseline; justify-content: center; min-width: 2.1em; padding: .12em .3em; border-radius: 5px; background: var(--plate); color: var(--plate-ink);
  font: 800 1rem/1 var(--display); letter-spacing: .01em; }
.plate small { font-size: .9em; font-weight: 800; margin-left: .04em; }

/* ---- course ticks (practice hollow, scored solid, confirmation round) ---- */
.ticks { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.ticks i { display: block; width: 10px; height: 16px; border-radius: 2px; background: var(--rule); transition: background .25s; }
.ticks i.s { background: transparent; border: 1.5px dashed var(--slate); }
.ticks i.done { background: var(--brand); }
.ticks i.now { background: var(--gold); box-shadow: 0 0 0 2px var(--ink); }
.ticks i.s.now { background: transparent; border: 2px solid var(--ink); box-shadow: none; }
.ticks .gap { width: 10px; }
.ticks i.c { width: 16px; height: 16px; border-radius: 50%; background: transparent; border: 1.5px solid var(--slate); }
.ticks i.c.done { background: var(--ok); border-color: var(--ok); }

/* ---- score colours ---- */
.r-gold { background: var(--gold); color: var(--gold-ink); }
.r-red { background: var(--red); color: #fff; }
.r-blue { background: var(--blue); color: #fff; }
.r-black { background: var(--black); color: #fff; }
.r-white { background: var(--white); color: #111; box-shadow: inset 0 0 0 1px #9aa3a0; }
.r-miss { background: var(--hair); color: var(--slate); }

/* ---- tables ---- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; }
table.t { border-collapse: collapse; width: 100%; }
table.t th, table.t td { padding: 9px 12px; border-bottom: 1px solid var(--hair); text-align: left; white-space: nowrap; }
table.t th { font-size: .85rem; font-weight: 600; color: var(--slate); background: var(--sheet); position: sticky; top: 0; border-bottom: 1px solid var(--rule); }
table.t td.n, table.t th.n { text-align: right; }
table.t tbody tr:last-child td { border-bottom: 0; }

/* ---- duel bracket (bracket.js): one column per stage, connector lines between a pair and the match they feed ---- */
.bracketwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 4px 2px 10px; }
.bracket { --bslot: 86px; --gap: 30px; display: flex; gap: var(--gap); min-width: max-content; align-items: stretch; }
.bcol { display: flex; flex-direction: column; width: 214px; flex: none; }
.bhead { font: 700 .95rem/1 var(--display); letter-spacing: .03em; text-transform: uppercase; color: var(--slate); padding: 0 2px 10px; }
.bslots { display: grid; flex: 1; }
.bslot { position: relative; display: flex; align-items: center; }
.bcol:not(.last) .bslot::after { content: ""; position: absolute; right: calc(var(--gap) / -2); width: calc(var(--gap) / 2); border-right: 2px solid var(--rule); }
.bcol:not(.last) .bslot.up::after { top: 50%; bottom: 0; border-top: 2px solid var(--rule); }
.bcol:not(.last) .bslot.dn::after { top: 0; bottom: 50%; border-bottom: 2px solid var(--rule); }
.bcol + .bcol .bslot::before { content: ""; position: absolute; left: calc(var(--gap) / -2); width: calc(var(--gap) / 2); top: 50%; border-top: 2px solid var(--rule); }
.bm { width: 100%; background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; position: relative; z-index: 1; }
.bm.click { cursor: pointer; }
.bm.click:hover { border-color: var(--slate); }
.bm.ready { border-color: var(--ink); }
.bm.live { box-shadow: 0 0 0 2px var(--gold); }
.bm.bye { opacity: .55; border-style: dashed; }
.bm-h { display: flex; justify-content: space-between; gap: 6px; font-size: .74rem; font-weight: 600; color: var(--slate); padding: 3px 8px 0; min-height: 1.3em; white-space: nowrap; }
.bm-h .so { color: var(--ink); }
.bm-r { display: grid; grid-template-columns: 1.6em minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 4px 8px; }
.bm-r + .bm-r { border-top: 1px solid var(--hair); }
.bm-r .sd { font: 600 .85rem/1 var(--display); color: var(--slate); text-align: right; }
.bm-r .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bm-r .nm i { color: var(--slate); font-style: normal; font-size: .9em; }
.bm-r .sc { font: 800 1.2rem/1 var(--display); min-width: 1.4em; text-align: right; }
.bm-r.win { background: color-mix(in srgb, var(--gold) 22%, var(--sheet)); }
.bm-r.win .nm { font-weight: 700; }
.bbronze { margin-top: 18px; }
table.branking td small { display: block; color: var(--slate); font-size: .82rem; }
table.branking .rk { width: 3.4em; text-align: center; }
img.medal { aspect-ratio: auto 4 / 5; object-fit: contain; } /* until the picture is there, then its own shape */
table.branking .rk .medal { height: 2.1em; width: auto; display: block; margin: -.2em auto; }
@media (max-width: 760px) { .bracket { --gap: 22px; } .bcol { width: 176px; } }

/* ---- toast + dialog ---- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; z-index: 100;
  background: var(--ink); color: var(--sheet); padding: 11px 18px; border-radius: 6px; font-weight: 600; max-width: calc(100vw - 32px); transition: .22s var(--ease); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); color: #fff; }
dialog { border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet); color: var(--ink); padding: 22px; width: min(480px, calc(100vw - 32px)); }
dialog[open] { animation: dlg .22s var(--ease); }
dialog::backdrop { background: rgba(10, 20, 15, .55); animation: fade .22s ease-out; }
@keyframes dlg { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---- motion helpers (each used where something changed) ---- */
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes from-right { from { opacity: 0; transform: translateX(28px); } }
@keyframes from-left { from { opacity: 0; transform: translateX(-28px); } }
@keyframes pop { 0% { transform: scale(.7); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes glow { 0% { background-color: color-mix(in srgb, var(--gold) 55%, transparent); } 100% { background-color: transparent; } }
.anim-rise { animation: rise .28s var(--ease) both; }
.anim-right { animation: from-right .26s var(--ease) both; }
.anim-left { animation: from-left .26s var(--ease) both; }
.anim-pop { animation: pop .24s var(--ease); }
.anim-glow { animation: glow 1.6s ease-out; }

@media (max-width: 760px) {
  body { font-size: 16px; }
  main { padding: 20px 14px 32px; }
  h1 { font-size: 2.1rem; }
  /* the page links get their own row under the brand on phones */
  .top { flex-wrap: wrap; padding: 8px 12px 0; gap: 8px 10px; row-gap: 4px; }
  .top nav { order: 10; flex-basis: 100%; justify-content: space-between; margin: 0 -4px; }
  .top nav a { flex: 1; text-align: center; padding: 10px 4px 12px; border-radius: 6px 6px 0 0; font-size: 1.05rem; }
  .brand { font-size: 1.35rem; } .brand svg { width: 30px; height: 30px; }
  .brand-logo { height: 32px; max-width: 130px; }
  .brand { min-width: 0; max-width: calc(100% - 120px); } .brand span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body.tm-bg main { width: calc(100% - 16px); margin: 8px auto 16px; border-radius: 10px; }
  .top .who-me { display: none; }
  .hide-sm { display: none !important; }
}
/* the shooting timer strip (light.js): the three lights, the seconds, the shift on the line and the end */
.tlight { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding: 7px 14px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--sheet); font: 700 1.1rem/1 var(--display); letter-spacing: .02em; }
.tl-dots { display: inline-flex; gap: 6px; padding: 5px 7px; border-radius: 999px; background: #1f1f1f; }
.tl-dots i { width: 16px; height: 16px; border-radius: 50%; background: #3b3b3b; }
.tl-dots i.r.on { background: #ff3b30; box-shadow: 0 0 9px #ff3b30; }
.tl-dots i.y.on { background: #ffcc00; box-shadow: 0 0 9px #ffcc00; }
.tl-dots i.g.on { background: #34c759; box-shadow: 0 0 9px #34c759; }
.tlight.flash .tl-dots i.r.on { animation: tl-blink 1s step-end infinite; }
@keyframes tl-blink { 50% { background: #3b3b3b; box-shadow: none; } }
.tl-secs { min-width: 2ch; font-size: 1.9rem; text-align: right; }
.tl-word { color: var(--slate); }
.tlight.flash .tl-word { color: var(--bad); }
.tl-shift { display: inline-flex; align-items: center; gap: 4px; }
.tl-shift small { margin-right: 3px; font-size: .8rem; color: var(--slate); }
.tl-shift em { padding: 3px 7px; border: 1px solid var(--rule); border-radius: 5px; font-style: normal; color: var(--slate); }
.tl-shift em.on { border-color: var(--ink); background: var(--ink); color: var(--sheet); }
.tl-end { margin-left: auto; }
.tlight.stale { opacity: .6; }
.tlwrap { margin: 0 0 14px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media print {
  .top, .noprint { display: none !important; }
  body, body.tm-bg { background: #fff; color: #000; }
  body.tm-bg main { box-shadow: none; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
