/* Isnad — web theme (ported from Theme.swift) */

:root {
  /* Backgrounds */
  --bg-top: #0B1020;      /* deep navy */
  --bg-bottom: #05070E;   /* velvet black */
  --surface: #121A2E;     /* raised card */
  --surface-hi: #1B2540;  /* hover / selected */

  /* Accents */
  --gold: #D4AF37;
  --gold-bright: #F3D77A;
  --copper: #B87333;

  /* Text */
  --text-primary: #F5F2E8;
  --text-secondary: #9AA3B8;
  --hairline: rgba(255, 255, 255, 0.08);

  /* Category colors */
  --cat-prophet: #2ECC71;
  --cat-companion: #3B82F6;
  --cat-successor: #9B7BF0;
  --cat-imam: #F5A623;
  --cat-book: #FF7A6B;
  --cat-opponent: #E04B5A;
  --cat-battle: #C0C6D4;

  --gold-gradient: linear-gradient(135deg, var(--gold-bright), var(--gold), var(--copper));
  --nav-h: 64px;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--sans);
  color: var(--text-primary);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

button { font-family: inherit; cursor: pointer; }
::selection { background: rgba(212, 175, 55, 0.35); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

.gold-text {
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ── Splash ──────────────────────────────────────────────────────────────── */
#splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  background: radial-gradient(circle at 50% 40%, #10182c, var(--bg-bottom) 70%);
  transition: opacity 0.7s ease;
}
#splash.hidden { opacity: 0; pointer-events: none; }
#splash .mark {
  font-family: var(--serif);
  font-size: 64px; font-weight: 700; letter-spacing: 1px;
}
#splash .ar { font-family: var(--serif); font-size: 30px; color: var(--gold); }
#splash .tag { font-size: 13px; color: var(--text-secondary); }
.halo-ring {
  width: 120px; height: 120px; margin-bottom: 8px;
  border-radius: 50%;
  border: 2px solid rgba(243, 215, 122, 0.25);
  border-top-color: var(--gold-bright);
  animation: spin 1.4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Top nav ─────────────────────────────────────────────────────────────── */
#nav {
  height: var(--nav-h);
  flex: 0 0 var(--nav-h);
  display: flex; align-items: center; gap: 22px;
  padding: 0 24px;
  border-bottom: 1px solid var(--hairline);
  background: rgba(9, 13, 26, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 20;
}
#nav .brand {
  display: flex; flex-direction: column; line-height: 1.05;
}
#nav .brand .name { font-family: var(--serif); font-size: 24px; font-weight: 700; }
#nav .brand .sub { font-size: 10.5px; color: var(--text-secondary); }

#nav .tabs { display: flex; gap: 4px; margin-left: 8px; }
#nav .tab {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 9px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  transition: all 0.2s ease;
}
#nav .tab svg { width: 17px; height: 17px; }
#nav .tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
#nav .tab.active {
  color: #1A1206;
  background: var(--gold-gradient);
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.35);
}
#nav .spacer { flex: 1; }
#nav .note { font-size: 11px; color: var(--text-secondary); max-width: 300px; text-align: right; opacity: 0.8; }

/* ── Main ────────────────────────────────────────────────────────────────── */
#main { position: relative; flex: 1; min-height: 0; }
.view { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity 0.35s ease; }
.view.active { opacity: 1; pointer-events: auto; }

/* ── Explore ─────────────────────────────────────────────────────────────── */
#view-explore { overflow: hidden; }
#graph-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

.floating { position: absolute; z-index: 6; }

/* Search cluster (top-left) */
#search-cluster { top: 18px; left: 18px; width: 340px; max-width: calc(100% - 36px); }
.search-box {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; border-radius: 16px;
  background: rgba(18, 26, 46, 0.72);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--hairline);
}
.search-box svg { width: 16px; height: 16px; color: var(--text-secondary); flex: 0 0 auto; }
.search-box input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text-primary); font-size: 15px;
}
.search-box input::placeholder { color: var(--text-secondary); }
.search-box .clear { background: none; border: none; color: var(--text-secondary); display: none; padding: 0; }
.search-box .clear svg { width: 18px; height: 18px; }

