/* Bank of Dad stylesheet. Mobile first. Every colour is a token on :root below. */

/* ---- Light (default, and "Light" theme) --------------------------------- */
:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #1c2321;
  --muted: #5b6763;
  --line: #d9dfdc;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --accent-soft: #d8efec;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --warn-soft: #fff1d6;
  --ok: #15703a;
  --ok-soft: #dcf3e3;
  --radius: 10px;
  --space: 1rem;
  --tap: 2.75rem;
  --tone-0: #0f766e;
  --tone-1: #2563eb;
  --tone-2: #7c3aed;
  --tone-3: #c026d3;
  --tone-4: #db2777;
  --tone-5: #dc2626;
  --tone-6: #ea580c;
  --tone-7: #ca8a04;
  --tone-8: #65a30d;
  --tone-9: #16a34a;
  --tone-10: #0891b2;
  --tone-11: #64748b;
}

/* ---- Following the device, when it is dark ------------------------------ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #121615;
    --surface: #1b211f;
    --text: #e8eeec;
    --muted: #9aa8a3;
    --line: #2d3733;
    --accent: #3fb8aa;
    --accent-text: #08201d;
    --accent-soft: #173a36;
    --danger: #ff8a7d;
    --danger-soft: #3a1c19;
    --warn-soft: #3a2e12;
    --ok: #6fd49a;
    --ok-soft: #173a25;
  }
}

/* ---- Explicit themes ---------------------------------------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121615;
  --surface: #1b211f;
  --text: #e8eeec;
  --muted: #9aa8a3;
  --line: #2d3733;
  --accent: #3fb8aa;
  --accent-text: #08201d;
  --accent-soft: #173a36;
  --danger: #ff8a7d;
  --danger-soft: #3a1c19;
  --warn-soft: #3a2e12;
  --ok: #6fd49a;
  --ok-soft: #173a25;
}

:root[data-theme="paper"] {
  color-scheme: light;
  --bg: #f1ebdf;
  --surface: #fbf8f1;
  --text: #2b261f;
  --muted: #655c4e;
  --line: #ddd3c1;
  --accent: #8a5a1f;
  --accent-text: #fffaf0;
  --accent-soft: #efe1c8;
  --danger: #a3301c;
  --danger-soft: #f5ddd3;
  --warn-soft: #f4e3bd;
  --ok: #4a6b1f;
  --ok-soft: #e1e9cf;
}

:root[data-theme="contrast"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #000000;
  --text: #ffffff;
  --muted: #e0e0e0;
  --line: #ffffff;
  --accent: #ffff00;
  --accent-text: #000000;
  --accent-soft: #333300;
  --danger: #ff8080;
  --danger-soft: #3d0000;
  --warn-soft: #3d2e00;
  --ok: #80ff80;
  --ok-soft: #003d14;
  --tone-0: #00ffff;
  --tone-1: #ffff00;
  --tone-2: #ff80ff;
  --tone-3: #80ff80;
  --tone-4: #ffa040;
  --tone-5: #80b0ff;
  --tone-6: #ff8080;
  --tone-7: #ffffff;
  --tone-8: #00ffff;
  --tone-9: #ffff00;
  --tone-10: #ff80ff;
  --tone-11: #80ff80;
}

:root[data-theme="colourblind"] {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1a1f24;
  --muted: #56606a;
  --line: #d5dce3;
  --accent: #005f99;
  --accent-text: #ffffff;
  --accent-soft: #d9eaf6;
  --danger: #b04600;
  --danger-soft: #fbe4d4;
  --warn-soft: #faf0c4;
  --ok: #005f99;
  --ok-soft: #d6ebf7;
  --tone-0: #0072b2;
  --tone-1: #e69f00;
  --tone-2: #009e73;
  --tone-3: #cc79a7;
  --tone-4: #56b4e9;
  --tone-5: #d55e00;
  --tone-6: #0072b2;
  --tone-7: #e69f00;
  --tone-8: #009e73;
  --tone-9: #cc79a7;
  --tone-10: #56b4e9;
  --tone-11: #d55e00;
}

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

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

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

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

h1,
h2 {
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

h1 {
  font-size: 1.6rem;
}

h2 {
  font-size: 1.25rem;
}

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 1rem;
}

.skip-link:focus {
  left: var(--space);
  top: var(--space);
  z-index: 20;
}

/* ---- Header ------------------------------------------------------------- */
.site-header {
  background: var(--accent);
  color: var(--accent-text);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  max-width: 60rem;
  margin: 0 auto;
  padding: 0.5rem var(--space);
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--tap);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
}

.brand__logo {
  flex: none;
}

/* ---- Buttons ------------------------------------------------------------ */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
}

.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.button--ghost {
  background: transparent;
  border-color: currentColor;
  color: inherit;
}

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

/* ---- Cards and forms ---------------------------------------------------- */
.page {
  max-width: 60rem;
  margin: 0 auto;
  padding: var(--space);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: calc(var(--space) * 1.25);
  margin-bottom: var(--space);
}

.card--narrow {
  max-width: 26rem;
  margin: 1rem auto;
}

.stack > * + * {
  margin-top: var(--space);
}

