/* ═══════════════════════════════════════════════════════════
   Recycling Bank × MODON — Premium Editorial Industrial v6
   Option 1: McKinsey meets Aramco Boardroom
   Deep obsidian + warm champagne-gold + soft slate
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── Background palette ── */
  --bg:          #0d0f0e;
  --bg-deep:     #090b0a;
  --bg-panel:    rgba(16, 20, 18, 0.72);
  --bg-panel-solid: #111411;
  --bg-surface:  rgba(255, 255, 255, 0.022);

  /* ── Border ── */
  --border:      rgba(255, 255, 255, 0.06);
  --border-gold: rgba(197, 168, 128, 0.22);
  --border-teal: rgba(26, 158, 143, 0.20);

  /* ── Brand teal ── */
  --teal:        #1A9E8F;
  --teal-light:  #22c4b2;
  --teal-glow:   rgba(26, 158, 143, 0.18);
  --teal-dim:    rgba(26, 158, 143, 0.06);

  /* ── Champagne gold ── */
  --gold:        #C5A880;
  --gold-light:  #d4b98c;
  --gold-glow:   rgba(197, 168, 128, 0.15);
  --gold-dim:    rgba(197, 168, 128, 0.06);

  /* ── Muted red ── */
  --red:         #c0614a;
  --red-glow:    rgba(192, 97, 74, 0.15);
  --red-dim:     rgba(192, 97, 74, 0.05);

  /* ── Ink (off-white warm) ── */
  --ink:         #f0ede8;
  --ink-dim:     rgba(240, 237, 232, 0.68);
  --ink-muted:   rgba(240, 237, 232, 0.38);
  --ink-faint:   rgba(240, 237, 232, 0.16);

  /* ── Typography ── */
  --font-sans:    'Space Grotesk', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-arabic:  'Tajawal', system-ui, sans-serif;

  /* ── Motion ── */
  --ease:        cubic-bezier(.16, 1, .3, 1);
  --ease-soft:   cubic-bezier(.25, 0.46, .45, .94);
}

/* ── BASE RESET ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.65;
  user-select: none;
}
input, button, textarea { font-family: inherit; }

/* ── SUBTLE NOISE TEXTURE (no scanlines) ────────────────── */
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.4;
}

/* Faint dot grid */
.dot-grid {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background-image: radial-gradient(rgba(240, 237, 232, 0.025) 1px, transparent 1px);
  background-size: 36px 36px;
}
/* Remove old scanlines */
.scanlines { display: none; }

/* ── APP CHROME FRAME ────────────────────────────────────── */
.app-frame {
  position: fixed; inset: 0; z-index: 10; pointer-events: none;
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.chrome-top {
  height: 60px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 15, 14, 0.88);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; pointer-events: auto;
}
.chrome-logo { display: flex; align-items: center; gap: 14px; }
.chrome-logo img { height: 24px; }
.chrome-logo div { display: flex; flex-direction: column; gap: 1px; }
.chrome-logo b {
  font-family: var(--font-sans); font-size: 13px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink);
}
.chrome-logo span {
  font-family: var(--font-arabic); font-size: 10px;
  color: var(--ink-muted); letter-spacing: 0.02em;
}

.chrome-controls { display: flex; align-items: center; gap: 20px; }

.lang-toggle {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px; padding: 5px 14px;
  font-family: var(--font-mono); font-size: 10px;
  color: var(--ink-muted); cursor: pointer;
  transition: all 0.25s var(--ease);
  letter-spacing: 0.08em;
}
.lang-toggle:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }
.lang-toggle.active { background: var(--gold-dim); border-color: var(--gold); color: var(--gold); }

