/* Base styles every page inherits. Accessibility rules from CLAUDE.md:
   18px base text, 48px tap targets, visible focus, mobile-first. */

:root {
  --text: #1a1a1a;
  --muted: #444444;
  --background: #ffffff;
  --surface: #f3f1ec;
  --border: #595959;
  --accent: #1f5c3a;
  --accent-text: #ffffff;
  --ok: #1f5c3a;
  --problem: #a12a1c;
  --caution: #8a5a00;
  --focus: #0b57d0;
}

/* Colour themes, chosen per person on the Settings page. */
html[data-theme="dark"] {
  --text: #f1f1f1;
  --muted: #c9c9c9;
  --background: #171a18;
  --surface: #262b28;
  --border: #a8a8a8;
  --accent: #8fd6ac;
  --accent-text: #10201a;
  --ok: #8fd6ac;
  --problem: #ff9e8f;
  --caution: #f0c060;
  --focus: #9cc2ff;
}

html[data-theme="contrast"] {
  --text: #000000;
  --muted: #000000;
  --background: #ffffff;
  --surface: #ffffff;
  --border: #000000;
  --accent: #000000;
  --accent-text: #ffffff;
  --ok: #000000;
  --problem: #8b0000;
  --caution: #000000;
  --focus: #0000ee;
}

html[data-theme="contrast"] .person-card,
html[data-theme="contrast"] .status-list li,
html[data-theme="contrast"] .messages,
html[data-theme="contrast"] .warning,
html[data-theme="contrast"] .find-existing {
  border: 2px solid #000000;
}

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

html {
  /* 112.5% of the browser default is 18px, and still respects a larger
     text size chosen in the browser or phone settings. */
  font-size: 112.5%;
}

/* Text sizes, chosen per person on the Settings page: 18, 21, 24 and 28px. */
html[data-text-size="2"] {
  font-size: 131.25%;
}

html[data-text-size="3"] {
  font-size: 150%;
}

html[data-text-size="4"] {
  font-size: 175%;
}

html[data-reduced-motion] *,
html[data-reduced-motion] *::before,
html[data-reduced-motion] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--background);
}

.skip-link {
  position: absolute;
  left: -999rem;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--background);
}

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

.site-header {
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--accent-text);
}

.site-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

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

h1 {
  font-size: 1.75rem;
  line-height: 1.25;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 48px;
  padding: 0.5rem 1.5rem;
  border-radius: 0.5rem;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
}

.status-list {
  list-style: none;
  padding: 0;
}

.status-list li {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  padding: 1rem;
  border-radius: 0.5rem;
  background: var(--surface);
  border-left: 0.5rem solid var(--problem);
}

.status-list li.ok {
  border-left-color: var(--ok);
}

.status-mark {
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--problem);
}

.ok .status-mark {
  color: var(--ok);
}

/* --- Navigation ---------------------------------------------------------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.5rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a,
.site-nav button {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 0.5rem;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.site-header :focus-visible {
  outline-color: var(--accent-text);
}

/* --- Text ---------------------------------------------------------------- */

h2 {
  margin-top: 2rem;
  font-size: 1.35rem;
  line-height: 1.3;
}

h3 {
  font-size: 1.1rem;
}

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

.lead {
  margin-top: -0.5rem;
  font-size: 1.15rem;
}

.problem-text {
  color: var(--problem);
  font-weight: 700;
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
}

.facts dt {
  font-weight: 700;
}

.facts dd {
  margin: 0;
}

/* --- Buttons ------------------------------------------------------------- */

.button {
  border: 2px solid var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button.secondary {
  background: var(--background);
  color: var(--accent);
}

.button.danger {
  border-color: var(--problem);
  background: var(--problem);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin: 1.5rem 0;
}

.button-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

/* --- Forms --------------------------------------------------------------- */

/* Every form gets breathing room between its boxes and before its buttons,
   including pages that come from django-allauth. */
main form > div,
main form > p {
  margin-bottom: 1.25rem;
}

main button,
main .button {
  margin-top: 0.75rem;
}

/* These containers space their own contents. */
.actions > *,
.button-list .button,
.card-list .button,
.pager .button {
  margin-top: 0;
}

label {
  display: block;
  font-weight: 700;
}

input[type="text"],
input[type="search"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  background: var(--background);
  color: var(--text);
  font: inherit;
}

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

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

.understood {
  min-height: 1.6em;
  margin: 0.25rem 0 0;
}

.errorlist {
  margin: 0.25rem 0;
  padding: 0;
  list-style: none;
  color: var(--problem);
  font-weight: 700;
}

.messages,
.warning {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border-left: 0.5rem solid var(--ok);
  background: var(--surface);
}

.warning {
  border-left-color: var(--caution);
}

.warning h2 {
  margin-top: 0;
}

.message {
  margin: 0;
}

.greyed-out {
  opacity: 0.55;
}

.find-existing {
  padding: 1rem;
  border-radius: 0.5rem;
  background: var(--surface);
}

/* --- People -------------------------------------------------------------- */

.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.person-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 48px;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

a.person-card:hover {
  outline: 2px solid var(--accent);
}

.person-name {
  font-weight: 700;
  color: var(--accent);
  text-decoration: underline;
}

.nickname {
  font-weight: 400;
}

.partnership,
.admin-tools {
  margin: 1rem 0;
  padding: 0.25rem 1rem 1rem;
  border: 2px solid var(--surface);
  border-radius: 0.5rem;
}

.partnership {
  padding-top: 1rem;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
}

/* --- Tree ---------------------------------------------------------------- */

.tree-row {
  margin: 1rem 0;
  padding: 0.25rem 1rem 1rem;
  border-left: 0.5rem solid var(--surface);
}

.tree-row h2 {
  margin-top: 0.5rem;
}

.tree-centre {
  border-left-color: var(--accent);
  background: var(--surface);
  border-radius: 0 0.5rem 0.5rem 0;
}

.tree-centre .person-card {
  background: var(--background);
}

@media (min-width: 40rem) {
  .tree-row .card-list,
  .button-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .tree-row .card-list li {
    flex: 1 1 14rem;
    max-width: 20rem;
  }
}

/* --- Settings and logins ------------------------------------------------- */

.stack ul,
.stack > div > div:not(.helptext) {
  margin: 0;
  padding: 0;
  list-style: none;
}

.stack label:has(input[type="radio"]),
.stack label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
  font-weight: 400;
}

input[type="radio"] {
  width: 1.5rem;
  height: 1.5rem;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  font-weight: 700;
}

.setup-code {
  font-family: ui-monospace, "Courier New", monospace;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  overflow-wrap: anywhere;
}

.code-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 0.5rem;
  background: var(--surface);
  list-style: none;
  font-family: ui-monospace, "Courier New", monospace;
  font-size: 1.15rem;
  font-weight: 700;
}

.qr-code {
  width: 14rem;
  max-width: 100%;
  background: #ffffff;
}

.setup-key {
  font-family: ui-monospace, "Courier New", monospace;
  overflow-wrap: anywhere;
}

main ol li {
  margin-bottom: 0.5rem;
}

.partnership h2 {
  margin-top: 0.5rem;
}
