/* ==========================================================================
   RÄKNARE.ORG - SHARED STYLESHEET
   Sections: 1. Variables  2. Reset  3. Base/Layout  4. Components
             5. Utilities  6. Responsive  7. Accessibility
   ========================================================================== */

/* ==========================================================================
   1. VARIABLES - design tokens (locked, see docs/BLUEPRINT.md section 5)
   ========================================================================== */
:root {
  /* Colors */
  --color-primary: #0F766E;
  --color-primary-dark: #0B5A54;
  --color-secondary: #1D4E89;
  --color-accent: #FB923C;
  --color-accent-dark: #EA7C1E;

  --color-bg: #F7FAF9;
  --color-surface: #FFFFFF;
  --color-border: #E2E8E6;

  --color-text: #1A2E2B;
  --color-text-muted: #5B6B68;
  --color-on-primary: #FFFFFF;
  --color-on-accent: #1A2E2B;

  --color-success: #22C55E;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;

  /* Typography */
  --font-display: 'Poppins', sans-serif;
  --font-body: 'Inter', sans-serif;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;
  --fs-3xl: 2.5rem;
  --fs-4xl: 3rem;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --lh-tight: 1.2;
  --lh-normal: 1.5;
  --lh-loose: 1.7;
  --ls-tight: -0.01em;

  /* Spacing scale - only these values, ever */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 22, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 22, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 22, 0.12);

  /* Layout */
  --container-max: 1200px;

  /* Motion */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

/* ==========================================================================
   2. RESET
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol {
  margin: 0;
}

ul[role="list"], ol[role="list"] { list-style: none; padding: 0; margin: 0; }

html:focus-within { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  text-rendering: optimizeSpeed;
  line-height: var(--lh-normal);
}

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

input, button, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

a { text-decoration: none; color: inherit; }

table { border-collapse: collapse; width: 100%; }

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

/* ==========================================================================
   3. BASE / LAYOUT
   ========================================================================== */
body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  direction: ltr;
  text-align: left;
  /* clip, not hidden: hidden would make body a scroll container and break the
     sticky header. This is a guard only, overflow is fixed at the source. */
  overflow-x: clip;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  color: var(--color-text);
  text-align: left;
}

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

p {
  text-align: left;
  color: var(--color-text);
}

p + p { margin-top: var(--space-4); }

.text-muted { color: var(--color-text-muted); }

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

main { display: block; }

section { padding-block: var(--space-8); }

/* ==========================================================================
   4. COMPONENTS
   ========================================================================== */

/* --- Skip link --- */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -48px;
  background: var(--color-primary);
  color: var(--color-on-primary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  z-index: 100;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-4);
}

/* --- Header / Navigation --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.site-header.is-scrolled {
  box-shadow: var(--shadow-sm);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-4);
  gap: var(--space-5);
}

.site-header__logo {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-lg);
  color: var(--color-primary);
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.nav__list {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.nav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  appearance: none;
  font: inherit;
  font-weight: var(--fw-medium);
  padding-block: var(--space-2);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.nav__chevron {
  flex-shrink: 0;
  transition: transform var(--transition-base);
}

.nav__dropdown.is-open .nav__chevron {
  transform: rotate(180deg);
}

.nav__link:hover,
.nav__link:focus-visible {
  color: var(--color-primary);
}

.nav__link[aria-current="page"] {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.nav__dropdown {
  position: relative;
}

.nav__dropdown-panel {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-3);
  display: none;
  flex-direction: column;
  gap: var(--space-1);
}

.nav__dropdown.is-open .nav__dropdown-panel {
  display: flex;
}

.nav__dropdown-panel a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}

.nav__dropdown-panel--mega {
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  min-width: min(640px, calc(100vw - var(--space-6)));
  max-width: calc(100vw - var(--space-6));
  padding: var(--space-4);
}

.nav__dropdown.is-open .nav__dropdown-panel--mega {
  display: grid;
}

/* Hover-to-open only on devices that actually hover, and only in the desktop
   nav. On touch, :hover can stick after a tap and leave the panel stuck open. */
@media (hover: hover) and (min-width: 601px) {
  .nav__dropdown:hover .nav__dropdown-panel {
    display: flex;
  }

  .nav__dropdown:hover .nav__dropdown-panel--mega {
    display: grid;
  }

  .nav__dropdown:hover .nav__chevron {
    transform: rotate(180deg);
  }
}

.nav__dropdown-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav__dropdown-group-title {
  font-weight: var(--fw-semibold);
  color: var(--color-primary);
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-sm);
}