.hud-pill {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase;
  border: 1px solid var(--border); border-radius: 4px; padding: 5px 14px;
  display: flex; align-items: center; gap: 8px; color: var(--ink-muted);
  background: var(--bg-surface);
}
.pulse-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--teal);
  box-shadow: 0 0 8px var(--teal); animation: pulseGlow 2.4s infinite;
}
@keyframes pulseGlow { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ── THREE.JS GLOBE BACKGROUND ──────────────────────────── */
.bg-canvas-container {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
}
#globe-canvas { width: 100%; height: 100%; display: block; opacity: 0.6; }

/* ── PANEL CARD ─────────────────────────────────────────── */
.panel-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  position: relative; overflow: hidden;
  backdrop-filter: blur(32px) saturate(130%);
  -webkit-backdrop-filter: blur(32px) saturate(130%);
  box-shadow:
    0 2px 0 rgba(255,255,255,0.03) inset,
    0 32px 80px rgba(0,0,0,0.55),
    0 1px 1px rgba(0,0,0,0.3);
  display: flex; flex-direction: column; gap: 0;
}
/* Subtle top-edge highlight */
.panel-card::before {
  content: '';
  position: absolute; top: 0; left: 20%; right: 20%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(240,237,232,0.08), transparent);
  pointer-events: none;
}

/* ── PANEL HEADER ───────────────────────────────────────── */
.panel-hdr {
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px; margin-bottom: 22px; flex-wrap: wrap;
}
.panel-hdr .title {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-muted);
  flex: 1;
}
.panel-hdr .subtitle {
  font-family: var(--font-arabic); font-size: 10px; color: var(--ink-faint);
}
.panel-hdr .status {
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600;
}
.status.ok   { color: var(--teal); }
.status.warn { color: var(--gold); }
.status.fault { color: var(--red); }

/* ── CORNER RETICLES (Refined) ──────────────────────────── */
.reticle-corner {
  position: absolute; width: 10px; height: 10px;
  border: 1px solid rgba(197, 168, 128, 0.25); pointer-events: none;
}
.reticle-tl { top: 14px; left: 14px; border-right: none; border-bottom: none; }
.reticle-tr { top: 14px; right: 14px; border-left: none; border-bottom: none; }
.reticle-bl { bottom: 14px; left: 14px; border-right: none; border-top: none; }
.reticle-br { bottom: 14px; right: 14px; border-left: none; border-top: none; }

/* ── SCREEN LAYOUT ──────────────────────────────────────── */
.screen-content {
  width: min(1260px, 92vw);
  height: min(650px, 80vh);
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
  position: relative; z-index: 6;
  pointer-events: none;
}
.screen-content > * { pointer-events: auto; }

/* ── TELEMETRY BLOCKS ───────────────────────────────────── */
.telemetry-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
.tel-block {
  border-left: 2px solid var(--teal);
  padding: 4px 0 4px 16px;
}
.tel-block.gold { border-color: var(--gold); }
.tel-block.red  { border-color: var(--red); }
.tel-num {
  font-family: var(--font-mono); font-size: 24px;
  font-weight: 600; color: var(--ink); line-height: 1;
  display: block;
}
.tel-label {
  font-family: var(--font-mono); font-size: 8px;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-muted); margin-top: 7px; display: block;
}
.tel-ar {
  font-family: var(--font-arabic); font-size: 9px;
  color: var(--ink-faint); display: block; margin-top: 3px;
}

/* ── TYPOGRAPHY SYSTEM ──────────────────────────────────── */
.presentation-title {
  font-family: var(--font-display);
  font-weight: 500; font-style: italic;
  font-size: clamp(38px, 4vw, 56px);
  line-height: 1.06; letter-spacing: -0.01em;
  margin-bottom: 10px; color: var(--ink);
}
.presentation-arabic-title {
  font-family: var(--font-arabic); font-weight: 700;
  font-size: clamp(18px, 1.8vw, 24px);
  color: var(--gold); margin-bottom: 24px;
  letter-spacing: 0.01em;
}
.presentation-sub {
  font-family: var(--font-sans); font-size: 14px;
  color: var(--ink-dim); max-width: 480px;
  line-height: 1.72; font-weight: 400;
}

