/* ==========================================================================
   MarmaAI — Design tokens & global shell styles
   ========================================================================== */

:root {
  /* Shell (dark) */
  --shell-bg: #0E1210;
  --shell-surface: #171B18;
  --shell-surface-2: #1E2320;
  --shell-border: rgba(212,175,55,0.14);
  --shell-border-strong: rgba(212,175,55,0.28);
  --shell-ink: #E8E1D0;
  --shell-ink-mute: #9BA097;
  --shell-ink-faint: #5D6259;

  /* Content cards (parchment) */
  --card-bg: #F5EFE3;
  --card-bg-2: #EDE5D3;
  --card-border: rgba(26,29,32,0.10);
  --card-border-strong: rgba(26,29,32,0.18);
  --card-ink: #1A1D20;
  --card-ink-mute: #5A5F5A;
  --card-ink-faint: #8A8F87;

  /* Brand */
  --emerald-deep: #0F5132;
  --emerald: #198754;
  --emerald-soft: #2A9D6C;
  --gold: #D4AF37;
  --gold-deep: #B8941F;
  --gold-soft: rgba(212,175,55,0.18);
  --copper: #B87333;
  --sage: #87A96B;
  --ivory: #F0EAD6;

  /* Verification states */
  --state-verified: #10B981;
  --state-jitter: #F59E0B;
  --state-unverified: #EF4444;

  /* Type */
  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-ui: "Inter Tight", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-sans-alt: "Cormorant Garamond", "Fraunces", serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  /* Layout */
  --sidebar-w: 240px;
  --sidebar-w-mini: 76px;
  --topbar-h: 64px;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --accent: var(--gold);
  --accent-deep: var(--gold-deep);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--shell-bg); color: var(--shell-ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
body { overflow: hidden; }
#app { height: 100vh; width: 100vw; }

/* Utility */
.font-display { font-family: var(--font-display); font-optical-sizing: auto; }
.font-alt { font-family: var(--font-sans-alt); }
.font-mono { font-family: var(--font-mono); }

/* Shell texture: subtle grain */
.shell-grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background-image:
    radial-gradient(1200px 700px at 10% -10%, rgba(212,175,55,0.06), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(25,135,84,0.05), transparent 60%);
  mix-blend-mode: screen;
}
.shell-noise {
  position: fixed; inset: 0; pointer-events: none; z-index: 2; opacity: 0.035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.35 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.16); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(212,175,55,0.28); }

/* Focus ring */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Buttons */
.btn {
  font-family: var(--font-ui); font-weight: 500; font-size: 14px; letter-spacing: -0.01em;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  transition: all 160ms ease; user-select: none;
}
.btn-primary { background: var(--emerald); color: #F5EFE3; border-color: rgba(255,255,255,0.06); }
.btn-primary:hover { background: var(--emerald-soft); box-shadow: 0 4px 20px rgba(25,135,84,0.35); }
.btn-gold { background: var(--gold); color: #1A1D20; }
.btn-gold:hover { background: #E5C24A; box-shadow: 0 4px 20px rgba(212,175,55,0.35); }
.btn-ghost { background: transparent; color: var(--shell-ink); border-color: var(--shell-border); }
.btn-ghost:hover { background: rgba(212,175,55,0.06); border-color: var(--shell-border-strong); }
.btn-card { background: var(--card-ink); color: var(--card-bg); }
.btn-card:hover { background: #2c3033; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Cards */
.card {
  background: var(--card-bg);
  color: var(--card-ink);
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  position: relative;
  overflow: hidden;
}
.card-paper::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence baseFrequency='0.75' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.6  0 0 0 0 0.5  0 0 0 0 0.35  0 0 0 0.10 0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
  opacity: 0.6; mix-blend-mode: multiply;
}
.card-dark {
  background: var(--shell-surface);
  color: var(--shell-ink);
  border-radius: var(--radius-lg);
  border: 1px solid var(--shell-border);
  position: relative;
  overflow: hidden;
}

/* Chips / pills */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid;
}
.chip-gold { color: var(--gold); border-color: rgba(212,175,55,0.35); background: rgba(212,175,55,0.08); }
.chip-emerald { color: #0F5132; border-color: rgba(15,81,50,0.25); background: rgba(25,135,84,0.10); }
.chip-verified { color: var(--state-verified); border-color: rgba(16,185,129,0.35); background: rgba(16,185,129,0.10); }
.chip-jitter { color: var(--state-jitter); border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.10); }
.chip-unverified { color: var(--state-unverified); border-color: rgba(239,68,68,0.35); background: rgba(239,68,68,0.10); }

/* Divider */
.gold-divider {
  height: 1px; background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
  border: none; margin: 0;
}

/* Gold sanskrit flourish */
.flourish {
  font-family: var(--font-sans-alt); font-style: italic; font-weight: 400;
  color: var(--gold); letter-spacing: 0.02em;
}

/* View transition */
.view-fade { animation: fadeUp 240ms cubic-bezier(.2,.7,.2,1); }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .view-fade { animation: none; }
}

/* Eyebrow */
.eyebrow {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--card-ink-mute); font-weight: 500;
}
.eyebrow-light { color: var(--shell-ink-mute); }

