/* St Peter's Swimming Club palette, dark mode.
   Brand colours (sampled from the club website and logo):
     teal #00637C  - primary buttons, selected states, rules
     red  #D1212F  - crest and wordmark red, used for stop and errors
   Dark surfaces are the brand near-black (#0D0A0A) lifted slightly for cards.
   Lighter tints of teal and red are used for text on dark backgrounds, so the
   brand colours stay readable.
*/
:root {
  --teal: #00637C;
  --teal-dark: #004A5C;
  --teal-light: #5FC3D8;
  --teal-tint: #0F3A44;
  --red: #D1212F;
  --red-light: #FF6B75;
  --ink: #0D0A0A;
  --bg: #0D0A0A;
  --card: #1A1F22;
  --line: #2E3A40;
  --text: #F2F6F8;
  --muted: #9AA8B0;
  --white: #FFFFFF;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  color-scheme: dark;
  -webkit-tap-highlight-color: transparent;
}

/* Site header with club logo, shown on every page */
.site-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 3px solid var(--teal);
  background: var(--card);
}
/* The logo has a white background, so it sits on a white panel */
.site-header img {
  height: 52px;
  width: auto;
  background: var(--white);
  border-radius: 8px;
  padding: 4px;
}
.site-header span { font-weight: 700; color: var(--teal-light); font-size: 1.1rem; }

h1 { font-size: 1.4rem; margin: 0 0 0.75rem; color: var(--text); }
h2 { font-size: 1.1rem; margin: 1rem 0 0.5rem; color: var(--teal-light); }

.screen { padding: 1rem; max-width: 720px; margin: 0 auto; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--red-light); min-height: 1.2em; margin: 0.5rem 0; }
.status { font-size: 0.85rem; padding: 0.25rem 0.6rem; border-radius: 999px; background: var(--line); color: var(--text); }
.status.online { background: var(--teal); color: var(--white); }
.status.offline { background: var(--red); color: var(--white); }

button, select, input {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--teal);
  background: #111619;
  color: var(--text);
  padding: 0.7rem 1rem;
  color-scheme: dark;
}

button { cursor: pointer; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary, button.go { background: var(--teal); border-color: var(--teal); color: var(--white); font-weight: 700; }
button.danger { background: var(--red); border-color: var(--red); color: var(--white); font-weight: 600; }
button.selected { background: var(--teal); border-color: var(--teal-light); color: var(--white); font-weight: 700; }
button.big { width: 100%; font-size: 1.3rem; padding: 1.1rem; }
button.small { padding: 0.35rem 0.6rem; font-size: 0.85rem; }

input[type="text"], input[type="search"], input[type="number"], input[type="password"], select { width: 100%; border-color: var(--line); }
/* Colour pickers (Recorder Console branding): show the colour itself, not a sliver of it */
input[type="color"] { width: 3.2rem; height: 2.4rem; padding: 3px; vertical-align: middle; cursor: pointer; }

.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1 1 auto; }
.stack > * + * { margin-top: 0.6rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem; margin-bottom: 0.9rem; }

.grid-teams { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.grid-teams button { padding: 0.9rem 0.4rem; }

.swimmer-list button { display: block; width: 100%; text-align: left; margin-bottom: 0.4rem; }

/* Timer race display */
.clock {
  font-family: "Consolas", "Courier New", monospace;
  font-size: min(20vw, 6rem);
  white-space: nowrap;
  text-align: center;
  font-weight: 700;
  padding: 0.5rem 0;
  letter-spacing: 0.04em;
  color: var(--teal-light);
  user-select: none;
}
.clock.long { font-size: min(15vw, 5rem); }
.clock.frozen { color: var(--red-light); }
.clock.editable { text-decoration: underline dotted var(--teal-light); cursor: text; }

/* STOP while racing: most of the screen, as the timer is watching the wall, not the phone. No scrolling, zooming,
   text selection or long-press menu from touches on it (see the touch guard in timer.html). */
button.stop-big {
  min-height: max(200px, 42vh);
  font-size: clamp(2.6rem, 14vw, 5rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  border-radius: 18px;
}
#stop { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

.toggle-on { background: var(--teal-dark); border-color: var(--teal-light); color: var(--white); font-weight: 700; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); }
th { color: var(--teal-light); font-weight: 700; font-size: 0.85rem; }
td.num { font-family: "Consolas", monospace; }
tr.fresh td { background: var(--teal-tint); transition: background 2s; }
/* Lane times: flagged (times too far apart, or a missing time), still timing, and chosen */
tr.lane-flag td { background: #4A161C; }
tr.lane-flag td:first-child { box-shadow: inset 4px 0 0 var(--red); }
tr.lane-wait td { background: #3D3210; }
tr.lane-wait td:first-child { box-shadow: inset 4px 0 0 #E0A82E; }
tr.lane-resolved td { background: var(--teal-tint); }

/* Upcoming heats on the Recorder Console */
.heat-block { border-left: 3px solid var(--line); padding-left: 0.6rem; margin-bottom: 0.6rem; }
.heat-block.current { border-left-color: var(--teal-light); }
.swimmer-chip { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px; background: #111619; border: 1px solid var(--line); }
.swimmer-chip.draggable { cursor: grab; border-color: var(--teal); }
.swimmer-chip.dns { text-decoration: line-through; color: var(--muted); }
tr.lane-open td { background: rgba(95, 195, 216, 0.05); }
tr.drop-here td { background: var(--teal-tint); outline: 2px dashed var(--teal-light); outline-offset: -2px; }

input.inline { width: auto; min-width: 5rem; }

/* QR cards on the home page: the whole code is a link */
a.qr-link { display: inline-block; }
a.qr-link img { transition: transform 0.15s; }
a.qr-link:hover img { transform: scale(1.03); }

/* Full-screen QR display page */
.qr-screen { text-align: center; padding: 2vh 3vw; min-height: calc(100vh - 80px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.5vh; }
.qr-screen h1 { font-size: clamp(2rem, 5vw, 4.5rem); margin: 0; color: var(--teal-light); }
.qr-screen .qr-sub { font-size: clamp(1rem, 2.2vw, 1.8rem); color: var(--muted); margin: 0; }
.qr-screen img { width: min(80vmin, 900px); height: auto; background: var(--white); padding: 2vmin; border-radius: 16px; }
.qr-screen .qr-url { font-family: "Consolas", monospace; font-size: clamp(0.9rem, 1.8vw, 1.4rem); color: var(--text); margin: 0; word-break: break-all; }
.qr-screen button { font-size: 1.1rem; }

/* Pop-up panel */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 9500; } /* above the help assistant's chat (9000-9001) */
.modal-card { background: var(--card); border: 1px solid var(--teal); border-radius: 14px; padding: 1.2rem; width: min(420px, 100%); }
