/* -----------------------------------------
   SECURITY GATE
------------------------------------------ */

#security-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(180deg, #c9dff5 0%, #e5f1fb 60%, #dde8f5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.5s ease;
}

#security-gate.gate-fade { opacity: 0; }

#gate-card {
  background: #fff;
  border: 2px solid #0b4f6c;
  box-shadow: 0 0 0 1px rgba(11, 79, 108, 0.2), 0 8px 40px rgba(0, 0, 0, 0.2);
  padding: 40px 48px 36px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  position: relative;
}

#gate-card::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  pointer-events: none;
}

#gate-title {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #0b4f6c;
  margin: 0 0 6px;
}

#gate-subtitle {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #145da0;
  margin-bottom: 14px;
}

.gate-divider {
  font-size: 0.65rem;
  color: #fbbf24;
  letter-spacing: 0.2em;
  margin: 12px 0;
  user-select: none;
}

#gate-prompt {
  font-size: 0.9rem;
  color: #22252b;
  margin-bottom: 14px;
}

#gate-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-size: 1.1rem;
  letter-spacing: 0.25em;
  text-align: center;
  padding: 9px 14px;
  background: #e5f1fb;
  border: 1px solid #145da0;
  color: #22252b;
  outline: none;
  margin-bottom: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#gate-input:focus {
  border-color: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.25);
}

#gate-submit {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 10px 36px;
  background: #145da0;
  color: #fff;
  border: 1px solid #fbbf24;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  margin-bottom: 12px;
}

#gate-submit:hover {
  background: #0b4f6c;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

#gate-error {
  font-size: 0.85rem;
  color: #8b1a1a;
  min-height: 1.2em;
  margin-top: 4px;
}

/* -----------------------------------------
   Base
------------------------------------------ */

:root {
  --jw-blue-dark: #0b4f6c;
  --jw-blue: #145da0;
  --jw-blue-light: #e5f1fb;
  --jw-gray-light: #f5f5f7;
  --jw-gray: #d0d3da;
  --jw-text: #22252b;
  --jw-muted: #6b7280;
  --jw-accent: #fbbf24;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-soft: 0 8px 20px rgba(0, 0, 0, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--jw-text);
  background: linear-gradient(180deg, #ffffff 0%, #f3f6fb 100%);
}

/* Header */

.app-header {
  background: linear-gradient(90deg, var(--jw-blue-dark), var(--jw-blue));
  color: #ffffff;
  padding: 1rem 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.app-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-header h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0.03em;
}

.subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: #e5ecf7;
}

/* Layout */

.app-main {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1.5rem 2rem;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1.5rem;
}

.sidebar {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.sidebar-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--jw-blue-dark);
  border-bottom: 1px solid var(--jw-gray);
  padding-bottom: 0.5rem;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Diagram */

.judge-diagram {
  position: relative;
  padding-left: 1.25rem;
  margin-top: 0.5rem;
}

.judge-diagram::before {
  content: "";
  position: absolute;
  left: 0.5rem;
  top: 0.25rem;
  bottom: 0.25rem;
  width: 2px;
  background: linear-gradient(to bottom, var(--jw-blue-light), var(--jw-blue));
  opacity: 0.7;
}

.judge-node {
  position: relative;
  padding: 0.4rem 0.5rem 0.4rem 1.25rem;
  margin-bottom: 0.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  font-size: 0.9rem;
  color: var(--jw-text);
}

.judge-node::before {
  content: "";
  position: absolute;
  left: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid var(--jw-blue);
}

.judge-node:hover {
  background: var(--jw-blue-light);
  transform: translateX(1px);
}

.judge-node.active {
  background: rgba(20, 93, 160, 0.12);
  box-shadow: 0 0 0 1px rgba(20, 93, 160, 0.4);
}

.judge-node.active::before {
  background: var(--jw-blue);
}

/* Detail panel */

.detail-panel {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.25rem 1.5rem;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.detail-placeholder {
  text-align: center;
  color: var(--jw-muted);
  margin: auto;
}

.detail-placeholder h2 {
  margin-bottom: 0.25rem;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.detail-header h2 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--jw-blue-dark);
}

.detail-meta {
  font-size: 0.85rem;
  color: var(--jw-muted);
}

.detail-section {
  margin-top: 0.5rem;
}

.detail-section h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  color: var(--jw-blue);
}

.detail-section ul {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.9rem;
}

.detail-section li {
  margin-bottom: 0.15rem;
}

.scripture-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.scripture-tag {
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--jw-blue-light);
  color: var(--jw-blue-dark);
}

/* Compare bar */

.compare-bar {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.compare-bar.hidden {
  display: none;
}

.compare-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.compare-cards {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.compare-card {
  min-width: 220px;
  max-width: 260px;
  border-radius: var(--radius-md);
  border: 1px solid var(--jw-gray);
  padding: 0.6rem 0.75rem;
  background: #fdfefe;
  font-size: 0.85rem;
}

.compare-card h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  color: var(--jw-blue-dark);
}

.compare-card p {
  margin: 0.15rem 0;
}

/* Buttons */

.btn {
  border-radius: 999px;
  border: none;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-link {
  background: transparent;
  color: var(--jw-blue);
  padding: 0.2rem 0.4rem;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Responsive */

@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }

  .content {
    order: 1;
  }
}

@media (max-width: 600px) {
  .app-header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-main {
    padding: 0 1rem 1.5rem;
  }
}

/* -----------------------------------------
   TIMELINE BAR CHART
------------------------------------------ */

.timeline-band {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 0.75rem 1rem 0.5rem;
}

.tl-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--jw-muted);
  margin-bottom: 0.5rem;
  padding: 0 0 0 90px;
}

