/* AgeManagement.com — readable, calm, and a bit more colorful
   Notes:
   - Larger type by default
   - Comfortable tap targets
   - High-contrast “Comfort” mode supported via body.contrast
*/

:root{
  /* Core palette */
  --bg: #f7fafc;
  --surface: #ffffff;
  --text: #102a43;
  --muted: #486581;
  --border: #d9e2ec;

  /* Brand + accents */
  --primary-rgb: 11, 74, 111;
  --primary2-rgb: 15, 118, 110;
  --accent-rgb: 180, 83, 9;

  /* Topic/section accent (overridden per page/card via [data-theme]) */
  --theme-accent: var(--primary-2);
  --theme-accent-rgb: var(--primary2-rgb);


  --primary: #0b4a6f;   /* deep blue-teal */
  --primary-2: #0f766e; /* teal */
  --accent: #b45309;    /* warm amber */
  --danger: #b91c1c;
  --success: #166534;
  --info: #0b57d0;

  --link: var(--info);
  --link-visited: #5a2ca0;
  --focus: #f59e0b;

  /* Surfaces */
  --card: #eef5fb;   /* cool tint */
  --card-2: #fff7ed; /* warm tint */
  --card-3: #ecfdf5; /* green tint */

  /* Sizing */
  --radius: 16px;
  --shadow: 0 2px 18px rgba(16,42,67,.10);
  --font-scale: 1; /* JS can update */
}

html{ font-size: 18px; }
body{
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(11,87,208,.10), transparent 55%),
              radial-gradient(900px 520px at 100% 0%, rgba(var(--theme-accent-rgb),.10), transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: calc(1rem * var(--font-scale));
  line-height: 1.65;
}

/* High-contrast / low-glare mode */
body.contrast{
  --bg: #0b0b0b;
  --surface: #111111;
  --text: #ffffff;
  --muted: #d2d2d2;
  --border: #2a2a2a;

  --primary: #8ab4ff;
  --primary-2: #34d399;
  --accent: #fbbf24;
  --danger: #fb7185;
  --success: #86efac;
  --info: #8ab4ff;

  --link: #8ab4ff;
  --link-visited: #c58af9;

  --card: #151515;
  --card-2: #171717;
  --card-3: #151515;

  --shadow: none;
}


