/*
 * base.css
 * Global element defaults and typography baseline.
 *
 * Applies sensible defaults to bare HTML elements using the design tokens
 * defined in variables.css. No class names are introduced here — those
 * live in style.css. This file should be stable across prompts.
 */


/* ==========================================================================
   ROOT / HTML
========================================================================== */

/* ==========================================================================
   REDUCED MOTION
   Disables all animations and transitions for users who have this
   accessibility setting enabled. Must be declared before everything else.
========================================================================== */

@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;
  }
}


html {
  /* Smooth scrolling for anchor links */
  scroll-behavior: smooth;

  /* Prevent font size inflation on orientation change in iOS */
  -webkit-text-size-adjust: 100%;

  /* Base font size (1rem = 16px) */
  font-size: 16px;
}


/* ==========================================================================
   BODY
========================================================================== */

body {
  font-family: var(--font-family-sans);
  font-size:   var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-base);
  color:       var(--color-text);
  background-color: var(--color-background);

  /* Prevent horizontal overflow from rogue content */
  overflow-x: hidden;
}


/* ==========================================================================
   HEADINGS
========================================================================== */

h1, h2, h3, h4, h5, h6 {
  line-height: var(--lh-tight);
  font-weight: var(--fw-bold);
  color:       var(--color-text);
}

h1 { font-size: var(--fs-5xl); }
h2 { font-size: var(--fs-4xl); }
h3 { font-size: var(--fs-3xl); }
h4 { font-size: var(--fs-2xl); }
h5 { font-size: var(--fs-xl);  }
h6 { font-size: var(--fs-lg);  }

/* Slightly smaller headings on mobile (mobile-first) */
@media (max-width: 639px) {
  h1 { font-size: var(--fs-4xl); }
  h2 { font-size: var(--fs-3xl); }
  h3 { font-size: var(--fs-2xl); }
}


/* ==========================================================================
   PARAGRAPH & INLINE TEXT
========================================================================== */

p {
  line-height: var(--lh-relaxed);
  max-width: 70ch; /* Comfortable reading width */
}

strong {
  font-weight: var(--fw-semibold);
}

em {
  font-style: italic;
}

small {
  font-size: var(--fs-sm);
}


/* ==========================================================================
   LINKS
========================================================================== */

a {
  color: var(--color-primary);
  transition: color var(--transition-fast), opacity var(--transition-fast);
}

a:hover:not(.btn) {
  color: var(--color-primary-dark);
}

/* Clean, visible focus ring for keyboard navigation */
a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}


/* ==========================================================================
   FOCUS VISIBLE
   Applied globally to all interactive elements.
   Uses :focus-visible to avoid showing rings on mouse click.
========================================================================== */

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Remove the default focus ring from elements that use :focus-visible */
:focus:not(:focus-visible) {
  outline: none;
}


/* ==========================================================================
   TEXT SELECTION
   Applies the brand primary colour at low opacity as the selection highlight.
========================================================================== */

::selection {
  background-color: rgba(168, 50, 125, 0.15); /* --color-primary at 15% */
  color: var(--color-text);
}

::-moz-selection {
  background-color: rgba(168, 50, 125, 0.15);
  color: var(--color-text);
}


/* ==========================================================================
   LISTS
========================================================================== */

ul, ol {
  padding-left: var(--space-6);
}

li {
  margin-bottom: var(--space-1);
}


/* ==========================================================================
   IMAGES
========================================================================== */

img {
  height: auto;
  border-style: none;
}


/* ==========================================================================
   HORIZONTAL RULE
========================================================================== */

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-8) 0;
}


/* ==========================================================================
   FORMS — baseline (full styling in style.css)
========================================================================== */

input,
textarea,
select {
  font-family: var(--font-family-sans);
  color: var(--color-text);
  background-color: var(--color-background);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
}


/* ==========================================================================
   LAYOUT UTILITY — Container
   A single reusable container class for consistent max-width + padding.
   Mobile-first: padding increases at wider breakpoints.
========================================================================== */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-4);   /* 16px on mobile */
}

@media (min-width: 640px) {
  .container {
    padding-inline: var(--space-6); /* 24px on sm+ */
  }
}

@media (min-width: 1024px) {
  .container {
    padding-inline: var(--space-8); /* 32px on lg+ */
  }
}


/* ==========================================================================
   VISUALLY HIDDEN
   Hides content visually while keeping it accessible to screen readers.
   Use for skip links, icon labels, etc.
========================================================================== */

.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;
}


/* ==========================================================================
   SKIP TO CONTENT
   Keyboard accessibility: allows keyboard users to skip repetitive navigation.
   Hidden by default, appears on focus.
========================================================================== */

.skip-link {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  z-index: 9999;
  padding: var(--space-2) var(--space-4);
  background-color: var(--color-primary);
  color: #ffffff;
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-md);
  transform: translateY(-200%);
  transition: transform var(--transition-fast);
}

.skip-link:focus {
  transform: translateY(0);
}
