@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0d1210;
  --surface: #141b17;
  --ink: #ecf1ec;
  --muted: #a9b6ac;
  --line: #27322b;
  --brand: #8dbd9a;
  --on-brand: #0d1210;
  --focus: #f2c48d;
  --danger: #ff9d8a;
  --ok: #8dbd9a;
  --grain: #ecf1ec;

  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --gutter: clamp(1rem, 4vw, 3.5rem);
  --max: 76rem;
  --glow: var(--brand);
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f1ea;
    --surface: #fbf9f4;
    --ink: #18201b;
    --muted: #55625a;
    --line: #d6d1c4;
    --brand: #2f6b45;
    --on-brand: #fbf9f4;
    --focus: #8a4b0f;
    --danger: #a3301c;
    --ok: #2f6b45;
    --grain: #18201b;
}

/* Each project has its own colour, read from that project's own tokens. --p-soft is its second colour. */
[data-p="pinekey"]          { --p: #94baff; --p-soft: #6bd7c1; }
[data-p="pinemail"]         { --p: #00adf0; --p-soft: #b3c0cb; }
[data-p="pinekeep"]         { --p: #00adf0; --p-soft: #b3c0cb; }
[data-p="tinypine"]         { --p: #6fa37e; --p-soft: #c1a8dc; }
[data-p="agentroots"]       { --p: #cba5ec; --p-soft: #f2b84b; }
[data-p="politikcentralen"] { --p: #f5d3b7; --p-soft: #dfefe6; }
[data-p="pinecoredsp"]      { --p: #e3a57f; --p-soft: #abcfb6; }
[data-p="plantdesigner"]    { --p: #4ade80; --p-soft: #bef264; }
:root[data-theme="light"] [data-p="pinekey"] { --p: #234fc0; --p-soft: #006863; }
:root[data-theme="light"] [data-p="pinemail"] { --p: #0087c7; --p-soft: #55625a; }
:root[data-theme="light"] [data-p="pinekeep"] { --p: #0087c7; --p-soft: #55625a; }
:root[data-theme="light"] [data-p="tinypine"] { --p: #3f6e4f; --p-soft: #7a5aa6; }
:root[data-theme="light"] [data-p="agentroots"] { --p: #763c9b; --p-soft: #a8321f; }
:root[data-theme="light"] [data-p="politikcentralen"] { --p: #6244c5; --p-soft: #24685f; }
:root[data-theme="light"] [data-p="pinecoredsp"] { --p: #a15f38; --p-soft: #3f6e4f; }
:root[data-theme="light"] [data-p="plantdesigner"] { --p: #15803d; --p-soft: #4d7c0f; }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--font-body);
  overflow-x: hidden;
}
h1, h2 { font-family: var(--font-display); line-height: 1.08; letter-spacing: -0.025em; margin: 0; font-weight: 600; }
p { margin: 0; }
a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 600;
  background: var(--brand); color: var(--on-brand);
  padding: 0.75rem 1rem; border-radius: 0.5rem; font-weight: 600; text-decoration: none;
}
.skip:focus { top: 1rem; }

/* Ambient light that takes the colour of the project in focus. */
.glow {
  position: fixed; z-index: 0; pointer-events: none;
  width: 70vmax; height: 70vmax; right: -22vmax; top: -26vmax;
  border-radius: 50%;
  background: var(--glow);
  opacity: 0.13;
  filter: blur(110px);
  transition: background-color 0.7s ease;
}
:root[data-theme="light"] .glow { opacity: 0.2; }

/* Fine grain on the page background. It lies above the ambient light and below all content. */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: url("/grain.svg?v=5") 0 0 / 256px 256px repeat;
  opacity: 0.05;
}
:root[data-theme="light"] body::after { background-image: url("/grain-dark.svg?v=5"); opacity: 0.05; }
.sprite { position: absolute; width: 0; height: 0; }

.top, main, .foot { position: relative; z-index: 1; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.5rem max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.brand {
  display: inline-flex; align-items: center; gap: 0.6rem; min-height: 44px;
  font: 600 1.02rem/1 var(--font-display); letter-spacing: -0.01em; text-decoration: none;
}
.brand-mark { width: 34px; height: 34px; color: var(--brand); flex: none; }
.top-right { display: flex; align-items: center; gap: 0.25rem; min-width: 0; }
.theme-toggle {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.theme-toggle:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 9%, transparent); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .moon { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .moon { display: block; }
.nav { display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.8rem;
  color: var(--muted); text-decoration: none; font-size: 0.94rem; border-radius: 999px;
  transition: color 0.2s ease, background-color 0.2s ease; white-space: nowrap;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="true"] { color: var(--ink); background: color-mix(in srgb, var(--ink) 9%, transparent); }

/* Hero */
.hero { position: relative; min-height: calc(100dvh - 61px); display: grid; align-items: center; }
.hero-inner {
  position: relative; width: 100%; max-width: var(--max); margin: 0 auto;
  padding: clamp(2.5rem, 7vw, 6rem) var(--gutter) clamp(3rem, 8vw, 6.5rem);
}
.hero-copy { max-width: 37rem; }
.eyebrow {
  font: 500 0.82rem/1 var(--font-body); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--brand); margin-bottom: 1.4rem;
}
h1 { font-size: clamp(2.3rem, 1.1rem + 4.6vw, 4.6rem); font-weight: 600; text-wrap: balance; }
.lead { margin-top: 1.5rem; max-width: 34rem; color: var(--muted); font-size: clamp(1.02rem, 0.95rem + 0.35vw, 1.2rem); }
.hero-actions { margin-top: 2.2rem; display: flex; flex-wrap: wrap; gap: 0.75rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 1.5rem; border-radius: 999px;
  font: 600 0.98rem/1 var(--font-body); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn-solid { background: var(--ink); color: var(--bg); }
.btn-solid:hover { background: color-mix(in srgb, var(--ink) 86%, var(--brand)); }
.btn-line { border-color: var(--line); color: var(--ink); }
.btn-line:hover { border-color: var(--muted); }
.btn[disabled] { opacity: 0.55; cursor: default; }

/* Field: one band of threads per project, drifting across the hero. */
.threads {
  position: absolute; top: -4rem; left: 0; width: 100%; height: calc(100% + 16rem);
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, rgba(0,0,0,0.2) 0%, #000 60%), linear-gradient(to bottom, #000 68%, transparent 100%);
  mask-image: linear-gradient(to right, rgba(0,0,0,0.2) 0%, #000 60%), linear-gradient(to bottom, #000 68%, transparent 100%);
  -webkit-mask-composite: source-in; mask-composite: intersect;
}
.threads g { transition: opacity 0.45s ease; }
.threads path { fill: none; stroke: var(--p); stroke-width: 1.15; stroke-linecap: round; opacity: 0.5; vector-effect: non-scaling-stroke; }
:root[data-theme="light"] .threads path { opacity: 0.6; }
.threads.is-focus g { opacity: 0.1; }
.threads.is-focus g.is-on { opacity: 1; }
.threads.is-focus g.is-on path { opacity: 0.85; }

/* Blocks */
.block {
  position: relative; z-index: 1;
  max-width: var(--max); margin: 0 auto;
  padding: clamp(3rem, 7vw, 6rem) var(--gutter);
  border-top: 1px solid var(--line);
}
.block-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 2rem; margin-bottom: clamp(1.5rem, 3vw, 2.5rem); }
h2 { font-size: clamp(1.7rem, 1.1rem + 2.2vw, 2.8rem); }
.muted { color: var(--muted); max-width: 36rem; }

/* Projects: a row takes a light tint of the project's colour when it is in focus. */
.projects { list-style: none; margin: 0 calc(var(--gutter) * -0.5); padding: 0; }
.projects li + li { border-top: 1px solid var(--line); }
.project {
  --cut: var(--bg);
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: 2.75rem clamp(10rem, 19vw, 16rem) minmax(0, 1fr) clamp(9rem, 16vw, 13.5rem);
  align-items: center; gap: 0.5rem clamp(1rem, 2.2vw, 2.25rem);
  padding: clamp(1.1rem, 2.2vw, 1.7rem) calc(var(--gutter) * 0.5);
  text-decoration: none; border-radius: 1rem;
}
.project::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: color-mix(in srgb, var(--p) 9%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--p) 30%, transparent);
  opacity: 0; transition: opacity 0.3s ease;
}
.project-logo { width: 2.75rem; height: 2.75rem; color: var(--p); }
.project-logo, .project-name, .project-shot { grid-row: 1 / span 2; }
.project-desc { grid-column: 3; grid-row: 1; align-self: end; }
.project-shot {
  grid-column: 4; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top;
  border-radius: 0.6rem; border: 1px solid var(--line); background: var(--surface);
  transition: transform 0.3s ease, border-color 0.3s ease;
}
.project:hover .project-shot, .project:focus-visible .project-shot { transform: scale(1.03); border-color: color-mix(in srgb, var(--p) 45%, transparent); }
.project-name { font: 600 clamp(1.45rem, 1.1rem + 1.5vw, 2.2rem)/1.1 var(--font-display); letter-spacing: -0.02em; }
.project-desc { color: var(--muted); }
.project-meta { grid-column: 3; grid-row: 2; align-self: start; display: flex; align-items: center; gap: 0.75rem; font-size: 0.86rem; white-space: nowrap; }
.status { padding: 0.2rem 0.6rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.host { color: var(--muted); transition: color 0.3s ease; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 0.25em; }

.project:hover::before, .project:focus-visible::before, .project.is-on::before { opacity: 1; }
.project:hover .host, .project:focus-visible .host, .project.is-on .host { color: var(--p); text-decoration-color: currentColor; }

/* About */
.about { display: grid; grid-template-columns: minmax(0, 0.55fr) minmax(0, 1fr); gap: 1rem clamp(1.5rem, 5vw, 5rem); }
.about .block-head { margin-bottom: 0; }
.about-body { max-width: 40rem; display: grid; gap: 1.1rem; font-size: clamp(1.02rem, 0.97rem + 0.3vw, 1.16rem); color: var(--muted); }
.about-first { font: 500 clamp(1.5rem, 1.1rem + 1.6vw, 2.3rem)/1.18 var(--font-display); letter-spacing: -0.02em; color: var(--ink); text-wrap: balance; }

/* Contact */
.contact { display: grid; grid-template-columns: minmax(0, 0.55fr) minmax(0, 1fr); gap: 1.5rem clamp(1.5rem, 5vw, 5rem); }
.contact .block-head { flex-direction: column; justify-content: flex-start; margin-bottom: 0; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; max-width: 40rem; }
.field { display: grid; gap: 0.4rem; }
.field-wide, .form-foot { grid-column: 1 / -1; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
label { font-size: 0.9rem; font-weight: 500; }
input, textarea {
  width: 100%; min-height: 48px; padding: 0.75rem 0.9rem;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 0.7rem;
  transition: border-color 0.2s ease;
}
textarea { resize: vertical; min-height: 9rem; }
input:hover, textarea:hover { border-color: var(--muted); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }
.form-status { color: var(--muted); min-height: 1.6em; }
.form-status[data-kind="error"] { color: var(--danger); }
.form-status[data-kind="ok"] { color: var(--ok); }

/* Footer */
.foot {
  max-width: var(--max); margin: 0 auto;
  padding: 2.5rem var(--gutter) 5rem; border-top: 1px solid var(--line);
  display: grid; gap: 0.6rem; color: var(--muted); font-size: 0.88rem;
}
.foot p { max-width: 60rem; }
.foot a { display: inline-block; padding: 0.6rem 0; margin: -0.6rem 0; }

/* To the top */
.to-top {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 200;
  width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.to-top svg { width: 22px; height: 22px; }
.to-top[hidden] { display: none; }

/* Text pages */
.page { max-width: 46rem; margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) var(--gutter); display: grid; gap: 1.1rem; }
.page h1 { font-size: clamp(2rem, 1.3rem + 2.6vw, 3.2rem); margin-bottom: 0.5rem; }
.page h2 { font-size: 1.35rem; margin-top: 1.4rem; letter-spacing: -0.01em; }
.page p, .page li { color: var(--muted); }
.page ul { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.4rem; }

/* Entrance */
.rise { opacity: 0; transform: translateY(18px); animation: rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) forwards; animation-delay: calc(var(--i, 0) * 90ms); }
@keyframes rise { to { opacity: 1; transform: none; } }

@media (max-width: 800px) {
  .hero { min-height: 0; }
  .hero-inner { padding-top: 5rem; padding-bottom: 9rem; }
  .threads { top: 0; height: calc(100% + 6rem); }
  .about, .contact { grid-template-columns: 1fr; }
  .project { grid-template-columns: 2.25rem minmax(0, 1fr); column-gap: 0.9rem; }
  .project-logo { width: 2.25rem; height: 2.25rem; }
  .project-logo, .project-name, .project-desc, .project-meta { grid-row: auto; }
  .project-desc, .project-meta { grid-column: 2; }
  .project-meta { margin-top: 0.25rem; }
  .project-shot { grid-column: 1 / -1; grid-row: 1; margin-bottom: 0.6rem; }
  .form { grid-template-columns: 1fr; }
  .brand span { font-size: 0.95rem; }
  .nav a { padding: 0 0.6rem; }
}
@media (max-width: 420px) {
  .brand span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .rise { opacity: 1; transform: none; }
}
