/* ---------- Tema ---------- */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #141a26;
  --muted: #5e6675;
  --border: #e3e6ee;
  --accent: #5b21b6;
  --accent-2: #0d9488;
  --chip-bg: #eaf0fe;
  --chip-text: #1d4ed8;
  --code-bg: #f1f3f8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --shadow-hover: 0 2px 4px rgba(16, 24, 40, .06), 0 18px 40px -16px rgba(16, 24, 40, .25);

  /* Masthead er mørk i begge tema */
  --mh-bg: #0b1530;
  --mh-text: #f3f6ff;
  --mh-muted: #a9b4d0;
  --mh-line: rgba(255, 255, 255, .1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d111a;
    --surface: #151b27;
    --text: #e7ebf3;
    --muted: #9aa3b5;
    --border: #252d3c;
    --accent: #c4b5fd;
    --accent-2: #5eead4;
    --chip-bg: #1c2840;
    --chip-text: #a8c6ff;
    --code-bg: #1b2230;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-hover: 0 18px 40px -16px rgba(0, 0, 0, .6);
    --mh-bg: #070c1c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d111a;
  --surface: #151b27;
  --text: #e7ebf3;
  --muted: #9aa3b5;
  --border: #252d3c;
  --accent: #c4b5fd;
  --accent-2: #5eead4;
  --chip-bg: #1c2840;
  --chip-text: #a8c6ff;
  --code-bg: #1b2230;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-hover: 0 18px 40px -16px rgba(0, 0, 0, .6);
  --mh-bg: #070c1c;
  color-scheme: dark;
}

