/*
  Curlew console. Design notes (frontend-design skill, .claude/skills/frontend-design):
  - Subject: a field-research console for sending measurement plans to phones.
  - Palette from tidal flats, where curlews feed: cool mudflat ground, slate ink,
    deep tide teal for actions, and the ochre of a curlew's bill used in one place only:
    the 24-hour cadence strip on each plan entry, which is the page's one bold element.
  - Type: local faces only (the CSP allows no font hosts). Bahnschrift / DIN for headings
    and numbers gives an instrument-panel feel; body stays on the system sans.
*/
:root {
  --mud: #e7ecea;
  --paper: #fbfcfb;
  --ink: #16232a;
  --reed: #53646a;
  --line: #c9d3d0;
  --tide: #1b5e66;
  --tide-soft: #dbe9ea;
  --on-tide: #ffffff;
  --bill: #b9781a;
  --bill-text: #8a5a12;   /* the bill ochre, darkened to 4.5:1 for text */
  --field-line: #6b7b80;  /* input edges: 3:1 against paper and mudflat */
  --ok-bg: #e1f0e6;
  --ok-text: #1e5631;
  --err-bg: #f8e3df;
  --err-text: #862015;
  --danger: #a8281e;
  --display: "Bahnschrift", "DIN Alternate", "DIN 2014", "Barlow", "Roboto Condensed", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --mud: #11191c;
    --paper: #172126;
    --ink: #e2eae8;
    --reed: #98a8ac;
    --line: #2c3a3f;
    --tide: #74bcc3;
    --tide-soft: #1d3338;
    --on-tide: #0b1d20;
    --bill: #e2a64a;
    --bill-text: #e2a64a;
    --field-line: #6b7f84;
    --ok-bg: #1b3524;
    --ok-text: #b5e0c0;
    --err-bg: #3b1d19;
    --err-text: #f3b6ad;
    --danger: #f08a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--mud);
  color: var(--ink);
  font: 16px/1.55 var(--body);
}
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 16px; }
h1, h2, legend, .brand { font-family: var(--display); font-weight: 600; letter-spacing: -0.005em; }
h1 { font-size: 2rem; line-height: 1.15; margin: 0 0 0.5rem; }
h2 { font-size: 1.25rem; line-height: 1.25; margin: 0 0 0.75rem; }
a { color: var(--tide); text-underline-offset: 0.15em; }
code { font-family: var(--mono); font-size: 0.88em; }
.muted { color: var(--reed); }
:focus-visible { outline: 3px solid var(--tide); outline-offset: 2px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 16px; top: -48px; z-index: 10; padding: 8px 14px; background: var(--tide); color: var(--on-tide); border-radius: 0 0 3px 3px; }
.skip-link:focus { top: 0; }
#main:focus { outline: none; }  /* skip-link target; the content itself is what matters */

/* Header */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px;
  padding: 12px 16px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand { font-size: 1.25rem; color: var(--ink); text-decoration: none; }
.brand span { color: var(--reed); font-weight: 400; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.top nav a { color: var(--ink); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.top nav a:hover { border-bottom-color: var(--line); }
.top nav a[aria-current="page"] { color: var(--tide); border-bottom-color: var(--tide); font-weight: 600; }
.logout { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 0.9rem; }

/* Page heading: title and lede on the left, a small side route on the right. */
.page-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 32px;
  align-items: end; margin-bottom: 20px;
}
.page-head h1, .page-head .lede { grid-column: 1; }
.page-head .lede { margin-bottom: 0; }
.page-head .aside { grid-column: 2; grid-row: 1 / span 2; margin: 0; font-size: 0.9rem; color: var(--reed); text-align: right; }
.lede { max-width: 68ch; color: var(--reed); margin: 0 0 20px; }
@media (max-width: 720px) {
  .page-head { grid-template-columns: 1fr; }
  .page-head .aside { grid-column: 1; grid-row: auto; text-align: left; margin-top: 10px; }
}

/* Surfaces. Forms sit on paper; the preview is marked by a tide rule, not a second box style. */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 4px;
  padding: 20px; margin: 0 0 20px;
}
.narrow { max-width: 460px; margin: 40px auto; }
.preview { border-left: 5px solid var(--tide); }
.empty { padding: 20px 0; color: var(--reed); }

