/* ═══════════════════════════════════════════════════
   ClearFlow Digital — Core Visual Identity
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;1,14..32,300&display=swap');

/* ─── DESIGN TOKENS ──────────────────────────────── */
:root {
  --navy:        #1A202C;
  --navy-soft:   #2D3748;
  --cyan:        #06B6D4;
  --cyan-light:  #67E8F9;
  --cyan-dim:    rgba(6, 182, 212, 0.08);
  --cyan-glow:   rgba(6, 182, 212, 0.35);
  --glass:       rgba(255, 255, 255, 0.8);
  --white:       #ffffff;
  --gray-50:     #F8FAFC;
  --gray-100:    #F1F5F9;
  --gray-200:    #E2E8F0;
  --gray-400:    #94A3B8;
  --gray-600:    #64748B;

  /* ── Spacing rhythm (8px base) ── */
  --space-1:  8px;
  --space-2:  16px;
  --space-3:  24px;
  --space-4:  32px;
  --space-6:  48px;
  --space-8:  64px;

  /* ── Touch targets ── */
  --touch-min: 44px;

  /* ── Safe-area bottom ── */
  --nav-h:  68px;
  --nav-pad: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

/* ─── GLOBAL RESET & BASE ────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  /* Allow dvh units to fall back gracefully */
  height: -webkit-fill-available;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  /* Fallback for browsers that don't support dvh */
  min-height: 100vh;
  min-height: 100dvh;
}

/* ─── GLOBAL MOBILE SAFETY ───────────────────── */
img, video, iframe, canvas {
  max-width: 100%;
  height: auto;
}

/* Prevent iOS input zoom — 16px minimum */
@media (max-width: 768px) {
  input, select, textarea, button {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
  }
}

/* ─── FLEX/GRID OVERFLOW SAFETY ─────────────────── */
/* Prevent flex children from overflowing their container */
.flex-shrink-fix {
  min-width: 0;
  min-height: 0;
}

/* ─── GLASS PANEL ────────────────────────────────── */
.glass-panel {
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
  pointer-events: auto;
}

/* ─── BOTTOM NAV (Portal) ────────────────────────── */
#mobile-nav,
.bottom-nav {
  z-index: 9999;
}

/* ─── APPLE-STYLE BUTTONS ────────────────────────── */
button,
a.btn-primary,
.btn-primary,
a.btn-secondary,
.btn-secondary,
a.btn-portal,
.btn-portal,
a.btn-flow,
.btn-flow,
.btn-login,
.request-link {
  border-radius: 9999px;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Minimum touch target for primary interactive elements on mobile */
@media (max-width: 768px) {
  .btn-primary,
  .btn-secondary,
  .btn-portal,
  .btn-flow,
  .btn-submit,
  .btn-save,
  a.btn-primary,
  a.btn-secondary {
    min-height: var(--touch-min);
  }
}

.btn-primary:hover,
a.btn-primary:hover {
  box-shadow: 0 0 0 3px var(--cyan-glow), 0 8px 32px rgba(6, 182, 212, 0.45);
  transform: translateY(-2px);
}

.btn-secondary:hover,
a.btn-secondary:hover {
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.3);
  border-color: var(--cyan);
}

.btn-portal:hover,
a.btn-portal:hover {
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.25);
}

.btn-flow:hover,
a.btn-flow:hover {
  box-shadow: 0 0 0 3px var(--cyan-glow), 0 16px 50px rgba(6, 182, 212, 0.55);
  transform: translateY(-3px);
}

/* ─── MODAL BASE ─────────────────────────────────── */
/* Shared modal anatomy — used across portal and landing pages */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-4) var(--space-2);
}

.modal-card {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  /* Never exceed viewport — allow inner scroll */
  max-height: calc(100dvh - 2 * var(--space-4));
  overflow: hidden;
}

.modal-header {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-3);
  min-height: 0;
}

.modal-actions {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: var(--space-1);
}

/* ─── SCROLL REVEAL ──────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1000ms cubic-bezier(0.4, 0, 0.2, 1),
              transform 1000ms cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── LIVE INDICATOR PULSE ───────────────────────── */
@keyframes live-pulse {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.7);
  }
  50% {
    opacity: 0.85;
    box-shadow: 0 0 0 6px rgba(6, 182, 212, 0);
  }
}

.live-indicator,
.crm-live-dot,
.live-dot,
.hero-badge-dot {
  animation: live-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
