/* WB-032 — Who Funds Tennessee "Capitol" skin for the Datasette portal, loaded on
 * EVERY page via extra_css_urls (not base.html's extra_head, which Datasette 1.0a's
 * index.html shadows — that was the broken-homepage regression). Goal: read like a
 * normal Astro page on whofundstn.org. Tokens from site-tn/src/config/site.ts. */

/* Self-hosted webfonts (the same files site/ ships) so the portal renders in the
   site's DM Serif Display headings + Source Sans 3 body, not Georgia/system fallbacks.
   URLs are RELATIVE to this stylesheet → /assets/fonts/* in prod, /fonts/* in preview. */
@font-face { font-family: 'DM Serif Display'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/dm-serif-display-latin.woff2') format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'DM Serif Display'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/dm-serif-display-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('fonts/source-sans-3-latin.woff2') format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('fonts/source-sans-3-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Source Sans 3'; font-style: italic; font-weight: 400 700; font-display: swap; src: url('fonts/source-sans-3-italic-latin.woff2') format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Source Sans 3'; font-style: italic; font-weight: 400 700; font-display: swap; src: url('fonts/source-sans-3-italic-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

:root {
  /* WB-068: brand colors come from the wf_portal plugin as --brand-* custom
     properties (set per WF_BRAND in base.html's <style>); the fallbacks below are
     the TN "Capitol" defaults, so an un-branded render still looks right. */
  --wf-ink: var(--brand-ink, #0f2238);              /* chrome (masthead) bg     */
  --wf-gold: var(--brand-accent-on-dark, #d2b066);  /* accent legible ON chrome */
  --wf-bronze: var(--brand-accent, #856213);        /* accent on LIGHT          */
  --wf-brass: #b8923a;    /* keyline (derived from --accent below) */
  --wf-wash: var(--brand-wash, #f5f2ea);            /* page bg                  */
  --wf-paper: var(--brand-paper, #fffdf8);          /* card/table surface       */
  --wf-link: var(--brand-link, #1f60c0);
  --wf-link-hover: var(--brand-link-hover, #17468f);
  --wf-text: #1b2733;
  --wf-rule: var(--brand-rule, #e6dfce);

  /* Aliases so the ported whofundstn.org masthead CSS (from BaseLayout.astro)
     reads verbatim against the portal's brand tokens. */
  --ink: var(--wf-ink);
  --accent: var(--wf-gold);
  --accent-on-dark: var(--wf-gold);  /* accent legible on the dark chrome */
  --muted: var(--brand-muted, #6b7686);
  --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'DM Serif Display', Georgia, "Times New Roman", serif;
  --z-dropdown: 100;
}
html, body {
  background: var(--wf-wash);
  color: var(--wf-text);
  font-family: var(--font-sans);
}
a { color: var(--wf-link); }
a:hover { color: var(--wf-link-hover); }

/* ── header: a verbatim port of the whofundstn.org masthead ────────────────
   Datasette nests the {% block nav %} content inside <header><nav>, so that <nav>
   plays the role of BaseLayout.astro's `.container.header-inner` flex row. The
   child markup + classes are identical to the Astro header. */
body > .not-footer > header {
  background: var(--ink);
  border-bottom: 3px solid var(--accent);   /* the brass keyline under the bar */
  margin-bottom: 0;
  padding: 0.8rem 0;
  overflow: visible;   /* Datasette's app.css sets header.hd{overflow:hidden}, which
                          clips the <details> dropdown as it drops below the bar. */
}
body > .not-footer > header > nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}
header .crumbs { width: 100%; max-width: 1100px; margin: 6px auto 0; padding: 0 16px; font-size: 13px; color: #c9d6e4; }
header .crumbs a { color: var(--accent); }
header .crumbs a:hover { color: #ecd9a8; }
body.wf-hub header .crumbs { display: none; }

/* ---- Logo lockup: coin-seal mark + two-line wordmark ---- */
.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  font-family: var(--font-sans);
  flex-shrink: 0;
}
.logo-mark { display: inline-flex; align-items: center; line-height: 0; font-size: 1.5rem; }
.logo-mark svg { height: 1.55em; width: 1.55em; display: block; }
.logo-stack {
  display: flex;
  flex-direction: column;
  line-height: 1.06;
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.logo-text { color: #ffffff; white-space: nowrap; }
.logo-accent { color: var(--accent); }
.site-logo:hover { text-decoration: none; }
.site-logo:hover .logo-accent { filter: brightness(1.12); }

/* ---- Primary nav: hugs the brand, pushes the chip/search right ---- */
.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-right: auto;
  font-size: 0.95rem;
  font-weight: 600;
}
.nav-link {
  position: relative;
  color: #ededf2;
  white-space: nowrap;
  padding: 0.1rem 0;
  text-decoration: none;
  transition: color 0.15s ease;
}
.nav-link:hover { color: #ffffff; text-decoration: none; }
.nav-link::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -3px;
  height: 2px;
  background: var(--accent-on-dark, var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.18s ease;
}
.nav-link:hover::after { transform: scaleX(1); }
.nav-link--utility { color: #9a9aa6; font-size: 0.86rem; font-weight: 600; }
.nav-link--utility:hover { color: #ffffff; }
.nav-link--utility::after { display: none; }
.nav-sep { width: 1px; height: 1.1rem; background: rgba(255, 255, 255, 0.18); flex-shrink: 0; }

/* ---- Sister-site chip ---- */
.sister-link {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  flex-shrink: 0;
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #d8d8de;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.sister-link:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.07);
  text-decoration: none;
}
.sister-arrow { color: var(--accent-on-dark, var(--accent)); flex-shrink: 0; }

/* ---- Mobile nav: a JS-free <details> dropdown (hidden on desktop) ---- */
.nav-menu { display: none; position: relative; }
.nav-icon--close { display: none; }
.nav-menu[open] .nav-icon--open { display: none; }
.nav-menu[open] .nav-icon--close { display: block; }

@media (max-width: 1100px) {
  body > .not-footer > header { padding: 0.55rem 0; }
  body > .not-footer > header > nav { gap: 0.4rem; min-width: 0; }
  .site-nav, .sister-link { display: none; }

  .nav-menu { display: block; flex-shrink: 0; margin-left: auto; }
  /* `.nav-menu > .nav-menu-toggle` (2 classes) out-specifies Datasette's
     `details.nav-menu > summary` (1 class + 2 elements), which sets
     float:right + display:inline and breaks the centered icon button. */
  .nav-menu > .nav-menu-toggle {
    list-style: none;
    float: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    cursor: pointer;
    color: #d8d8de;
    border-radius: 6px;
    user-select: none;
    transition: color 0.15s ease, background 0.15s ease;
  }
  .nav-menu-toggle::-webkit-details-marker { display: none; }
  .nav-menu-toggle:hover { color: #ffffff; background: rgba(255, 255, 255, 0.08); }
  .nav-menu[open] .nav-menu-toggle { color: #ffffff; background: rgba(255, 255, 255, 0.1); }

  .nav-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    display: flex;
    flex-direction: column;
    min-width: 12.5rem;
    padding: 0.4rem 0;
    background: var(--ink);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
    z-index: var(--z-dropdown);
  }
  .nav-menu[open] .nav-menu-panel { animation: nav-pop 0.16s ease both; }
  @keyframes nav-pop {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .nav-menu-panel a {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: #ececf0;
    text-decoration: none;
    padding: 0.55rem 1.05rem;
    font-size: 0.95rem;
    font-weight: 600;
  }
  .nav-menu-panel a.util { color: #9a9aa6; font-size: 0.9rem; }
  .nav-menu-panel a.sister { color: #d8d8de; }
  .nav-menu-panel a.sister svg { color: var(--accent-on-dark, var(--accent)); }
  .nav-menu-panel a:hover { color: #ffffff; background: rgba(255, 255, 255, 0.07); text-decoration: none; }
  .nav-menu-sep { height: 1px; margin: 0.35rem 0.7rem; background: rgba(255, 255, 255, 0.12); }
}

/* ── content ──────────────────────────────────────────────────────────────── */
section.content { max-width: 1100px; margin: 0 auto; padding: 22px 16px 40px; }
.content h1 { color: var(--wf-ink); font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.01em; }
.content h1 a, .content h2 a, .content h1 a:visited { color: var(--wf-ink); }
.content h2 { color: var(--wf-ink); }
.content h2 a { text-decoration: none; }
.page-header { border-color: var(--wf-gold) !important; }

/* intro / description / privacy callout */
.metadata-description, .db-description {
  background: var(--wf-paper); border: 1px solid var(--wf-rule);
  border-left: 4px solid var(--wf-bronze); border-radius: 8px;
  padding: 14px 18px; margin: 16px 0; line-height: 1.5;
}
.metadata-description ul { margin: 8px 0 0; }

/* ── tables ─────────────────────────────────────────────────────────────── */
table.rows-and-columns { background: var(--wf-paper); border-color: var(--wf-rule); }
table.rows-and-columns th {
  background: var(--wf-ink); color: var(--wf-gold);
  border-color: var(--wf-ink); font-weight: 600;
}
table.rows-and-columns th a { color: var(--wf-gold); }
table.rows-and-columns td { border-color: var(--wf-rule); }
table.rows-and-columns tbody tr:nth-child(even) td { background: #fbf8f1; }

/* ── controls: SQL box, inputs, buttons ─────────────────────────────────── */
textarea, input[type=text], input[type=search], select {
  border: 1px solid var(--wf-brass); border-radius: 6px; background: var(--wf-paper);
}
textarea:focus, input:focus, select:focus { outline: 2px solid var(--wf-gold); border-color: var(--wf-gold); }
.button, button, input[type=submit], input[type=button] {
  background: var(--wf-bronze); color: #fff; border: 0; border-radius: 6px;
}
.button:hover, button:hover, input[type=submit]:hover { background: var(--wf-ink); color: #fff; }

/* ── hide Datasette chrome so it reads as a normal page ──────────────────── */
/* the "Database/Table/Homepage actions" cog menus, and the export_meta table row */
.page-action-menu, details.actions-menu, .actions-menu-links { display: none !important; }
/* de-emphasize the footer credit (kept for attribution, not a banner) */
footer.ft, body > footer {
  background: var(--wf-ink); color: #9fb3c8;
  border-top: 3px solid var(--wf-gold); margin-top: 36px;
  padding: 14px 16px; font-size: 12.5px;
}
footer.ft a, body > footer a { color: var(--wf-gold); }

/* ── one-page hub (index) ───────────────────────────────────────────────── */
.wf-muted { color: #6b7686; font-size: 14px; margin: 2px 0 12px; }
.wf-hub .metadata-description {
  background: none; border: 0; border-left: 0; padding: 0; margin: 6px 0 22px;
  font-size: 17px; line-height: 1.55; color: #2a3744; max-width: 70ch;
}
.wf-card {
  background: var(--wf-paper); border: 1px solid var(--wf-rule); border-radius: 12px;
  padding: 18px 20px; margin: 0 0 18px;
}
.wf-card > h2 {
  margin: 0 0 4px; font-family: var(--font-serif); font-weight: 400; font-size: 20px; border: 0; color: var(--wf-ink);
}
/* ask + sql forms */
.wf-card form { margin: 0; }
.wf-card textarea {
  width: 100%; box-sizing: border-box; font-size: 15px; padding: 10px 12px;
  border: 1px solid var(--wf-brass); border-radius: 8px; background: #fff; resize: vertical;
}
.wf-sqlcard textarea { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13.5px; }
.wf-actions { margin-top: 10px; }
.wf-card button {
  background: var(--wf-bronze); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.wf-card button:hover { background: var(--wf-ink); }
.wf-ask { border-left: 4px solid var(--wf-gold); }

/* saved reports */
.wf-reports { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 10px; }
.wf-reports a {
  display: inline-block; background: #fff; border: 1px solid var(--wf-rule);
  border-radius: 99px; padding: 6px 14px; text-decoration: none; font-weight: 500;
}
.wf-reports a:hover { border-color: var(--wf-brass); background: #fbf8f1; }

/* tables list */
.wf-tables { width: 100%; border-collapse: collapse; margin: 4px 0; }
.wf-tables td { padding: 9px 8px; border-bottom: 1px solid var(--wf-rule); vertical-align: baseline; }
.wf-tables tr:last-child td { border-bottom: 0; }
.wf-tname a { font-weight: 600; font-size: 15.5px; text-decoration: none; }
.wf-tname a:hover { text-decoration: underline; }
.wf-rows { color: #6b7686; font-size: 13.5px; white-space: nowrap; }
.wf-dl { text-align: right; font-size: 13.5px; white-space: nowrap; }

/* about-the-data disclosure */
.wf-about { margin: 6px 0 0; }
.wf-about > summary {
  cursor: pointer; color: var(--wf-bronze); font-weight: 600; font-size: 14px;
  padding: 6px 0; list-style: none;
}
.wf-about > summary::-webkit-details-marker { display: none; }
.wf-about > summary::before { content: "▸ "; }
.wf-about[open] > summary::before { content: "▾ "; }
.wf-about-body { font-size: 14px; color: #3a4654; line-height: 1.55; max-width: 72ch; }
.wf-about-body ul { margin: 8px 0; }

@media (max-width: 560px) {
  .wf-dl { text-align: left; }
  .wf-tables td { display: block; padding: 2px 0; border: 0; }
  .wf-tables tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--wf-rule); }
}
