/* ==========================================================================
   main.css - Design tokens, typography, layout shell
   Design system: design-system/quizora/MASTER.md
   (UI/UX Pro Max — "Online Course/E-learning", Minimalism, progress teal +
   achievement orange, Plus Jakarta Sans, density 6/10, motion 3/10)
   ========================================================================== */

:root {
  /* Brand */
  --primary: #0F766E;            /* teal-700: 5.47:1 with white text */
  --primary-hover: #115E59;      /* teal-800 */
  --primary-bright: #0D9488;     /* skill primary: graphics & large fills only (3.7:1 with white) */
  --primary-soft: #F0FDFA;
  --primary-tint: #CCFBF1;
  --primary-border: #99F6E4;
  --primary-glow: rgba(15, 118, 110, 0.16);

  --accent: #EA580C;             /* achievement orange: graphics, or with dark text */
  --accent-text: #C2410C;        /* orange text on white: 5.18:1 */
  --accent-soft: #FFF7ED;
  --accent-strong: #9A3412;      /* on --accent-soft: 6.88:1 */

  /* Surfaces */
  --bg-primary: #F0FDFA;         /* page background */
  --bg-card: #FFFFFF;
  --bg-card-hover: #F7FBFA;
  --bg-input: #FFFFFF;
  --bg-muted: #EEF4F3;
  --bg-glass: #F3F7F6;           /* subtle inset panels */

  /* Lines */
  --border-color: #D5E3E0;       /* decorative dividers & card edges */
  --border-hover: #A9C2BE;
  --border-input: #7B8C98;       /* form controls: 3.47:1 non-text contrast */
  --border-focus: #0F766E;

  /* Text (all >= 4.5:1 on white and on the page background) */
  --text-primary: #134E4A;
  --text-secondary: #475569;
  --text-muted: #5B6B79;
  --text-inverse: #FFFFFF;

  /* Status */
  --success: #15803D;
  --success-bg: #F0FDF4;
  --success-border: #BBF7D0;
  --warning: #A16207;
  --warning-bg: #FEFCE8;
  --warning-border: #FDE68A;
  --danger: #B91C1C;
  --danger-bg: #FEF2F2;
  --danger-border: #FECACA;
  --info: #0F766E;
  --info-bg: #F0FDFA;
  --info-border: #99F6E4;

  /* Legacy aliases (solid fills — Minimalism uses no gradients) */
  --accent-gradient: var(--primary);
  --accent-gradient-hover: var(--primary-hover);

  /* Elevation (skill shadow tiers; Minimalism prefers borders, shadows sparingly) */
  --shadow-sm: 0 1px 2px rgba(19, 78, 74, 0.06);
  --shadow-md: 0 4px 6px rgba(19, 78, 74, 0.08);
  --shadow-lg: 0 10px 15px rgba(19, 78, 74, 0.10);
  --shadow-xl: 0 20px 25px rgba(19, 78, 74, 0.15);
  --shadow-glow: 0 0 0 4px var(--primary-glow);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Spacing (density 6/10) */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Typography */
  --font-heading: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Motion (subtle: 150–250ms, exits faster than entrances) */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-bounce: 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);

  --nav-height: 64px;
}

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

html {
  font-size: 16px;
  height: 100%;
  scroll-behavior: smooth;
  /* keep focused elements clear of the sticky header (WCAG 2.2 focus-not-obscured) */
  scroll-padding-top: calc(var(--nav-height) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 { font-size: 2.1rem; font-weight: 800; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p {
  color: var(--text-secondary);
  text-wrap: pretty;
}

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

a:hover { color: var(--primary-hover); }

a, button, [role="button"], [role="radio"], summary, label[for], select {
  touch-action: manipulation;
}

button, [role="button"], [role="radio"], summary, select {
  cursor: pointer;
}

img, svg { max-width: 100%; }

/* Numbers line up in tables and stats */
.stat-value, .mini-stat-value, .data-table, .matrix-table, .score-main-number, #timer-countdown {
  font-variant-numeric: tabular-nums;
}

/* Skip link (keyboard users jump past the navigation) */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 3000;
  background: var(--primary);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 700;
}

.skip-link:focus { top: 0.75rem; color: #fff; }

/* App Container */
.app-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

main.main-content {
  flex: 1;
  padding: var(--space-xl) 0 var(--space-3xl);
}

main.main-content:focus { outline: none; }

/* Navbar */
.app-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--border-color);
  min-height: var(--nav-height);
  display: flex;
  align-items: center;
  padding: 0.5rem 0;
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  min-height: 44px;
}

.navbar-brand:hover { color: var(--text-primary); }

/* Quizora logo: assets/brand/quizora-logo.svg (wordmark) and quizora-mark.svg (Q icon) */
.brand-logo {
  display: block;
  height: 34px;
  width: auto;
  aspect-ratio: 1461 / 335;
}

.brand-mark {
  display: block;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.925rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-muted);
}

.nav-link.active {
  color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 -2px 0 var(--primary);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-left: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.3rem 0.8rem 0.3rem 0.35rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--primary-tint);
  color: var(--primary-hover);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  padding: 1.25rem 0;
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.footer-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* Focus: visible 2px ring with offset on every interactive element */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

/* Gentle entrance for page content (disabled under reduced motion) */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

main.main-content > .app-container {
  animation: fadeIn 0.25s ease-out both;
}

/* Responsive */
@media (max-width: 768px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.15rem; }

  .app-container { padding: 0 1rem; }
  main.main-content { padding: var(--space-lg) 0 var(--space-2xl); }

  .navbar-inner {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .navbar-nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
  }

  .navbar-nav::-webkit-scrollbar { display: none; }
  .nav-link { flex-shrink: 0; }
  .user-pill { margin-left: auto; flex-shrink: 0; }
}

/* Respect the user's motion preference */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
