/*
 * ============================================================
 * OpseraCert Design System
 * ============================================================
 * Cinematic dark-mode aesthetic with glassy layered panels,
 * bold typography, and subtle depth. Intentionally avoids
 * generic SaaS gradients and "AI template" patterns.
 *
 * Color philosophy: Deep charcoal surfaces with a single
 * electric cyan accent. Security-focused products deserve
 * coolness and precision — not warmth.
 * ============================================================
 */

/* ---- FONT LOADING ---- */
/* Switzer (Fontshare) — clean geometric sans with character.
   Cabinet Grotesk for display — bold, modern, distinctive. */
@import url('https://api.fontshare.com/v2/css?f[]=switzer@400,500,600,700&f[]=cabinet-grotesk@500,700,800&display=swap');

/* ---- CSS CUSTOM PROPERTIES ---- */
:root {
  /* === SURFACES === */
  /* Deep charcoal base — not pure black, warmed slightly
     to avoid the "OLED void" look */
  --bg-deep:       #0a0b0f;
  --bg-base:       #0e1016;
  --bg-surface:    #141620;
  --bg-elevated:   #1a1d2a;
  --bg-panel:      #1e2133;
  --bg-hover:      #252940;

  /* === GLASS EFFECT === */
  /* Frosted glass panels use backdrop-filter with semi-transparent fills.
     The border uses a very subtle light stroke for depth. */
  --glass-bg:      rgba(20, 22, 32, 0.65);
  --glass-border:  rgba(255, 255, 255, 0.06);
  --glass-hover:   rgba(255, 255, 255, 0.03);
  --glass-blur:    16px;

  /* === TEXT === */
  --text-primary:  #e8eaf0;
  --text-secondary: #8b90a5;
  --text-tertiary: #555a70;
  --text-inverse:  #0a0b0f;

  /* === ACCENT — Electric Cyan === */
  /* A single accent hue. Not teal, not blue — a precise
     cyan that reads "secure" and "technical". */
  --accent:        #00d4ff;
  --accent-muted:  #00a8cc;
  --accent-dim:    rgba(0, 212, 255, 0.15);
  --accent-glow:   rgba(0, 212, 255, 0.08);

  /* === SEMANTIC === */
  --color-success: #34d399;
  --color-warning: #fbbf24;
  --color-error:   #f87171;
  --color-info:    #60a5fa;

  /* === BORDERS === */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* === TYPOGRAPHY === */
  --font-display: 'Cabinet Grotesk', 'Inter', sans-serif;
  --font-body:    'Switzer', 'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* Fluid type scale */
  --text-xs:   clamp(0.75rem, 0.7rem + 0.25vw, 0.8125rem);
  --text-sm:   clamp(0.8125rem, 0.78rem + 0.2vw, 0.875rem);
  --text-base: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
  --text-lg:   clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
  --text-xl:   clamp(1.25rem, 1.1rem + 0.75vw, 1.75rem);
  /* Display sizes — landing page hero ONLY */
  --text-2xl:  clamp(1.75rem, 1.2rem + 2vw, 2.75rem);
  --text-3xl:  clamp(2.25rem, 1rem + 4vw, 4rem);

  /* === SPACING (4px base unit) === */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* === RADIUS === */
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.25rem;
  --radius-full: 9999px;

  /* === MOTION === */
  /* Easing curves — see shared/03-motion.md for full reference */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);   /* entries, reveals — fast start, gentle settle */
  --ease-in:     cubic-bezier(0.4, 0, 1, 1);       /* exits only — slow start, fast finish */
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);     /* morphs, layout shifts */
  --transition-fast: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-medium: 300ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Stagger timing — applied via animation-delay in JS */
  --stagger-interval: 50ms;
  /* Page transition */
  --page-enter-duration: 350ms;
  --page-exit-duration: 180ms;
  /* Counter animation */
  --counter-duration: 800ms;

  /* === SHADOWS (cool-toned to match palette) === */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(0, 212, 255, 0.06);

  /* === LAYOUT === */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;
}


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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-16);
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--bg-deep);
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6 { text-wrap: balance; line-height: 1.2; font-family: var(--font-display); font-weight: 700; }
p, li, figcaption { text-wrap: pretty; max-width: 72ch; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; background: none; border: none; }
ul { list-style: none; }

::selection {
  background: rgba(0, 212, 255, 0.25);
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ---- INTERACTIVE TRANSITIONS ---- */
a, button, [role="button"], input, textarea, select {
  transition: color var(--transition-fast),
              background var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-fast),
              transform var(--transition-fast),
              opacity var(--transition-fast);
}

