/* =========================================================
   Henri Järvenpää — portfolio
   ========================================================= */

:root {
  --ink: #231F20;
  --paper: #ffffff;
  --placeholder: #58595B;
  --green: #00FF90;
  --magenta: #FC02A3;

  --header-h: clamp(62px, 5.4vw, 108px);

  /* text column: 17% / 83% like the layout */
  --container: 1310px;
  --grid-max: 1050px;

  --font-display: "Bitter", Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;

  /* logo aspect ratios — match the tightened viewBoxes in /assets */
  --mark-ratio: 1.408;
  --lockup-ratio: 1.561;
  --lockup-full-ratio: 1.403;
}

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

html {
  /* Lenis drives scrolling; keep the native fallback sane */
  scroll-behavior: smooth;
}

html.lenis, html.lenis body { height: auto; }
/* once Lenis is running, native smooth scrolling must stay out of its way —
   keyed on .lenis, not .lenis-smooth, which Lenis toggles at runtime */
html.lenis { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: clamp(16px, 1.05vw, 20px);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }

a { color: inherit; }

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

.skip-link {
  position: fixed;
  top: 8px; left: 8px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px;
  transform: translateY(-200%);
  transition: transform .2s ease;
}
.skip-link:focus-visible { transform: none; }

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

/* text column: ~17% margins like the layout, capped on very wide screens */
.container {
  width: min(var(--container), 100% - 2 * clamp(24px, 16vw, 310px));
  margin-inline: auto;
}

/* ---------------------------------------------------------
   Header
   --------------------------------------------------------- */

.header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding-inline: clamp(20px, 3.4vw, 64px);
  background: var(--ink);
  color: var(--paper);
  transition: height .4s cubic-bezier(.22,1,.36,1);
  will-change: height;
}

.header.is-compact { height: calc(var(--header-h) * .62); }

.burger {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 56px; height: 56px;
  margin-left: -10px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

.burger__box {
  display: block;
  width: 42px;
  height: 26px;
  position: relative;
}

.burger__bar {
  position: absolute;
  left: 0;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: 50% 50%;
}
.burger__bar:nth-child(1) { top: 0; }
.burger__bar:nth-child(2) { top: 11px; }
.burger__bar:nth-child(3) { top: 22px; }

.header__mark {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: clamp(56px, 4.1vw, 82px);
  aspect-ratio: var(--mark-ratio);
  background-color: currentColor;
  -webkit-mask: url("assets/mark.svg") no-repeat center / contain;
  mask: url("assets/mark.svg") no-repeat center / contain;
  transition: width .4s cubic-bezier(.22,1,.36,1), opacity .3s ease;
}
.header__mark:hover { opacity: .7; }

/* shrinks with the bar once you start scrolling */
.header.is-compact .header__mark { width: clamp(42px, 3vw, 58px); }

/* ---------------------------------------------------------
   Menu overlay
   --------------------------------------------------------- */

.menu {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  clip-path: inset(0 0 100% 0);
  visibility: hidden;
}

.menu__inner {
  width: min(var(--container), 100% - 2 * clamp(24px, 6vw, 64px));
  padding-top: var(--header-h);
}

.menu__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu__item { overflow: hidden; }

.menu__item a {
  display: inline-block;
  padding: .12em 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.4rem, 8vw, 6rem);
  line-height: 1.12;
  text-decoration: none;
}

/* the link itself is GSAP's; the label carries the hover motion */
.menu__label {
  display: inline-block;
  transition: opacity .3s ease, transform .5s cubic-bezier(.22,1,.36,1);
}
.menu__item a:hover .menu__label { opacity: .55; transform: translateX(18px); }

.menu__meta {
  margin: clamp(24px, 4vw, 48px) 0 0;
  font-size: 1.05rem;
  letter-spacing: .02em;
  opacity: .7;
}
.menu__meta a { text-decoration: none; border-bottom: 1px solid currentColor; }

/* ---------------------------------------------------------
   Hero
   --------------------------------------------------------- */

.hero {
  position: relative;
  display: grid;
  place-items: center;
  /* one full screen; the bottom padding keeps the lockup clear of the wave */
  min-height: 100svh;
  padding: var(--header-h) 24px clamp(120px, 22vh, 300px);
}

.hero__lockup {
  width: clamp(220px, 21vw, 400px);
  aspect-ratio: var(--lockup-ratio);
  background-color: var(--ink);
  -webkit-mask: url("assets/lockup.svg") no-repeat center / contain;
  mask: url("assets/lockup.svg") no-repeat center / contain;
  will-change: transform, opacity;
}

