/* Material Design 3 – Core tokens and responsive safeguards */

:root {
  /* Typography scale */
  --text-display-large: clamp(3.5rem, 8vw, 4.5rem);
  --text-display-medium: clamp(2.8rem, 6.5vw, 3.6rem);
  --text-display-small: clamp(2.25rem, 5.5vw, 2.8rem);

  --text-headline-large: clamp(2rem, 4.5vw, 2.5rem);
  --text-headline-medium: clamp(1.75rem, 4vw, 2.2rem);
  --text-headline-small: clamp(1.5rem, 3.5vw, 1.9rem);

  --text-title-large: clamp(1.375rem, 3vw, 1.5rem);
  --text-title-medium: clamp(1rem, 2.5vw, 1.125rem);
  --text-title-small: clamp(0.875rem, 2vw, 1rem);

  --text-body-large: clamp(1rem, 2.5vw, 1.125rem);
  --text-body-medium: clamp(0.875rem, 2vw, 1rem);
  --text-body-small: clamp(0.75rem, 1.8vw, 0.875rem);

  --text-label-large: clamp(0.875rem, 2vw, 1rem);
  --text-label-medium: clamp(0.75rem, 1.8vw, 0.875rem);
  --text-label-small: clamp(0.6875rem, 1.5vw, 0.75rem);

  /* Spacing (8dp grid) */
  --spacing-4:  clamp(0.25rem, 0.5vw, 0.5rem);
  --spacing-8:  clamp(0.5rem, 1vw, 0.75rem);
  --spacing-12: clamp(0.75rem, 1.5vw, 1rem);
  --spacing-16: clamp(1rem, 2vw, 1.25rem);
  --spacing-20: clamp(1.25rem, 2.5vw, 1.5rem);
  --spacing-24: clamp(1.5rem, 3vw, 2rem);
  --spacing-32: clamp(2rem, 4vw, 2.5rem);
  --spacing-40: clamp(2.5rem, 5vw, 3rem);
  --spacing-48: clamp(3rem, 6vw, 4rem);
  --spacing-64: clamp(4rem, 8vw, 5rem);

  /* Elevation */
  --elevation-0: none;
  --elevation-1: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15);
  --elevation-2: 0 1px 2px rgba(0,0,0,0.3), 0 2px 6px 2px rgba(0,0,0,0.15);
  --elevation-3: 0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.3);
  --elevation-4: 0 6px 10px 4px rgba(0,0,0,0.15), 0 2px 3px rgba(0,0,0,0.3);
  --elevation-5: 0 8px 12px 6px rgba(0,0,0,0.15), 0 4px 4px rgba(0,0,0,0.3);

  /* Motion */
  --motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
  --motion-duration-short2: 100ms;
  --motion-duration-medium2: 300ms;
}

/* Global rendering & viewport friendliness */
html { text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
body { 
  text-rendering: optimizeLegibility; 
  -webkit-font-smoothing: antialiased; 
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent text overflow across components */
h1, h2, h3, h4, h5, h6, p,
.display-*, .headline-*, .title-*, .body-*, .label-*,
.question-text, .option-text, .card-title, .card-text {
  overflow-wrap: anywhere; /* breaks very long tokens */
  word-break: break-word;  /* legacy fallback */
  hyphens: auto;           /* natural hyphenation where available */
  text-wrap: balance;      /* modern browsers: nicer headings */
}

/* Media content should not overflow cards */
img, video, svg, canvas { max-width: 100%; height: auto; }

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
