/* ==========================================================================
   cnam.ee — Domain OÜ
   ULTRAMARINE v1.2 — scroll-driven. Pinned scenes, scrubbed by the reader.
   ========================================================================== */

@font-face {
  font-family: "Instrument Serif";
  src: url("/assets/fonts/instrument-serif-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("/assets/fonts/instrument-serif-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --blue: #1e2be0;
  --cream: #f5f2e8;
  --cream-dim: rgba(245, 242, 232, 0.66);
  --cream-faint: rgba(245, 242, 232, 0.42);
  --cream-ghost: rgba(245, 242, 232, 0.07);
  --hairline: rgba(245, 242, 232, 0.16);
  --blue-dim: rgba(30, 43, 224, 0.62);
  --blue-ghost: rgba(30, 43, 224, 0.1);
  --bg: #1e2be0;
  --band-bg: #f5f2e8;
  --band-fg: #1e2be0;
  --band-dim: rgba(30, 43, 224, 0.62);
  --band-faint: rgba(30, 43, 224, 0.45);
  --band-ghost: rgba(30, 43, 224, 0.1);
  --band-hairline: rgba(30, 43, 224, 0.18);
  --band-rail: rgba(30, 43, 224, 0.16);
  --serif: "Instrument Serif", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.19, 1, 0.22, 1);
}


/* ---------- Night mode: deep blue-black, bands invert to ultramarine ---------- */
:root[data-theme="dark"] {
  --bg: #090a1e;
  --band-bg: #1822b3;
  --band-fg: #f5f2e8;
  --band-dim: rgba(245, 242, 232, 0.66);
  --band-faint: rgba(245, 242, 232, 0.45);
  --band-ghost: rgba(245, 242, 232, 0.07);
  --band-hairline: rgba(245, 242, 232, 0.16);
  --band-rail: rgba(245, 242, 232, 0.16);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="blue"]) {
    --bg: #090a1e;
    --band-bg: #1e2be0;
    --band-fg: #f5f2e8;
    --band-dim: rgba(245, 242, 232, 0.66);
    --band-faint: rgba(245, 242, 232, 0.45);
    --band-ghost: rgba(245, 242, 232, 0.07);
    --band-hairline: rgba(245, 242, 232, 0.16);
    --band-rail: rgba(245, 242, 232, 0.16);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
}

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

body {
  background: var(--bg);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  min-height: 100svh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Cross-page transitions ---------- */
@view-transition {
  navigation: auto;
}

.top .home {
  view-transition-name: brand;
}

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) {
    animation: vt-out 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
  }

  ::view-transition-new(root) {
    animation: vt-in 0.7s var(--ease) both;
  }
}

@keyframes vt-out {
  to {
    opacity: 0;
    transform: translateY(-26px);
  }
}

@keyframes vt-in {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
}

/* ---------- Atmosphere ---------- */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 31;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(closest-side, rgba(245, 242, 232, 0.055), transparent 72%);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.6s ease;
}

.glow.on {
  opacity: 1;
}

@media (pointer: coarse), (prefers-reduced-motion: reduce) {
  .glow {
    display: none;
  }
}

::selection {
  background: var(--cream);
  color: var(--blue);
}

:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 3px;
}

a {
  color: var(--cream);
}

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

.wrap {
  width: min(1280px, calc(100% - clamp(32px, 6vw, 100px)));
  margin-inline: auto;
  position: relative;
  z-index: 2;
}

/* ---------- Top ---------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px 32px;
  flex-wrap: wrap;
  padding-block: 24px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
}

.top .home {
  font-family: var(--serif);
  font-size: 1.3rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.top .home em {
  font-style: italic;
}

.top nav {
  display: flex;
  gap: 26px;
}

.top nav a,
.top .mail {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--cream-dim);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-size: 0% 1px;
  background-position: 0 100%;
  padding-bottom: 3px;
  transition: color 0.2s ease, background-size 0.35s var(--ease);
}

.top nav a:hover,
.top .mail:hover {
  color: var(--cream);
  background-size: 100% 1px;
}

.top nav a[aria-current="page"] {
  color: var(--cream);
  background-size: 100% 1px;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mode {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: none;
  color: var(--cream-dim);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.mode:hover {
  color: var(--cream);
  border-color: var(--cream-faint);
  transform: rotate(180deg);
}

@media (max-width: 619px) {
  .top nav {
    gap: 18px;
  }

  .top .mail {
    display: none;
  }
}

/* ==========================================================================
   SCENES — pinned stages scrubbed by scroll.
   .anim is set by JS only when motion is allowed; without it, everything
   below falls back to a normal static document.
   ========================================================================== */