/* ---------- Grunnlag ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.7 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; letter-spacing: -0.02em; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: color-mix(in srgb, var(--accent) 80%, var(--text)); }
img { max-width: 100%; height: auto; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 828px; } /* 780px innhold + 2×24px padding */
@media (min-width: 640px) { .wrap { padding: 0 24px; } }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- Masthead (header + hero) ---------- */
.masthead {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--mh-bg);
  color: var(--mh-text);
}
.masthead::before { /* rutenett */
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background-image:
    linear-gradient(var(--mh-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--mh-line) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 70% 80% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 80% at 50% 0%, #000 30%, transparent 75%);
  opacity: .55;
}
.glow { /* fargeskyer */
  position: absolute; inset: -20% -10% auto -10%; height: 140%; z-index: -2;
  background:
    radial-gradient(40% 50% at 15% 20%, rgba(37, 99, 235, .55), transparent 70%),
    radial-gradient(35% 45% at 85% 10%, rgba(20, 184, 166, .40), transparent 70%),
    radial-gradient(40% 50% at 65% 90%, rgba(124, 58, 237, .35), transparent 70%);
  filter: blur(10px);
}

.site-header { position: relative; }
.bar { display: flex; align-items: center; justify-content: flex-end; gap: 16px; padding-top: 12px; padding-bottom: 4px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.logo {
  flex: none;
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #14b8a6);
  color: #fff; font-weight: 800; font-size: 15px; letter-spacing: .02em;
  box-shadow: 0 6px 18px -6px rgba(37, 99, 235, .8), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
.brand-tag { color: var(--mh-muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .brand-tag { display: none; } }

.nav { display: flex; align-items: center; gap: 4px; }
.nav a, .theme-toggle {
  color: var(--mh-text); text-decoration: none; font-size: .95rem; font-weight: 500;
  padding: 8px 12px; border-radius: 10px; border: 0; background: none; cursor: pointer;
  display: inline-grid; place-items: center;
}
.nav a:hover, .theme-toggle:hover { background: rgba(255, 255, 255, .1); }
.icon-link, .theme-toggle { padding: 8px !important; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}

/* Hero */
.hero { position: relative; padding: 12px 0 40px; }
.hero h1 { font-size: clamp(2.1rem, 5.5vw, 3.6rem); line-height: 1.08; margin: 0 0 12px; font-weight: 800; }
.hero .lead { font-size: clamp(1.05rem, 2vw, 1.2rem); color: var(--mh-muted); margin: 0 0 24px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em;
  color: #7dd3fc; margin: 0 0 10px;
}
.eyebrow::before { content: ""; width: 24px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, #60a5fa, #5eead4); }
.grad { background: linear-gradient(90deg, #60a5fa 0%, #5eead4 60%, #a78bfa 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }

.hero-small { padding: 8px 0 36px; }
.hero-small h1 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); margin-bottom: 6px; max-width: none; }
.hero-small .lead { margin-bottom: 0; }

.cat-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  color: var(--mh-text); text-decoration: none; font-size: .9rem;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(6px);
  transition: background .15s, border-color .15s;
}
.pill span { font-size: .78rem; color: var(--mh-muted); }
.pill:hover { background: rgba(255, 255, 255, .14); }
.pill.active { background: #fff; color: #0b1530; border-color: #fff; }
.pill.active span { color: #47506a; }

/* Innleggs-hero */
.hero-post { padding: 8px 0 40px; text-align: center; }
.hero-post.has-image { padding-bottom: 130px; }
.hero-post h1 { margin: 14px auto 16px; max-width: none; font-size: clamp(1.9rem, 4.8vw, 3rem); line-height: 1.15; }
.hero-post .meta { justify-content: center; color: var(--mh-muted); }
.post-cats { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.post-cats .chip { background: rgba(255, 255, 255, .1); color: #bfdbfe; border: 1px solid rgba(255, 255, 255, .15); }
.post-cats .chip:hover { background: rgba(255, 255, 255, .18); }

main.wrap { padding-top: 48px; padding-bottom: 80px; }

/* ---------- Kort ---------- */
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--muted); font-size: .85rem; }
.dot { opacity: .6; }
.chip {
  display: inline-block; background: var(--chip-bg); color: var(--chip-text);
  border-radius: 999px; padding: 2px 10px; font-size: .78rem; font-weight: 500; text-decoration: none; line-height: 1.6;
}
a.chip:hover { filter: brightness(.96); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 24px; }
.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.card-img { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--code-bg); }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.card:hover .card-img img { transform: scale(1.04); }
.card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; flex: 1; }
.card h2 { font-size: 1.2rem; line-height: 1.3; margin: 8px 0 10px; }
.card h2 a { color: var(--text); text-decoration: none; }
.card h2 a::after { content: ""; position: absolute; inset: 0; } /* hele kortet klikkbart */
.card h2 a:hover { color: var(--accent); }
.card p { margin: 0 0 16px; color: var(--muted); font-size: .95rem; line-height: 1.6; }
.card-cats { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; position: relative; z-index: 1; }
.new {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: #fff; background: linear-gradient(90deg, #2563eb, #0d9488); padding: 2px 9px; border-radius: 999px; margin-right: 2px;
}


/* ---------- Innlegg ---------- */
.single main.wrap { padding-top: 0; }
.post { max-width: 780px; margin: 0 auto; }
.post-image {
  display: block; width: 100%; border-radius: 18px; margin: -120px 0 40px;
  position: relative; box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .55); border: 1px solid var(--border);
  background: var(--surface);
}
.single .post:not(:has(.post-image)) { padding-top: 40px; }

.content { font-size: 1.08rem; }
.content > :first-child { margin-top: 0; }
.content h2 { margin: 2.2em 0 .6em; font-size: 1.6rem; line-height: 1.25; }
.content h3 { margin: 1.8em 0 .5em; font-size: 1.25rem; line-height: 1.3; }
.content h4 { margin: 1.6em 0 .4em; font-size: 1.08rem; }
.content p, .content ul, .content ol { margin: 0 0 1.15em; }
.content li { margin: .3em 0; }
.content li::marker { color: var(--accent); }
.content img { border-radius: 12px; border: 1px solid var(--border); display: block; margin: 24px auto; }
.content blockquote {
  margin: 1.8em 0; padding: 16px 22px; border-left: 4px solid var(--accent);
  background: var(--surface); border-radius: 0 12px 12px 0; box-shadow: var(--shadow);
}
.content blockquote > :last-child { margin-bottom: 0; }
.content code { background: var(--code-bg); padding: 2px 6px; border-radius: 6px; font-size: .86em; font-family: "Cascadia Code", ui-monospace, Consolas, monospace; }
.content pre { background: #0f172a; color: #e2e8f0; padding: 18px 20px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; font-size: .9rem; border: 1px solid var(--border); }
.content pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.content table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-size: .92rem; margin: 1.5em 0; }
.content th, .content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
.content th { background: var(--code-bg); }
.content hr { border: 0; height: 1px; background: var(--border); margin: 3em 0; }
.content a { font-weight: 500; }

.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.tags-label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-right: 6px; }

/* ---------- Deling ---------- */
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 24px; }
.tags + .share { margin-top: 20px; }
.share:first-child, .content + .share { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.share-label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-right: 2px; }
.share-list { display: flex; flex-wrap: wrap; gap: 8px; }
.share-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
  font: inherit; font-size: .88rem; font-weight: 600; line-height: 1; text-decoration: none; cursor: pointer;
  transition: border-color .15s, color .15s, transform .15s;
}
.share-btn[hidden] { display: none; }
.share-btn svg { width: 18px; height: 18px; flex: none; }
.share-btn svg.brand { fill: currentColor; stroke: none; }
.share-btn:hover, .share-btn:focus-visible { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.share-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.share-status { font-size: .85rem; color: var(--muted); min-height: 1em; }
@media (max-width: 600px) { .share-btn span { display: none; } .share-btn { padding: 10px; min-width: 42px; justify-content: center; } }

.post-nav { max-width: 780px; margin: 48px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.post-nav a {
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
  text-decoration: none; color: var(--text); font-weight: 600; line-height: 1.35; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.post-nav a span { color: var(--muted); font-size: .8rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.post-nav a:hover { border-color: var(--accent); transform: translateY(-2px); }
.post-nav .next { text-align: right; }
@media (max-width: 600px) { .post-nav { grid-template-columns: 1fr; } .post-nav .next { text-align: left; } }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 64px 0; }
.notfound .eyebrow { color: var(--accent); }
.notfound h1 { font-size: 2.4rem; margin: 0 0 8px; }
.button { display: inline-block; margin-top: 12px; padding: 10px 20px; border-radius: 10px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .9rem; }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 20px; padding-top: 32px; padding-bottom: 32px; }
.foot p { margin: 8px 0 0; }
.brand.small { color: var(--text); }
.brand.small .logo { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; box-shadow: none; }
.foot-links { display: flex; gap: 20px; align-items: center; }
.foot-links a { color: var(--muted); text-decoration: none; }
.foot-links a:hover { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ---------- Faste sider (Om meg) ---------- */
.page { max-width: 780px; margin: 0 auto; }
.links-title { font-size: 1.1rem; margin: 48px 0 16px; padding-top: 32px; border-top: 1px solid var(--border); }
.link-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.link-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.link-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-hover); }
.link-badge {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #14b8a6); color: #fff; font-weight: 800; font-size: 1.05rem;
}
.link-badge svg { width: 22px; height: 22px; }
.link-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.link-text span { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-card .arrow { margin-left: auto; flex: none; width: 18px; height: 18px; color: var(--muted); transition: color .15s, transform .15s; }
.link-card:hover .arrow { color: var(--accent); transform: translate(2px, -2px); }

/* Bunntekst nederst også på korte sider */
body { min-height: 100vh; display: flex; flex-direction: column; }
main.wrap { flex: 1 0 auto; width: 100%; }

/* Tilbake-knapp i headeren på innlegg */
.back-link {
  margin-right: auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 10px; border-radius: 999px;
  color: var(--mh-text); text-decoration: none; font-size: .92rem; font-weight: 500;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .14);
  transition: background .15s, transform .15s;
}
.back-link svg { width: 18px; height: 18px; transition: transform .15s; }
.back-link:hover { background: rgba(255, 255, 255, .14); }
.back-link:hover svg { transform: translateX(-3px); }
@media (max-width: 480px) { .single .nav a[href="/"] { display: none; } }

/* Filterbanner over kortene på kategorisider */
.list-heading {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 16px;
  margin: 0 0 28px; padding: 16px 18px 16px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.list-heading::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: linear-gradient(180deg, #2563eb, #14b8a6);
}
.lh-icon {
  flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #14b8a6); color: #fff;
  box-shadow: 0 8px 20px -10px rgba(37, 99, 235, .8);
}
.lh-icon svg { width: 22px; height: 22px; }
.lh-text { display: flex; flex-direction: column; min-width: 0; }
.lh-eyebrow { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); }
.list-heading h2 { margin: 2px 0 0; font-size: 1.45rem; line-height: 1.2; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.lh-count {
  font-family: inherit; font-size: .78rem; font-weight: 600; letter-spacing: 0;
  color: var(--chip-text); background: var(--chip-bg); padding: 3px 10px; border-radius: 999px;
}
.list-heading .clear {
  margin-left: auto; flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text); background: var(--bg); text-decoration: none; font-size: .9rem; font-weight: 500;
  transition: border-color .15s, color .15s, background .15s;
}
.list-heading .clear svg { width: 16px; height: 16px; }
.list-heading .clear:hover { color: var(--accent); border-color: var(--accent); background: var(--surface); }
@media (max-width: 520px) {
  .list-heading { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px 14px; }
  .list-heading .clear { grid-column: 2; justify-self: start; margin-left: 0; padding: 6px 12px; }
}

/* Bildetekst: kursiv avsnitt rett under et bilde */
.content p:has(> img:only-child) + p:has(> em:only-child) {
  margin-top: -12px; text-align: center; color: var(--muted); font-size: .92rem; line-height: 1.5;
}
