/* DampSnag links, v4. Same house as The Snag Locker. Dark only, no JS.
   Spacing on an 8px grid; 1px rules and the 2px hover bar are exempt. */

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-Var.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("fonts/SchibstedGrotesk-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  /* Blog tokens, unchanged */
  --bg: #0C1015;
  --surface: #151A21;
  --raised: #1E252D;
  --border: #2D333C;
  --text: #EAE8DF;
  --muted: #A2ACB7;
  --accent: #9FE079;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;

  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s6: 48px; --s8: 64px; --s12: 96px;

  --dur-fast: 0.18s;
  --dur: 0.35s;
  --dur-slow: 0.6s;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-in: cubic-bezier(0.5, 0, 0.75, 0);
  --ease-morph: cubic-bezier(0.5, 0, 0.1, 1);
  --spring: linear(0, 0.037 2.5%, 0.129 5%, 0.253 7.5%, 0.392 10%, 0.531 12.5%, 0.661 15%, 0.775 17.5%, 0.871 20%, 1.003 25%, 1.068 30%, 1.084 35%, 1.072 40%, 1.05 45%, 1.028 50%, 1.01 55%, 0.999 60%, 0.994 65%, 0.993 70%, 0.996 80%, 0.999 90%, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
::selection { background: var(--accent); color: var(--bg); }

/* GoatCounter no-JS pixel: loads, but takes no space and is never seen */
.gc { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- Page frame ---------- */
.page {
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--s4) var(--s2) var(--s3);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
}

/* ---------- Identity ---------- */
.id { padding: 0 0 var(--s4) var(--s1); }
.wordmark {
  font: 800 clamp(56px, 15vw, 112px)/1 var(--mono);
  white-space: nowrap;
  letter-spacing: -0.06em;
  margin-left: -0.04em;
}
.wm-a, .wm-b { display: inline-block; }
/* Separate view-transition elements: "Snag" carries across to the blog's wordmark (The Snag Locker), "Damp" leaves */
.wm-a { color: var(--text); view-transition-name: wm-damp; }
.wm-b { color: var(--accent); view-transition-name: wm-snag; }
.handle-line {
  margin-top: var(--s2);
  font: 400 18px/1.5 var(--mono);
  color: var(--muted);
}
.intro {
  margin-top: var(--s1);
  max-width: 22em; /* 36ch in Schibsted Grotesk. A ch width changes when the font loads, and Chrome then skips the .enter step */
  font-size: 18px;
  line-height: 1.5;
  text-wrap: pretty;
}

/* ---------- Section labels: the blog's // LABEL ---------- */
.section-label {
  font: 700 14px/1.5 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding: 0 0 var(--s1) var(--s1);
}
/* the "// " is decoration: the alt text after the slash keeps screen readers from reading "slash slash" */
.section-label::before { content: "// "; content: "// " / ""; color: var(--accent); }

/* ---------- Link rows ---------- */
.rows { border-top: 1px solid var(--border); }
.rows li { border-bottom: 1px solid var(--border); }
.row {
  position: relative;
  display: grid;
  grid-template-columns: var(--s3) minmax(0, 1fr) var(--s3);
  grid-template-areas:
    "ic label arrow"
    ".  sub   arrow";
  column-gap: var(--s2);
  row-gap: var(--s1);
  align-items: center;
  min-height: var(--s8);
  padding: var(--s2) var(--s2) var(--s2) var(--s2);
  outline: none;
  transition: background-color var(--dur-fast) ease;
}
/* the green bar that springs in, as on the blog */
.row::before {
  content: "";
  position: absolute;
  left: 0; top: var(--s1); bottom: var(--s1);
  width: 2px; border-radius: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform var(--dur) var(--spring);
}
.ic {
  grid-area: ic;
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 1.25;
  color: var(--muted);
  transition: color var(--dur-fast) ease;
}
.label {
  grid-area: label;
  font: 700 20px/1.3 var(--mono);
  letter-spacing: -0.03em;
  width: fit-content;
  text-decoration: underline 1.5px transparent;
  text-underline-offset: 4px;
  transition: text-decoration-color var(--dur-fast) ease, text-decoration-thickness var(--dur) var(--spring), text-underline-offset var(--dur) var(--spring);
}
.handle { grid-area: sub; font: 400 14px/1.5 var(--mono); color: var(--muted); }
.arrow {
  grid-area: arrow;
  justify-self: end;
  font: 400 18px/1 var(--mono);
  color: var(--muted);
  transition: translate var(--dur) var(--spring), color var(--dur-fast) ease;
}

.row:is(:hover, :focus-visible) { background: var(--surface); }
.row:is(:hover, :focus-visible)::before { transform: scaleY(1); }
.row:is(:hover, :focus-visible) .ic,
.row:is(:hover, :focus-visible) .arrow { color: var(--accent); }
.row:is(:hover, :focus-visible) .arrow { translate: 6px 0; }
.row:is(:hover, :focus-visible) .label { text-decoration-color: var(--accent); text-decoration-thickness: 3px; text-underline-offset: 6px; }
.row:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.row:active { background: var(--raised); }


/* ---------- Tablet and up: label column plus list column, offset left of centre ---------- */
@media (min-width: 768px) {
  .page {
    --label: 176px;
    --list: 560px;
    grid-template-columns: [label] var(--label) [list] var(--list);
    justify-content: start;
    padding: var(--s12) var(--s4);
    /* sits 96px left of centre, never closer than 32px to the edge */
    padding-left: max(var(--s4), calc((100vw - var(--label) - var(--list)) / 2 - var(--s12)));
    position: relative;
  }
  .id { grid-column: label / span 2; padding: 0 0 var(--s6); }
  .block { grid-column: label / span 2; display: grid; grid-template-columns: subgrid; align-items: start; }
  .section-label { grid-column: label; padding: var(--s2) var(--s3) 0 0; }
  .rows { grid-column: list; border-left: 1px solid var(--border); }
  .wordmark { font-size: 112px; }
  .handle-line { margin-top: var(--s3); }
  .intro { margin-top: var(--s1); }
}

/* ---------- Motion ---------- */
/* Same-origin page changes to and from the blog (Chrome and Edge 126+, Safari 18.2+; Firefox loads normally) */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.28s; animation-timing-function: ease; }

/* Hub <-> blog wordmark. A cross-document transition takes its pseudo-element styles from the page being
   opened, so this block is the same in the hub's styles.css and the theme's site.css.
   "Snag" moves and resizes between the two wordmarks. The words only one page has (Damp on the hub, The and
   Locker on the blog) leave fast, then the arriving words close in on "Snag" with the spring: the old
   homepage's tracking settle, done word by word. :only-child picks out a word with no partner on the other page. */
::view-transition-group(wm-snag) { animation-duration: 0.5s; animation-timing-function: var(--ease-morph); }
/* Colour swap (accent on the hub, text on the blog), done mid-move so neither snapshot is shown blown up */
::view-transition-old(wm-snag) { animation-duration: 0.2s; animation-delay: 0.08s; }
::view-transition-new(wm-snag) { animation-duration: 0.24s; animation-delay: 0.08s; }
::view-transition-old(wm-snag), ::view-transition-new(wm-snag),
::view-transition-old(wm-damp), ::view-transition-new(wm-damp),
::view-transition-old(wm-the), ::view-transition-new(wm-the),
::view-transition-old(wm-locker), ::view-transition-new(wm-locker) { height: 100%; object-fit: contain; object-position: left top; }

::view-transition-old(wm-damp):only-child { animation: 0.14s var(--ease-in) both wm-out-left; }
::view-transition-old(wm-the):only-child { animation: 0.16s var(--ease-in) both wm-out-left; }
::view-transition-old(wm-locker):only-child { animation: 0.16s var(--ease-in) both wm-out-right; }

::view-transition-new(wm-damp):only-child { animation: 0.45s var(--spring) 0.26s both wm-in-from-left; }
::view-transition-new(wm-the):only-child { animation: 0.45s var(--spring) 0.22s both wm-in-from-left; }
::view-transition-new(wm-locker):only-child { animation: 0.45s var(--spring) 0.28s both wm-in-from-right; }

@keyframes wm-out-left { to { opacity: 0; transform: translateX(-12%); } }
@keyframes wm-out-right { to { opacity: 0; transform: translateX(12%); } }
@keyframes wm-in-from-left { from { opacity: 0; transform: translateX(-24%); } 60% { opacity: 1; } }
@keyframes wm-in-from-right { from { opacity: 0; transform: translateX(24%); } 60% { opacity: 1; } }

/* The hub's "Blog" row label grows into the /blog/ heading (and back), with the same quick handover the blog uses for post titles */
.blog-title { view-transition-name: blog-title; view-transition-class: title; }

::view-transition-group(*.title) {
  animation-duration: 0.5s;
  animation-timing-function: var(--ease-out);
}
::view-transition-old(*.title),
::view-transition-new(*.title) {
  height: 100%;
  object-fit: contain;
  object-position: left top;
}
::view-transition-old(*.title) { animation-duration: 0.16s; }
::view-transition-new(*.title) { animation-duration: 0.3s; animation-delay: 0.06s; animation-fill-mode: both; }
/* A title with no partner on the other page (the post list arriving from the hub, or leaving for it) fades with the page */
::view-transition-old(*.title):only-child,
::view-transition-new(*.title):only-child { animation-duration: 0.28s; animation-delay: 0s; animation-timing-function: ease; }

/* First load: the old homepage's settle. The wordmark's tracking tightens on the spring, then the rest steps in. */
.wordmark { transition: letter-spacing 0.9s var(--spring), opacity 0.5s ease; }
@starting-style {
  .wordmark { letter-spacing: 0.08em; opacity: 0; }
}
/* Arriving from the blog, "Snag" is already mid-move, so the tracking stays put */
html:active-view-transition .wordmark { transition: none; }

.enter {
  transition: opacity var(--dur-slow) var(--ease-out), translate var(--dur-slow) var(--ease-out);
  transition-delay: calc(var(--i, 0) * 55ms);
}
@starting-style {
  .enter { opacity: 0; translate: 0 12px; }
}
/* Stagger order (kept here because the CSP blocks inline styles) */
.handle-line { --i: 1; }
.intro { --i: 2; }
.links { --i: 3; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; transition-delay: 0s !important; }
  .wm-a, .wm-b, .blog-title { view-transition-name: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.15s; }
}