.scene {
  position: relative;
}

.stage {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: clamp(48px, 8vh, 96px);
}

.anim .stage {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: clip;
}

/* ---------- Scene 1 · Hero zoom ---------- */
.anim .scene-hero {
  height: 240vh;
}

.scene-hero .stage {
  justify-content: flex-end;
  padding-top: clamp(120px, 15vh, 160px);
  padding-bottom: clamp(40px, 7vh, 84px);
}

.wm-zoom {
  transform-origin: 64% 72%;
  will-change: transform, opacity;
}

.anim .wm-zoom {
  transform: scale(calc(1 + var(--p, 0) * var(--zmax, 5.4)));
  opacity: calc(1 - clamp(0, (var(--p, 0) - 0.52) * 2.6, 1));
}

.wordmark {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(5rem, 19.4vw, 16rem);
  line-height: 0.94;
  letter-spacing: -0.045em;
  margin-left: -0.05em;
  padding-bottom: 0.03em;
  overflow: hidden;
}

.wordmark .l {
  display: inline-block;
}

.wordmark .it {
  font-style: italic;
  letter-spacing: -0.02em;
}

@media (prefers-reduced-motion: no-preference) {
  .wordmark .l {
    animation: rise-in 1s var(--ease) calc(0.07s * var(--i, 0) + 0.05s) both;
  }

  .hero-intro {
    animation: fade-up 0.9s ease 0.75s both;
  }
}

@keyframes rise-in {
  from {
    transform: translateY(112%);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

.hero-intro {
  max-width: 56ch;
  font-size: clamp(1.02rem, 1.5vw, 1.16rem);
  color: var(--cream-dim);
  margin-top: clamp(30px, 5vh, 60px);
}

.anim .hero-intro {
  opacity: calc(1 - var(--p, 0) * 2.6);
}

.hero-intro strong {
  color: var(--cream);
  font-weight: 500;
}

.cue {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cream-faint);
  display: none;
}

.anim .cue {
  display: block;
  opacity: calc(1 - var(--p, 0) * 7);
}

.cue::after {
  content: "";
  display: block;
  width: 1px;
  height: 34px;
  margin: 10px auto 0;
  background: var(--cream-faint);
}

@media (prefers-reduced-motion: no-preference) {
  .cue::after {
    animation: cue-drop 1.8s var(--ease) infinite;
  }
}

@keyframes cue-drop {
  0% {
    transform: scaleY(0);
    transform-origin: top;
  }
  45% {
    transform: scaleY(1);
    transform-origin: top;
  }
  55% {
    transform: scaleY(1);
    transform-origin: bottom;
  }
  100% {
    transform: scaleY(0);
    transform-origin: bottom;
  }
}

/* ---------- Scene 2 · Services trilogy ---------- */
.anim .scene-services {
  height: 440vh;
}

.slides {
  position: relative;
  width: 100%;
}

.slide {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  max-width: 46em;
}

.anim .slide {
  position: absolute;
  inset: auto 0;
  top: 50%;
  translate: 0 -50%;
  opacity: 0;
  will-change: transform, opacity;
}

/* static fallback: slides stack as normal sections */
html:not(.anim) .slide {
  padding-block: clamp(36px, 6vh, 64px);
}

html:not(.anim) .slide + .slide {
  border-top: 1px solid var(--hairline);
}

.slide h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.6rem, 7.4vw, 5.6rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.slide h2 em {
  font-style: italic;
}

.slide p {
  color: var(--cream-dim);
  max-width: 56ch;
  font-size: clamp(1rem, 1.4vw, 1.12rem);
}

.slide .tag {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cream-faint);
}

/* giant ghost numerals, right side */
.numerals {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--serif);
  font-size: clamp(9rem, 30vw, 26rem);
  line-height: 1;
  color: var(--cream-ghost);
  pointer-events: none;
  display: none;
}

.anim .numerals {
  display: block;
}

.numerals span {
  position: absolute;
  right: 0;
  top: 50%;
  translate: 0 -50%;
  opacity: 0;
  will-change: transform, opacity;
}

/* progress rail */
.rail {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 38vh;
  background: var(--hairline);
  display: none;
}

.anim .rail {
  display: block;
}

.rail i {
  position: absolute;
  inset: 0;
  background: var(--cream);
  transform: scaleY(var(--p, 0));
  transform-origin: top;
}

.scene-services .stage-inner {
  position: relative;
  width: 100%;
  padding-left: clamp(0px, 3vw, 40px);
}

.sec-label {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cream-faint);
}

