/* matkasse-guiden.no — site stylesheet.
   
   Two constraints shape this file and neither is aesthetic:

   1. The .disclosure banner is legally required (markedsføringsloven § 6 jf.
      § 8) to be prominent and near the top. Nothing here may shrink it, move it
      below the fold, or let it inherit a low-contrast colour.
   2. No web fonts, no external requests. The pages are served from Cloudflare
      Pages with no build step beyond build.py, and a blocking font request is
      the slowest thing on a page that is otherwise text.

   Everything else is ordinary editorial layout: one measure for prose, a wider
   frame for tables and cards.
*/

:root {
  --bg:        #ffffff;
  --bg-sunk:   #f6f7f5;
  --bg-raise:  #ffffff;
  --fg:        #14171a;
  --fg-soft:   #4a5158;
  --muted:     #6b7480;
  --line:      #e2e5e1;
  --line-soft: #eef0ec;
  --brand:     #1c6b4c;
  --brand-ink: #12503a;
  --accent:    #0b57d0;
  --ad-bg:     #fff8e4;
  --ad-line:   #e0bf5c;
  --ad-fg:     #4a3a05;

  --measure: 40rem;      /* prose column */
  --frame:   68rem;      /* full-bleed frame for nav, grids, footer */
  --radius:  10px;

  --serif: ui-serif, Georgia, "Iowan Old Style", "Source Serif Pro", "Times New Roman", serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #101316;
    --bg-sunk:   #171b1f;
    --bg-raise:  #181c20;
    --fg:        #e7eae8;
    --fg-soft:   #b3bbc2;
    --muted:     #8f99a3;
    --line:      #2a3038;
    --line-soft: #21262c;
    --brand:     #6ec49b;
    --brand-ink: #8fd6b3;
    --accent:    #8ab4f8;
    --ad-bg:     #2b2413;
    --ad-line:   #6d5c23;
    --ad-fg:     #f0e2b4;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1.0625rem/1.7 var(--sans);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
}

/* ---------------------------------------------------------------- skip link */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: .6rem 1rem;
  z-index: 50;
}
.skip:focus { left: 0; }

/* -------------------------------------------------------------------- header */
header.site {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

header.site .bar {
  max-width: var(--frame);
  margin: 0 auto;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font: 600 1.0625rem/1 var(--sans);
  letter-spacing: -.015em;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

/* The mark is drawn in CSS rather than fetched: a crate seen end-on. One less
   request, and it recolours with the theme for free. */
.brand::before {
  content: "";
  width: 1.4rem;
  height: 1.4rem;
  border: 2px solid var(--brand);
  border-radius: 4px;
  background:
    linear-gradient(var(--brand), var(--brand)) center/100% 2px no-repeat;
  flex: none;
}

.mainnav {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  font-size: .9375rem;
  margin-left: auto;
}
.mainnav a {
  color: var(--fg-soft);
  text-decoration: none;
  padding: .15rem 0;
  border-bottom: 2px solid transparent;
}
.mainnav a:hover { color: var(--fg); border-bottom-color: var(--brand); }

/* ---------------------------------------------------------------------- main */
main {
  max-width: var(--frame);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 4rem;
}

/* Prose lives in a narrow measure; tables, cards and the disclosure are allowed
   the full frame because they are scanned, not read line by line. */
article > *,
.crumbs,
footer.meta {
  max-width: var(--measure);
}
article > .table-wrap,
article > .callout { max-width: 52rem; }

/* --------------------------------------------------------------- disclosure */
/* Legally required to be prominent. Full width, high contrast, above the
   headline — never below the fold, never de-emphasised. */
.disclosure {
  background: var(--ad-bg);
  border: 1px solid var(--ad-line);
  border-left: 4px solid var(--ad-line);
  color: var(--ad-fg);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  margin: 0 0 1.75rem;
  font-size: .9375rem;
  line-height: 1.6;
  max-width: 52rem;
}
.disclosure strong { letter-spacing: .04em; text-transform: uppercase; font-size: .82rem; }

.ad-tag {
  color: var(--muted);
  font-size: .8em;
  white-space: nowrap;
  vertical-align: baseline;
}

/* ------------------------------------------------------------- breadcrumbs */
.crumbs {
  font-size: .875rem;
  color: var(--muted);
  margin: 0 0 1rem;
}
.crumbs a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line); }
.crumbs a:hover { color: var(--fg); }

/* ------------------------------------------------------------- typography */
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--fg);
}

h1 {
  font-size: clamp(1.85rem, 1.3rem + 2.2vw, 2.6rem);
  line-height: 1.15;
  margin: .25rem 0 .75rem;
}

h2 {
  font-size: clamp(1.35rem, 1.15rem + .8vw, 1.6rem);
  line-height: 1.25;
  margin: 2.75rem 0 .6rem;
  padding-top: .9rem;
  border-top: 1px solid var(--line-soft);
}

h3 {
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 1.9rem 0 .4rem;
}

p { margin: 0 0 1.1rem; }

a { color: var(--accent); text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }

strong { font-weight: 650; }

/* The articles lean heavily on bullets. Tightening the leading inside a list and
   giving it a marker in the brand colour makes a long list read as one block
   instead of as a wall of separate sentences. */
ul, ol { margin: 0 0 1.25rem; padding-left: 1.35rem; }
li { margin: .3rem 0; line-height: 1.6; }
ul { list-style: none; padding-left: 1.1rem; }
ul > li { position: relative; padding-left: .95rem; }
ul > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .72em;
  width: .38rem;
  height: .38rem;
  border-radius: 50%;
  background: var(--brand);
}
ul ul { margin: .3rem 0; }

blockquote {
  margin: 1.5rem 0;
  padding: .1rem 0 .1rem 1.1rem;
  border-left: 3px solid var(--brand);
  color: var(--fg-soft);
  font-style: normal;
}

/* Sources and caveats are written as trailing italic paragraphs. Pulling them
   out of the prose rhythm makes them read as provenance rather than as filler. */
em { font-style: italic; }
p > em:only-child {
  display: block;
  font-style: normal;
  font-size: .875rem;
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding-left: .85rem;
  line-height: 1.55;
}

hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .9em;
  background: var(--bg-sunk);
  padding: .1em .35em;
  border-radius: 4px;
}

/* ------------------------------------------------------------------- tables */
/* The comparison table is the reason people arrive. It gets the most care:
   the wrapper scrolls on a phone so the page itself never does. */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raise);
  -webkit-overflow-scrolling: touch;
}
table {
  border-collapse: collapse;
  width: 100%;
  min-width: 30rem;
  font-size: .9375rem;
}
thead th {
  background: var(--bg-sunk);
  font-family: var(--sans);
  font-weight: 600;
  font-size: .8125rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--fg-soft);
  white-space: nowrap;
}
th, td {
  padding: .7rem .85rem;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-sunk) 55%, transparent); }
td:first-child { font-weight: 600; white-space: nowrap; }

/* ---------------------------------------------------------------------- toc */
.toc {
  background: var(--bg-sunk);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 0 0 2rem;
  max-width: 34rem;
  font-size: .9375rem;
}
.toc h2 {
  font-family: var(--sans);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 0 0 .55rem;
  padding: 0;
  border: 0;
}
.toc ol { margin: 0; padding-left: 1.1rem; }
.toc li { margin: .22rem 0; }
.toc a { color: var(--fg-soft); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }

/* ------------------------------------------------------------------- cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}
.cards > li { margin: 0; padding: 0; }
.cards > li::before { display: none; }
.card {
  display: block;
  height: 100%;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raise);
  color: inherit;
  text-decoration: none;
  transition: border-color .12s ease, transform .12s ease;
}
.card:hover { border-color: var(--brand); transform: translateY(-1px); }
.card .t {
  display: block;
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: .3rem;
}
.card .d {
  display: block;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--muted);
}

/* -------------------------------------------------------------- related box */
.related {
  margin: 3.5rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.related > h2 {
  font-family: var(--sans);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 0;
  padding: 0;
  border: 0;
}

/* --------------------------------------------------------------- page meta */
footer.meta {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: .875rem;
}

/* ------------------------------------------------------------- site footer */
footer.site {
  border-top: 1px solid var(--line);
  background: var(--bg-sunk);
  margin-top: 2rem;
}
footer.site .inner {
  max-width: var(--frame);
  margin: 0 auto;
  padding: 2rem 1.25rem 2.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.5rem 2rem;
  font-size: .9rem;
  color: var(--fg-soft);
}
footer.site h2 {
  font-family: var(--sans);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 0 0 .5rem;
  padding: 0;
  border: 0;
}
footer.site ul { margin: 0; padding: 0; }
footer.site ul > li { padding-left: 0; margin: .28rem 0; }
footer.site ul > li::before { display: none; }
footer.site a { color: var(--fg-soft); text-decoration: none; }
footer.site a:hover { color: var(--fg); text-decoration: underline; }
footer.site .legal {
  max-width: var(--frame);
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  color: var(--muted);
  font-size: .8125rem;
  line-height: 1.6;
}

/* ------------------------------------------------------------------- mobile */
@media (max-width: 40rem) {
  body { font-size: 1rem; }
  header.site { position: static; }
  header.site .bar { gap: .6rem; padding: .7rem 1rem; }
  .mainnav {
    margin-left: 0;
    width: 100%;
    gap: .9rem;
    overflow-x: auto;
    padding-bottom: .15rem;
    scrollbar-width: none;
    font-size: .875rem;
  }
  .mainnav::-webkit-scrollbar { display: none; }
  main { padding: 1rem 1rem 3rem; }
  h2 { margin-top: 2.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .card:hover { transform: none; }
}

/* Printing a comparison table is a real use for this site. */
@media print {
  header.site, .mainnav, .related, .toc, footer.site { display: none; }
  body { font-size: 11pt; color: #000; background: #fff; }
  .disclosure { border: 2px solid #000; }
}