/* ── SCENE 1: COVER / GRID INITIALIZATION ────────────── */
#scene-cover .panel-hero    { grid-column: 1 / 7; grid-row: 1 / 3; display: flex; flex-direction: column; justify-content: center; }
#scene-cover .panel-context { grid-column: 7 / 13; grid-row: 1 / 2; }
#scene-cover .panel-stats   { grid-column: 7 / 13; grid-row: 2 / 3; }

.kpi-row {
  display: flex; flex-direction: column; gap: 20px; flex: 1; justify-content: center;
}
.kpi-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 16px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-surface);
}
.kpi-item b { font-size: 13px; color: var(--ink-dim); font-weight: 500; }
.kpi-item span { font-family: var(--font-arabic); font-size: 10px; color: var(--ink-muted); }
.kpi-num {
  font-family: var(--font-mono); font-size: 18px; font-weight: 600;
  color: var(--gold); margin-top: 4px;
}

/* ── SCENE 2: THE GAP ───────────────────────────────────── */
#scene-gap .panel-inflow  { grid-column: 1 / 6; grid-row: 1 / 3; }
#scene-gap .panel-outflow { grid-column: 6 / 13; grid-row: 1 / 3; border-color: var(--red-glow); }

.grid-telemetry-rows { display: flex; flex-direction: column; gap: 10px; }
.grid-row-tel {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}
.grid-row-tel.ok    { border-color: var(--border-teal); }
.grid-row-tel.fault { border-color: rgba(192, 97, 74, 0.18); background: var(--red-dim); }
.grid-row-tel .label-wrap { display: flex; flex-direction: column; gap: 2px; }
.grid-row-tel b    { font-size: 13px; color: var(--ink); font-weight: 500; }
.grid-row-tel span { font-family: var(--font-arabic); font-size: 9.5px; color: var(--ink-muted); }

.gap-fault-banner {
  padding: 18px 20px; border: 1px solid rgba(192, 97, 74, 0.25);
  border-radius: 8px; background: var(--red-dim);
  color: var(--ink); margin-bottom: 20px;
  display: flex; align-items: flex-start; gap: 14px;
}
.gap-fault-banner svg { color: var(--red); flex-shrink: 0; margin-top: 2px; }
.gap-fault-banner .text { font-size: 14px; line-height: 1.55; }
.gap-fault-banner .ar {
  font-family: var(--font-arabic); font-size: 11px;
  color: var(--ink-dim); display: block; margin-top: 4px;
}

/* ── SCENE 3: THE CLEARING HOUSE ────────────────────────── */
#scene-platform .panel-clearing-telemetry { grid-column: 1 / 5; grid-row: 1 / 3; }
#scene-platform .panel-clearing-engine    { grid-column: 5 / 13; grid-row: 1 / 3; }

.clearing-canvas-container {
  flex: 1; position: relative; width: 100%;
  border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; background: rgba(0, 0, 0, 0.3);
  min-height: 200px;
}
#clearing-canvas { width: 100%; height: 100%; display: block; }

.protocol-step-card {
  padding: 14px 18px; border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 10px;
  background: var(--bg-surface);
  transition: border-color 0.35s var(--ease), background 0.35s var(--ease), transform 0.35s var(--ease);
}
.protocol-step-card:hover { transform: translateX(3px); }
.protocol-step-card.active { border-color: var(--border-teal); background: var(--teal-dim); }
.protocol-step-card .hdr {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 9px;
  color: var(--teal); margin-bottom: 5px; letter-spacing: 0.1em;
}
.protocol-step-card .title { font-size: 13px; font-weight: 500; color: var(--ink); }
.protocol-step-card .ar {
  font-family: var(--font-arabic); font-size: 10px;
  color: var(--ink-muted); margin-top: 3px; line-height: 1.5;
}

