/* Janma Kundli — the report on the page: a parchment "paper" with the PDF's content (rendered by
   astro/report/html.py from the same view model as the PDF), a contents sidebar and print styles.
   Colours and fills used inside the report are fixed classes (c-*, f-*): the CSP forbids inline styles. */

:root {
  --sheet: #fffcf4;
  --r-line: #a8957a;        /* table rules */
  --r-head: #efe2c5;        /* table header (PDF: grey #d1d3d4) */
  --r-label: #f6eedd;       /* label column (PDF: #e9eaeb) */
  --r-zebra: #fbf6ea;
  --r-current: #fbe3ab;     /* the running period (PDF: #fbf0d9) */
  --r-callout: #fbf1dc;
  --r-note: #4f4238;
}

/* ------------------------------------------------------------------ result card additions */
.sky-page { margin-top: 26px; }
.sky + .report-wrap { margin-top: -36px; }
button.btn-gold { border: 0; }
.btn-gold.is-preparing, .r-pdf.is-preparing { cursor: progress; filter: saturate(.55) brightness(.97); }
.btn-gold.is-preparing svg, .r-pdf.is-preparing svg { animation: jk-pulse 1.1s ease-in-out infinite; }
.btn-gold.is-error, .r-pdf.is-error { filter: hue-rotate(-18deg) saturate(.8); }
@keyframes jk-pulse { 50% { opacity: .3; transform: translateY(2px); } }

/* ------------------------------------------------------------------ layout: sidebar + paper */
.report-wrap { max-width: 1240px; margin: 0 auto 80px; padding: 0 28px; }
.r-report { display: grid; grid-template-columns: 228px minmax(0, 1fr); gap: 34px; align-items: start; }

.r-nav {
  position: sticky; top: 24px; z-index: 30; max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; gap: 16px; padding-top: 8px;
}
.r-nav-title, .r-toc > summary {
  margin: 0; font-size: 12.5px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-soft);
}
.r-nav-title { display: none; }
.r-toc > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.r-toc > summary::-webkit-details-marker { display: none; }
.r-toc > summary::after {
  content: ""; flex: none; width: 7px; height: 7px; margin-left: auto; border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .2s;
}
.r-toc[open] > summary::after { transform: translateY(1px) rotate(-135deg); }
.r-nav-current { display: none; }
.r-toc-list {
  list-style: none; margin: 10px 0 0; padding: 0 4px 0 0; border-left: 1px solid rgba(183, 121, 31, .5);
  max-height: calc(100vh - 210px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(183, 121, 31, .5) transparent;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 28px), transparent);
          mask-image: linear-gradient(#000 calc(100% - 28px), transparent);
  padding-bottom: 18px;
}
.r-toc-list a {
  display: block; margin-left: -1px; padding: 4px 8px 4px 14px; border-left: 2px solid transparent;
  font-size: 14.5px; line-height: 1.3; color: var(--ink-soft); text-decoration: none;
}
.r-toc-list a:hover { color: var(--maroon); background: rgba(223, 165, 58, .14); }
.r-toc-list a[aria-current] {
  color: var(--maroon); font-weight: 600; border-left-color: var(--vermilion);
  background: linear-gradient(90deg, rgba(223, 165, 58, .2), transparent 85%);
}
/* wide screens with JavaScript: the list is always open (report.js), so the toggle is not shown */
@media (min-width: 1021px) {
  .r-js .r-nav-title { display: block; }
  .r-js .r-toc > summary { display: none; }
  .r-js .r-toc-list { margin-top: 0; }
}

