/* ==========================================================================
   BLOP Space – base tokens
   ========================================================================== */
:root {
  /* Colour inversion: script.js moves --inv from 0 (white on video) to 1 (black on bright video) */
  --inv: 0;
  --ink-c: calc(255 * (1 - var(--inv)));          /* 255 → 0 */
  --paper-c: calc(255 * var(--inv));              /* 0 → 255 */
  --ink: rgb(var(--ink-c), var(--ink-c), var(--ink-c));             /* text, logo line, rules */
  --ink-soft: rgba(var(--ink-c), var(--ink-c), var(--ink-c), 0.8);  /* paragraphs */
  --paper: rgb(var(--paper-c), var(--paper-c), var(--paper-c));     /* opposite of ink */
  --black: #000000;

  --font: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;

  --edge: clamp(1.25rem, 3.2vw, 3rem);          /* page margin */
  /* Fluid scale shared by tagline and logo: small on phones, grows gently, stops on large screens */
  --scale: clamp(3rem, 2.25rem + 3.5vw, 5.75rem);

  --logo-scale: 0.46;                             /* logo height relative to the tagline */
  --logo-h: calc(var(--scale) * var(--logo-scale));   /* height of blop.svg / space.svg */

  /* Type sizes */
  --tagline-size: var(--scale);
  --text-size: clamp(1rem, 0.3vw + 0.92rem, 1.1875rem);   /* short paragraphs */
  --text-leading: 1.5;
  --title-size: clamp(1.75rem, 4.2vw, 4.5rem);            /* contact line, section titles */

  /* Connecting line between BLOP and Space */
  --logo-line-thickness: clamp(2px, 0.18vw, 4px);
  --logo-line-offset: 7px;                        /* negative = up, positive = down */
  --logo-line-gap: calc(var(--logo-h) * 0.25);  /* space between wordmarks and line, relative to logo height */

  /* Gradient behind the logo for readability – dark at first, turns light with the inversion */
  --logo-shade: 0.45;                              /* strength at the very top, 0–1 */
  --logo-shade-scrolled: 0.9;                      /* strength once content scrolls beneath the logo */
  --logo-shade-height: calc(var(--logo-h) + var(--edge) * 3.5);

  /* Rules above headings, button outline, arrow – follow the logo line by default */
  --rule: var(--logo-line-thickness);

  /* "Köpfe drehen": length of the rotated text block (its height on screen) */
  --turn-length: clamp(16rem, 40vh, 26rem);

  /* Written by script.js (0 → 1) */
  --p-intro: 0;
  --p-past: 0;             /* 0 → 1 once the page scrolls past the video sequence */
}

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

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

body {
  margin: 0;
  background: var(--black);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-size);
  line-height: var(--text-leading);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

/* ==========================================================================
   Background video
   ========================================================================== */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--black);
}

.backdrop__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* slight overscale hides the soft edges the blur produces */
  transform: scale(1.06);
  will-change: filter;
}

.backdrop__veil {
  position: absolute;
  inset: 0;
  background: #ffffff;     /* brightening layer; opacity set by script.js */
  opacity: 0;
  pointer-events: none;
}

/* ---------- Loading spinner (hidden by script.js once the video can play) ---------- */
.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.5rem;
  height: 2.5rem;
  margin: -1.25rem 0 0 -1.25rem;
  border: var(--rule) solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  transition: opacity 0.4s;
}

