.vp-chart {
  width: 100%;
  aspect-ratio: 1;
  max-width: 40rem;
  margin-inline: auto;
  position: relative;
  container-type: inline-size;
  background: var(--sw-bg);
  border: 1px solid var(--kundli-chart-border, var(--sw-stroke));
  border-radius: .5rem;
  overflow: clip;
  color: var(--sw-lavender);
}
.vp-chart svg { width: 100%; height: 100%; display: block; stroke: currentColor; stroke-width: .36; fill: none; }
.vp-house {
  --orb-standard: min(42px, 8.3cqw);
  --orb-size: var(--orb-standard);
  --orb-label: min(12px, 3cqw);
  --orb-gap: 2px;
  position: absolute;
  inset: 0;
  color: var(--sw-gold-light);
  text-decoration: none;
  font-weight: 750;
}
.vp-house[aria-current="true"] { background: rgb(246 183 60 / .28); color: var(--sw-gold-light); }
a.vp-house:not([aria-current="true"]):is(:hover, :focus-visible) { background: rgb(246 183 60 / .1); color: var(--sw-gold-light); }
.vp-chart:not(.vp-chart--south) .vp-house {
  inset: var(--north-inset);
  clip-path: var(--north-cell);
}
.vp-house--2, .vp-house--6 { --sign-x: 20%; }
.vp-house--8, .vp-house--12 { --sign-x: 80%; }
.vp-house--3, .vp-house--11 { --sign-y: 20%; }
.vp-house--5, .vp-house--9 { --sign-y: 80%; }
:is(.vp-house--1, .vp-house--4, .vp-house--7, .vp-house--10) { --sign-x: 50%; --sign-y: 20%; }
:is(.vp-house--2, .vp-house--12) { --orb-y: 40%; --sign-y: 16%; }
:is(.vp-house--6, .vp-house--8) { --orb-y: 60%; --sign-y: 84%; }
:is(.vp-house--3, .vp-house--5) { --orb-x: 36%; --sign-x: 16%; }
:is(.vp-house--9, .vp-house--11) { --orb-x: 64%; --sign-x: 84%; }
.vp-house-sign, .vp-orbs { position: absolute; transform: translate(-50%, -50%); }
.vp-house-sign { left: var(--sign-x); top: var(--sign-y); font-size: .75rem; line-height: 1; }
.vp-orbs {
  left: var(--orb-x, 50%);
  top: var(--orb-y, 50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--orb-gap);
  width: max-content;
  max-width: calc(var(--orb-size) * var(--orb-columns, 2) + var(--orb-gap) * (var(--orb-columns, 2) - 1));
}
.vp-orb { display: grid; justify-items: center; width: var(--orb-size); font-size: var(--orb-label); line-height: 1; }
.vp-orb img { width: var(--orb-size); height: var(--orb-size); max-width: none; }
.vp-chart:not(.vp-chart--south) :is(.vp-house--1, .vp-house--4, .vp-house--7, .vp-house--10) { --orb-columns: 3; }
.vp-house:has(.vp-orb:nth-child(3)) { --orb-size: min(36px, 5.5cqw); --orb-label: min(11px, 2.8cqw); }
.vp-chart:not(.vp-chart--south) :is(.vp-house--1, .vp-house--4, .vp-house--7, .vp-house--10):has(.vp-orb:nth-child(3)):not(:has(.vp-orb:nth-child(4))) {
  --orb-size: var(--orb-standard);
}
.vp-chart:not(.vp-chart--south) :is(.vp-house--2, .vp-house--12):has(.vp-orb:nth-child(4)) { --orb-y: 34%; }
.vp-chart:not(.vp-chart--south) :is(.vp-house--6, .vp-house--8):has(.vp-orb:nth-child(4)) { --orb-y: 66%; }
.vp-chart:not(.vp-chart--south) :is(.vp-house--6, .vp-house--8) .vp-orbs { flex-wrap: wrap-reverse; }
.vp-chart:not(.vp-chart--south) :is(.vp-house--2, .vp-house--6, .vp-house--8, .vp-house--12):has(.vp-orb:nth-child(3)) {
  --orb-columns: 3; --orb-size: min(33px, 5.2cqw);
}
.vp-house:has(.vp-orb:nth-child(5)),
.vp-chart:not(.vp-chart--south) :is(.vp-house--2, .vp-house--6, .vp-house--8, .vp-house--12):has(.vp-orb:nth-child(5)) {
  --orb-columns: 3; --orb-size: min(26px, 4.2cqw); --orb-label: min(11px, 2.45cqw); --orb-gap: 1px;
}
.vp-chart:not(.vp-chart--south) :is(.vp-house--2, .vp-house--6, .vp-house--8, .vp-house--12):has(.vp-orb:nth-child(7)) { --orb-columns: 4; }
.vp-chart:not(.vp-chart--south) :is(.vp-house--3, .vp-house--5, .vp-house--9, .vp-house--11):has(.vp-orb:nth-child(5)) {
  --orb-columns: 2; --orb-size: min(21px, 3.4cqw); --orb-label: min(10px, 2.1cqw);
}
.vp-chart--south { display: grid; grid-template: repeat(4, 1fr) / repeat(4, 1fr); }
.vp-chart--south svg { display: none; }
.vp-chart--south .vp-house { position: relative; border: 1px solid var(--kundli-chart-border, var(--sw-stroke)); }
.vp-chart--south .vp-orbs { left: 50%; top: 56%; }
.vp-chart--south .vp-house:has(.vp-orb:nth-child(3)) .vp-orbs { top: calc(50% + 7px); }
.vp-chart--south .vp-house:has(.vp-orb:nth-child(7)) { --orb-size: min(22px, 3.45cqw); --orb-label: min(10px, 2cqw); }
.vp-chart--south .vp-house:has(.vp-orb:nth-child(7)) .vp-orbs { top: auto; bottom: 1px; transform: translateX(-50%); }
.vp-chart--south .vp-house-sign { left: .25rem; top: .25rem; transform: none; }
.vp-south-r1 { grid-row: 1; }.vp-south-r2 { grid-row: 2; }.vp-south-r3 { grid-row: 3; }.vp-south-r4 { grid-row: 4; }
.vp-south-c1 { grid-column: 1; }.vp-south-c2 { grid-column: 2; }.vp-south-c3 { grid-column: 3; }.vp-south-c4 { grid-column: 4; }

