/* Sæga: what every page shares. The design tokens, the skip link, the header, the
   footer and the buttons. Linked first on every page, so a page's own <style> (or
   styles.css on / and /en) builds on it and can override a token where it has to.

   The header and footer markup is written into each page by scripts/chrome.py; change
   it there and re-run, never by hand in one page. assets/site.js runs them.

   Contrast (WCAG AA, 4.5:1 for text): --text-dim is the faintest text colour and is
   chosen against the darkest background it sits on. Light #6B6B6B: 5.10 on --bg,
   4.66 on --bg-subtle, 4.69 on --bg-cool, 4.81 on --bg-footer, 4.56 on #F0EDE8.
   Dark #888888: 5.33 on --bg, 4.70 on --bg-subtle, 4.91 on --bg-card, 5.03 on --bg-cool.
   Text on the brand colour uses --brand-ink: 4.91 light, 5.96 dark. */

:root {
  --bg: #FAFAF8;
  --bg-card: #FFFFFF;
  --bg-subtle: #F0F0EC;
  --bg-footer: #F5F3EE;
  --text: #111111;
  --text-muted: #666666;
  --text-dim: #6B6B6B;
  --accent-nordic: #5B7B94;
  --accent-nordic-soft: rgba(91, 123, 148, 0.08);
  --accent-fjord: #3A5A6E;
  --accent-rust:  #A65D45;
  --accent-moss:  #6B7D5C;
  --bg-cool: #EEF1F2;
  --border: #E5E5E0;
  --red: #c0392b;
  --green: #1a7a3a;
  --header-bg: rgba(250, 250, 248, 0.9);
  --shadow: 0 2px 20px rgba(0,0,0,0.05);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.08);
  --scroll-shadow: rgba(0,0,0,0.13);
  /* One colour, used at full strength. Rust was already the Pro colour.
     --brand-ink is the text that sits ON the brand: white clears AA here (4.91:1),
     but the lighter dark-mode rust does not, so it flips to near-black there. */
  --brand: #A65D45;
  --brand-hover: #8F4A34;
  --brand-ink: #FFFFFF;
  --brand-tint: #FAF3F0;
  --sans: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  --serif: 'Gelasio', Georgia, serif;
  --mono: 'Ubuntu Mono', 'Courier New', monospace;
  --radius: 16px;
  --radius-btn: 24px;
  --maxw: 940px;
  /* One content column for the whole site. Header, footer and every section pad
     themselves out to it, so they start on the same left edge. */
  --content: 1080px;
  --gutter: clamp(16px, 5vw, 48px);
  --edge: max(var(--gutter), calc((100% - var(--content)) / 2));
}

html.dark {
  --bg: #111111;
  --bg-card: #1A1A1A;
  --bg-subtle: #1E1E1E;
  --bg-footer: #151515;
  --text: #E8E8E6;
  --text-muted: #999999;
  --text-dim: #888888;
  --accent-nordic: #7BA3C4;
  --accent-nordic-soft: rgba(123, 163, 196, 0.1);
  --accent-fjord: #6F92AB;
  --accent-rust: #C28167;
  --accent-moss: #94A883;
  --bg-cool: #15181A;
  --border: #2A2A28;
  --red: #e74c3c;
  --green: #2ecc71;
  --header-bg: rgba(17, 17, 17, 0.9);
  --shadow: 0 2px 20px rgba(0,0,0,0.25);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.4);
  --scroll-shadow: rgba(255,255,255,0.16);
  /* #C28167 with white text is 3.17:1, under AA. Against near-black it is 5.96:1,
     so the ink flips rather than the hue. */
  --brand: #C28167;
  --brand-hover: #D0937B;
  --brand-ink: #111111;
  --brand-tint: #1C1614;
}

