/* ============================================================
   Peptera — shared stylesheet
   Warm, low-contrast, desaturated theme (easy on the eyes).
   Original work for peptera.org. No third-party code.
   ============================================================ */

:root {
  --bg:        #F3EEE4;   /* warm off-white page */
  --surface:   #FBF8F3;   /* card surface */
  --surface-2: #F6F1E8;   /* alt / striped surface */
  --ink:       #33312E;   /* primary text (not pure black) */
  --ink-soft:  #6B655C;   /* secondary text */
  --ink-faint: #9C948A;   /* muted / placeholder */
  --line:      #E4DCCF;   /* borders */
  --line-2:    #D8CFC2;   /* stronger borders */
  --brand:     #5C6E4F;   /* sage — primary accent */
  --brand-dk:  #4A5A40;
  --accent:    #A8794A;   /* ochre — secondary accent */
  --warn:      #9A5B45;   /* muted terracotta for cautions */
  --header-bg: rgba(251,248,243,.9);
  --link: #4A5A40;   /* readable link color (light theme) */
  --btn-bg: #5C6E4F; --btn-bg-hover: #4A5A40; --btn-text: #F3EEE4;  /* solid buttons (light) */
  --radius: 12px;
  --shadow: 0 1px 3px rgba(80,70,60,.08), 0 6px 20px rgba(80,70,60,.05);
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- dark theme (warm, low-contrast, VSS-friendly) ---------- */
:root[data-theme="dark"] {
  --bg:        #26221E;
  --surface:   #2F2A25;
  --surface-2: #38322C;
  --ink:       #D8CFC2;
  --ink-soft:  #A89A8C;
  --ink-faint: #877B6D;
  --line:      #433C34;
  --line-2:    #52493F;
  --brand:     #93A577;
  --brand-dk:  #AEC091;
  --accent:    #C99A63;
  --warn:      #CE9E86;
  --header-bg: rgba(38,34,30,.9);
  --link: #B7C79C;   /* readable link color (dark theme) */
  /* solid buttons (dark): light-sage fill needs DARK text for contrast */
  --btn-bg: #93A577; --btn-bg-hover: #AEC091; --btn-text: #23201C;
  --shadow: 0 1px 3px rgba(0,0,0,.30), 0 6px 20px rgba(0,0,0,.22);
}

/* accessibility: skip link + visible focus */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--btn-bg); color: var(--btn-text); padding: 10px 16px; border-radius: 0 0 8px 0;
  font-weight: 700; text-decoration: none;
}
.skip-link:focus { left: 0; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }

/* default links (readable in both themes; specific components override) */
a { color: var(--link); }
a:visited { color: var(--link); }
a:hover { text-decoration: underline; }

/* theme toggle button (injected into the nav) */
.theme-toggle {
  background:none; border:1px solid var(--line-2); color:var(--ink-soft);
  border-radius:8px; padding:7px 11px; font-size:14px; font-family:var(--font);
  cursor:pointer; margin-left:6px; line-height:1;
}
.theme-toggle:hover { background:var(--surface-2); color:var(--brand-dk); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
.section { padding: 56px 0; }
.section.tight { padding: 36px 0; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--header-bg);
  backdrop-filter: saturate(120%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex; align-items: center; gap: 8px;
  height: 62px; max-width: var(--maxw); margin: 0 auto; padding: 0 22px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 20px; color: var(--ink); text-decoration: none;
  letter-spacing: .3px;
}
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--btn-bg); color: var(--btn-text);
  display: grid; place-items: center; font-weight: 800; font-size: 16px;
}
.nav-links { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.nav-links a {
  color: var(--ink-soft); text-decoration: none; font-size: 15px; font-weight: 500;
  padding: 8px 12px; border-radius: 8px;
}
.nav-links a:hover, .nav-links a.active { color: var(--brand-dk); background: var(--surface-2); }

/* mobile hamburger (button injected by JS) */
.nav-toggle {
  display: none; margin-left: auto; background: none; border: 1px solid var(--line-2);
  color: var(--ink); border-radius: 8px; padding: 7px 11px; font-size: 18px; cursor: pointer; line-height: 1;
}
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 62px; left: 0; right: 0;
    flex-direction: column; gap: 0; margin: 0; padding: 8px 12px 14px;
    background: var(--surface); border-bottom: 1px solid var(--line-2); box-shadow: var(--shadow);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 10px; font-size: 16px; border-radius: 8px; }
  .nav-links .theme-toggle { margin: 8px 0 0; align-self: flex-start; }
  .site-header { position: sticky; }
  .nav { position: relative; }
}

/* homepage stats strip */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 640px){ .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 16px; text-align: center; box-shadow: var(--shadow);
}
.statnum { display: block; font-size: 30px; font-weight: 800; color: var(--brand-dk); line-height: 1; }
.statlbl { display: block; margin-top: 6px; font-size: 14px; color: var(--ink-soft); }

