/*
Theme Name: SAFE Adults Digital Guide
Theme URI: https://safeaustin.org
Author: Eric Castro
Description: Mobile-first web app theme for the SAFE Adults Digital Guide. Card-based navigation, accordion content, fixed bottom tab bar. Designed for first responders working with adults with disabilities.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: safe-adults
*/

/* ═══════════ CUSTOM PROPERTIES ═══════════ */
:root {
  --navy: #0F1B2D; --navy-light: #1A2840;
  --amber: #D4770B; --amber-light: #E89530;
  --teal: #1B6B8A; --teal-light: #2A96B8;
  --forest: #2D8E5F; --plum: #7B4FA2; --slate: #4A6FA5;
  --coral: #CC6B4F; --wine: #C0392B; --sage: #5B8C5A;
  --indigo: #3A5A8C; --earth: #8B6B4A; --red-accent: #E74C3C;
  --bg: #F2F4F7; --text-muted: #6B7B8D;
  --tab-h: 72px; --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ═══════════ RESET ═══════════ */
*,*::before,*::after { margin:0; padding:0; box-sizing:border-box; }
html { font-size:16px; -webkit-text-size-adjust:100%; -webkit-tap-highlight-color:transparent; }
body {
  font-family:'DM Sans',system-ui,-apple-system,sans-serif;
  background:var(--bg); color:#333; line-height:1.5;
  overflow-x:hidden; -webkit-font-smoothing:antialiased;
}
a { color:inherit; text-decoration:none; }
img { display:block; max-width:100%; }
button { font:inherit; border:none; background:none; cursor:pointer; }
:focus-visible { outline:3px solid var(--amber); outline-offset:2px; border-radius:4px; }

/* ═══════════ APP HEADER ═══════════ */
.app-header {
  position:sticky; top:0; z-index:100;
  background:var(--navy);
  padding:12px 16px 14px;
  padding-top:max(12px, env(safe-area-inset-top));
}
.logo { display:flex; align-items:center; justify-content:center; gap:10px; margin-bottom:12px; }
.logo-safe { font-size:28px; font-weight:800; color:#fff; letter-spacing:1.5px; }
.logo-divider { width:2px; height:28px; background:var(--red-accent); border-radius:1px; flex-shrink:0; }
.logo-tagline { font-size:11px; color:#7B8DA5; line-height:1.3; }
.logo-tagline strong { color:#fff; font-size:15px; font-weight:700; display:block; }
.logo a { display:flex; align-items:center; gap:10px; }
.logo img { height:40px; width:auto; }

.search-bar {
  display:flex; align-items:center; gap:10px;
  background:var(--navy-light); border:1.5px solid rgba(255,255,255,.08);
  border-radius:100px; padding:10px 16px; transition:border-color .2s,background .2s;
}
.search-bar:focus-within { border-color:rgba(212,119,11,.5); background:#1E3050; }
.search-bar svg { width:18px; height:18px; stroke:#5A7093; fill:none; stroke-width:2; flex-shrink:0; }
.search-bar input {
  flex:1; background:none; border:none; outline:none;
  color:#fff; font-size:14px; font-family:inherit;
}
.search-bar input::placeholder { color:#5A7093; }

/* Sub-header */
.sub-header {
  position:sticky; top:0; z-index:100; background:var(--navy);
  padding:10px 16px 12px; padding-top:max(10px, env(safe-area-inset-top));
  display:flex; align-items:center; gap:12px;
}
.sub-header__back {
  width:36px; height:36px; border-radius:50%; background:rgba(255,255,255,.1);
  display:flex; align-items:center; justify-content:center;
  transition:background .15s; flex-shrink:0;
}
.sub-header__back:hover { background:rgba(255,255,255,.18); }
.sub-header__back svg { width:20px; height:20px; stroke:#fff; fill:none; stroke-width:2.5; stroke-linecap:round; stroke-linejoin:round; }
.sub-header__color { width:4px; height:28px; border-radius:2px; flex-shrink:0; }
.sub-header__title { font-size:16px; font-weight:700; color:#fff; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ═══════════ CONTENT ═══════════ */
.content { padding:6px 14px calc(var(--tab-h) + var(--safe-bottom) + 16px); min-height:70vh; }
.section-label {
  font-size:11px; font-weight:700; color:var(--text-muted);
  letter-spacing:.1em; text-transform:uppercase; margin:18px 0 10px 4px;
}

/* ═══════════ CARD GRID ═══════════ */
.grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.card {
  position:relative; overflow:hidden; border-radius:16px; padding:16px;
  min-height:148px; display:flex; flex-direction:column; justify-content:flex-end;
  cursor:pointer; transition:transform .15s ease,box-shadow .2s ease;
  -webkit-user-select:none; user-select:none; color:#fff;
}
.card:hover { transform:translateY(-2px); box-shadow:0 8px 24px -6px rgba(0,0,0,.22); }
.card:active { transform:scale(.97); box-shadow:none; }
.card--tall { min-height:168px; }
.card--full {
  grid-column:1/-1; min-height:auto; flex-direction:row;
  align-items:center; justify-content:space-between; padding:14px 18px; gap:12px;
}
.card__badge {
  width:40px; height:40px; border-radius:11px; background:rgba(255,255,255,.18);
  display:flex; align-items:center; justify-content:center;
  margin-bottom:auto; position:relative; z-index:1;
  backdrop-filter:blur(4px); -webkit-backdrop-filter:blur(4px);
}
.card__badge svg { width:20px; height:20px; stroke:#fff; fill:none; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.card__badge--filled svg { fill:#fff; stroke:none; }
.card__watermark { position:absolute; right:-12px; top:50%; transform:translateY(-50%); opacity:.12; pointer-events:none; }
.card__watermark svg { width:110px; height:110px; stroke:#fff; fill:none; stroke-width:1; }
.card__title { font-size:15px; font-weight:700; color:#fff; line-height:1.25; position:relative; z-index:1; text-shadow:0 1px 3px rgba(0,0,0,.15); }
.card__subtitle { font-size:11px; color:rgba(255,255,255,.7); margin-top:3px; }
.card__arrow {
  width:28px; height:28px; border-radius:50%; background:rgba(255,255,255,.14);
  display:flex; align-items:center; justify-content:center;
  position:absolute; bottom:12px; right:12px; z-index:1; transition:background .15s;
}
.card:hover .card__arrow { background:rgba(255,255,255,.24); }
.card__arrow svg { width:14px; height:14px; stroke:#fff; fill:none; stroke-width:2.5; stroke-linecap:round; stroke-linejoin:round; }
.card--full .card__arrow { position:static; flex-shrink:0; }

.card--amber  { background:linear-gradient(135deg,#C06A08,#E89530); }
.card--teal   { background:linear-gradient(135deg,#155C76,#2A96B8); }
.card--forest { background:linear-gradient(135deg,#247A50,#3DB87A); }
.card--plum   { background:linear-gradient(135deg,#6A4290,#9B6FC2); }
.card--slate  { background:linear-gradient(135deg,#3E6092,#6A8FC5); }
.card--coral  { background:linear-gradient(135deg,#B45A40,#E08B6F); }
.card--wine   { background:linear-gradient(135deg,#A93226,#E74C3C); }
.card--sage   { background:linear-gradient(135deg,#4D7A4C,#7BAC7A); }
.card--indigo { background:linear-gradient(135deg,#314D78,#5A7AAC); }
.card--earth  { background:linear-gradient(135deg,#7A5D40,#AB8B6A); }
.card--navy   { background:linear-gradient(135deg,#0F1B2D,#1A2840); }

/* ═══════════ TAB BAR ═══════════ */
.tab-bar {
  position:fixed; bottom:0; left:0; right:0; z-index:100;
  height:calc(var(--tab-h) + var(--safe-bottom));
  background:rgba(255,255,255,.92); backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px);
  border-top:1px solid #E2E8F0;
  display:flex; align-items:flex-start; justify-content:space-around;
  padding:0 4px; padding-bottom:var(--safe-bottom);
}
.tab {
  display:flex; flex-direction:column; align-items:center; gap:3px;
  padding:8px 14px 4px; border-radius:8px; position:relative;
  transition:background .15s; min-width:60px;
}
.tab:hover { background:rgba(15,27,45,.04); }
.tab svg { width:22px; height:22px; stroke:#8A9BB5; fill:none; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; transition:stroke .15s; }
.tab span { font-size:10px; font-weight:500; color:#8A9BB5; letter-spacing:.02em; transition:color .15s; }
.tab--active svg { stroke:var(--navy); stroke-width:2; }
.tab--active span { color:var(--navy); font-weight:700; }
.tab--active::before {
  content:''; position:absolute; top:0; left:50%; transform:translateX(-50%);
  width:28px; height:3px; background:var(--amber); border-radius:0 0 3px 3px;
}

/* ═══════════ GUIDE HERO ═══════════ */
.guide-hero { padding:24px 18px 20px; color:#fff; position:relative; overflow:hidden; }
.guide-hero__watermark { position:absolute; right:-20px; bottom:-20px; opacity:.1; }
.guide-hero__watermark svg { width:160px; height:160px; stroke:#fff; fill:none; stroke-width:.8; }
.guide-hero h1 { font-size:22px; font-weight:800; line-height:1.2; margin-bottom:6px; position:relative; z-index:1; }
.guide-hero p { font-size:13px; opacity:.8; line-height:1.5; position:relative; z-index:1; }

.guide-nav {
  display:flex; gap:8px; padding:14px 18px; overflow-x:auto;
  scrollbar-width:none; -webkit-overflow-scrolling:touch;
}
.guide-nav::-webkit-scrollbar { display:none; }
.guide-pill {
  flex-shrink:0; padding:8px 16px; border-radius:100px;
  font-size:13px; font-weight:600; white-space:nowrap;
  background:#fff; color:var(--navy); border:1.5px solid #E2E8F0; transition:all .15s;
}
.guide-pill:hover { border-color:var(--amber); color:var(--amber); }
.guide-pill.is-active { background:var(--navy); color:#fff; border-color:var(--navy); }

/* ═══════════ ACCORDION ═══════════ */
.accordion { padding:0 14px; }
.accordion-item {
  background:#fff; border-radius:14px; margin-bottom:10px;
  box-shadow:0 1px 3px rgba(0,0,0,.06); overflow:hidden;
  /*border:1px solid #E8ECF0; transition:box-shadow .2s;*/
	border: 1px solid #999;
}
.accordion-item:hover { box-shadow:0 2px 8px rgba(0,0,0,.08); }
.accordion-trigger {
  width:100%; text-align:left; padding:16px 18px;
  display:flex; align-items:center; gap:12px;
  font-size:15px; font-weight:700; color:var(--navy);
  background:none; transition:background .15s; cursor:pointer;
}
.accordion-trigger:hover { background:#F8F9FB; }
.accordion-trigger__icon {
  width:28px; height:28px; border-radius:8px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  position:relative; overflow:hidden;
}
.accordion-trigger__icon svg { width:14px; height:14px; stroke:#fff; fill:none; stroke-width:2.5; stroke-linecap:round; stroke-linejoin:round; position:relative; z-index:1; transition:transform .25s ease; }
.accordion-item.is-open .accordion-trigger__icon svg { transform:rotate(45deg); }
.accordion-trigger__chevron { margin-left:auto; width:20px; height:20px; flex-shrink:0; transition:transform .25s ease; }
.accordion-trigger__chevron svg { width:20px; height:20px; stroke:#9CA3AF; fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.accordion-item.is-open .accordion-trigger__chevron { transform:rotate(180deg); }
.accordion-item.is-open .accordion-trigger { background:#F8F9FB; }
.accordion-body { max-height:0; overflow:hidden; transition:max-height .35s ease; }
.accordion-body__inner { padding:0 18px 18px; font-size:14px; line-height:1.7; color:#444; }

.acc-tip {
  padding:10px 0 10px 14px; border-left:3px solid #E8ECF0;
  margin-bottom:8px; transition:border-color .15s,background .3s;
}
.acc-tip:hover { border-left-color:var(--amber); }
.acc-tip strong { color:var(--navy); font-weight:600; }
.acc-tip em { color:#666; }
.acc-subsection { margin-top:16px; }
.acc-subsection__title {
  font-size:13px; font-weight:700; color:var(--navy);
  text-transform:uppercase; letter-spacing:.06em;
  margin-bottom:8px; padding-bottom:6px; border-bottom:2px solid #E8ECF0;
}

/* ═══════════ PAGE CONTENT ═══════════ */
.page-content { padding:24px 18px calc(var(--tab-h) + var(--safe-bottom) + 20px); }
.page-content h1 { font-size:22px; font-weight:800; color:var(--navy); margin-bottom:12px; }
.page-content h2 { font-size:18px; font-weight:700; color:var(--navy); margin:20px 0 8px; }
.page-content p { color:#555; font-size:14px; line-height:1.7; margin-bottom:14px; }
.page-content ul,.page-content ol { padding-left:20px; margin-bottom:14px; }
.page-content li { font-size:14px; line-height:1.7; color:#555; margin-bottom:6px; }
.page-content a { color:var(--amber); text-decoration:underline; }

/* ═══════════ SEARCH ═══════════ */
.search-overlay {
  display:none; position:fixed; inset:0; z-index:200;
  background:rgba(15,27,45,.6); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
  opacity:0; transition:opacity .2s;
}
.search-overlay.is-open { display:flex; flex-direction:column; opacity:1; }
.search-overlay__header { background:var(--navy); padding:12px 16px 16px; padding-top:max(12px, env(safe-area-inset-top)); }
.search-overlay__bar { display:flex; align-items:center; gap:10px; background:var(--navy-light); border:1.5px solid rgba(212,119,11,.4); border-radius:100px; padding:10px 16px; }
.search-overlay__bar input { flex:1; background:none; border:none; outline:none; color:#fff; font-size:15px; font-family:inherit; }
.search-overlay__bar input::placeholder { color:#5A7093; }
.search-overlay__close { color:#7B8DA5; padding:4px; border-radius:50%; }
.search-overlay__close:hover { background:rgba(255,255,255,.1); }
.search-overlay__close svg { width:20px; height:20px; stroke:currentColor; fill:none; stroke-width:2; }
.search-overlay__body { flex:1; overflow-y:auto; padding:20px 16px; }
.search-overlay__hint { text-align:center; color:#7B8DA5; font-size:14px; padding-top:40px; }

/* ═══════════ RESPONSIVE ═══════════ */

/* Shared max-width variable for alignment between search bar, content, and tab bar */
:root { --content-max: 600px; }

/* Tablet */
@media(min-width:480px) {
  .content,.page-content { max-width:var(--content-max); margin-left:auto; margin-right:auto; }
  .content { padding-left:20px; padding-right:20px; }
  .accordion { max-width:var(--content-max); margin-left:auto; margin-right:auto; }
  .guide-hero,.guide-nav { max-width:var(--content-max); margin-left:auto; margin-right:auto; }
}

/* Small desktop */
@media(min-width:768px) {
  :root { --content-max: 720px; }

  /* Header — full-width bg, search constrained to content width */
  .app-header { display:flex; flex-direction:column; align-items:center; }
  .app-header .logo { width:100%; justify-content:center; }
  .app-header .search-bar { width:100%; max-width:var(--content-max); }

  /* Tab bar aligns with content */
  .tab-bar { max-width:var(--content-max); left:50%; transform:translateX(-50%); border-radius:16px 16px 0 0; border-left:1px solid #E2E8F0; border-right:1px solid #E2E8F0; }

  /* Grid — 3-col, cards stretch to fill */
  .grid { grid-template-columns:repeat(3, 1fr); gap:14px; }
  .card { min-height:180px; padding:18px; }
  .card--tall { min-height:180px; }
  .card--full { grid-column:1/-1; }
  .card__title { font-size:16px; }

  /* Accordion — full width within container */
  .accordion { padding:0; }
  .accordion-item { border-radius:16px; }
  .accordion-trigger { padding:18px 22px; font-size:16px; }
  .accordion-body__inner { padding:0 22px 22px; font-size:15px; }

  .guide-hero h1 { font-size:26px; }
  .guide-hero p { font-size:14px; }
  .page-content h1 { font-size:26px; }
  .page-content p { font-size:15px; }
}

/* Large desktop */
@media(min-width:1024px) {
  :root { --content-max: 960px; }

  .grid { grid-template-columns:repeat(4, 1fr); gap:16px; }
  .card { min-height:210px; padding:22px; border-radius:20px; }
  .card--tall { min-height:220px; }
  .card__badge { width:44px; height:44px; border-radius:12px; }
  .card__badge svg { width:22px; height:22px; }
  .card__watermark svg { width:130px; height:130px; }
  .card__title { font-size:17px; }
  .card__arrow { width:32px; height:32px; }
  .guide-hero { padding:32px 28px 28px; }
  .guide-hero h1 { font-size:30px; }
  .guide-hero p { font-size:15px; }
  .guide-nav { padding:16px 0; gap:10px; }
  .guide-pill { padding:10px 20px; font-size:14px; }
  .accordion-trigger { padding:20px 24px; font-size:17px; }
  .accordion-body__inner { padding:0 24px 24px; }
  .acc-tip { padding:12px 0 12px 16px; font-size:15px; }
  .page-content { padding:32px 28px calc(var(--tab-h) + var(--safe-bottom) + 24px); }
  .page-content h1 { font-size:30px; margin-bottom:16px; }
  .page-content p { font-size:15px; line-height:1.8; }
}

/* Wide desktop */
@media(min-width:1280px) {
  :root { --content-max: 1200px; }

  .grid { gap:18px; }
  .card { min-height:230px; padding:24px; }
  .card--tall { min-height:240px; }
  .card__title { font-size:18px; }
  .card__watermark svg { width:150px; height:150px; }
  .section-label { font-size:12px; margin:24px 0 14px 4px; }
}

/* Extra-wide desktop */
@media(min-width:1600px) {
  :root { --content-max: 1400px; }

  .grid { gap:20px; }
  .card { min-height:260px; padding:28px; border-radius:22px; }
  .card--tall { min-height:270px; }
  .card__badge { width:48px; height:48px; border-radius:14px; }
  .card__badge svg { width:24px; height:24px; }
  .card__watermark svg { width:170px; height:170px; }
  .card__title { font-size:20px; line-height:1.3; }
  .card__arrow { width:36px; height:36px; }
  .guide-hero { padding:40px 36px 36px; }
  .guide-hero h1 { font-size:34px; }
  .guide-hero p { font-size:16px; }
  .guide-pill { padding:12px 24px; font-size:15px; }
  .accordion-trigger { padding:22px 28px; font-size:18px; }
  .accordion-body__inner { padding:0 28px 28px; font-size:16px; }
  .acc-tip { font-size:16px; }
}

/* ═══════════ BACKGROUND IMAGE / PATTERN SUPPORT ═══════════ */
/*
 * USAGE: Add one of these classes to the <body> tag.
 * In WordPress, this is done via functions.php body_class filter
 * or through the Customizer → Background settings.
 *
 * CSS-only patterns (no image file needed):
 *   has-bg-dots          Subtle dot grid
 *   has-bg-grid          Fine graph-paper lines
 *   has-bg-gradient      Warm ambient gradient (light)
 *   has-bg-gradient-cool Cool blue-grey gradient (light)
 *   has-bg-topography    Topographic contour lines
 *
 * Custom image:
 *   has-bg-image         Uses --bg-image CSS variable
 *   Example in Customizer Additional CSS:
 *     body.has-bg-image { --bg-image: url('/wp-content/uploads/bg.jpg'); }
 *
 * SUGGESTED IMAGES (royalty-free):
 *   - Soft abstract watercolor wash (blues/greys)
 *   - Subtle linen or paper texture
 *   - Blurred cityscape or nature (very low contrast)
 *   - Geometric low-poly pattern in navy/grey tones
 *   Good sources: unsplash.com, heropatterns.com, svgbackgrounds.com
 */

/* Custom image background */
body.has-bg-image {
  background: var(--bg) var(--bg-image, none) center/cover fixed no-repeat;
}

/* Dot pattern */
body.has-bg-dots {
  background-color: var(--bg);
  background-image: radial-gradient(circle, #C5CDD8 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Grid / graph-paper pattern */
body.has-bg-grid {
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(0,0,0,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.04) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* Warm ambient gradient */
body.has-bg-gradient {
  background: linear-gradient(135deg, #E8EDF4 0%, #F2F4F7 30%, #F7F0E8 60%, #EEF1F6 100%);
  background-attachment: fixed;
}

/* Cool blue-grey gradient */
body.has-bg-gradient-cool {
  background: linear-gradient(160deg, #E4EAF2 0%, #EEF1F6 35%, #E8ECF4 65%, #F0F3F8 100%);
  background-attachment: fixed;
}

/* Topographic contour lines */
body.has-bg-topography {
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cpath d='M306 534c-53 0-97-30-126-56s-53-63-53-63 29-37 53-63c29-26 73-56 126-56s97 30 126 56 53 63 53 63-29 37-53 63c-29 26-73 56-126 56z' fill='none' stroke='%23CDD5DF' stroke-opacity='.25' stroke-width='1'/%3E%3Cpath d='M306 490c-37 0-68-22-90-42s-40-48-40-48 18-28 40-48c22-20 53-42 90-42s68 22 90 42 40 48 40 48-18 28-40 48c-22 20-53 42-90 42z' fill='none' stroke='%23CDD5DF' stroke-opacity='.2' stroke-width='1'/%3E%3Cpath d='M306 450c-23 0-42-14-56-28s-26-33-26-33 12-19 26-33c14-14 33-28 56-28s42 14 56 28 26 33 26 33-12 19-26 33c-14 14-33 28-56 28z' fill='none' stroke='%23CDD5DF' stroke-opacity='.15' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 300px 300px;
}

/* Shared rules for all backgrounds */
body[class*='has-bg-'] .card { box-shadow:0 2px 12px rgba(0,0,0,.1); }
body[class*='has-bg-'] .accordion-item { box-shadow:0 2px 10px rgba(0,0,0,.08); }
body[class*='has-bg-'] .tab-bar { background:rgba(255,255,255,.96); }

/* ═══════════ ANIMATIONS ═══════════ */
@keyframes fadeUp { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
.card { animation:fadeUp .4s ease both; }
.grid .card:nth-child(1){animation-delay:.05s} .grid .card:nth-child(2){animation-delay:.1s}
.grid .card:nth-child(3){animation-delay:.14s} .grid .card:nth-child(4){animation-delay:.18s}
.grid .card:nth-child(5){animation-delay:.22s} .grid .card:nth-child(6){animation-delay:.26s}
.grid .card:nth-child(7){animation-delay:.3s} .grid .card:nth-child(8){animation-delay:.34s}
@media(prefers-reduced-motion:reduce) { .card{animation:none} }

/* WP Admin bar fix */
body.admin-bar .app-header, body.admin-bar .sub-header { top:32px; }
@media(max-width:782px) { body.admin-bar .app-header, body.admin-bar .sub-header { top:46px; } }