/* Form steps: a real sequence, so the legends keep their numbers. */
fieldset { border: 0; border-top: 1px solid var(--line); margin: 0 0 16px; padding: 16px 0 0; min-width: 0; }
fieldset:first-of-type { border-top: 0; padding-top: 0; }
legend { font-size: 1.15rem; padding: 0; margin-bottom: 4px; }
label { display: block; margin: 12px 0 4px; font-weight: 500; }
/* Hanging indent: the box starts the line and wrapped text lines up under the text, not the box. */
label.inline { display: block; padding-left: 1.7em; text-indent: -1.7em; font-weight: 400; margin: 6px 0; }
label.inline input { text-indent: 0; }
label.inline > input[type=checkbox], label.inline > input[type=radio] { width: 1.1em; margin: 0 0.6em 0 0; vertical-align: -0.1em; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--mud);
  border: 1px solid var(--field-line); border-radius: 3px; padding: 7px 9px;
  width: 100%; max-width: 480px;
}
input:focus, select:focus, textarea:focus { border-color: var(--tide); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--tide); }
input.short { max-width: 120px; font-variant-numeric: tabular-nums; }
.help { margin: 4px 0 0; color: var(--reed); max-width: 72ch; }
.device-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 3px; padding: 4px 12px; margin-top: 8px; background: var(--mud); }

/* Plan entries: a ticked entry lifts onto a tide-tinted ground. */
.plan-entry { border-top: 1px solid var(--line); padding: 14px 0 14px 14px; border-left: 4px solid transparent; }
.plan-entry:first-child { border-top: 0; }
.plan-entry:has([data-plan-include]:checked) { border-left-color: var(--tide); background: linear-gradient(to right, var(--tide-soft), transparent 70%); }
.plan-entry > label.inline { font-family: var(--display); font-size: 1.05rem; font-weight: 600; margin: 0; }
.plan-entry .settings { padding-left: 26px; }
.plan-entry .help { padding-left: 26px; }

/* The cadence strip: one day, 00:00 to 24:00, with an ochre tick for each run. */
.cadence { margin: 12px 0 0; max-width: 560px; }
.cadence-strip {
  --step: 4.1667%;
  height: 22px; border: 1px solid var(--line); border-radius: 2px;
  background:
    repeating-linear-gradient(to right, var(--bill) 0 2px, transparent 2px var(--step)),
    repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px 25%),
    var(--paper);
}
.cadence-hours { display: flex; justify-content: space-between; font: 0.75rem/1.6 var(--display); color: var(--reed); font-variant-numeric: tabular-nums; }
.cadence-note { margin: 2px 0 0; font-family: var(--display); font-variant-numeric: tabular-nums; }
.cadence-note strong { color: var(--bill-text); font-weight: 600; }

/* Buttons */
button, .button {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--tide); color: var(--on-tide); border: 1px solid var(--tide); border-radius: 3px;
  padding: 9px 18px; margin-top: 14px;
}
button:hover, .button:hover { filter: brightness(1.08); }
.button.secondary, button.secondary { background: transparent; color: var(--tide); }
.button.download { margin: 0; padding: 4px 12px; font-size: 0.9rem; }
button.danger { background: var(--danger); border-color: var(--danger); color: var(--paper); }
button.link {
  background: none; border: 0; color: var(--tide); padding: 0; margin: 14px 0 0 12px;
  font-weight: 400; text-decoration: underline; text-underline-offset: 0.15em;
}
.logout button.link { margin: 0; }

