/* =========================================================================
   Bas: reset, typografi, layoutprimitiver
   ========================================================================= */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.018em;
  line-height: var(--lh-snug);
  text-wrap: balance;
}
h1 { font-size: var(--t-h1); line-height: var(--lh-tight); }
h2 { font-size: var(--t-h2); line-height: var(--lh-tight); }
h3 { font-size: var(--t-h3); }
h4 {
  font-family: var(--font-body);
  font-size: var(--t-h4);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

p { text-wrap: pretty; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }

::selection { background: var(--brass-500); color: #14100E; }

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

/* ---------- Layout ---------- */

.shell {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.shell--narrow { max-width: 64rem; }
.shell--text { max-width: var(--maxw-text); }

.section {
  position: relative;
  padding-block: var(--section-y);
  background: var(--bg);
  color: var(--fg);
}
.section--tight { padding-block: clamp(3.5rem, 2.5rem + 5vw, 7rem); }
.section--flush { padding-block: 0; }

/* ---------- Etiketter ----------
   Versal sans med rejäl spärr. Läser som redaktionell rubriklinje,
   inte som gränssnitt. */

.label {
  display: inline-flex;
  align-items: center;
  gap: 0.9em;
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: var(--letter-label);
  text-transform: uppercase;
  color: var(--fg-subtle);
}
.label--rule::before {
  content: "";
  width: 2.4rem;
  height: 1px;
  background: currentColor;
  opacity: .55;
}
.label--accent { color: var(--accent); }

/* ---------- Sektionsrubriker ---------- */

.section-head {
  display: grid;
  gap: var(--sp-5);
  margin-bottom: clamp(2.5rem, 1.6rem + 4vw, 5.5rem);
}
.section-head h2 { max-width: 18ch; }
.section-head__lead {
  font-size: var(--t-lead);
  color: var(--fg-muted);
  max-width: 46ch;
  line-height: 1.55;
}

@media (min-width: 62rem) {
  .section-head--split {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    align-items: end;
    gap: var(--sp-7);
  }
  .section-head--split .section-head__lead { justify-self: end; }
}

/* Kursiv serif som accent i rubriker */
.em { font-style: italic; }
.accent { color: var(--accent); }

/* ---------- Hjälpklasser ---------- */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: var(--sp-4);
  z-index: 200;
  padding: 0.7rem 1.1rem;
  background: var(--char-900);
  color: var(--sand-50);
  border-radius: var(--r-sm);
  font-size: var(--t-small);
  transform: translateY(-160%);
  transition: transform var(--dur) var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(0); }

.rule { height: 1px; background: var(--line); border: 0; }

/* ---------- Bildytor ----------
   Alla bilder ligger i en figur med fast proportion så att layouten
   aldrig hoppar medan de laddas. */

.media {
  position: relative;
  overflow: hidden;
  background: var(--bg-sunken);
  aspect-ratio: var(--media-ratio, 3 / 2);
}
.media > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media--tall { --media-ratio: 3 / 4; }
.media--square { --media-ratio: 1 / 1; }
.media--wide { --media-ratio: 16 / 9; }
.media--pano { --media-ratio: 21 / 9; }

/* Cinematisk bilduppspelning: bilden skalas ned till 1 medan masken öppnas */
.js .reveal-media { clip-path: inset(0 0 100% 0); }
.js .reveal-media > img { transform: scale(1.12); }
.js .reveal-media,
.js .reveal-media > img {
  transition: clip-path 1200ms var(--ease-out) var(--reveal-delay, 0ms),
              transform 1600ms var(--ease-out) var(--reveal-delay, 0ms);
}
.js .reveal-media.is-revealed { clip-path: inset(0 0 0 0); }
.js .reveal-media.is-revealed > img { transform: scale(1); }

/* ---------- Reveal ---------- */

.js [data-reveal] {
  opacity: 0;
  transform: translate3d(0, 26px, 0);
  transition:
    opacity 900ms var(--ease-out) var(--reveal-delay, 0ms),
    transform 1000ms var(--ease-out) var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
.js [data-reveal="fade"] { transform: none; }
.js [data-reveal="scale"] { transform: scale(.97); }
.js .is-revealed[data-reveal] {
  opacity: 1;
  transform: none;
  will-change: auto;
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal],
  .reveal-media,
  .reveal-media > img {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    transition: none !important;
  }
}
