/* ============================================================
   USGenWeb search tool — shared stylesheet (index.html + methodology.html)
   Matches the EvidenceToolbox design system defined in CLAUDE.md.
   Site chrome (header/nav/cards/buttons/footer) is copied from the
   Negative Search Generator reference page; tool-specific components
   (form controls, chips, badges, result cards, pager) follow below.
   ============================================================ */

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

:root {
  --navy:      #1F3B57;
  --navy-dark: #17304a;
  --teal:      #1C8C8C;
  --teal-dark: #166f6f;
  --gold:      #D9A441;
  --cream:     #F7F3EC;
  --white:     #FFFFFF;
  --text:      #111111;
}

html { font-size: 17px; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--cream);
  color: var(--text);
  line-height: 1.6;
}

/* ── HEADER ── */
header {
  background: var(--navy);
  text-align: center;
  padding: 40px 20px;
  position: relative;
  overflow: hidden;
}
header .texture {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.18;
}
header .header-content { position: relative; z-index: 1; }
header h1 {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 2.4rem;
  letter-spacing: 1px;
  color: var(--white);
}
header .tagline {
  font-family: 'Lora', serif;
  font-style: italic;
  font-size: 1.2rem;
  color: var(--gold);
  margin-top: 8px;
}

/* ── NAV ── */
nav.site-nav {
  background: var(--navy-dark);
  border-bottom: 2px solid var(--teal);
  padding: 10px 20px;
}
nav.site-nav ul {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}
nav.site-nav a {
  color: var(--white);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
nav.site-nav a:hover,
nav.site-nav a.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ── LAYOUT ── */
main { padding-bottom: 60px; }
.hero {
  max-width: 900px;
  margin: 40px auto 0;
  padding: 0 20px;
}
.hero h2 {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 1.9rem;
  color: var(--navy);
  margin-bottom: 10px;
}
.hero .hero-sub { font-size: 1.05rem; color: #444; max-width: 760px; }

section {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 20px;
}
section > p { margin-bottom: 14px; }
section > p:last-child { margin-bottom: 0; }

hr.section-divider {
  border: none;
  border-top: 1px solid #ddd;
  margin: 40px auto;
  max-width: 900px;
}

h2.section-title {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 1.9rem;
  color: var(--navy);
  margin-bottom: 16px;
}
h3.sub-title {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--navy);
  margin: 24px 0 8px;
}

/* ── CARD ── */
article.card {
  background: var(--white);
  border-left: 6px solid var(--teal);
  border-radius: 0 6px 6px 0;
  padding: 24px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  margin-bottom: 20px;
}
article.card h3 {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--navy);
  margin-top: 0;
  margin-bottom: 12px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-block;
  background: var(--teal);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 4px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}
.btn:hover { background: var(--teal-dark); }
.btn:disabled { background: #9bbfbf; cursor: not-allowed; }

/* ── FOOTER ── */
footer {
  background: var(--navy);
  color: var(--white);
  text-align: center;
  padding: 20px;
  font-size: 0.9rem;
  margin-top: 40px;
}
footer .footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 8px;
}
footer a {
  color: var(--white);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}
footer a:hover { color: var(--gold); }

/* ── SUPPORT NOTE / SUBSCRIBE ── */
.support-note { margin-top: 14px; font-size: 0.9rem; color: #555; }
.support-note a { color: var(--teal); text-decoration: none; }
.support-note a:hover { color: var(--teal-dark); text-decoration: underline; }

/* ── LIST STYLING (teal dot bullets, per design system) ── */
ul.dot-list { list-style: none; padding: 0; margin: 10px 0 14px 0; }
ul.dot-list li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 12px;
  line-height: 1.6;
}
ul.dot-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
}

/* ── NUMBERED STEPS (intro prose) ── */
ol.tool-steps {
  max-width: 760px;
  margin: 0 0 14px 1.2rem;
  color: #333;
}
ol.tool-steps li {
  margin-bottom: 10px;
  line-height: 1.6;
}

