@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800&family=Noto+Sans:wght@400;500;600;700&display=swap');

/* ==========================================================================
   PulmApps — shared design system
   Modern, responsive, clinical UI
   Palette & type informed by UI-UX Pro Max → "Accessible & Ethical" (healthcare)
   ========================================================================== */

:root {
  /* Palette */
  --bg:            #eff7f8;
  --bg-alt:        #ffffff;
  --surface:       #ffffff;
  --surface-2:     #eef4f7;
  --ink:           #123a3c;
  --ink-soft:      #47646c;
  --ink-faint:     #7c95a2;
  --line:          #d9e4ea;
  --line-strong:   #c2d3dc;

  --brand:         #0891b2;   /* medical teal */
  --brand-dark:    #0b6b7c;
  --brand-soft:    #d7eff4;
  --accent:        #2c7be5;   /* clinical blue */
  --accent-soft:   #e2edfb;

  --ok:            #1f9d55;
  --ok-soft:       #dff3e6;
  --warn:          #c47f17;
  --warn-soft:     #fbeecd;
  --danger:        #c1432e;
  --danger-soft:   #f8e0da;

  --radius:        14px;
  --radius-sm:     9px;
  --shadow-sm:     0 1px 2px rgba(20,48,61,.06), 0 1px 3px rgba(20,48,61,.05);
  --shadow-md:     0 4px 14px rgba(20,48,61,.09);
  --shadow-lg:     0 12px 34px rgba(20,48,61,.14);

  --maxw:          1080px;
  --font: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-head: "Figtree", "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- Dark mode ---------- */
[data-theme="dark"] {
  --bg:            #0f1a1f;
  --bg-alt:        #13232a;
  --surface:       #16272f;
  --surface-2:     #1e333c;
  --ink:           #e6eef2;
  --ink-soft:      #a9bfc9;
  --ink-faint:     #7e97a2;
  --line:          #26404a;
  --line-strong:   #375563;

  --brand:         #16a0ac;   /* teal, brightened for dark surfaces */
  --brand-dark:    #4bc3ce;   /* used as link / active text — lightened for contrast */
  --brand-soft:    #123c42;
  --accent:        #5aa0f0;
  --accent-soft:   #14304a;

  --ok:            #4cc17e;
  --ok-soft:       #123528;
  --warn:          #e0a94a;
  --warn-soft:     #3a2f16;
  --danger:        #ec7a67;
  --danger-soft:   #3d211b;

  --shadow-sm:     0 1px 2px rgba(0,0,0,.45), 0 1px 3px rgba(0,0,0,.35);
  --shadow-md:     0 4px 14px rgba(0,0,0,.5);
  --shadow-lg:     0 12px 34px rgba(0,0,0,.6);
}

/* Overrides for values hardcoded to white / light in the light theme */
[data-theme="dark"] .site-header { background: rgba(19,35,42,.86); }
[data-theme="dark"] .hero {
  background:
    radial-gradient(1200px 400px at 80% -10%, var(--brand-soft), transparent 60%),
    linear-gradient(180deg, var(--bg-alt) 0%, var(--bg) 100%);
}
[data-theme="dark"] input[type=text],
[data-theme="dark"] input[type=number],
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: var(--surface); }
[data-theme="dark"] .seg button.active { background: var(--surface); color: var(--brand-dark); }
[data-theme="dark"] .metric { background: var(--bg-alt); }
[data-theme="dark"] .report { background: var(--bg-alt); }
[data-theme="dark"] .disclaimer { border-color: #5a4a1e; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 780px; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  height: 62px; gap: 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-head);
  font-weight: 800; font-size: 1.15rem; color: var(--ink);
  letter-spacing: -.02em;
}
.brand:hover { text-decoration: none; }
.brand .lung { font-size: 1.35rem; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  color: var(--ink-soft); font-weight: 600; font-size: .92rem;
  padding: 8px 12px; border-radius: 8px;
}
.nav-links a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-links a.active { color: var(--brand-dark); background: var(--brand-soft); }
.nav-toggle {
  display: none; background: none; border: 1px solid var(--line-strong);
  border-radius: 8px; width: 40px; height: 38px; cursor: pointer;
  color: var(--ink); font-size: 1.2rem;
}
.nav-right { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  background: none; border: 1px solid var(--line-strong);
  border-radius: 8px; width: 40px; height: 38px; cursor: pointer;
  color: var(--ink); font-size: 1.05rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { background: var(--surface-2); }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav-links {
    position: absolute; top: 62px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg-alt); border-bottom: 1px solid var(--line);
    padding: 8px; box-shadow: var(--shadow-md);
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 14px; border-radius: 8px; }
}

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(1200px 400px at 80% -10%, var(--brand-soft), transparent 60%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
  padding: 68px 0 56px;
}
.hero h1 { font-size: clamp(2rem, 4.5vw, 3rem); margin-bottom: .3em; }
.hero .tag { color: var(--brand-dark); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: .8rem; }
.hero p.lede { font-size: 1.15rem; color: var(--ink-soft); max-width: 640px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff; border: 1px solid transparent;
  padding: 11px 20px; border-radius: 10px; font-weight: 650; font-size: .95rem;
  cursor: pointer; transition: transform .05s ease, background .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--brand-dark); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-2); color: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--ink-soft); box-shadow: none; border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.small { padding: 7px 13px; font-size: .85rem; border-radius: 8px; }
