/*
 * ============================================================
 * OpseraCert — Application-Specific Styles
 * ============================================================
 * Component styles for navigation, pages, and layout regions.
 * Built on top of design-system.css tokens.
 * ============================================================
 */


/* ============================================================
 * NAVIGATION
 * ============================================================ */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: var(--space-4) 0;
  transition: background var(--transition-medium), backdrop-filter var(--transition-medium);
}

/* Nav becomes glassy on scroll — JS toggles .nav-scrolled */
.nav-scrolled {
  background: rgba(10, 11, 15, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.nav-link {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-weight: 500;
}
.nav-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.nav-link.active { color: var(--accent); }

.nav-cta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav-mobile-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-mobile-toggle { display: flex; }
  .nav-cta .btn-secondary { display: none; }
}


/* ============================================================
 * HERO — Landing Page
 * ============================================================
 * Full-viewport cinematic hero. No gradient backgrounds.
 * Uses the perspective grid + glow from design-system.css
 * as the atmospheric backdrop.
 */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: var(--space-24) var(--space-6) var(--space-16);
  position: relative;
  z-index: 1;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-4);
  background: var(--accent-dim);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  margin-bottom: var(--space-8);
  animation: fadeInDown 0.6s var(--ease-out) both;
}

.hero h1 {
  font-size: var(--text-3xl);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-6);
  max-width: 14ch;
  animation: fadeInUp 0.7s var(--ease-out) 0.1s both;
}

.hero h1 .accent-word {
  color: var(--accent);
  /* No gradient text — solid color is cleaner */
}

.hero-subtitle {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  max-width: 48ch;
  margin-bottom: var(--space-10);
  line-height: 1.6;
  animation: fadeInUp 0.7s var(--ease-out) 0.2s both;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  justify-content: center;
  animation: fadeInUp 0.7s var(--ease-out) 0.3s both;
}

/* Quick-scan domain input in the hero */
.hero-scan-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  max-width: 480px;
  margin-top: var(--space-10);
  animation: fadeInUp 0.7s var(--ease-out) 0.4s both;
}

.hero-scan-form .input-field {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  padding: var(--space-4);
}

.hero-scan-form .btn {
  flex-shrink: 0;
  padding: var(--space-4) var(--space-6);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ============================================================
 * FEATURE SHOWCASE — Landing Page
 * ============================================================
 * Asymmetric layout to avoid the generic 3-column grid.
 * One large feature callout + 2 stacked smaller ones.
 */
.features-section {
  position: relative;
  z-index: 1;
}

.features-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  grid-template-rows: auto auto;
  gap: var(--space-6);
}

/* The primary feature spans both rows */
.feature-card-hero {
  grid-row: 1 / 3;
  padding: var(--space-10);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 380px;
}

.feature-card {
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.feature-icon {
  width: 40px;
  height: 40px;
  color: var(--accent);
  opacity: 0.9;
}

.feature-card h3 {
  font-size: var(--text-lg);
  font-weight: 700;
}

.feature-card p,
.feature-card-hero p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.7;
}

@media (max-width: 768px) {
  .features-grid {
    grid-template-columns: 1fr;
  }
  .feature-card-hero {
    grid-row: auto;
    min-height: auto;
  }
}


/* ============================================================
 * STATS BAR
 * ============================================================ */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: var(--space-16);
  padding: var(--space-12) 0;
  flex-wrap: wrap;
}

.stat {
  text-align: center;
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: var(--space-1);
}


/* ============================================================
 * PRICING
 * ============================================================ */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  align-items: start;
}

.pricing-card {
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  position: relative;
}

/* The recommended plan is visually elevated */
.pricing-card.featured {
  border-color: rgba(0, 212, 255, 0.2);
  box-shadow: 0 0 40px rgba(0, 212, 255, 0.06), var(--shadow-lg);
}

