/* style.css — Berkshire Elder Care Guide Design Tokens & Components */

/* ============================================
   CUSTOM PALETTE: Soft Greens & Earth Tones
   Warm, reassuring, care-focused
   ============================================ */

:root, [data-theme="light"] {
  /* --- Type Scale (larger for elderly readability) --- */
  --text-xs:   clamp(0.8rem,  0.75rem + 0.25vw, 0.9rem);
  --text-sm:   clamp(0.9rem, 0.85rem + 0.3vw, 1.05rem);
  --text-base: clamp(1.0625rem, 0.95rem + 0.55vw, 1.1875rem);
  --text-lg:   clamp(1.25rem, 1.05rem + 0.9vw, 1.625rem);
  --text-xl:   clamp(1.5rem, 1.1rem + 1.5vw, 2.25rem);
  --text-2xl:  clamp(2rem, 1.3rem + 2.5vw, 3rem);
  --text-3xl:  clamp(2.5rem, 1.2rem + 3.5vw, 4rem);

  /* --- Spacing (4px grid) --- */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* --- Surfaces (Warm Cream) --- */
  --color-bg:             #f8f6f1;
  --color-surface:        #faf9f5;
  --color-surface-2:      #ffffff;
  --color-surface-offset: #f2efe8;
  --color-surface-offset-2: #eae7df;
  --color-surface-dynamic: #e3e0d8;
  --color-divider:        #d9d5cb;
  --color-border:         #cfc9bd;

  /* --- Text (Warm Dark) --- */
  --color-text:           #2c2a24;
  --color-text-muted:     #6b685f;
  --color-text-faint:     #a8a59c;
  --color-text-inverse:   #faf9f5;

  /* --- Primary Accent (Sage Green) --- */
  --color-primary:        #3d7a5f;
  --color-primary-hover:  #2d6249;
  --color-primary-active: #204a36;
  --color-primary-highlight: #d5e8dd;

  /* --- Secondary Accent (Warm Earth) --- */
  --color-secondary:      #8b6e4e;
  --color-secondary-hover: #725a3e;
  --color-secondary-highlight: #e8ddd0;

  /* --- Semantic: Info (Soft Blue) --- */
  --color-info:           #4a7c94;
  --color-info-hover:     #3a6578;
  --color-info-highlight: #d4e3eb;

  /* --- Semantic: Warning (Warm Amber) --- */
  --color-warning:        #b8862a;
  --color-warning-highlight: #f0e4c8;

  /* --- Semantic: Success (Forest Green) --- */
  --color-success:        #4a8c52;
  --color-success-highlight: #d5ebd8;

  /* --- Radius --- */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* --- Transitions --- */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* --- Shadows (warm-tinted) --- */
  --shadow-sm: 0 1px 2px oklch(0.25 0.02 80 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.25 0.02 80 / 0.08);
  --shadow-lg: 0 12px 32px oklch(0.25 0.02 80 / 0.12);

  /* --- Content widths --- */
  --content-narrow: 720px;
  --content-default: 960px;
  --content-wide: 1200px;

  /* --- Fonts --- */
  --font-display: 'Merriweather', 'Georgia', serif;
  --font-body: 'Source Sans 3', 'Segoe UI', sans-serif;
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] {
  --color-bg:             #1a1914;
  --color-surface:        #201f1a;
  --color-surface-2:      #262520;
  --color-surface-offset: #1e1d18;
  --color-surface-offset-2: #24231e;
  --color-surface-dynamic: #2e2d28;
  --color-divider:        #2e2d28;
  --color-border:         #3a3933;

  --color-text:           #d8d5cc;
  --color-text-muted:     #908d84;
  --color-text-faint:     #5e5c55;
  --color-text-inverse:   #1a1914;

  --color-primary:        #6aac8a;
  --color-primary-hover:  #4d9470;
  --color-primary-active: #3d7a5f;
  --color-primary-highlight: #2a3830;

  --color-secondary:      #b8976f;
  --color-secondary-hover: #a5845c;
  --color-secondary-highlight: #3a3229;

  --color-info:           #6a9eb4;
  --color-info-hover:     #5489a0;
  --color-info-highlight: #2a3538;

  --color-warning:        #d4a54a;
  --color-warning-highlight: #3a3428;

  --color-success:        #6aaa72;
  --color-success-highlight: #2a382c;

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.2);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.3);
  --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:             #1a1914;
    --color-surface:        #201f1a;
    --color-surface-2:      #262520;
    --color-surface-offset: #1e1d18;
    --color-surface-offset-2: #24231e;
    --color-surface-dynamic: #2e2d28;
    --color-divider:        #2e2d28;
    --color-border:         #3a3933;
    --color-text:           #d8d5cc;
    --color-text-muted:     #908d84;
    --color-text-faint:     #5e5c55;
    --color-text-inverse:   #1a1914;
    --color-primary:        #6aac8a;
    --color-primary-hover:  #4d9470;
    --color-primary-active: #3d7a5f;
    --color-primary-highlight: #2a3830;
    --color-secondary:      #b8976f;
    --color-secondary-hover: #a5845c;
    --color-secondary-highlight: #3a3229;
    --color-info:           #6a9eb4;
    --color-info-hover:     #5489a0;
    --color-info-highlight: #2a3538;
    --color-warning:        #d4a54a;
    --color-warning-highlight: #3a3428;
    --color-success:        #6aaa72;
    --color-success-highlight: #2a382c;
    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.2);
    --shadow-md: 0 4px 12px oklch(0 0 0 / 0.3);
    --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.4);
  }
}

