/* Toby Attendance Portal. Plain CSS, no framework; colours chosen for WCAG 2.1 AA contrast.
   Served as a file: the Content Security Policy allows no inline styles. */

:root {
  --text: #1a1a1a;
  --muted: #4a5360;
  --bg: #ffffff;
  --panel: #f5f7fa;
  --line: #d5dbe3;
  --primary: #0b5394;
  --primary-dark: #083c6c;
  --focus: #ffbf47;
  --ok-bg: #e3f4e8; --ok: #11592b;
  --warn-bg: #fff4d6; --warn: #6b4a00;
  --bad-bg: #fde7e7; --bad: #8a1c1c;
  --info-bg: #e8f0fb; --info: #0b3d6e;
  --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.6rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
code { background: var(--panel); padding: 0.1rem 0.3rem; border-radius: 4px; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--focus); color: #000; padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 0.5rem; top: 0.5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Environment banner (staging) */
.env-banner { margin: 0; padding: 0.35rem 1rem; background: #6b21a8; color: #fff; font-weight: 700; text-align: center; }

/* Header and navigation */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem;
  padding: 0.6rem 1rem; background: var(--primary); color: #fff; }
.top a, .top .link { color: #fff; }
.brand { font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.top ul, .subnav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: center; }
.top a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; font-weight: 600; }
.subnav { margin: 0 0 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--line); }
main { padding: 1rem; max-width: 80rem; margin: 0 auto; }
main:focus { outline: none; }
.narrow { max-width: 28rem; }
form.inline { display: inline; }

/* Buttons and forms */
button, .button {
  display: inline-block; font: inherit; font-size: 0.95rem; padding: 0.45rem 0.9rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; line-height: 1.3;
}
button:hover, .button:hover { background: var(--panel); color: var(--text); }
.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.primary:hover, .button.primary:hover { background: var(--primary-dark); color: #fff; }
button.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; }
.small { padding: 0.2rem 0.5rem; font-size: 0.85rem; }
.field { margin: 0 0 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="email"], select, textarea {
  font: inherit; padding: 0.45rem 0.6rem; border: 1px solid #8a96a3; border-radius: var(--radius); width: 100%; max-width: 28rem; background: #fff;
}
.field input[type="checkbox"] { width: 1.1rem; height: 1.1rem; vertical-align: -0.15rem; margin-right: 0.3rem; }
.help { color: var(--muted); font-size: 0.9rem; margin: 0.25rem 0 0; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--bad); }
.error, .errors { color: var(--bad); }
.errors { background: var(--bad-bg); padding: 0.5rem 1rem; border-radius: var(--radius); }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0 0 1rem; }
.toolbar select { width: auto; }
.toolbar label { font-weight: 600; }

/* Messages and banners */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.msg { padding: 0.6rem 1rem; border-radius: var(--radius); background: var(--info-bg); color: var(--info); margin-bottom: 0.5rem; }
.msg-success { background: var(--ok-bg); color: var(--ok); }
.msg-error { background: var(--bad-bg); color: var(--bad); }
.banner { padding: 0.6rem 1rem; border-radius: var(--radius); margin: 0 0 1rem; }
.banner p { margin: 0.25rem 0; }
.banner-info { background: var(--info-bg); color: var(--info); }
.banner-ok { background: var(--ok-bg); color: var(--ok); }
.banner-warn { background: var(--warn-bg); color: var(--warn); }
.banner-bad { background: var(--bad-bg); color: var(--bad); }
.banner a { color: inherit; font-weight: 600; }
.empty { color: var(--muted); font-style: italic; }
ul.compact { margin: 0.25rem 0; padding-left: 1.25rem; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 0 1rem; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
thead th { background: var(--panel); font-weight: 600; }
tbody th { font-weight: 600; }
tfoot th, tfoot td { background: var(--panel); }

/* Status labels (always text, never colour alone) */
.status { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-weight: 600; font-size: 0.85rem; }
.s-ok { background: var(--ok-bg); color: var(--ok); }
.s-warn { background: var(--warn-bg); color: var(--warn); }
.s-bad { background: var(--bad-bg); color: var(--bad); }
.s-done, .s-neutral, .s-unknown { background: #eef1f5; color: #33404d; }

/* Live board */
.updated { color: var(--muted); margin-top: 0; }
.shift { border: 1px solid var(--line); border-left: 6px solid var(--muted); border-radius: var(--radius); padding: 0.25rem 1rem 0.5rem; margin: 0 0 1rem; }
.shift h2 { margin-top: 0.75rem; }
.shift-now { border-left-color: var(--primary); }
.shift-next { border-left-color: #6b7c93; }
.shift-ended { border-left-color: #b8c2cc; }
.shift .when { color: var(--muted); font-weight: 400; font-size: 0.95rem; }
.coverage { font-weight: 600; margin: 0 0 0.5rem; }
.coverage.short { color: var(--bad); }

/* Roster grid */
table.roster th, table.roster td { text-align: center; white-space: nowrap; }
table.roster tbody th, table.roster tfoot th { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; }
table.roster tfoot th { background: var(--panel); }
table.roster .team { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; }
table.roster thead th.today { background: var(--info-bg); color: var(--info); }
table.roster thead th.holiday { background: var(--warn-bg); color: var(--warn); }
.hol { font-size: 0.75rem; font-weight: 400; white-space: normal; }
.cell { display: inline-block; min-width: 3.25rem; padding: 0.3rem 0.4rem; border-radius: var(--radius); font-weight: 700;
  text-decoration: none; border: 1px solid transparent; position: relative; color: var(--text); }
a.cell:hover { border-color: var(--primary); }
.empty-cell { color: var(--muted); font-weight: 400; border: 1px dashed var(--line); }
.cell.changed::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: #c2410c; }
.k-m { background: #dbeafe; color: #0b3d91; }
.k-e { background: #fde9b6; color: #5c3d00; }
.k-n { background: #312e81; color: #ffffff; }
.k-ld { background: #d1fae5; color: #064e3b; }
.k-off { background: #eef1f5; color: #33404d; }
.k-leave { background: #fce7f3; color: #831843; }
td.cov { font-variant-numeric: tabular-nums; }
td.cov.gap { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.cell-form { display: flex; gap: 0.25rem; align-items: center; justify-content: center; }
.cell-form select { width: auto; max-width: 12rem; padding: 0.2rem; font-size: 0.85rem; }
table.overview tr.week-start th, table.overview tr.week-start td { border-top: 2px solid #8a96a3; }
table.overview td { text-align: center; }

/* Account pages */
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; }
dl.facts dt { font-weight: 600; }
dl.facts dd { margin: 0; }
.qr svg { width: 12rem; height: 12rem; display: block; margin: 0.5rem 0; }
.secret { font-size: 1rem; letter-spacing: 0.05em; word-break: break-all; }

/* htmx: dim content while a request is running */
.htmx-request { opacity: 0.6; transition: opacity 0.2s; }

@media (max-width: 40rem) {
  main { padding: 0.75rem; }
  h1 { font-size: 1.35rem; }
  th, td { padding: 0.35rem 0.4rem; }
}
