:root {
  --maxw: 46rem;
  --sans: "Helvetica Neue", Arial, "Segoe UI", system-ui, sans-serif;
}

/* Dark palette — the default, and when forced via the toggle */
:root,
:root[data-theme="dark"] {
  --bg: #0b0b0c;
  --bg-raised: #141416;
  --ink: #f4f2ee;
  --ink-dim: #9a958c;
  --line: #2a2a2d;
  --accent: #c08a3e;        /* warm bronze */
  --accent-bright: #e0a64e;
  color-scheme: dark;
}

/* Light palette — applied automatically when the system prefers light,
   unless the visitor has explicitly chosen dark via the toggle. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #faf8f3;
    --bg-raised: #ffffff;
    --ink: #1b1a17;
    --ink-dim: #6c675c;
    --line: #e4ded2;
    --accent: #9a6a24;
    --accent-bright: #7f5717;
    color-scheme: light;
  }
}

/* Light palette — when forced via the toggle */
:root[data-theme="light"] {
  --bg: #faf8f3;
  --bg-raised: #ffffff;
  --ink: #1b1a17;
  --ink-dim: #6c675c;
  --line: #e4ded2;
  --accent: #9a6a24;
  --accent-bright: #7f5717;
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

.content {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* ---- header / footer ---- */
.site-header {
  position: relative;
  border-bottom: 1px solid var(--line);
  padding: 2rem 1.5rem 1.75rem;
  text-align: center;
}
.theme-toggle {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 2.3rem;
  height: 2.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover {
  color: var(--accent-bright);
  border-color: var(--accent);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.brand { display: inline-block; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-name {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.brand-sub {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.7rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.site-footer {
  border-top: 1px solid var(--line);
  padding: 2rem 1.5rem;
  text-align: center;
}
.site-footer p {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* ---- intro ---- */
.intro { color: var(--ink-dim); }
.intro p { margin: 0 0 1.5rem; }

/* ---- table of contents ---- */
.toc-section { margin: 2.75rem 0; }
.toc-heading {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
  margin: 0 0 0.75rem;
}
.toc-heading a { color: inherit; }
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: item;
}
.toc-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(42,42,45,0.5);
}
.toc-item::before {
  counter-increment: item;
  content: counter(item, decimal-leading-zero);
  color: var(--ink-dim);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  min-width: 1.75rem;
}
.toc-item a {
  color: var(--ink);
  font-size: 1.05rem;
}
.toc-item a:hover { color: var(--accent-bright); }
.composer {
  margin-left: auto;
  color: var(--ink-dim);
  font-size: 0.8rem;
  font-style: italic;
  text-align: right;
}

/* ---- back link / pager ---- */
.back {
  display: inline-block;
  margin-bottom: 2rem;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.back:hover { color: var(--accent-bright); text-decoration: none; }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}
.pager-next { margin-left: auto; text-align: right; }

/* ---- waiata page ---- */
.section-title,
.waiata-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
  margin: 0;
}
.waiata-head { margin-bottom: 2.25rem; }
.waiata-head .composer {
  margin: 0.6rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-dim);
}

.lyrics {
  font-size: 1.15rem;
  line-height: 1.8;
}
.lyrics p { margin: 0 0 1.5rem; }

/* ---- translation dropdown ---- */
.translation {
  margin: 2rem 0 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-raised);
}
.translation > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 1.1rem;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.translation > summary::-webkit-details-marker { display: none; }
.translation > summary::before {
  content: "+";
  font-size: 1rem;
  line-height: 1;
  color: var(--ink-dim);
}
.translation[open] > summary::before { content: "−"; }
.translation > summary:hover { color: var(--accent-bright); }
.translation-body {
  padding: 0.25rem 1.1rem 1.1rem;
  color: var(--ink-dim);
  line-height: 1.7;
}
.translation-body p { margin: 0 0 1rem; }
.translation-body p:last-child { margin-bottom: 0; }

@media (max-width: 480px) {
  .composer { margin-left: 0; flex-basis: 100%; text-align: left; }
  .toc-item { flex-wrap: wrap; }
}