/* ---- REDUCED MOTION ---- */
/* Users who prefer reduced motion get instant state changes.
   All animation durations collapse, stagger delays zero out,
   and page transitions become immediate swaps. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  :root {
    --stagger-interval: 0ms;
    --page-enter-duration: 0ms;
    --page-exit-duration: 0ms;
    --counter-duration: 0ms;
  }
  /* Ensure stagger-animated elements are immediately visible */
  .stagger-item { opacity: 1 !important; transform: none !important; }
  .page-enter, .page-exit { opacity: 1 !important; transform: none !important; }
  /* Kill pulse/glow loops */
  .pulse-warning, .pulse-critical, .glow-critical { animation: none !important; }
}


/* ============================================================
 * COMPONENT LIBRARY
 * ============================================================ */

/* ---- GLASS PANEL ---- */
/* The signature element. Layered frosted-glass panels with
   subtle borders and depth. Used for cards, modals, nav. */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
}

.glass-strong {
  background: rgba(20, 22, 32, 0.82);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
}

.glass-hover:hover {
  background: rgba(25, 28, 42, 0.75);
  border-color: rgba(255, 255, 255, 0.10);
}


/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-md);
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.15);
}
.btn-primary:hover {
  background: #00bfe6;
  box-shadow: 0 0 30px rgba(0, 212, 255, 0.25);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.1);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.btn-secondary:active { transform: translateY(0); }

.btn-ghost {
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-4);
}
.btn-ghost:hover { color: var(--text-primary); background: var(--glass-hover); }

.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}
.btn-icon:hover { color: var(--text-primary); background: var(--glass-hover); }


/* ---- FORM INPUTS ---- */
.input-field {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.input-field::placeholder { color: var(--text-tertiary); }
.input-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.4;
}

.badge-success { background: rgba(52, 211, 153, 0.12); color: var(--color-success); }
.badge-warning { background: rgba(251, 191, 36, 0.12); color: var(--color-warning); }
.badge-error   { background: rgba(248, 113, 113, 0.12); color: var(--color-error); }
.badge-info    { background: rgba(96, 165, 250, 0.12); color: var(--color-info); }
.badge-accent  { background: var(--accent-dim); color: var(--accent); }


/* ---- STATUS DOT ---- */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.status-dot.valid     { background: var(--color-success); box-shadow: 0 0 6px rgba(52, 211, 153, 0.4); }
.status-dot.warning   { background: var(--color-warning); box-shadow: 0 0 6px rgba(251, 191, 36, 0.4); }
.status-dot.expired   { background: var(--color-error); box-shadow: 0 0 6px rgba(248, 113, 113, 0.4); }
.status-dot.unknown   { background: var(--text-tertiary); }


/* ---- LAYOUT UTILITIES ---- */
.container {
  width: 100%;
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container-narrow {
  max-width: var(--content-default);
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }
.text-center { text-align: center; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-6);
}


/* ---- ANIMATED BACKGROUND GRID ---- */
/* Subtle perspective grid that recedes into depth — gives the landing
   page a cinematic "control room" feel without being overwhelming. */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-grid::before {
  content: '';
  position: absolute;
  inset: -50%;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  transform: perspective(500px) rotateX(60deg);
  transform-origin: center center;
  mask-image: radial-gradient(ellipse 80% 50% at 50% 0%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 80% 50% at 50% 0%, black 20%, transparent 70%);
}

/* Accent glow orb — positioned top-center, very subtle */
.bg-grid::after {
  content: '';
  position: absolute;
  top: -10%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: radial-gradient(ellipse, rgba(0, 212, 255, 0.04) 0%, transparent 70%);
}


/* ---- SCROLL REVEAL ---- */
/* Opacity-only to avoid CLS. Uses CSS scroll-driven animation
   where supported, falls back to visible by default. */
.reveal {
  opacity: 1;
}

@supports (animation-timeline: scroll()) {
  .reveal {
    opacity: 0;
    animation: reveal-fade linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 80%;
  }
}

@keyframes reveal-fade {
  to { opacity: 1; }
}


/* ---- SKELETON LOADERS ---- */
/* Skeleton shapes mirror real component geometry. The shimmer
   travels left-to-right at a calm 1.5s cadence — fast enough
   to signal life, slow enough to avoid anxiety. */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text   { height: 1em; margin-bottom: var(--space-2); border-radius: var(--radius-sm); }