.spinner.is-done {
  opacity: 0;
  animation-play-state: paused;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Logo: BLOP ———————— Space
   ========================================================================== */
.logo {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: var(--edge) var(--edge) 0;
  padding-top: max(var(--edge), env(safe-area-inset-top));
  pointer-events: none;
}

.logo::before {
  --shade: calc(var(--logo-shade) + (var(--logo-shade-scrolled) - var(--logo-shade)) * var(--p-past));
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  z-index: -1;
  height: calc(var(--logo-shade-height) + env(safe-area-inset-top));
  /* several stops = a soft, eased fade without a visible edge */
  background: linear-gradient(
    to bottom,
    rgba(var(--paper-c), var(--paper-c), var(--paper-c), var(--shade)) 0%,
    rgba(var(--paper-c), var(--paper-c), var(--paper-c), calc(var(--shade) * 0.74)) 25%,
    rgba(var(--paper-c), var(--paper-c), var(--paper-c), calc(var(--shade) * 0.45)) 50%,
    rgba(var(--paper-c), var(--paper-c), var(--paper-c), calc(var(--shade) * 0.18)) 75%,
    rgba(var(--paper-c), var(--paper-c), var(--paper-c), 0) 100%
  );
  pointer-events: none;
}

.logo__link {
  display: flex;
  align-items: center;
  width: 100%;
  text-decoration: none;
  pointer-events: auto;
}

.logo__part {
  display: block;
  height: var(--logo-h);
  width: auto;
  flex: none;
  filter: invert(var(--inv));   /* white SVGs turn black */
}

.logo__line {
  flex: 1 1 auto;          /* this is what stretches with the viewport */
  min-width: 1.5rem;
  height: var(--logo-line-thickness);
  margin-inline: var(--logo-line-gap);
  transform: translateY(var(--logo-line-offset));
  background: var(--ink);
}

/* ==========================================================================
   Scroll track + sticky stage
   ========================================================================== */
.track {
  position: relative;
  z-index: 1;
  height: 420vh;           /* length of the whole sequence – increase for a slower feel */
}

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

/* ---------- Intro (tagline) ---------- */
.intro {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--edge);
  padding-bottom: max(calc(var(--edge) * 2), env(safe-area-inset-bottom));
  opacity: calc(1 - var(--p-intro));
  transform: translateY(calc(var(--p-intro) * -6vh));
}

