/* ------------------------------------------------------------------
   Fonts (self-hosted; licensed by Fredrik Malm)
------------------------------------------------------------------ */
@font-face {
  font-family: "KH Teka";
  src: url("assets/fonts/kh-teka-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Ivar Headline";
  src: url("assets/fonts/ivar-headline-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
/* Metric-matched Arial fallbacks (same overrides Framer uses) to avoid layout shift */
@font-face {
  font-family: "KH Teka Fallback";
  src: local("Arial");
  ascent-override: 95.61%;
  descent-override: 25.16%;
  line-gap-override: 0%;
  size-adjust: 99.36%;
}
@font-face {
  font-family: "Ivar Headline Fallback";
  src: local("Arial");
  ascent-override: 106.42%;
  descent-override: 28.01%;
  line-gap-override: 0%;
  size-adjust: 89.27%;
}

/* ------------------------------------------------------------------
   Tokens
------------------------------------------------------------------ */
:root {
  --font-sans: "KH Teka", "KH Teka Fallback", sans-serif;
  --font-serif: "Ivar Headline", "Ivar Headline Fallback", serif;

  --bg: #fff;
  --fg: #000;
  --muted: rgba(0, 0, 0, 0.5);
  --row-hover: rgba(0, 0, 0, 0.08);

  --gutter: 8px;
  --radius: 12px;
  --ease-out: cubic-bezier(0.12, 0.23, 0.5, 1);
  --ease-in-out: cubic-bezier(0.44, 0, 0.56, 1);
  /* Framer spring {stiffness: 500, damping: 60, mass: 1}: overdamped, settles in ~714ms.
     Fallback curve for browsers without linear() easing. */
  --spring: cubic-bezier(0.15, 0.75, 0.3, 1);
  --spring-duration: 0.714s;

  --text: 18px;
  --text-lh: 1.35;
  --display: 48px;
  --ticker-h: 37.5vw; /* 540px at 1440 */
  --case-gap: 200px;

  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #000;
  --fg: #fff;
  --muted: rgba(255, 255, 255, 0.6);
  --row-hover: rgba(255, 255, 255, 0.12);
  color-scheme: dark;
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.039 2%, 0.12 4%, 0.215 6%, 0.308 8%, 0.395 10%, 0.508 13%,
      0.602 16%, 0.7 20%, 0.79 25%, 0.853 30%, 0.904 36%, 0.942 43%, 0.965 50%,
      0.983 60%, 0.994 75%, 1);
  }
}

@media (min-width: 810px) and (max-width: 1199.98px) {
  :root {
    --display: 40px;
    --ticker-h: 45vw;
    --case-gap: 160px;
  }
}
@media (max-width: 809.98px) {
  :root {
    --text: 16px;
    --text-lh: 1.5;
    --display: 30px;
    --ticker-h: 56.4vw;
    --case-gap: 120px;
  }
}

/* ------------------------------------------------------------------
   Base
------------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--text);
  line-height: var(--text-lh);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
body.overlay-open {
  overflow: hidden;
}
img,
video,
iframe {
  display: block;
  max-width: none;
}
a {
  color: inherit;
  text-decoration: none;
}
/* Dotted underlines (selected link and hover). Longhands + -webkit- so
   Safari honours the dotted style; 1.5px so the dots read at text size. */
a:hover,
.nav__work,
.nav__contact:hover {
  -webkit-text-decoration-line: underline;
  text-decoration-line: underline;
  -webkit-text-decoration-style: dotted;
  text-decoration-style: dotted;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
p,
h1,
h2,
ul {
  font: inherit;
}
p,
h1,
h2,
ul {
  margin: 0;
  padding: 0;
}
ul {
  list-style: none;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
:focus-visible {
  outline: 1px dotted currentColor;
  outline-offset: 3px;
}
.muted {
  color: var(--muted);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------------
   Navigation
------------------------------------------------------------------ */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 40px;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
/* The page's own nav is drawn in white and blended with "difference", so it
   inverts against whatever scrolls beneath it: black on white, white on black,
   the inverse colour over images. Same rule for both themes. The contact
   overlay's nav row is left out, as it sits on its own frosted panel. */
body > .nav {
  --fg: #fff;
  color: #fff;
  mix-blend-mode: difference;
}
.nav__work {
  justify-self: start;
}
.nav__contact {
  justify-self: end;
}

/* Theme switch */
.switch {
  position: relative;
  width: 32px;
  height: 16px;
  border-radius: 9px;
}
.switch::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px dotted var(--fg);
  border-radius: 9px;
}
.switch__knob {
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  border: 1px solid var(--fg);
  border-radius: 50%;
  background-color: transparent;
  transition: transform var(--spring-duration) var(--spring),
    background-color var(--spring-duration) var(--spring);
}
.switch:hover .switch__knob {
  background-color: var(--fg);
}
:root[data-theme="dark"] .switch__knob {
  transform: translateX(16px);
}

/* ------------------------------------------------------------------
   Intro
------------------------------------------------------------------ */
.intro {
  padding: 200px var(--gutter);
}
.intro h1 {
  max-width: 1178px;
  font-weight: 400;
  font-size: var(--display);
  line-height: 1.05;
  letter-spacing: -1px;
}
.intro a {
  font-family: var(--font-serif);
  font-style: italic;
  letter-spacing: -0.5px;
}

/* ------------------------------------------------------------------
   Case studies
------------------------------------------------------------------ */
.case {
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
  padding-bottom: var(--case-gap);
}

.ticker {
  height: var(--ticker-h);
  overflow: hidden;
  cursor: grab;
  touch-action: pan-y; /* vertical page scroll stays native; horizontal drags scrub */
  user-select: none;
  -webkit-user-select: none;
}
.ticker.is-dragging {
  cursor: grabbing;
}
.ticker__track {
  display: flex;
  gap: var(--gutter);
  height: 100%;
  width: max-content;
  will-change: transform;
}
.ticker__track img {
  height: 100%;
  width: auto;
  border-radius: var(--radius);
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}
.ticker__track img.flat {
  border-radius: 0;
}

.media {
  margin: 0 var(--gutter);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #000;
}
.media video,
.media iframe,
.media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
}

.desc {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: var(--gutter);
  padding: 56px var(--gutter) 0; /* + 8px flex gap = 64px, as original */
}
.desc__body {
  max-width: 475px;
}
@media (max-width: 809.98px) {
  .desc {
    grid-template-columns: 1fr;
    row-gap: 24px;
  }
}

/* ------------------------------------------------------------------
   Client table
------------------------------------------------------------------ */
.clients__title,
.clients__row {
  padding: 16px;
}
.clients__row {
  display: grid;
  grid-template-columns: 1fr 2fr 2fr 1fr;
  column-gap: 16px;
}
/* Each row carries its client's brand colours as --hover-bg / --hover-fg.
   As in the original, script.js adds .is-hot on mouseenter (the colour springs
   fully in, even on a fast swipe) and removes it 1s after mouseleave. */
.clients__list .clients__row {
  transition: background-color var(--spring-duration) var(--spring),
    color var(--spring-duration) var(--spring);
}
.clients__list .clients__row.is-hot,
html:not(.js) .clients__list .clients__row:hover {
  background: var(--hover-bg, var(--row-hover));
  color: var(--hover-fg, inherit);
}
.clients {
  padding-bottom: 160px;
}
@media (max-width: 809.98px) {
  .clients__title,
  .clients__row {
    padding: 16px var(--gutter);
  }
  .clients__row {
    grid-template-columns: 1fr 1fr 2fr;
    column-gap: var(--gutter);
  }
  .clients__row > :nth-child(4) {
    display: none;
  }
}

/* ------------------------------------------------------------------
   Contact panel — mirrors the Framer nav's "Contact" variant.
   Open:  instant; the frosted panel and its content appear at once.
   Close: content disappears at once. The panel is then the 40px nav bar
          stretched to full height (scaleY), springing back to 1 while its
          tint (0.8 -> 0) and blur (16px -> 0) spring out with it.
          Because the blur is applied before the stretch, it smears
          vertically over the page as the panel retracts — as in Framer.
------------------------------------------------------------------ */
:root {
  --panel-bg: rgba(255, 255, 255, 0.8);
  --panel-bg-clear: rgba(255, 255, 255, 0);
}
:root[data-theme="dark"] {
  --panel-bg: rgba(0, 0, 0, 0.5);
  --panel-bg-clear: rgba(0, 0, 0, 0);
}
.contact {
  position: fixed;
  inset: 0;
  /* Just below the page nav (20), so the nav text stays crisp on top of the
     retracting panel; while open the page nav is hidden and the panel's own
     nav row takes its place. */
  z-index: 19;
  color: var(--fg);
  overflow-y: auto;
  pointer-events: none;
}
/* Closed (resting) state: a clear 40px strip tucked into the nav bar */
.contact__panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 40px;
  transform-origin: top;
  transform: scaleY(1);
  background-color: var(--panel-bg-clear);
  -webkit-backdrop-filter: blur(0px);
  backdrop-filter: blur(0px);
  pointer-events: none;
  transition: transform var(--spring-duration) var(--spring),
    background-color var(--spring-duration) var(--spring),
    -webkit-backdrop-filter var(--spring-duration) var(--spring),
    backdrop-filter var(--spring-duration) var(--spring);
}
.contact.is-open {
  pointer-events: auto;
}
/* Open: full-height frosted panel, no transition */
.contact.is-open .contact__panel {
  height: 100%;
  transform: none;
  background-color: var(--panel-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  transition: none;
}
/* First frame of closing (set by script.js): back to the 40px strip, but
   stretched to cover the screen, still fully tinted and blurred */
.contact.is-closing .contact__panel {
  transform: scaleY(var(--panel-stretch, 22.5));
  background-color: var(--panel-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  transition: none;
}
/* Content swaps instantly, both ways */
.contact > .nav,
.contact__inner {
  position: relative;
  visibility: hidden;
}
.contact.is-open > .nav,
.contact.is-open .contact__inner {
  visibility: visible;
}
/* The page's own nav row swaps for the panel's (same positions) */
body.overlay-open > .nav {
  visibility: hidden;
}
/* While Contact is open, Work and the switch dim to 20% (still clickable).
   As in Framer: they dim instantly on open and spring back on close. */
.nav > .nav__work,
.nav > .switch {
  transition: opacity var(--spring-duration) var(--spring);
}
.contact > .nav > .nav__work,
.contact > .nav > .switch,
body.overlay-open > .nav > .nav__work,
body.overlay-open > .nav > .switch {
  opacity: 0.2;
  transition: none;
}
.contact__inner {
  min-height: calc(100% - 40px);
  display: grid;
  grid-template-columns: 1fr 346px;
  grid-template-rows: 1fr auto;
  column-gap: var(--gutter);
  padding: 200px var(--gutter) var(--gutter);
}
.contact__links {
  font-size: var(--display);
  line-height: 1;
  letter-spacing: -1px;
}
.contact__links a {
  display: inline-block;
}
.contact__portrait {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: start;
  width: 346px;
  height: auto;
  aspect-ratio: 346 / 652; /* original crop */
  max-height: calc(100vh - 248px);
  object-fit: cover;
  border-radius: var(--radius);
}
.contact__footer {
  grid-row: 2;
  align-self: end;
  color: var(--muted);
}
@media (max-width: 809.98px) {
  .contact__inner {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    row-gap: 40px;
    padding-top: 120px;
  }
  .contact__portrait {
    grid-row: 2;
    grid-column: 1;
    width: min(240px, 60vw);
    max-height: none;
  }
  .contact__footer {
    grid-row: 3;
  }
}

/* ------------------------------------------------------------------
   Appear animations (mirrors Framer's 0.9s tween, 150px rise)
------------------------------------------------------------------ */
.js .nav {
  animation: nav-in 0.9s var(--ease-out) both;
}
@keyframes nav-in {
  from {
    opacity: 0;
    transform: translateY(-150px);
  }
}
.js [data-reveal] {
  opacity: 0;
  transform: translateY(150px);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
}
.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .js .nav {
    animation: none;
  }
  .js [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .contact__panel,
  .switch__knob,
  .nav > .nav__work,
  .nav > .switch {
    transition: none;
  }
}
