/* ==========================================================================
   Kodelig — design tokens
   ========================================================================== */

@font-face {
  font-family: 'Schibsted Grotesk';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/schibsted-grotesk.woff2') format('woff2');
}
@font-face {
  font-family: 'Karla';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/karla.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/jetbrains-mono.woff2') format('woff2');
}

:root {
  /* colour — Arctic fjord + midnight-sun */
  --ink-950: #0B1A28;
  --ink-900: #0F2032;
  --ink-800: #13293E;
  --ink-700: #1C384F;
  --ink-600: #2E5268;
  --ink-500: #3E5F76;

  --mist: #F4F6F5;
  --muted: #92A5B8;

  --gold: #E8A855;
  --gold-soft: #F6D9A8;
  --aurora: #3E7A6D;

  --bg: var(--ink-950);
  --panel: var(--ink-800);
  --border: var(--ink-700);
  --text: var(--mist);
  --text-muted: var(--muted);
  --accent: var(--gold);

  /* type */
  --font-display: 'Schibsted Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Karla', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;

  /* space (4px rhythm) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --space-9: 6.5rem;
  --space-10: 9rem;

  --container: 72rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);

  --radius-sm: 8px;
  --radius-md: 16px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 180ms;
  --dur-base: 500ms;
}

/* ==========================================================================
   Reset
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* film-grain overlay — quiets the flat dark gradients */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 500;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ==========================================================================
   Layout helpers
   ========================================================================== */

.wrap {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -3rem;
  background: var(--gold);
  color: var(--ink-950);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  z-index: 1000;
  transition: top var(--dur-fast) var(--ease-out);
}
.skip-link:focus {
  top: var(--space-4);
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: absolute;
  inset-inline: 0;
  top: 0;
  z-index: 20;
  padding-top: var(--space-6);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-mark {
  width: 30px;
  height: 30px;
  color: var(--gold);
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--mist);
}

/* ==========================================================================
   Eyebrow / section kickers (semantic h2, styled small)
   ========================================================================== */

.eyebrow {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.8125rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 var(--space-4);
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  background: var(--ink-950);
}

.hero-art {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

.hero-photo {
  /* 10% taller than its box, so the scroll-parallax translate always has
     bleed to reveal instead of exposing an empty edge */
  position: absolute;
  top: -10%;
  left: 0;
  right: 0;
  bottom: -10%;
  width: 100%;
  height: 120%;
  object-fit: cover;
  object-position: 63% 40%;
}

.hero-glow {
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
  background: radial-gradient(ellipse 55% 42% at 66% 82%,
    rgba(246, 217, 168, 0.55) 0%,
    rgba(232, 168, 85, 0.22) 45%,
    rgba(232, 168, 85, 0) 72%);
}

.hero-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(100deg,
      rgba(8, 15, 24, 0.86) 0%,
      rgba(8, 15, 24, 0.64) 30%,
      rgba(8, 15, 24, 0.28) 55%,
      rgba(8, 15, 24, 0.08) 76%),
    linear-gradient(to top,
      rgba(8, 15, 24, 0.6) 0%,
      rgba(8, 15, 24, 0) 28%);
}

@media (max-width: 40em) {
  /* narrow crops zoom into the photo's brightest rock face, and the text
     column spans nearly the full width — the desktop left-to-right scrim
     doesn't cover enough of it, so fall back to a strong, even wash */
  .hero-scrim {
    background:
      linear-gradient(rgba(6, 12, 20, 0.6), rgba(6, 12, 20, 0.6)),
      linear-gradient(to top,
        rgba(6, 12, 20, 0.7) 0%,
        rgba(6, 12, 20, 0.35) 30%,
        rgba(6, 12, 20, 0.45) 65%,
        rgba(6, 12, 20, 0.7) 100%);
  }
}

/* ==========================================================================
   Hero terminal — decorative "statement" piece. Stacked full-width below the
   text on narrow viewports (there's no side-by-side room); becomes a column
   beside the text from 64em up. Hidden only in the short/landscape case
   where the lede already gets dropped to keep the hero fitting on-screen.
   ========================================================================== */

.hero-terminal {
  margin-top: var(--space-6);
  border-radius: var(--radius-md);
  background: rgba(15, 30, 45, 0.42);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(244, 246, 245, 0.14);
  box-shadow: 0 24px 60px rgba(3, 8, 14, 0.45), 0 1px 0 rgba(244, 246, 245, 0.06) inset;
  overflow: hidden;
}

@media (min-width: 64em) {
  /* grid, not absolute positioning: a text column that can grow its own
     font-size (the h1's clamp() tracks viewport width, not this container)
     next to a fixed-width terminal column drifted apart or collided at
     various widths when it was guesswork percentages — grid reserves real
     track space for both, so they can't overlap regardless of exactly how
     wide the heading gets */
  .hero-inner {
    display: grid;
    grid-template-columns: 1fr min(21vw, 340px);
    align-items: center;
    column-gap: clamp(1.5rem, 4vw, 4rem);
  }

  .hero-terminal {
    margin-top: 0;
  }
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(244, 246, 245, 0.1);
}

.term-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(244, 246, 245, 0.28);
}