.scene-services .sec-label {
  margin-bottom: clamp(24px, 4vh, 40px);
}

.anim .scene-services .sec-label {
  position: absolute;
  top: 12vh;
  left: clamp(0px, 3vw, 40px);
  margin: 0;
}

/* ---------- Scene 3 · Statement scrub (inverted) ---------- */
.anim .scene-statement {
  height: 220vh;
}

.scene-statement .stage {
  background: var(--band-bg);
  color: var(--band-fg);
}

.scene-statement ::selection {
  background: var(--band-fg);
  color: var(--band-bg);
}

.statement {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 5.8vw, 4.6rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  max-width: 17em;
}

.statement em {
  font-style: italic;
}

.statement .sw {
  display: inline-block;
}

.anim .statement .sw {
  opacity: 0.14;
  transform: translateY(0.18em);
  will-change: opacity, transform;
}

.scene-statement .sec-label {
  color: var(--band-dim);
  margin-bottom: clamp(24px, 4vh, 40px);
}

/* ---------- Cream scene variant (works with slides + words) ---------- */
.scene-cream .stage {
  background: var(--band-bg);
  color: var(--band-fg);
}

.scene-cream ::selection {
  background: var(--band-fg);
  color: var(--band-bg);
}

.scene-cream .sec-label {
  color: var(--band-dim);
}

.scene-cream .slide p {
  color: var(--band-dim);
}

.scene-cream .slide .tag {
  color: var(--band-faint);
}

.scene-cream .numerals {
  color: var(--band-ghost);
}

.scene-cream .rail {
  background: var(--band-rail);
}

.scene-cream .rail i {
  background: var(--band-fg);
}

html:not(.anim) .scene-cream .slide + .slide {
  border-top-color: var(--band-hairline);
}

/* ---------- Email grow scene (contact) ---------- */
.anim .scene-email {
  height: 230vh;
}

.scene-email .sec-label {
  margin-bottom: clamp(24px, 4vh, 40px);
}

.email-grow {
  transform-origin: 0% 62%;
  will-change: transform, opacity;
}

.anim .email-grow {
  transform: scale(calc(0.34 + var(--p, 0) * 0.66));
  opacity: calc(0.15 + var(--p, 0) * 0.85);
}

.anim .scene-email .contact-sub {
  opacity: calc(var(--p, 0) * 1.7 - 0.5);
}

/* ---------- Generic inner-page pieces ---------- */
section.plain {
  padding-block: clamp(56px, 10vh, 120px);
}

.sec {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 28px clamp(32px, 5vw, 80px);
  align-items: start;
}

.sec > .sec-label {
  position: sticky;
  top: 28px;
}

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

  .sec > .sec-label {
    position: static;
  }
}

.page-hero {
  padding-block: clamp(130px, 18vh, 190px) clamp(20px, 4vh, 44px);
}

.page-hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3rem, 9.4vw, 7.6rem);
  line-height: 1;
  letter-spacing: -0.035em;
  margin-left: -0.03em;
  margin-bottom: clamp(24px, 4vh, 40px);
  max-width: 11em;
}

.page-hero h1 em {
  font-style: italic;
}

.page-hero h1 .w {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  padding-bottom: 0.06em;
  margin-bottom: -0.06em;
}

.page-hero h1 .wi {
  display: inline-block;
}

@media (prefers-reduced-motion: no-preference) {
  .page-hero h1 .wi {
    animation: rise-in 0.95s var(--ease) calc(0.08s * var(--i, 0) + 0.05s) both;
  }

  .page-hero .lede {
    animation: fade-up 0.9s ease 0.6s both;
  }
}

.lede {
  max-width: 56ch;
  font-size: clamp(1.02rem, 1.5vw, 1.18rem);
  color: var(--cream-dim);
}

.lede .sw {
  display: inline-block;
}

.anim .lede[data-scrub] .sw {
  opacity: 0.24;
  transform: translateY(0.18em);
}

.prose p {
  color: var(--cream-dim);
  max-width: 62ch;
  margin-bottom: 1.25em;
}

.prose strong {
  color: var(--cream);
  font-weight: 500;
}

.company-line {
  font-size: 0.86rem;
  color: var(--cream-faint);
}

/* how we work */
.ways {
  list-style: none;
  padding: 0;
}

.way {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 10px clamp(28px, 4vw, 64px);
  padding-block: clamp(24px, 3.6vh, 40px);
  transition: opacity 0.3s ease;
}

.way:first-child {
  padding-top: 0;
}

.way + .way {
  border-top: 1px solid var(--hairline);
}

.ways:hover .way {
  opacity: 0.45;
}

