@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&family=Playfair+Display:wght@600;700&display=swap");

/* ==========================================================================
   VHWF Resource Library — theme
   Calm, medical-trustworthy look. All colors via CSS variables.
   WCAG 2.1 AA: base font >= 18px, contrast-checked palette, visible focus.
   ========================================================================== */

:root {
  /* palette — from myvhwf.org (live CSS, 2026-11-14). AA-checked:
     navy on white 11.98:1, navy on cream 11.28:1, gold on navy 7.69:1,
     green-dark on cream 5.79:1, gold-text on white 6.03:1. */
  --brand: #1b3a4b;          /* VHWF navy */
  --brand-dark: #163140;
  --brand-darker: #132b38;
  --accent: #1b3a4b;         /* links: navy */
  --accent-hover: #3f6b4c;   /* brand green #4a7c59 darkened for AA on cream */
  --green: #4a7c59;          /* brand green (decorative / large text only) */
  --gold: #ffc73d;           /* brand gold (on navy only) */
  --gold-button: #e0a813;    /* donate-button gold; navy text 5.58:1 */
  --gold-text: #7a5f1f;      /* brand #a88434 darkened for AA on white */
  --bg: #faf8f3;             /* warm cream */
  --card: #ffffff;
  --text: #1f2a30;
  --muted: #5a6470;
  --border: #e4dfd4;
  --crisis-bg: #fdf3f2;
  --crisis-border: #e4b7b2;
  --crisis: #9c1c0e;
  --badge-pdf-bg: #fff4d6;
  --badge-pdf-text: #1b3a4b;
  --badge-web-bg: #eaf2ec;
  --badge-web-text: #2f5a3c;
  --focus: #ffc73d;

  /* type — Playfair Display headings, Open Sans body (as on myvhwf.org) */
  --font-body: "Open Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-head: "Playfair Display", Georgia, "Times New Roman", serif;

  /* hero: gradient placeholder (static/images/hero-veterans.jpg not supplied).
     To use a photo: add that file, then append to --hero-bg a second layer
     pointing at ../images/hero-veterans.jpg (center / cover no-repeat) and
     put a navy rgba(19,43,56,.78) gradient over it to keep text at AA. */
  --hero-bg: linear-gradient(135deg, #132b38 0%, #1b3a4b 55%, #2c4f5f 100%);

  /* layout */
  --maxw: 1200px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(19, 43, 56, 0.12);
  --shadow-lg: 0 6px 24px rgba(19, 43, 56, 0.16);
}

/* ---------- base ---------- */

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

html {
  font-size: 112.5%; /* 18px base */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

img, svg { max-width: 100%; height: auto; }

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

h1, h2, h3 { line-height: 1.25; color: var(--brand-darker); font-family: var(--font-head); font-weight: 700; }

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

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

.skip-link {
  position: absolute;
  left: 0.75rem; top: -4rem;
  z-index: 200;
  background: var(--brand-dark);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius) var(--radius);
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0; color: #fff; }

/* ---------- hero ---------- */

.site-hero {
  background: var(--hero-bg);
  border-bottom: 4px solid var(--gold);
  color: #fff;
}
.hero-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.75rem 1.25rem 3rem;
}
.site-hero.hero--small .hero-inner { padding: 1.25rem; }

.site-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}
.site-kicker a { color: var(--gold); text-decoration: none; }
.site-kicker a:hover { text-decoration: underline; }

.hero-title {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 2.1rem;
  color: #fff;
}
.hero--small .hero-title { font-size: 1.35rem; }
.hero-sub {
  margin: 0.5rem 0 0;
  font-size: 1.05rem;
  max-width: 46rem;
  opacity: 0.95;
}
.hero--small .hero-sub { display: none; }

/* ---------- nav ---------- */

.site-nav {
  background: var(--brand-darker);
  position: relative; /* not sticky: wrapped nav covered half the viewport */
  z-index: 100;
  box-shadow: var(--shadow);
}
.nav-wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem;
}
.nav-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  list-style: none;
  margin: 0;
  padding: 0.35rem 0;
}
.nav-item { position: relative; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  text-decoration: none;
}
.nav-link:hover, .nav-link[aria-expanded="true"] { background: rgba(255, 255, 255, 0.14); color: var(--gold); }
.nav-link .chev { width: 0.7em; height: 0.7em; transition: transform 0.15s ease; }
.nav-link[aria-expanded="true"] .chev { transform: rotate(180deg); }