.nav__dropdown-panel a:hover,
.nav__dropdown-panel a:focus-visible {
  background-color: var(--color-bg);
  color: var(--color-primary);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  padding: var(--space-2);
  min-width: 44px;
  min-height: 44px;
}

.nav-toggle__bar {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--color-text);
  margin: 5px auto;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

/* --- Footer --- */
.site-footer {
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-8) var(--space-6);
  margin-top: var(--space-9);
}

.site-footer__grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-6);
}

.site-footer__heading {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.site-footer__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.site-footer__list a:hover,
.site-footer__list a:focus-visible {
  color: var(--color-primary);
}

.site-footer__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

.site-footer__blurb {
  color: var(--color-text-muted);
  max-width: 32ch;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background-color: var(--color-bg);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--color-primary);
}

/* --- Breadcrumb --- */
.breadcrumb {
  padding-block: var(--space-4);
}

.breadcrumb__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

.breadcrumb__list a {
  color: var(--color-text-muted);
}

.breadcrumb__list a:hover,
.breadcrumb__list a:focus-visible {
  color: var(--color-primary);
}

.breadcrumb__list li:not(:last-child)::after {
  content: "/";
  margin-left: var(--space-2);
  color: var(--color-border);
}

.breadcrumb__list li[aria-current="page"] {
  color: var(--color-text);
  font-weight: var(--fw-medium);
}

/* --- Hero --- */
.hero {
  padding-block: var(--space-8);
}

.hero__inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-7);
  align-items: center;
}

.hero__eyebrow {
  display: inline-flex;
  padding: var(--space-1) var(--space-3);
  background-color: rgba(15, 118, 110, 0.1);
  color: var(--color-primary);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--space-4);
}

.hero__title { margin-bottom: var(--space-4); }

.hero__lead {
  font-size: var(--fs-md);
  color: var(--color-text-muted);
  max-width: 42ch;
  margin-bottom: var(--space-5);
}

