/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body, h1, h2, h3, p, ul { margin: 0; }
html { scroll-behavior: smooth; }

/* Tokens */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #111827; /* deeper for contrast */
  --muted: #4b5563;
  --border: #e5e7eb;
  --brand: #111827;
  --primary: #1d4ed8; /* accessible blue */
  --primary-hover: #1e40af;
  --link: var(--primary);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 10px rgba(0,0,0,.08), 0 10px 24px rgba(0,0,0,.08);
  --section-radius: 12px;
}

/* High contrast mode */
html.contrast-high {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #000000;
  --muted: #1f2937;
  --border: #111827;
  --primary: #0b57d0; /* deeper accessible blue */
  --primary-hover: #0846a6;
  --link: var(--primary);
  --shadow: none;
  --shadow-lg: none;
}
html.contrast-high .hero::before { background: linear-gradient(to bottom, rgba(0,0,0,.65), rgba(0,0,0,.35)); }
html.contrast-high .card { border-width: 2px; }
html.contrast-high nav a.active { border-bottom-width: 4px; }

/* Base */
html { font-size: 18px; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, Noto Sans, sans-serif;
  line-height: 1.7;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { text-underline-offset: 3px; }

/* Large-text toggle */
html.text-lg { font-size: 20px; }
html.text-lg h2 { font-size: 1.75rem; margin-bottom: 1rem; }
html.text-lg section { padding: 1.75rem; scroll-margin-top: 80px; }

/* Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  text-align: center;
  padding: 2rem 1rem 1.5rem;
}
header h1 { font-size: 1.875rem; }
header p { color: var(--muted); margin-top: .25rem; }

/* Brand link in header */
header .brand { color: inherit; text-decoration: none; }
header .brand:hover { color: var(--link); }

/* Navigation */
nav {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  padding: .9rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
nav a {
  color: var(--text);
  text-decoration: none;
  padding: .5rem .25rem;
  font-weight: 600;
}
nav a:hover { color: var(--link); }
nav a:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; border-radius: 6px; }
nav a.active {
  color: var(--link);
  border-bottom: 3px solid var(--link);
}
/* Mobile nav call-to-action */
.nav-cta { display: none; }

/* Small button variant (for nav) */
.btn-sm { padding: .5rem .6rem; min-height: 36px; font-weight: 700; border-radius: 10px; font-size: .95rem; }

/* Skip link */
.skip-link {
  position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  position: fixed; left: 1rem; top: 1rem; width: auto; height: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: .5rem .75rem;
  box-shadow: var(--shadow);
  z-index: 1000;
}

/* Hero */
.hero {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 42vh;
  padding: 3rem 1rem;
  color: #fff;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(17,24,39,.55), rgba(17,24,39,.25));
  z-index: 1;
  pointer-events: none;
}
.hero-bg { position: absolute; inset: 0; z-index: 0; }
.hero-bg .slide { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; animation: heroFade 36s infinite; }
.hero-bg .s1 { animation-delay: 0s; }
.hero-bg .s2 { animation-delay: 12s; }
.hero-bg .s3 { animation-delay: 24s; }
@keyframes heroFade {
  0%, 27% { opacity: 1; }
  33%, 94% { opacity: 0; }
  100% { opacity: 1; }
}
.hero-inner { position: relative; z-index: 2; text-align: center; max-width: 860px; }
.hero h2 { font-size: 2rem; letter-spacing: .2px; }
.hero .muted { color: rgba(255,255,255,.85); margin-top: .5rem; }
.hero-ctas { margin-top: 1rem; display: inline-flex; gap: .5rem; flex-wrap: wrap; }

/* Buttons (accessible sizes) */
.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 700; border-radius: 12px; padding: .75rem 1rem; min-height: 44px; line-height: 1; border: 2px solid transparent; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-outline { color: var(--text); border-color: rgba(17,24,39,.6); background: transparent; }
.btn-outline:hover { border-color: var(--text); background: rgba(17,24,39,.04); }
.hero .btn-outline { color: #fff; border-color: rgba(255,255,255,.85); }
.hero .btn-outline:hover { border-color: #fff; background: rgba(255,255,255,.06); }
html.contrast-high .btn-outline { border-color: currentColor; background: transparent; }
html.contrast-high .btn-outline:hover { background: rgba(0,0,0,.06); }

/* Sections */
section {
  max-width: 860px;
  margin: 2rem auto;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--section-radius);
  box-shadow: var(--shadow);
  scroll-margin-top: 72px; /* account for sticky nav */
}
h1, h2 { margin-bottom: .75rem; }
h2 { font-size: 1.5rem; }
section p { color: var(--text); }

/* Lists */
.list { margin: .5rem 0 0 1.1rem; padding: 0; }
.list li { margin: .5rem 0; font-size: 1.05rem; }

/* Expect checklist */
.checklist { list-style: none; padding: 0; margin: .5rem 0 0; }
.checklist li { position: relative; padding-left: 1.75rem; margin: .6rem 0; }
.checklist li::before {
  content: "";
  position: absolute; left: 0; top: .15rem;
  width: 1.1rem; height: 1.1rem; border-radius: 6px;
  border: 2px solid var(--primary);
  background: radial-gradient(circle at 50% 50%, var(--primary) 60%, transparent 61%);
}

/* Service cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: .5rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--section-radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.card h3 { margin-bottom: .35rem; font-size: 1.15rem; }
.card p { margin: 0; color: var(--muted); }
.card .icon { color: var(--primary); margin-bottom: .5rem; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: rgba(29,78,216,.35); }
.card:focus-within { box-shadow: var(--shadow-lg); border-color: rgba(29,78,216,.5); }

.donation-card {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  min-height: 320px;
}
.wallet-visual {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  border: 1px dashed rgba(17,24,39,.2);
  border-radius: 16px;
  background: rgba(17,24,39,.02);
}
.wallet-icon {
  width: min(320px, 100%);
  aspect-ratio: 1 / 1;
  padding: 0.25rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}
.wallet-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.donation-body { text-align: center; }
.wallet-address {
  display: block;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: .9rem;
  padding: .4rem .55rem;
  border-radius: 10px;
  background: rgba(17,24,39,.04);
  word-break: break-all;
}
.copy-btn { align-self: flex-start; }

@media (prefers-reduced-motion: reduce) {
  .card { transition: box-shadow 160ms ease, border-color 160ms ease; }
  .card:hover { transform: none; }
}

/* Page-specific light alignment for legacy centered sections */
section#services, section#contact { text-align: center; }
section#contact h4, section#contact h5 { margin: .25rem 0; color: var(--text); }
/* Sub-note line */
#contact h5 { color: var(--muted); }

/* Utility */
.muted { color: var(--muted); }

/* Footer */
footer {
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding: 2rem 1rem;
  margin-top: 3rem;
}

/* Responsive tweaks */
@media (max-width: 640px) {
  html { font-size: 16px; }
  html.text-lg { font-size: 18px; }
  header { padding: 1.5rem 1rem; }
  .hero { min-height: 32vh; padding: 2rem 1rem; }
  section { margin: 1.25rem 1rem; padding: 1.25rem; }
  .nav-cta { display: inline-flex; align-items: center; }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --surface: #0f1720;
    --text: #e5e7eb;
    --muted: #9aa4b2;
    --border: #1f2937;
    --primary: #60a5fa;
    --primary-hover: #3b82f6;
    --link: var(--primary);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 8px rgba(0,0,0,.35);
    --shadow-lg: 0 4px 10px rgba(0,0,0,.45), 0 10px 24px rgba(0,0,0,.5);
  }
  .hero::before { background: linear-gradient( to bottom, rgba(17,24,39,.6), rgba(17,24,39,.35) ); }
}

/* Respect reduced motion: keep first slide only */
@media (prefers-reduced-motion: reduce) {
  .hero-bg .slide { animation: none !important; }
  .hero-bg .s1 { opacity: 1; }
  .hero-bg .s2, .hero-bg .s3 { opacity: 0; }
}

/* Print styles: emphasize contact, simplify visuals */
@media print {
  :root { --text: #000; --muted: #000; --border: #000; }
  body { background: #fff; color: #000; }
  nav, .hero, .cards { display: none !important; }
  section { box-shadow: none; border: 1px solid #000; }
  #contact { display: block; }
}

/* ===== Forums Theme ===== */
.forums-section { max-width: 1100px; }
.forums-grid { display: grid; grid-template-columns: 1fr 300px; gap: 1rem; }
.forums-main > .card + .card { margin-top: .75rem; }
.forums-aside .card { position: sticky; top: 84px; }

/* Forum/Topic lists */
.forum-list { display: flex; flex-direction: column; gap: .5rem; }
.forum-row, .topic-row { display: grid; grid-template-columns: 44px 1fr 180px; gap: .75rem; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .75rem; }
.item-icon { width: 44px; height: 44px; display: grid; place-items: center; background: transparent; color: var(--text); border-radius: 50%; font-size: 1.1rem; }
.item-main .item-title { font-weight: 700; color: var(--text); text-decoration: none; }
.item-main .item-title:hover { color: var(--link); }
.item-main .item-desc { color: var(--muted); margin-top: .15rem; }
.item-meta { text-align: right; }
.item-meta .count { font-weight: 700; }
.item-meta .muted { display: block; }
.item-meta-line { display: flex; flex-wrap: wrap; gap: .35rem .6rem; margin-top: .15rem; align-items: center; }
.pill { padding: .15rem .45rem; border: 1px solid var(--border); border-radius: 999px; font-size: .8rem; color: var(--muted); }

/* Topic thread */
.topic-thread { display: flex; flex-direction: column; gap: .75rem; }
.post-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .75rem 1rem; box-shadow: var(--shadow); }
.post-head { display: grid; grid-template-columns: 40px 1fr; gap: .6rem; align-items: center; margin-bottom: .25rem; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: rgba(29,78,216,.1); color: #111; display: grid; place-items: center; font-weight: 800; letter-spacing: .3px; }
.avatar-sm { width: 36px; height: 36px; font-size: .95rem; }
.author { font-weight: 700; }
.post-body pre { white-space: pre-wrap; font-family: inherit; margin: 0; }
.post-body .md { line-height: 1.7; }
.post-body .md h2, .post-body .md h3, .post-body .md h4 { margin: .25rem 0; }
.post-body .md p { margin: .4rem 0; }
.post-body .md ul { margin: .4rem 0 .4rem 1.25rem; }
.post-body .md code { background: rgba(17,24,39,.06); padding: .1rem .3rem; border-radius: 6px; }
.post-body .md pre.md-code { background: rgba(17,24,39,.06); padding: .6rem .75rem; border-radius: 10px; overflow: auto; }
.post-body .md blockquote { margin: .5rem 0; padding: .35rem .6rem; border-left: 3px solid var(--primary); background: rgba(29,78,216,.06); border-radius: 8px; }

/* Reactions */
.reactions { display: flex; gap: .35rem; align-items: center; margin-top: .45rem; flex-wrap: wrap; }
.reaction { display: inline-flex; align-items: center; gap: .25rem; border: 1px solid var(--border); background: rgba(17,24,39,.03); padding: .2rem .45rem; border-radius: 999px; cursor: pointer; }
.reaction.active { border-color: var(--primary); background: rgba(29,78,216,.08); }
.reaction img { width: 18px; height: 18px; border-radius: 4px; }

/* Mini list in sidebar */
.mini-row { display: block; margin: .35rem 0; }
.mini-row a { color: var(--text); text-decoration: none; }
.mini-row a:hover { color: var(--link); }
.breadcrumbs { color: var(--muted); font-size: .95rem; margin-top: .25rem; }
.breadcrumbs a { color: inherit; text-decoration: none; }
.breadcrumbs a:hover { color: var(--link); }

/* Composed forms */
.form-card { padding-top: 1rem; }
.form { margin-top: .25rem; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem .75rem; }
.field-grid .field-span { grid-column: 1 / -1; }
.field { display: grid; gap: .35rem; }
.field .label { font-weight: 700; color: var(--text); font-size: .95rem; }
.input, .textarea {
  width: 100%;
  padding: .7rem .8rem;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
select.input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' viewBox='0 0 24 24' stroke='rgba(17,24,39,0.8)' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  background-size: 18px 18px;
  padding-right: 2.2rem;
}
html.contrast-high select.input { background-image: none; }
.textarea { min-height: 120px; resize: vertical; }
.input:focus, .textarea:focus { outline: none; border-color: rgba(29,78,216,.5); box-shadow: 0 0 0 3px rgba(29,78,216,.18); }
.counter { justify-self: end; color: var(--muted); font-size: .85rem; }
.form-actions { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; }
#forumContextWrap .chip { display: inline-flex; }

@media (max-width: 720px) {
  .field-grid { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .forums-grid { grid-template-columns: 1fr; }
  .forums-aside { order: -1; }
  .forum-row, .topic-row { grid-template-columns: 36px 1fr 120px; }
  .item-icon { width: 36px; height: 36px; }
}

/* Top sub-bar for forums/messages */
.subbar { display: flex; gap: .5rem; align-items: center; padding: .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: .6rem; }
.subbar a:not(.btn) { text-decoration: none; color: var(--text); font-weight: 700; padding: .35rem .6rem; border-radius: 10px; border: 1px solid var(--border); }
.subbar a:not(.btn).active, .subbar a:not(.btn):hover { color: var(--link); border-color: rgba(29,78,216,.35); }

/* Messages page layout */
.messages-grid { display: grid; grid-template-columns: 300px 1fr; gap: 1rem; }
.messages-list { position: sticky; top: 84px; height: fit-content; }
.messages-thread { display: flex; flex-direction: column; gap: .75rem; }
@media (max-width: 960px) { .messages-grid { grid-template-columns: 1fr; } .messages-list { position: static; } }

/* Profile layout */
.profile-hero { position: relative; border: 1px solid var(--border); border-radius: var(--section-radius); overflow: hidden; box-shadow: var(--shadow); }
.profile-cover { height: 120px; background: linear-gradient(135deg, rgba(29,78,216,.3), rgba(99,102,241,.3)); }
.profile-head { display: grid; grid-template-columns: 80px 1fr auto; gap: .9rem; align-items: end; padding: .75rem 1rem; background: var(--surface); }
.profile-avatar { width: 72px !important; height: 72px !important; font-size: 1.1rem; border: 3px solid #fff; box-shadow: var(--shadow); margin-top: -36px; }
.profile-summary h2 { margin: 0; }
.profile-stats { display: flex; gap: .5rem; margin-top: .25rem; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .5rem; border: 1px solid var(--border); border-radius: 999px; background: rgba(17,24,39,.03); font-size: .9rem; }
.profile-actions { display: flex; gap: .5rem; align-items: center; }
.profile-grid { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; margin-top: 1rem; }
.profile-aside { position: sticky; top: 84px; height: fit-content; }
.profile-main { display: grid; gap: 1rem; }
@media (max-width: 960px) { .profile-grid { grid-template-columns: 1fr; } .profile-aside { position: static; } }