.r-nav-actions { display: flex; flex-direction: column; gap: 6px; }
.r-pdf {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 42px;
  padding: 9px 14px; border: 0; border-radius: 3px; cursor: pointer; text-decoration: none;
  font: inherit; font-size: 15.5px; font-weight: 600; color: #fff6e6; background: var(--maroon);
  box-shadow: inset 0 0 0 1px rgba(255, 220, 160, .28), 0 10px 20px -14px rgba(92, 21, 21, .9);
}
.r-pdf:hover { color: #fff; background: var(--maroon-deep); }
.r-pdf svg, .r-top svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.r-top { display: inline-flex; align-items: center; gap: 6px; padding: 6px 2px; font-size: 14.5px; color: var(--ink-soft); text-decoration: none; }
.r-top:hover { color: var(--maroon); }

/* ------------------------------------------------------------------ the paper */
.r-paper {
  min-width: 0; container-type: inline-size; margin: 7px;
  padding: 50px clamp(16px, 5.4vw, 64px) 64px;
  background: var(--sheet); color: var(--ink); font-size: 17px; line-height: 1.66;
  border: 1px solid rgba(122, 31, 31, .35);
  box-shadow: 0 0 0 6px var(--sheet), 0 0 0 7px rgba(183, 121, 31, .5), 0 40px 70px -40px rgba(80, 35, 10, .5);
  font-variant-numeric: lining-nums;
}
.r-paper p { margin: 0 0 14px; }
.r-paper strong { font-weight: 600; }
.r-paper :focus-visible { outline-offset: 2px; }

/* header (the PDF cover) */
.r-cover { text-align: center; padding-bottom: 8px; scroll-margin-top: 24px; }
.r-cover-mandala { width: 92px; margin: 0 auto 12px; }
.r-cover-mandala svg { display: block; width: 100%; height: auto; }
.r-paper .r-invocation { font-family: var(--display); font-size: 19px; color: #8a5a12; margin: 0 0 6px; }
.r-paper .r-brand { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .32em; text-transform: uppercase; color: var(--maroon); }
.r-paper .r-tagline { margin: 2px 0 0; font-size: 13.5px; letter-spacing: .12em; color: var(--ink-soft); }
.r-paper .r-doc-title { margin: 16px 0 0; font-family: var(--display); font-size: clamp(30px, 4vw, 42px); line-height: 1.08; color: var(--maroon); }
.r-paper .r-doc-sub { margin: 4px 0 0; font-style: italic; color: var(--ink-soft); }
.r-paper .r-prepared { margin: 18px 0 0; font-size: 12.5px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-soft); }
.r-paper .r-name { margin: 2px 0 14px; font-family: var(--display); font-size: clamp(28px, 3.6vw, 38px); line-height: 1.15; overflow-wrap: anywhere; }
.r-cover-details {
  display: grid; grid-template-columns: max-content minmax(0, max-content); justify-content: center;
  gap: 5px 16px; max-width: 600px; margin: 0 auto 16px; text-align: left; font-size: 16.5px; line-height: 1.45;
}
.r-cover-details > div { display: contents; }
.r-cover-details dt { color: var(--ink-soft); text-align: right; }
.r-cover-details dd { margin: 0; }
.r-paper .r-generated { margin: 0; font-size: 14.5px; color: var(--ink-soft); }
.r-paper .r-cover-note { margin: 2px 0 0; font-size: 14px; font-style: italic; color: var(--ink-soft); }

/* section titles: centred "॥ Title ॥" with the gold ornament rule, as in the PDF */
.r-section { margin-top: 76px; scroll-margin-top: 24px; }
.r-section-head { text-align: center; margin-bottom: 24px; }
.r-title {
  margin: 0; text-align: center; text-wrap: balance;
  font-family: var(--display); font-weight: 400; font-size: clamp(26px, 3.1vw, 35px); line-height: 1.18; color: var(--maroon);
}
.r-title .danda { font-size: .78em; color: var(--gold); padding: 0 .12em; }
.orn {
  position: relative; display: block; width: min(250px, 56%); height: 10px; margin: 10px auto 0;
  background:
    linear-gradient(var(--gold), var(--gold)) left center / calc(50% - 24px) 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right center / calc(50% - 24px) 1px no-repeat;
}
.orn::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  background: var(--gold); transform: rotate(45deg);
  box-shadow: 8.5px -8.5px 0 -1.5px var(--gold), -8.5px 8.5px 0 -1.5px var(--gold);
}
.r-cover .orn { margin: 14px auto 0; }
.r-paper .r-subtitle { margin: 8px 0 0; font-style: italic; color: var(--ink-soft); }

/* headings inside a section */
.r-h2, .r-h3, .r-caption { font-family: var(--text); font-weight: 600; text-wrap: balance; }
.r-h2 { margin: 36px 0 10px; font-size: 22px; line-height: 1.3; color: var(--maroon); }
.r-h3 { margin: 28px 0 8px; font-size: 18.5px; line-height: 1.35; color: var(--ink); }
.r-hgroup { margin: 34px 0 12px; }
.r-hgroup > h3, .r-hgroup > h4 { margin: 0; }
.r-paper .r-hsub { margin: 3px 0 0; font-size: 16px; font-weight: 600; color: var(--ink-soft); }
.r-caption { margin: 26px 0 8px; font-size: 17.5px; line-height: 1.35; color: var(--ink); }
.r-section-head + .r-caption, .r-section-head + .r-h2, .r-section-head + .r-hgroup { margin-top: 10px; }

