/**
 * App styling, matching the landing page: orange on navy, Oswald headings,
 * bracket buttons and corner accents on the furniture.
 *
 * Dark is the default. The light variant is the same design on a pale surface,
 * for shooting in bright sun; it swaps the accent to a darker orange because
 * #ff6a00 only reaches 2.9:1 on white, where #c74a00 reaches 4.8:1.
 *
 * Forms and tables stay deliberately plain: they get filled in at the range.
 */

/* ---------- Tokens: dark (default) ---------- */
:root {
  color-scheme: dark;

  --bg: #0b0e18;
  --surface: #141828;
  --surface-muted: #1a1f30;
  --surface-raised: #1f2538;
  --text: #e8ecf0;
  --text-muted: #98a1b5;
  --border: rgba(255, 255, 255, 0.09);
  --border-accent: rgba(255, 106, 0, 0.3);
  --accent: #ff6a00;
  --accent-contrast: #0b0e18;
  --accent-wash: rgba(255, 106, 0, 0.12);
  --danger: #ff5a52;
  --header-bg: rgba(11, 14, 24, 0.95);
  --header-text: #e8ecf0;
  --header-accent: #ff6a00;
  --glow: 0 0 18px rgba(255, 106, 0, 0.25);

  --radius: 0; /* square corners: the design is angular */
  --gap: 1rem;
  --max-width: 1100px;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Oswald', var(--font);
  --font-label: 'Barlow Condensed', var(--font);
}

/* ---------- Tokens: light ---------- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    color-scheme: light;

    --bg: #f2f3f6;
    --surface: #ffffff;
    --surface-muted: #e9ebf0;
    --surface-raised: #ffffff;
    --text: #12151f;
    --text-muted: #59616f;
    --border: rgba(11, 14, 24, 0.14);
    --border-accent: rgba(199, 74, 0, 0.35);
    --accent: #c74a00;
    --accent-contrast: #ffffff;
    --accent-wash: rgba(199, 74, 0, 0.09);
    --danger: #c0271e;
    --header-bg: rgba(11, 14, 24, 0.97);
    --header-text: #e8ecf0;
    --header-accent: #ff6a00;
    --glow: 0 0 18px rgba(199, 74, 0, 0.2);
  }
}

:root[data-theme='light'] {
  color-scheme: light;

  --bg: #f2f3f6;
  --surface: #ffffff;
  --surface-muted: #e9ebf0;
  --surface-raised: #ffffff;
  --text: #12151f;
  --text-muted: #59616f;
  --border: rgba(11, 14, 24, 0.14);
  --border-accent: rgba(199, 74, 0, 0.35);
  --accent: #c74a00;
  --accent-contrast: #ffffff;
  --accent-wash: rgba(199, 74, 0, 0.09);
  --danger: #c0271e;
  --header-bg: rgba(11, 14, 24, 0.97);
  --header-text: #e8ecf0;
  --header-accent: #ff6a00;
  --glow: 0 0 18px rgba(199, 74, 0, 0.2);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.1;
  margin: 0 0 0.5rem;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

h2 {
  font-size: 1.4rem;
}

h3 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
}

img {
  max-width: 100%;
  height: auto;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

/* ---------- Header & nav ---------- */
.site-header {
  background: var(--header-bg);
  color: var(--header-text);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(255, 106, 0, 0.3);
  backdrop-filter: blur(16px);
}

.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  min-height: 3.5rem;
}

.brand {
  font-family: var(--font-display);
  color: var(--header-accent);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: none;
  border: 1px solid rgba(255, 106, 0, 0.3);
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--header-accent);
  transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle[aria-expanded='true'] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded='true'] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded='true'] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.site-nav {
  display: none;
  width: 100%;
  padding-bottom: 0.75rem;
}

.site-nav.is-open {
  display: block;
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-label);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--header-text);
  text-decoration: none;
  border: 1px solid transparent;
}

.site-nav a::before {
  content: '[';
  color: var(--header-accent);
}

.site-nav a::after {
  content: ']';
  color: var(--header-accent);
}

.site-nav a:hover,
.site-nav a:focus-visible {
  border-color: var(--header-accent);
  box-shadow: var(--glow);
}

.site-nav a[aria-current='page'] {
  border-color: var(--header-accent);
  background: rgba(255, 106, 0, 0.14);
}

/* ---------- Main ---------- */
main {
  flex: 1;
  padding: 1.5rem 0 2.5rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  margin-bottom: 1.5rem;
  padding-left: 0.85rem;
  border-left: 3px solid var(--accent);
}

