/* Unified clinical Read-mode stylesheet for all 6 public guides.
   Aligned with landing.css palette, typography, elevation, and restraint. */

:root {
  --ink: #0f172a;
  --ink-soft: #1e293b;
  --muted: #475569;
  --muted-light: #64748b;
  --primary: #0369a1;
  --primary-hover: #075985;
  --blue: #0369a1;
  --blue-dark: #075985;
  --selection: #0284c7;
  --selection-bg: #e0f2fe;
  --paper: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --slate-deep: #0c2231;
  --slate-band: #112d3f;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  scroll-behavior: smooth;
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--selection-bg);
  color: var(--ink);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--selection);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Sticky Clinical Header (matches landing.css) */
.guide-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.guide-header-inner {
  width: min(1080px, calc(100% - 64px));
  min-height: 72px;
  height: 72px;
  margin-inline: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.guide-header .brand {
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.guide-header .brand-light {
  font-weight: 400;
  color: var(--muted);
}

.guide-header .brand-logo {
  width: 28px;
  height: 28px;
  color: var(--primary-hover);
}

.guide-header-links {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-left: auto;
}

.guide-header-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: color 180ms ease;
}

.guide-header-link:hover {
  color: var(--ink);
}

.guide-header .header-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 15px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: var(--surface);
  font-size: 13px;
  font-weight: 600;
  transition: background-color 180ms var(--ease-out);
}

.guide-header .header-cta:hover {
  background: var(--primary-hover);
  color: var(--surface);
}

/* Main Reading Container */
.guide {
  width: min(920px, calc(100% - 64px));
  margin-inline: auto;
}

/* Article Intro */
.guide-intro {
  padding: clamp(56px, 7vw, 84px) 0 40px;
  max-width: 760px;
}

.guide h1 {
  font-size: clamp(32px, 4.4vw, 50px);
  font-weight: 620;
  line-height: 1.09;
  letter-spacing: -0.034em;
  margin: 0 0 20px;
  text-wrap: balance;
  color: var(--ink);
}

.guide-intro p {
  font-size: clamp(16px, 1.5vw, 18px);
  line-height: 1.68;
  color: var(--muted);
  max-width: 64ch;
  margin: 0;
}

.guide-intro strong {
  color: var(--ink);
  font-weight: 600;
}

.guide-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 24px;
}

/* Buttons & Links */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  transition:
    background-color 180ms var(--ease-out),
    color 180ms var(--ease-out),
    transform 180ms var(--ease-out),
    box-shadow 180ms var(--ease-out);
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button-primary {
  background: var(--primary);
  color: var(--surface);
}

.button-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 8px 20px -6px rgba(15, 23, 42, 0.22);
}

.button-outline {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  min-height: 40px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 180ms ease, color 180ms ease, background-color 180ms ease;
}

.button-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--paper);
}

.text-link {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 5px 0;
  border-bottom: 1px solid var(--line-strong);
  transition: color 180ms ease, border-color 180ms ease;
}

.text-link:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.guide-inline-link {
  color: var(--ink);
  font-weight: 550;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  transition: color 180ms ease, text-decoration-color 180ms ease;
}

.guide-inline-link:hover {
  color: var(--primary);
  text-decoration-color: var(--primary);
}

/* In-Page Anchor Navigation */
.guide-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.guide-nav a {
  padding: 4px 0;
  transition: color 180ms ease;
}

.guide-nav a:hover {
  color: var(--primary);
}

/* Content Sections */
.guide-section {
  padding: 56px 0 0;
  scroll-margin-top: 88px;
}

.guide-section h2 {
  font-size: clamp(24px, 2.8vw, 32px);
  font-weight: 600;
  letter-spacing: -0.026em;
  line-height: 1.18;
  margin: 0 0 16px;
  text-wrap: balance;
  color: var(--ink);
}

.guide-section h3 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.38;
  margin: 28px 0 10px;
  color: var(--ink);
}

.guide-section p {
  max-width: 68ch;
  font-size: 16px;
  line-height: 1.76;
  color: var(--muted);
  margin: 0 0 16px;
}

.guide-section p strong {
  color: var(--ink);
  font-weight: 600;
}

.guide-list {
  max-width: 68ch;
  padding-left: 20px;
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.74;
}

.guide-list li + li {
  margin-top: 10px;
}

.guide-list strong {
  color: var(--ink);
  font-weight: 600;
}

