/* ==============================================================================
   InterviewPal - Levels-Style Design Tokens
   LinkedIn-inspired light theme layered over Pico.css
   Mobile-first, performance-optimized, YAML audit compliant
   ============================================================================== */

/* Pico.css Integration & Override Layer */
:root {
  /* LinkedIn-Style Color Palette (YAML: design_tokens.colors) */
  --ip-bg: #ffffff;
  --ip-bg-alt: #F8FAFC;
  --ip-card: #ffffff;
  --ip-border: #E5E7EB;
  --ip-text: #0B1220;
  --ip-muted: #667085;
  --ip-accent: #0A66C2;     /* LinkedIn blue primary */
  --ip-accent-600: #095CAD; /* hover */
  --ip-accent-700: #084F94; /* active */
  --ip-accent-alt: #2E7D32; /* success green */
  --ip-warn: #F59E0B;
  --ip-danger: #DC2626;

  /* Accent Scale for Visual Hierarchy */
  --ip-accent-50: #F0F7FF;
  --ip-accent-100: #E7F0FA;
  --ip-accent-200: #CFE3F7;

  /* Warning & Status Colors */
  --ip-warning-50: #FFF8E6;
  --ip-warning-200: #FBECC8;
  --ip-warning-600: #8A5A00;

  /* Typography Stack (YAML: AF4 system fonts) */
  --ip-font-stack: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Ubuntu,"Helvetica Neue",Arial,"Noto Sans",sans-serif;

  /* Spacing Scale (YAML: design_tokens.spacing_scale_px) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 72px;

  /* Border Radius (YAML: design_tokens.radii_px) */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Shadows (YAML: design_tokens.shadows) */
  --shadow-1: 0 1px 2px rgba(16,24,40,.06);
  --shadow-2: 0 8px 40px rgba(16,24,40,.12);

  /* Layout & Container */
  --container-max: 1280px;

  /* Pico.css Custom Properties Override */
  --pico-font-family: var(--ip-font-stack);
  --pico-background-color: var(--ip-bg);
  --pico-color: var(--ip-text);
  --pico-primary: var(--ip-accent);
  --pico-muted-color: var(--ip-muted);
  --pico-border-color: var(--ip-border);
  --pico-form-element-spacing-vertical: .75rem;
  --pico-spacing: 1rem;
  --pico-border-radius: var(--radius-sm);
  --pico-box-shadow: var(--shadow-1);
}

/* Legacy Variable Support (preserve existing functionality) */
:root {
  --bg: var(--ip-bg);
  --bg-alt: var(--ip-bg-alt);
  --card: var(--ip-card);
  --border: var(--ip-border);
  --text: var(--ip-text);
  --muted: var(--ip-muted);
  --accent: var(--ip-accent);
  --accent-alt: var(--ip-accent-alt);
  --accent-50: var(--ip-accent-50);
  --accent-100: var(--ip-accent-100);
  --accent-200: var(--ip-accent-200);
  --accent-600: var(--ip-accent-600);
  --accent-700: var(--ip-accent-700);
  --warning-50: var(--ip-warning-50);
  --warning-200: var(--ip-warning-200);
  --warning-600: var(--ip-warning-600);
  --font-stack: var(--ip-font-stack);
}

/* Dark Theme Support (preserve existing) */
:root[data-theme="dark_levels"] {
  --ip-bg: #0b0b0c;
  --ip-bg-alt: #111214;
  --ip-text: #e9eaec;
  --ip-muted: #a3a7ad;
  --ip-card: #15161a;
  --ip-border: #23252a;
  --ip-accent: #5b8cff;
  --ip-accent-alt: #36d399;
  
  /* Update legacy vars */
  --bg: var(--ip-bg);
  --bg-alt: var(--ip-bg-alt);
  --text: var(--ip-text);
  --muted: var(--ip-muted);
  --card: var(--ip-card);
  --border: var(--ip-border);
  --accent: var(--ip-accent);
  --accent-alt: var(--ip-accent-alt);
}

/* ==============================================================================
   Base Styles & Mobile-First Foundations
   ============================================================================== */

/* Global Performance & Accessibility (YAML: PF2, AX1-3) */
html {
  scroll-behavior: smooth;
  font-size: 16px; /* Explicit base for rem calculations */
}

/* Mobile-First Global Fixes */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  max-width: 100%;
  overflow-x: hidden; /* YAML: mobile-first no horizontal scroll */
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--ip-bg);
  color: var(--ip-text);
  font-family: var(--ip-font-stack);
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

/* Responsive Media (YAML: PF5 image optimization) */
img, video, svg, canvas, iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Text Wrapping for Mobile */
:where(p, h1, h2, h3, h4, h5, h6, li, code, pre) {
  overflow-wrap: anywhere;
}

/* ==============================================================================
   Levels-Style Layout System (Mobile-First)
   ============================================================================== */

/* Fluid Container System (YAML: layout requirements) */
.maxw {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--pico-spacing);
}