@media (width < 640px) {
  .vp-house { --orb-standard: min(32px, 8.3cqw); }
}

/* At desktop chart widths, give crowded cells more room before shrinking orbs. */
@container (width >= 560px) {
  .vp-house:has(.vp-orb:nth-child(3)) { --orb-size: 36px; --orb-label: 11px; }
  .vp-chart--south .vp-house:has(.vp-orb:nth-child(5)) { --orb-columns: 3; }
  .vp-chart--south .vp-house:has(.vp-orb:nth-child(7)) { --orb-size: 36px; --orb-label: 11px; }
  .vp-house:has(.vp-orb:nth-child(5)) .vp-orb { position: relative; }
  .vp-house:has(.vp-orb:nth-child(5)) .vp-orb span {
    position: absolute;
    bottom: 0;
    background: var(--sw-bg);
    padding-inline: 2px;
    border-radius: 3px;
  }
  .vp-chart:not(.vp-chart--south) :is(.vp-house--2, .vp-house--6, .vp-house--8, .vp-house--12):has(.vp-orb:nth-child(3)) {
    --orb-size: 36px;
  }
  .vp-chart:not(.vp-chart--south) :is(.vp-house--2, .vp-house--12):has(.vp-orb:nth-child(7)) { --orb-y: 32%; --orb-columns: 5; }
  .vp-chart:not(.vp-chart--south) :is(.vp-house--6, .vp-house--8):has(.vp-orb:nth-child(7)) { --orb-y: 68%; --orb-columns: 5; }
  .vp-chart:not(.vp-chart--south) :is(.vp-house--3, .vp-house--5):has(.vp-orb:nth-child(3)) { --orb-x: 29%; }
  .vp-chart:not(.vp-chart--south) :is(.vp-house--9, .vp-house--11):has(.vp-orb:nth-child(3)) { --orb-x: 71%; }
  .vp-chart:not(.vp-chart--south) :is(.vp-house--3, .vp-house--5, .vp-house--9, .vp-house--11):has(.vp-orb:nth-child(5)) {
    --orb-size: 36px; --orb-label: 11px;
  }
  .vp-chart:not(.vp-chart--south) :is(.vp-house--3, .vp-house--5, .vp-house--9, .vp-house--11):has(.vp-orb:nth-child(7)) .vp-orbs {
    display: grid;
    grid-auto-flow: column;
    grid-template: repeat(5, var(--orb-size)) / repeat(2, var(--orb-size));
  }
  .vp-chart:not(.vp-chart--south) :is(.vp-house--9, .vp-house--11):has(.vp-orb:nth-child(7)) .vp-orbs { direction: rtl; }
  .vp-chart:not(.vp-chart--south) :is(.vp-house--3, .vp-house--5, .vp-house--9, .vp-house--11) {
    .vp-orb:nth-child(n+6) { grid-column: 2; }
    .vp-orb:nth-child(6) { grid-row: 2; }
    .vp-orb:nth-child(7) { grid-row: 3; }
    .vp-orb:nth-child(8) { grid-row: 4; }
  }
}

