/* ChoreTracker — mobile-first, WCAG 2.1 AA contrast, no external assets. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #eef0f4;
  --border: #c9ced8;
  --text: #14181f;
  --text-muted: #4a5262;
  --accent: #1c4f9c;
  --accent-text: #ffffff;
  --danger: #a01523;
  --danger-bg: #fdeaec;
  --warn: #7a4a00;
  --warn-bg: #fdf1d8;
  --ok: #0f5c3a;
  --ok-bg: #e3f5eb;
  --focus: #0b5fff;
  --radius: 8px;
  --touch: 2.75rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10131a;
    --surface: #191d26;
    --surface-alt: #222733;
    --border: #3a4150;
    --text: #f2f4f8;
    --text-muted: #b3bccd;
    --accent: #8fb4ff;
    --accent-text: #0b1220;
    --danger: #ff9ba5;
    --danger-bg: #3a1319;
    --warn: #f4cd82;
    --warn-bg: #3a2c0d;
    --ok: #86e0b4;
    --ok-bg: #0f2e21;
    --focus: #8fb4ff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
a:hover { text-decoration: none; }

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

.skip-link {
  position: absolute;
  left: -9999px;
  background: var(--surface);
  padding: 0.75rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* ---------- layout ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand-name {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}

.household-switcher {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

nav.main-nav ul {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  margin: 0.5rem 0 0;
  padding: 0;
  overflow-x: auto;
  flex-wrap: wrap;
}

nav.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0 0.75rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}

nav.main-nav a[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

main {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}

h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1.03rem; margin: 1rem 0 0.35rem; }
h4 { font-size: 0.95rem; margin: 0.75rem 0 0.3rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }
.stack > * + * { margin-top: 0.75rem; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.spread { display: flex; gap: 0.75rem; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }

/* ---------- messages ---------- */

.messages { list-style: none; margin: 0 0 1rem; padding: 0; }
.messages li {
  border: 1px solid var(--border);
  border-left-width: 5px;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
}
.messages li.success { border-left-color: var(--ok); background: var(--ok-bg); color: var(--text); }
.messages li.error { border-left-color: var(--danger); background: var(--danger-bg); }
.messages li.warning { border-left-color: var(--warn); background: var(--warn-bg); }

/* ---------- forms & buttons ---------- */

form .field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.field .helptext { display: block; color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: 0.25rem 0; font-weight: 600; }
/* A live region ships empty so screen readers announce what lands in it later. */
.errorlist:empty { margin: 0; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

textarea { min-height: 5rem; }

input[type="checkbox"], input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  vertical-align: middle;
}

ul.checkbox-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
ul.checkbox-list li { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.35rem 0.6rem; }
ul.checkbox-list label { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 500; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--touch);
  padding: 0 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.btn-small { min-height: 2.25rem; padding: 0 0.6rem; font-size: 0.875rem; }
.inline-form { display: inline; }

/* ---------- instances ---------- */

.instance-list { list-style: none; margin: 0; padding: 0; }

.instance {
  border: 1px solid var(--border);
  border-left-width: 5px;
  border-left-color: var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.75rem;
  margin-bottom: 0.6rem;
}

.instance.is-late { border-left-color: var(--warn); background: var(--warn-bg); }
.instance.is-very-late { border-left-color: var(--danger); background: var(--danger-bg); }
.instance.is-done { opacity: 0.75; }

.instance .title { font-weight: 600; }
.instance .title a { color: var(--text); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
}
.badge.late { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.badge.very-late { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.badge.done { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.badge.paused { background: var(--surface-alt); }

.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }

/* ---------- calendar ---------- */

.calendar { display: grid; gap: 0.4rem; }
.calendar-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.4rem; }
.calendar-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.4rem; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }

.calendar-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem;
  min-height: 5.5rem;
  font-size: 0.8rem;
}
.calendar-day.out-of-focus { opacity: 0.55; }
.calendar-day.today { border-color: var(--accent); border-width: 2px; }
.calendar-day .date { font-weight: 700; display: block; margin-bottom: 0.2rem; }
.calendar-day ul { list-style: none; margin: 0; padding: 0; }
.calendar-day li { margin-bottom: 0.2rem; }
.calendar-day a { display: block; text-decoration: none; color: var(--text); border-radius: 4px; padding: 0.1rem 0.2rem; background: var(--surface-alt); }
.calendar-day li.is-late a { background: var(--warn-bg); color: var(--warn); }
.calendar-day li.is-very-late a { background: var(--danger-bg); color: var(--danger); }
.calendar-day li.is-done a { text-decoration: line-through; opacity: 0.7; }

@media (max-width: 45rem) {
  .calendar-head { display: none; }
  .calendar-week { grid-template-columns: 1fr; }
  .calendar-day { min-height: 0; }
  .calendar-day.out-of-focus:empty { display: none; }
}

/* ---------- reports ---------- */

.bar-track {
  background: var(--surface-alt);
  border-radius: 999px;
  height: 0.9rem;
  overflow: hidden;
  border: 1px solid var(--border);
  min-width: 6rem;
}
.bar-fill { background: var(--accent); height: 100%; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; display: block; }
.stat .label { color: var(--text-muted); font-size: 0.85rem; }

/* ---------- filters ---------- */

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.6rem; align-items: end; }
.filters .field { margin: 0; }

details.filter-panel summary {
  cursor: pointer;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  font-weight: 600;
}

/* Each multiple-choice filter collapses to one line, so five of them fit on a phone
   screen instead of two dozen checkboxes (US-01-008, US-05-002). */
details.filter-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
details.filter-group > summary {
  cursor: pointer;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.5rem;
  font-weight: 600;
  border-radius: var(--radius);
}
details.filter-group > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.filter-summary { font-weight: 400; color: var(--text-muted); }

.filter-options {
  border: 0;
  margin: 0;
  padding: 0 0.5rem 0.4rem;
  display: flex;
  flex-direction: column;
  /* A household with many rooms or members scrolls inside the group rather than
     pushing the task list off the screen. */
  max-height: 13rem;
  overflow-y: auto;
}
.filter-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: var(--touch);
  font-weight: 400;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}
.empty-state .big { font-size: 1.15rem; color: var(--text); font-weight: 600; }

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

/* ---------- room sections (US-01-004) ---------- */
.room-section { margin-top: 1.5rem; }
.room-section-head { align-items: baseline; border-bottom: 2px solid var(--border); padding-bottom: 0.3rem; }
.room-section-head h2, .room-section-head h4 { margin: 0; }
.room-section-head p { margin: 0; }
.badge.room { background: var(--surface-alt); }

/* Rooms nest inside the today board's assignee groups, so they read lighter
   than the task list's top-level room sections (US-05-001). */
.board-room { margin-top: 0.75rem; }
.board-room .room-section-head { border-bottom-width: 1px; }