.fullbleed {
  padding-inline: 0;
}

/* Responsive Grid System (Mobile-First) */
.grid {
  display: grid;
  gap: clamp(16px, 2vw, 24px);
}

.grid-2 {
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.grid-12 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

@media (min-width: 900px) {
  .grid-12 {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }
}

.span-12 { grid-column: span 12; }
@media (min-width: 900px) {
  .md-span-6 { grid-column: span 6; }
  .xl-span-8 { grid-column: span 8; }
  .xl-span-4 { grid-column: span 4; }
}

/* Content Width Control */
.measure {
  max-width: 70ch;
}

/* Hide/Show Utilities */
.hide-xs {
  display: none;
}

@media (min-width: 768px) {
  .hide-xs {
    display: block;
  }
}

/* ==============================================================================
   Typography Scale (Levels-Style)
   ============================================================================== */

h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.2;
  margin-bottom: 12px;
  font-weight: 700;
}

h2 {
  font-size: clamp(22px, 2.8vw, 28px);
  line-height: 1.3;
  font-weight: 600;
}

h3 {
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 1.4;
  font-weight: 600;
}

/* ==============================================================================
   Button System (YAML: AF1, AX2 - 44x44px targets, focus states)
   ============================================================================== */

.btn,
button,
[role="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px; /* YAML: AX2 accessibility requirement */
  min-width: 44px;
  padding: .625rem 1rem;
  font-family: var(--ip-font-stack);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

/* Primary Button (YAML: AF1 single decisive CTA) */
.btn-primary {
  background: var(--ip-accent);
  color: #fff;
  border-color: var(--ip-accent);
}

.btn-primary:hover {
  background: var(--ip-accent-600);
  border-color: var(--ip-accent-600);
  filter: brightness(0.95);
  transform: translateY(-1px);
}

.btn-primary:active {
  background: var(--ip-accent-700);
  border-color: var(--ip-accent-700);
  transform: translateY(0);
}

/* Secondary Button */
.btn-secondary {
  background: #fff;
  color: var(--ip-text);
  border-color: var(--ip-border);
}

.btn-secondary:hover {
  background: var(--ip-bg-alt);
  border-color: var(--ip-accent);
}

/* Text Link Button (YAML: AF5 secondary as text link) */
.btn-link {
  background: transparent;
  color: var(--ip-accent);
  border: none;
  text-decoration: underline;
  padding: .5rem;
}

.btn-link:hover {
  color: var(--ip-accent-600);
  text-decoration: none;
}

/* Focus States (YAML: AX1 visible focus) */
.btn:focus-visible,
.link:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--ip-accent);
  outline-offset: 2px;
}

/* Mobile Button Adjustments */
@media (max-width: 480px) {
  .btn,
  a[role="button"] {
    white-space: normal;
    padding: 10px 12px;
    max-width: 100%;
  }
}

/* ==============================================================================
   Card System
   ============================================================================== */

.card {
  background: var(--ip-card);
  border: 1px solid var(--ip-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  padding: clamp(16px, 2.2vw, 24px);
}

.card.highlight {
  border-width: 2px;
  border-color: var(--ip-accent);
}

/* ==============================================================================
   Form Elements (Mobile-First)
   ============================================================================== */

input,
textarea,
select {
  font-family: var(--ip-font-stack);
  font-size: 14px;
  padding: var(--space-3);
  border: 1px solid var(--ip-border);
  border-radius: var(--radius-sm);
  background: var(--ip-bg);
  color: var(--ip-text);
  width: 100%;
  max-width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--ip-accent);
  box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.1);
}

/* ==============================================================================
   Navigation System (YAML: IA1 ≤5 items)
   ============================================================================== */

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--ip-border);
}

nav ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
  gap: var(--space-4);
}

nav a {
  color: var(--ip-text);
  text-decoration: none;
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

nav a:hover {
  background: var(--ip-bg-alt);
  color: var(--ip-accent);
}

.nav-brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--ip-text) !important;
}

/* Responsive Navigation */
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

@media (max-width: 480px) {
  .header-cta {
    display: block;
    width: 100%;
    text-align: center;
  }
}

/* ==============================================================================
   Hero Section (YAML: AF1-5)
   ============================================================================== */

.hero {
  text-align: center;
  padding: var(--space-8) 0;
}

.hero h1 {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 var(--space-4) 0;
  color: var(--ip-text);
}

.hero p {
  font-size: 18px;
  color: var(--ip-muted);
  margin: 0 0 var(--space-6) 0;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ==============================================================================
   Sections & Components
   ============================================================================== */

.section {
  background: var(--ip-card);
  border: 1px solid var(--ip-border);
  border-radius: var(--radius-md);
}

.section + .section {
  margin-top: var(--space-5);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5) var(--space-3);
  border-bottom: 1px solid var(--ip-border);
}

.section-title {
  font-weight: 800;
  font-size: clamp(1.05rem, 1vw + 1rem, 1.2rem);
}

