/* Self-hosted fonts (no third-party requests). */
@font-face {
  font-family: "Familjen Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/familjen-grotesk-normal-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Familjen Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/familjen-grotesk-normal-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/ibm-plex-mono-normal-latin-400.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/ibm-plex-mono-normal-latin-ext-400.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/ibm-plex-mono-normal-latin-500.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/newsreader-italic-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Layout: one calm reading column that opens like a dictionary entry for the word "myggfritt". */
:root {
  --bg: #f1f4f1;        /* birch bark, faint green bias */
  --surface: #e5ebe7;
  --ink: #131d1a;       /* spruce black */
  --muted: #55635e;
  --line: #cdd6d1;
  --accent: #23584a;    /* spruce */
  --accent-ink: #f1f4f1;
  --mark: #f0dc72;      /* midsummer light, used once */

  --font-sans: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3rem;
  --step-2: clamp(1.45rem, 1.2rem + 1vw, 1.75rem);
  --step-3: clamp(2rem, 1.4rem + 2.6vw, 3.1rem);
  --step-hero: clamp(3.6rem, 1.4rem + 10vw, 9rem);

  --wide: 70rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1513;
    --surface: #16201d;
    --ink: #e3eae6;
    --muted: #97a7a1;
    --line: #26332f;
    --accent: #8fcab6;
    --accent-ink: #0e1513;
    --mark: #e6d26a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1513;
  --surface: #16201d;
  --ink: #e3eae6;
  --muted: #97a7a1;
  --line: #26332f;
  --accent: #8fcab6;
  --accent-ink: #0e1513;
  --mark: #e6d26a;
  color-scheme: dark;
}

/* Language: Swedish unless English is chosen. */
:root:not([data-lang="en"]) .t[lang="en"],
:root[data-lang="en"] .t[lang="sv"] { display: none; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 1rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  width: 100%;
  max-width: calc(var(--wide) + 3rem);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 1.5rem);
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--font-sans); text-wrap: balance; margin: 0; }
p { margin: 0; }
svg { display: block; }
.nowrap { white-space: nowrap; }

.label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.5rem;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.mark { width: 1.75rem; height: 1.75rem; flex: none; }
.mark-bg { fill: var(--accent); }
.mark-fg { fill: var(--accent-ink); stroke: var(--accent-ink); stroke-width: 0; }
.mark-fg path { stroke-width: 1.3; }

.site-nav { display: flex; align-items: center; gap: clamp(0.9rem, 3vw, 2rem); }
.site-nav > a {
  font-size: var(--step--1);
  color: var(--muted);
  text-decoration: none;
  padding-block: 0.25rem;
}
.site-nav > a:hover { color: var(--ink); }
.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
}
.lang-switch button {
  font: 500 0.72rem/1 var(--font-mono);
  letter-spacing: 0.06em;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 999px;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---------- Hero: the dictionary entry ---------- */
.entry {
  position: relative;
  padding-block: clamp(2.75rem, 8vw, 6.5rem) clamp(3rem, 7vw, 5.5rem);
}
.headword {
  font-size: var(--step-hero);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.05em;
  margin: 0.15em 0 0 -0.05em;
}
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1.1rem;
  margin-top: 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--muted);
}
.entry-meta .ipa { color: var(--ink); }
.entry-meta .forms i { font-style: normal; color: var(--line); }
.senses {
  list-style: none;
  margin: 2.25rem 0 0;
  padding: 0;
  display: grid;
  gap: 1.1rem;
  max-width: 42rem;
}
.senses li {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr);
  align-items: baseline;
}
.senses .n {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--accent);
}
.senses .def { font-size: var(--step-1); line-height: 1.45; }
.senses .ex {
  display: block;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--muted);
  margin-top: 0.15rem;
}
.senses .domain {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--muted);
}
.hl {
  background: linear-gradient(transparent 60%, var(--mark) 60%, var(--mark) 90%, transparent 90%);
  padding-inline: 0.08em;
  margin-inline: -0.08em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hl { background: none; color: var(--mark); }
}
:root[data-theme="dark"] .hl { background: none; color: var(--mark); }

