@font-face {
  font-family: "Cormorant";
  src: url("/fonts/cormorant-rett.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant";
  src: url("/fonts/cormorant-kursiv.woff2") format("woff2");
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --papir: #f6f1e9;
  --papir-2: #efe7db;
  --blekk: #1f1a15;
  --blekk-2: #6b6056;
  --gull: #a8834f;
  --gull-lys: #d9bf91;
  --strek: rgba(31, 26, 21, 0.12);
  --nav-bg: rgba(246, 241, 233, 0.82);
  --serif: "Cormorant", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mellomrom: 6px;
  --side: clamp(10px, 3vw, 40px);
  --myk: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --papir: #14110e;
    --papir-2: #1d1915;
    --blekk: #f1e9dd;
    --blekk-2: #a99c8c;
    --gull: #cfae78;
    --strek: rgba(241, 233, 221, 0.12);
    --nav-bg: rgba(20, 17, 14, 0.8);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--papir);
  color: var(--blekk);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.låst { overflow: hidden; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Forsiden ---------- */

.forside {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 520px;
  overflow: hidden;
  color: #fff;
  background: #2b241d;
}
.forside-bilde, .forside-bilde img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.forside-bilde img {
  object-fit: cover;
  object-position: 50% 45%;
  animation: forside-zoom 22s var(--myk) both;
  transform-origin: 50% 60%;
}
@media (orientation: portrait) {
  .forside-bilde img { object-position: 50% 40%; }
}
@keyframes forside-zoom {
  from { transform: scale(1.12); opacity: 0; }
  8% { opacity: 1; }
  to { transform: scale(1); opacity: 1; }
}
.forside::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(12, 9, 6, 0.42) 0%, rgba(12, 9, 6, 0) 34%),
    linear-gradient(to top, rgba(12, 9, 6, 0.72) 0%, rgba(12, 9, 6, 0.12) 46%, rgba(12, 9, 6, 0) 64%);
  pointer-events: none;
}
.forside-tekst {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  bottom: max(13vh, 96px);
  padding: 0 24px;
  text-align: center;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
}
.forside-tekst > * { animation: inn 1.6s var(--myk) both; }
.forside-tekst h1 { animation-delay: 0.35s; }
.forside-tekst .underlinje { animation-delay: 0.7s; }
.forside-tekst .liten-linje { animation-delay: 0.95s; }
@keyframes inn {
  from { opacity: 0; transform: translateY(18px); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}
.overlinje, .underlinje {
  margin: 0;
  font-size: clamp(11px, 1.1vw, 13px);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-weight: 500;
  opacity: 0.92;
}
.forside h1 {
  margin: 0.08em 0 0.18em;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(52px, 10.5vw, 148px);
  line-height: 0.95;
  letter-spacing: -0.01em;
}
.og {
  font-style: italic;
  color: var(--gull-lys);
  padding: 0 0.04em;
}
.underlinje { letter-spacing: 0.24em; text-wrap: balance; line-height: 1.7; }
@media (max-width: 600px) {
  .underlinje time, .slutt-dato time { display: block; }
  .skille { display: none; }
}
.liten-linje {
  margin-top: 10px;
  font-size: clamp(10px, 0.95vw, 11px);
  opacity: 0.72;
}
.bla-ned {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: max(env(safe-area-inset-bottom), 22px);
  translate: -50% 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #fff;
  opacity: 0.85;
  animation: svev 2.6s ease-in-out infinite 2s;
}
@keyframes svev { 50% { transform: translateY(7px); } }

.språk {
  position: absolute;
  z-index: 1;
  top: max(env(safe-area-inset-top), 16px);
  right: max(env(safe-area-inset-right), 16px);
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  opacity: 0.8;
  transition: opacity 0.3s, background-color 0.3s;
  animation: inn 1.2s var(--myk) 1.2s both;
}
.språk:hover, .språk:focus-visible { opacity: 1; background: rgba(255, 255, 255, 0.14); }

/* ---------- Kapittelmenyen ---------- */

.kapitler {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  backdrop-filter: saturate(1.4) blur(18px);
  border-bottom: 1px solid var(--strek);
}
.kapitler-indre {
  display: flex;
  gap: 4px;
  justify-content: safe center;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 10px var(--side);
  scroll-padding-inline: var(--side);
}
.kapitler-indre::-webkit-scrollbar { display: none; }
.kapitler button {
  flex: none;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  color: var(--blekk-2);
  transition: color 0.3s, background-color 0.3s;
  white-space: nowrap;
}
.kapitler button:hover { color: var(--blekk); }
.kapitler button[aria-current="true"] {
  color: var(--blekk);
  background: var(--papir-2);
}
.kapitler button:focus-visible, .knapp:focus-visible, .flis:focus-visible, .ikon:focus-visible {
  outline: 2px solid var(--gull);
  outline-offset: 2px;
}

/* ---------- Galleriet ---------- */

main { padding: 0 var(--side) 40px; }
.kapittel {
  scroll-margin-top: 58px;
  padding-top: clamp(56px, 9vw, 120px);
}
.kapittel-hode {
  text-align: center;
  margin-bottom: clamp(26px, 4vw, 48px);
}
.kapittel-nr {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--gull);
  font-weight: 600;
}
.kapittel h2 {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(38px, 5.4vw, 68px);
  line-height: 1;
}
.kapittel-sted {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-size: 20px;
  color: var(--blekk-2);
}
.kapittel-antall {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--blekk-2);
}
.kapittel-antall::before, .kapittel-antall::after {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--strek);
  vertical-align: middle;
  margin: 0 12px;
}