/* ── SCENE 4: WORKFLOW ──────────────────────────────────── */
#scene-workflow .panel-workflow { grid-column: 1 / 13; grid-row: 1 / 3; }

.wf-console-container {
  display: flex; gap: 24px; flex: 1; align-items: stretch;
}
.wf-console-sidebar {
  width: 200px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
  padding-right: 20px; flex-shrink: 0;
}
.wf-console-step-btn {
  padding: 12px 16px; border: 1px solid transparent;
  border-radius: 8px; background: transparent;
  color: var(--ink-dim); text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  transition: all 0.3s var(--ease);
}
.wf-console-step-btn:hover { background: var(--bg-surface); border-color: var(--border); }
.wf-console-step-btn b {
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 0.1em; color: var(--ink-muted);
}
.wf-console-step-btn span { font-size: 12px; font-weight: 500; }
.wf-console-step-btn.active {
  border-color: var(--border-gold); background: var(--gold-dim); color: var(--gold);
}
.wf-console-step-btn.active b { color: var(--gold); }

.wf-console-viewport {
  flex: 1; position: relative; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
}
.wf-stage { position: relative; width: 100%; height: 100%; }

/* ── SCENE 5: MODON CITIES ──────────────────────────────── */
#scene-modon .panel-modon-cities    { grid-column: 1 / 7; grid-row: 1 / 3; }
#scene-modon .panel-modon-telemetry { grid-column: 7 / 13; grid-row: 1 / 3; }

.cities-grid-table {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  overflow-y: auto; max-height: 460px; padding-right: 4px;
}
.city-node-btn {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; color: var(--ink-dim); text-align: left;
  transition: all 0.25s var(--ease);
}
.city-node-btn:hover { border-color: var(--border-teal); color: var(--teal); background: var(--teal-dim); }
.city-node-btn.active { border-color: var(--border-teal); color: var(--teal); background: var(--teal-dim); }
.city-node-btn .name-wrap { display: flex; flex-direction: column; gap: 3px; }
.city-node-btn b { font-size: 13px; font-weight: 500; }
.city-node-btn span { font-family: var(--font-arabic); font-size: 9px; color: var(--ink-muted); }
.city-node-btn.active span { color: var(--teal); }
.city-node-btn .factories { font-family: var(--font-mono); font-size: 10px; font-weight: 500; }

.modon-telemetry-box { display: flex; flex-direction: column; gap: 24px; flex: 1; justify-content: center; }

/* ── SCENE 6: THE ASK ───────────────────────────────────── */
#scene-ask .panel-auth {
  grid-column: 3 / 11; grid-row: 1 / 3;
  border-color: var(--border-gold);
}

.auth-terminal {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1; text-align: center; padding: 24px;
}
.auth-reticle {
  width: 60px; height: 60px; border-radius: 50%;
  border: 1.5px solid var(--gold);
  display: grid; place-items: center; color: var(--gold); margin-bottom: 28px;
  box-shadow: 0 0 20px var(--gold-glow); animation: authPulse 2.8s infinite;
}
@keyframes authPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 12px var(--gold-glow); }
  50% { transform: scale(1.04); box-shadow: 0 0 28px var(--gold-glow); }
}
.auth-header {
  font-family: var(--font-display); font-size: 32px;
  line-height: 1.1; margin-bottom: 8px; font-weight: 500; font-style: italic;
}
.auth-header-ar {
  font-family: var(--font-arabic); font-size: 18px;
  color: var(--gold); margin-bottom: 22px;
}
.auth-sub {
  font-size: 14px; color: var(--ink-dim); max-width: 460px;
  margin-bottom: 32px; line-height: 1.68;
}
.auth-toggle-rows {
  width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 12px;
}
.auth-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-surface); text-align: left;
  transition: all 0.3s var(--ease);
}
.auth-toggle-row.authorized { border-color: var(--border-gold); background: var(--gold-dim); }
.auth-toggle-row .text-wrap { display: flex; flex-direction: column; gap: 2px; }
.auth-toggle-row b { font-size: 13px; color: var(--ink); font-weight: 500; }
.auth-toggle-row span { font-family: var(--font-arabic); font-size: 10px; color: var(--ink-muted); margin-top: 2px; }
.auth-toggle-row.authorized b { color: var(--gold); }
.auth-toggle-row.authorized span { color: var(--gold); }