.pricing-card.featured::before {
  content: 'Most Popular';
  position: absolute;
  top: calc(var(--space-4) * -1);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-1) var(--space-4);
  background: var(--accent);
  color: var(--text-inverse);
  font-size: var(--text-xs);
  font-weight: 700;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.pricing-tier {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.pricing-price {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
}

.pricing-price .amount {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
}

.pricing-price .period {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.pricing-features {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1;
}

.pricing-feature {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.pricing-feature svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

@media (max-width: 900px) {
  .pricing-grid { grid-template-columns: 1fr; max-width: 440px; margin: 0 auto; }
}


/* ============================================================
 * AUTH PAGES (Sign In / Sign Up)
 * ============================================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
  position: relative;
  z-index: 1;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: var(--space-10);
}

.auth-card h1 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.auth-card .auth-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.auth-form .form-group {
  display: flex;
  flex-direction: column;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-6) 0;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.auth-footer {
  margin-top: var(--space-8);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--accent);
  font-weight: 600;
}
.auth-footer a:hover { text-decoration: underline; }

/* Auth container — wrapper for Clerk components and fallback forms */
.auth-container {
  width: 100%;
  max-width: 440px;
}

/* ============================================================
 * CLERK COMPONENT OVERRIDES
 * ============================================================
 * Clerk's prebuilt components render in Shadow DOM with their
 * own styles. These overrides ensure the container and any
 * wrapper elements integrate seamlessly with our dark theme.
 * The deep component styling is handled via Clerk's appearance
 * API in auth.js — these rules handle the host containers.
 * ============================================================ */

/* Sign-in and sign-up component containers */
#clerk-sign-in,
#clerk-sign-up {
  width: 100%;
}

/* UserProfile component in account page */
.clerk-profile-container {
  width: 100%;
  min-height: 400px;
}

/* Ensure Clerk components don't get clipped by glass panels */
.clerk-profile-container .cl-rootBox,
.clerk-profile-container .cl-card {
  width: 100%;
}

/* Loading placeholder while Clerk mounts */
#clerk-sign-in:empty,
#clerk-sign-up:empty,
.clerk-profile-container:empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

#clerk-sign-in:empty::after,
#clerk-sign-up:empty::after,
.clerk-profile-container:empty::after {
  content: '';
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-medium);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}


/* ============================================================
 * DASHBOARD LAYOUT
 * ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-base);
  border-right: 1px solid var(--border-subtle);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
}

.app-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-6);
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
}
.sidebar-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.sidebar-link.active {
  color: var(--text-primary);
  background: rgba(0, 212, 255, 0.08);
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.sidebar-link { position: relative; }

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.app-main {
  flex: 1;
  margin-left: 260px;
  padding: var(--space-8);
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.app-header h1 {
  font-size: var(--text-xl);
  font-weight: 700;
}

@media (max-width: 900px) {
  .app-sidebar { display: none; }
  .app-main { margin-left: 0; }
}


/* ============================================================
 * DASHBOARD CARDS — KPI / Overview
 * ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.kpi-card {
  padding: var(--space-6);
}

.kpi-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: var(--space-2);
}
.kpi-delta.positive { color: var(--color-success); }
.kpi-delta.negative { color: var(--color-error); }

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
  .kpi-grid { grid-template-columns: 1fr; }
}


/* ============================================================
 * CERTIFICATE TABLE
 * ============================================================ */
.cert-table {
  width: 100%;
  border-collapse: collapse;
}

.cert-table thead th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-subtle);
}

.cert-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast),
              transform var(--transition-fast),
              box-shadow var(--transition-fast);
}
.cert-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
  transform: translateX(2px);
}

.cert-table tbody td {
  padding: var(--space-4);
  font-size: var(--text-sm);
  vertical-align: middle;
}

.cert-domain {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 600;
  color: var(--text-primary);
}


/* ============================================================
 * SCAN RESULT PAGE
 * ============================================================ */
.scan-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.scan-domain {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.scan-domain h1 {
  font-size: var(--text-xl);
  font-weight: 700;
}

.scan-meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.cert-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

.cert-detail-card {
  padding: var(--space-6);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}

.detail-row:last-child { border-bottom: none; }

.detail-label {
  color: var(--text-tertiary);
  font-weight: 500;
}

.detail-value {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
}

.chain-step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4);
  border-left: 2px solid var(--border-medium);
  margin-left: var(--space-3);
}

.chain-step:last-child {
  border-left-color: var(--accent);
}

@media (max-width: 768px) {
  .cert-detail-grid { grid-template-columns: 1fr; }
}


/* ============================================================
 * ACCOUNT PAGE
 * ============================================================ */
.account-section {
  max-width: 640px;
}

.account-section + .account-section {
  margin-top: var(--space-8);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-subtle);
}

.account-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) 0;
}