.btn.block { width: 100%; justify-content: center; }

/* ---------- Tool grid ---------- */
.section { padding: 56px 0; }
.section h2 { font-size: 1.6rem; }
.section-head { margin-bottom: 26px; }
.section-head p { color: var(--ink-soft); max-width: 640px; }

.tool-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.tool-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
  color: inherit;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); text-decoration: none; }
.tool-card .ic { font-size: 1.7rem; }
.tool-card h3 { font-size: 1.12rem; margin: 0; }
.tool-card p { color: var(--ink-soft); font-size: .92rem; margin: 0; }
.tool-card .go { margin-top: auto; color: var(--brand-dark); font-weight: 700; font-size: .88rem; padding-top: 8px; }
.badge {
  display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 20px;
  background: var(--warn-soft); color: var(--warn); vertical-align: middle;
}
.badge.beta { background: var(--accent-soft); color: var(--accent); }

/* ---------- Tool page layout ---------- */
.tool-header { padding: 40px 0 8px; }
.tool-header .tool-eyebrow { color: var(--brand-dark); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: .78rem; }
.tool-header h1 { font-size: clamp(1.7rem, 3.5vw, 2.3rem); display: flex; align-items: center; gap: 12px; }
.tool-header p { color: var(--ink-soft); max-width: 680px; }

.grid-2 { display: grid; gap: 22px; grid-template-columns: 1fr 1fr; align-items: start; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 20px; }
.card h2 { font-size: 1.15rem; margin-bottom: 4px; }
.card h3 { font-size: 1rem; margin: 18px 0 8px; color: var(--ink); }
.card .sub { color: var(--ink-faint); font-size: .85rem; margin-bottom: 16px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 5px; color: var(--ink); }
.field .hint { color: var(--ink-faint); font-weight: 400; font-size: .8rem; }
input[type=text], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; font-size: .95rem; font-family: var(--font);
  color: var(--ink); background: #fff; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; min-height: 120px; font-family: var(--mono); font-size: .85rem; line-height: 1.5; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.row-3 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 520px) { .row, .row-3 { grid-template-columns: 1fr; } }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button {
  border: none; background: transparent; color: var(--ink-soft); cursor: pointer;
  padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: .88rem;
}
.seg button.active { background: #fff; color: var(--brand-dark); box-shadow: var(--shadow-sm); }

.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 9px; font-size: .92rem; }
.check input { width: auto; margin-top: 3px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }

/* ---------- Results ---------- */
.result {
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface-2); padding: 18px; margin-top: 4px;
}
.result.empty { color: var(--ink-faint); text-align: center; padding: 34px 18px; }
.metric-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); margin: 4px 0 14px; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.metric .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); font-weight: 700; }
.metric .v { font-size: 1.35rem; font-weight: 750; color: var(--ink); }
.metric .v small { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }

.tagline { display: inline-block; padding: 5px 12px; border-radius: 20px; font-weight: 700; font-size: .82rem; margin-bottom: 10px; }
.t-ok { background: var(--ok-soft); color: var(--ok); }
.t-warn { background: var(--warn-soft); color: var(--warn); }
.t-danger { background: var(--danger-soft); color: var(--danger); }
.t-neutral { background: var(--accent-soft); color: var(--accent); }

.report {
  font-family: var(--mono); font-size: .84rem; line-height: 1.6; white-space: pre-wrap;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 16px; margin-top: 12px; color: var(--ink);
}

