/* Medical astrology — the manual matrix, the Kālapuruṣa figure and the
   classical tables. Layers on the site's optical-glass tokens (--ink,
   --accent, --gold, --good, --bad, the .card.glass material). The figure is
   inline SVG in currentColor: the CSP allows no icon font and no CDN set. */

/* ── head ───────────────────────────────────────────────────────────── */
.md-head { margin: 6px 0 26px; }
.md-head h1 { margin: 0 0 10px; }
.md-head h1 .dev { font-weight: 600; color: var(--ink-soft); font-size: .72em; margin-left: 6px; }
.md-lede {
  max-width: 68ch; margin: 0 0 16px; font-size: 1.02rem; line-height: 1.7;
  color: var(--ink-soft);
}
.md-mode {
  max-width: 72ch; margin: 0 0 10px; font-size: .88rem; line-height: 1.65;
  color: var(--ink-soft); padding: 10px 14px; border-radius: 12px;
  border: 1px solid rgba(120, 150, 200, .26);
  background: rgba(255, 255, 255, .3);
}
.md-mode strong { color: var(--ink); }
.md-mode-care { border-color: color-mix(in srgb, var(--bad) 34%, transparent); }
.md-noscript {
  margin: 0 0 20px; padding: 10px 14px; border-radius: 12px; font-size: .88rem;
  border: 1px solid rgba(120, 150, 200, .3); background: rgba(255, 255, 255, .3);
}

/* ── sections ───────────────────────────────────────────────────────── */
.md-sec { margin: 34px 0 0; }
.md-sec-h {
  margin: 0 0 6px; font-size: .74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .18em; color: var(--ink-faint);
}
.md-sec-lede { margin: 0 0 16px; max-width: 68ch; font-size: .92rem; color: var(--ink-soft); line-height: 1.65; }
.md-basis { margin: 0; max-width: 72ch; font-size: .88rem; color: var(--ink-soft); line-height: 1.7; }

/* ── the matrix form ────────────────────────────────────────────────── */
.md-form { padding: 18px; display: grid; gap: 18px; }
.md-field { display: grid; gap: 6px; }
.md-label { font-size: .78rem; font-weight: 700; letter-spacing: .04em; color: var(--ink); }
.md-select {
  min-height: 44px; padding: 8px 12px; border-radius: 10px; font: inherit;
  font-size: .92rem; color: var(--ink); max-width: 34ch;
  border: 1px solid rgba(120, 150, 200, .4); background: rgba(255, 255, 255, .68);
}
.md-hint { margin: 2px 0 0; font-size: .78rem; color: var(--ink-faint); line-height: 1.55; }