/* text blocks */
.r-note { font-size: 15.5px; line-height: 1.6; color: var(--r-note); margin: 4px 0 16px; }
.r-note-sm { font-size: 14.5px; }
.r-note p { margin: 0 0 8px; }
.r-list-title { font-weight: 600; margin: 16px 0 4px !important; }
.r-list { margin: 6px 0 18px; padding-left: 1.7em; }
.r-list > li { margin-bottom: 8px; }
ul.r-list { list-style: none; }
ul.r-list > li { position: relative; }
ul.r-list > li::before {
  content: ""; position: absolute; left: -1.2em; top: .66em; width: 6px; height: 6px; background: var(--gold); transform: rotate(45deg);
}
ol.r-list > li::marker { color: var(--maroon); font-weight: 600; }
.r-callout {
  margin: 18px 0; padding: 12px 18px 12px 16px; background: var(--r-callout);
  border-left: 3px solid var(--gold); border-radius: 0 3px 3px 0;
}
.r-callout.tone-good { border-left-color: #166534; }
.r-callout.tone-warn { border-left-color: var(--maroon); }
.r-paper .r-callout-title { margin: 0 0 4px; font-weight: 600; color: var(--maroon); }
.r-callout p:last-child { margin-bottom: 0; }
.r-notebox {
  margin: 22px 0 8px; padding: 14px 18px; border: 1px solid #9d9083; border-radius: 10px;
  font-size: 14.5px; line-height: 1.55; color: #5a5048;
}
.r-paper .r-notebox-title { margin: 0 0 4px; font-weight: 600; }
.r-notebox p:last-child { margin-bottom: 0; }

/* text colours (html.py color_class) — all at least 4.5:1 on the paper and the table fills */
.c-red { color: #b91c1c; }
.c-rust { color: #9a3412; }
.c-green { color: #166534; }
.c-accent { color: var(--maroon); }
.c-gold { color: #7f5310; }
.c-muted { color: #5b4f45; }
.c-ink { color: var(--ink); }
.c-grey { color: #5a5048; }
.sc { font-variant: small-caps; }
.t-small { font-size: .88em; }
.t-large { font-size: 1.12em; }

/* ------------------------------------------------------------------ tables */
.r-table-wrap { overflow-x: auto; margin: 10px 0 18px; overscroll-behavior-x: contain; }
.r-table-wrap:focus-visible { outline: 2px solid var(--vermilion); }
.r-table-wrap.more-right {   /* report.js: more columns to the right */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), rgba(0, 0, 0, .25));
          mask-image: linear-gradient(to right, #000 calc(100% - 36px), rgba(0, 0, 0, .25));
}
.r-paper .r-scroll-hint { display: none; margin: 0 0 4px; font-size: 13.5px; font-style: italic; color: var(--ink-soft); }
.r-paper .r-scroll-hint::before { content: "\2194"; font-style: normal; margin-right: 6px; color: var(--gold); }
.r-table {
  width: 100%; border-collapse: collapse; background: #fffefb;
  font-size: 15px; line-height: 1.35; font-variant-numeric: lining-nums tabular-nums;
}
.r-table th, .r-table td { padding: 5px 8px; border: 1px solid var(--r-line); text-align: left; vertical-align: middle; }
.r-table thead th, .r-table thead .r-corner { background: var(--r-head); font-weight: 600; }
.r-table .r-label { background: var(--r-label); font-weight: 600; }
.r-table tr.r-zebra > td { background: var(--r-zebra); }
.r-band {
  caption-side: top; padding: 5px 8px; text-align: left; font-weight: 600;
  background: var(--r-head); border: 1px solid var(--r-line); border-bottom: 0;
}
.t-compact { font-size: 14.5px; }
.t-compact th, .t-compact td, .t-compact .r-band { padding: 4px 7px; }
.t-dense { font-size: 14px; line-height: 1.3; }
.t-dense th, .t-dense td, .t-dense .r-band { padding: 3px 6px; }
.t-large { font-size: 16px; }
/* many columns: set tighter, as the PDF does, so they fit the paper on a desktop */
.r-wide { font-size: 14px; }
.r-wide th, .r-wide td { padding: 4px 5px; }
.r-xwide, .r-col .r-wide { font-size: 12.5px; line-height: 1.25; }
.r-xwide th, .r-xwide td, .r-col .r-wide th, .r-col .r-wide td { padding: 3px; }
/* Tables that may scroll sideways (5+ columns) keep their row labels in view (html.py marks the
   .r-stick cells). Separate borders, so a stuck cell carries its own lines. */
.r-scroll { border-collapse: separate; border-spacing: 0; }
.r-scroll th, .r-scroll td { border-width: 0 1px 1px 0; }
.r-scroll tr > :first-child { border-left-width: 1px; }
.r-scroll thead tr:first-child > *, .r-scroll:not(:has(thead)) tbody tr:first-child > * { border-top-width: 1px; }
.r-stick { position: sticky; left: 0; z-index: 1; }
.r-scroll :where(td.r-stick) { background: #fffefb; }
.r-table .a-c { text-align: center; }
.r-table .a-r { text-align: right; }
/* cell fills (html.py fill_class) */
.r-table .f-head { background: var(--r-head); }
.r-table .f-label { background: var(--r-label); }
.r-table .f-zebra, .r-table .f-cream { background: var(--r-zebra); }
.r-table .f-current { background: var(--r-current); }
.r-table .f-diag { background: repeating-linear-gradient(135deg, #efe7d8 0 4px, #e4d9c5 4px 8px); }

/* key/value tables (Birth Details) */
.r-kv { font-size: 15.5px; }
.r-kv th { width: 44%; font-weight: 400; color: var(--ink-soft); background: #fffaf0; }
.r-kv-narrow th { width: 32%; }
.r-kv-fill th { background: var(--r-label); color: var(--ink); }
.r-kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 26px; align-items: start; }
.r-kv-block .r-caption { margin-top: 18px; }

/* label/value box (Traditional, Lal Kitab, KP headers) */
.r-info {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 18px;
  margin: 12px 0 24px; padding: 16px 18px; background: #fffefb; border: 1px solid rgba(43, 29, 22, .42); border-radius: 6px;
}
.r-info dt { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.r-info dd { margin: 1px 0 0; font-size: 15.5px; line-height: 1.35; text-wrap: pretty; }

/* small tables in a grid (dasha periods) */
.r-table-grid { display: grid; gap: 14px 16px; margin: 12px 0 20px; align-items: start; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.r-table-grid.tg-3 { grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); }
.r-table-grid.tg-4 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.r-mini .r-table-wrap { margin: 0; }

/* highlight cards */
.r-facts { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0 22px; padding: 0; }
.r-facts li { display: flex; flex-direction: column; padding: 10px 12px; background: var(--r-zebra); border: 1px solid rgba(183, 121, 31, .7); border-radius: 4px; }
.r-fact-label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.r-fact-value { font-family: var(--display); font-size: 23px; line-height: 1.2; color: var(--maroon); }
.r-fact-note { font-size: 14px; color: var(--ink); }

/* ------------------------------------------------------------------ charts and columns */
.r-chart { margin: 14px auto 22px; max-width: 420px; }
.r-chart-wide { max-width: 480px; }
.r-chart figcaption { margin: 0 0 6px; text-align: center; font-weight: 600; font-size: 16px; line-height: 1.35; }
/* Inline SVG from the PDF view: scale to the column; the site's text face replaces the PDF font. */
.r-chart svg { display: block; width: 100%; height: auto; font-family: var(--text); }
.r-chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px 32px; margin: 14px 0 22px; }
.r-chart-grid .r-chart { margin: 0; max-width: none; }
.r-cols { display: grid; gap: 4px 28px; align-items: start; margin: 6px 0; }
.r-cols.n-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.r-cols.n-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.r-cols.n-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.r-col { min-width: 0; }
.r-col > .r-chart:first-child { margin-top: 4px; }
.r-cols .r-chart { max-width: 100%; }

/* narrow paper (phones, small windows): stack columns; wide tables keep a readable width and
   scroll sideways inside their own box (never the page) */
@container (max-width: 660px) {
  .r-cols.n-2, .r-cols.n-3, .r-cols.n-4, .r-kv-grid { grid-template-columns: minmax(0, 1fr); }
  .r-cols .r-chart { max-width: 420px; }
  .r-wide { min-width: 600px; }
  .r-wide th, .r-wide td { white-space: nowrap; }   /* one line per row while scrolling sideways */
  .r-paper .r-scroll-hint { display: block; }
  .r-table-grid { grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 10px; }
  .r-table-grid.tg-3, .r-table-grid.tg-4 { grid-template-columns: minmax(0, 1fr); }
  .r-info { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); padding: 12px 14px; gap: 8px 14px; }
  .r-chart-grid { grid-template-columns: minmax(0, 1fr); }
  .r-table { font-size: 14.5px; }
  .t-dense { font-size: 13.5px; }
}

/* ------------------------------------------------------------------ narrow screens */
@media (max-width: 1020px) {
  .report-wrap { padding: 0 20px; }
  .r-report { display: block; }   /* block, not grid: the sticky bar then spans the whole report */
  .r-nav {
    top: 0; max-height: none; flex-direction: row; align-items: center; gap: 8px; margin: 0 0 14px; padding: 8px;
    background: rgba(251, 246, 234, .97); border: 1px solid rgba(122, 31, 31, .28); border-radius: 3px;
    box-shadow: 0 10px 22px -16px rgba(60, 25, 5, .6);
  }
  .r-toc { flex: 1 1 auto; min-width: 0; }
  .r-toc > summary {
    min-height: 42px; padding: 0 12px; border: 1px solid var(--field-line); border-radius: 3px; background: var(--field);
    font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--maroon);
  }
  .r-nav-current { display: block; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 400; color: var(--ink-soft); }
  .r-nav-current:not(:empty)::before { content: "·"; margin-right: 8px; color: var(--gold); }
  .r-toc-list {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 2; margin: 0; padding: 6px;
    max-height: min(70vh, 540px); background: var(--paper-hi); border: 1px solid rgba(122, 31, 31, .3); border-radius: 3px;
    box-shadow: 0 24px 40px -20px rgba(60, 25, 5, .55); -webkit-mask-image: none; mask-image: none;
  }
  .r-toc-list a { padding: 8px 12px; font-size: 15.5px; }
  .r-nav-actions { flex: none; flex-direction: row; gap: 6px; }
  .r-pdf { width: auto; min-width: 46px; padding: 0 12px; }
  .r-top { min-width: 42px; min-height: 42px; justify-content: center; border: 1px solid var(--field-line); border-radius: 3px; background: var(--field); }
  .r-section, .r-cover { scroll-margin-top: 76px; }
}
@media (max-width: 620px) {
  .report-wrap { padding: 0 6px; }
  .sky + .report-wrap { margin-top: -28px; }
  .r-paper { margin: 5px; padding: 34px 14px 40px; font-size: 16.5px; }
  /* charts: use the paper's side margins too, and set the small house numbers 15% larger
     (each scaled about its own centre, so nothing moves) */
  .r-chart, .r-cols .r-chart, .r-chart-grid .r-chart { margin-left: -9px; margin-right: -9px; }
  .r-chart .kundli-text > text[font-size] { transform-box: fill-box; transform-origin: center; transform: scale(1.15); }
  .r-section { margin-top: 56px; }
  .r-cover-details { grid-template-columns: max-content minmax(0, 1fr); font-size: 15.5px; gap: 4px 12px; }
  /* icon-only buttons in the bar; the label stays for screen readers */
  .r-pdf > span, .r-top > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ------------------------------------------------------------------ print: the report only */
@media print {
  body:has(.r-report) .masthead, body:has(.r-report) .hero, body:has(.r-report) .inside,
  body:has(.r-report) .time-note, body:has(.r-report) .colophon, .sky, .r-nav, .skip-link { display: none !important; }
  body { background: #fff !important; }
  .report-wrap { max-width: none; margin: 0 !important; padding: 0; }
  .r-report { display: block; }
  .r-paper { margin: 0; padding: 0; border: 0; box-shadow: none; background: none; font-size: 10.5pt; line-height: 1.5; }
  .r-section { margin-top: 26pt; }
  .r-lead { break-inside: avoid; }   /* a section title stays with its first block */
  .r-scroll-hint, .r-cover-mandala { display: none !important; }
  .r-section-head, .r-h2, .r-h3, .r-caption, .r-hgroup, .r-list-title { break-after: avoid; }
  .r-chart, .r-mini, .r-callout, .r-notebox, .r-info, .r-kv-block, .r-group, tr { break-inside: avoid; }
  .r-table-wrap { overflow: visible; }
  .r-wide { min-width: 0; }
  .r-table { font-size: 8.5pt; }
  .r-paper, .r-paper * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .r-paper a { color: inherit; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
  .btn-gold.is-preparing svg, .r-pdf.is-preparing svg { animation: none; }
}