/* The one living thing on the page: a mosquito at the end of its flight path. Click it. */
.flight {
  position: absolute;
  top: clamp(1.5rem, 4vw, 3rem);
  right: 0;
  width: min(40vw, 30rem);
  aspect-ratio: 420 / 320;
  pointer-events: none;
}
.trail {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.trail path {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-dasharray: 0.1 7;
  opacity: 0.75;
  animation: flow 9s linear infinite;
  transition: opacity 0.6s ease;
}
.mygg {
  position: absolute;
  left: calc(300 / 420 * 100%);
  top: calc(58 / 320 * 100%);
  width: 3.5rem;
  height: 3.5rem;
  margin: -1.75rem 0 0 -1.75rem;
  padding: 0.55rem;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: crosshair;
  pointer-events: auto;
  animation: hover 3.2s ease-in-out infinite;
}
.mygg:hover { background: color-mix(in srgb, var(--mark) 35%, transparent); }
.mygg svg { width: 100%; height: 100%; transform: rotate(18deg); }
.mygg .body { fill: currentColor; }
.mygg .legs { fill: none; stroke: currentColor; stroke-width: 0.9; stroke-linecap: round; }
.mygg .wing { fill: currentColor; opacity: 0.22; transform-origin: 16px 13px; animation: buzz 0.08s linear infinite alternate; }
.flight.swatted .trail path { opacity: 0; }
.mygg.swatted { animation: none; pointer-events: none; background: none; }
.mygg.swatted svg { animation: splat 0.3s ease-in forwards; }
.swat-note {
  position: absolute;
  left: calc(300 / 420 * 100%);
  top: calc(58 / 320 * 100%);
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  animation: rise 0.4s ease-out;
}
@keyframes flow { to { stroke-dashoffset: -70; } }
@keyframes hover {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  30% { transform: translate(-5px, 3px) rotate(-6deg); }
  65% { transform: translate(4px, -3px) rotate(5deg); }
}
@keyframes buzz { from { transform: scaleY(1) rotate(-6deg); } to { transform: scaleY(0.55) rotate(6deg); } }
@keyframes splat { to { transform: scale(0.15) rotate(70deg); opacity: 0; } }
@keyframes rise { from { opacity: 0; translate: 0 0.4rem; } }
@media (prefers-reduced-motion: reduce) {
  .trail path, .mygg, .mygg .wing, .mygg.swatted svg, .swat-note { animation: none; }
  .mygg.swatted { visibility: hidden; }
}

/* ---------- Intro ---------- */
.intro-body { display: grid; gap: 2rem; }
.lede {
  font-size: var(--step-2);
  max-width: 30ch;
  line-height: 1.38;
  letter-spacing: -0.012em;
  font-weight: 500;
}
.lede .quiet { color: var(--muted); }
.now {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.85rem;
  color: var(--ink);
}
.now .label { color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font: 500 var(--step-0)/1 var(--font-sans);
  padding: 0.95rem 1.35rem;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid var(--accent);
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.15s; }
.btn:hover svg { transform: translateX(2px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-ghost { color: var(--accent); }
.btn-ghost:hover { background: var(--surface); }

/* ---------- Sections ---------- */
.section {
  padding-block: clamp(3rem, 7vw, 5rem);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: 1.5rem clamp(2rem, 6vw, 5rem);
}
.section-head h2 {
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 0.6rem;
}
.section-note { color: var(--muted); font-size: var(--step--1); margin-top: 0.5rem; max-width: 22ch; }

.services { list-style: none; margin: 0; padding: 0; }
.services > li {
  display: grid;
  gap: 0.45rem;
  padding-block: 1.6rem;
  border-bottom: 1px solid var(--line);
}
.services > li:first-child { padding-top: 0; }
.services > li:last-child { border-bottom: 0; padding-bottom: 0; }
.services h3 {
  font-size: var(--step-2);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.services p { color: var(--muted); max-width: 40rem; }
.services .featured h3 { font-size: var(--step-3); letter-spacing: -0.035em; line-height: 1.05; }
.services .featured > p:not(.tags) { color: var(--ink); font-size: var(--step-1); line-height: 1.5; }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.tags span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  padding: 0.1rem 0.45rem;
}

.projects {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.projects a {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.4rem;
  height: 100%;
  padding: 1.35rem 1.4rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.projects a:hover { border-color: var(--accent); background: var(--surface); }
.p-name { font-size: var(--step-1); font-weight: 600; letter-spacing: -0.01em; }
.p-desc { color: var(--muted); }
.p-url {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
}
.p-url svg { width: 0.9rem; height: 0.9rem; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.15s; }
.projects a:hover .p-url svg { transform: translate(2px, -2px); }

/* ---------- Contact ---------- */
.contact-section { padding-block: clamp(1rem, 3vw, 2rem) clamp(2rem, 5vw, 3rem); }
.contact {
  background: var(--surface);
  border-radius: 1.25rem;
  padding: clamp(1.75rem, 6vw, 4.5rem);
  display: grid;
  gap: 1.25rem;
}
.contact .label { margin-bottom: 0.25rem; }
.contact h2 {
  font-size: var(--step-3);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  max-width: 22ch;
}
.contact .label { grid-column: 1 / -1; }
.contact-reach { display: grid; gap: 1rem; align-content: end; }
.contact-reach > p { color: var(--muted); max-width: 30rem; }
@media (min-width: 960px) {
  .contact { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); column-gap: 3rem; align-items: end; }
}
.email-row { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: center; }
.email {
  font-family: var(--font-mono);
  font-size: clamp(1.05rem, 0.9rem + 0.8vw, 1.4rem);
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
  overflow-wrap: anywhere;
}
.email:hover { text-decoration-color: var(--accent); }
.copy {
  font: 500 var(--step--1)/1 var(--font-sans);
  padding: 0.6rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
.copy:hover { border-color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 2.5rem 3rem;
  font-size: var(--step--1);
  color: var(--muted);
}

@media (max-width: 800px) {
  .section { grid-template-columns: minmax(0, 1fr); }
  .section-note { max-width: none; }
}
@media (max-width: 640px) {
  .projects { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .trail { visibility: hidden; }
  .flight { top: 0.75rem; width: 10rem; }
  .mygg, .swat-note { left: auto; right: 0; top: 2rem; margin: 0; }
  .swat-note { transform: none; }
}
@media (max-width: 560px) {
  .headword { font-size: calc(0.4rem + 21vw); }
  .site-nav > a.hide-sm { display: none; }
  .mygg { width: 2.9rem; height: 2.9rem; top: 1.4rem; }
  .swat-note { top: 2.3rem; }
}
@media (max-width: 400px) {
  .site-nav > a { display: none; }
}

/* ---------- 404 ---------- */
.not-found { display: grid; gap: 1.75rem; padding-block: clamp(3rem, 10vw, 8rem); }
.not-found .headword { margin-top: 0; }
.not-found .lede { color: var(--muted); }