/* ============================================
   LAYOUT
   ============================================ */

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  z-index: 1000;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  top: var(--space-2);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-divider);
  transition: box-shadow var(--transition-interactive);
}
.site-header.scrolled {
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.site-logo {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--color-text);
  flex-shrink: 0;
}
.site-logo-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.1;
}
.site-logo-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.phone-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-primary);
  font-weight: 600;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-primary-highlight);
  transition: all var(--transition-interactive);
  white-space: nowrap;
}
.phone-link:hover {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}
.phone-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.theme-toggle {
  padding: var(--space-2);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  transition: all var(--transition-interactive);
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-dynamic);
}

.nav-toggle {
  display: none;
  padding: var(--space-2);
  color: var(--color-text);
  border-radius: var(--radius-md);
}

@media (max-width: 768px) {
  .nav-toggle { display: flex; align-items: center; justify-content: center; }
  .phone-link span { display: none; }
  .phone-link { padding: var(--space-2); border-radius: var(--radius-full); }
}

/* Navigation */
.site-nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
}
.nav-inner {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding: 0 var(--space-4);
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-inner::-webkit-scrollbar { display: none; }

.nav-section {
  position: relative;
}
.nav-section-btn {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  transition: all var(--transition-interactive);
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.nav-section-btn:hover,
.nav-section-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.nav-section-btn svg {
  width: 14px;
  height: 14px;
  transition: transform var(--transition-interactive);
}
.nav-section-btn.open svg {
  transform: rotate(180deg);
}

.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 320px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: 50;
  display: none;
  opacity: 0;
  transform: translateY(-4px);
}
.nav-dropdown.open {
  display: block;
  opacity: 1;
  transform: translateY(0);
  animation: dropdown-in 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.nav-dropdown a {
  display: block;
  padding: var(--space-3) var(--space-4);
  text-decoration: none;
  color: var(--color-text);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  transition: background var(--transition-interactive);
  line-height: 1.4;
}
.nav-dropdown a:hover {
  background: var(--color-surface-offset);
}
.nav-dropdown a.active-article {
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  font-weight: 500;
}

/* Mobile nav */
.mobile-nav {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-bg);
  z-index: 200;
  overflow-y: auto;
  padding: var(--space-4);
}
.mobile-nav.open { display: block; animation: fade-in 200ms ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.mobile-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
}
.mobile-nav-close {
  padding: var(--space-2);
  color: var(--color-text);
}

.mobile-nav-section {
  margin-bottom: var(--space-6);
}
.mobile-nav-section h3 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-divider);
}
.mobile-nav-section a {
  display: block;
  padding: var(--space-3) var(--space-2);
  text-decoration: none;
  color: var(--color-text);
  font-size: var(--text-base);
  border-radius: var(--radius-md);
  transition: background var(--transition-interactive);
}
.mobile-nav-section a:hover,
.mobile-nav-section a:active {
  background: var(--color-surface-offset);
}

@media (max-width: 768px) {
  .site-nav { display: none; }
}

/* Main content */
main {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding: var(--space-8) var(--space-4);
  min-height: 60vh;
}

@media (max-width: 768px) {
  main { padding: var(--space-6) var(--space-4); }
}

/* ============================================
   HOMEPAGE
   ============================================ */
.hero {
  text-align: center;
  padding: var(--space-12) 0 var(--space-8);
  max-width: 800px;
  margin-inline: auto;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-6);
  line-height: 1.25;
}
.hero-intro {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  line-height: 1.7;
  max-width: 65ch;
  margin-inline: auto;
  margin-bottom: var(--space-8);
}
.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  text-decoration: none;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: var(--text-base);
  transition: all var(--transition-interactive);
}
.hero-cta:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.hero-cta:active {
  transform: translateY(0);
}

/* Section cards on homepage */
.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: var(--space-6);
  margin-top: var(--space-8);
}

.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--transition-interactive);
}
.section-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary-highlight);
}

