/* ==========================================================================
   Somatic Strings - Circadian Design Tokens & Glassmorphic Scaffolding
   Advenire Software Standards
   ========================================================================== */

:root {
  /* Twilight Ember (Default Circadian Rest State - ~590nm / 2200K) */
  --bg-primary: #0d0907;
  --bg-surface: rgba(28, 18, 14, 0.65);
  --bg-surface-elevated: rgba(42, 26, 20, 0.82);
  --border-subtle: rgba(245, 158, 11, 0.16);
  --border-focus: rgba(245, 158, 11, 0.45);
  --accent-main: #f59e0b;
  --accent-glow: rgba(245, 158, 11, 0.4);
  --accent-secondary: #d97706;
  --string-rest: rgba(245, 158, 11, 0.28);
  --string-vibe: #fbbf24;
  --string-glow: rgba(251, 191, 36, 0.7);
  --text-main: #fef3c7;
  --text-muted: #d97706;
  --text-ghost: rgba(254, 243, 199, 0.45);
  --font-display: 'Cinzel', serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  --hud-transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

body[data-theme="monolith"] {
  /* Monolith Focus State - Charcoal & Bioluminescent Cyan */
  --bg-primary: #06090e;
  --bg-surface: rgba(14, 22, 33, 0.65);
  --bg-surface-elevated: rgba(20, 32, 48, 0.85);
  --border-subtle: rgba(6, 182, 212, 0.16);
  --border-focus: rgba(6, 182, 212, 0.45);
  --accent-main: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.45);
  --accent-secondary: #0891b2;
  --string-rest: rgba(6, 182, 212, 0.25);
  --string-vibe: #38bdf8;
  --string-glow: rgba(56, 189, 248, 0.75);
  --text-main: #e0f2fe;
  --text-muted: #38bdf8;
  --text-ghost: rgba(224, 242, 254, 0.45);
}

body[data-theme="solarium"] {
  /* Solarium Daytime State - Warm Muted Parchment & Deep Sienna */
  --bg-primary: #f5ede2;
  --bg-surface: rgba(237, 226, 212, 0.75);
  --bg-surface-elevated: rgba(229, 215, 197, 0.9);
  --border-subtle: rgba(180, 83, 9, 0.16);
  --border-focus: rgba(180, 83, 9, 0.4);
  --accent-main: #b45309;
  --accent-glow: rgba(180, 83, 9, 0.25);
  --accent-secondary: #92400e;
  --string-rest: rgba(180, 83, 9, 0.25);
  --string-vibe: #b45309;
  --string-glow: rgba(180, 83, 9, 0.45);
  --text-main: #3d2314;
  --text-muted: #78350f;
  --text-ghost: rgba(61, 35, 20, 0.45);
}

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

html, body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-body);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.viewport-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

canvas#somatic-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
}

/* ==========================================================================
   Glassmorphism Foundations
   ========================================================================== */
.glass-card {
  background: var(--bg-surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.45);
  transition: var(--hud-transition);
}

/* ==========================================================================
   Top HUD
   ========================================================================== */
.hud-header {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  max-width: 1040px;
  margin: 0 auto;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-main);
  box-shadow: 0 0 12px var(--accent-glow);
  display: inline-block;
  animation: pulseAura 3s ease-in-out infinite;
}

@keyframes pulseAura {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; filter: drop-shadow(0 0 6px var(--accent-main)); }
}

.brand-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-main);
}

.pill-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.sanctuary-badge {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.35));
  border: 1px solid var(--border-focus);
  color: var(--text-main);
}

.action-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--hud-transition);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-subtle);
}

.icon-btn.active {
  color: var(--accent-main);
  background: rgba(245, 158, 11, 0.12);
  border-color: var(--border-focus);
}

.btn-sanctuary {
  background: linear-gradient(135deg, var(--accent-main), var(--accent-secondary));
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  min-height: 44px;
}

.btn-sanctuary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--accent-glow);
}

.star-icon {
  font-size: 0.85rem;
}

/* ==========================================================================
   Telemetry Oscilloscope
   ========================================================================== */
