@font-face {
  font-family: "IndoPak Nastaleeq";
  src:
    url("../fonts/indopak-nastaleeq.woff2") format("woff2"),
    url("../fonts/indopak-nastaleeq.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Digital Khatt Indopak";
  src: url("../fonts/digitalkhatt-indopak.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --jdw-bg: #0a1510;
  --jdw-surface: #12201a;
  --jdw-panel: #0e1a14;
  --jdw-border: rgba(196, 163, 90, 0.22);
  --jdw-text: #f3efe6;
  --jdw-muted: rgba(243, 239, 230, 0.62);
  --jdw-gold: #c4a35a;
  --jdw-gold-soft: rgba(196, 163, 90, 0.16);
  --jdw-moss: #6b9e86;
  --jdw-top: 76px;
  --jdw-font: "Outfit", sans-serif;
  --jdw-display: "IndoPak Nastaleeq", "Digital Khatt Indopak", "Noto Nastaliq Urdu", serif;
  --jdw-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body.jdw-page {
  background: var(--jdw-bg);
  color: var(--jdw-text);
  font-family: var(--jdw-font);
  overflow: hidden;
}

.jdw-topbar {
  height: var(--jdw-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem 0 1.1rem;
  border-bottom: 1px solid var(--jdw-border);
  background: rgba(8, 18, 13, 0.96);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 20;
}

.jdw-topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.jdw-brand {
  font-family: var(--jdw-font);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--jdw-gold);
  text-decoration: none;
  white-space: nowrap;
}

.jdw-eyebrow {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--jdw-muted);
}

.jdw-title-block h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--jdw-font);
  line-height: 1.2;
}

.jdw-title-block p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--jdw-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(48vw, 520px);
}

.jdw-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.jdw-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 8px;
  border: 1px solid var(--jdw-border);
  padding: 0.32rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--jdw-text);
  background: transparent;
  cursor: pointer;
  font-family: var(--jdw-font);
}

.jdw-btn:hover {
  background: rgba(196, 163, 90, 0.1);
  color: #fff8e8;
}

.jdw-btn.is-on {
  background: var(--jdw-gold-soft);
  border-color: rgba(196, 163, 90, 0.5);
  color: #e8d5a3;
}

.jdw-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.jdw-mode-toggle {
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.15rem;
  border: 1px solid var(--jdw-border);
  border-radius: 10px;
  background: rgba(14, 32, 24, 0.7);
}

.jdw-shell {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 400px);
  height: calc(100vh - var(--jdw-top));
}

.jdw-map-stage {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 560px at 12% 8%, rgba(196, 163, 90, 0.12), transparent 55%),
    radial-gradient(800px 520px at 88% 90%, rgba(31, 77, 58, 0.45), transparent 50%),
    linear-gradient(165deg, #08120e 0%, #0e1a14 50%, #0a1510 100%);
}

.jdw-map-bg {
  position: absolute;
  inset: 0;
  opacity: 0.28;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(196, 163, 90, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(196, 163, 90, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
}

.jdw-branch-chips {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-width: calc(100% - 2rem);
}

.jdw-chip {
  border: 1px solid var(--jdw-border);
  background: rgba(10, 21, 16, 0.78);
  color: var(--jdw-muted);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.jdw-chip:hover {
  color: var(--jdw-text);
  border-color: rgba(196, 163, 90, 0.45);
}

.jdw-chip.is-on {
  color: #f3efe6;
  border-color: rgba(196, 163, 90, 0.55);
  background: rgba(196, 163, 90, 0.18);
}

.jdw-svg-scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 3.2rem 0.5rem 2.8rem;
  z-index: 1;
}

.jdw-svg {
  width: 100%;
  min-height: 100%;
  height: auto;
  display: block;
}

.jdw-map-hint {
  position: absolute;
  left: 50%;
  bottom: 0.85rem;
  transform: translateX(-50%);
  z-index: 6;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--jdw-border);
  background: rgba(10, 21, 16, 0.88);
  color: var(--jdw-muted);
  font-size: 0.72rem;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  animation: jdw-hint-in 0.6s ease both;
}

.jdw-map-hint strong { color: var(--jdw-gold); font-weight: 600; }

.jdw-panel {
  border-left: 1px solid var(--jdw-border);
  background: var(--jdw-panel);
  overflow: auto;
  padding: 1rem 1.05rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.jdw-context-id {
  font-family: var(--jdw-mono);
  font-size: 0.72rem;
  color: var(--jdw-gold);
  margin-bottom: 0.35rem;
}

.jdw-context-note {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--jdw-muted);
}

.jdw-focus {
  border: 1px solid var(--jdw-border);
  border-radius: 12px;
  padding: 0.95rem;
  background: rgba(18, 32, 26, 0.65);
  animation: jdw-rise 0.45s ease both;
}

.jdw-focus-empty {
  color: var(--jdw-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.jdw-focus-kicker {
  font-family: var(--jdw-mono);
  font-size: 0.7rem;
  color: var(--jdw-moss);
  margin-bottom: 0.25rem;
}

.jdw-focus-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
}

.jdw-focus-arabic {
  margin: 0.35rem 0 0.5rem;
  font-family: var(--jdw-display);
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--jdw-gold);
  line-height: 1.7;
}

.jdw-focus-hint {
  margin: 0;
  font-size: 0.84rem;
  color: var(--jdw-muted);
  line-height: 1.45;
}

.jdw-focus-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.jdw-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--jdw-border);
  color: var(--jdw-text);
  background: rgba(196, 163, 90, 0.08);
}