.account-field-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.account-field-value {
  font-size: var(--text-sm);
  font-weight: 600;
}


/* ============================================================
 * FOOTER
 * ============================================================ */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-12) 0 var(--space-8);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-8);
}

.footer-brand p {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  margin-top: var(--space-3);
  max-width: 28ch;
}

.footer-col h4 {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-4);
}

.footer-col a {
  display: block;
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.footer-col a:hover { color: var(--text-primary); }

.footer-bottom {
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--space-6); }
}


/* ============================================================
 * SCAN RESULT — Health Status Hero
 * ============================================================
 * Large banner card showing the overall certificate health.
 * Colour-coded background tint for instant visual clarity.
 */
.scan-status-hero {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-8);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}

/* Colour-coded background tints */
.scan-status-hero.valid-bg {
  background: linear-gradient(135deg, rgba(67, 122, 34, 0.10) 0%, rgba(67, 122, 34, 0.03) 100%);
  border-color: rgba(67, 122, 34, 0.25);
}
.scan-status-hero.warning-bg {
  background: linear-gradient(135deg, rgba(150, 66, 25, 0.12) 0%, rgba(150, 66, 25, 0.03) 100%);
  border-color: rgba(150, 66, 25, 0.3);
}
.scan-status-hero.expired-bg {
  background: linear-gradient(135deg, rgba(161, 44, 123, 0.12) 0%, rgba(161, 44, 123, 0.03) 100%);
  border-color: rgba(161, 44, 123, 0.3);
}

.scan-status-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
}

.scan-status-label {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.scan-status-days {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.scan-status-sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-top: var(--space-1);
}


/* ============================================================
 * SCAN RESULT — Card Grid & Cards
 * ============================================================ */
.scan-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.scan-card {
  padding: var(--space-6);
}

.scan-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.scan-card-header h3 {
  font-size: var(--text-lg);
  font-weight: 700;
}

.scan-card-icon {
  font-size: 1.25rem;
  line-height: 1;
}

/* Scan metadata bar — subtle row below the cards */
.scan-meta-bar {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-3) 0;
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-subtle);
}

@media (max-width: 768px) {
  .scan-cards-grid { grid-template-columns: 1fr; }
  .scan-status-hero { flex-direction: column; text-align: center; }
  .scan-header { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
  .scan-header .flex { flex-wrap: wrap; }
  .scan-domain h1 { font-size: var(--text-lg); word-break: break-all; }
  .detail-value { max-width: 55%; text-align: right; word-break: break-word; }
}


/* ============================================================
 * SCAN RESULT REVEAL ANIMATIONS
 * ============================================================
 * Scan detail cards slide in from slight offset when results
 * load. Each card in the grid staggers slightly.
 */
.scan-reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: scanRevealIn 600ms var(--ease-out) both;
}

.scan-reveal:nth-child(2) { animation-delay: 100ms; }
.scan-reveal:nth-child(3) { animation-delay: 200ms; }
.scan-reveal:nth-child(4) { animation-delay: 300ms; }
.scan-reveal:nth-child(5) { animation-delay: 400ms; }

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

/* Scan spinner — enhanced with accent glow ring */
.scan-spinner-enhanced {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-medium);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 16px rgba(0, 212, 255, 0.15);
}


/* ============================================================
 * INTERACTIVE BACKGROUND PARTICLES
 * ============================================================
 * Slow-drifting gradient orbs behind the grid. Adds a subtle
 * sense of life without competing for attention. The orbs
 * are large, blurred, and very low opacity.
 */
.bg-grid::before {
  /* Keep existing grid, add slow drift */
  animation: gridDrift 25s ease-in-out infinite alternate;
}

@keyframes gridDrift {
  0% { transform: perspective(500px) rotateX(60deg) translateZ(0); }
  100% { transform: perspective(500px) rotateX(60deg) translateZ(8px); }
}

/* Secondary floating orb — injected via bg-grid-orb in landing */
.bg-orb {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(80px);
  opacity: 0.04;
  animation: orbFloat 20s ease-in-out infinite alternate;
}

.bg-orb-1 {
  top: 20%;
  left: -5%;
  background: var(--accent);
}

.bg-orb-2 {
  bottom: 10%;
  right: -5%;
  background: var(--accent);
  animation-delay: -10s;
  animation-direction: alternate-reverse;
}

@keyframes orbFloat {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -20px) scale(1.1); }
}