#search-results {
  margin-top: 8px; border-radius: 16px; overflow: hidden;
  background: rgba(18, 26, 46, 0.86);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--hairline);
  display: none;
}
#search-results .result {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--hairline);
  transition: background 0.15s ease;
}
#search-results .result:last-child { border-bottom: none; }
#search-results .result:hover { background: rgba(255,255,255,0.05); }
#search-results .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
#search-results .r-name { font-size: 14px; font-weight: 500; }
#search-results .r-title { font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#search-results .grow { flex: 1; min-width: 0; }
#search-results .arrow { color: var(--text-secondary); }
#search-results .arrow svg { width: 13px; height: 13px; }

/* Controls (bottom-right) */
#controls { bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 12px; }
.circle-btn {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(18, 26, 46, 0.75);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--hairline);
  color: var(--text-primary);
  box-shadow: 0 8px 18px rgba(0,0,0,0.4);
  transition: transform 0.15s ease, border-color 0.2s ease;
}
.circle-btn:hover { transform: translateY(-2px); border-color: rgba(212,175,55,0.4); }
.circle-btn svg { width: 20px; height: 20px; }
.circle-btn.gold { color: var(--gold-bright); }

/* Legend (top-right) */
#legend {
  top: 18px; right: 18px; width: 232px;
  padding: 18px; border-radius: 20px;
  background: rgba(18, 26, 46, 0.82);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--hairline);
  display: none;
}
#legend h4 { margin: 0 0 12px; font-size: 14px; color: var(--gold); font-weight: 600; }
#legend .row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
#legend .row .dot { width: 11px; height: 11px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
#legend .divider { height: 1px; background: var(--hairline); margin: 12px 0; }
#legend .chain-hint { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-secondary); }
#legend .chain-hint svg { width: 16px; height: 16px; color: var(--gold-bright); }
.hint-badge {
  position: absolute; bottom: 24px; left: 18px; z-index: 6;
  font-size: 12px; color: var(--text-secondary);
  padding: 8px 14px; border-radius: 12px;
  background: rgba(18, 26, 46, 0.6);
  border: 1px solid var(--hairline);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

/* ── Node detail panel (side drawer) ─────────────────────────────────────── */
#detail-panel {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 8;
  width: 380px; max-width: 92%;
  background: rgba(14, 20, 36, 0.92);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--hairline);
  box-shadow: -20px 0 50px rgba(0,0,0,0.5);
  transform: translateX(105%);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex; flex-direction: column;
}
#detail-panel.open { transform: translateX(0); }
.detail-inner { padding: 24px; overflow-y: auto; height: 100%; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-head .ar { font-family: var(--serif); font-size: 26px; font-weight: 700; }
.detail-head .en { font-size: 17px; font-weight: 600; margin-top: 4px; }
.detail-head .role { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.detail-close { background: none; border: none; color: var(--text-secondary); padding: 0; }
.detail-close svg { width: 26px; height: 26px; }
.detail-summary { margin: 18px 0; font-size: 15px; line-height: 1.55; color: rgba(245,242,232,0.92); }
.info-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-secondary); margin-bottom: 8px; }
.info-row svg { width: 15px; height: 15px; color: var(--gold); flex: 0 0 auto; }
.detail-connections-title { font-size: 13px; font-weight: 600; color: var(--gold); margin: 18px 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.rel-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 11px; border-radius: 999px;
  background: var(--surface-hi); border: 1px solid var(--hairline);
  font-size: 12.5px; color: var(--text-primary);
  transition: border-color 0.2s ease, transform 0.12s ease;
}
.rel-chip:hover { transform: translateY(-1px); border-color: rgba(212,175,55,0.4); }
.rel-chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.rel-chip .rel-type { font-size: 11px; color: var(--text-secondary); }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
}
.cat-chip .dot { width: 8px; height: 8px; border-radius: 50%; }

/* ── Scrollable content views (Timeline / Review) ────────────────────────── */
.scroll-view { position: absolute; inset: 0; overflow-y: auto; }
.geometric-bg {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.4;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(212,175,55,0.05), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(184,115,51,0.05), transparent 40%);
}
.container { max-width: 860px; margin: 0 auto; padding: 40px 24px 80px; position: relative; }
.page-head h1 { font-family: var(--serif); font-size: 34px; margin: 0; }
.page-head p { font-size: 13.5px; color: var(--text-secondary); margin: 6px 0 0; }