.page-header p {
  margin: 0;
  color: var(--text-muted);
}

.section {
  margin-bottom: 2rem;
}

/* ---------- Buttons ---------- */
.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-label);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--accent-contrast);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 0;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, color 0.2s;
}

.button::before {
  content: '[';
}

.button::after {
  content: ']';
}

.button:hover,
.button:focus-visible {
  box-shadow: var(--glow);
}

.button.secondary {
  color: var(--text);
  background: transparent;
  border-color: var(--border);
}

.button.secondary::before,
.button.secondary::after {
  color: var(--accent);
}

.button.secondary:hover,
.button.secondary:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Cards & grids ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  padding: 1.25rem;
}

/* A card that is also a link: the whole tile is the target, which on a phone
   is the difference between a tap that lands and one that doesn't. */
.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card-link:hover,
.card-link:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--glow);
}

/* New sign-ups: the admin's nudge on the dashboard and in the menu. */
.notice {
  margin-bottom: var(--gap);
  font-weight: 600;
  background: var(--accent-wash);
  border-color: var(--border-accent);
}

.nav-badge {
  display: inline-block;
  min-width: 1.4em;
  margin-left: 0.4em;
  padding: 0 0.35em;
  font-size: 0.75em;
  line-height: 1.4;
  text-align: center;
  color: var(--accent-contrast);
  background: var(--accent);
}

.tag {
  display: inline-block;
  margin-left: 0.4em;
  padding: 0 0.4em;
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-contrast);
  background: var(--accent);
}

.card-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Corner accents, as on the landing page's icon boxes. */
.card::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  background: var(--accent);
}

.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}

