/* The Broons: one small stylesheet, tokens only, light and dark. */

:root {
  color-scheme: light dark;
  --bg: #f2f5f8;
  --surface: #ffffff;
  --surface-2: #e8eef4;
  --text: #101d2b;
  --muted: #526372;
  --line: #d3dfe9;
  --accent: #1f5fce;
  --accent-text: #ffffff;
  --good: #0f7048;
  --bad: #a32318;
  --warn: #7d5200;
  --shadow: 0 1px 2px rgba(16, 29, 43, 0.08), 0 8px 24px rgba(16, 29, 43, 0.06);
  --radius: 14px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --maxw: 1180px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tap: 44px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c141e;
  --surface: #121d2a;
  --surface-2: #1a2938;
  --text: #e9eff5;
  --muted: #a7b7c6;
  --line: #243749;
  --accent: #7cb0ff;
  --accent-text: #071320;
  --good: #6ad3a0;
  --bad: #ff9d92;
  --warn: #f0c879;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 10px 28px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c141e;
    --surface: #121d2a;
    --surface-2: #1a2938;
    --text: #e9eff5;
    --muted: #a7b7c6;
    --line: #243749;
    --accent: #7cb0ff;
    --accent-text: #071320;
    --good: #6ad3a0;
    --bad: #ff9d92;
    --warn: #f0c879;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 10px 28px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 var(--space-2);
}

h1 {
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 0.95rem;
}

p {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration: underline;
}

small,
.small {
  font-size: 0.84rem;
}

.mut {
  color: var(--muted);
}

.inline {
  display: inline;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  z-index: 20;
}