/* Filter chips */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0; }
.filter-chip {
  padding: 7px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  color: var(--text-primary); background: rgba(255,255,255,0.04);
  border: 1px solid var(--hairline); transition: all 0.18s ease;
}
.filter-chip:hover { border-color: rgba(255,255,255,0.25); }
.filter-chip.active { color: #120C02; }

/* Timeline */
.tl-row { display: flex; gap: 14px; align-items: stretch; }
.tl-year { width: 62px; flex: 0 0 62px; text-align: right; font-size: 10.5px; font-weight: 600; color: var(--text-secondary); padding-top: 15px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; }
.tl-dot { width: 13px; height: 13px; border-radius: 50%; margin-top: 14px; border: 2px solid var(--bg-bottom); box-shadow: 0 0 6px currentColor; }
.tl-line { width: 2px; flex: 1; background: var(--hairline); margin: 4px 0; }
.tl-card {
  flex: 1; margin-bottom: 14px; padding: 13px 15px; border-radius: 14px;
  background: rgba(18, 26, 46, 0.7); border: 1px solid var(--hairline);
  transition: transform 0.15s ease, border-color 0.2s ease;
}
.tl-card:hover { transform: translateX(3px); }
.tl-card .top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.tl-card .nm { font-size: 15px; font-weight: 600; }
.tl-card .yl { font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.tl-card .rl { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ── Review ──────────────────────────────────────────────────────────────── */
.mode-picker {
  display: flex; gap: 6px; padding: 4px; margin: 20px auto; max-width: 380px;
  background: rgba(18,26,46,0.5); border-radius: 999px;
}
.mode-btn {
  flex: 1; padding: 10px; border: none; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--text-primary);
  background: transparent; transition: all 0.2s ease;
}
.mode-btn.active { color: #120C02; background: var(--gold-gradient); }

.review-panel { max-width: 480px; margin: 0 auto; }

/* Flashcard */
.flashcard-wrap { perspective: 1600px; }
.flashcard {
  position: relative; height: 360px; width: 100%;
  transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.4,0,0.2,1);
  cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 26px; padding: 26px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center;
  background: rgba(18, 26, 46, 0.85);
}
.flash-face.back { transform: rotateY(180deg); }
.flash-face .ar { font-family: var(--serif); font-size: 40px; font-weight: 700; }
.flash-face .en { font-size: 20px; font-weight: 600; }
.flash-face .role { font-size: 17px; font-weight: 600; color: var(--gold); }
.flash-face .sum { font-size: 14px; line-height: 1.5; color: rgba(245,242,232,0.9); }
.flash-face .yl { font-size: 12px; color: var(--text-secondary); }
.flash-hint { text-align: center; font-size: 12px; color: var(--text-secondary); margin: 16px 0; }
.flash-nav { display: flex; align-items: center; justify-content: center; gap: 14px; }
.flash-nav .count { font-size: 14px; font-weight: 600; min-width: 70px; text-align: center; }

/* Quiz */
.quiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.quiz-score { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--gold); }
.quiz-score svg { width: 15px; height: 15px; }
.quiz-answered { font-size: 13px; color: var(--text-secondary); }
.quiz-q {
  padding: 18px; border-radius: 18px; text-align: center; margin-bottom: 16px;
  background: rgba(18,26,46,0.75); border: 1px solid var(--hairline);
}
.quiz-q .lead { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.quiz-q .body { font-size: 15.5px; font-weight: 500; margin: 8px 0; line-height: 1.5; }
.quiz-q .yl { font-size: 12px; }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; }
.quiz-opt {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-radius: 14px; font-size: 15px; font-weight: 500;
  color: var(--text-primary); background: rgba(18,26,46,0.7);
  border: 1px solid var(--hairline); text-align: left; transition: all 0.18s ease;
}
.quiz-opt:not(:disabled):hover { border-color: rgba(255,255,255,0.25); }
.quiz-opt svg { width: 20px; height: 20px; }
.quiz-opt.correct { background: rgba(46,204,113,0.22); }
.quiz-opt.wrong { background: rgba(224,75,90,0.22); }
.quiz-next {
  width: 100%; margin-top: 14px; padding: 13px; border: none; border-radius: 999px;
  font-size: 15px; font-weight: 600; color: #120C02; background: var(--gold-gradient);
}

.disclaimer {
  max-width: 860px; margin: 0 auto; padding: 18px 24px 30px;
  font-size: 11.5px; line-height: 1.6; color: var(--text-secondary); text-align: center;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  #nav { gap: 12px; padding: 0 14px; }
  #nav .brand .sub, #nav .note { display: none; }
  #nav .tab span { display: none; }
  #nav .tab { padding: 9px 12px; }
  #detail-panel { width: 100%; }
  #search-cluster { width: calc(100% - 36px); }
  #legend { display: none !important; }
  .page-head h1 { font-size: 27px; }
}