/* Clinical Symbol Atlas Grid */
.symbol-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 28px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px -18px rgba(15, 23, 42, 0.1);
}

.symbol-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 162px;
  padding: 20px 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  transition: background-color 180ms ease;
}

.symbol-item:hover {
  background: var(--paper);
}

.symbol-item + .symbol-item {
  border-left: 1px solid var(--line);
}

.symbol-item:nth-child(4n + 1) {
  border-left: 0;
}

.symbol-item:nth-child(n + 5) {
  border-top: 1px solid var(--line);
}

.symbol-item small {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.4;
  max-width: 20ch;
}

.symbol-item svg {
  width: 100%;
  max-width: 118px;
  height: 68px;
  fill: none;
  stroke: #1e3a4c;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Diagram Example Frames */
.example {
  margin: 28px 0;
  background: var(--surface);
  padding: 28px 28px 18px;
  border: 1px solid #d5e0e8;
  border-radius: 10px;
  box-shadow: 0 12px 32px -18px rgba(15, 23, 42, 0.1);
}

.example svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}

.example-lines {
  fill: none;
  stroke: #1e3a4c;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.example-dashed {
  fill: none;
  stroke: #1e3a4c;
  stroke-width: 2;
  stroke-dasharray: 6 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.example-conflict {
  fill: none;
  stroke: #991b1b;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.example-close {
  fill: none;
  stroke: #065f46;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.example-labels {
  fill: var(--ink);
  font: 14px system-ui, sans-serif;
  text-anchor: middle;
}

.example-sublabels {
  fill: var(--muted);
  font: 12px system-ui, sans-serif;
  text-anchor: middle;
}

.example figcaption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted-light);
  font-size: 12px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* Case Narrative Sheet (aligned with landing trace-sheet) */
.case-extract {
  margin: 26px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 28px -18px rgba(15, 23, 42, 0.09);
}

.case-extract-header {
  padding: 12px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.case-extract blockquote {
  margin: 0;
  padding: 22px 24px;
  font-size: 16px;
  line-height: 1.72;
  color: var(--ink-soft);
  font-style: italic;
  max-width: 68ch;
}

.guide-section .case-extract-notes,
.case-extract-notes {
  margin: 0;
  padding: 16px 24px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
  max-width: none;
}

.case-extract-notes strong {
  color: var(--ink);
}

/* Comparison Tables */
.comparison-wrap {
  margin: 26px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.62;
  text-align: left;
  background: var(--surface);
}

.comparison-table th,
.comparison-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.comparison-table th {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
}

.comparison-table td {
  color: var(--muted);
}

.comparison-table tbody tr:last-child td {
  border-bottom: 0;
}

.comparison-table tbody tr:hover td {
  background: #fbfdff;
}

.comparison-table td strong {
  color: var(--ink);
  font-weight: 600;
}

/* CTA Band (matches landing closing slate band) */
.guide-cta-box {
  margin-top: 32px;
  padding: clamp(28px, 4vw, 38px);
  background: var(--slate-band);
  color: #f8fafc;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-cta-box h2 {
  margin: 0;
  color: #f8fafc;
  font-size: clamp(22px, 2.5vw, 28px);
}

.guide-cta-box p {
  margin: 0;
  max-width: 62ch;
  font-size: 15px;
  line-height: 1.65;
  color: #b8d1de;
}

.guide-cta-actions {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.guide-cta-box .button-primary {
  background: var(--surface);
  color: var(--slate-deep);
}

.guide-cta-box .button-primary:hover {
  background: #e6f2f8;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.35);
}

.guide-cta-box .text-link {
  color: #cfe3ed;
  border-bottom-color: rgba(207, 227, 237, 0.45);
}

.guide-cta-box .text-link:hover {
  color: #ffffff;
  border-bottom-color: #ffffff;
}

/* FAQ Accordion (matches landing.css) */
.guide-faq-list {
  border-top: 1px solid var(--line);
  margin-top: 22px;
}

.guide-faq-item {
  border-bottom: 1px solid var(--line);
}

details.guide-faq-item {
  padding: 0;
}

details.guide-faq-item summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--ink);
  transition: color 180ms ease;
}

details.guide-faq-item summary::-webkit-details-marker {
  display: none;
}

details.guide-faq-item summary:hover {
  color: var(--primary);
}

.faq-toggle {
  position: relative;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.faq-toggle::before,
.faq-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 1.5px;
  background: var(--muted);
  transition: transform 200ms var(--ease-out), opacity 200ms ease;
}