.md-fs {
  margin: 0; padding: 12px 14px 14px; border-radius: 14px;
  border: 1px solid rgba(120, 150, 200, .28); background: rgba(255, 255, 255, .22);
}
.md-legend {
  padding: 0 6px; font-size: .78rem; font-weight: 700; letter-spacing: .04em;
  color: var(--ink);
}
.md-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.md-chip {
  display: inline-flex; align-items: center; min-height: 44px;
  padding: 4px 14px; border-radius: 999px; cursor: pointer;
  font-size: .86rem; font-weight: 600; color: var(--ink-soft);
  border: 1px solid rgba(120, 150, 200, .34); background: rgba(255, 255, 255, .34);
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.md-chip input {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.md-chip:hover { border-color: color-mix(in srgb, var(--accent) 44%, transparent); }
.md-chip:has(input:checked) {
  color: color-mix(in srgb, var(--accent) 76%, var(--ink));
  border-color: color-mix(in srgb, var(--accent) 56%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
/* Selection carries a mark, not only a tint — the chips are read by count. */
.md-chip:has(input:checked) .md-chip-txt::before {
  content: "\2713\00a0"; font-weight: 700;
}
.md-chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.md-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.md-btn {
  min-height: 44px; padding: 8px 18px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: .88rem; font-weight: 600; color: var(--ink-soft);
  border: 1px solid rgba(120, 150, 200, .38); background: rgba(255, 255, 255, .5);
}
.md-btn:hover { color: var(--ink); border-color: color-mix(in srgb, var(--accent) 46%, transparent); }

/* ── the figure ─────────────────────────────────────────────────────── */
.md-bodywrap {
  display: grid; gap: 16px; align-items: start;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
}
.md-figure { margin: 0; padding: 16px; }
.md-fig { display: block; width: 100%; height: auto; max-height: 62vh; margin: 0 auto; }

.md-seg { cursor: pointer; }
.md-seg rect, .md-seg circle {
  fill: color-mix(in srgb, var(--good) 20%, transparent);
  stroke: color-mix(in srgb, var(--good) 62%, var(--ink));
  stroke-width: 1.5;
  transition: fill .18s ease, stroke-width .18s ease;
}
.md-lvl-1 rect, .md-lvl-1 circle {
  fill: color-mix(in srgb, var(--gold) 30%, transparent);
  stroke: color-mix(in srgb, var(--gold) 78%, var(--ink));
  stroke-dasharray: 5 3;
}
.md-lvl-2 rect, .md-lvl-2 circle {
  fill: color-mix(in srgb, var(--bad) 26%, transparent);
  stroke: color-mix(in srgb, var(--bad) 76%, var(--ink));
  stroke-dasharray: 1.5 3; stroke-width: 2.4;
}
.md-seg.is-sel rect, .md-seg.is-sel circle { stroke-width: 3.2; }
.md-seg:hover rect, .md-seg:hover circle { fill: color-mix(in srgb, var(--accent) 22%, transparent); }
.md-seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.md-badge {
  font-size: 12px; font-weight: 700; fill: var(--ink);
  font-variant-numeric: tabular-nums; pointer-events: none;
}

.md-legend-key { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0 0; }
.md-key { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--ink-soft); }
.md-key::before { content: ""; width: 11px; height: 11px; flex: none; border-radius: 3px; border: 1.5px solid; }
.md-key-0::before {
  border-color: color-mix(in srgb, var(--good) 62%, var(--ink));
  background: color-mix(in srgb, var(--good) 20%, transparent);
}
.md-key-1::before {
  border-color: color-mix(in srgb, var(--gold) 78%, var(--ink));
  border-style: dashed;
  background: color-mix(in srgb, var(--gold) 30%, transparent);
}
.md-key-2::before {
  border-color: color-mix(in srgb, var(--bad) 76%, var(--ink));
  border-style: dotted; border-width: 2.4px;
  background: color-mix(in srgb, var(--bad) 26%, transparent);
}

/* ── the house table ────────────────────────────────────────────────── */
.md-houses { padding: 8px 8px 14px; }
.md-hlist { list-style: none; margin: 0; padding: 0; }
.md-hrow {
  display: grid; width: 100%; gap: 2px 12px; min-height: 44px;
  grid-template-columns: 5.6rem minmax(0, 7rem) minmax(0, 1fr) auto;
  align-items: center; text-align: left; cursor: pointer;
  padding: 8px 10px; border: 0; border-radius: 10px; background: none;
  font: inherit; color: var(--ink-soft);
  border-bottom: 1px solid rgba(120, 150, 200, .16);
}
.md-hlist li:last-child .md-hrow { border-bottom: 0; }
.md-hrow:hover { background: rgba(255, 255, 255, .4); }
.md-hrow.is-sel { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.md-h-no { font-size: .74rem; letter-spacing: .06em; color: var(--ink-faint); text-transform: uppercase; }
.md-h-num { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
.md-h-sign { font-weight: 700; color: var(--ink); font-size: .9rem; }
.md-h-parts { font-size: .82rem; color: var(--ink-soft); }
.md-h-state { font-size: .74rem; font-weight: 700; white-space: normal; }
.md-state-0 { color: color-mix(in srgb, var(--good) 78%, var(--ink)); }
.md-state-1 { color: color-mix(in srgb, var(--gold) 84%, var(--ink)); }
.md-state-2 { color: color-mix(in srgb, var(--bad) 82%, var(--ink)); }
.md-state-0::before, .md-state-1::before, .md-state-2::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px;
  vertical-align: baseline;
}
.md-state-0::before { border-radius: 50%; background: currentColor; }
.md-state-1::before {
  border-radius: 50%; border: 1.5px solid currentColor;
  background: linear-gradient(135deg, transparent 43%, currentColor 43% 57%, transparent 57%);
}
.md-state-2::before {
  background: currentColor;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

/* ── the computed cards ─────────────────────────────────────────────── */
.md-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.md-card { padding: 16px; }
.md-card-wide { grid-column: 1 / -1; }
.md-card-h {
  margin: 0 0 12px; font-size: .74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .16em; color: var(--ink-faint);
}
.md-sub-h { margin: 14px 0 6px; font-size: .8rem; font-weight: 700; color: var(--ink); }
.md-empty { margin: 0; font-size: .86rem; color: var(--ink-faint); font-style: italic; }
.md-formula { margin: 14px 0 0; font-size: .78rem; color: var(--ink-soft); line-height: 1.6; }
.md-cite {
  margin: 8px 0 0; font-size: .72rem; color: var(--ink-faint); line-height: 1.5;
  overflow-wrap: anywhere;
}
.md-note { margin: 8px 0 0; font-size: .8rem; color: var(--ink-soft); line-height: 1.6; }

.md-item {
  padding: 10px 0; border-bottom: 1px solid rgba(120, 150, 200, .16);
}
.md-item:last-child { border-bottom: 0; }
.md-item-h { margin: 0 0 4px; font-size: .92rem; font-weight: 700; color: var(--ink); line-height: 1.4; }
.md-item-p { margin: 0 0 3px; font-size: .84rem; color: var(--ink-soft); line-height: 1.6; }
.md-item-quiet .md-item-h { color: var(--ink-faint); }
.md-ph-optimal .md-item-h { color: color-mix(in srgb, var(--good) 78%, var(--ink)); }
.md-ph-moderate .md-item-h { color: color-mix(in srgb, var(--gold) 84%, var(--ink)); }
.md-ph-high .md-item-h { color: color-mix(in srgb, var(--bad) 82%, var(--ink)); }

.md-diet-list { margin: 0; padding-left: 18px; font-size: .84rem; color: var(--ink-soft); line-height: 1.6; }
.md-diet-list li { margin-bottom: 3px; }

/* ── the tridoṣa bars ───────────────────────────────────────────────── */
.md-bar-row { margin-bottom: 12px; }
.md-bar-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.md-bar-name { font-size: .84rem; font-weight: 700; color: var(--ink); }
.md-bar-val { font-size: .78rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.md-bar {
  height: 12px; border-radius: 999px; overflow: hidden;
  background: rgba(120, 150, 200, .16);
  border: 1px solid rgba(120, 150, 200, .24);
}
.md-bar-fill { display: block; height: 100%; border-radius: 999px; transition: width .28s ease; }
/* Each doṣa keeps a texture as well as a tone: the meter must still read as
   three distinct rows in greyscale and to a red-green colourblind reader. */
.md-bar-vata .md-bar-fill {
  background: repeating-linear-gradient(90deg,
    color-mix(in srgb, var(--accent) 62%, transparent) 0 6px,
    color-mix(in srgb, var(--accent) 30%, transparent) 6px 10px);
}
.md-bar-pitta .md-bar-fill {
  background: repeating-linear-gradient(45deg,
    color-mix(in srgb, var(--bad) 62%, transparent) 0 5px,
    color-mix(in srgb, var(--bad) 26%, transparent) 5px 10px);
}
.md-bar-kapha .md-bar-fill {
  background: color-mix(in srgb, var(--good) 54%, transparent);
}

/* ── the reference tables ───────────────────────────────────────────── */
.md-tables {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.md-table-card { padding: 16px; }
.md-table-wide { grid-column: 1 / -1; }
.md-dl { margin: 0; display: grid; grid-template-columns: minmax(0, 12rem) minmax(0, 1fr); gap: 4px 14px; }
.md-dl dt { font-size: .84rem; font-weight: 700; color: var(--ink); }
.md-dl dd { margin: 0; font-size: .84rem; color: var(--ink-soft); line-height: 1.55; }
.md-gem-fit { color: var(--ink-faint); }

/* ── birth details → the matrix ─────────────────────────────────────── */
/* Coordinates and offset are visible, required inputs, not hidden state: a
   required field the visitor cannot see is a form that refuses to submit and
   never says why. It also keeps the page honest about what was used. */
.md-birth { padding: 18px; display: grid; gap: 16px; }
.md-bgrid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.md-span2 { grid-column: 1 / -1; }
.md-bfield { display: grid; gap: 6px; font-size: .78rem; font-weight: 700; letter-spacing: .04em; color: var(--ink); }
.md-bfield input {
  min-height: 44px; padding: 8px 12px; border-radius: 10px; font: inherit;
  font-size: .92rem; font-weight: 400; letter-spacing: 0; color: var(--ink);
  border: 1px solid rgba(120, 150, 200, .4); background: rgba(255, 255, 255, .68);
}
.md-bfield input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.md-bfield small {
  font-size: .74rem; font-weight: 400; letter-spacing: 0;
  color: var(--ink-faint); line-height: 1.5;
}
.md-bcoords {
  display: grid; gap: 8px; padding: 12px 14px 14px; border-radius: 14px;
  border: 1px solid rgba(120, 150, 200, .28); background: rgba(255, 255, 255, .22);
}
.md-bcoords-l { font-size: .78rem; font-weight: 700; letter-spacing: .04em; color: var(--ink); }
.md-bcoords-row { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.md-bcoords-help { font-size: .74rem; color: var(--ink-faint); line-height: 1.55; }
.md-btn-go {
  color: var(--ink); font-weight: 700;
  border-color: color-mix(in srgb, var(--accent) 52%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, rgba(255, 255, 255, .62));
}
/* The outcome lines carry a word as well as a colour — a border tint alone
   would leave the state invisible to anyone who cannot see the difference. */
.md-berr, .md-bok {
  margin: 0; padding: 10px 12px; border-radius: 10px;
  font-size: .84rem; line-height: 1.6;
}
.md-berr {
  color: var(--ink); border: 1px solid color-mix(in srgb, var(--bad) 46%, transparent);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
}
.md-bok {
  color: var(--ink-soft); border: 1px solid color-mix(in srgb, var(--good) 46%, transparent);
  background: color-mix(in srgb, var(--good) 10%, transparent);
}
.md-bok strong { color: var(--ink); }

/* ── narrow ─────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .md-bodywrap { grid-template-columns: minmax(0, 1fr); }
  .md-fig { max-width: 240px; }
}
@media (max-width: 560px) {
  .md-hrow { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 10px; }
  .md-h-no { display: inline; }
  .md-dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .md-dl dd { margin-bottom: 8px; }
  .md-select { max-width: 100%; }
  .md-bgrid, .md-bcoords-row { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .md-chip, .md-seg rect, .md-seg circle, .md-bar-fill { transition: none; }
}

/* ── the download button ────────────────────────────────────────────────── */
.md-btn-pdf {
  display: inline-flex; align-items: center; gap: 8px;
  border-color: color-mix(in srgb, var(--gold) 50%, transparent);
  color: var(--ink);
}
.md-btn-pdf:hover { border-color: color-mix(in srgb, var(--gold) 78%, transparent); }
.md-btn-pdf svg { width: 17px; height: 17px; flex: none; }
.md-pdf-hint { margin-top: 2px; }

/* The report masthead, the basis summary and the sign-off exist only on
   paper; on screen the site's own header and footer already say all three. */
.md-rep-head, .md-rep-foot, .md-rep-only { display: none; }

/* ── print / save as PDF ─────────────────────────────────────────────────
   The saved document is this page, printed. Nothing here recomputes a single
   value: it hides the chrome and the controls, prints the chosen values as
   words instead, and keeps the colour that carries the reading. */
@media print {
  @page { size: A4; margin: 15mm 13mm 17mm; }

  /* Colour IS content here — the tridoṣa bars, the organ heat and the bio-pH
     band all read by hue. Browsers drop backgrounds by default, so ask for
     them explicitly and repeat the ask on the elements that carry them. */
  html, body {
    background: #fff; color: #101418;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* The site around the report. The reader saved a reading, not a website. */
  .samvat, .site-header, .site-footer, .crumbs, .sky-strip,
  .md-noscript, .md-actions, .md-pdf-hint, .md-birth, #birth,
  .md-legend-key, .nav-toggle, .nav-burger { display: none !important; }

  /* The "two ways in" note points at a form that is not in the printed copy;
     it explains a screen the reader no longer has. The care note stays — it
     is the one paragraph that belongs in the report more than on the page. */
  .md-mode:not(.md-mode-care) { display: none !important; }

  /* The form's own controls cannot print usefully — a checkbox on paper says
     nothing. #md-rep-basis prints the same state in words instead. */
  #matrix { display: none !important; }

  .md-rep-head, .md-rep-foot, .md-rep-only { display: block; }

  .stage, .page { display: block; margin: 0; padding: 0; max-width: none; }

  .md-rep-head {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 0 0 10px; margin: 0 0 16px;
    border-bottom: 2.5px solid #b8892b;
  }
  .md-rep-glyph { font-size: 30px; line-height: 1; color: #b8892b; }
  .md-rep-lock { display: flex; flex-direction: column; gap: 1px; }
  .md-rep-lock b { font-size: 15pt; letter-spacing: .01em; }
  .md-rep-lock b .dev { font-weight: 600; color: #5b6673; }
  .md-rep-lock span { font-size: 8.5pt; color: #3d4854; }
  .md-rep-site { color: #7a8794 !important; }
  .md-rep-meta {
    margin-left: auto; text-align: right;
    display: flex; flex-direction: column; gap: 2px;
  }
  .md-rep-meta b { font-size: 10pt; color: #b8892b; }
  .md-rep-meta span { font-size: 8.5pt; color: #3d4854; }

  .md-head h1 { font-size: 17pt; }
  .md-lede, .md-sec-lede, .md-basis { font-size: 9pt; max-width: none; }
  .md-mode { font-size: 9pt; }
  /* The caution travels with the report and is never allowed to be orphaned
     onto a page of its own away from the reading it qualifies. */
  .md-mode-care { break-inside: avoid; }

  .md-sec { margin: 14px 0 0; break-inside: auto; }
  .md-sec-h { font-size: 12pt; break-after: avoid; }
  .md-card-h, .md-item-h, .md-sub-h { break-after: avoid; }

  /* A card split across a page break loses the citation from the line it
     belongs to, which is the one thing this page promises never to do. */
  .md-card, .md-table-card, .md-figure, .md-houses, .md-hrow, .md-item {
    break-inside: avoid;
  }

  /* Glass is a screen material: on paper it is an empty rectangle. */
  .card, .card.glass, [data-glass] {
    background: #fff !important; backdrop-filter: none !important;
    border: 1px solid #d3dae2 !important; box-shadow: none !important;
  }

  .md-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .md-tables { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .md-bodywrap { grid-template-columns: 190px minmax(0, 1fr); gap: 12px; }
  .md-fig { max-height: none; max-width: 175px; }

  .md-rep-dl dt { color: #101418; }
  .md-rep-dl dd { color: #2b3540; }

  .md-rep-foot {
    margin: 18px 0 0; padding: 10px 0 0;
    border-top: 1.5px solid #b8892b; break-inside: avoid;
  }
  .md-rep-care {
    margin: 0 0 6px; font-size: 9pt; font-weight: 700; color: #8a2b2b;
  }
  .md-rep-sign { margin: 0; font-size: 8.5pt; color: #3d4854; }

  /* Link URLs are noise in a report nobody can click. */
  a { text-decoration: none; color: inherit; }
}