.callout {
  border-left: 3px solid var(--brand); background: var(--brand-soft);
  padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .9rem; color: var(--ink); margin: 14px 0;
}
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }

table.data { width: 100%; border-collapse: collapse; font-size: .88rem; margin: 6px 0 14px; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.data th { color: var(--ink-faint); font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; }
table.data tr:last-child td { border-bottom: none; }

/* ---------- Disclaimer / footer ---------- */
.disclaimer {
  font-size: .82rem; color: var(--ink-soft); background: var(--warn-soft);
  border: 1px solid #f0dcae; border-radius: var(--radius-sm); padding: 12px 16px;
  margin: 18px 0;
}
.disclaimer strong { color: var(--warn); }

.site-footer {
  border-top: 1px solid var(--line); background: var(--bg-alt);
  padding: 40px 0 32px; margin-top: 40px; color: var(--ink-soft); font-size: .9rem;
}
.footer-grid { display: grid; gap: 26px; grid-template-columns: 2fr 1fr 1fr; }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr; } }
.site-footer h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.site-footer a { color: var(--ink-soft); }
.site-footer a:hover { color: var(--brand-dark); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 6px; }
.foot-bottom { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; color: var(--ink-faint); font-size: .82rem; }

.supporters { columns: 2; column-gap: 24px; font-size: .9rem; color: var(--ink-soft); }
@media (max-width: 520px){ .supporters { columns: 1; } }

.hidden { display: none !important; }
.muted { color: var(--ink-faint); }
.small { font-size: .84rem; }
.center { text-align: center; }

/* ---------- Print ---------- */
@media print {
  /* Hide site chrome, navigation, forms, and interactive controls */
  .site-header, .site-footer, .nav, .nav-links, .nav-toggle,
  .disclaimer, .btn, .btn-row, .seg, form, button, input, select, textarea {
    display: none !important;
  }

  /* Clean white page, black text, no shadows */
  html, body {
    background: #fff !important;
    color: #000 !important;
  }
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  .wrap { max-width: none !important; width: auto !important; margin: 0 !important; padding: 0 !important; }

  /* Keep page titles visible */
  .tool-header { padding: 0 0 8px !important; }
  .tool-header h1, .tool-header .tool-eyebrow { color: #000 !important; }
  .tool-header p { color: #222 !important; }

  /* Show the result / report content cleanly */
  .card {
    border: none !important;
    background: #fff !important;
    padding: 0 !important;
    margin: 0 0 8px !important;
  }
  .result, .report {
    border: 1px solid #999 !important;
    background: #fff !important;
    color: #000 !important;
    border-radius: 0 !important;
    page-break-inside: avoid;
  }
  .result.empty { display: none !important; }
  .metric, table.data th, table.data td, .callout {
    background: #fff !important;
    color: #000 !important;
    border-color: #999 !important;
  }
  .metric .k, .metric .v, .metric .v small { color: #000 !important; }
  .tagline { border: 1px solid #999 !important; color: #000 !important; background: #fff !important; }
  a { color: #000 !important; text-decoration: none !important; }
}

/* ==========================================================================
   Accessibility helpers
   ========================================================================== */
.visually-hidden, .sr-only {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -52px; z-index: 200;
  background: var(--brand); color: #fff; padding: 10px 16px;
  border-radius: 0 0 8px 8px; font-weight: 650; transition: top .15s ease;
}
.skip-link:focus { top: 0; text-decoration: none; outline: 2px solid #fff; outline-offset: 2px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Slightly stronger contrast for muted text in light mode (WCAG AA) */
html:not([data-theme="dark"]) { --ink-faint: #5e7a88; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   UI-UX Pro Max — "Accessible & Ethical" polish
   Stronger focus rings (WCAG AAA) + comfortable touch targets
   ========================================================================== */
a:focus-visible, button:focus-visible, .btn:focus-visible, .tool-card:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible,
.seg button:focus-visible, .theme-toggle:focus-visible, .nav-toggle:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 4px var(--brand-soft); }

/* Minimum comfortable touch targets */
.btn { min-height: 44px; }
.btn.small { min-height: 34px; }
.seg button { min-height: 40px; }
.nav-links a { display: inline-flex; align-items: center; min-height: 40px; }

/* Emoji brand marks kept intentionally (original PulmApps identity); render crisply */
.brand .lung, .tool-card .ic, .tool-header h1 { font-synthesis: none; }