.field label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.field-error {
  margin: 0.3rem 0 0;
  color: var(--danger);
  font-weight: 600;
}

.input {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  font: inherit;
}

/* ---- Messages and alerts ------------------------------------------------ */
.messages {
  display: grid;
  gap: 0.5rem;
  list-style: none;
  margin: 0 0 var(--space);
  padding: 0;
}

.message,
.alert {
  padding: 0.75rem 1rem;
  border-left: 0.35rem solid;
  border-radius: var(--radius);
  color: var(--text);
}

.message--success {
  background: var(--ok-soft);
  border-color: var(--ok);
}

.message--info {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.message--error,
.alert--error {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.alert p {
  margin: 0;
}

/* ---- Badges and people -------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.85rem;
}

.people {
  display: grid;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.person {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--tap);
}

.person__text {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.6rem;
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--tap);
  height: var(--tap);
  border: 4px solid var(--tone-0);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.tone-0 { border-color: var(--tone-0); }
.tone-1 { border-color: var(--tone-1); }
.tone-2 { border-color: var(--tone-2); }
.tone-3 { border-color: var(--tone-3); }
.tone-4 { border-color: var(--tone-4); }
.tone-5 { border-color: var(--tone-5); }
.tone-6 { border-color: var(--tone-6); }
.tone-7 { border-color: var(--tone-7); }
.tone-8 { border-color: var(--tone-8); }
.tone-9 { border-color: var(--tone-9); }
.tone-10 { border-color: var(--tone-10); }
.tone-11 { border-color: var(--tone-11); }

/* ---- Theme picker ------------------------------------------------------- */
.theme-menu {
  position: relative;
}

.theme-menu summary {
  cursor: pointer;
}

.theme-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 10;
  display: grid;
  gap: 0.25rem;
  min-width: 16rem;
  padding: 0.5rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  white-space: nowrap;
}

.theme-menu__option {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 0.4rem 0.75rem;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.theme-menu__option[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 700;
}

/* ---- Footer ------------------------------------------------------------- */
.site-footer {
  max-width: 60rem;
  margin: 2rem auto 0;
  padding: var(--space);
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--line);
}

/* ---- Contrast theme extras ---------------------------------------------- */
:root[data-theme="contrast"] a {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

:root[data-theme="contrast"] .button,
:root[data-theme="contrast"] .badge,
:root[data-theme="contrast"] .theme-menu__option,
:root[data-theme="contrast"] .input {
  border: 2px solid var(--text);
}

/* ---- Colour-blind theme: a second cue for each category ----------------- */
:root[data-theme="colourblind"] .avatar {
  border-style: double;
  border-width: 6px;
}

/* ---- Menu --------------------------------------------------------------- */
.site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.site-nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 var(--space);
  list-style: none;
}

.site-nav__list li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.site-nav__list a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-weight: 600;
}

.count {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0 0.4rem;
  border: 1px solid var(--danger);
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}

/* ---- Buttons, forms, details -------------------------------------------- */
.button--secondary {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.help {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.field--check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--tap);
}

.field--check label {
  margin: 0;
}

.check {
  width: 1.5rem;
  height: 1.5rem;
  accent-color: var(--accent);
}

select.input {
  appearance: auto;
}

details > summary {
  cursor: pointer;
}

.form-panel {
  margin-top: var(--space);
  padding-top: var(--space);
  border-top: 1px solid var(--line);
}

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

code {
  overflow-wrap: anywhere;
}

.secret {
  display: block;
  padding: 0.75rem;
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 1rem;
}

/* ---- Cards, balances and accounts --------------------------------------- */
.card--attention {
  border-color: var(--danger);
  border-width: 2px;
}

.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}

.balance {
  margin: 0;
  font-size: 2.75rem;
  font-variant-numeric: tabular-nums;
}

.accounts {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.account-card__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

.account-card__link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.account-card__text {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.6rem;
}

.account-card__balance {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---- Chart -------------------------------------------------------------- */
.chart {
  margin: var(--space) 0 0;
}

.chart svg {
  display: block;
  width: 100%;
  height: 6rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
}

.chart-line {
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.chart figcaption {
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

/* ---- Tables ------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.table th,
.table td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table .num {
  text-align: right;
  white-space: nowrap;
}

.amount--in {
  color: var(--ok);
  font-weight: 700;
}

.amount--out {
  color: var(--danger);
  font-weight: 700;
}

/* ---- Requests and status badges ----------------------------------------- */
.requests {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.request {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.request p {
  margin: 0.25rem 0 0;
}

.request__actions {
  display: grid;
  gap: 0.5rem;
  min-width: 14rem;
}

.badge--pending {
  background: var(--warn-soft);
}

.badge--approved {
  background: var(--ok-soft);
}

.badge--declined,
.badge--cancelled {
  background: var(--danger-soft);
}

:root[data-theme="contrast"] .count,
:root[data-theme="contrast"] .button--secondary,
:root[data-theme="contrast"] .account-card__link {
  border: 2px solid var(--text);
}

/* ---- Wider screens ------------------------------------------------------ */
@media (min-width: 40rem) {
  .people {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
