@import url('tokens.css');

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
body {
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background-color: var(--color-bg-main);
  color: var(--color-text-main);
  font-family: var(--font-text);
  font-size: var(--text-base);
}
img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-brand-deep);
}
a {
  color: var(--color-brand-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover {
  text-decoration-thickness: 2px;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.grid-asymmetric {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}
@media (min-width: 768px) {
  .grid-asymmetric {
    grid-template-columns: 3fr 2fr;
  }
}

.editorial-spread {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  margin-top: var(--space-8);
  margin-bottom: var(--space-8);
}
@media (min-width: 1024px) {
  .editorial-spread {
    grid-template-columns: 1fr 1fr;
  }
}

.full-bleed {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  background: var(--color-brand-deep);
  color: var(--color-bg-main);
  padding: var(--space-8) 0;
}
.full-bleed h2 {
  color: var(--color-bg-main);
}

header {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) 0;
}
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.nav-links {
  display: flex;
  gap: var(--space-4);
  list-style: none;
  padding: 0;
}
.nav-links a {
  text-decoration: none;
  color: var(--color-text-main);
  font-weight: 600;
}
.nav-links a.active {
  color: var(--color-brand-accent);
  border-bottom: 2px solid var(--color-brand-accent);
}
.brand {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  text-decoration: none;
  color: var(--color-brand-deep);
}
footer {
  margin-top: var(--space-16);
  padding: var(--space-8) 0;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-offset);
}
.btn {
  display: inline-block;
  background: var(--color-brand-accent);
  color: #fff;
  padding: var(--space-3) var(--space-6);
  text-decoration: none;
  font-weight: bold;
  font-family: var(--font-text);
  border: none;
  cursor: pointer;
}
.btn:hover {
  background: var(--color-brand-deep);
  color: #fff;
}

/* Tool styles */
.tool-container {
  background: var(--color-bg-offset);
  border: 1px solid var(--color-border);
  padding: var(--space-6);
  margin: var(--space-6) 0;
}
.tool-input {
  display: block;
  width: 100%;
  padding: var(--space-2);
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-border);
}
.tool-result {
  font-size: var(--text-2xl);
  font-family: var(--font-display);
  color: var(--color-brand-accent);
  margin-top: var(--space-4);
}
noscript .tool-container::after {
  content: "This interactive tool requires JavaScript to function. Below is the manual calculation method.";
  display: block;
  color: var(--color-error);
  font-weight: bold;
  margin-top: var(--space-4);
}

/* Additional responsive breakpoints and Accessibility requirements */

/* 360px */
@media (max-width: 360px) {
    :root {
        --text-base: 0.875rem;
        --text-2xl: 1.25rem;
    }
    .container {
        padding: 0 var(--space-2);
    }
}

/* 768px - handled in grid-asymmetric already, let's refine */
@media (min-width: 768px) {
    :root {
        --text-base: 1rem;
    }
}

/* 1024px */
@media (min-width: 1024px) {
    .container {
        max-width: 960px;
    }
}

/* 1440px */
@media (min-width: 1440px) {
    .container {
        max-width: 1200px;
    }
}

/* WCAG Focus states */
a:focus, button:focus, input:focus, select:focus, textarea:focus {
    outline: 3px solid var(--color-brand-accent);
    outline-offset: 2px;
}

/* Ensure sufficient contrast */
/* Brand deep is #0a192f (very dark blue), Brand light is #e6f1ff (very light blue) */
/* Accent #ff6b35 on White gives 3.1:1, okay for large text but for small text we should use a darker shade for links if they aren't buttons */
a {
    color: #cc4a14; /* Darker orange for better contrast on white background */
}
.btn {
    background: #cc4a14; /* Match link color for WCAG AA compliance (4.5:1 ratio) */
}

/* Hide visually but keep for 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;
}