.section-sub {
  color: var(--ip-muted);
  font-size: .95rem;
}

.section-body {
  padding: var(--space-5);
}

.section-accent {
  border-left: 3px solid var(--ip-accent);
}

.compact-stack > * + * {
  margin-top: var(--space-3);
}

/* Page Hero */
.page-hero {
  padding: clamp(12px, 2.5vw, 24px);
  margin: 0 0 var(--space-6);
  border: 1px solid var(--ip-border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--ip-accent) 5%, var(--ip-card));
}

.page-hero .h1 {
  margin: 0 0 var(--space-2);
}

.page-hero .lead {
  margin: 0;
  color: var(--ip-muted);
}

/* ==============================================================================
   Utility Classes
   ============================================================================== */

.text-center { text-align: center; }
.muted { color: var(--ip-muted); }
.w-100 { width: 100%; }

/* Link Styles */
.link {
  color: var(--ip-accent);
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

/* Badge Component */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #EEF2FF;
  color: #1D4ED8;
  border: 1px solid #E0E7FF;
  font-size: 12px;
  font-weight: 500;
}

.badge.success {
  background: #ECFDF5;
  color: #065F46;
  border-color: #A7F3D0;
}

/* Divider */
.hr {
  border: 0;
  border-top: 1px solid var(--ip-border);
  margin: var(--space-6) 0;
}

/* ==============================================================================
   Mobile-First Responsive Fixes
   ============================================================================== */

/* Table Responsive */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap > table {
  width: 100%;
}

/* Common Overflow Prevention */
.flex-item,
.card,
.tag,
.chip {
  min-width: 0;
}

/* Safety for 3rd-party content */
:where([style*="width:"]) {
  max-width: 100% !important;
}

/* ==============================================================================
   Skip Link for Accessibility (YAML: AX1)
   ============================================================================== */

.visually-hidden-focusable {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.visually-hidden-focusable:focus {
  position: fixed !important;
  top: var(--space-4) !important;
  left: var(--space-4) !important;
  width: auto !important;
  height: auto !important;
  padding: var(--space-2) var(--space-3) !important;
  margin: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
  background: var(--ip-card) !important;
  color: var(--ip-text) !important;
  border: 1px solid var(--ip-border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-2) !important;
  z-index: 100000 !important;
  text-decoration: none !important;
  font-size: 14px !important;
}

/* ==============================================================================
   Choice Card Component (preserve existing functionality)
   ============================================================================== */

.choice-set {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 900px) {
  .choice-set {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.choice-card {
  display: grid;
  align-items: start;
  gap: var(--space-2);
  padding: var(--space-5);
  border: 1px solid var(--ip-border);
  border-radius: var(--radius-md);
  background: var(--ip-card);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.choice-card > input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.choice-title {
  font-weight: 700;
}

.choice-desc {
  color: var(--ip-muted);
  font-size: .95rem;
}

.choice-card:hover {
  border-color: var(--ip-accent);
}

.choice-card:focus-within {
  outline: none;
  box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.1);
}

.choice-card:has(input[type="radio"]:checked) {
  border-color: var(--ip-accent);
  background: color-mix(in srgb, var(--ip-accent) 6%, var(--ip-card));
  box-shadow: var(--shadow-2);
}

.choice-card:has(input[type="radio"]:focus-visible) {
  box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.1);
}

.choice-card {
  min-width: 0;
  width: 100%;
}

.choice-title,
.choice-desc {
  overflow-wrap: anywhere;
}

/* ==============================================================================
   Sticky Actions (Mobile UX Enhancement)
   ============================================================================== */

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--ip-bg-alt) 80%, #fff);
  border-top: 1px solid var(--ip-border);
  padding: var(--space-4) var(--space-5);
  backdrop-filter: blur(6px);
}

/* ==============================================================================
   Features Grid & Components
   ============================================================================== */

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-5);
  padding: var(--space-8) 0;
}

.feature {
  text-align: center;
  padding: var(--space-5);
}

.feature h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 var(--space-3) 0;
  color: var(--ip-text);
}

.feature p {
  color: var(--ip-muted);
  margin: 0;
  line-height: 1.6;
}

/* ==============================================================================
   FAQ Accordion (Native Details/Summary)
   ============================================================================== */

details {
  border: 1px solid var(--ip-border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

summary {
  padding: var(--space-4);
  cursor: pointer;
  font-weight: 600;
  background: var(--ip-bg-alt);
  border-radius: var(--radius-sm);
  user-select: none;
}

summary:hover {
  background: var(--ip-border);
}

details[open] summary {
  border-bottom: 1px solid var(--ip-border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

details div {
  padding: var(--space-4);
  color: var(--ip-muted);
  line-height: 1.6;
}

/* ==============================================================================
   Pricing Toggle Component
   ============================================================================== */

.pricing-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 24px;
  background: var(--ip-border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle-switch.active {
  background: var(--ip-accent);
}

.toggle-switch::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle-switch.active::before {
  transform: translateX(24px);
}