/* Hunt House Chores: see SPEC.md section 7.6 */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5a6370;
  --border: #d5d9e0;
  --input-border: #6b7380;
  --accent: #1f5fbf;
  --on-accent: #ffffff;
  --accent-bg: #e8f0fb;
  --overdue: #b3261e;
  --overdue-bg: #fdecea;
  --overdue-text: #7a1410;
  --on-overdue: #ffffff;
  --done: #1e7a3c;
  --done-bg: #e8f5ec;
  --done-text: #14532a;
  --late: #b45309;
  --late-bg: #fff4e0;
  --late-text: #7a3e00;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --surface: #1c1f24;
    --text: #e8eaed;
    --muted: #a3abb7;
    --border: #343a43;
    --input-border: #8a93a0;
    --accent: #6ea8ff;
    --on-accent: #0b1b33;
    --accent-bg: #1a2a44;
    --overdue: #ff8a80;
    --overdue-bg: #3a1513;
    --overdue-text: #ffd9d6;
    --on-overdue: #2b0b09;
    --done: #6fcf8f;
    --done-bg: #14301d;
    --done-text: #bfeacb;
    --late: #f0b45a;
    --late-bg: #3a2a10;
    --late-text: #ffe2b0;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }

h1 { font-size: 24px; font-weight: 700; line-height: 1.25; }
h2 { font-size: 18px; font-weight: 600; line-height: 1.3; }
h3 { font-size: 17px; font-weight: 600; line-height: 1.3; }

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

.small { font-size: 14px; }
.muted { color: var(--muted); }

.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;
}

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

/* Layout */

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

main.wrap { padding-top: 24px; padding-bottom: 48px; }
main > * + * { margin-top: 24px; }
main > .visually-hidden + * { margin-top: 0; }

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tabs .wrap { display: flex; gap: 24px; }

.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 3px solid transparent;
}

.tabs a[aria-current="page"] {
  color: var(--text);
  font-weight: 700;
  border-bottom-color: var(--accent);
}

.section > * + * { margin-top: 12px; }
.chore-list { display: grid; gap: 16px; }

/* Icons: SVG line icons used as colour masks, so they follow the text colour */

.icon {
  display: inline-block;
  flex-shrink: 0;
  width: 1.1em;
  height: 1.1em;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.icon-alert { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='7' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E"); }
.icon-circle { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3C/svg%3E"); }
.icon-clock { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E"); }
.icon-check { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E"); }
.icon-triangle { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E"); }
.icon-skip { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='5 4 15 12 5 20 5 4'/%3E%3Cline x1='19' y1='5' x2='19' y2='19'/%3E%3C/svg%3E"); }

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 0 20px;
  border: 2px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: var(--on-accent); }

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

.btn-quiet {
  background: transparent;
  color: var(--text);
  border-color: var(--input-border);
  font-weight: 500;
}

.btn-danger { background: var(--overdue); color: var(--on-overdue); }

.btn-overdue-outline {
  background: transparent;
  color: var(--overdue-text);
  border-color: var(--overdue);
}

.btn-small { width: auto; min-height: 44px; padding: 0 16px; font-size: 14px; }

.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

@media (min-width: 480px) {
  .btn { width: auto; }
}

/* Forms */

.field + .field, .field + .btn, form > .btn { margin-top: 12px; }

label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; }

input[type="text"],
input[type="password"],
input[type="date"] {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 2px solid var(--input-border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
}

input[aria-invalid="true"] { border-color: var(--overdue); }

.error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 12px;
  border-left: 4px solid var(--overdue);
  border-radius: 4px;
  background: var(--overdue-bg);
  color: var(--overdue-text);
  font-weight: 600;
}

.error .icon { margin-top: 0.2em; }
.login-card .error { margin: 0 0 16px; }

/* Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 12px;
  padding: 16px;
}

.card > * + * { margin-top: 12px; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.card-head .window { font-size: 14px; color: var(--muted); white-space: nowrap; }

.card.state-planned { border-left-color: var(--accent); }
.card.state-done { border-left-color: var(--done); background: var(--done-bg); }
.card.state-overdue { border-left-color: var(--overdue); background: var(--overdue-bg); }
.card.state-skipped { border-left-color: var(--input-border); }
.card.state-late { border-left-color: var(--late); background: var(--late-bg); }

/* Badges: always a symbol plus words, never colour alone */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--input-border);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.badge-planned { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.badge-done { background: var(--done-bg); border-color: var(--done); color: var(--done-text); }
.badge-late { background: transparent; border-color: var(--late); color: var(--late-text); }
.badge-overdue { background: var(--overdue-bg); border-color: var(--overdue); color: var(--overdue-text); }

.card.state-done .badge-done, .card.state-late .badge-done { background: transparent; }
.card.state-overdue .badge-overdue { background: transparent; }

/* Overdue banner */

.banner {
  background: var(--overdue-bg);
  border: 1px solid var(--overdue);
  border-radius: 12px;
  padding: 16px;
  color: var(--overdue-text);
}

.banner-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
}

.banner ul { margin-top: 12px; display: grid; gap: 12px; }

.banner li {
  padding-top: 12px;
  border-top: 1px solid var(--overdue);
}

.banner li:first-child { padding-top: 0; border-top: 0; }

.banner form > p + .field { margin-top: 8px; }
.banner li form + form { margin-top: 12px; }

/* Flash messages */

.flash {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--done);
  background: var(--done-bg);
  color: var(--done-text);
  font-weight: 600;
}

/* History */

.months { display: grid; gap: 12px; }

.month {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.month summary {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  min-height: 56px;
  padding: 10px 16px;
  cursor: pointer;
  list-style: none;
}

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

.month summary > span:first-of-type {
  grid-column: 2;
  grid-row: 1;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.month summary .count {
  grid-column: 2;
  grid-row: 2;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.month summary::before {
  content: "";
  grid-column: 1;
  grid-row: 1 / span 2;
  width: 10px;
  height: 10px;
  border-right: 3px solid var(--muted);
  border-bottom: 3px solid var(--muted);
  transform: rotate(-45deg);
}

.month[open]:not([data-closing]) summary::before { transform: rotate(45deg); }
.month summary::before { transition: transform 0.25s ease-out; }
.month { scroll-margin-top: 16px; }
.month summary { scroll-margin-top: 16px; }

.month .history, .month .empty { margin: 0 12px 12px; }
.month .empty { border-style: solid; border-color: var(--border); background: transparent; }

.history { display: grid; gap: 12px; }
.history li.card > * + * { margin-top: 4px; }
.history .by { font-weight: 600; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }

.empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--input-border);
  border-radius: 12px;
}

/* Login */

.login-wrap { max-width: 400px; margin: 0 auto; padding: 48px 16px; }
.login-wrap h1 { text-align: center; margin-bottom: 24px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.login-card .btn { width: 100%; margin-top: 24px; }

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