/* Sidebar */
.sidebar {
  flex-shrink: 0; height: 100vh;
  background: linear-gradient(180deg, #10151300 0%, #0E1210 20%);
  border-right: 1px solid var(--shell-border);
  display: flex; flex-direction: column;
  transition: width 220ms cubic-bezier(.2,.7,.2,1);
  position: relative; z-index: 10;
  width: var(--sidebar-w);
}
.sidebar.is-mini, .sidebar.is-collapsed { width: var(--sidebar-w-mini); }

.side-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--shell-ink-mute); font-weight: 500; font-size: 14px;
  cursor: pointer; position: relative; letter-spacing: -0.005em;
  transition: all 160ms ease;
  border: 1px solid transparent;
}
.side-item:hover { color: var(--shell-ink); background: rgba(212,175,55,0.05); }
.side-item.active {
  color: #F5EFE3;
  background: linear-gradient(180deg, rgba(25,135,84,0.16), rgba(15,81,50,0.10));
  border-color: rgba(25,135,84,0.30);
}
.side-item.active::before {
  content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px;
  background: var(--accent); border-radius: 3px;
}
.side-icon { width: 20px; height: 20px; stroke-width: 1.75; flex-shrink: 0; }

/* AR viewport specific */
.ar-canvas {
  position: relative;
  background: #050706;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--shell-border);
  min-height: 500px;
}
.ar-scanlines {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(180deg, transparent 0, transparent 2px, rgba(255,255,255,0.015) 2px, rgba(255,255,255,0.015) 3px);
}
.ar-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.6) 100%);
}
.ar-edge-glow {
  position: absolute; inset: 0; pointer-events: none; border-radius: var(--radius-lg);
  box-shadow: inset 0 0 80px rgba(16,185,129,0.25), inset 0 0 200px rgba(16,185,129,0.06);
}
.ar-edge-glow.jitter { box-shadow: inset 0 0 60px rgba(245,158,11,0.20); }
.ar-edge-glow.unverified { box-shadow: inset 0 0 80px rgba(239,68,68,0.28); }

/* HUD reticles */
.hud-corner { position: absolute; width: 36px; height: 36px; border: 2px solid rgba(212,175,55,0.7); }
.hud-corner.tl { top: 24px; left: 24px; border-right: none; border-bottom: none; }
.hud-corner.tr { top: 24px; right: 24px; border-left: none; border-bottom: none; }
.hud-corner.bl { bottom: 24px; left: 24px; border-right: none; border-top: none; }
.hud-corner.br { bottom: 24px; right: 24px; border-left: none; border-top: none; }

/* HUD ring */
@keyframes pulseRing { 0%, 100% { transform: scale(1); opacity: 0.9; } 50% { transform: scale(1.06); opacity: 0.6; } }
.hud-ring { animation: pulseRing 2.4s ease-in-out infinite; transform-origin: center; }
@media (prefers-reduced-motion: reduce) { .hud-ring { animation: none; } }

/* Progress ring */
.ring-track { stroke: rgba(26,29,32,0.12); }

/* Drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  animation: fadeIn 180ms ease;
}
.drawer-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 92%);
  background: var(--card-bg); box-shadow: -20px 0 60px rgba(0,0,0,0.4);
  animation: slideIn 240ms cubic-bezier(.2,.7,.2,1);
  overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* Mobile hint */
@media (max-width: 720px) {
  .desktop-only-note { display: block !important; }
}

/* Om divider */
.om-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--gold); font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase;
}
.om-divider::before, .om-divider::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,175,55,0.4), transparent);
}

/* Rows */
.row-hover:hover { background: rgba(26,29,32,0.03); }

/* Segment control */
.seg {
  display: inline-flex; padding: 3px; gap: 3px;
  background: rgba(26,29,32,0.06); border-radius: 10px;
  border: 1px solid var(--card-border);
}
.seg-dark { background: rgba(255,255,255,0.03); border-color: var(--shell-border); }
.seg button {
  border: none; background: transparent; font-family: var(--font-ui); font-size: 12.5px; font-weight: 500;
  padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--card-ink-mute);
}
.seg-dark button { color: var(--shell-ink-mute); }
.seg button.on { background: var(--card-ink); color: var(--card-bg); }
.seg-dark button.on { background: rgba(212,175,55,0.16); color: var(--shell-ink); }

/* Info tooltip */
.tracking-info {
  position: relative; display: inline-flex; cursor: help;
}
.tracking-info .dot {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1px solid var(--card-ink-faint);
  color: var(--card-ink-mute);
  font-size: 9px; font-family: var(--font-mono); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}
.tracking-info.dark .dot {
  border-color: var(--shell-ink-faint);
  color: var(--shell-ink-mute);
}
.tracking-info .tooltip {
  position: absolute; top: calc(100% + 6px); left: -8px; z-index: 200;
  background: #1E2320; color: #E8E1D0;
  border: 1px solid rgba(212,175,55,0.28);
  padding: 8px 10px; border-radius: 8px; width: 220px;
  font-size: 11.5px; line-height: 1.45; letter-spacing: 0; text-transform: none;
  font-family: var(--font-ui); font-weight: 400;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  pointer-events: none;
  display: none;
}
.tracking-info.open .tooltip { display: block; }

/* Nav / topbar */
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--shell-border);
  background: rgba(14,18,16,0.7);
  backdrop-filter: blur(20px);
  position: relative; z-index: 5;
}
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.02); border: 1px solid var(--shell-border);
  color: var(--shell-ink-faint); font-size: 13px;
  width: 260px;
}
.cam-status {
  display: flex; align-items: center; gap: 6px; color: var(--state-verified);
  font-size: 11.5px; font-family: var(--font-mono); letter-spacing: 0.06em;
}
.cam-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--state-verified); box-shadow: 0 0 8px var(--state-verified); }

/* Region filter chips (library) */
.region-chip {
  padding: 8px 14px; border-radius: 999px;
  background: transparent; border: 1px solid var(--shell-border);
  color: var(--shell-ink-mute);
  font-size: 12.5px; font-weight: 500; font-family: var(--font-ui);
  text-transform: capitalize; cursor: pointer;
  letter-spacing: 0.02em; white-space: nowrap;
}
.region-chip.active {
  background: rgba(212,175,55,0.15);
  border-color: rgba(212,175,55,0.4);
  color: var(--gold);
}

/* Library card */
.point-card {
  background: var(--card-bg); border-radius: 16px;
  border: 1px solid var(--card-border);
  overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column;
  transition: transform 220ms cubic-bezier(.2,.7,.2,1), box-shadow 220ms ease, border-color 220ms ease;
}
.point-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  border-color: var(--card-border-strong);
}

/* Region tile (dashboard) */
.region-tile {
  padding: 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--card-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.4), rgba(255,255,255,0));
  transition: all 160ms ease;
}
.region-tile:hover { border-color: var(--card-border-strong); }

/* Safety guideline card */
.safety-item { padding: 24px; display: flex; gap: 20px; }

/* Mobile note (desktop-only) */
.desktop-only-note { display: none; }

/* Layout */
.app-shell { display: flex; height: 100vh; width: 100vw; position: relative; z-index: 3; }
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.view-scroll { flex: 1; overflow: auto; min-height: 0; }