.intro__tagline {
  margin: 0;
  max-width: 14ch;
  font-size: var(--tagline-size);
  font-weight: 500;
  line-height: 0.92;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.intro__sub {
  margin: clamp(0.75rem, 1.5vw, 1.25rem) 0 0;
  max-width: 38ch;
  color: var(--ink-soft);
  font-size: var(--text-size);
  line-height: var(--text-leading);
}

.intro__arrow {
  position: absolute;
  right: var(--edge);
  bottom: max(calc(var(--edge) * 2), env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: clamp(2.75rem, 4vw, 3.5rem);
  aspect-ratio: 3 / 5;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.intro__arrow svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--rule);
  stroke-linecap: square;
  vector-effect: non-scaling-stroke;   /* keeps the stroke as thick as the logo line */
  transition: transform .2s;
}

.intro__arrow:hover svg,
.intro__arrow:focus-visible svg { transform: translateY(4px); }

/* ---------- Content that drops in from the top ---------- */
.content {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto auto;
  align-content: end;
  column-gap: clamp(1.5rem, 4vw, 4.5rem);
  row-gap: clamp(2.5rem, 7vh, 5rem);
  padding: calc(var(--logo-h) + var(--edge) * 3) var(--edge) calc(var(--edge) * 2.5);
  pointer-events: none;    /* lets clicks reach the arrow; landed elements re-enable it */
}

.drop {
  /* script.js sets --d from 0 (above viewport) to 1 (in place) */
  --d: 0;
  --fall: 70vh;            /* how far above its final spot an element starts */
  align-self: start;
  opacity: calc(var(--d) * var(--d));
  transform: translate3d(0, calc((1 - var(--d)) * var(--fall) * -1), 0);
  will-change: transform, opacity;
}

.drop h2 {
  margin: 0 0 0.6em;
  padding-top: 0.9em;
  border-top: var(--rule) solid var(--ink);   /* echoes the logo line */
  font-size: clamp(1.5rem, 2.4vw, 2.5rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.drop p {
  margin: 0;
  max-width: 38ch;
  color: var(--ink-soft);
}

.drop a {
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

/* ---------- "Köpfe drehen": rotated 90° CCW, arrives from the right ---------- */
.drop--turn {
  --travel: 60vw;
  transform: translate3d(calc((1 - var(--d)) * var(--travel)), 0, 0);
}

.turn {
  /* vertical text + 180° turn = text reading bottom-to-top, i.e. rotated 90° counter-clockwise.
     Unlike a plain rotate(), this keeps the rotated size in the layout, so nothing overlaps. */
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  inline-size: var(--turn-length);
}

.drop--turn .turn h2 {
  margin: 0;
  padding: 0;
  border: 0;
  margin-block-end: 0.6em;
  padding-block-start: 0.9em;
  border-block-start: var(--rule) solid var(--ink);   /* ends up as a vertical rule on the left */
}

.drop--turn .turn p {
  max-width: none;
  max-inline-size: none;
}

.drop--contact {
  grid-column: 1 / -1;
  align-self: start;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem 2rem;
}

.drop .contact__lead {
  margin: 0;
  color: var(--ink);
  max-width: none;
  font-size: var(--title-size);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.03em;
}

.contact__button {
  display: inline-block;
  padding: 0.8em 1.4em;
  border: var(--rule) solid var(--ink);
  border-radius: 999px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color .2s, color .2s;
}

.contact__button:hover,
.contact__button:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

/* ---------- Full-width image ---------- */
.feature {
  position: relative;
  z-index: 1;
  margin: clamp(3rem, 10vh, 7rem) 0 0;
}

.feature__img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100vh;        /* very tall images are cropped to one screen height */
  max-height: 100svh;
  object-fit: cover;
}

/* ---------- Services (normal scrolling) ---------- */
.services {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;      /* ensures the drop-in content has fully left the screen at the end */
  padding: calc(var(--logo-h) + var(--edge) * 3) var(--edge) clamp(3rem, 8vh, 6rem);
}

.section-title {
  margin: 0 0 clamp(2rem, 5vh, 3.5rem);
  font-size: var(--title-size);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.03em;
}

.services__list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(2rem, 5vh, 3.5rem) clamp(1.5rem, 3vw, 3.5rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.service h3 {
  margin: 0 0 0.6em;
  padding-top: 0.9em;
  border-top: var(--rule) solid var(--ink);
  font-size: clamp(1.25rem, 1.8vw, 1.875rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.service p {
  margin: 0;
  max-width: 38ch;
  color: var(--ink-soft);
}

/* ---------- Footer ---------- */
.foot {
  position: relative;
  z-index: 1;
  padding: 0 var(--edge) max(1.5rem, env(safe-area-inset-bottom));
  color: var(--ink-soft);
  font-size: 0.8125rem;
}

.foot address { font-style: normal; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 860px) {
  :root {
    --text-size: 0.9375rem;
    --text-leading: 1.45;
  }

  .track { height: 520vh; }

  /* two columns: texts left, rotated "Köpfe drehen" block right next to them */
  .content {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: none;
    align-content: end;
    column-gap: 1.25rem;
    row-gap: clamp(1.25rem, 3.5vh, 2rem);
  }

  .drop { --fall: 22vh; }
  .drop--turn { grid-column: 2; grid-row: 1 / span 2; align-self: end; --travel: 70vw; }
  .drop--turn .turn h2 { margin-block-end: 0.35em; padding-block-start: 0.6em; }
  :root { --turn-length: clamp(14rem, 52vh, 28rem); }
  .drop--turn .turn p { font-size: 0.875rem; line-height: 1.4; }
  .drop h2 { padding-top: 0.6em; margin-bottom: 0.35em; }

  .intro__sub { max-width: 30ch; padding-right: 3.5rem; }   /* keep clear of the arrow */

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

  .drop--contact {
    flex-direction: column;
    align-items: flex-start;
    margin-top: 0.5rem;
  }
}

@media (max-width: 600px) and (orientation: portrait) {
  /* phones upright: let the tagline stack large over three lines (logo keeps the shared scale) */
  :root { --tagline-size: clamp(3rem, 16vw, 5rem); }
}

@media (max-width: 560px) {
  .services__list { grid-template-columns: 1fr; }
}

@media (max-width: 860px) and (max-height: 760px) {
  /* short phones: keep the three texts but drop the body copy */
  .drop p:not(.contact__lead) { display: none; }
}

/* ==========================================================================
   Reduced motion: no blur animation, no movement – just fades
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .drop { transform: none; }
  .intro { transform: none; }
}