/* ---------------------------------------------------------
   Wave
   --------------------------------------------------------- */

.wave-section {
  position: relative;
  overflow: hidden;
  /* pulled up so the crest already breaks into the hero screen */
  margin-top: clamp(-460px, -36vh, -130px);
  /* the ribbon needs breathing room above and below */
  padding-block: clamp(20px, 4vw, 60px);
}

.wave {
  display: block;
  width: 100%;
  height: clamp(360px, 48vw, 920px);
  overflow: visible;
}

.wave--footer {
  position: absolute;
  left: 0;
  right: 0;
  /* overlaps the footer by 2px: any antialiased edge row lands on dark, not
     on the white page, so there is no hairline seam */
  bottom: calc(100% - 2px);
  height: clamp(110px, 13vw, 240px);
  overflow: hidden;
}

/* ---------------------------------------------------------
   Prose blocks
   --------------------------------------------------------- */

.prose { padding-block: clamp(70px, 9vw, 150px); }
.prose--last { padding-bottom: clamp(90px, 12vw, 200px); }

.prose__title {
  margin: 0 0 .85em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.15rem, 1.2vw, 1.4rem);
  letter-spacing: .005em;
}

/* split heading pieces (see splitIntoChars in main.js) */
.word { display: inline-block; }
.char { display: inline-block; }

.prose__body {
  margin: 0;
  max-width: 92ch;
  font-size: clamp(1rem, 1.02vw, 1.18rem);
  line-height: 1.62;
}

/* ---------------------------------------------------------
   Work grid
   --------------------------------------------------------- */

.work {
  padding-block: clamp(30px, 5vw, 70px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(20px, 3.9vw, 74px);
  width: min(var(--grid-max), 55vw, 100% - 2 * clamp(24px, 8vw, 64px));
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.tile { will-change: transform, opacity; }

.tile__link {
  display: block;
  border-radius: 14%;
  overflow: hidden;
  text-decoration: none;
  transition: transform .6s cubic-bezier(.22,1,.36,1);
}
.tile__link:hover { transform: translateY(-8px); }

.tile__media {
  display: block;
  aspect-ratio: 1 / 1.03;
  background: var(--placeholder);
  transition: filter .6s ease, transform .8s cubic-bezier(.22,1,.36,1);
}
.tile__link:hover .tile__media { filter: brightness(1.12); transform: scale(1.03); }

/* ---------------------------------------------------------
   Footer
   --------------------------------------------------------- */

.footer {
  position: relative;
  margin-top: clamp(110px, 13vw, 240px);
  background: var(--ink);
  color: var(--paper);
}

.footer__inner {
  width: min(var(--container), 100% - 2 * clamp(24px, 6vw, 64px));
  margin-inline: auto;
  padding-block: clamp(50px, 7vw, 120px) clamp(36px, 4vw, 64px);
  display: grid;
  gap: clamp(28px, 4vw, 56px);
  justify-items: center;
  text-align: center;
}

.footer__lockup {
  width: clamp(190px, 17vw, 300px);
  aspect-ratio: var(--lockup-full-ratio);
  background-color: var(--paper);
  -webkit-mask: url("assets/lockup-full.svg") no-repeat center / contain;
  mask: url("assets/lockup-full.svg") no-repeat center / contain;
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(18px, 2.4vw, 44px);
  margin: 0; padding: 0;
  list-style: none;
  font-size: 1.02rem;
}
.footer__links a {
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(255,255,255,.35);
  transition: border-color .3s ease, opacity .3s ease;
}
.footer__links a:hover { border-color: var(--paper); opacity: .8; }

.footer__copy {
  margin: 0;
  font-size: .95rem;
  opacity: .55;
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */

@media (max-width: 760px) {
  .container { width: calc(100% - 48px); }

  .burger__box { width: 34px; height: 22px; }
  .burger__bar { height: 3px; }
  .burger__bar:nth-child(2) { top: 9.5px; }
  .burger__bar:nth-child(3) { top: 19px; }

  .hero__lockup { width: min(62vw, 300px); }

  .grid {
    grid-template-columns: 1fr;
    width: min(420px, 100% - 48px);
    gap: 24px;
  }
}

/* ---------------------------------------------------------
   Reduced motion
   --------------------------------------------------------- */

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