/* ── FAQ ── */
.faq-item { margin-bottom: 24px; }
.faq-item:last-child { margin-bottom: 0; }
.faq-q { font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.faq-a a { color: var(--teal); text-decoration: none; }
.faq-a a:hover { color: var(--teal-dark); text-decoration: underline; }

/* ============================================================
   SEARCH FORM
   ============================================================ */

#search-form .field { margin-bottom: 18px; }
#search-form label.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}
#search-form input[type="text"],
#search-form input[type="number"],
#search-form select {
  width: 100%;
  border: 1px solid #999;
  border-radius: 4px;
  padding: 11px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
}
#search-form input:focus,
#search-form select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(28,140,140,0.15);
}
#search-form input:disabled {
  background: #eee;
  color: #888;
  cursor: not-allowed;
}

.sub-caption {
  font-size: 0.85rem;
  color: #666;
  margin-top: 5px;
}

.field-error {
  color: #a33;
  font-size: 0.88rem;
  margin-top: 5px;
}

/* Variant toggle — labeled switch */
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
}
.switch-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: #bbb;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.switch-row input[type="checkbox"]:checked { background: var(--teal); }
.switch-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--white);
  transition: left 0.2s;
}
.switch-row input[type="checkbox"]:checked::after { left: 23px; }
.switch-row input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--teal-dark);
  outline-offset: 2px;
}

/* Proximity radio group */
#proximity-group {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
#proximity-group legend {
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0 6px;
}
.prox-option { margin-bottom: 10px; }
.prox-option:last-of-type { margin-bottom: 0; }
.prox-option label { font-weight: 600; cursor: pointer; }
.prox-option .prox-desc {
  font-size: 0.85rem;
  color: #666;
  margin-left: 26px;
}
.prox-caveat {
  font-size: 0.85rem;
  color: #7a5b1e;
  background: #faf3e3;
  border-left: 4px solid var(--gold);
  border-radius: 0 4px 4px 0;
  padding: 8px 12px;
  margin-top: 10px;
}

/* Refine accordion */
details.refine {
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 18px;
  background: #fbfaf7;
}
details.refine summary {
  cursor: pointer;
  font-weight: 600;
  padding: 12px 16px;
  color: var(--navy);
}
details.refine[open] summary { border-bottom: 1px solid #eee; }
details.refine .refine-body { padding: 14px 16px; }
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px 16px;
  margin-bottom: 14px;
}
.type-grid label { font-size: 0.95rem; cursor: pointer; }
.type-grid input { margin-right: 6px; accent-color: var(--teal); }
#untagged-row {
  border-top: 1px dashed #ddd;
  padding-top: 12px;
  margin-bottom: 14px;
}
#untagged-row input { margin-right: 6px; accent-color: var(--teal); }
.years-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: end;
  border-top: 1px dashed #ddd;
  padding-top: 12px;
}
.years-row .field { margin-bottom: 0; flex: 1; min-width: 120px; }

#search-btn { min-width: 160px; }
#search-btn .spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: var(--white);
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   RESULTS AREA
   ============================================================ */

#scope-header {
  font-size: 0.95rem;
  color: #444;
  margin-bottom: 12px;
}
#scope-header a { color: var(--teal); text-decoration: none; }
#scope-header a:hover { text-decoration: underline; }

/* Variant disclosure + refinement chips */
.disclosure-line {
  font-size: 0.92rem;
  margin-bottom: 10px;
}
.chip {
  display: inline-block;
  background: #ecf4f4;
  border: 1px solid var(--teal);
  color: var(--navy);
  border-radius: 12px;
  padding: 2px 12px;
  font-size: 0.85rem;
  margin: 2px 4px 2px 0;
}
.chip-warn {
  display: inline-block;
  background: #faf3e3;
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: #6b4f16;
  padding: 6px 12px;
  font-size: 0.9rem;
}
.chip-neutral {
  display: inline-block;
  background: #efece5;
  border: 1px solid #bbb;
  border-radius: 4px;
  color: #555;
  padding: 6px 12px;
  font-size: 0.9rem;
}
.chip-expander {
  background: none;
  border: none;
  color: var(--teal);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.refine-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
  border: 1px solid var(--teal);
  color: var(--navy);
  border-radius: 14px;
  padding: 3px 6px 3px 12px;
  font-size: 0.85rem;
  margin: 2px 6px 2px 0;
}
.refine-chip button {
  background: none;
  border: none;
  color: var(--teal-dark);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 50%;
}
.refine-chip button:hover { background: #ecf4f4; }

#count-line {
  font-weight: 600;
  color: var(--navy);
  margin: 14px 0;
}