.timeline-chart {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tl-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  transition: background 0.12s ease;
}

.tl-row:hover {
  background: var(--jw-blue-light);
}

.tl-row.active {
  background: rgba(20, 93, 160, 0.08);
}

.tl-name {
  width: 82px;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--jw-text);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-row.active .tl-name {
  font-weight: 600;
  color: var(--jw-blue-dark);
}

.tl-track {
  flex: 1;
  height: 10px;
  background: var(--jw-gray-light);
  border-radius: 999px;
  position: relative;
}

.tl-bar {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 999px;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}

.tl-row:hover .tl-bar,
.tl-row.active .tl-bar {
  opacity: 1;
}

/* Accent border on detail panel */
.detail-panel {
  border-left: 6px solid var(--jw-blue);
}

/* Accent bar on compare cards */
.compare-card::before {
  content: "";
  display: block;
  height: 4px;
  border-radius: 999px;
  margin-bottom: 0.4rem;
  background: var(--jw-blue);
}

.judge-diagram {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.btn-ghost.active {
  background: rgba(255, 255, 255, 0.35);
  border-color: rgba(255, 255, 255, 0.6);
  color: #ffffff;
  font-weight: 600;
}
.compare-banner {
  background: #145da0;
  color: #ffffff;
  padding: 0.5rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.compare-banner.hidden {
  display: none;
}

/* -----------------------------------------
   PORTRAIT
------------------------------------------ */

.detail-header {
  align-items: flex-start;
}

.detail-header-left {
  flex: 1;
  min-width: 0;
}

.judge-portrait {
  width: 100px;
  height: 100px;
  object-fit: cover;
  object-position: top center;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  margin-left: 0.75rem;
  border: 1px solid var(--jw-gray);
}

/* -----------------------------------------
   STATS ROW
------------------------------------------ */

.judge-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--jw-blue-light);
  border: 1px solid rgba(20, 93, 160, 0.2);
  font-size: 0.78rem;
}

.stat-label {
  color: var(--jw-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.68rem;
}

.stat-value {
  color: var(--jw-blue-dark);
  font-weight: 600;
}

/* -----------------------------------------
   SUMMARY & KEY VERSE
------------------------------------------ */

.judge-summary {
  font-size: 0.88rem;
  color: #333;
  line-height: 1.6;
  margin: 0.5rem 0 0;
}

.key-verse {
  margin: 0.6rem 0 0;
  padding: 0.6rem 0.9rem;
  border-left: 3px solid var(--jw-blue);
  background: var(--jw-blue-light);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.84rem;
  font-style: italic;
  color: var(--jw-blue-dark);
  line-height: 1.5;
}

/* -----------------------------------------
   APOSTASY CYCLE DIAGRAM
------------------------------------------ */

.cycle-diagram {
  display: flex;
  align-items: flex-start;
  gap: 0.2rem;
  margin-top: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.cycle-step {
  flex: 1;
  min-width: 100px;
  background: #f9fafc;
  border: 1px solid var(--jw-gray);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.6rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.cycle-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.15rem;
}

.cycle-step--sin         .cycle-num { background: #b33a3a; }
.cycle-step--oppression  .cycle-num { background: #a05a1a; }
.cycle-step--cry         .cycle-num { background: #8a6b00; }
.cycle-step--deliverance .cycle-num { background: #2a7a4a; }
.cycle-step--result      .cycle-num { background: #145da0; }

.cycle-step--sin         { border-top: 3px solid #b33a3a; }
.cycle-step--oppression  { border-top: 3px solid #a05a1a; }
.cycle-step--cry         { border-top: 3px solid #8a6b00; }
.cycle-step--deliverance { border-top: 3px solid #2a7a4a; }
.cycle-step--result      { border-top: 3px solid #145da0; }

.cycle-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--jw-text);
}

.cycle-text {
  font-size: 0.77rem;
  color: #555;
  line-height: 1.4;
}

.cycle-arrow {
  flex-shrink: 0;
  align-self: center;
  font-size: 1rem;
  color: var(--jw-gray);
  padding: 0 0.1rem;
  margin-top: -0.75rem;
}

@media (max-width: 700px) {
  .cycle-diagram {
    flex-direction: column;
    overflow-x: visible;
  }
  .cycle-arrow {
    align-self: flex-start;
    transform: rotate(90deg);
    margin: 0 0 0 0.5rem;
  }
  .judge-portrait {
    width: 72px;
    height: 72px;
  }
}

/* -----------------------------------------
   MAP PANEL
------------------------------------------ */

.judge-map-panel {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.judge-map-panel.hidden {
  display: none;
}

.judge-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--jw-gray);
  gap: 0.75rem;
  flex-wrap: wrap;
}

.judge-map-header h3 {
  margin: 0;
  font-size: 0.88rem;
  color: var(--jw-blue-dark);
  font-weight: 600;
}

.judge-map-legend {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--jw-muted);
}

.map-legend-swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 2px;
  flex-shrink: 0;
}

.map-legend-swatch--tribe {
  background: rgba(20, 93, 160, 0.45);
  border: 1.5px solid #145da0;
}

.map-legend-swatch--opp {
  background: rgba(192, 57, 43, 0.35);
  border: 1.5px dashed #8b1a1a;
}

.judge-map-el {
  height: 280px;
  width: 100%;
}

.judge-map-note {
  margin: 0;
  padding: 0.35rem 1rem;
  font-size: 0.78rem;
  color: var(--jw-muted);
  font-style: italic;
  border-top: 1px solid var(--jw-gray);
  background: var(--jw-gray-light);
}

.judge-map-note.hidden {
  display: none;
}