.flash { padding: 10px 14px; border-radius: 3px; margin: 0 0 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--err-bg); color: var(--err-text); }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--display); font-weight: 600; white-space: nowrap; background: var(--mud); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--tide-soft); }
table.results td { font-size: 0.88rem; white-space: nowrap; }
.slots { max-height: 320px; overflow-y: auto; margin-bottom: 8px; }
.status { font-weight: 600; }
.status.pending { color: var(--tide); }
.status.expired, .status.failed { color: var(--danger); }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 14px; margin-bottom: 20px; }
.filters label { margin: 0 0 2px; font-size: 0.9rem; }
.filters input, .filters select { width: auto; }
.filters button, .filters .button { margin-top: 0; }

details summary { cursor: pointer; color: var(--tide); margin: 8px 0; }
pre { overflow-x: auto; background: var(--mud); padding: 10px; border-radius: 3px; font: 0.85rem/1.5 var(--mono); }
[hidden] { display: none !important; }

/* The curlew photo (USFWS, public domain): home page hero and beside the login form. */
.hero { margin: -24px -16px 28px; }
.hero img {
  display: block; width: 100%; height: clamp(220px, 42vw, 460px);
  object-fit: cover; object-position: 38% 45%;
}
.hero figcaption { max-width: 46rem; margin: 6px auto 0; padding: 0 16px; font-size: 0.8rem; color: var(--reed); }
.palette { list-style: none; padding: 0; }
.palette li { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.swatch { width: 28px; height: 18px; border-radius: 2px; border: 1px solid var(--line); flex: none; }
/* Fixed to the light palette so the key matches the photo in either theme. */
.swatch.mud { background: #e7ecea; }
.swatch.ink { background: #16232a; }
.swatch.tide { background: #1b5e66; }
.swatch.bill { background: #b9781a; }

.login-split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 32px; align-items: center; margin-top: 24px; }
.login-split .narrow { margin: 0; width: 100%; }
.login-photo { width: 100%; height: 100%; max-height: 520px; object-fit: cover; object-position: 38% 45%; border-radius: 4px; }
@media (max-width: 760px) {
  .login-split { grid-template-columns: 1fr; gap: 16px; margin-top: 0; }
  .login-photo { max-height: 180px; }
}

/* Public pages: about, privacy, terms. */
.prose { max-width: 46rem; margin-left: auto; margin-right: auto; line-height: 1.6; }
.prose h2 { font-size: 1.15rem; margin-top: 1.5rem; }
.prose ul { padding-left: 1.25rem; }
.site-footer { text-align: center; padding: 1.5rem 16px 2rem; font-size: 0.9rem; }

/* Groups and tokens */
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; }
.inline-form select { width: auto; }
.inline-form button { margin-top: 0; }
.inline-form button.link { margin: 0; }
.saved-plan label { flex-basis: 100%; margin: 0; }
.saved-plan p { flex-basis: 100%; margin: 4px 0 0; }
.join-code code { font: 600 1.6rem/1.2 var(--display); letter-spacing: 0.08em; }

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

/* My plans */
.filters a { color: var(--ink); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.filters a[aria-current="page"] { color: var(--tide); border-bottom-color: var(--tide); }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.plan-card { margin: 0; display: flex; flex-direction: column; border-left: 5px solid var(--line); }
.plan-card.active { border-left-color: var(--tide); }
.plan-card-head h2 { margin: 0; font-size: 1.1rem; }
.plan-card-head p { margin: 2px 0 10px; font-size: 0.9rem; }
.plan-lines { margin: 0 0 6px; padding-left: 1.2em; }
.plan-lines li { margin: 2px 0; }
.plan-pending { margin: 10px 0 0; padding: 10px 12px; border-radius: 3px; background: var(--tide-soft); }
.plan-pending p { margin: 0 0 4px; }
.plan-actions { margin-top: auto; padding-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.plan-actions .button, .plan-actions button, .plan-pending button { margin: 0; }
