/* ===================================================
   LinguaQuest — Global CSS
   Reset, variables, typography, layout utilities
   =================================================== */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=DM+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- CSS Variables (Design System) --- */
:root {
  /* Brand Core */
  --brand-primary: #1B4965;
  --brand-secondary: #62B6CB;
  --brand-accent: #F4A261;
  --brand-surface: #F8F5EF;
  --brand-dark: #0D2535;
  --brand-muted: #6B7B8D;
  --brand-light: #FFFFFF;

  /* Semantic */
  --success: #2D6A4F;
  --success-bg: #D8F3DC;
  --error: #C1121F;
  --error-bg: #FFE5E5;
  --warning: #E76F51;
  --warning-bg: #FFF0E6;
  --info: #1B4965;
  --info-bg: #E8F4FD;

  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Spacing */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 32px;

  /* Shadows */
  --shadow-card: 0 2px 20px rgba(27, 73, 101, 0.08);
  --shadow-hover: 0 8px 40px rgba(27, 73, 101, 0.16);
  --shadow-modal: 0 24px 80px rgba(13, 37, 53, 0.24);

  /* Layout */
  --max-width: 1280px;
  --nav-height: 64px;
  --section-padding: 80px 24px;
  --content-padding: 0 24px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 300ms ease;
  --transition-slow: 500ms ease;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--brand-dark);
  background-color: var(--brand-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* --- Background Pattern --- */
body.has-pattern {
  position: relative;
}

body.has-pattern::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%231B4965' fill-opacity='0.04'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  line-height: 1.2;
  color: var(--brand-dark);
  font-weight: 600;
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
h4 { font-size: 1.25rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
  margin-bottom: 1rem;
  color: var(--brand-muted);
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--brand-secondary);
}

strong { font-weight: 600; }
small { font-size: 0.875rem; }

/* --- Text Utilities --- */
.text-display { font-family: var(--font-display); font-size: clamp(2rem, 5vw, 3.5rem); }
.text-heading { font-family: var(--font-display); }
.text-body { font-family: var(--font-body); }
.text-caption { font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; }
.text-muted { color: var(--brand-muted); }
.text-accent { color: var(--brand-accent); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* --- Layout Utilities --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--content-padding);
}

.section {
  padding: var(--section-padding);
  position: relative;
  z-index: 1;
}

.section-sm { padding: 40px 24px; }
.section-lg { padding: 120px 24px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.gap-xl { gap: 40px; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.w-full { width: 100%; }
.h-full { height: 100%; }

/* --- Spacing --- */
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 32px; }
.mt-xl { margin-top: 48px; }
.mt-2xl { margin-top: 64px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 32px; }
.mb-xl { margin-bottom: 48px; }
.pt-sm { padding-top: 8px; }
.pt-md { padding-top: 16px; }
.pt-lg { padding-top: 32px; }
.pt-xl { padding-top: 64px; }
.pb-sm { padding-bottom: 8px; }
.pb-md { padding-bottom: 16px; }
.pb-lg { padding-bottom: 32px; }
.pb-xl { padding-bottom: 64px; }

/* --- Visual Utilities --- */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: 9999px; }
.shadow-card { box-shadow: var(--shadow-card); }
.shadow-hover { box-shadow: var(--shadow-hover); }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.absolute { position: absolute; }
.z-1 { z-index: 1; }
.z-10 { z-index: 10; }
.cursor-pointer { cursor: pointer; }
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-100 { opacity: 1; }

/* --- Skip Link (Accessibility) --- */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--brand-primary);
  color: var(--brand-light);
  padding: 8px 16px;
  z-index: 9999;
  transition: top var(--transition-fast);
  font-weight: 500;
}

.skip-link:focus {
  top: 0;
  color: var(--brand-light);
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--brand-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--brand-muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--brand-primary);
}

/* --- Selection --- */
::selection {
  background: var(--brand-secondary);
  color: var(--brand-dark);
}

/* --- Focus Styles --- */
:focus-visible {
  outline: 2px solid var(--brand-secondary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* --- Screen Reader Only --- */
.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;
}

/* --- Responsive Breakpoints --- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .hide-lg { display: none; }
}

@media (max-width: 768px) {
  :root {
    --section-padding: 60px 16px;
    --content-padding: 0 16px;
  }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
  .hide-md { display: none; }
  .text-center-md { text-align: center; }
}

@media (max-width: 480px) {
  :root {
    --section-padding: 40px 12px;
    --content-padding: 0 12px;
  }

  .grid-4 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: 1fr 1fr; gap: 12px; }
  .hide-sm { display: none; }
  .text-center-sm { text-align: center; }
}

/* --- Reduced Motion --- */
@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;
  }
}