.faq-toggle::after {
  transform: rotate(90deg);
}

details.guide-faq-item[open] .faq-toggle::after {
  transform: rotate(0deg);
  opacity: 0;
}

details.guide-faq-item p {
  margin: 0;
  padding: 0 32px 20px 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--muted);
  max-width: 66ch;
}

article.guide-faq-item {
  padding: 20px 0;
}

article.guide-faq-item h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

article.guide-faq-item p {
  margin: 0;
}

/* Related Guides (2-column clean typographic index) */
.guide-related {
  padding: 56px 0 0;
}

.guide-related h2 {
  font-size: clamp(22px, 2.5vw, 28px);
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0 0 20px;
  color: var(--ink);
}

.guide-related-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 36px;
}

.guide-related-list article {
  padding: 18px 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-related-list article:nth-last-child(-n + 2) {
  border-bottom: 1px solid var(--line);
}

.guide-related-list h3 {
  font-size: 15px;
  margin: 0;
  font-weight: 600;
  line-height: 1.4;
}

.guide-related-list h3 a {
  color: var(--ink);
  transition: color 180ms ease;
}

.guide-related-list h3 a:hover {
  color: var(--primary);
}

.guide-related-list p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0;
}

/* Citation & Sources */
.guide-citation {
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 22px;
}

.guide-citation p {
  font-size: 14px;
  line-height: 1.62;
  margin: 0 0 8px;
}

.guide-citation p:last-child {
  margin-bottom: 0;
}

.guide-sources {
  padding-bottom: 84px;
}

.guide-sources ul {
  padding-left: 20px;
  margin: 0;
  max-width: 68ch;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.72;
}

.guide-sources li + li {
  margin-top: 8px;
}

.guide-sources a {
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  transition: color 180ms ease, text-decoration-color 180ms ease;
}

.guide-sources a:hover {
  color: var(--primary);
  text-decoration-color: var(--primary);
}

/* Footer (matches landing.css light clinical footer) */
.guide-footer {
  background: var(--paper);
  color: var(--ink);
  border-top: 1px solid var(--line);
}

.guide-footer-inner {
  width: min(1080px, calc(100% - 64px));
  margin-inline: auto;
  padding: 36px 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 14px;
}

.guide-footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.guide-footer-top a:first-child {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.guide-footer-top a:last-child {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.guide-footer-top a:hover {
  color: var(--primary-hover);
}

.guide-footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  font-size: 13px;
  color: var(--muted);
}

.guide-footer-nav a {
  transition: color 180ms ease;
}

.guide-footer-nav a:hover {
  color: var(--primary);
}

/* Responsive */
@media (max-width: 720px) {
  .guide-header-inner,
  .guide,
  .guide-footer-inner {
    width: calc(100% - 36px);
  }

  .guide-header-inner {
    min-height: 64px;
    height: 64px;
  }

  .guide-header .brand {
    font-size: 17px;
  }

  .guide-header-link {
    display: none;
  }

  .guide-intro {
    padding: 44px 0 32px;
  }

  .guide-nav {
    gap: 8px 16px;
  }

  .guide-section {
    padding-top: 44px;
  }

  .symbol-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .symbol-item:nth-child(odd) {
    border-left: 0;
  }

  .symbol-item:nth-child(even) {
    border-left: 1px solid var(--line);
  }

  .symbol-item:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .example {
    padding: 20px 14px 14px;
  }

  .case-extract-header,
  .case-extract blockquote,
  .case-extract-notes {
    padding-inline: 18px;
  }

  .guide-related-list {
    grid-template-columns: 1fr;
  }

  .guide-related-list article:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .guide-related-list article:last-child {
    border-bottom: 1px solid var(--line);
  }

  .guide-sources {
    padding-bottom: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

@media print {
  .guide-header,
  .guide-nav,
  .guide-toolbar,
  .guide-cta-box,
  .guide-related,
  .guide-footer,
  .no-print {
    display: none !important;
  }

  body {
    background: #ffffff;
  }

  .guide {
    width: 100%;
  }

  .guide-intro {
    padding: 12px 0 20px;
  }

  .guide-section {
    padding-top: 24px;
    break-inside: avoid;
  }

  .symbol-list,
  .example,
  .case-extract,
  .comparison-wrap {
    box-shadow: none;
    break-inside: avoid;
  }

  .comparison-table {
    font-size: 12px;
  }
}