.jdw-focus-actions {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.jdw-section h3 {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--jdw-muted);
}

.jdw-related {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 280px;
  overflow: auto;
}

.jdw-related-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  background: rgba(18, 32, 26, 0.55);
  color: var(--jdw-text);
  cursor: pointer;
  font-family: var(--jdw-font);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.jdw-related-item:hover,
.jdw-related-item.is-on {
  border-color: rgba(107, 158, 134, 0.45);
  background: rgba(107, 158, 134, 0.12);
}

.jdw-related-main {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.jdw-related-main strong {
  font-size: 0.84rem;
  font-weight: 600;
}

.jdw-related-main span {
  font-size: 0.7rem;
  color: var(--jdw-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.jdw-related-badge {
  font-family: var(--jdw-mono);
  font-size: 0.68rem;
  color: var(--jdw-gold);
  flex-shrink: 0;
}

.jdw-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--jdw-muted);
}

.jdw-legend li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.jdw-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid;
  flex-shrink: 0;
}

.jdw-dot--juz {
  border-color: var(--jdw-gold);
  background: #0f172a;
  box-shadow: 0 0 0 3px rgba(196, 163, 90, 0.2);
}

.jdw-dot--sura {
  border-color: var(--jdw-moss);
  background: #0f172a;
}

.jdw-dot--ruku {
  border-color: #8a9eb8;
  background: #0f172a;
}

.jdw-line {
  width: 22px;
  height: 0;
  border-top: 2px solid;
  flex-shrink: 0;
}

.jdw-line--spine { border-color: rgba(196, 163, 90, 0.75); }
.jdw-line--contains {
  border-color: rgba(107, 158, 134, 0.65);
  border-top-style: dashed;
}
.jdw-line--ruku {
  border-color: rgba(138, 158, 184, 0.7);
  border-top-style: dotted;
}

/* SVG node states */
.jdw-node { cursor: pointer; }
.jdw-node .jdw-halo {
  fill: none;
  stroke: rgba(196, 163, 90, 0.35);
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
  opacity: 0;
}
.jdw-node.is-key .jdw-halo { opacity: 1; }
.jdw-node.is-focus .jdw-halo {
  opacity: 1;
  stroke: rgba(196, 163, 90, 0.85);
  stroke-dasharray: none;
}
.jdw-node .jdw-core {
  fill: #0f172a;
  stroke-width: 2.4;
}
.jdw-node--juz .jdw-core { stroke: #c4a35a; }
.jdw-node--sura .jdw-core { stroke: #6b9e86; stroke-width: 2; }
.jdw-node--ruku .jdw-core { stroke: #8a9eb8; stroke-width: 1.7; }
.jdw-node .jdw-label {
  fill: #f3efe6;
  font-family: var(--jdw-font);
  font-size: 12px;
  font-weight: 600;
}
.jdw-node .jdw-sub {
  fill: rgba(243, 239, 230, 0.55);
  font-family: var(--jdw-mono);
  font-size: 9.5px;
}
.jdw-node--sura .jdw-label { font-size: 11px; }
.jdw-node--ruku .jdw-label { font-size: 10px; font-weight: 500; }
.jdw-node--ruku .jdw-sub { font-size: 8.5px; }
.jdw-node.is-dim { opacity: 0.18; }
.jdw-node.is-live { opacity: 1; }
.jdw-node:hover .jdw-core { fill: #15241c; }

.jdw-edge {
  fill: none;
  stroke-linecap: round;
}
.jdw-edge--spine {
  stroke: rgba(196, 163, 90, 0.55);
  stroke-width: 2.2;
}
.jdw-edge--contains {
  stroke: rgba(107, 158, 134, 0.5);
  stroke-width: 1.4;
  stroke-dasharray: 5 4;
}
.jdw-edge--ruku {
  stroke: rgba(138, 158, 184, 0.55);
  stroke-width: 1.15;
  stroke-dasharray: 2 3;
}
.jdw-edge.is-dim { opacity: 0.12; }
.jdw-edge.is-live { opacity: 1; }

@keyframes jdw-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes jdw-hint-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 960px) {
  .jdw-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr minmax(240px, 38vh);
  }
  .jdw-panel {
    border-left: none;
    border-top: 1px solid var(--jdw-border);
  }
  .jdw-title-block p { display: none; }
  .jdw-map-hint { font-size: 0.65rem; max-width: 92%; white-space: normal; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .jdw-focus, .jdw-map-hint { animation: none; }
}
