/* HemeOncBuddy site-wide styles
   ---------------------------------
   Palette: stone / rose (matches flashcards)
   Type: Georgia serif for body, system sans for UI chrome
*/

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --ink: #1c1917;          /* stone-900 */
  --ink-soft: #44403c;     /* stone-700 */
  --ink-faint: #78716c;    /* stone-500 */
  --line: #e7e5e4;         /* stone-200 */
  --line-strong: #d6d3d1;  /* stone-300 */
  --accent: #be123c;       /* rose-700 */
  --accent-soft: #fecdd3;  /* rose-200 */
  --bar: #0d1f4d;          /* deep navy (matches user swatch) */
  --bar-border: #081237;   /* darker navy for separators */
  --bar-hover: #1c3268;    /* nav link hover */
  --bar-active: #2a4288;   /* active nav link */
  --bar-text: #cbd5e1;     /* nav link default text */
  --header-stack-height: 6.5rem;  /* nav (~3.75rem) + disclaimer bar (~2rem) + buffer */
  --highlight: #fef3c7;    /* amber-100 */
  --highlight-line: #b45309; /* amber-700 */
  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* Always reserve space for the vertical scrollbar so columns don't shift
   ~15px sideways when content grows tall enough to need one.
   overflow-y:scroll is the cross-browser fallback (works everywhere);
   scrollbar-gutter:stable is the modern equivalent for browsers that have it. */