.rad {
  display: flex;
  gap: var(--mellomrom);
  margin-bottom: var(--mellomrom);
}
.flis {
  position: relative;
  flex: none;
  overflow: hidden;
  border-radius: 3px;
  background-color: var(--papir-2);
  background-size: cover;
  background-position: center;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.9s var(--myk), transform 0.9s var(--myk);
}
.flis.synlig { opacity: 1; transform: none; }
.flis img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.7s ease, transform 1.2s var(--myk), filter 0.6s;
}
.flis img.lastet { opacity: 1; }
@media (hover: hover) {
  .flis:hover img { transform: scale(1.035); }
}
.flis::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
  border-radius: inherit;
  pointer-events: none;
}
.flis.skjult-under { visibility: hidden; }

/* ---------- Slutten ---------- */

.slutt {
  text-align: center;
  padding: clamp(80px, 12vw, 160px) 24px calc(64px + env(safe-area-inset-bottom));
}
.slutt-hjerte {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 72px;
  line-height: 1;
  color: var(--gull);
}
.slutt-takk {
  margin: 18px auto 12px;
  max-width: 22ch;
  font-family: var(--serif);
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 400;
  line-height: 1.2;
}
.slutt-dato {
  margin: 0 0 34px;
  font-size: 12px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--gull);
}
.knapp {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-radius: 999px;
  border: 1px solid var(--strek);
  color: var(--blekk);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: background-color 0.3s, border-color 0.3s;
}
.knapp:hover { background: var(--papir-2); border-color: var(--gull); }
.knapp svg { width: 20px; height: 20px; }
.liten { color: var(--blekk-2); font-weight: 400; }
.slutt-språk { margin: 18px 0 0; font-size: 14px; }
.slutt-språk a { color: var(--blekk-2); text-underline-offset: 3px; }
.slutt-språk a:hover { color: var(--blekk); }
.slutt-foto {
  margin: 28px 0 0;
  font-size: 12px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--blekk-2);
}

/* ---------- Lysboksen ---------- */

