/* ==========================================================================
   JyotirVed Engine — D3 Parivritti Traya / Practical Karma-Gati Redesign
   Synchronized with Light, Cosmic Midnight Dark & custom palettes
   ========================================================================== */

.d3kg-container {
  color: var(--ink, #0f172a);
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  background: var(--paper, #ffffff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
}

body.dark .d3kg-container {
  background: var(--paper, #0c1527);
  border-color: var(--line, rgba(223, 177, 91, 0.22));
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

/* ==========================================================================
   Hero Header Banner
   ========================================================================== */
.d3kg-hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  background: #f8fbff;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.04);
}

body.dark .d3kg-hero {
  background: #0f1a2e;
  border-color: rgba(59, 130, 246, 0.25);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.d3kg-hero-left {
  flex: 1.2;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  z-index: 2;
  min-width: 0;
}

.d3kg-eyebrow {
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #0284c7;
  margin-bottom: 6px;
}

body.dark .d3kg-eyebrow {
  color: #38bdf8;
}

.d3kg-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.d3kg-cornucopia-icon {
  font-size: 22px;
  line-height: 1;
}

.d3kg-hero-left h1 {
  margin: 0;
  font-size: 23px;
  font-weight: 700;
  font-family: var(--font-serif, "Georgia", serif);
  color: #0f2d59;
  letter-spacing: -0.2px;
  line-height: 1.25;
}

body.dark .d3kg-hero-left h1 {
  color: #93c5fd;
}

.d3kg-hero-desc {
  margin: 0 0 16px 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: #475569;
  max-width: 650px;
}

body.dark .d3kg-hero-desc {
  color: #94a3b8;
}

/* Dasha Pills in Hero */
.d3kg-dasha-pills {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.d3kg-dasha-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 8px 14px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.05);
}

body.dark .d3kg-dasha-pill {
  background: #132238;
  border-color: rgba(59, 130, 246, 0.3);
}

.d3kg-dasha-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.d3kg-icon-blue {
  background: #e0f2fe;
  color: #0284c7;
}

.d3kg-icon-amber {
  background: #fef3c7;
  color: #d97706;
}

body.dark .d3kg-icon-blue {
  background: rgba(2, 132, 199, 0.25);
  color: #38bdf8;
}

body.dark .d3kg-icon-amber {
  background: rgba(217, 119, 6, 0.25);
  color: #fbbf24;
}

.d3kg-dasha-text {
  display: flex;
  flex-direction: column;
}

.d3kg-dasha-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

body.dark .d3kg-dasha-label {
  color: #94a3b8;
}

.d3kg-dasha-val {
  font-size: 12.5px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
}

body.dark .d3kg-dasha-val {
  color: #f1f5f9;
}

/* Right Illustration in Hero */
.d3kg-hero-banner {
  flex: 0.9;
  min-width: 260px;
  max-width: 440px;
  position: relative;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.d3kg-hero-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #f8fbff 0%, rgba(248, 251, 255, 0.35) 45%, transparent 100%);
  pointer-events: none;
}

body.dark .d3kg-hero-banner::before {
  background: linear-gradient(90deg, #0f1a2e 0%, rgba(15, 26, 46, 0.45) 45%, transparent 100%);
}

.d3kg-hero-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================================================
   Top Grid: D3 Chart & Current Mahadasha Movement Map
   ========================================================================== */
.d3kg-top-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 18px;
  margin-bottom: 20px;
}

.d3kg-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
}

body.dark .d3kg-card {
  background: #111d30;
  border-color: rgba(139, 160, 184, 0.18);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.d3kg-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.d3kg-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
  color: #1e293b;
  font-family: var(--font-sans);
}

body.dark .d3kg-card-title {
  color: #f1f5f9;
}

.d3kg-study-link {
  font-size: 11px;
  color: #0284c7;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.d3kg-study-link:hover {
  text-decoration: underline;
}

body.dark .d3kg-study-link {
  color: #38bdf8;
}

/* Chart Canvas Box */
.d3kg-chart-box {
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.d3kg-chart-box .astro-chart-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.d3kg-chart-box .chart-svg-box {
  order: 1;
  width: 100%;
}

.d3kg-chart-box svg {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  display: block;
}

.d3kg-chart-box .chart-note {
  display: none;
}

.d3kg-chart-meta {
  order: 2;
  text-align: center;
  margin: 10px 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
}

body.dark .d3kg-chart-meta {
  color: #cbd5e1;
}

.d3kg-chart-box .chart-action-bar {
  order: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  width: 100%;
}

.d3kg-chart-box .btn-chart-action {
  padding: 4px 11px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid #bfdbfe;
  background: #f0f7ff;
  color: #1d4ed8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

body.dark .d3kg-chart-box .btn-chart-action {
  background: #15243c;
  border-color: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.d3kg-chart-box .btn-chart-action:hover {
  background: #dbeafe;
  color: #1e40af;
}

body.dark .d3kg-chart-box .btn-chart-action:hover {
  background: #1e3a8a;
  color: #ffffff;
}

.d3kg-chart-box .btn-chart-action.btn-chart-active {
  background: #2563eb;
  border-color: #1d4ed8;
  color: #ffffff;
}

.d3kg-rotate-row {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.d3kg-rotate-row span {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}

body.dark .d3kg-rotate-row span {
  color: #94a3b8;
}

.d3kg-rotate-select {
  width: 100%;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink, #1e293b);
  background: var(--paper, #ffffff);
  border: 1px solid var(--line, #cbd5e1);
  border-radius: 8px;
  cursor: pointer;
  outline: none;
}

body.dark .d3kg-rotate-select {
  background: #132238;
  border-color: rgba(59, 130, 246, 0.25);
  color: #f1f5f9;
}

/* ==========================================================================
   Right Card: Current Mahadasha Movement Map Timeline
   ========================================================================== */
.d3kg-map-list {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 20px;
  margin: 4px 0 0;
}

/* Connecting vertical timeline track */
.d3kg-map-list::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 14px;
  bottom: 24px;
  width: 2px;
  background: #e2e8f0;
}

body.dark .d3kg-map-list::before {
  background: rgba(139, 160, 184, 0.2);
}

.d3kg-map-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

body.dark .d3kg-map-item {
  border-bottom-color: rgba(139, 160, 184, 0.08);
}

.d3kg-map-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.d3kg-map-dot {
  position: absolute;
  left: -20px;
  top: 15px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid #0284c7;
  z-index: 2;
  box-shadow: 0 0 0 2px #ffffff;
}

body.dark .d3kg-map-dot {
  background: #111d30;
  box-shadow: 0 0 0 2px #111d30;
}

.d3kg-dot-blue { border-color: #0284c7; }
.d3kg-dot-yellow { border-color: #eab308; }
.d3kg-dot-rose { border-color: #f43f5e; }
.d3kg-dot-purple { border-color: #a855f7; }
.d3kg-dot-green { border-color: #10b981; }
.d3kg-dot-royal { border-color: #3b82f6; }
.d3kg-dot-orange { border-color: #f97316; }

.d3kg-map-content {
  flex: 1;
  min-width: 0;
}

.d3kg-map-heading {
  font-size: 13px;
  font-weight: 750;
  color: #0f172a;
  line-height: 1.25;
  margin-bottom: 2px;
}

body.dark .d3kg-map-heading {
  color: #f8fafc;
}

.d3kg-map-desc {
  font-size: 11.5px;
  color: #64748b;
  line-height: 1.4;
}

body.dark .d3kg-map-desc {
  color: #94a3b8;
}

.d3kg-map-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

/* Badges */
.d3kg-badge-identity { background: #e0f2fe; color: #0284c7; }
.d3kg-badge-stability { background: #fef9c3; color: #a16207; }
.d3kg-badge-workload { background: #ffe4e6; color: #be123c; }
.d3kg-badge-transformation { background: #f3e8ff; color: #7e22ce; }
.d3kg-badge-guidance { background: #dcfce7; color: #15803d; }
.d3kg-badge-recognition { background: #dbeafe; color: #1d4ed8; }
.d3kg-badge-closure { background: #ffedd5; color: #c2410c; }

body.dark .d3kg-badge-identity { background: rgba(2, 132, 199, 0.2); color: #38bdf8; }
body.dark .d3kg-badge-stability { background: rgba(234, 179, 8, 0.2); color: #facc15; }
body.dark .d3kg-badge-workload { background: rgba(244, 63, 94, 0.2); color: #fb7185; }
body.dark .d3kg-badge-transformation { background: rgba(168, 85, 247, 0.2); color: #c084fc; }
body.dark .d3kg-badge-guidance { background: rgba(16, 185, 129, 0.2); color: #4ade80; }
body.dark .d3kg-badge-recognition { background: rgba(37, 99, 235, 0.2); color: #60a5fa; }
body.dark .d3kg-badge-closure { background: rgba(249, 115, 22, 0.2); color: #fb923c; }

/* ==========================================================================
   Middle 2x2 Grid (4 Cards)
   ========================================================================== */
.d3kg-middle-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 20px;
}

.d3kg-info-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
}

body.dark .d3kg-info-card {
  background: #111d30;
  border-color: rgba(139, 160, 184, 0.18);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.d3kg-info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.d3kg-info-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.d3kg-round-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.d3kg-ricon-sun { background: #fef3c7; color: #d97706; }
.d3kg-ricon-moon { background: #e0f2fe; color: #0284c7; }
.d3kg-ricon-chart { background: #dcfce7; color: #16a34a; }
.d3kg-ricon-house { background: #ffedd5; color: #ea580c; }

body.dark .d3kg-ricon-sun { background: rgba(217, 119, 6, 0.2); color: #fbbf24; }
body.dark .d3kg-ricon-moon { background: rgba(2, 132, 199, 0.2); color: #38bdf8; }
body.dark .d3kg-ricon-chart { background: rgba(22, 163, 74, 0.2); color: #4ade80; }
body.dark .d3kg-ricon-house { background: rgba(234, 88, 12, 0.2); color: #fb923c; }

.d3kg-info-title {
  font-size: 13.5px;
  font-weight: 750;
  color: #1e293b;
}

body.dark .d3kg-info-title {
  color: #f1f5f9;
}

.d3kg-info-pill {
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.d3kg-pill-supportive {
  background: #e0f2fe;
  color: #0284c7;
  border: 1px solid #bae6fd;
}

.d3kg-pill-warning {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

body.dark .d3kg-pill-supportive {
  background: rgba(2, 132, 199, 0.2);
  color: #38bdf8;
  border-color: rgba(2, 132, 199, 0.35);
}

body.dark .d3kg-pill-warning {
  background: rgba(217, 119, 6, 0.2);
  color: #fbbf24;
  border-color: rgba(217, 119, 6, 0.35);
}

.d3kg-info-desc {
  font-size: 12px;
  line-height: 1.55;
  color: #334155;
  margin: 0 0 10px 0;
}

body.dark .d3kg-info-desc {
  color: #cbd5e1;
}

/* Inner Tinted Boxes */
.d3kg-tinted-box {
  margin-top: auto;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 11.5px;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.d3kg-tint-amber {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  color: #78350f;
}

.d3kg-tint-purple {
  background: #f5f3ff;
  border: 1px solid #ede9fe;
  color: #581c87;
}

body.dark .d3kg-tint-amber {
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.25);
  color: #fde68a;
}

body.dark .d3kg-tint-purple {
  background: rgba(124, 58, 237, 0.12);
  border-color: rgba(124, 58, 237, 0.25);
  color: #ddd6fe;
}

.d3kg-tint-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.d3kg-tint-subhead {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  opacity: 0.85;
  margin-bottom: 2px;
}

.d3kg-tint-bold {
  font-weight: 750;
  margin-bottom: 2px;
}

.d3kg-tint-body {
  font-size: 11px;
  opacity: 0.9;
}

/* ==========================================================================
   Bottom Timing Map Table
   ========================================================================== */
.d3kg-timing-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

body.dark .d3kg-timing-card {
  background: #111d30;
  border-color: rgba(139, 160, 184, 0.18);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.d3kg-timing-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.d3kg-cal-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #e0f2fe;
  color: #0284c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

body.dark .d3kg-cal-icon {
  background: rgba(2, 132, 199, 0.2);
  color: #38bdf8;
}

.d3kg-timing-titles h2 {
  margin: 0 0 2px 0;
  font-size: 16px;
  font-weight: 750;
  color: #1e293b;
  font-family: var(--font-sans);
}

body.dark .d3kg-timing-titles h2 {
  color: #f1f5f9;
}

.d3kg-timing-titles p {
  margin: 0;
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

body.dark .d3kg-timing-titles p {
  color: #94a3b8;
}

/* Responsive Table */
.d3kg-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

body.dark .d3kg-table-wrap {
  border-color: rgba(139, 160, 184, 0.18);
}

.d3kg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.d3kg-table th {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 10.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #bae6fd;
  white-space: nowrap;
}

body.dark .d3kg-table th {
  background: #15243c;
  color: #38bdf8;
  border-bottom-color: rgba(59, 130, 246, 0.25);
}

.d3kg-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
  line-height: 1.45;
}

body.dark .d3kg-table td {
  border-bottom-color: rgba(139, 160, 184, 0.1);
  color: #cbd5e1;
}

.d3kg-table tr:last-child td {
  border-bottom: none;
}

.d3kg-table tr:hover td {
  background: #f8fafc;
}

body.dark .d3kg-table tr:hover td {
  background: #132034;
}

/* Planet Cell */
.d3kg-planet-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 750;
  color: #0f172a;
  white-space: nowrap;
}

body.dark .d3kg-planet-cell {
  color: #f8fafc;
}

.d3kg-planet-glyph {
  font-size: 16px;
  line-height: 1;
}

/* Dates Cell */
.d3kg-date-cell {
  font-size: 11.5px;
  color: #64748b;
  white-space: nowrap;
  line-height: 1.35;
}

body.dark .d3kg-date-cell {
  color: #94a3b8;
}

/* House Cell */
.d3kg-house-cell {
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
}

body.dark .d3kg-house-cell {
  color: #f1f5f9;
}

/* Key Theme Pills */
.d3kg-theme-pill {
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.d3kg-tp-initiation { background: #e0f2fe; color: #0284c7; }
.d3kg-tp-reeval { background: #fef9c3; color: #a16207; }
.d3kg-tp-network { background: #dcfce7; color: #15803d; }
.d3kg-tp-learning { background: #f3e8ff; color: #7e22ce; }
.d3kg-tp-financial { background: #fce7f3; color: #be185d; }
.d3kg-tp-direction { background: #dcfce7; color: #16a34a; }
.d3kg-tp-transformation { background: #ede9fe; color: #6d28d9; }
.d3kg-tp-workload { background: #ffedd5; color: #c2410c; }
.d3kg-tp-enterprise { background: #e0f2fe; color: #0369a1; }

body.dark .d3kg-tp-initiation { background: rgba(2, 132, 199, 0.2); color: #38bdf8; }
body.dark .d3kg-tp-reeval { background: rgba(234, 179, 8, 0.2); color: #facc15; }
body.dark .d3kg-tp-network { background: rgba(16, 185, 129, 0.2); color: #4ade80; }
body.dark .d3kg-tp-learning { background: rgba(168, 85, 247, 0.2); color: #c084fc; }
body.dark .d3kg-tp-financial { background: rgba(219, 39, 119, 0.2); color: #f472b6; }
body.dark .d3kg-tp-direction { background: rgba(22, 163, 74, 0.2); color: #4ade80; }
body.dark .d3kg-tp-transformation { background: rgba(124, 58, 237, 0.2); color: #a78bfa; }
body.dark .d3kg-tp-workload { background: rgba(234, 88, 12, 0.2); color: #fb923c; }
body.dark .d3kg-tp-enterprise { background: rgba(3, 105, 161, 0.2); color: #38bdf8; }

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 1024px) {
  .d3kg-top-grid {
    grid-template-columns: 1fr;
  }
  .d3kg-middle-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .d3kg-hero {
    flex-direction: column;
  }
  .d3kg-hero-banner {
    max-width: 100%;
    height: 180px;
  }
  .d3kg-hero-banner::before {
    background: linear-gradient(0deg, #f8fbff 0%, rgba(248, 251, 255, 0.35) 45%, transparent 100%);
  }
  body.dark .d3kg-hero-banner::before {
    background: linear-gradient(0deg, #0f1a2e 0%, rgba(15, 26, 46, 0.45) 45%, transparent 100%);
  }
  .d3kg-dasha-pills {
    flex-direction: column;
    align-items: stretch;
  }
}
