/* ═══════════════════════════════════════════════════════════════════════════════
   TRENCHES — DESIGN SYSTEM (2027 SPEC)
   Apple · Nothing · Stripe · Linear · FOMO · Modern Financial Terminal
   Ultra-Dark · Monochrome · Smoked Glass · Micro-Borders · Ample Negative Space
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Canvas & Surfaces ── */
  --bg-canvas: #000000;
  --surface-base: #060608;
  --surface-elevated: #0c0c0f;
  --surface-card: rgba(255, 255, 255, 0.024);
  --surface-card-hover: rgba(255, 255, 255, 0.045);
  --surface-card-active: rgba(255, 255, 255, 0.065);
  --surface-glass: rgba(10, 10, 14, 0.72);
  --surface-glass-modal: rgba(8, 8, 10, 0.88);
  --surface-input: rgba(255, 255, 255, 0.035);

  /* ── Borders & Micro-Lines ── */
  --border-ultra-subtle: rgba(255, 255, 255, 0.04);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-mid: rgba(255, 255, 255, 0.14);
  --border-hover: rgba(255, 255, 255, 0.22);
  --border-focus: rgba(255, 255, 255, 0.45);

  /* ── Typography ── */
  --font-sans: -apple-system, BlinkMacSystemFont, "Geist", "Inter", "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Geist Mono", "JetBrains Mono", "Fira Code", monospace;

  /* ── Monochrome Text Palette ── */
  --text-pure: #ffffff;
  --text-primary: #ededed;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --text-muted: #52525b;
  --text-ghost: #3f3f46;

  /* ── Functional Deltas (strictly for price deltas, never backgrounds) ── */
  --delta-green: #22c55e;
  --delta-green-glow: rgba(34, 197, 94, 0.15);
  --delta-red: #ef4444;
  --delta-red-glow: rgba(239, 68, 68, 0.15);

  /* ── Shadows & Refraction ── */
  --glass-blur: blur(28px) saturate(190%);
  --glass-blur-sm: blur(14px) saturate(180%);
  --sheen-top: radial-gradient(ellipse 70% 30% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 70%);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--border-subtle);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.9), 0 0 0 1px var(--border-subtle);
  --shadow-card-hover: 0 14px 40px -10px rgba(0, 0, 0, 0.95), 0 0 0 1px var(--border-mid);
  --shadow-modal: 0 28px 70px -14px rgba(0, 0, 0, 0.98), 0 0 0 1px var(--border-mid);

  /* ── Transitions & Radii ── */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --transition-fast: 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);

  /* ── Mobile Safe Areas ── */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset & Baseline ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 14px;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  min-height: 100%;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Typography Utilities ── */
.mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1, "zero" 1;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-pure);
}

a {
  color: inherit;
  text-decoration: none;
}

/* ── Glass Primitives ── */
.glass-panel {
  background: var(--surface-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.glass-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  pointer-events: none;
}

.glass-panel:hover {
  border-color: var(--border-mid);
}

.glass-panel-interactive:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

/* ── Buttons (Apple & Linear minimalism) ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 0 18px rgba(255, 255, 255, 0.15);
}

.btn-primary:hover {
  background: #e8e8e8;
  border-color: #e8e8e8;
  box-shadow: 0 2px 10px rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--border-subtle);
  backdrop-filter: blur(10px);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--border-mid);
  color: #ffffff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--text-pure);
  background: rgba(255, 255, 255, 0.04);
}

.btn-sm {
  font-size: 11px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  font-size: 15px;
  padding: 12px 24px;
  border-radius: var(--radius-lg);
}

/* ── Interactive Financial Asset Pill ($TICKER) ── */
.asset-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-pure);
  cursor: pointer;
  transition: all var(--transition-fast);
  vertical-align: middle;
  box-shadow: var(--shadow-sm);
}

.asset-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.asset-pill .pill-sym {
  color: #ffffff;
  font-weight: 700;
}

.asset-pill .pill-price {
  color: var(--text-secondary);
}

.asset-pill .pill-delta {
  font-weight: 700;
}

.asset-pill .pill-delta.up {
  color: var(--delta-green);
}

.asset-pill .pill-delta.down {
  color: var(--delta-red);
}

.asset-pill .pill-action {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  padding: 1px 7px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.asset-pill:hover .pill-action {
  background: #ffffff;
  color: #000000;
}

/* ── Elite Score Badge ── */
.elite-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.elite-badge.high {
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.elite-badge.mid {
  border-color: rgba(234, 179, 8, 0.3);
  color: #fde047;
}

/* ── Inputs & Selects ── */
input, select, textarea {
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-pure);
  font-family: var(--font-sans);
  font-size: 13px;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  background: rgba(255, 255, 255, 0.055);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

/* ── Modals & Drawers ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  padding: 16px;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-window {
  background: var(--surface-glass-modal);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: scale(0.96) translateY(8px);
  transition: transform var(--transition-normal);
}

.modal-backdrop.active .modal-window {
  transform: scale(1) translateY(0);
}

/* ── Scrollbars ── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ── Mobile-First Responsive Breakpoints ── */
@media (max-width: 768px) {
  html {
    font-size: 13px;
  }

  .desktop-only {
    display: none !important;
  }
}

@media (min-width: 769px) {
  .mobile-only {
    display: none !important;
  }
}