.lys {
  position: fixed;
  inset: 0;
  z-index: 100;
  color: #fff;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.lys[hidden] { display: none; }
.lys-bakgrunn {
  position: absolute;
  inset: 0;
  background: #0b0907;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.lys.åpen .lys-bakgrunn { opacity: 1; }
.lys-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.lys-bilde {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  transform-origin: 0 0;
  will-change: transform;
  -webkit-user-drag: none;
  border-radius: 2px;
}
.lys-topp {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(env(safe-area-inset-top), 10px) max(env(safe-area-inset-right), 10px) 24px max(env(safe-area-inset-left), 18px);
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
}
.lys-tekst {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  font-size: 13px;
  letter-spacing: 0.04em;
}
.lys-kapittel {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lys-teller { opacity: 0.66; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lys-knapper { display: flex; gap: 2px; flex: none; }
.ikon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.ikon:hover { background: rgba(255, 255, 255, 0.12); }
.lys-spill .pause, .lys.spiller .lys-spill .spill { display: none; }
.lys.spiller .lys-spill .pause { display: block; }
.lys-pil {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  width: 56px;
  height: 56px;
  background: rgba(20, 16, 12, 0.32);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.lys-pil:hover { background: rgba(20, 16, 12, 0.55); }
.lys-forrige { left: max(env(safe-area-inset-left), 18px); }
.lys-neste { right: max(env(safe-area-inset-right), 18px); }
.lys-topp, .lys-pil, .lys-fremdrift { transition: opacity 0.35s ease; }
.lys:not(.åpen) .lys-topp, .lys:not(.åpen) .lys-pil,
.lys.rolig .lys-topp, .lys.rolig .lys-pil { opacity: 0; pointer-events: none; }
.lys.rolig { cursor: none; }
@media (hover: none) {
  .lys-pil { display: none; }
}
.lys-fremdrift {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  opacity: 0;
}
.lys.spiller .lys-fremdrift { opacity: 1; }
.lys-fremdrift span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--gull-lys);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

.melding {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  translate: -50% 0;
  padding: 11px 20px;
  border-radius: 999px;
  background: rgba(20, 16, 12, 0.88);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s var(--myk);
  pointer-events: none;
}
.melding.vis { opacity: 1; transform: none; }

/* ---------- Musikken ---------- */

.musikk {
  position: fixed;
  z-index: 150;
  left: max(env(safe-area-inset-left), 16px);
  bottom: max(env(safe-area-inset-bottom), 16px);
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(20, 16, 12, 0.34);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  color: #fff;
  cursor: pointer;
  opacity: 0.72;
  transition: opacity 0.3s, background-color 0.3s;
  -webkit-tap-highlight-color: transparent;
  animation: inn 1.2s var(--myk) 1.4s both;
}
.musikk[hidden] { display: none; }
.musikk:hover, .musikk:focus-visible, .musikk.viser { opacity: 1; background: rgba(20, 16, 12, 0.55); }
.musikk:focus-visible { outline: 2px solid var(--gull-lys); outline-offset: 2px; }
.musikk-stolper {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 15px;
  height: 14px;
}
.musikk-stolper i {
  flex: 1;
  height: 100%;
  border-radius: 2px;
  background: currentColor;
  transform: scaleY(0.18);
  transition: transform 0.5s var(--myk);
}
.musikk.spiller .musikk-stolper i { animation: stolpe 1.1s ease-in-out infinite alternate; }
.musikk.spiller .musikk-stolper i:nth-child(2) { animation-duration: 0.8s; animation-delay: -0.4s; }
.musikk.spiller .musikk-stolper i:nth-child(3) { animation-duration: 1.3s; animation-delay: -0.7s; }
/* Musikken er på, men venter på første trykk: stolpene står stille og puster. */
.musikk.venter .musikk-stolper i { transform: scaleY(0.5); }
.musikk.venter { animation: inn 1.2s var(--myk) 1.4s both, pust 2.8s ease-in-out 3s infinite; }
@keyframes stolpe {
  from { transform: scaleY(0.2); }
  to { transform: scaleY(1); }
}
@keyframes pust { 50% { opacity: 1; } }
.musikk-tittel {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  opacity: 0;
  transition: max-width 0.6s var(--myk), opacity 0.4s, margin 0.6s var(--myk);
}
.musikk.viser .musikk-tittel { max-width: 220px; opacity: 1; margin-left: 10px; }
@media (hover: hover) {
  .musikk:hover .musikk-tittel { max-width: 220px; opacity: 1; margin-left: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
  .flis { opacity: 1; transform: none; }
}
