/* Homeless Mpowerment — Main Stylesheet
   Mobile-first, high-contrast, accessible design */

/* ── Reset and Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --accent: #e67e22;
  --accent-light: #f39c12;
  --emergency: #c0392b;
  --emergency-light: #e74c3c;
  --success: #27ae60;
  --bg: #fafafa;
  --bg-card: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #e0e0e0;
  --focus: #3498db;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-size: 18px;
}

html {
  font-size: var(--font-size);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ── Typography ── */
h1 { font-size: 1.8rem; line-height: 1.2; }
h2 { font-size: 1.4rem; line-height: 1.3; }
h3 { font-size: 1.15rem; }
p { margin-bottom: 0.75rem; }

a { color: var(--primary-light); text-decoration: underline; text-underline-offset: 2px; }
a:hover, a:focus { color: var(--primary); }

/* ── Skip Link ── */
.skip-link {
  position: absolute; top: -100%; left: 0; z-index: 1000;
  padding: 0.5rem 1rem; background: var(--primary); color: #fff;
  text-decoration: none; font-weight: bold;
}
.skip-link:focus { top: 0; }

/* ── Header ── */
.site-header {
  background: var(--primary);
  color: #fff;
  padding: 1rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.site-header-inner {
  max-width: 800px; margin: 0 auto;
  display: flex; align-items: center; gap: 0.75rem;
}

.site-logo {
  font-size: 1.3rem; font-weight: 800;
  line-height: 1.1;
  display: flex; align-items: center; gap: 0.5rem;
}
.logo-icon { border-radius: 4px; flex-shrink: 0; }
.site-logo span { display: block; font-size: 0.7rem; font-weight: 400; opacity: 0.85; }

.header-nav { margin-left: auto; display: flex; gap: 0.5rem; }
.header-nav a {
  color: #fff; text-decoration: none; padding: 0.4rem 0.75rem;
  border-radius: var(--radius); font-size: 0.9rem;
  background: rgba(255,255,255,0.1);
}
.header-nav a:hover, .header-nav a:focus {
  background: rgba(255,255,255,0.2);
}

/* ── Emergency Banner ── */
.emergency-banner {
  background: var(--emergency);
  color: #fff;
  padding: 1rem;
  text-align: center;
}
.emergency-banner h2 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.emergency-banner p { margin-bottom: 0.4rem; }

.emergency-numbers {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem;
  margin-top: 0.5rem;
}
.emergency-numbers a {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  color: #fff;
  text-decoration: none;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius);
  font-weight: bold;
  font-size: 1.1rem;
  border: 2px solid rgba(255,255,255,0.3);
}
.emergency-numbers a:hover, .emergency-numbers a:focus {
  background: rgba(255,255,255,0.35);
}

/* ── Main Content ── */
main { max-width: 800px; margin: 0 auto; padding: 1rem; }

.page-section { margin-bottom: 2rem; }

/* ── Hero / Entry Point ── */
.hero {
  text-align: center;
  padding: 2rem 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.hero h1 { margin-bottom: 0.5rem; }
.hero p { color: var(--text-light); font-size: 1.05rem; margin-bottom: 0; }

/* ── Search ── */
.search-box {
  position: relative;
  margin-bottom: 1.5rem;
}
.search-box input {
  width: 100%;
  padding: 0.9rem 1rem 0.9rem 3rem;
  font-size: 1.05rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: border-color 0.2s;
}
.search-box input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(52,152,219,0.2);
}
.search-icon {
  position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
  font-size: 1.2rem; color: var(--text-light);
}

/* ── Category Grid ── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.category-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding: 1rem 0.75rem;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.category-card:hover, .category-card:focus {
  border-color: var(--primary-light);
  box-shadow: 0 2px 8px rgba(41,128,185,0.15);
}
.category-card.active {
  border-color: var(--primary-light);
  background: #ebf5fb;
}

.category-icon { font-size: 1.6rem; line-height: 1; }
.category-label { font-size: 0.85rem; font-weight: 600; line-height: 1.2; }

/* ── Filter Bar ── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.filter-bar label { font-size: 0.9rem; font-weight: 600; }
.filter-btn {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.filter-btn:hover, .filter-btn:focus { border-color: var(--primary-light); }
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Results List ── */
.results-info {
  font-size: 0.9rem; color: var(--text-light); margin-bottom: 0.75rem;
}

.resource-list { list-style: none; }

.resource-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.resource-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