.telemetry-pill {
  position: absolute;
  top: max(78px, calc(env(safe-area-inset-top) + 62px));
  left: 20px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  pointer-events: none;
}

#telemetry-canvas {
  width: 90px;
  height: 20px;
}

.telemetry-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.telemetry-text span:first-child {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.telemetry-text span:last-child {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ==========================================================================
   Bottom HUD Deck
   ========================================================================== */
.hud-footer {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  z-index: 10;
  padding: 12px 18px;
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-cluster {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-cluster-inline {
  display: flex;
  gap: 16px;
  width: 100%;
}

.control-cluster-inline .control-cluster {
  flex: 1;
}

.cluster-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 600;
  color: var(--text-muted);
}

.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented-control::-webkit-scrollbar {
  display: none;
}

.segment {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-ghost);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 8px 10px;
  min-height: 40px;
  border-radius: calc(var(--radius-md) - 3px);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.segment:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.segment.active {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-focus);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  font-weight: 600;
}

.segment.locked-feature {
  opacity: 0.75;
}

/* Studio Zen View Mode */
body.studio-zen .hud-header,
body.studio-zen .hud-footer,
body.studio-zen .telemetry-pill {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

/* ==========================================================================
   Gesture Unlock Gate Overlay
   ========================================================================== */
.gesture-gate {
  position: absolute;
  inset: 0;
  z-index: 99;
  background: rgba(10, 7, 5, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.gesture-gate.dismissed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gate-card {
  max-width: 440px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.gate-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-main);
  font-weight: 600;
}

.gate-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-main);
}

.gate-desc {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-ghost);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-main), var(--accent-secondary));
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 14px 28px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 6px 20px var(--accent-glow);
  min-height: 48px;
  touch-action: manipulation;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 26px var(--accent-glow);
}

.gate-hint {
  font-size: 0.75rem;
  color: var(--text-ghost);
  letter-spacing: 0.05em;
}

/* ==========================================================================
   Stripe Sanctuary Upgrade Modal
   ========================================================================== */
.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  padding: 28px;
  position: relative;
  background: var(--bg-surface-elevated);
}

.modal-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: var(--text-ghost);
  cursor: pointer;
  line-height: 1;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-close-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.modal-header {
  text-align: center;
  margin-bottom: 20px;
}

.modal-icon {
  font-size: 1.8rem;
  color: var(--accent-main);
  margin-bottom: 4px;
}

.modal-eyebrow {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent-main);
  font-weight: 600;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--text-main);
  margin: 6px 0;
}

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-ghost);
  line-height: 1.4;
}

.feature-checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 22px;
}

.feature-checklist li {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
}

.check-mark {
  color: var(--accent-main);
  font-weight: bold;
}

.feature-checklist li div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.feature-checklist li div strong {
  color: var(--text-main);
}

.feature-checklist li div span {
  color: var(--text-ghost);
  font-size: 0.78rem;
}

.pricing-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  margin-bottom: 18px;
}

.price-box {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

.price-box .currency {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-main);
}

.price-box .amount {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.price-box .term {
  font-size: 0.78rem;
  color: var(--text-ghost);
}

.secure-tag {
  display: block;
  font-size: 0.7rem;
  color: var(--accent-main);
  margin-top: 4px;
  letter-spacing: 0.04em;
}

.btn-checkout {
  width: 100%;
  justify-content: center;
}

.modal-footer-note {
  margin-top: 14px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-ghost);
}

.text-link {
  background: transparent;
  border: none;
  color: var(--accent-main);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.78rem;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Responsive Viewport Refinements
   ========================================================================== */
@media (max-width: 640px) {
  .hud-header {
    padding: 8px 12px;
  }
  .brand-title {
    font-size: 0.82rem;
  }
  .btn-sanctuary {
    padding: 6px 12px;
    font-size: 0.72rem;
  }
  .control-cluster-inline {
    flex-direction: column;
    gap: 8px;
  }
  .hud-footer {
    padding: 10px 12px;
    gap: 8px;
  }
  .telemetry-pill {
    display: none;
  }
}