.ways .way:hover {
  opacity: 1;
}

.way h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.5rem, 2.9vw, 2.2rem);
  line-height: 1.08;
  letter-spacing: -0.018em;
}

.way h2 em {
  font-style: italic;
}

.way p {
  color: var(--cream-dim);
  max-width: 54ch;
  align-self: center;
}

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

/* ---------- Contact ---------- */
.email {
  display: inline-block;
  font-family: var(--serif);
  font-size: clamp(2.6rem, 9vw, 7.4rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-size: 0% 0.045em;
  background-position: 0 96%;
  transition: background-size 0.6s var(--ease);
  overflow-wrap: anywhere;
  will-change: transform;
}

.email:hover,
.email:focus-visible {
  background-size: 100% 0.045em;
}

.contact-sub {
  margin-top: 26px;
  color: var(--cream-dim);
  max-width: 54ch;
}

.contact-hints {
  margin-top: clamp(36px, 6vh, 56px);
  color: var(--cream-faint);
  font-size: 0.92rem;
  max-width: 54ch;
}

.contact-hints strong {
  color: var(--cream-dim);
  font-weight: 500;
}

/* ---------- Contact form ---------- */
.form {
  max-width: 620px;
}

.hp {
  position: absolute !important;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 32px;
}

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

.field {
  display: block;
  margin-bottom: 30px;
}

.field-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cream-faint);
  margin-bottom: 10px;
}

.field input,
.field textarea {
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  color: var(--cream);
  font: inherit;
  font-size: 1.05rem;
  padding: 4px 0 12px;
  transition: border-color 0.25s ease;
}

.field textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-bottom-color: var(--cream);
}

.send {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  background: none;
  border: 0;
  padding: 0;
  margin-top: 6px;
  cursor: pointer;
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
  color: var(--cream);
}

.send em {
  font-style: italic;
}

.send .arrow {
  transition: transform 0.5s var(--ease);
}

.send:hover .arrow {
  transform: translateX(0.35em);
}

.send[disabled] {
  opacity: 0.5;
  cursor: wait;
}

.form-status {
  margin-top: 18px;
  font-size: 0.92rem;
  color: var(--cream-dim);
  min-height: 1.4em;
}

.form-status.err {
  color: #ffb2a0;
}

/* ---------- Next page link ---------- */
.next-block {
  padding-block: clamp(56px, 11vh, 130px) 0;
}

.next-label {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cream-faint);
  margin-bottom: 16px;
}

.next {
  display: inline-block;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 7.4vw, 6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.next em {
  font-style: italic;
}

.next .arrow {
  display: inline-block;
  transition: transform 0.5s var(--ease);
}

.next:hover .arrow {
  transform: translateX(0.35em);
}

/* ---------- Footer ---------- */
footer {
  padding-top: clamp(40px, 8vh, 90px);
}

.foot-mark {
  height: 0.56em;
  overflow: hidden;
  font-family: var(--serif);
  font-size: clamp(5rem, 21.5vw, 18rem);
  line-height: 0.82;
  letter-spacing: -0.045em;
  margin-left: -0.05em;
  user-select: none;
}

.foot-mark em {
  font-style: italic;
  color: var(--cream-dim);
}

.foot-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px 36px;
  margin-top: 14px;
  padding-block: 20px clamp(24px, 4vh, 40px);
  font-size: 0.8rem;
  color: var(--cream-faint);
}

.foot-nav {
  display: flex;
  gap: 20px;
}

.foot-nav a {
  color: var(--cream-faint);
  text-decoration: none;
  transition: color 0.2s ease;
}

.foot-nav a:hover {
  color: var(--cream);
}

/* ---------- Mobile motion tuning ---------- */
@media (max-width: 719px) {
  .scene-hero {
    --zmax: 3.2;
  }

  .anim .scene-hero {
    height: 190vh;
  }

  .anim .scene-services {
    height: 340vh;
  }

  .anim .scene-statement {
    height: 170vh;
  }

  .anim .scene-email {
    height: 180vh;
  }

  .anim .rail {
    display: none;
  }
}

/* ---------- Scroll reveals ---------- */
.lm {
  overflow: hidden;
}

@media (prefers-reduced-motion: no-preference) {
  .js .lm .lm-i {
    transform: translateY(115%);
    transition: transform 1s var(--ease);
    transition-delay: var(--d, 0s);
  }

  .js .lm.in .lm-i {
    transform: none;
  }

  .js .rv {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.9s var(--ease);
    transition-delay: var(--d, 0s);
  }

  .js .rv.in {
    opacity: 1;
    transform: none;
  }
}