.term-title {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.term-body {
  height: 165px;
  overflow: hidden;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.7;
  white-space: pre;
}

@media (min-width: 64em) {
  .term-body { height: 258px; }
}

.term-body > div {
  min-height: 1.7em;
}

.term-cmd { color: var(--mist); }
.term-ok { color: var(--gold-soft); }
.term-code { color: var(--muted); }
.term-dim { color: var(--muted); opacity: 0.75; }

.term-cursor {
  display: inline-block;
  width: 6px;
  height: 1em;
  background: var(--gold);
  margin-left: 1px;
  vertical-align: text-bottom;
}

@media (prefers-reduced-motion: no-preference) {
  .term-cursor { animation: term-blink 1s step-end infinite; }
}

@keyframes term-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .hero-glow { animation: glow 7s ease-in-out infinite alternate; }

  /* scroll parallax targets — updated from js/main.js while the hero is in view */
  .hero-photo, .hero-glow {
    will-change: transform;
  }
}

@keyframes glow {
  from { opacity: 0.58; }
  to   { opacity: 1; }
}

.hero-inner {
  position: relative;
  z-index: 2;
}

.hero-content {
  position: relative;
  padding-top: var(--space-10);
  padding-bottom: var(--space-8);
}

.hero-content .eyebrow { color: var(--gold-soft); }

.hero h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.75rem, 2.1rem + 3.6vw, 5.25rem);
  line-height: 1.03;
  letter-spacing: -0.02em;
  color: var(--mist);
  max-width: 16ch;
}

.hero h1 em {
  font-style: normal;
  color: var(--gold);
}

.hero .lede {
  margin-top: var(--space-5);
  font-size: clamp(1.0625rem, 1rem + 0.4vw, 1.3125rem);
  line-height: 1.55;
  color: var(--muted);
  max-width: 38ch;
}

.scroll-cue {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  align-self: flex-start;
  margin: var(--space-7) var(--gutter) var(--space-7);
  padding: var(--space-2) var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color var(--dur-fast) var(--ease-out);
}
.scroll-cue:hover,
.scroll-cue:focus-visible { color: var(--gold-soft); }

.scroll-cue-line {
  width: 1px;
  height: 28px;
  background: currentColor;
  opacity: 0.6;
}
@media (prefers-reduced-motion: no-preference) {
  .scroll-cue-line { animation: pulse-line 2.2s ease-in-out infinite; }
}
@keyframes pulse-line {
  0%, 100% { transform: scaleY(1); opacity: 0.35; }
  50%      { transform: scaleY(0.55); opacity: 0.8; }
}

/* ==========================================================================
   Reveal-on-scroll (progressive enhancement — see js/main.js)
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
  .js .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
  }
  .js .reveal.is-visible { opacity: 1; transform: none; }

  .js .hero-content > * {
    opacity: 0;
    transform: translateY(14px);
    animation: rise var(--dur-base) var(--ease-out) forwards;
  }
  .js .hero-content > *:nth-child(1) { animation-delay: 80ms; }
  .js .hero-content > *:nth-child(2) { animation-delay: 180ms; }
  .js .hero-content > *:nth-child(3) { animation-delay: 300ms; }
  @keyframes rise {
    to { opacity: 1; transform: none; }
  }
}

/* ==========================================================================
   About
   ========================================================================== */

.about {
  padding-block: var(--space-9);
  border-bottom: 1px solid var(--border);
}

.about .prose {
  font-size: clamp(1.125rem, 1.05rem + 0.4vw, 1.4375rem);
  line-height: 1.65;
  color: var(--text);
  max-width: 42ch;
}

/* ==========================================================================
   Services
   ========================================================================== */

.services {
  padding-block: var(--space-9);
}

.service-list {
  margin-top: var(--space-6);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 48em) {
  .service-list { grid-template-columns: repeat(3, 1fr); gap: var(--space-5); }
}

.service-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  transition: border-color var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

.service-card:hover {
  border-color: var(--ink-500);
  transform: translateY(-2px);
}

.service-icon {
  width: 32px;
  height: 32px;
  color: var(--gold);
  margin-bottom: var(--space-5);
}

.service-card h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--mist);
  letter-spacing: -0.01em;
}

.service-card p {
  margin-top: var(--space-3);
  color: var(--muted);
  line-height: 1.6;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  padding-block: var(--space-6);
  border-top: 1px solid var(--border);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: 0.875rem;
  color: var(--muted);
}

.site-footer .tagline {
  font-family: var(--font-mono);
  color: var(--muted);
}

/* ==========================================================================
   Breakpoints — spacing/rhythm refinement
   ========================================================================== */

@media (min-width: 90em) {
  :root { --gutter: max(3rem, calc((100vw - 90rem) / 2 + 3rem)); }
}

/* short viewports (landscape phones/tablets) — the hero's normal padding and
   type scale are sized for portrait; without this the heading alone can
   overflow a ~375px-tall viewport before the lede or scroll-cue even render */
@media (max-height: 480px) {
  .hero-content {
    padding-top: 4.5rem; /* clears the absolutely-positioned header (~4.25rem tall) */
    padding-bottom: var(--space-3);
  }
  .hero h1 {
    font-size: clamp(1.75rem, 1.4rem + 2.2vw, 3rem);
    line-height: 1.08;
  }
  .hero .lede {
    display: none; /* supplementary copy — the heading already carries the message */
  }
  .hero-terminal {
    display: none; /* same reasoning — there's no headroom for it here either */
  }
  .scroll-cue {
    margin: var(--space-3) var(--gutter);
  }
}