.hero__actions {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.hero--centered {
  text-align: center;
  padding-bottom: var(--space-4);
}

.hero--centered .hero__eyebrow {
  margin-inline: auto;
}

.hero--centered .hero__title {
  text-align: center;
}

.hero--centered .hero__lead {
  max-width: 680px;
  margin-inline: auto;
  margin-bottom: 0;
}

.hero--centered .hero__actions {
  justify-content: center;
}

.hero--centered + section {
  padding-top: var(--space-4);
}

.hero__media img {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
  border: 2px solid transparent;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.btn:active { transform: translateY(1px); }

.btn--primary {
  background-color: var(--color-accent);
  color: var(--color-on-accent);
}

.btn--primary:hover,
.btn--primary:focus-visible {
  background-color: var(--color-accent-dark);
}

.btn--secondary {
  background-color: transparent;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn--secondary:hover,
.btn--secondary:focus-visible {
  background-color: var(--color-primary);
  color: var(--color-on-primary);
}

/* --- CTA section --- */
.cta {
  background-color: var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-7);
  text-align: left;
}

.cta__title {
  color: var(--color-on-primary);
  margin-bottom: var(--space-3);
}

.cta__lead {
  /* 0.85 measured at 4.41:1 against --color-primary in Lighthouse's
     color-contrast audit, just under the 4.5:1 WCAG AA minimum for normal
     text. 0.92 gives 4.9:1, a safe margin instead of a razor's-edge pass. */
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: var(--space-5);
  max-width: 56ch;
}

.cta__actions {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.cta .btn--secondary {
  border-color: var(--color-on-primary);
  color: var(--color-on-primary);
}

.cta .btn--secondary:hover,
.cta .btn--secondary:focus-visible {
  background-color: var(--color-on-primary);
  color: var(--color-primary);
}

/* --- Cards --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}

.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card__icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(15, 118, 110, 0.1);
  color: var(--color-primary);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
}

.card__title { margin-bottom: var(--space-2); }

.card__text { color: var(--color-text-muted); font-size: var(--fs-sm); }

.card__link {
  display: inline-block;
  margin-top: var(--space-3);
  font-weight: var(--fw-semibold);
  color: var(--color-primary);
}

/* --- Author / trust bio card (Om oss) --- */
.author-card {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.author-card__photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.author-card__name {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-lg);
  color: var(--color-text);
}

.author-card__role {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.author-card__bio {
  margin-top: var(--space-3);
  color: var(--color-text);
}

@media (max-width: 600px) {
  .author-card {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
}

/* --- FAQ (accordion) --- */
.faq { max-width: 72ch; }

.faq__item {
  border-bottom: 1px solid var(--color-border);
}

.faq__item summary {
  padding-block: var(--space-4);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Question text is a real <h4> for heading-hierarchy/SEO reasons, but must
   look identical to the plain text it replaced - neutralize every default
   h4 style and inherit summary's own instead. */
.faq__item summary h4 {
  margin: 0;
  font: inherit;
  font-weight: var(--fw-semibold);
  font-family: var(--font-display);
}

.faq__item summary::-webkit-details-marker { display: none; }

.faq__item summary::after {
  content: "+";
  font-size: var(--fs-xl);
  color: var(--color-primary);
  transition: transform var(--transition-fast);
}

.faq__item[open] summary::after {
  transform: rotate(45deg);
}

.faq__item p {
  padding-bottom: var(--space-4);
  color: var(--color-text-muted);
}

/* --- Search --- */
.search {
  position: relative;
  max-width: 480px;
}

.search__input {
  width: 100%;
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-surface);
  font-size: var(--fs-base);
}

.search__input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.search__results {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  right: 0;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 320px;
  overflow-y: auto;
  z-index: 40;
}

.search__results:empty { display: none; }

.search__results a {
  display: block;
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
}

.search__results a:hover,
.search__results a:focus-visible {
  background-color: var(--color-bg);
  color: var(--color-primary);
}

/* --- Calculator form --- */
.calculator {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-md);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.form-field { display: flex; flex-direction: column; gap: var(--space-2); }

.form-field label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

fieldset.form-field {
  border: none;
  padding: 0;
  margin: 0;
}

fieldset.form-field legend {
  padding: 0;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

.form-field input,
.form-field select {
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-surface);
}

.form-field input:focus-visible,
.form-field select:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.form-field input[readonly] {
  background-color: var(--color-bg);
  font-weight: var(--fw-semibold);
  color: var(--color-primary);
}

/* Value + unit side by side under one label, e.g. Enhetsomvandlare. */
.unit-row {
  display: flex;
  gap: var(--space-3);
}

.unit-row input {
  flex: 1;
  min-width: 0;
}

.unit-row select {
  flex: 0 0 auto;
  width: 180px;
  padding-right: var(--space-2);
}

.swap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 40px;
  margin-block: var(--space-1);
  border: none;
  background: none;
  color: var(--color-primary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
}

.swap-btn:hover,
.swap-btn:focus-visible {
  text-decoration: underline;
}

@media (max-width: 600px) {
  .unit-row {
    flex-direction: column;
  }

  .unit-row select {
    width: 100%;
  }
}

/* Numerator / denominator pair, e.g. Bråkräknare. Both inputs equally
   weighted (unlike .unit-row's input+select), separated by a plain "/". */
.fraction-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.fraction-row input {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.fraction-row span {
  font-weight: var(--fw-bold);
  color: var(--color-text-muted);
  font-size: var(--fs-lg);
}

.form-field--radio-group {
  flex-direction: row;
  gap: var(--space-4);
  align-items: center;
}

.radio-group {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.radio-option input[type="radio"],
.radio-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* Highlight the selected option's label, not just the tiny input dot itself,
   so the active choice (e.g. which percent-calculation mode) is obvious at a
   glance. Sitewide, since every radio-option group benefits equally. */
.radio-option:has(input:checked) {
  color: var(--color-primary);
  font-weight: var(--fw-semibold);
}

.field-hint {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

/* --- Calculator quadrant layout (standard template for every tool page) --- */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "inputs results"
    "table chart";
  gap: var(--space-5);
}

/* Grid items default to min-width:auto, which lets wide content (currency
   strings, tables) force a column wider than the card and spill outside it.
   min-width:0 is what keeps every cell inside the border. */
.calc-grid > * {
  min-width: 0;
  max-width: 100%;
}

.calc-cell--inputs { grid-area: inputs; }
.calc-cell--results { grid-area: results; }
.calc-cell--table { grid-area: table; }
.calc-cell--chart { grid-area: chart; }

.calc-cell--results,
.calc-cell--chart {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Author CSS always wins over the browser's native [hidden] rule regardless
   of specificity (it's a lower-priority UA-stylesheet default, not a normal
   cascade loss), so any cell using `display: flex` needs this to make the
   `hidden` attribute actually hide it - otherwise a JS-toggled `hidden` is
   silently a no-op and stale content (e.g. an old chart) stays visible. */
.calc-cell--results[hidden],
.calc-cell--chart[hidden] {
  display: none;
}

.calc-cell--table .table-wrap,
.calc-cell--chart .chart {
  margin-top: 0;
}

/* Two-cell variant (inputs | results only) for tools with no table/chart,
   e.g. a stat-list result like Åldersräknare. Standalone rule set (not a
   .calc-grid modifier) so it can't be re-overridden by the 4-area .calc-grid
   media-query rules further down. */
.calc-grid--simple {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

.calc-grid--simple > * {
  min-width: 0;
  max-width: 100%;
  /* .calc-cell--inputs/--results carry a named grid-area for the 4-area
     .calc-grid. Left in place here, that named area doesn't exist in this
     variant's (unnamed) grid, so the browser implicitly creates a new track
     per name and stacks both items on top of each other. Resetting to auto
     restores normal left-to-right auto-placement across the 2 columns. */
  grid-area: auto;
}

/* Three-cell variant (inputs | results, table spanning full width below)
   for tools with a list result but no chart, e.g. Arbetsdagar-räknare. Named
   areas here match .calc-cell--inputs/--results/--table's own grid-area
   values, so unlike .calc-grid--simple no grid-area reset is needed. */
.calc-grid--table {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "inputs results"
    "table table";
  gap: var(--space-5);
}

.calc-grid--table > * {
  min-width: 0;
  max-width: 100%;
}

/* Single-column layout for tools whose content is inherently asymmetric -
   a short form and an even shorter result, e.g. Procenträknare. A 2-column
   inputs|results grid was tried here first and rejected: whichever side has
   less content still gets stretched to match the taller side's row height,
   which just relocates the dead-space problem instead of solving it. This
   variant avoids the mismatch entirely by never splitting into columns. */
.calculator--compact {
  max-width: 520px;
  margin-inline: auto;
}

.calculator--compact .form-field input {
  max-width: 240px;
}

@media (max-width: 600px) {
  .calculator--compact .form-field input {
    max-width: none;
  }
}

/* Result + chart combined into one tight card, side by side, instead of a
   full-width result row over a separately-boxed chart - two short elements
   read as more intentionally designed sitting in one compact unit than
   stacked with room to spare around each. */
.result-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-5);
  padding: var(--space-5);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.result-callout__text {
  min-width: 0;
}

.result-callout__label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

.result-callout__value {
  display: block;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-xl);
  color: var(--color-text);
  margin-top: var(--space-1);
  overflow-wrap: anywhere;
}

.result-callout__secondary {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

.result-callout__chart {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
}

/* Wider variant for a labeled shape diagram (viewBox 200x160), e.g.
   Area-/volymräknare, which needs more room than a plain donut/icon to show
   dimension labels legibly. */
.result-callout__chart--wide {
  width: 160px;
  height: 128px;
}

@media (max-width: 600px) {
  .result-callout {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }

  .result-callout__chart {
    align-self: center;
  }
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.result-list__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.result-list__row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.result-list__label {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

.result-list__value {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-xl);
  color: var(--color-text);
  overflow-wrap: anywhere;
}

/* --- Result / meter --- */
.result {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.result__value {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
}

.result__label {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.meter {
  margin-top: var(--space-5);
}

.meter__track {
  display: flex;
  height: 12px;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.meter__zone--low { background-color: var(--color-secondary); }
.meter__zone--normal { background-color: var(--color-success); }
.meter__zone--warning { background-color: var(--color-warning); }
.meter__zone--danger { background-color: var(--color-danger); }

.meter__pointer {
  width: 2px;
  height: 20px;
  background-color: var(--color-text);
  margin-top: -4px;
}

.meter__labels {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

.meter__labels span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.meter__labels span::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

/* --- Progress bar (accrual, e.g. Semesterdagar-räknare) --- */
.progress-bar {
  margin-top: var(--space-5);
}

.progress-bar__track {
  height: 12px;
  border-radius: var(--radius-pill);
  background-color: var(--color-border);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background-color: var(--color-primary);
  border-radius: var(--radius-pill);
}

.progress-bar__label {
  margin-top: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

/* --- Trust / data-source banner --- */
.trust-banner {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
  padding: var(--space-5);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.trust-banner__label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: var(--fw-semibold);
}

.trust-banner__sources {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
}

/* --- Chart --- */
.chart {
  width: 100%;
  height: auto;
  margin-top: var(--space-5);
}

.chart__grid-line {
  stroke: var(--color-border);
  stroke-width: 1;
}

.chart__line {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart__axis-label {
  font-size: 10px;
  fill: var(--color-text-muted);
  font-family: var(--font-body);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}

.result-grid .result {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.source-note {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

.source-note a { text-decoration: underline; }

/* --- Steps --- */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  counter-reset: step;
}

.step {
  position: relative;
  padding-top: var(--space-7);
}

.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-primary);
  color: var(--color-on-primary);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
}

/* --- Tables --- */
.table {
  font-size: var(--fs-sm);
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.table th {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  color: var(--color-text-muted);
}

.table-wrap {
  max-height: 220px;
  overflow-y: auto;
  overflow-x: auto;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-top: var(--space-5);
}

.table-wrap .table {
  margin: 0;
}

/* --- Plain content lists (body copy, e.g. homepage numbered steps) ---
   ul/ol get margin:0 from the reset but keep their native padding-left and
   markers (only ul/ol[role="list"] strip those, for nav-style lists), so a
   plain content list still shows bullets/numbers. Scoped to .content-list
   specifically - a bare `li + li` selector would also hit nav/footer lists,
   which already space themselves via flex `gap` and would double up. */
.content-list {
  max-width: 60ch;
}

.content-list li + li {
  margin-top: var(--space-2);
}

/* --- Tip box (body-copy callout, e.g. homepage "💡 Tips") --- */
.tip-box {
  background-color: rgba(251, 146, 60, 0.1);
  border: 1px solid rgba(251, 146, 60, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  font-size: var(--fs-sm);
}

.table-wrap thead th {
  position: sticky;
  top: 0;
  background-color: var(--color-surface);
}

/* ==========================================================================
   5. UTILITIES
   ========================================================================== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }

.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mt-7 { margin-top: var(--space-7); }
.mb-4 { margin-top: var(--space-4); }

.text-center { text-align: center; }

.section-intro { max-width: 60ch; }

/* ==========================================================================
   6. RESPONSIVE
   ========================================================================== */

/* Tablet: 768px */
@media (max-width: 768px) {
  .hero__inner {
    grid-template-columns: 1fr;
  }

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .site-footer__grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-5);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .result-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .steps {
    grid-template-columns: 1fr;
  }

  .calculator {
    padding: var(--space-4);
  }

  /* Inputs stacked in the left half, results in the right half, then the
     table full width, then the chart full width. */
  .calc-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "inputs results"
      "table table"
      "chart chart";
    gap: var(--space-4);
  }

  .form-field label,
  fieldset.form-field legend {
    font-size: var(--fs-xs);
  }

  .form-field input,
  .form-field select {
    min-height: 40px;
    padding: var(--space-2) var(--space-3);
    font-size: var(--fs-sm);
  }

  .radio-group {
    gap: var(--space-3);
  }

  .radio-option {
    font-size: var(--fs-xs);
  }

  .result-list {
    gap: var(--space-3);
  }

  .result-list__row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
    padding-bottom: var(--space-3);
  }

  .result-list__label {
    font-size: var(--fs-xs);
  }

  .result-list__value {
    font-size: var(--fs-base);
  }

  .table th,
  .table td {
    padding: var(--space-2) var(--space-3);
    font-size: var(--fs-xs);
  }
}

/* Mobile: full width below 768px */
@media (max-width: 600px) {
  .nav {
    position: fixed;
    inset: 72px 0 0 0;
    background-color: var(--color-surface);
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-5);
    display: none;
    overflow-y: auto;
  }

  .nav.is-open { display: flex; }

  .nav__list {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }

  .nav__dropdown-panel {
    position: static;
    box-shadow: none;
    border: none;
    display: none;
    padding-left: var(--space-4);
  }

  .nav__dropdown.is-open .nav__dropdown-panel {
    display: flex;
  }

  .nav__dropdown-panel--mega {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .nav__dropdown.is-open .nav__dropdown-panel--mega {
    display: grid;
  }

  /* Full-width accordion row with the chevron pushed to the right edge. */
  .nav__dropdown {
    width: 100%;
  }

  .nav__dropdown-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .nav-toggle { display: block; }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .site-footer__grid {
    grid-template-columns: 1fr;
  }

  .site-footer__bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .cta__actions,
  .hero__actions {
    flex-direction: column;
    align-items: stretch;
  }

  /* Tighter gutters and vertical rhythm so a phone screen isn't dominated by
     padding. This is also what makes the page read at its true scale instead
     of looking zoomed in. */
  .container {
    padding-inline: var(--space-4);
  }

  section {
    padding-block: var(--space-6);
  }

  .hero {
    padding-block: var(--space-6);
  }

  .hero__lead {
    font-size: var(--fs-base);
  }

  .cta {
    padding: var(--space-5);
  }

  h1 { font-size: var(--fs-2xl); }
  h2 { font-size: var(--fs-xl); }
  h3 { font-size: var(--fs-lg); }
}

/* ==========================================================================
   7. ACCESSIBILITY
   ========================================================================== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn:focus-visible {
  outline-offset: 3px;
}

@media (prefers-contrast: more) {
  :root {
    --color-border: #94A3A0;
    --color-text-muted: #3F4C49;
  }
}