/* ---------- skip link ---------- */
/* Off screen until it gets keyboard focus, then the first thing on the page. */
.skip-link {
  position: absolute; left: 12px; top: -200px; z-index: 1000;
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px;
  background: var(--text); color: var(--bg); border-radius: 12px;
  font: 500 1rem/1.2 var(--sans); text-decoration: none;
}
.skip-link:focus { top: 12px; }
main:focus { outline: none; }
.site-header :focus-visible, .site-footer :focus-visible, .skip-link:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent-nordic); outline-offset: 2px;
}

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 8px; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  /* The card sits 8px in from the window; this padding puts the logo on the content edge at every width. */
  --hpad: max(12px, calc(var(--gutter) - 8px));
  padding: 10px var(--hpad);
  max-width: calc(var(--content) + 2 * var(--hpad)); width: calc(100% - 16px); margin: 0 auto;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid var(--border); border-radius: 16px;
  font-family: var(--sans); line-height: 1.6;
  transition: transform 0.34s cubic-bezier(.4, 0, .2, 1), box-shadow 0.25s ease;
}
.site-header.scrolled { box-shadow: 0 6px 20px rgba(0,0,0,0.08); }
.site-header.header-hidden { transform: translateY(calc(-100% - 20px)); }
@media (prefers-reduced-motion: reduce) { .site-header { transition: none; } }