.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 16rem;
  max-width: 22rem;
  max-height: 70vh;
  overflow: auto;
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
}
.nav-item.open .dropdown { display: block; }
.dropdown a {
  display: block;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
}
.dropdown a:hover, .dropdown a:focus-visible { background: var(--bg); color: var(--brand-dark); }
.dropdown a[aria-current="page"] { font-weight: 700; color: var(--brand-dark); }

.nav-toggle {
  display: none;
  width: 100%;
  background: none;
  border: 0;
  font: inherit;
  font-weight: 700;
  color: #fff;
  text-align: left;
  padding: 0.8rem 0;
  cursor: pointer;
}
.nav-toggle .chev { float: right; }

/* ---------- search ---------- */

.search-band { background: var(--card); border-bottom: 1px solid var(--border); }
.search-wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem 1.25rem;
}
.search { position: relative; max-width: 44rem; margin: 0 auto; }
.search input {
  width: 100%;
  font: inherit;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: #fff url("../images/icon-search.svg") 0.9rem center / 1.15rem no-repeat;
}
.search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(255, 199, 61, 0.45); }

.search-results {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0; right: 0;
  z-index: 90;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-results ul { list-style: none; margin: 0; padding: 0.3rem; }
.search-results a {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
}
.search-results a .crumb { display: block; font-size: 0.8rem; color: var(--muted); }
.search-results a.active, .search-results a:hover { background: var(--bg); }
.search-results .snippet { display: block; font-size: 0.85rem; color: var(--text); margin-top: 0.15rem; }
.search-status { padding: 0.55rem 0.7rem; color: var(--muted); font-size: 0.9rem; }

/* ---------- layout ---------- */

.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 19rem;
  gap: 1.75rem;
  align-items: start;
}
main { min-width: 0; }

/* ---------- breadcrumbs ---------- */

.breadcrumbs {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 1rem;
}
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0; padding: 0; }
.breadcrumbs li + li::before { content: "›"; margin-right: 0.3rem; color: var(--muted); }
.breadcrumbs [aria-current="page"] { color: var(--text); font-weight: 600; }

/* ---------- cards & lists ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-title { font-size: 1.45rem; margin: 0 0 1rem; }
.section-intro { color: var(--muted); margin: -0.5rem 0 1.25rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
}
.card-grid .card { padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.card-grid .card h3 { margin: 0; font-size: 1.05rem; }
.card-grid .card .crumb { font-size: 0.8rem; color: var(--muted); }
.card-grid .card .card-link { margin-top: auto; font-weight: 600; text-decoration: none; }
.card-grid .card .card-link:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.badge--pdf { background: var(--badge-pdf-bg); color: var(--badge-pdf-text); }
.badge--web { background: var(--badge-web-bg); color: var(--badge-web-text); }

/* topic cards on the main page */
.topic-card h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.topic-card ul { list-style: none; margin: 0; padding: 0; }
.topic-card li + li { margin-top: 0.15rem; }
.topic-card a { text-decoration: none; }
.topic-card a:hover { text-decoration: underline; }
.topic-card details { margin-top: 0.4rem; }
.topic-card summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; font-weight: 600; }

/* resource list on sub-sub pages */
.resource-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.resource-list .card { padding: 0.9rem 1.1rem; }
.resource-list h2 { margin: 0; font-size: 1.08rem; }
.resource-list h2 a { text-decoration: none; color: var(--brand-darker); }
.resource-list h2 a:hover { color: var(--accent); text-decoration: underline; }
.resource-list .meta { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.35rem; font-size: 0.85rem; color: var(--muted); }

/* ---------- resource (article) page ---------- */