/* Section themes (subtle accents that pair with the photography) */
body[data-theme="getting-started"], .card[data-theme="getting-started"]{ --theme-accent: #b45309; --theme-accent-rgb: 180, 83, 9; }
body[data-theme="movement-strength"], .card[data-theme="movement-strength"]{ --theme-accent: #0f766e; --theme-accent-rgb: 15, 118, 110; }
body[data-theme="sleep"], .card[data-theme="sleep"]{ --theme-accent: #4f46e5; --theme-accent-rgb: 79, 70, 229; }
body[data-theme="nutrition"], .card[data-theme="nutrition"]{ --theme-accent: #166534; --theme-accent-rgb: 22, 101, 52; }
body[data-theme="weight-metabolism"], .card[data-theme="weight-metabolism"]{ --theme-accent: #a16207; --theme-accent-rgb: 161, 98, 7; }
body[data-theme="heart-metabolic-health"], .card[data-theme="heart-metabolic-health"]{ --theme-accent: #be123c; --theme-accent-rgb: 190, 18, 60; }
body[data-theme="home-safety-falls"], .card[data-theme="home-safety-falls"]{ --theme-accent: #ea580c; --theme-accent-rgb: 234, 88, 12; }
body[data-theme="bones-joints-pain"], .card[data-theme="bones-joints-pain"]{ --theme-accent: #334155; --theme-accent-rgb: 51, 65, 85; }
body[data-theme="brain-mood-memory"], .card[data-theme="brain-mood-memory"]{ --theme-accent: #7c3aed; --theme-accent-rgb: 124, 58, 237; }
body[data-theme="medications-doctor-visits"], .card[data-theme="medications-doctor-visits"]{ --theme-accent: #2563eb; --theme-accent-rgb: 37, 99, 235; }
body[data-theme="health-basics"], .card[data-theme="health-basics"]{ --theme-accent: #0b4a6f; --theme-accent-rgb: 11, 74, 111; }
body[data-theme="caregiving"], .card[data-theme="caregiving"]{ --theme-accent: #db2777; --theme-accent-rgb: 219, 39, 119; }
body[data-theme="life-planning"], .card[data-theme="life-planning"]{ --theme-accent: #7c2d12; --theme-accent-rgb: 124, 45, 18; }

a{ color: var(--link); }
a:visited{ color: var(--link-visited); }
a:hover{ text-decoration: none; }

.skip-link{
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--focus);
  color: #000;
  padding: 10px 12px;
  border-radius: 12px;
  z-index: 9999;
}
.skip-link:focus{ left: 8px; }

header{
  position: sticky;
  top: 0;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
body.contrast header{
  background: rgba(11,11,11,.92);
}

.container{
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar{
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
}

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}
.brand .logo{
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: .4px;
  box-shadow: 0 10px 22px rgba(11,74,111,.18);
}

.logo-img{
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: block;
  box-shadow: 0 10px 22px rgba(11,74,111,.18);
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.75);
}
@media (max-width: 720px){
  .logo-img{ width: 36px; height: 36px; border-radius: 12px; }
}

body.contrast .brand .logo{
  box-shadow: none;
}
.brand a{
  text-decoration: none;
  color: inherit;
}
.brand .name{
  font-weight: 900;
  letter-spacing: .2px;
}
.brand .tagline{
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.2;
}

nav{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-left: auto;
  padding-bottom: 12px;
}
nav a{
  text-decoration: none;
  color: inherit;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
nav a:hover{
  background: rgba(var(--theme-accent-rgb), .08);
  border-color: rgba(var(--theme-accent-rgb), .25);
}
nav a[aria-current="page"]{
  background: var(--card);
  border-color: var(--border);
  font-weight: 700;
}

.controls{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

button, .btn{
  font: inherit;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  padding: 10px 12px;
  cursor: pointer;
  min-height: 44px; /* comfy tap target */
  box-shadow: 0 1px 0 rgba(16,42,67,.04);
}
button:hover, .btn:hover{ filter: brightness(0.985); }
button:focus, a:focus, input:focus, textarea:focus, select:focus{
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Colored button variants */
.btn.primary{
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(11,74,111,.16);
}
.btn.primary:visited{ color:#fff; }
.btn.primary:hover{ filter: brightness(0.98); }

.btn.soft{
  background: var(--card);
}
.btn.warn{
  background: var(--card-2);
  border-color: rgba(180,83,9,.25);
}
.btn.ghost{
  background: transparent;
}

.searchwrap{
  position: relative;
  flex: 1;
  min-width: 240px;
}
.searchwrap input{
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  min-height: 44px;
}
.search-results{
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: none;
}
.search-results.active{ display: block; }
.search-results a{
  display: block;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  border-top: 1px solid var(--border);
}
.search-results a:first-child{ border-top: none; }
.search-results a:hover{ background: var(--card); }
.search-results .meta{
  display: block;
  color: var(--muted);
  font-size: .9rem;
  margin-top: 2px;
}

main{ padding: 28px 0 60px; }

/* Hero */
.hero{
  background: linear-gradient(135deg,
    rgba(var(--primary-rgb),.10),
    rgba(var(--theme-accent-rgb),.10) 45%,
    rgba(var(--accent-rgb),.12));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
body.contrast .hero{
  background: var(--card);
}
.hero h1{ margin: 0 0 8px; line-height: 1.2; }
.hero p{ margin: 0; color: var(--muted); }
.hero .cta{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

/* Grids + cards */
.grid{
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  margin-top: 18px;
}
.card{
  grid-column: span 6;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.card::before{
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg,
    rgba(var(--theme-accent-rgb), .95),
    rgba(var(--theme-accent-rgb), .55) 55%,
    rgba(var(--theme-accent-rgb), .14));
  opacity: .75;
}
.card.no-accent::before{ display:none; }
.card.soft{ background: var(--card); }
.card.warm{ background: var(--card-2); }
.card.mint{ background: var(--card-3); }
.card h2, .card h3{ margin-top: 0; }
.card p{ color: var(--muted); }
.card .btn{ margin-top: 10px; }

.card-grid-3 .card{ grid-column: span 4; }

@media (max-width: 980px){
  .card-grid-3 .card{ grid-column: span 6; }
}
@media (max-width: 860px){
  .card{ grid-column: span 12; }
  .brand{ min-width: unset; }
  nav{ margin-left: 0; }
  .topbar{ flex-wrap: wrap; }
}

/* Prose */
.prose{
  width: min(780px, 100%);
  margin: 0 auto;
}
.prose h1{ line-height: 1.2; margin-bottom: 8px; }
.prose .lede{ color: var(--muted); margin-top: 0; font-size: 1.05rem; }
.prose h2{ margin-top: 28px; }
.prose ul{ padding-left: 1.2rem; }
.prose li{ margin: 6px 0; }

/* Pills / meta */
.kicker{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 18px;
  color: var(--muted);
  font-size: .95rem;
}
.pill{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.55);
}
body.contrast .pill{ background: var(--card); }


/* Topic pill accents (subtle color that matches each section) */
.kicker .pill:first-child{
  border-color: rgba(var(--theme-accent-rgb), .28);
  background: rgba(var(--theme-accent-rgb), .12);
  font-weight: 750;
}
body.contrast .kicker .pill:first-child{
  border-color: rgba(var(--theme-accent-rgb), .55);
  background: rgba(var(--theme-accent-rgb), .18);
}

/* Callouts (note cards) */
.callout{
  border-left: 6px solid var(--theme-accent);
  background: var(--card);
  padding: 14px 16px;
  border-radius: 16px;
  margin: 18px 0;
}
.callout strong{ display: block; margin-bottom: 6px; }
.callout.info{ border-left-color: var(--info); background: rgba(11,87,208,.10); }
.callout.tip{ border-left-color: var(--success); background: rgba(22,101,52,.10); }
.callout.warn{ border-left-color: var(--accent); background: rgba(180,83,9,.12); }
.callout.danger{ border-left-color: var(--danger); background: rgba(185,28,28,.10); }
body.contrast .callout.info,
body.contrast .callout.tip,
body.contrast .callout.warn,
body.contrast .callout.danger{ background: var(--card); }

/* Details accordion */
details{
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  padding: 12px 14px;
  margin: 12px 0;
}
summary{
  cursor: pointer;
  font-weight: 750;
}
details[open]{ box-shadow: var(--shadow); }

/* Tables */
.table{
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
}
.table th, .table td{
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.table th{ background: var(--card); }
.table tr:last-child td{ border-bottom: none; }

/* Forms */
label{ font-weight: 650; }
input[type="text"], input[type="search"], input[type="email"], select, textarea{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  background: var(--surface);
  color: inherit;
  min-height: 44px;
  box-sizing: border-box;
}
textarea{ min-height: 120px; }

/* Footer */
footer{
  border-top: 1px solid var(--border);
  padding: 24px 0;
  color: var(--muted);
  font-size: .95rem;
}
.footerlinks{
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}
.footerlinks a{ color: inherit; }

.small{ font-size: .95rem; color: var(--muted); }

hr{
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* Print-friendly */
@media print{
  header, footer, .noprint{ display: none !important; }
  body{ background: #fff; color:#000; }
  a{ color:#000; text-decoration: none; }
}
/* === Filters, chips, and print bar === */
.filterbar{
  margin: 18px 0 22px;
  padding: 14px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.80), rgba(255,255,255,.55));
  box-shadow: var(--shadow);
}

.filter-row{
  display:flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.filter-row label.small{
  font-weight: 700;
}

.filter-row input[type="search"],
.filter-row input[type="text"],
.filter-row select{
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  min-width: 220px;
}

.filter-row select{ min-width: 200px; }

.chips{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip{
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.75);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  line-height: 1;
  transition: transform .08s ease, box-shadow .08s ease, border-color .08s ease;
}

.chip:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.chip:focus{
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.chip.active{
  border-color: rgba(var(--theme-accent-rgb), .55);
  background: rgba(var(--theme-accent-rgb), .12);
}

.muted{ color: var(--muted); }

.hidden{ display:none !important; }

.printbar{
  display:flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin: 16px 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,.60));
  box-shadow: var(--shadow);
}

.printbar .hint{
  color: var(--muted);
  font-size: .95rem;
}

.printbar .printbar-right{
  display:flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Make guide cards show tag pills neatly */
.tagrow{ display:flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }

/* Slightly tighter cards for long lists */
.grid.tight{ gap: 14px; }


/* ===== Photo heroes + media cards ===== */

/* Hero with a photo (uses <picture class="hero-photo"> inside) */
.hero.has-photo{
  position: relative;
  overflow: hidden;
  color: #fff;
  border-color: rgba(255,255,255,.22);
  background: none;
}

/* Photo layer */
.hero.has-photo .hero-photo{
  position:absolute;
  inset:0;
  z-index:0;
}
.hero.has-photo .hero-photo img{
  display:block;
  width:100%;
  height:100%;
  object-fit: cover;
  object-position: center;
  filter: saturate(1.05) contrast(1.02);
}

/* Dark overlay for readability */
.hero.has-photo::before{
  content:"";
  position:absolute;
  inset:0;
  z-index:1;
  background: linear-gradient(135deg, rgba(10,14,23,.84), rgba(10,14,23,.52) 55%, rgba(10,14,23,.22));
}

/* Accent glow */
.hero.has-photo::after{
  content:"";
  position:absolute;
  inset:0;
  z-index:1;
  background:
    radial-gradient(900px 360px at 18% 10%, rgba(255,255,255,.20), rgba(255,255,255,0) 60%),
    radial-gradient(700px 260px at 80% 30%, rgba(var(--theme-accent-rgb), .18), rgba(var(--theme-accent-rgb), 0) 60%);
  pointer-events:none;
  opacity: .7;
}

.hero.has-photo > *{ position: relative; z-index:2; }

.hero.has-photo p{ color: rgba(255,255,255,.88); }
.hero.has-photo a{ color: rgba(255,255,255,.95); }

.hero.has-photo .pill{
  border-color: rgba(255,255,255,.20);
  background: rgba(255,255,255,.10);
  color: rgba(255,255,255,.92);
}


/* Buttons inside photo heroes need their own colors (otherwise they inherit white text on light buttons) */
.hero.has-photo .btn{
  border-color: rgba(255,255,255,.24);
  box-shadow: 0 10px 22px rgba(0,0,0,.18);
}
.hero.has-photo .btn.soft{
  background: rgba(255,255,255,.14);
  color: #fff;
}
.hero.has-photo .btn.soft:hover{ background: rgba(255,255,255,.18); }
.hero.has-photo .btn.ghost{
  background: rgba(255,255,255,.08);
  color: #fff;
}
.hero.has-photo .btn.ghost:hover{ background: rgba(255,255,255,.12); }
.hero.has-photo .btn.warn{
  background: rgba(245,158,11,.18);
  border-color: rgba(245,158,11,.35);
  color: #fff;
}
.hero.has-photo .btn.warn:hover{ background: rgba(245,158,11,.22); }
.hero.has-photo .btn:visited{ color:#fff; }
body.contrast .hero.has-photo::before{
  background: linear-gradient(135deg, rgba(0,0,0,.90), rgba(0,0,0,.62));
}

/* Photo banner inside prose pages (articles/tools/common-issues/resources) */
.photo-banner{
  margin: 0 0 16px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
  border: 1px solid rgba(255,255,255,.08);
}
.photo-banner img{
  display:block;
  width:100%;
  height: 220px;
  object-fit: cover;
  object-position: center;
  filter: saturate(1.05) contrast(1.02);
}
.photo-banner::after{
  content:"";
  position:absolute;
  inset:0;
  background: linear-gradient(to top, rgba(0,0,0,.28), rgba(0,0,0,0) 55%);
  pointer-events:none;
}

@media (min-width: 720px){
  .photo-banner img{ height: 260px; }
}

/* Card top image */
.card-media{
  display: block;
  border-radius: 14px;
  overflow: hidden;
  height: 124px;
  margin: 0 0 12px;
  position: relative;
  border: 1px solid rgba(255,255,255,.08);
}
.card-media img{
  display:block;
  width:100%;
  height:100%;
  object-fit: cover;
  object-position: center;
  filter: saturate(1.05) contrast(1.02);
}
.card-media::after{
  content:"";
  position:absolute;
  inset:0;
  background: linear-gradient(to top, rgba(0,0,0,.35), rgba(0,0,0,0) 60%);
  pointer-events:none;
}

body.contrast .card-media{
  border-color: rgba(255,255,255,.20);
}



/* --- Compact hero sizing (reduce vertical space) --- */
.hero{
  padding: 16px;
}
.hero.has-photo{
  padding: 16px;
}
.hero h1{
  font-size: 1.65rem;
  margin-bottom: 6px;
}
.hero p{
  margin: 0 0 10px;
  font-size: 1rem;
  max-width: 68ch;
}
.hero .cta{
  gap: 8px;
  margin-top: 10px;
}
.hero .cta .btn{
  padding: 8px 10px;
  font-size: .95rem;
}
@media (max-width: 560px){
  .hero{ padding: 14px; }
  .hero h1{ font-size: 1.5rem; }
  .hero .cta .btn{ padding: 8px 9px; }
}


/* --- Research Updates page additions --- */
.media-card .card-body{ padding-top: .75rem; }
.media-card .card-media img{ aspect-ratio: 16/9; object-fit: cover; border-bottom: 1px solid var(--border); }
.theme-research .kicker{ opacity: .95; }
.topic-blood-pressure{ --accent: var(--danger); }
.topic-strength-muscle{ --accent: var(--success); }
.topic-sleep{ --accent: var(--info); }
.topic-diabetes{ --accent: var(--warning); }
.topic-brain-health{ --accent: #7c5cff; }
.topic-bone-health{ --accent: #b7791f; }
.topic-nutrition-weight{ --accent: #2f855a; }
.topic-vaccines-prevention{ --accent: #2b6cb0; }
.topic-cholesterol{ --accent: #c53030; }
.topic-arthritis{ --accent: #b7791f; }
.topic-kidney-health{ --accent: #2c7a7b; }
.topic-hearing-vision{ --accent: #2b6cb0; }
.topic-cancer-screening{ --accent: #6b46c1; }