/* Result cards */
article.result-card {
  background: var(--white);
  border-left: 6px solid var(--teal);
  border-radius: 0 6px 6px 0;
  padding: 18px 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  margin-bottom: 20px;
}
article.result-card h3 {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 1.1rem;
  margin: 0 0 6px;
  overflow-wrap: anywhere;
}
article.result-card h3 a { color: var(--navy); text-decoration: none; }
article.result-card h3 a:hover { color: var(--teal-dark); text-decoration: underline; }
.loc-line {
  font-size: 0.92rem;
  color: #333;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.snippet {
  font-size: 0.97rem;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}
.snippet b { color: var(--teal-dark); font-weight: 700; }
.meta-line {
  font-size: 0.83rem;
  color: #666;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.type-chip {
  background: #f0ede6;
  border-radius: 10px;
  padding: 1px 10px;
  cursor: default;
}
.raw-url { color: #888; overflow-wrap: anywhere; }

/* Coverage tier badges */
.badge {
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 3px;
  padding: 1px 8px;
  border: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}
.badge.tier-substantial { background: var(--teal); color: var(--white); }
.badge.tier-moderate { background: var(--gold); color: #3d2e0a; }
.badge.tier-limited { background: #d8d4cc; color: #444; }
.badge.tier-unrated { background: var(--white); color: #777; border: 1px solid #bbb; }
.badge-wrap { position: relative; display: inline-block; }
.badge-tip {
  display: none;
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  width: 290px;
  max-width: 80vw;
  background: var(--navy);
  color: var(--white);
  font-size: 0.83rem;
  font-weight: 400;
  line-height: 1.5;
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.badge-tip a { color: var(--gold); }
.badge-wrap.open .badge-tip,
.badge-wrap:hover .badge-tip,
.badge-wrap:focus-within .badge-tip { display: block; }
.pdf-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: #8a6614;
  border: 1px solid var(--gold);
  border-radius: 3px;
  padding: 0 8px;
  cursor: default;
}

/* Zero-results and error states */
.state-card {
  background: var(--white);
  border-left: 6px solid var(--gold);
  border-radius: 0 6px 6px 0;
  padding: 24px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.state-card h3 {
  font-family: 'Lora', serif;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 10px;
}
.state-card p { margin-bottom: 12px; }
.state-card p:last-child { margin-bottom: 0; }
.state-card a { color: var(--teal); }

/* Skeleton loading (PROGRESSIVE_LOAD = true path) */
.skeleton-card {
  background: var(--white);
  border-left: 6px solid #ddd;
  border-radius: 0 6px 6px 0;
  padding: 18px 20px;
  margin-bottom: 20px;
  height: 110px;
  position: relative;
  overflow: hidden;
}
.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,0.05), transparent);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

/* Pagination */
#pager {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 24px 0 6px;
}
#pager button {
  background: var(--white);
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 7px 13px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--navy);
}
#pager button:hover:not(:disabled) { border-color: var(--teal); color: var(--teal-dark); }
#pager button[aria-current="page"] {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--white);
  font-weight: 600;
}
#pager button:disabled { color: #bbb; cursor: not-allowed; }
#pager .pager-ellipsis { color: #888; padding: 0 2px; }
.pager-cap-note {
  text-align: center;
  font-size: 0.88rem;
  color: #666;
  margin-bottom: 10px;
}

/* Staleness footer line */
.staleness-note {
  max-width: 900px;
  margin: 30px auto 0;
  padding: 0 20px;
  font-size: 0.83rem;
  color: #777;
  font-style: italic;
}

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  header h1 { font-size: 1.8rem; }
  .hero h2 { font-size: 1.5rem; }
  h2.section-title { font-size: 1.5rem; }
  nav.site-nav ul { gap: 1rem; }
  #search-btn { width: 100%; text-align: center; }
  .years-row { flex-direction: column; align-items: stretch; }
  .type-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .type-grid { grid-template-columns: 1fr; }
}