.skeleton-text:last-child { width: 60%; }
.skeleton-heading { height: 1.5em; width: 40%; margin-bottom: var(--space-4); }
.skeleton-kpi    { height: 2.4em; width: 70%; margin-bottom: var(--space-2); }
.skeleton-badge  { height: 1.4em; width: 5em; border-radius: var(--radius-full); }
.skeleton-row    { height: 3rem; margin-bottom: var(--space-1); }


/* ---- PAGE TRANSITION ---- */
/* The #app container fades + slides on route change.
   Exit: fast ease-in fade out. Enter: ease-out fade in.
   translateY kept very small (8px) for subtlety — enough
   to feel directional, not enough to shift layout. */
#app {
  /* Ensures page transitions don't leak */
  will-change: opacity, transform;
}

.page-exit {
  animation: pageOut var(--page-exit-duration) var(--ease-in) both;
}

.page-enter {
  animation: pageIn var(--page-enter-duration) var(--ease-out) both;
}

@keyframes pageOut {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ---- STAGGER ENTRANCE SYSTEM ---- */
/* Elements with .stagger-item start invisible and slide up
   into place. The motion controller in motion.js applies
   progressive animation-delay based on data-stagger-index
   or DOM order. */
.stagger-item {
  opacity: 0;
  transform: translateY(12px);
}

.stagger-item.stagger-visible {
  animation: staggerIn 500ms var(--ease-out) both;
}

@keyframes staggerIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ---- CARD LIFT ON HOVER ---- */
/* Applied to interactive glass panels. The lift is subtle
   (3px) with a shadow bloom — feels physical without
   being cartoonish. Border brightens to reinforce depth. */
.card-lift {
  transition: transform var(--transition-fast),
              box-shadow var(--transition-fast),
              border-color var(--transition-fast);
}

.card-lift:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), var(--shadow-glow);
  border-color: rgba(255, 255, 255, 0.10);
}

.card-lift:active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}


/* ---- HEALTH STATUS PULSE & GLOW ---- */
/* Warning: gentle rhythmic pulse to draw attention.
   Critical/expired: more urgent pulse + animated glow ring.
   These are restrained — no red flashing, just luminosity shifts. */
@keyframes pulseWarning {
  0%, 100% { box-shadow: 0 0 6px rgba(251, 191, 36, 0.4); }
  50%      { box-shadow: 0 0 12px rgba(251, 191, 36, 0.6); }
}

@keyframes pulseCritical {
  0%, 100% { box-shadow: 0 0 6px rgba(248, 113, 113, 0.4); }
  50%      { box-shadow: 0 0 14px rgba(248, 113, 113, 0.7); }
}

@keyframes glowCritical {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.15); }
  50%      { box-shadow: 0 0 0 6px rgba(248, 113, 113, 0.08); }
}

.pulse-warning {
  animation: pulseWarning 2.5s ease-in-out infinite;
}

.pulse-critical {
  animation: pulseCritical 2s ease-in-out infinite;
}

/* Animated glow ring around critical status badges */
.glow-critical {
  position: relative;
}
.glow-critical::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  animation: glowCritical 2s ease-in-out infinite;
  pointer-events: none;
}


/* ---- ANIMATED COUNTER ---- */
/* Counters use CSS @property for number interpolation.
   The JS motion controller drives the value; CSS handles
   the smooth transition. */
@property --counter-value {
  syntax: '<integer>';
  initial-value: 0;
  inherits: false;
}

.counter-animate {
  --counter-value: 0;
  transition: --counter-value var(--counter-duration) var(--ease-out);
  counter-reset: num var(--counter-value);
  /* Display uses content for pseudo-element approach,
     but we drive values via JS textContent for flexibility */
}


/* ---- INTERACTIVE BACKGROUND TEXTURE ---- */
/* Subtle noise grain overlaid on the deep background. Adds
   tactile depth to the dark surfaces without being distracting.
   Very low opacity — visible on large panels, invisible on text. */
.bg-noise {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.025;
  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)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px;
}


/* ---- DIVIDER ---- */
.divider {
  width: 100%;
  height: 1px;
  background: var(--border-subtle);
}


/* ---- MONO TEXT ---- */
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}


/* ---- PAGE SECTIONS ---- */
.section {
  padding: clamp(var(--space-12), 8vw, var(--space-24)) 0;
}

.section-tight {
  padding: clamp(var(--space-8), 5vw, var(--space-16)) 0;
}
