/* ==========================================================================
   BASE — reset, typography, layout primitives, accessibility floor
   ========================================================================== */

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

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

/* Smooth scrolling is an enhancement for anchor clicks the visitor makes, and
   it must NOT be active while the page is loading.
   With `scroll-behavior: smooth` on the root, the browser's own jump to a
   #fragment on load is an animation — and Chrome abandons it, back to the
   top, the moment the document's height changes under it. With a hero image
   and two webfonts still landing on pages this long, it was abandoned every
   time: arriving at /motoroptimering/#forfragan from the header CTA, the
   mobile-menu CTA or the action bar left the visitor at the top of a ~9600px
   page, with the form 6800px below them and nothing telling them so. The same
   applied to /kontakt/#forfragan.
   `html.ready` is added by main.js once the page has loaded, so the load-time
   jump is instant and reliable and every later anchor click still glides. */
html.ready { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  /* Room for the fixed mobile action bar, plus the iPhone home-indicator
     strip the bar itself now grows into — otherwise the last of the footer
     sits behind it and cannot be scrolled clear. */
  padding-bottom: calc(var(--mobilebar-h) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  body { padding-bottom: 0; }
}

h1, h2, h3, h4, p, figure, blockquote { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, picture, video, svg { display: block; max-width: 100%; }

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

/* --- TYPE ROLES --------------------------------------------------------- */

/* Display-font tier — the hero and MAJOR section/page headlines only.
   Confident, condensed, uppercase. Everything smaller than this (card
   titles, trust labels, review names — see .t-heading-s below) renders in
   Inter instead, so the page doesn't read as one shouting headline after
   another. */
.t-display-xl,
.t-display-l {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--lh-display);
  text-transform: uppercase;
  text-wrap: balance;
}

.t-display-xl {
  font-size: var(--fs-display-xl);
  letter-spacing: var(--tr-display-xl);
  max-width: var(--measure-display);
}

.t-display-l {
  font-size: var(--fs-display-l);
  letter-spacing: var(--tr-display-l);
  line-height: 1.08;
  max-width: var(--measure-display);
}

/* Quiet tier — Inter, not the display face, no uppercase shouting. For
   headings that need SOME visual weight (card titles, small section
   headers) without competing with an H1/H2. */
.t-heading-s {
  font-family: var(--font-body);
  font-size: var(--fs-body-l);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.t-body-l {
  font-size: var(--fs-body-l);
  line-height: 1.55;
  max-width: 46ch;
}

.t-body {
  font-size: var(--fs-body);
  max-width: var(--measure);
}

/* dim text — defaults to the dark-surface value, since dark is the site
   default; .on-light flips it back for the light sections */
.t-dim { color: var(--paper-dim); }

/* --- THE SIGNATURE: SPECIFICATION LINE ---------------------------------- *
   Small uppercase sans, letterspaced, sat on a hairline — the eyebrow/
   label device used throughout. No monospace anywhere in this system.
   ------------------------------------------------------------------------ */

.spec {
  font-family: var(--font-label);
  font-size: var(--fs-spec);
  font-weight: 500;
  letter-spacing: var(--tr-spec);
  text-transform: uppercase;
  color: var(--paper-dim);
  line-height: 1.4;
}

.spec-rule {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: var(--hairline) solid var(--ink-hairline);
}

.label {
  font-family: var(--font-label);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--paper-dim);
}

/* --- LIGHT-SECTION CONTEXT ------------------------------------------------
   The site defaults dark. .on-light flips one section (or an entire page,
   applied to <body>) back to paper-on-white — used for Utvalda fordon,
   Sålda fordon, Om oss, Kontakt. Mirrors the old .on-dark pattern, inverted.
   -------------------------------------------------------------------------- */

/* Light sections are a deliberate rhythm break, not a different website.
   Two changes make the transition read as designed rather than abrupt:

   1. The ground is the warm off-white --paper-raised, not pure #FFFFFF.
      Pure white against #0B0B0D is the maximum possible jump and reads
      clinical; it also left white cards invisible against a white section.
   2. Where dark actually meets light, the seam is marked with the one red —
      the same small graphic detail used for section eyebrows. It appears
      only on the FIRST light section of a run, so two adjacent light
      sections do not draw the line twice. */
.on-light {
  background: var(--paper-raised);
  color: var(--ink);
}

:not(.on-light) + .on-light { border-top: 2px solid var(--accent); }

.on-light .t-dim { color: var(--graphite); }
.on-light .spec,
.on-light .label { color: var(--graphite); }
.on-light .spec-rule { border-top-color: var(--paper-hairline); }

/* --- LAYOUT ------------------------------------------------------------- */

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

.container--text { max-width: var(--max-width-text); }

.section { padding-block: var(--section-y); }

.section-head {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}

/* --- ACCESSIBILITY FLOOR ------------------------------------------------ */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-3);
  z-index: 999;
  padding: var(--sp-3) var(--sp-4);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-label);
  font-size: var(--fs-label);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
}

.skip-link:focus { top: var(--sp-3); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* --- MOTION ------------------------------------------------------------- */

/* If scripting is unavailable the reveal class can never be added, so the
   hidden state must not apply at all. html.js is set by main.js on boot. */
html:not(.js) [data-reveal] { opacity: 1 !important; transform: none !important; }

[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-out);
}

[data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html,
  html.ready { scroll-behavior: auto; }

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

  [data-reveal] { opacity: 1; transform: none; }
}

/* The last section before the footer -------------------------------------
   The footer opens with 112px of its own padding, so a final section that
   also closes with 112px puts 224px of dead black between the last thing a
   visitor can act on and the footer. Measured on Kontakt at 1440: 224px
   between the submit button and the footer logo. Desktop only — on a phone
   that separation is right.
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) {
  main > section:last-child { padding-bottom: var(--sp-7); }
}