html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}
body {
  font-family: var(--serif);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* Sticky footer: pin .heb-footer-bar to the bottom of the viewport when
     content is short, while still flowing naturally when content is long. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ========== TOP NAV ========== */
.heb-nav {
  background: var(--bar);
  color: var(--bg);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--bar-border);
}
.heb-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
}
.heb-nav-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}
.heb-nav-brand-text {
  display: flex;
  flex-direction: column;
}
.heb-nav-eyebrow {
  font-family: var(--sans);
  font-size: 0.625rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #fda4af; /* rose-300 */
  font-weight: 600;
}
.heb-nav-title {
  font-style: italic;
  font-size: 1rem;
}
.heb-nav-links {
  display: flex;
  gap: 0.25rem;
  font-family: var(--sans);
  font-size: 0.875rem;
}
.heb-nav-link {
  color: var(--bar-text);
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border-radius: 0.375rem;
  transition: background 120ms;
}
.heb-nav-link:hover { background: var(--bar-hover); color: #fafaf9; }
.heb-nav-link.active { background: var(--bar-active); color: #fafaf9; }

/* ========== PAGE CONTAINER ========== */
.heb-page {
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  box-sizing: border-box;
}
.heb-page-header h1 {
  font-size: 1.75rem;
  margin: 0 0 0.25rem;
  letter-spacing: -0.01em;
}
.heb-page-header p {
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
}

/* ========== BUTTONS / CHIPS ========== */
.heb-btn {
  font-family: var(--sans);
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.heb-btn:hover { background: var(--ink-soft); }
.heb-chip {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--surface);
}

/* ========== DISCLAIMER ========== */
/* Thin persistent disclaimer strip beneath the nav.
   Replaces the older amber .heb-disclaimer block — same safety message,
   far less visual real estate, and uses the existing navy palette so we
   don't introduce a third accent hue. */
.heb-disclaimer-bar {
  background: #081237;        /* one shade darker than --bar for separation */
  color: #fef3c7;             /* warm amber text — keeps the warning cue */
  border-bottom: 1px solid #04081f;
  padding: 0.4rem 1.25rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-align: center;
}
.heb-disclaimer-bar strong { color: #fde68a; font-weight: 600; }
@media (max-width: 540px) {
  .heb-disclaimer-bar { font-size: 0.7rem; padding: 0.4rem 0.75rem; }
}

/* Sticky header stack: nav + disclaimer bar both stay pinned to the top
   together while scrolling. */
.heb-header-stack {
  position: sticky;
  top: 0;
  z-index: 50;
}

/* Legacy in-page disclaimer rule retained for any holdout markup —
   collapses to nothing so a stray .heb-disclaimer div renders harmlessly. */
.heb-disclaimer { display: none; }

/* ========== UTIL ========== */
.heb-muted { color: var(--ink-faint); }
.heb-small { font-size: 0.8125rem; }
.heb-divider { height: 1px; background: var(--line); margin: 1.5rem 0; border: 0; }

/* ========== BOTTOM BAR (universal footer) ========== */
.heb-footer-bar {
  background: var(--bar);
  color: var(--bar-text);
  border-top: 1px solid var(--bar-border);
  padding: 1.1rem 1.25rem;
  font-family: var(--sans);
  font-size: 0.8125rem;
  line-height: 1.5;
  text-align: center;
  margin-top: auto;       /* pushes footer to bottom of body flex column */
  flex-shrink: 0;
}
.heb-footer-bar a { color: #fda4af; text-decoration: none; }
.heb-footer-bar a:hover { text-decoration: underline; }
.heb-footer-bar p { margin: 0.15rem 0; }
.heb-footer-bar .heb-footer-brand {
  color: #fafaf9;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
}
.heb-footer-bar .heb-footer-app {
  margin: 0.55rem 0 0.4rem;
  display: flex;
  justify-content: center;
  align-items: center;
}
.heb-footer-bar .heb-footer-app img {
  height: 40px;
  width: auto;
  vertical-align: middle;
  transition: transform 150ms ease;
}
.heb-footer-bar .heb-footer-app img:hover { transform: scale(1.05); }

/* ========== MOBILE OPTIMIZATIONS ========== */

/* Below 640px: tighten the nav, hide the long subtitle so the brand stays
   compact next to the wrapping link row. */
@media (max-width: 640px) {
  .heb-nav {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }
  .heb-nav-logo { width: 30px; height: 30px; }
  .heb-nav-eyebrow { font-size: 0.6rem; letter-spacing: 0.18em; }
  .heb-nav-title {
    font-size: 0.85rem;
    /* Hide the long descriptive tagline on phones */
    display: none;
  }
  .heb-nav-links {
    width: 100%;
    justify-content: space-between;
    gap: 0;
    flex-wrap: wrap;
  }
  .heb-nav-link {
    padding: 0.6rem 0.85rem;
    font-size: 0.85rem;
  }
  /* Tighter page padding on mobile */
  .heb-page {
    padding: 1.25rem 1rem 3rem;
  }
  .heb-page-header h1 {
    font-size: 1.4rem;
  }
  .heb-page-header p {
    font-size: 0.95rem;
    margin-bottom: 1rem;
  }
}

/* Below 540px: tighten the footer too */
@media (max-width: 540px) {
  .heb-footer-bar {
    padding: 0.9rem 0.75rem;
    font-size: 0.75rem;
  }
  .heb-footer-bar .heb-footer-app img {
    height: 36px;
  }
  .heb-footer-bar .heb-footer-brand {
    font-size: 0.85rem;
  }
}

/* ========== SIDEBAR CATEGORY COLOR CODING ========== */
/* Applied to the outermost <details> on trials (cat1) and notes (cat2) so the
   tree visually groups by Malignant Heme / Medical Onc / Classical Heme.
   Same rose / navy / amber palette used on the Stats page. */
.sidebar .cat-block {
  border-radius: 0.5rem;
  padding: 0.2rem 0.3rem;
  margin-bottom: 0.4rem;
}
.sidebar .cat-malignant-hematology  { background: #fdf2f4; }   /* very light rose */
.sidebar .cat-medical-oncology      { background: #f0f4f8; }   /* very light navy */
.sidebar .cat-classical-hematology  { background: #fdf6eb; }   /* very light amber */
.sidebar .cat-benign-hematology     { background: #fdf6eb; }   /* very light amber (same family as classical) */
.sidebar .cat-radiation-oncology    { background: #ecfdf5; }   /* very light teal */
.sidebar .cat-pharmacology          { background: #f5f0fb; }   /* very light purple */

/* Cat label text in category color — reads as the section identity */
.sidebar .cat-malignant-hematology  > summary { color: #be123c; }
.sidebar .cat-medical-oncology      > summary { color: #1e3a5f; }
.sidebar .cat-classical-hematology  > summary { color: #b45309; }
.sidebar .cat-benign-hematology     > summary { color: #b45309; }
.sidebar .cat-radiation-oncology    > summary { color: #0f766e; }
.sidebar .cat-pharmacology          > summary { color: #6b21a8; }

/* Active selection uses the category color (was solid black). Works for
   trials' .lvl3 anchors and notes' .note-link anchors equally. */
.sidebar .cat-malignant-hematology .lvl3.active,
.sidebar .cat-malignant-hematology .note-link.active  { background: #be123c; color: #fafaf9; }
.sidebar .cat-medical-oncology .lvl3.active,
.sidebar .cat-medical-oncology .note-link.active      { background: #1e3a5f; color: #fafaf9; }
.sidebar .cat-classical-hematology .lvl3.active,
.sidebar .cat-classical-hematology .note-link.active  { background: #b45309; color: #fafaf9; }
.sidebar .cat-radiation-oncology .lvl3.active,
.sidebar .cat-radiation-oncology .note-link.active    { background: #0f766e; color: #fafaf9; }
.sidebar .cat-benign-hematology .lvl3.active,
.sidebar .cat-benign-hematology .note-link.active     { background: #b45309; color: #fafaf9; }
.sidebar .cat-pharmacology .lvl3.active,
.sidebar .cat-pharmacology .note-link.active          { background: #6b21a8; color: #fafaf9; }
/* Soften the count chip color when row is active */
.sidebar .cat-block .lvl3.active .count,
.sidebar .cat-block .note-link.active .count { color: rgba(250, 250, 249, 0.78); }



/* =====================================================================
   PRINT STYLESHEET — Cmd+P / Save-as-PDF support
   When a user prints a note, trial, or flashcards deck, strip all the
   interactive chrome (nav links, sidebar, search, filters, share buttons,
   footer ads) and show a clean branded header at the top of page 1
   followed by content with sensible page breaks. Logo at the top via
   the existing .heb-nav-brand element repurposed for print.
   ===================================================================== */
@media print {
  /* Force light, ink-on-paper rendering. Cancel decorative shadows AND
     cancel the screen-time sticky-footer flex column + 100vh on body that
     was inflating the page and dragging the nav toward vertical center. */
  html, body {
    background: #ffffff !important;
    color: #1c1917 !important;
    font-size: 11pt !important;
  }
  body {
    /* `display: table` + `display: table-header-group` is the standard trick
       to repeat content (the logo header) on every printed page. Browsers
       automatically render table-header-group children at the top of each
       page when the table overflows. */
    display: table !important;
    width: 100% !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  html { overflow-y: auto !important; }
  /* Make the wrapper a table-header-group so it repeats. The nav inside it
     becomes the running logo on every page. */
  .heb-header-stack { display: table-header-group !important; }
  /* Main content area becomes the body of the table */
  .heb-page { display: table-row-group !important; }
  /* table-row-group needs cells/rows underneath to render — but block-level
     children inside a table-row-group are wrapped in anonymous rows/cells
     by the browser, which works for our purposes. */

  /* @page sets the paper margins and adds a small URL footer on every page.
     Bottom-right margin box is supported by Chrome/Edge/Safari; Firefox
     falls back to no footer (acceptable). */
  @page {
    margin: 0.75in 0.55in 0.8in 0.55in;
    @bottom-left  { content: "hemeoncbuddy.org"; font-size: 8.5pt; color: #78716c; }
    @bottom-right { content: "page " counter(page); font-size: 8.5pt; color: #78716c; }
  }

  /* === Header: centered, large logo on top, brand stacked below ===
     Use plain block + text-align rather than flex column with justify-content
     center, because flex column's justify-content centers VERTICALLY in
     available space — and in print the body can be tall enough to drag the
     logo to the middle of the paper. */
  .heb-header-stack { display: block !important; margin-top: 0 !important; padding-top: 0 !important; }
  .heb-nav {
    background: #ffffff !important;
    color: #1c1917 !important;
    border-bottom: 2px solid #be123c !important;
    padding: 0.25rem 0 0.7rem !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: block !important;
    text-align: center !important;
    page-break-after: avoid;
    page-break-inside: avoid;
  }
  .heb-nav-brand {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 0.3rem !important;
    color: #1c1917 !important;
  }
  /* 3× the previous print size (44px → 132px) */
  .heb-nav-logo  { width: 132px !important; height: 132px !important; }
  .heb-nav-brand-text {
    align-items: center !important;
    gap: 0.15rem !important;
  }
  .heb-nav-eyebrow {
    color: #be123c !important;
    letter-spacing: 0.22em !important;
    font-size: 11pt !important;
    font-weight: 700 !important;
  }
  .heb-nav-title {
    color: #1c1917 !important;
    font-style: normal !important;
    font-weight: 500 !important;
    font-size: 10pt !important;
  }
  /* Hide top-nav link list, disclaimer ribbon, and the page footer */
  .heb-nav-links,
  .heb-disclaimer-bar,
  .heb-footer-bar { display: none !important; }

  /* === Chrome that's irrelevant on paper === */
  .sidebar, aside.sidebar { display: none !important; }
  input[type="search"], input[type="text"].search,
  .flashcards-search, #search, #year, .year-filter,
  .filters, .controls,
  .toolbar, #result-count,
  .flashcards-page-header,
  .heb-page-header p,
  #year-filter,
  select { display: none !important; }
  /* Keep page-header h1 small and tight so the logo header dominates */
  .heb-page-header { margin: 0.4rem 0 0.6rem !important; padding: 0 !important; }
  .heb-page-header h1 { font-size: 13pt !important; margin: 0 !important; }
  /* No extra top margin on the navy/branded header — it must be at the very
     top of page 1, not pushed down by container padding */
  .heb-page { padding: 0.25rem 0 0 !important; }
  .heb-header-stack { margin: 0 !important; padding: 0 !important; }
  /* Share buttons we just added */
  .note-share-btn, .trial-share-btn { display: none !important; }
  /* Flashcards prev/reveal/next/shuffle/reset row — keep cards, drop buttons */
  [data-fc-action], #root button.bg-rose-800,
  #root button.border.border-stone-900,
  #root button.border-stone-300 { display: none !important; }

  /* === Force any collapsed <details> open so the printed page is complete === */
  details:not([open]) > *:not(summary) { display: revert !important; }
  details > summary { list-style: none; }
  details > summary::-webkit-details-marker { display: none; }
  details { page-break-inside: avoid; }

  /* === Reset layout so content uses the full printable width === */
  .layout, .flashcards-layout, .heb-page, main, #content, #root {
    display: block !important;
    grid-template-columns: none !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Strip card shadows / rounded corners — they look weird in print */
  .card, .deck-card, .note-body, .trial,
  #root [data-fc-action="flip"],
  #root .bg-white.border.border-stone-900 {
    box-shadow: none !important;
    border-radius: 0 !important;
    border-color: #d6d3d1 !important;
    transform: none !important;
  }

  /* Notes: in-note TOC sits in a small floated box at the top-right of the
     note body — same general shape as on screen, just denser for paper. */
  .note-toc {
    display: block !important;
    float: right !important;
    width: 165px !important;
    max-width: 35% !important;
    margin: 0 0 0.5rem 0.75rem !important;
    padding: 0.4rem 0.55rem !important;
    background: #fafafa !important;
    border: 1px solid #d6d3d1 !important;
    border-left: 2px solid #be123c !important;
    border-radius: 0 !important;
    font-size: 8pt !important;
    line-height: 1.25 !important;
    page-break-inside: avoid;
  }
  .note-toc-title {
    font-size: 7pt !important;
    letter-spacing: 0.08em !important;
    color: #be123c !important;
    margin-bottom: 0.2rem !important;
  }
  .note-toc ul { margin: 0 !important; padding: 0 !important; }
  .note-toc li { margin: 0 !important; }
  .note-toc a {
    color: #1c1917 !important;
    padding: 0.05rem 0 !important;
    border: 0 !important;
    font-size: 7.5pt !important;
  }
  .note-toc a.lvl-3 { padding-left: 0.5rem !important; font-size: 7pt !important; color: #44403c !important; }
  .note-toc a.lvl-4 { padding-left: 0.9rem !important; font-size: 7pt !important; color: #525252 !important; }
  .note-title { font-size: 18pt; margin-top: 0.5rem; }
  .note-meta { color: #525252 !important; }
  .note-body h2 { font-size: 14pt; margin-top: 1rem; page-break-after: avoid; }
  .note-body h3 { font-size: 12pt; margin-top: 0.75rem; page-break-after: avoid; }
  .note-body p, .note-body li { page-break-inside: avoid; }
  .source-link { color: #44403c !important; text-decoration: none; }
  .source-link::after { content: " (" attr(href) ")"; color: #78716c; font-size: 9pt; }

  /* Trials: render each trial as a clean block */
  .trial { border: 1px solid #d6d3d1; margin: 0 0 0.6rem; padding: 0.4rem 0.5rem; }
  .trial summary { font-weight: 600; }
  .trial-title { color: #1c1917 !important; }
  .trial-year { color: #be123c !important; font-weight: 600; }
  .trial-body { padding: 0.3rem 0 0.2rem; }

  /* Flashcards: show only the active card front + back (already stacked
     after the flip-removal). Hide the empty-state placeholder. */
  .flashcards-empty { display: none !important; }
  /* Visual SVGs scale to print page */
  #root svg.card-svg, #root .card-svg { max-width: 100%; height: auto; }

  /* Don't break links across pages */
  a { color: inherit !important; text-decoration: none; }
}