.vp-chart-layout {
  display: grid;
  gap: .65rem;
  align-items: start;
  min-width: 0;
}
.vp-chart-controls {
  display: flex;
  justify-content: center;
  gap: .35rem;
}
.vp-chart-controls[hidden] { display: none; }
.vp-chart-controls button {
  min-height: 44px;
  padding: .55rem .8rem;
  border: 1px solid var(--sw-stroke);
  border-radius: var(--sw-r-sm);
  background: var(--sw-surface3);
  color: var(--sw-ink);
  font: inherit;
  font-size: .9rem;
  font-weight: 800;
  cursor: pointer;
}
.vp-chart-controls button[aria-pressed="true"] { background: var(--sw-gold); color: var(--sw-on-gold); }
.vp-house-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .5rem;
}
.vp-house-card {
  min-width: 0;
  border: 1px solid var(--sw-stroke);
  border-radius: var(--sw-r-md);
  background: var(--sw-surface1);
}
.vp-house-card__link {
  display: block;
  padding: .65rem;
  min-height: 100%;
  scroll-margin-block-start: 6rem;
  border-radius: inherit;
  color: var(--sw-ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.vp-house-card:is([data-selected], :target, :hover, :focus-within) { border-color: var(--sw-gold); }
.vp-house-card__label { display: block; color: var(--sw-gold-light); font-size: .85rem; font-weight: 750; }
.vp-house-card p { margin: .3rem 0 0; font-size: .86rem; }
.vp-house-occupant { display: flex; align-items: start; gap: .4rem; margin-block-start: .45rem; }
.vp-house-occupant img { flex: none; }
.vp-house-occupant p { margin: 0; }
@media (width >= 640px) {
  .vp-house-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (width >= 1024px) {
  .vp-house-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.free-chat--funnel .free-chat__kundli:has(.vp-chart-layout) { grid-template-columns: minmax(0, 1fr); }
.free-chat--funnel .free-chat__kundli-chart:has(.vp-chart-layout) { max-width: none; }

/* A marked point in a house (the Varshphal Muntha): a gold chip over the orbs. */
.vp-orb-chip { order: -1; flex: 0 0 100%; grid-column: 1 / -1; display: flex; justify-content: center; }
.vp-orb-chip > span {
  padding: 2px 7px; border-radius: 999px; background: var(--sw-gold-light); color: var(--sw-on-gold);
  font-size: min(10px, 3cqw); font-weight: 800; line-height: 1.2; white-space: nowrap;
}
/* The worked example on the calculator page, as the approved board draws it. */
.vp-chart--example {
  max-width: 360px; margin-inline: auto; border-radius: 14px; border-color: rgb(217 134 26 / .9);
  background: radial-gradient(circle, #2b2462 0%, var(--sw-surface1) 75%); color: var(--sw-gold-deep);
}
.vp-chart--example svg { opacity: .9; }
.vp-chart--example .vp-house { color: var(--sw-ink); }
.vp-chart--example .vp-house-sign { color: #9d97bd; font-size: 11px; font-weight: 600; }
