/* Shared layout and components. Colours and fonts come from brand.css. */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-brand);
  font-size: 18px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 700; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.6rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--color-info); }

.hidden { display: none !important; }
.muted { color: var(--color-text-muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* ---------- Header ---------- */

.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.app-header .logo { height: var(--logo-height); width: auto; display: block; }
.app-header .title {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 1rem;
  padding-left: 16px;
  border-left: 2px solid var(--color-border);
}
.app-header .spacer { flex: 1; }
.app-header .station-label { font-size: 0.95rem; color: var(--color-text-muted); }
.app-header .station-label strong { color: var(--color-text); }

main {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
main.wide { max-width: 1280px; }

/* ---------- Cards ---------- */

.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 36px);
  margin-bottom: 20px;
}
.card.tight { padding: 18px 20px; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

/* Able rounded-square motif */
.squares { display: inline-grid; grid-template-columns: repeat(2, 14px); grid-template-rows: repeat(2, 14px); gap: 4px; vertical-align: middle; }
.squares span { background: var(--color-accent); border-radius: 4px; }
.squares span:nth-child(1) { grid-column: 1; grid-row: 1; }
.squares span:nth-child(2) { grid-column: 1; grid-row: 2; }
.squares span:nth-child(3) { grid-column: 2; grid-row: 2; }

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 14px 22px;
  min-height: 56px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, transform 0.05s;
  touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--able-blue); outline-offset: 3px; }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--able-grey); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--color-danger-hover); }
.btn-ghost { background: transparent; color: var(--color-info); border-color: transparent; text-decoration: underline; min-height: 44px; padding: 8px 12px; }
.btn-small { min-height: 40px; padding: 6px 14px; font-size: 0.95rem; border-radius: var(--radius-sm); }
.btn-xl { min-height: 76px; font-size: 1.45rem; padding: 18px 32px; width: 100%; }
.btn-block { width: 100%; }

/* Grid of large choice buttons (stations, teams, members) */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.choice {
  appearance: none;
  font: inherit;
  text-align: left;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius);
  padding: 20px 22px;
  min-height: 96px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  touch-action: manipulation;
  transition: border-color 0.15s, background-color 0.15s;
}
.choice:hover:not(:disabled) { border-color: var(--color-accent); background: var(--color-accent-soft); }
.choice:focus-visible { outline: 3px solid var(--able-blue); outline-offset: 3px; }
.choice .choice-title { font-size: 1.35rem; font-weight: 700; }
.choice .choice-sub { font-size: 0.95rem; color: var(--color-text-muted); }
.choice:disabled { cursor: not-allowed; background: #f6f8f9; border-style: dashed; }
.choice:disabled .choice-title { color: var(--color-text-muted); }
.choice.selected { border-color: var(--color-primary); background: var(--color-accent-soft); }

/* ---------- Forms ---------- */

label { font-weight: 700; display: block; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field-hint { font-size: 0.9rem; color: var(--color-text-muted); margin-top: 6px; }
.field-error { color: var(--color-danger); font-weight: 700; margin-top: 8px; min-height: 1.4em; }

input[type="text"], input[type="password"], select {
  font: inherit;
  color: var(--color-text);
  background: #fff;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-height: 48px;
  width: 100%;
}
input:focus, select:focus { outline: 3px solid var(--able-light-blue); border-color: var(--color-info); }
input:disabled { background: #eef2f3; color: var(--color-text-muted); }
input.invalid { border-color: var(--color-danger); }

.answer-input {
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  font-weight: 700;
  text-align: center;
  padding: 16px;
  min-height: 80px;
  border-width: 3px;
  border-radius: var(--radius);
  letter-spacing: 0.04em;
}
.answer-input.code { letter-spacing: 0.35em; font-variant-numeric: tabular-nums; }

/* ---------- Status banners ---------- */

.banner {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 18px;
  font-weight: 600;
  border-left: 8px solid;
}
.banner-info { background: var(--color-info-soft); border-color: var(--color-info); }
.banner-warning { background: var(--color-warning-soft); border-color: var(--color-warning); color: #5c3c00; }
.banner-danger { background: var(--color-danger-soft); border-color: var(--color-danger); color: #6b1712; }
.banner-success { background: var(--color-accent-soft); border-color: var(--color-accent); }

/* ---------- Pills ---------- */

.pill {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill-not_started { background: #eef2f3; color: var(--color-text-muted); border-color: var(--color-border); }
.pill-in_progress { background: var(--color-info-soft); color: #1f4a6e; border-color: var(--able-light-blue); }
.pill-locked_out { background: var(--color-danger-soft); color: #7a1a14; border-color: #f2b8b5; }
.pill-completed { background: var(--color-accent-soft); color: #234a31; border-color: var(--able-light-green); }
.pill-warning { background: var(--color-warning-soft); color: #5c3c00; border-color: #f0d49a; }

/* ---------- Dialog ---------- */

dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: min(520px, calc(100vw - 32px));
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  color: var(--color-text);
  font-family: var(--font-brand);
}
dialog::backdrop { background: rgba(53, 69, 74, 0.55); }
.dialog-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  z-index: 50;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow);
}
.toast.error { background: var(--color-danger); }

.footer-note { text-align: center; font-size: 0.85rem; color: var(--color-text-muted); padding: 12px; }
