
/* ==========================================================
   Pension Asset Navigator – Danu Insight design system
   Tokens lifted from danuinsight.org (Hugo theme)
   ========================================================== */

/* ========== Design tokens ========== */
:root {
  /* Brand */
  --coral:       #d85a4a;
  --coral-deep:  #b8443a;
  --coral-soft:  #f4d8d2;

  /* Neutrals */
  --ink:         #1a1a1a;
  --ink-soft:    #4a4540;
  --ink-mute:    #6e6862;
  --paper:       #fefcf8;
  --paper-warm:  #f8f4ed;
  --paper-deep:  #efe9dc;
  --line:        #e6dfd0;

  /* Header / footer */
  --header-bg:   #16162a;
  --header-fg:   #ffffff;

  /* Functional aliases */
  --link:        var(--coral-deep);
  --link-hover:  var(--coral);
  --focus-ring:  var(--coral);

  /* Layout */
  --max-w:       1180px;
  --radius:      2px;

  /* Spacing (simplified from the fluid scale) */
  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs:  0.75rem;
  --space-s:   1rem;
  --space-m:   1.5rem;
  --space-l:   2rem;
  --space-xl:  3rem;
}

/* ========== Base reset ========== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Source Sans 3", "Source Sans Pro", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: "kern", "liga", "calt";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ========== Typography ========== */
h1, h2, h3, h4 {
  font-family: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 var(--space-s);
}

h1 { font-size: clamp(1.75rem, 2.5vw, 2.25rem); line-height: 1.12; margin-bottom: var(--space-m); }
h2 { font-size: clamp(1.25rem, 1.8vw, 1.5rem); margin-bottom: var(--space-xs); }
h3 { font-size: 1.125rem; }

p { margin: 0 0 1.25rem; }

.muted { color: var(--ink-mute); font-size: 0.9rem; }

/* ========== Layout ========== */
.container {
  max-width: var(--max-w);
  margin: var(--space-l) auto;
  padding: 0 var(--space-m);
}

/* ========== Header ========== */
.site-header {
  background: var(--header-bg);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.site-header__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0.875rem var(--space-m);
  display: flex;
  align-items: center;
  gap: var(--space-l);
}

.brand-title {
  text-decoration: none;
  color: var(--header-fg);
  font-family: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
  display: inline-flex;
  gap: var(--space-xs);
  align-items: center;
}
.brand-title:hover { text-decoration: none; color: var(--header-fg); }

.badge-proto {
  font-weight: 600;
  font-size: 0.65rem;
  line-height: 1;
  padding: 3px 8px;
  border-radius: var(--radius);
  background: var(--coral);
  color: #fff;
  border: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-inline {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius);
  background: var(--coral);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  vertical-align: middle;
  margin-left: 6px;
}

.main-nav { margin-left: auto; display: flex; gap: var(--space-2xs); }
.main-nav a {
  color: rgba(255,255,255,0.78);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: color 0.15s;
}
.main-nav a:hover { color: var(--header-fg); background: rgba(255,255,255,0.08); text-decoration: none; }
.main-nav a.active { background: var(--coral); color: #fff; }

.brand-logo { display: inline-flex; align-items: center; margin-left: var(--space-xs); }
.brand-logo img { height: 32px; width: auto; display: block; }

/* ========== Footer ========== */
.site-footer {
  background: var(--header-bg);
  border-top: 4px solid var(--coral);
  padding: var(--space-xl) var(--space-m) var(--space-l);
  margin-top: var(--space-xl);
  color: rgba(255,255,255,0.78);
  font-size: 0.9375rem;
}
.site-footer__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-l);
}
.site-footer a { color: rgba(255,255,255,0.78); }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.site-footer__brand {
  font-weight: 600;
  color: #fff;
  font-size: 1rem;
  margin-bottom: var(--space-2xs);
}

@media (max-width: 640px) {
  .site-footer__inner { flex-direction: column; text-align: center; align-items: center; }
}

/* ========== Card ========== */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-m);
  box-shadow: 0 2px 12px rgba(20,16,10,0.06);
}

/* ========== Tables ========== */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-xs);
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  background: var(--paper-warm);
  color: var(--ink-soft);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 2px solid var(--line);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

tbody tr:hover { background: var(--paper-warm); }
tbody tr:nth-child(even) { background: rgba(248,244,237,0.4); }
tbody tr:nth-child(even):hover { background: var(--paper-warm); }

/* Sort links in headers */
thead th a {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  color: inherit;
  text-decoration: none;
  justify-content: flex-start;
}
thead th a:hover { text-decoration: underline; color: var(--ink); }
.sort { font-size: 0.75rem; opacity: 0.6; }

/* ========== Filters bar ========== */
.filters {
  display: grid;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
  grid-template-columns: minmax(220px,1fr) minmax(220px,1fr) auto;
}
@media (max-width: 1100px) { .filters { grid-template-columns: 1fr 1fr; } }

.filters label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filters input, .filters select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s;
}
.filters input:focus, .filters select:focus {
  outline: 2px solid var(--coral);
  outline-offset: -1px;
  border-color: var(--coral);
}

.filters .actions { display: flex; gap: 8px; justify-self: end; align-items: center; }

/* Drawer toggle spans full width */
.filters__drawer { grid-column: 1 / -1; }

