/**
 * ============================================================================
 * base.css — Reset, Typography, and Global Element Styles
 * ============================================================================
 *
 * PURPOSE:
 *   Establishes baseline styles for all HTML elements. Applies the
 *   typography system, resets browser defaults to a consistent state,
 *   and styles fundamental elements (headings, paragraphs, links, forms)
 *   without using any classes.
 *
 * ARCHITECTURE:
 *   Loaded AFTER tokens.css in the CSS order. This file sets the
 *   foundation that all BEM component styles build on top of.
 *   No classes defined here — only element selectors.
 *
 * DEPENDS ON:
 *   - tokens.css (all values reference CSS custom properties from tokens)
 *
 * ============================================================================
 */


/* ==========================================================================
 * RESET
 * ==========================================================================
 * Minimal, targeted reset. Not a full normalize — just the bits that
 * cause cross-browser inconsistencies for this type of site.
 * ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Remove default margins. Each component controls its own spacing. */
body,
h1, h2, h3, h4, h5, h6,
p,
figure,
blockquote,
dl, dd {
  margin: 0;
}

/* Remove list styles on ul, ol with a list role.
   This keeps semantic lists unstyled by default. */
ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

/* Smooth scrolling for in-page anchor links, but respect user preference */
html:focus-within {
  scroll-behavior: smooth;
}

/* Ensure images don't overflow their containers */
img,
picture,
svg {
  max-width: 100%;
  display: block;
}


/* ==========================================================================
 * BODY
 * ==========================================================================
 * Background and text from design tokens (theme-aware).
 * ========================================================================== */

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);

  /* Prevent horizontal scroll on mobile */
  overflow-x: hidden;

  /* Optimise text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}


/* ==========================================================================
 * TYPOGRAPHY — HEADINGS
 * ==========================================================================
 * Serif (Source Serif 4), navy colour — editorial, trustworthy.
 * ========================================================================== */

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

h1 {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-lg);
}

h2 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-md);
  /* Fine horizontal rule below h2s for editorial feel */
  padding-bottom: var(--space-sm);
  border-bottom: var(--border);
}

h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-sm);
}

h4 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-sm);
}


/* ==========================================================================
 * TYPOGRAPHY — BODY TEXT
 * ==========================================================================
 * Generous line height for readability. Spacing between paragraphs
 * uses margin-top to avoid collapsing margin issues.
 * ========================================================================== */

p {
  margin-bottom: var(--space-md);
}

/* Lead paragraph — slightly larger, used for intro text */
.lead {
  font-size: var(--text-md);
  line-height: var(--leading-loose);
  color: var(--color-text-light);
}

/* Small print — disclaimers, footnotes, legal */
small,
.small {
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

/* Strong — use semibold, not bold, for inline emphasis */
strong {
  font-weight: var(--weight-semibold);
}


/* ==========================================================================
 * LINKS
 * ==========================================================================
 * Accent colour (copper) for links. Underline on hover for clarity.
 * No underline by default keeps the page clean.
 * ========================================================================== */

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

a:hover,
a:focus-visible {
  color: var(--color-text);
  text-decoration: underline;
}


/* ==========================================================================
 * LISTS
 * ==========================================================================
 * Styled lists for content sections (FAQ answers, explainer text).
 * ========================================================================== */

ul, ol {
  padding-left: var(--space-lg);
  margin-bottom: var(--space-md);
}

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


/* ==========================================================================
 * HORIZONTAL RULES
 * ==========================================================================
 * Fine lines used as section dividers. The "editorial" feel relies on
 * these rather than cards or heavy borders.
 * ========================================================================== */

hr {
  border: none;
  border-top: var(--border);
  margin: var(--space-2xl) 0;
}


/* ==========================================================================
 * FORM ELEMENTS — BASE STYLES
 * ==========================================================================
 * Clean, minimal form inputs. Subtle 1px borders, slight rounding.
 * NOT pill-shaped. NOT chunky. The calculator forms build on these
 * with BEM classes, but the base styling is here.
 * ========================================================================== */

/* Inherit fonts on form elements — browsers don't do this by default */
input,
button,
textarea,
select {
  font: inherit;
}

/* Text inputs and selects */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="url"],
select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-input-bg);
  border: var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
select:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* Range slider — styled for consistency */
input[type="range"] {
  width: 100%;
  cursor: pointer;
  accent-color: var(--color-accent);
}

/* Buttons — base style. BEM classes refine further. */
button {
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  padding: var(--space-sm) var(--space-lg);
  color: var(--color-white);
  background-color: var(--color-accent);
  border: none;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

button:hover,
button:focus-visible {
  background-color: var(--color-navy);
}

/* Labels */
label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-2xs);
}


/* ==========================================================================
 * TABLES
 * ==========================================================================
 * Clean table styles for year-by-year breakdowns and comparison data.
 * ========================================================================== */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-lg);
  font-size: var(--text-sm);
}

thead th {
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-light);
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--color-navy);
}

tbody td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: var(--border);
}

/* Alternating row backgrounds for readability */
tbody tr:nth-child(even) {
  background-color: var(--color-surface);
}

/* Right-align numeric columns */
td[data-type="number"],
th[data-type="number"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}


/* ==========================================================================
 * ACCESSIBILITY
 * ==========================================================================
 * Screen reader only class, focus styles, reduced motion preference.
 * ========================================================================== */

/* Visually hidden but accessible to screen readers */
.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;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