/* ---------- hero ---------- */
.hero { padding: 72px 0 40px; }
.hero h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.12; margin: 0 0 16px; letter-spacing: -.5px; }
.hero p.lead { font-size: 20px; color: var(--ink-soft); max-width: 640px; margin: 0 0 26px; }
.eyebrow { color: var(--brand); font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; font-size: 13px; margin: 0 0 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--btn-bg); color: var(--btn-text); text-decoration: none;
  padding: 12px 20px; border-radius: 10px; font-weight: 600; font-size: 16px;
  border: none; cursor: pointer; transition: background .15s, color .15s;
}
.btn:hover { background: var(--btn-bg-hover); color: var(--btn-text); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--brand-dk); border: 1px solid var(--line-2); }
.btn.secondary:hover { background: var(--surface-2); color: var(--brand-dk); text-decoration: none; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- cards / grid ---------- */
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 780px){ .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 8px; font-size: 20px; }
.card p { margin: 0; color: var(--ink-soft); font-size: 16px; }
a.card { text-decoration: none; color: inherit; display: block; transition: transform .12s, box-shadow .12s; }
a.card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(80,70,60,.10), 0 12px 28px rgba(80,70,60,.08); }
.card .ico { font-size: 26px; margin-bottom: 10px; display: block; }

/* ---------- section headings ---------- */
.h-center { text-align: center; max-width: 660px; margin: 0 auto 36px; }
.h-center h2 { font-size: clamp(26px, 4vw, 34px); margin: 0 0 10px; }
.h-center p { color: var(--ink-soft); margin: 0; font-size: 18px; }

/* ---------- calculators ---------- */
.calc {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow);
}
.calc h3 { margin: 0 0 4px; font-size: 22px; }
.calc .sub { color: var(--ink-soft); font-size: 15px; margin: 0 0 20px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.field .hint { color: var(--ink-faint); font-weight: 400; font-size: 13px; }
.field input, .field select {
  width: 100%; padding: 11px 13px; font-size: 16px; font-family: var(--font);
  color: var(--ink); background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: 9px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(92,110,79,.15); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.preset-chip {
  font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line-2);
  padding: 4px 10px; border-radius: 999px;
}
.preset-chip:hover { color: var(--brand-dk); border-color: var(--brand); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px){ .field-row { grid-template-columns: 1fr; } }

.result {
  margin-top: 18px; padding: 18px 20px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.result .big { font-size: 30px; font-weight: 800; color: var(--brand-dk); line-height: 1.1; }
.result .big small { font-size: 16px; font-weight: 600; color: var(--ink-soft); }
.result .line { color: var(--ink-soft); font-size: 15px; margin-top: 6px; }
.result.empty { color: var(--ink-faint); font-style: italic; }

/* ---------- prose (learn/safety) ---------- */
.prose { max-width: 760px; }
.prose h2 { font-size: 28px; margin: 40px 0 12px; }
.prose h3 { font-size: 21px; margin: 28px 0 8px; }
.prose p, .prose li { color: var(--ink); font-size: 17px; }
.prose ul { padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose .callout {
  border-left: 4px solid var(--brand); background: var(--surface);
  padding: 14px 18px; border-radius: 0 10px 10px 0; margin: 20px 0;
}
.prose .callout.warn { border-left-color: var(--warn); }

/* ---------- disclaimer banner ---------- */
.disclaimer {
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 14px 18px; font-size: 14px; color: var(--ink-soft);
}
.disclaimer strong { color: var(--warn); }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line); background: var(--surface);
  padding: 34px 0; margin-top: 40px; font-size: 14px; color: var(--ink-soft);
}
.site-footer .cols { display: flex; gap: 40px; flex-wrap: wrap; justify-content: space-between; }
.site-footer a { color: var(--ink-soft); text-decoration: none; }
.site-footer a:hover { color: var(--brand-dk); }
.site-footer .fine { margin-top: 20px; font-size: 12.5px; color: var(--ink-faint); max-width: 720px; }

.tag { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .5px;
  color: var(--brand-dk); background: var(--surface-2); border: 1px solid var(--line);
  padding: 3px 9px; border-radius: 999px; text-transform: uppercase; }

/* ---------- print ---------- */
@media print {
  :root { --bg:#fff; --surface:#fff; --surface-2:#f7f7f7; --ink:#000; --ink-soft:#333; --line:#ccc; --line-2:#bbb; }
  .site-header, .site-footer, .theme-toggle, .btn, .btn-row,
  #cx-search, .cx-searchwrap, .cx-cats, .cx-selectwrap, .cx-copy { display:none !important; }
  body { background:#fff; color:#000; font-size:12pt; }
  a { color:#000 !important; text-decoration:none; }
  .prose a[href^="http"]::after, .cx-cite a[href^="http"]::after { content:" (" attr(href) ")"; font-size:9pt; color:#555; }
  .card, .calc, .cx-panel, .result { box-shadow:none !important; border:1px solid #ccc; break-inside:avoid; }
  .hero { padding:12px 0 !important; }
  .section { padding:14px 0 !important; }
  main { max-width:100% !important; }
}