.section-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  color: var(--color-text-inverse);
}
.section-card-icon.green { background: var(--color-primary); }
.section-card-icon.earth { background: var(--color-secondary); }
.section-card-icon.blue { background: var(--color-info); }
.section-card-icon.amber { background: var(--color-warning); }

.section-card h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-3);
  color: var(--color-text);
}
.section-card p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.section-card-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.section-card-links a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-primary);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: all var(--transition-interactive);
}
.section-card-links a:hover {
  background: var(--color-primary-highlight);
}
.section-card-links a::before {
  content: '→';
  font-size: var(--text-xs);
  opacity: 0.6;
}

/* ============================================
   ARTICLE STYLES
   ============================================ */
.article-view {
  max-width: var(--content-narrow);
  margin-inline: auto;
  padding-bottom: var(--space-16);
}

.article-meta {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-divider);
}
.article-breadcrumb {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
.article-breadcrumb a {
  color: var(--color-primary);
  text-decoration: none;
}
.article-breadcrumb a:hover {
  text-decoration: underline;
}

.article-view h1 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-3);
  line-height: 1.25;
}

.article-view .last-updated {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.article-body h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-top: var(--space-10);
  margin-bottom: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-divider);
}
.article-body h2:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: var(--space-6);
}

.article-body h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}

.article-body p {
  margin-bottom: var(--space-4);
  color: var(--color-text);
  line-height: 1.8;
}

.article-body ul, .article-body ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}
.article-body li {
  margin-bottom: var(--space-2);
  line-height: 1.7;
}

.article-body a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-interactive);
}
.article-body a:hover {
  color: var(--color-primary-hover);
}

.article-body strong {
  font-weight: 600;
  color: var(--color-text);
}

.article-body blockquote {
  border-left: 3px solid var(--color-primary);
  padding: var(--space-4) var(--space-6);
  margin: var(--space-6) 0;
  background: var(--color-surface-offset);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-style: italic;
  color: var(--color-text-muted);
}

/* Tables in articles */
.article-body .table-wrap {
  overflow-x: auto;
  margin: var(--space-6) 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.article-body table {
  min-width: 500px;
}
.article-body th {
  background: var(--color-surface-offset);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}
.article-body td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
}
.article-body tr:last-child td {
  border-bottom: none;
}

/* Info boxes */
.info-box {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  margin: var(--space-6) 0;
  font-size: var(--text-sm);
  line-height: 1.7;
}
.info-box.tip {
  background: var(--color-primary-highlight);
  border-left: 3px solid var(--color-primary);
}
.info-box.warning {
  background: var(--color-warning-highlight);
  border-left: 3px solid var(--color-warning);
}
.info-box.key-point {
  background: var(--color-info-highlight);
  border-left: 3px solid var(--color-info);
}
.info-box strong {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-base);
}

/* CTA box */
.article-cta {
  margin-top: var(--space-10);
  padding: var(--space-6);
  background: var(--color-primary-highlight);
  border-radius: var(--radius-xl);
  text-align: center;
}
.article-cta p {
  max-width: 55ch;
  margin-inline: auto;
  color: var(--color-text);
  line-height: 1.7;
}
.article-cta a {
  color: var(--color-primary);
  font-weight: 600;
}

/* Internal link blocks */
.related-articles {
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-divider);
}
.related-articles h3 {
  font-family: var(--font-display);
  font-weight: 700;
  margin-bottom: var(--space-4);
}
.related-articles ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}
.related-articles a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-primary);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  transition: background var(--transition-interactive);
}
.related-articles a:hover {
  background: var(--color-primary-highlight);
}
.related-articles a::before {
  content: '→';
  opacity: 0.5;
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  background: var(--color-surface-offset);
  border-top: 1px solid var(--color-divider);
  padding: var(--space-8) var(--space-4);
  margin-top: var(--space-12);
}
.footer-inner {
  max-width: var(--content-wide);
  margin-inline: auto;
  text-align: center;
}
.footer-sponsor {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.8;
  max-width: 60ch;
  margin-inline: auto;
}
.footer-sponsor a {
  color: var(--color-primary);
  text-decoration: none;
}
.footer-sponsor a:hover {
  text-decoration: underline;
}
.footer-sponsor .footer-phone {
  font-weight: 600;
  color: var(--color-primary);
}
.footer-note {
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ============================================
   BACK TO TOP
   ============================================ */
.back-to-top {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(10px);
  transition: all var(--transition-interactive);
  pointer-events: none;
  z-index: 50;
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ============================================
   UTILITIES & ANIMATIONS
   ============================================ */
.fade-in {
  opacity: 0;
  animation: fadeIn 300ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes fadeIn {
  to { opacity: 1; }
}

/* Print styles */
@media print {
  .site-header, .site-nav, .mobile-nav, .back-to-top, .theme-toggle, .nav-toggle { display: none !important; }
  .article-view { max-width: 100%; }
  .site-footer { break-inside: avoid; }
}