.auth-switch {
  width: 42px; height: 23px; border-radius: 99px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  position: relative; cursor: pointer; transition: all 0.3s var(--ease);
  flex-shrink: 0;
}
.auth-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--ink-muted); transition: all 0.3s var(--ease);
}
.auth-toggle-row.authorized .auth-switch { background: var(--gold); border-color: var(--gold); }
.auth-toggle-row.authorized .auth-switch::after { left: 22px; background: #0d0f0e; }

/* ── SCENE 7: CLOSING ───────────────────────────────────── */
#scene-closing .panel-closing {
  grid-column: 4 / 10; grid-row: 1 / 3;
  display: flex; flex-direction: column; justify-content: center;
  align-items: center; text-align: center; gap: 0;
  border-color: var(--border-gold);
}
.closing-logo {
  height: 48px; margin-bottom: 28px;
  filter: drop-shadow(0 0 16px var(--teal-glow));
}
.closing-quote {
  font-family: var(--font-display); font-weight: 400; font-style: italic;
  font-size: clamp(28px, 3.2vw, 44px); line-height: 1.15; margin-bottom: 14px;
}
.closing-quote-ar {
  font-family: var(--font-arabic); font-size: clamp(16px, 1.8vw, 22px);
  color: var(--gold); margin-bottom: 28px;
}
.closing-desc { font-size: 14px; color: var(--ink-dim); max-width: 420px; line-height: 1.7; }
.closing-desc-ar {
  font-family: var(--font-arabic); font-size: 11px; color: var(--ink-muted);
  display: block; margin-top: 8px;
}

/* ── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

/* ── ARABIC MODE ────────────────────────────────────────── */
.ar-only { display: none; }
.en-only { display: block; }
body.ar-mode { direction: rtl; font-family: var(--font-arabic); }
body.ar-mode .en-only { display: none; }
body.ar-mode .ar-only { display: block; }
body.ar-mode .tel-block { border-left: none; border-right: 2px solid var(--teal); padding-left: 0; padding-right: 16px; }
body.ar-mode .tel-block.gold { border-color: var(--gold); }
body.ar-mode .tel-block.red  { border-color: var(--red); }
body.ar-mode .city-node-btn  { text-align: right; }
body.ar-mode .auth-toggle-row { text-align: right; }
body.ar-mode .wf-console-step-btn { text-align: right; }
body.ar-mode .protocol-step-card:hover { transform: translateX(-3px); }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 960px) {
  .screen-content {
    grid-template-columns: 1fr; height: auto;
    overflow-y: auto; gap: 16px; padding: 70px 0;
  }
  #scene-cover .panel-hero, #scene-cover .panel-context, #scene-cover .panel-stats,
  #scene-gap .panel-inflow, #scene-gap .panel-outflow,
  #scene-platform .panel-clearing-telemetry, #scene-platform .panel-clearing-engine,
  #scene-workflow .panel-workflow,
  #scene-modon .panel-modon-cities, #scene-modon .panel-modon-telemetry,
  #scene-ask .panel-auth,
  #scene-closing .panel-closing { grid-column: 1 / -1 !important; grid-row: auto !important; }
  .bg-canvas-container { opacity: 0.2; }
  .wf-console-container { flex-direction: column; }
  .wf-console-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 16px; flex-direction: row; overflow-x: auto; }
  .wf-console-step-btn { flex-shrink: 0; }
}