.resource-link {
  display: block;
  padding: 1rem;
  text-decoration: none;
  color: var(--text);
}
.resource-link:focus { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: var(--radius); }

.resource-name { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.25rem; }
.resource-org { font-size: 0.9rem; color: var(--text-light); margin-bottom: 0.25rem; }
.resource-summary { font-size: 0.9rem; margin-bottom: 0.25rem; }
.resource-meta {
  font-size: 0.8rem; color: var(--text-light);
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.resource-meta span { display: inline-flex; align-items: center; gap: 0.25rem; }
.verified-badge { color: var(--success); font-weight: 600; }

/* ── Resource Detail ── */
.detail-header { margin-bottom: 1rem; }
.detail-header h2 { margin-bottom: 0.25rem; }
.detail-org { color: var(--text-light); font-size: 1rem; }

.detail-section { margin-bottom: 1rem; }
.detail-section h3 {
  font-size: 1rem; margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.detail-actions {
  display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem;
}
.detail-actions a {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
}
.btn-call { background: var(--success); color: #fff; }
.btn-call:hover { background: #219a52; }
.btn-directions { background: var(--primary); color: #fff; }
.btn-directions:hover { background: #154360; }
.btn-website { background: var(--bg-card); color: var(--text); border: 2px solid var(--border); }
.btn-website:hover { border-color: var(--primary-light); }

/* ── No-JS Fallback ── */
.no-js-message { display: block; }
.has-js .no-js-message { display: none; }

/* ── Fixed-bottom Call Button (mobile) ── */
.mobile-call-bar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--primary); padding: 0.6rem;
  z-index: 200;
}
.mobile-call-bar a {
  display: block; text-align: center;
  background: var(--success); color: #fff;
  padding: 0.7rem; border-radius: var(--radius);
  text-decoration: none; font-weight: bold; font-size: 1.1rem;
}

/* ── Footer ── */
.site-footer {
  background: var(--primary);
  color: rgba(255,255,255,0.85);
  padding: 1.5rem 1rem;
  margin-top: 2rem;
}
.footer-inner { max-width: 800px; margin: 0 auto; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 0.75rem; }
.footer-links a { color: rgba(255,255,255,0.85); text-decoration: underline; }
.footer-disclaimer { font-size: 0.8rem; opacity: 0.8; }

/* ── Privacy & Correction Pages ── */
.content-page { max-width: 700px; margin: 0 auto; padding: 1rem; line-height: 1.6; }
.content-page h1 { margin-bottom: 1rem; }
.content-page h2 { margin-top: 1.5rem; margin-bottom: 0.5rem; }

/* ── Correction Form ── */
.correction-form { max-width: 600px; margin: 1.5rem auto; }
.correction-form label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.correction-form input,
.correction-form textarea,
.correction-form select {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  margin-bottom: 1rem;
  font-family: var(--font);
}
.correction-form input:focus,
.correction-form textarea:focus {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(52,152,219,0.2);
}
.correction-form .form-note { font-size: 0.85rem; color: var(--text-light); margin-top: -0.75rem; margin-bottom: 1rem; }
.correction-form button {
  background: var(--primary); color: #fff; border: none;
  padding: 0.9rem 2rem; font-size: 1.05rem; border-radius: var(--radius);
  cursor: pointer; font-weight: 600;
}
.correction-form button:hover { background: var(--primary-light); }

/* ── 404 Page ── */
.error-page { text-align: center; padding: 3rem 1rem; }
.error-page h1 { font-size: 3rem; color: var(--text-light); margin-bottom: 0.5rem; }
.error-page p { font-size: 1.1rem; margin-bottom: 1rem; }

/* ── Print Styles ── */
@media print {
  .site-header, .emergency-banner, .mobile-call-bar, .site-footer { display: none; }
  .resource-item { break-inside: avoid; border: 1px solid #000; }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  :root { --font-size: 16px; }
  .category-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .emergency-numbers { flex-direction: column; align-items: stretch; }
  .emergency-numbers a { text-align: center; }
  .detail-actions { flex-direction: column; }
  .detail-actions a { justify-content: center; }
  .mobile-call-bar { display: block; }
  main { padding-bottom: 4rem; }
}

@media (min-width: 768px) {
  .category-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Focus Styles for Keyboard Nav ── */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ── Screen Reader Only ── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* ── High Contrast Support ── */
@media (prefers-contrast: high) {
  :root {
    --primary: #0d2b45;
    --emergency: #8b0000;
    --text: #000;
    --bg: #fff;
    --border: #000;
  }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}