.skip-link:focus {
  left: var(--space-3);
  top: var(--space-3);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.page-title {
  color: var(--muted);
  font-size: 0.95rem;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.who {
  font-size: 0.9rem;
}

/* layout */
.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

.sidenav {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.navlink {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  min-height: var(--tap);
  line-height: 1.9;
}

.navlink:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.navlink.is-active {
  background: var(--surface-2);
  font-weight: 600;
}

.tabbar {
  display: none;
}

.content {
  min-width: 0;
}

/* cards and grid */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow);
  margin-bottom: var(--space-4);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.grid .card {
  margin-bottom: 0;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.card-head h2 {
  margin: 0;
}

.card-head a {
  color: var(--text);
  text-decoration: none;
}

.card-head a:hover {
  text-decoration: underline;
}

.stack {
  display: grid;
  gap: var(--space-3);
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-4);
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
  font-weight: 600;
}

.btn.primary:hover {
  filter: brightness(1.06);
}

.btn.bad {
  color: var(--bad);
  border-color: var(--bad);
}

.btn.small {
  min-height: 36px;
  padding: var(--space-1) var(--space-3);
  font-size: 0.85rem;
}

.btn.link {
  border-color: transparent;
  background: none;
  color: var(--accent);
  padding: 0;
  min-height: var(--tap);
}

/* states */
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8rem;
  white-space: nowrap;
}

.pill.state {
  border: 1px solid var(--line);
}

.pill.state.on {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.pill.ok {
  color: var(--good);
  border: 1px solid var(--good);
}

.pill.bad {
  color: var(--bad);
  border: 1px solid var(--bad);
}

.state {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

/* forms */
.field {
  display: grid;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.field label {
  font-size: 0.9rem;
  font-weight: 600;
}

.field .hint {
  color: var(--muted);
  font-size: 0.82rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: var(--space-2) var(--space-3);
  min-height: var(--tap);
  width: 100%;
  max-width: 100%;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  font-size: 0.92rem;
}

.check input {
  width: 20px;
  height: 20px;
}

.actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

/* tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: var(--surface-2);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

tr:last-child td {
  border-bottom: 0;
}

td .btn.small {
  min-height: 34px;
}

/* lists */
.states {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.states li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
}

.states li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.items {
  list-style: none;
  margin: 0 0 var(--space-3);
  padding: 0;
  display: grid;
  gap: var(--space-1);
}

.items li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.items li:last-child {
  border-bottom: 0;
}

.items .done {
  color: var(--muted);
  text-decoration: line-through;
}

.qty {
  color: var(--muted);
  font-size: 0.85rem;
}

/* weather */
.now-weather {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.now-weather .temp {
  font-size: 2.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.hours {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(56px, 1fr);
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
}

.hour {
  text-align: center;
  font-size: 0.85rem;
}

.hour .temp {
  font-weight: 600;
}

.days {
  display: grid;
  gap: var(--space-1);
}

.day {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: var(--space-1) 0;
  font-size: 0.9rem;
}

.day:last-child {
  border-bottom: 0;
}

.icon {
  width: 26px;
  height: 26px;
  flex: none;
  color: var(--accent);
}

/* map and charts (Leaflet structure lives in static/vendor/leaflet) */
.map {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.map .pin {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.chart {
  width: 100%;
  height: 140px;
  display: block;
}

.chart-title {
  font-size: 0.82rem;
  color: var(--muted);
  margin: var(--space-3) 0 var(--space-1);
}

/* tablets / kiosk */
body.kiosk {
  min-height: 100vh;
  background: var(--bg);
}

.kiosk {
  min-height: 100vh;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.kiosk-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.clock {
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.02em;
}

.kiosk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.kiosk-card {
  margin: 0;
  overflow: hidden;
}

.kiosk-card .btn {
  min-height: 48px;
}

.kiosk .states li,
.kiosk .items li {
  min-height: 48px;
  font-size: 1.02rem;
}

.kiosk .now-weather .temp {
  font-size: 3rem;
}

body.kiosk.night {
  --bg: #04070b;
  --surface: #0a1017;
  --surface-2: #111a24;
  --text: #b9c4ce;
  --muted: #78848f;
  --line: #1a2530;
  --accent: #6f93b8;
  --accent-text: #05090d;
  --shadow: none;
}

@media (min-width: 1500px) {
  .kiosk-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* phone */
@media (max-width: 860px) {
  .shell {
    display: block;
    padding: var(--space-4) var(--space-3) 96px;
  }

  .sidenav {
    display: none;
  }

  .tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    gap: 2px;
    overflow-x: auto;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: var(--space-1) var(--space-2) calc(var(--space-1) + env(safe-area-inset-bottom));
  }

  .tabbar a {
    flex: 0 0 auto;
    padding: var(--space-2) var(--space-3);
    border-radius: 999px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
    min-height: var(--tap);
    display: flex;
    align-items: center;
  }

  .tabbar a.is-active {
    background: var(--surface-2);
    font-weight: 600;
  }

  h1 {
    font-size: 1.3rem;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .kiosk {
    padding: var(--space-3);
  }

  .kiosk-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* small helpers used by pages */
.centred {
  max-width: 440px;
  margin: 8vh auto;
}

.narrow {
  max-width: 640px;
}

.state.bad,
.bad-text {
  color: var(--bad);
}

.state.ok {
  color: var(--good);
}

.secret-once {
  display: block;
  font-size: 1.15rem;
  padding: var(--space-3);
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  word-break: break-all;
  user-select: all;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.tabs .navlink {
  min-height: 38px;
  line-height: 1.6;
  padding: var(--space-1) var(--space-3);
  font-size: 0.9rem;
}

details summary {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

details summary::-webkit-details-marker {
  display: none;
}

details[open] summary {
  margin-bottom: var(--space-2);
}

/* calendar colours */
.swatch-blue {
  border-left: 4px solid var(--accent);
}

.swatch-green {
  border-left: 4px solid var(--good);
}

.swatch-amber {
  border-left: 4px solid var(--warn);
}

.swatch-red {
  border-left: 4px solid var(--bad);
}

.swatch-purple {
  border-left: 4px solid var(--accent);
  border-left-style: double;
}

.swatch-teal {
  border-left: 4px double var(--good);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