.article-head { margin-bottom: 1.25rem; }
.article-head h1 { margin: 0.35rem 0 0.6rem; font-size: 1.8rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  padding: 0.7rem 1.15rem;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn .ext-icon { width: 1em; height: 1em; }
.btn--ghost {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
.btn--ghost:hover { background: var(--badge-pdf-bg); color: var(--brand); }
.article-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.article-body {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.article-body > *:first-child { margin-top: 0; }
.placeholder-note {
  border-left: 4px solid var(--brand);
  background: var(--bg);
  padding: 0.9rem 1.1rem;
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}

/* PDF viewer actions above the inline embed (always shown in "View original layout") */
.pdf-viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.pdf-viewer-actions .btn {
  flex: 1 1 auto;
  min-width: 160px;
  text-align: center;
}
.pdf-embed[hidden] {
  display: none;
}
/* stacked WebP page previews for PDFs whose host blocks framing */
.pdf-page-stack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
}
.pdf-page-stack .pdf-page {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}
.pdf-page .page-label {
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.pdf-page img {
  display: block;
  width: 100%;
  height: auto;
}

/* scanned-document notice (text-reconstructed articles) */
.notice--reconstructed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  border-left: 4px solid var(--crisis);
  background: var(--crisis-bg);
  border-radius: 0 8px 8px 0;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.2rem;
}
.notice--reconstructed p { margin: 0; flex: 1 1 22rem; }
.notice--reconstructed .btn { flex: 0 0 auto; }

/* article view tabs (converted text / original layout) */
.article-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.2rem;
}
.article-tab {
  font: inherit;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 0.55rem 1rem;
  color: var(--muted);
  cursor: pointer;
}
.article-tab:hover { color: var(--brand); }
.article-tab[aria-selected="true"] {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}
.article-tab:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.article-body--pdf { padding: 0; }
.pdf-embed {
  display: block;
  width: 100%;
  height: 80vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.filed-under { margin-top: 1.5rem; font-size: 0.92rem; color: var(--muted); }
.filed-under ul { list-style: none; margin: 0.35rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.filed-under a {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  text-decoration: none;
}
.filed-under a:hover { background: var(--badge-pdf-bg); }

/* ---------- sidebar ---------- */

.sidebar { display: grid; gap: 1.25rem; position: sticky; top: 1rem; }
.sidebar .card { padding: 1.1rem 1.2rem; }
.sidebar h2 { margin: 0 0 0.6rem; font-size: 1.05rem; }

.crisis-card { background: var(--crisis-bg); border: 1px solid var(--crisis-border); }
.crisis-card h2 { color: var(--crisis); }
.crisis-card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.crisis-card strong { color: var(--crisis); }

.useful-links ul { list-style: none; margin: 0; padding: 0; }
.useful-links li + li { border-top: 1px solid var(--border); }
.useful-links a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.1rem;
  text-decoration: none;
}
.useful-links a:hover { text-decoration: underline; }
.useful-links .ext-icon { width: 0.9em; height: 0.9em; flex: none; color: var(--muted); }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 0.85rem;
}
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 1.25rem; }
.site-footer p { margin: 0; }

/* ---------- responsive ---------- */

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
}

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav-menu { display: none; padding-bottom: 0.6rem; }
  .site-nav.nav-open .nav-menu { display: block; }
  .nav-item { width: 100%; }
  .nav-link { width: 100%; justify-content: space-between; }
  .dropdown {
    position: static;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.06);
    padding: 0 0 0.4rem;
  }
  .dropdown a { color: #fff; }
  .dropdown a:hover, .dropdown a:focus-visible { background: rgba(255, 255, 255, 0.12); color: #fff; }
  .dropdown a[aria-current="page"] { color: #fff; }
}

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

/* ---------- brand mark (echoes the VHWF star-emblem wordmark) ---------- */
.site-kicker { font-weight: 700; }
.site-kicker::before {
  content: "★" / "";
  display: inline-block;
  margin-right: 0.45em;
  color: var(--gold);
}
.section-title { color: var(--brand); }
.section-title::after {
  content: "";
  display: block;
  width: 3rem;
  height: 3px;
  margin-top: 0.4rem;
  background: var(--gold-button);
  border-radius: 2px;
}

/* sidebar "useful links" — developer-picked, awaiting client approval */
.link-placeholder {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.4em;
  border-radius: 999px;
  background: var(--badge-pdf-bg);
  color: var(--badge-pdf-text);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}