.stat-label {
  font-family: var(--font-label);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.placeholder {
  display: grid;
  place-items: center;
  min-height: 200px;
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 1px dashed var(--border-accent);
  text-align: center;
  padding: 1.25rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  font-family: var(--font-label);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

/* ---------- Messages ---------- */
.flash,
.errors {
  padding: 0.8rem 1rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}

.errors {
  border-left-color: var(--danger);
}

.errors p,
.errors ul {
  margin: 0;
}

.errors ul {
  padding-left: 1.25rem;
}

/* ---------- Table (stacks into cards on small screens) ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--border-accent);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead {
  display: none;
}

.table tr {
  display: block;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.table tr:last-child {
  border-bottom: 0;
}

.table tr.is-editing {
  background: var(--accent-wash);
  box-shadow: inset 3px 0 0 var(--accent);
}

.table td {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
}

.table td::before {
  content: attr(data-label);
  font-family: var(--font-label);
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* A short, narrow table stays a table even on a phone: three numbers a row
   read better side by side than stacked into a card each. */
.table.table-compact thead {
  display: table-header-group;
}

.table.table-compact tr {
  display: table-row;
  padding: 0;
}

.table.table-compact th,
.table.table-compact td {
  display: table-cell;
  padding: 0.45rem 0.75rem;
  /* Centred, so the columns stay together however wide the table runs. */
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.table.table-compact th {
  font-family: var(--font-label);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.table.table-compact td::before {
  content: none;
}

.cell-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.table td.row-actions {
  justify-content: flex-end;
  gap: 1rem;
}

.row-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.link-button {
  padding: 0;
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
}

/* ---------- Forms (kept plain on purpose) ---------- */
.form {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}

.field input,
.field select,
.field textarea,
.weather-search input {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 1rem; /* 16px stops iOS zooming on focus */
  color: var(--text);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 0;
}

/* Safari on iOS draws date and time fields natively and ignores width: 100%
   until its own styling is switched off, so they burst out of their column on a
   phone. Every iPhone browser uses Safari's engine, so Firefox and Chrome there
   do the same. Chrome's DevTools phone view does not: it keeps Chrome's field.
   All the date and time types are listed, so a new one cannot repeat this. */
.field input[type='date'],
.field input[type='time'],
.field input[type='datetime-local'],
.field input[type='month'],
.field input[type='week'] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-width: 0;
  max-width: 100%;
}

/* With the native styling off, iOS centres the value; line it up with the rest. */
.field input::-webkit-date-and-time-value {
  text-align: left;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.weather-search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.field.checkbox label {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  font-weight: 400;
}

.field.checkbox input {
  width: 1.15rem;
  min-height: 0;
  height: 1.15rem;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

.input-group input {
  flex: 1;
  min-width: 0;
}

.input-group select {
  width: auto;
  flex: 0 0 auto;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.form-heading {
  grid-column: 1 / -1;
  margin: 0;
}

.form-note {
  grid-column: 1 / -1;
  margin: -0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ---------- Session detail ---------- */
.detail-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 0;
}

.detail-grid dt {
  font-family: var(--font-label);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.detail-grid dd {
  margin: 0.15rem 0 0;
  font-weight: 600;
}

.session-notes {
  margin: 1.25rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-weight: 400;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-header h2 {
  margin: 0;
}

/* "Print DOPE card" and one button per card format. */
.card-print {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.card-print-label {
  /* Its own line, so the format buttons sit together beneath it. */
  flex-basis: 100%;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Dashboard: the last few outings, one line each, the whole line the link. */
.recent-sessions {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.recent-sessions li + li {
  border-top: 1px solid var(--border);
}

.recent-sessions a {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.75rem;
  align-items: baseline;
  padding: 0.65rem 0;
  min-height: 44px;
  color: inherit;
  text-decoration: none;
}

.recent-sessions a:hover strong,
.recent-sessions a:focus-visible strong {
  color: var(--accent);
}

.recent-sessions span {
  /* Under the date on a phone, so every line breaks the same way. */
  flex-basis: 100%;
  color: var(--text-muted);
}

@media (min-width: 600px) {
  .recent-sessions span {
    flex-basis: auto;
  }
}

/* Dashboard: weather where you shoot, now and over the next day. */
.weather-search {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.weather-search input {
  flex: 1;
  min-width: 0;
  /* Safari rounds search boxes; square, like every other field. */
  -webkit-appearance: none;
  appearance: none;
}

.weather-place {
  margin: 0;
}

.weather-alternatives {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.weather-now {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  margin: 0.75rem 0 0.5rem;
}

.weather-temp {
  font-family: var(--font-display);
  font-size: 2.4rem;
  line-height: 1;
}

.weather-description {
  color: var(--text-muted);
}

.weather-description::first-letter {
  text-transform: uppercase;
}

.weather-facts {
  display: grid;
  gap: 0.35rem;
  margin: 0 0 1rem;
}

.weather-facts div {
  display: flex;
  gap: 0.75rem;
}

.weather-facts dt {
  min-width: 5.5rem;
  font-family: var(--font-label);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.weather-facts dd {
  margin: 0;
}

.weather-use {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
}

.weather-next td {
  white-space: nowrap;
}

.weather-next caption {
  padding-bottom: 0.4rem;
  text-align: left;
  font-family: var(--font-label);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.wind-arrow {
  width: 1em;
  height: 1em;
  margin-right: 0.3em;
  vertical-align: -0.15em;
  fill: var(--accent);
}

.weather-credit {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Chart ---------- */
.chart-card {
  margin-top: 2.5rem;
  margin-bottom: 2rem;
}

.chart-subtitle {
  margin-bottom: 1rem;
}

.chart {
  position: relative;
  width: 100%;
  /* A tap on a point is for the tooltip, not for selecting the axis labels
     or opening the long-press copy menu. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.chart svg {
  display: block;
  touch-action: pan-y;
}

.chart-tooltip {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 140px;
  padding: 0.5rem 0.65rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border-accent);
  pointer-events: none;
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 1.25rem 0;
  font-family: var(--font-label);
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-top: 2px solid var(--border-accent);
}

/* ---------- Tablet ---------- */
/* ─── Target photos ─── */

/* One child for the cell, so on a phone the row is label-then-value like every
   other row. Three loose children (label, photos, status line) spread across
   the row put the photos in the middle. */
.photo-wrap {
  display: grid;
  justify-items: end;
  gap: 0.35rem;
}

.photo-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  align-items: flex-start;
}

.photo-item {
  display: grid;
  justify-items: center;
  gap: 0.1rem;
}

/* Phone first: thumbnail and button are the same 48px square — over the 44px
   a finger needs, and small enough to sit beside the other values. */
.photo-thumb img {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.photo-thumb:hover img,
.photo-thumb:focus-visible img {
  border-color: var(--accent);
}

.photo-remove {
  font-size: 0.7rem;
}

/* The file input is hidden; this is what you tap. */
.photo-add {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px dashed var(--border-accent, var(--accent));
  color: var(--accent);
  font-family: var(--font-label);
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1;
  cursor: pointer;
}

.photo-add-plus {
  font-size: 1.1rem;
}

.photo-add-label {
  margin-top: 0.15rem;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
}

.photo-add:hover,
.photo-add:focus-within {
  border-style: solid;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.photo-status:empty {
  display: none;
}

/* Desktop keeps the roomier look that already works there: a larger thumbnail
   and the button reading "+ Photo" on one line. */
@media (min-width: 900px) {
  .photo-wrap {
    justify-items: start;
  }

  .photo-strip {
    justify-content: flex-start;
  }

  .photo-thumb img {
    width: 56px;
    height: 56px;
  }

  .photo-remove {
    font-size: 0.75rem;
  }

  .photo-add {
    flex-direction: row;
    gap: 0.25rem;
    width: auto;
    min-width: 56px;
    height: 56px;
    padding: 0 0.6rem;
  }

  .photo-add-plus {
    font-size: 0.8rem;
  }

  .photo-add-label {
    margin-top: 0;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
  }
}

/* ─── Range Log filter ─── */

/* A <details>, so on a phone it stays folded away until wanted and the list
   is the first thing you see. It opens itself when a filter is in force. */
.filter {
  margin-bottom: var(--gap);
  padding: 0;
}

.filter summary {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-label);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.filter summary::before {
  content: '+';
  color: var(--accent);
  width: 1ch;
}

.filter[open] summary::before {
  content: '−';
}

.filter summary .muted {
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-body);
  font-weight: 400;
}

.filter-form {
  padding: 0 1.25rem 1.25rem;
}

/* minmax(0, 1fr), not 1fr: a plain 1fr column never shrinks below its widest
   content, and Safari on iOS gives a date field a wide minimum of its own. */
.filter-grid {
  display: grid;
  gap: 0 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filter-grid .field select,
.filter-grid .field input {
  width: 100%;
  min-width: 0;
}

.filter-temp {
  grid-column: 1 / -1;
}

/* Its own columns, not the shared flex group: the width: 100% above would
   otherwise hand the whole row to the unit dropdown and crush the numbers. */
.filter-temp .input-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  align-items: center;
}

.filter-temp .input-group select {
  width: auto;
}

.filter-to {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

@media (min-width: 900px) {
  .filter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .filter-temp {
    grid-column: span 2;
  }
}

/* ─── Settings ─── */

/* Label above value on a phone, label beside value once there is room. */
/* Name and theme: small forms under the account details, a little apart. */
.name-form {
  margin-top: 1.5rem;
}

.detail-list {
  margin: 1rem 0;
  display: grid;
  gap: 0.6rem;
}

.detail-list > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.detail-list > div:last-child {
  border-bottom: 0;
}

.detail-list dt {
  font-family: var(--font-label);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.download-list {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.download-list li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.download-list a {
  font-family: var(--font-label);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* The one place in the app that destroys something irreversibly, marked as
   such: the accent line down the side is the warning, not a shouty colour. */
.danger-zone {
  border-left: 3px solid var(--danger);
}

.danger-zone h2 {
  color: var(--danger);
}

/* Outlined, not filled: the one button in the app you do not want pressed by
   accident should not be the most eye-catching thing on the page. It fills in
   on hover, so there is no doubt once you are on it. */
.button.danger {
  color: var(--danger);
  background: transparent;
  border-color: var(--danger);
  margin-top: 0.75rem;
}

.button.danger:hover,
.button.danger:focus-visible {
  background: var(--danger);
  color: var(--surface);
  box-shadow: none;
}

.danger-zone .muted {
  margin-top: 1rem;
}

@media (min-width: 600px) {
  .grid-2,
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .form {
    grid-template-columns: repeat(2, 1fr);
  }

  .field.full,
  .form-actions {
    grid-column: 1 / -1;
  }
}

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  main {
    padding-top: 2.5rem;
  }

  .nav-toggle {
    display: none;
  }

  .site-nav,
  .site-nav.is-open {
    display: block;
    width: auto;
    padding: 0;
  }

  .site-nav ul {
    display: flex;
    gap: 0.35rem;
  }

  .site-nav a {
    min-height: 36px;
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
  }

  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }

  .table thead {
    display: table-header-group;
  }

  .table tr {
    display: table-row;
    padding: 0;
  }

  .table th,
  .table td {
    display: table-cell;
    padding: 0.8rem 1rem;
    text-align: left;
  }

  .table th {
    font-family: var(--font-label);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-accent);
  }

  .table td::before {
    content: none;
  }

  .table tbody tr {
    border-bottom: 1px solid var(--border);
  }

  .table tbody tr:hover {
    background: var(--surface-muted);
  }

  .cell-stack {
    align-items: flex-start;
    text-align: left;
  }

  .table td.row-actions {
    white-space: nowrap;
    text-align: right;
  }

  .table td.row-actions > a,
  .table td.row-actions > form {
    display: inline-block;
  }
}

/* ---------- Ballistics calculator ---------- */
.calculator-grid {
  display: grid;
  gap: var(--gap);
  margin: var(--gap) 0;
}

@media (min-width: 900px) {
  .calculator-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.calculator .input-group input {
  min-width: 0;
}

.disclaimer {
  font-weight: 600;
  color: var(--accent);
}

.calc-error {
  color: var(--danger);
  font-weight: 600;
}

.calc-chart svg {
  display: block;
  width: 100%;
}

/* On a phone the chart runs into the card's padding: every pixel of width is
   trajectory. The docked readout keeps in line with the table. */
.calc-chart {
  /* auto, not .chart's 100%, or the margins only shift it left. */
  width: auto;
  margin-inline: -1rem;
}

@media (min-width: 600px) {
  .calc-chart {
    margin-inline: 0;
  }
}

/* Twice the hold chart's size: read at arm's length on the range, often
   without glasses. A phone's chart is smaller than that, so there it reads out
   above the chart, clear of the thumb on the point; wider screens float it. */
.calc-chart .chart-tooltip {
  position: static;
  gap: 0.2rem;
  min-width: 0;
  margin: 0 1rem 0.5rem;
  padding: 1rem 1.3rem;
  font-size: 1.625rem;
  line-height: 1.25;
}

.calc-chart .chart-tooltip .nowrap {
  white-space: nowrap;
}

@media (min-width: 600px) {
  .calc-chart .chart-tooltip {
    position: absolute;
    max-width: calc(100% - 8px);
    margin: 0;
  }
}

/* Seven columns will not fit a phone, so the table scrolls sideways in its box. */
.calc-table-wrap {
  overflow-x: auto;
}

.calc-table {
  min-width: 34rem;
  font-variant-numeric: tabular-nums;
}

.calc-table th,
.calc-table td {
  white-space: nowrap;
}

/* Disclaimer, how-to and FAQ under the results, each folded away. */
.calc-help {
  margin-top: 1.5rem;
}

.calc-help-body {
  padding: 0 1.25rem 1.25rem;
  max-width: 70ch;
}

.calc-help-body h3 {
  margin: 1.25rem 0 0.35rem;
  font-size: 1rem;
}

.calc-help-body h3:first-child {
  margin-top: 0;
}

.calc-help-body ol {
  padding-left: 1.25rem;
}

.calc-help-body li + li {
  margin-top: 0.6rem;
}

/* ---------- Calculator on paper ---------- */
/* A4 portrait: what it was worked out for and the chart across the top
   (about 40%), the full table below. A long table carries on over the page,
   with its headings repeated. */
.calc-print-heading {
  display: none;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }

  body {
    background: #fff;
    color: #000;
  }

  .site-header,
  .site-footer,
  .page-header,
  noscript,
  #calculator,
  .calc-help,
  .results .card-header,
  .calc-error,
  .chart-tooltip {
    display: none !important;
  }

  main,
  .container {
    padding: 0;
    max-width: none;
  }

  .results.card {
    padding: 0;
    background: none;
    border: 0;
  }

  .results.card::after {
    content: none;
  }

  .calc-print-heading {
    display: block;
    margin-bottom: 2mm;
    font-size: 9pt;
    color: #000;
  }

  .calc-print-heading p {
    margin: 0 0 1mm;
  }

  .calc-print-title {
    font-family: var(--font-display);
    font-size: 13pt;
    text-transform: uppercase;
  }

  .calc-print-date {
    font-family: var(--font);
    font-size: 9pt;
    text-transform: none;
    color: #444;
  }

  .results .disclaimer {
    margin: 0 0 1mm;
    font-size: 9pt;
    color: #000;
  }

  .calc-chart svg {
    width: 100%;
    height: auto;
  }

  .calc-table-wrap {
    overflow: visible;
    background: none;
    border: 0;
  }

  .calc-table {
    min-width: 0;
    font-size: 8.5pt;
    color: #000;
  }

  /* .table.table-compact sets screen padding, so match its weight. */
  .table.calc-table th,
  .table.calc-table td {
    padding: 0.8mm 1.5mm;
    line-height: 1.25;
    color: #000;
    border-bottom: 0.2mm solid #bbb;
  }

  .calc-table thead {
    display: table-header-group;
  }

  .calc-table tr {
    break-inside: avoid;
  }

  .results .form-note {
    margin-top: 2mm;
    font-size: 8pt;
    color: #444;
  }
}

.licence-text {
  white-space: pre-wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}