/* ========== Drawer content ========== */
.filters--drawer {
  margin-top: 12px;
  display: grid;
  gap: 12px;
  align-items: end;
  grid-template-columns: minmax(200px,1fr) minmax(110px,.6fr) minmax(90px,.5fr) minmax(200px,1fr);
  grid-auto-flow: row dense;
}
@media (max-width: 1100px) { .filters--drawer { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .filters--drawer { grid-template-columns: 1fr; } }

details > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-warm);
  color: var(--ink-soft);
  user-select: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s;
}
details > summary:hover { background: var(--paper-deep); }
details[open] > summary { background: var(--paper-deep); }
details > summary::before { content: "\25B8"; transition: transform 0.15s ease; }
details[open] > summary::before { transform: rotate(90deg); }

/* Range controls */
.range { display: grid; grid-template-rows: auto auto; gap: 6px; }
.range__inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 260px; }

/* ========== Results bar ========== */
.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: var(--space-xs) 0;
}
.results-bar__left { display: flex; align-items: center; }
.results-bar__form { display: flex; align-items: center; gap: 8px; }
.results-bar__search { flex: 0 1 560px; min-width: 280px; }

.form-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  background: #fff;
  color: var(--ink);
}
.form-input:focus {
  outline: 2px solid var(--coral);
  outline-offset: -1px;
  border-color: var(--coral);
}

/* Filter chips */
.filters-applied { margin-left: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper-warm);
  color: var(--ink-soft);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ========== Buttons ========== */
a.btn, button.btn, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 1.25rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-warm);
  color: var(--ink-soft);
  text-decoration: none;
  cursor: pointer;
  appearance: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--paper-deep); text-decoration: none; }

.btn.primary {
  background: var(--coral);
  color: #fff;
  border-color: transparent;
}
.btn.primary:hover { background: var(--coral-deep); }

/* ========== Input helpers ========== */
.input--year { max-width: 110px; }
.input--state { max-width: 90px; }
.input--xs { max-width: 120px; }
.input--compact { max-width: 320px; }

/* ========== Messages ========== */
::placeholder { color: var(--ink-mute); }

.form-errors {
  border: 1px solid var(--coral-soft);
  border-left: 3px solid var(--coral);
  background: #fff5f4;
  color: var(--coral-deep);
  padding: 8px 14px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 0.9rem;
}
.field-error { color: var(--coral-deep); font-size: 0.85rem; margin-top: 4px; }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  color: var(--ink-mute);
  font-size: 0.8rem;
}

/* ========== Grid utilities ========== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .grid-2, .cols-2 { grid-template-columns: 1fr; } }

/* ========== Row interactions ========== */
.row--clickable { cursor: pointer; }
tr.row-details td { background: var(--paper-warm); border-left: 3px solid var(--coral); }

/* ========== View toggle ========== */
.toolbar { display: flex; gap: 6px; align-items: center; }

.view-toggle { display: inline-flex; gap: 0; margin: var(--space-2xs) 0 var(--space-s); }
.view-toggle .btn {
  border-radius: 0;
  padding: 8px 16px;
  border: 1px solid var(--line);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.view-toggle .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.view-toggle .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }
.view-toggle .btn.active {
  background: var(--coral);
  color: #fff;
  border-color: var(--coral);
}
.view-toggle .btn.active + .btn { border-left: none; }

/* ========== Plan Detail: Overview ========== */
.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
}
.kv > div span {
  display: block;
  color: var(--ink-mute);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.kv > div strong {
  display: block;
  font-weight: 500;
  font-size: 1rem;
}

@media (max-width: 750px) { .kv { grid-template-columns: 1fr; } }

/* 3-col overview grid */
.overview-3col h2 { margin-bottom: 10px; }

.ov-grid {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(220px, 0.75fr);
  gap: 12px 18px;
  align-items: start;
}

.ov-grid .kv {
  grid-column: 1 / span 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
}
.ov-grid .kv > div span {
  display: block;
  color: var(--ink-mute);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.ov-grid .kv > div strong { display: block; font-weight: 500; }

.ov-actions {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 900px) {
  .ov-grid { grid-template-columns: 1fr; }
  .ov-grid .kv { grid-column: 1; grid-template-columns: 1fr; }
  .ov-actions { grid-column: 1; flex-direction: row; flex-wrap: wrap; gap: 8px; }
}

/* ========== Pagination ========== */
.pagination {
  margin-top: var(--space-s);
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ========== About page ========== */
.card h2 { margin-top: var(--space-m); }
.card ul, .card ol { padding-left: 1.25rem; margin: 0 0 1.25rem; }
.card li { margin-bottom: 0.5rem; line-height: 1.55; }
.card dt { font-weight: 600; margin-top: var(--space-xs); }
.card dd { margin: 2px 0 var(--space-xs) 0; color: var(--ink-soft); }

/* ========== Back link ========== */
a[href*="Back"],
a[href^="{% url"]:first-child {
  /* fallback: style the back-arrow links */
}

/* ========== Responsive tweaks ========== */
@media (max-width: 760px) {
  .container { padding: 0 var(--space-s); margin: var(--space-s) auto; }
  .site-header__inner { padding: 0.75rem var(--space-s); gap: var(--space-s); }
  h1 { font-size: 1.5rem; }
}

@media (max-width: 540px) {
  .main-nav { gap: 2px; }
  .main-nav a { padding: 6px 8px; font-size: 0.85rem; }
  .brand-logo img { height: 26px; }
  .brand-title { font-size: 1rem; }
  .results-bar { flex-direction: column; align-items: flex-start; }
  .results-bar__search { min-width: 100%; }
}