.brand { display: flex; align-items: center; gap: 9px; min-height: 44px; min-width: 44px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.brand-logo { width: 30px; height: 30px; border-radius: 7px; display: block; box-shadow: 0 0 0 1px rgba(120,120,120,0.18); margin: 0; }
.brand-word { font-family: var(--serif); font-weight: 400; font-size: 1.4rem; line-height: 1; letter-spacing: -0.005em; color: var(--text); }
.header-right { display: flex; align-items: center; gap: 10px; }

.theme-toggle {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 44px; height: 44px; padding: 0; margin: 0;
  border: 1px solid var(--border); border-radius: 12px; background: none; color: var(--text-dim); cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.icon-sun { display: none; } .icon-moon { display: block; }
html.dark .icon-sun { display: block; } html.dark .icon-moon { display: none; }

/* Language: a pill of codes. Links on the static pages, buttons on / (app.js
   translates that page in place). The active one is plain text. */
.lang-toggle { display: flex; align-items: center; gap: 2px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 999px; padding: 3px; margin: 0; }
.lang-toggle a, .lang-toggle span, .lang-toggle button {
  font-family: var(--mono); font-size: 0.8rem; line-height: 1; text-decoration: none;
  color: var(--text-dim); border: 0; background: none; cursor: pointer; border-radius: 999px;
  min-width: 40px; min-height: 36px; padding: 0 10px; margin: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.lang-toggle span { cursor: default; }
.lang-toggle a:hover, .lang-toggle button:hover { color: var(--text); }
.lang-toggle .active { color: var(--text); background: var(--accent-nordic-soft); }

/* On a phone the pill does not fit beside the download button; every page folds the
   languages into this menu instead. It is a <details>, so it opens without JavaScript. */
.lang-menu { display: none; position: relative; margin: 0; padding: 0; border: 0; }
.lang-menu > summary {
  list-style: none; display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  min-width: 44px; min-height: 44px; padding: 0 6px; border-radius: 12px; cursor: pointer;
  font-family: var(--mono); font-size: 0.8rem; color: var(--text);
}
.lang-menu > summary::-webkit-details-marker { display: none; }
.lang-menu > summary::after { content: "\25BE"; color: var(--text-dim); font-size: 0.75rem; }
.lang-menu .lang-toggle {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 5;
  flex-direction: column; align-items: stretch; gap: 0; padding: 6px; border-radius: 14px;
  background: var(--bg-card); box-shadow: var(--shadow-lg); min-width: 132px;
}
.lang-menu .lang-toggle a, .lang-menu .lang-toggle span, .lang-menu .lang-toggle button {
  min-height: 44px; justify-content: flex-start; padding: 0 14px; border-radius: 10px; font-size: 0.9rem;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; font-family: var(--sans); font-weight: 500; font-size: 1rem; line-height: 1.2;
  padding: 12px 24px; border-radius: var(--radius-btn); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease, border-color 0.15s ease;
  /* A call to action that breaks across two lines stops reading as a button. */
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn-sm { padding: 8px 16px; font-size: 0.9rem; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); color: var(--brand-ink); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn.full { width: 100%; }
@media (prefers-reduced-motion: reduce) { .btn, .btn:hover, .btn:active { transition: none; transform: none; } }

/* On a phone the download links hand the link over to the visitor's Mac instead
   (assets/site.js sets html.dl-handoff), and say so. */
.handoff-label { display: none; }
html.dl-handoff .handoff-label { display: inline; }
html.dl-handoff .dl-label { display: none; }
.handoff-toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 1000; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 12px 18px;
  background: var(--text); color: var(--bg); border-radius: 14px; box-shadow: var(--shadow-lg);
  font: 1rem/1.4 var(--sans); text-align: center;
}

/* ---------- footer ---------- */
.site-footer { background: var(--bg-footer); border-top: 1px solid var(--border); padding: 56px var(--gutter) 40px; margin: 0; font-family: var(--sans); line-height: 1.6; max-width: none; display: block; text-align: left; }
.footer-cols { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 32px; max-width: var(--content); margin: 0 auto; }
.footer-brand-lockup { display: flex; align-items: center; gap: 9px; margin: 0 0 8px; }
.footer-brand-lockup .brand-logo { width: 28px; height: 28px; }
.footer-brand-col .brand-word { font-family: var(--serif); font-weight: 700; font-size: 1.3rem; }
.footer-tagline { font-family: var(--mono); color: var(--text-dim); font-size: 0.875rem; margin: 8px 0 0; max-width: 240px; }
.footer-col { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; margin: 0; padding: 0; }
.footer-col-title { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); margin: 0 0 3px; }
.footer-col a { color: var(--text-muted); text-decoration: none; font-size: 0.95rem; margin: 0; }
.footer-col a:hover { color: var(--accent-nordic); }
.footer-col a[aria-current="page"] { color: var(--text); }
.footer-signature { font-family: var(--serif); font-style: italic; color: var(--text-muted); text-align: center; max-width: 560px; margin: 44px auto 12px; font-size: 1rem; line-height: 1.5; }
.footer-built { font-family: var(--mono); text-align: center; color: var(--text-dim); font-size: 0.875rem; margin: 0; }
.footer-lang { text-align: center; margin: 14px 0 0; color: var(--text-dim); font-size: 1rem; }
.footer-lang a { color: var(--accent-nordic); }

/* ---------- phones ---------- */
@media (max-width: 680px) {
  /* The brand and its tagline get a row of their own, then Produkt beside Juridik over
     Support, so no column stands half empty next to a long one. */
  .footer-cols { grid-template-columns: 1fr 1fr; grid-template-areas: "brand brand" "a b" "a c"; row-gap: 24px; }
  .footer-brand-col { grid-area: brand; }
  .footer-tagline { max-width: none; }
  .footer-cols > .footer-col:nth-of-type(1) { grid-area: a; }
  .footer-cols > .footer-col:nth-of-type(2) { grid-area: b; }
  .footer-cols > .footer-col:nth-of-type(3) { grid-area: c; }
  /* Every link and button is a 44 px target. */
  .site-footer .footer-col { gap: 0; }
  .site-footer .footer-col a { min-height: 44px; min-width: 44px; display: flex; align-items: center; font-size: 1rem; }
  .footer-lang a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; }
  /* Language: the same menu on every page, the current language with a caret, every
     language inside with the current one marked. The pill does not fit beside the button. */
  .site-header .lang-toggle--pill { display: none; }
  .lang-menu { display: block; }
  .lang-menu .lang-toggle { display: flex; border: 1px solid var(--border); }
  .site-header .btn-sm { padding: 0 14px; font-size: 0.86rem; }
  /* Breadcrumbs above articles are navigation, not running text. */
  .breadcrumb a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; }
  /* Link rows and lone links that several page groups share: the vs pages' switcher,
     the docs' "see also", the blog's language and Free/Pro links, the changelog button. */
  .vs-nav a, .see-also a, .lang-switch a, .cta-box p > a, .older-releases button {
    display: inline-flex; align-items: center; min-height: 44px; }
  .more-link { display: flex; align-items: center; justify-content: center; min-height: 44px; }
  /* A 44 px target inside a line of text without moving the line: the padding is taken
     back by the margin. For short links (an address, a source) in legal text and sign-offs. */
  .legal-content a[href^="mailto:"], .legal-content li a, .content li a, .signoff a, .stat-src a {
    display: inline-block; padding: 12px 0; margin: -12px 0; }
}
@media (max-width: 480px) {
  .site-header { padding: 6px 10px; }
  .header-right { gap: 4px; }
  .brand { gap: 7px; }
  .brand-word { font-size: 1.28rem; }
}
/* The narrowest phones, and larger phones with Display Zoom on, lay out at 320-370px.
   The logo mark stays (the link keeps its "Sæga" label); the word goes. */
@media (max-width: 370px) {
  .brand-word { display: none; }
  .site-header .btn-sm { padding: 0 12px; font-size: 0.84rem; }
}

/* Text for screen readers only, e.g. "Nej" behind a dash in a table. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
