/* Spanly – grund: typsnitt, tokens, typografi och komponenter som delas av alla sidor. */

/* ---------- Typsnitt (självhostade, OFL) ---------- */
@font-face {
  font-family: 'Schibsted Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url(../fonts/schibsted-grotesk-latin-wght-normal.woff2?v=f5a306f465) 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: 'Schibsted Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url(../fonts/schibsted-grotesk-latin-ext-wght-normal.woff2?v=3af21f587a) 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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(../fonts/ibm-plex-mono-latin-400-normal.woff2?v=41e1208bd1) 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-display: swap;
  font-weight: 400;
  src: url(../fonts/ibm-plex-mono-latin-ext-400-normal.woff2?v=854ed0c590) 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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(../fonts/ibm-plex-mono-latin-500-normal.woff2?v=425916c873) 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-display: swap;
  font-weight: 500;
  src: url(../fonts/ibm-plex-mono-latin-ext-500-normal.woff2?v=182c3593f7) 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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
  --paper: #F6F5F1;
  --paper-2: #EFEDE7;
  --white: #FFFFFF;
  --ink: #121820;
  --ink-2: #2A323C;
  --graphite: #5A636E;
  --graphite-2: #646C76; /* ≥ 4,5:1 mot --paper-2 och ljusare (AA för 10–11 px) */
  --line: #E2E0D9;
  --line-2: #D2CFC5;
  --deep: #1F5A41;
  --deep-700: #184A35;
  --deep-800: #123826;
  --deep-50: #E3EFE8;
  --brass: #E06A12;
  --brass-light: #F57C22;
  --brass-dark: #A44E0E;

  --ok: #1D7A4E;   --ok-bg: #E4F2EA;
  --risk: #9A5207; --risk-bg: #FBEEDD;
  --bad: #B42318;  --bad-bg: #FBE6E4;
  --unk: #5C6370;  --unk-bg: #EEEFF1;

  --sans: 'Schibsted Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --r-xs: 3px;
  --r-sm: 4px;
  --r: 6px;
  --r-lg: 8px;

  --wrap: 1200px;
  --gutter: clamp(20px, 4vw, 40px);
  --header-h: 64px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --focus: 0 0 0 2px var(--paper), 0 0 0 4px var(--deep);
  color-scheme: light;
}

/* ---------- Grund ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  font-feature-settings: 'kern' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--deep); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--deep-700); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; line-height: 1.15; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; }
[hidden] { display: none !important; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
code, kbd, samp, pre, .mono { font-family: var(--mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
::selection { background: var(--deep-50); color: var(--ink); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--deep); outline-offset: 2px; border-radius: var(--r-xs); }
.on-dark :focus-visible, .dark :focus-visible { outline-color: var(--brass-light); }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: var(--r); font-weight: 550; text-decoration: none; transition: top .15s; }
.skip-link:focus { top: 12px; color: var(--paper); }

.wrap { width: 100%; max-width: calc(var(--wrap) + var(--gutter) * 2); margin: 0 auto; padding: 0 var(--gutter); }
.wrap-narrow { max-width: calc(760px + var(--gutter) * 2); }

/* ---------- Typografi ---------- */
.display { font-size: clamp(2.5rem, 1.4rem + 4.2vw, 4.5rem); font-weight: 680; letter-spacing: -0.028em; line-height: 1.02; }
.h1 { font-size: clamp(2.1rem, 1.5rem + 2.4vw, 3.25rem); font-weight: 670; letter-spacing: -0.022em; line-height: 1.06; }
.h2 { font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem); font-weight: 660; letter-spacing: -0.018em; line-height: 1.1; }
.h3 { font-size: 1.25rem; font-weight: 640; letter-spacing: -0.01em; line-height: 1.25; }
.h4 { font-size: 1.0625rem; font-weight: 620; letter-spacing: -0.005em; line-height: 1.3; }
.lead { font-size: clamp(1.0625rem, 1rem + .35vw, 1.25rem); line-height: 1.55; color: var(--ink-2); }
.muted { color: var(--graphite); }
.small { font-size: .875rem; }
.tiny { font-size: .8125rem; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font: 500 .75rem/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--graphite);
}
.eyebrow::before { content: ''; width: 14px; height: 2px; background: var(--brass); }

/* ---------- Knappar ---------- */
.btn {
  --h: 42px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--r);
  font-weight: 560; font-size: .9375rem; line-height: 1; letter-spacing: -0.003em;
  text-decoration: none; white-space: nowrap; user-select: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--deep); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--deep-700); color: var(--white); }
.btn-secondary { background: var(--white); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover:not(:disabled) { border-color: var(--graphite-2); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: rgba(18, 24, 32, .05); color: var(--ink); }
.btn-danger { background: var(--white); color: var(--bad); border-color: #E8B7B1; }
.btn-danger:hover:not(:disabled) { background: var(--bad-bg); color: var(--bad); }
.btn-danger-solid { background: var(--bad); color: var(--white); }
.btn-danger-solid:hover:not(:disabled) { background: #8f1c13; color: var(--white); }
.btn-light { background: var(--paper); color: var(--ink); }
.btn-light:hover:not(:disabled) { background: var(--white); color: var(--ink); }
.btn-lg { --h: 48px; padding: 0 22px; font-size: 1rem; }
.btn-sm { --h: 34px; padding: 0 12px; font-size: .875rem; }
.btn-xs { --h: 28px; padding: 0 9px; font-size: .8125rem; border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn .arrow { transition: transform .2s var(--ease); }
.btn:hover .arrow { transform: translateX(2px); }
.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 560; text-decoration: none; }
.link-arrow:hover { text-decoration: underline; }

/* ---------- Formulär ---------- */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: 16px; }
.label { font-size: .875rem; font-weight: 560; color: var(--ink); }
.label .opt { font-weight: 400; color: var(--graphite); }
.hint { font-size: .8125rem; color: var(--graphite); }
.input, .select, .textarea {
  width: 100%; height: 44px; padding: 0 12px;
  background: var(--white); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: #68707B; } /* 4,5:1 mot vitt (WCAG 1.4.3) */
.input:hover, .select:hover, .textarea:hover { border-color: var(--graphite-2); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--deep); box-shadow: 0 0 0 3px var(--deep-50); }
.input[aria-invalid='true'] { border-color: var(--bad); }
.input[aria-invalid='true']:focus { box-shadow: 0 0 0 3px var(--bad-bg); }
.input-mono { font-family: var(--mono); font-size: .9375rem; }
.select {
  appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235A636E' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .9375rem; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--deep); margin: 0; }

.form-error, .form-ok {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--r); font-size: .9063rem; line-height: 1.45;
}
.form-error { background: var(--bad-bg); color: #7A1810; border: 1px solid #F0C6C0; }
.form-ok { background: var(--ok-bg); color: #145838; border: 1px solid #BFDFCC; }
.form-error[hidden], .form-ok[hidden] { display: none; }

/* ---------- Statusbrickor ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px 0 7px;
  border-radius: var(--r-sm);
  font-size: .75rem; font-weight: 580; line-height: 1; letter-spacing: .005em;
  white-space: nowrap;
  background: var(--unk-bg); color: var(--unk);
}
.badge svg { width: 10px; height: 10px; flex: none; }
.badge-giltig { background: var(--ok-bg); color: var(--ok); }
.badge-riskabel { background: var(--risk-bg); color: var(--risk); }
.badge-ogiltig { background: var(--bad-bg); color: var(--bad); }
.badge-okand { background: var(--unk-bg); color: var(--unk); }
.badge-neutral { background: var(--paper-2); color: var(--graphite); }
.badge-deep { background: var(--deep-50); color: var(--deep-700); }
.badge-brass { background: #FCEBDD; color: var(--brass-dark); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border: 1px solid var(--line); border-radius: var(--r-xs); font: 500 .6875rem/1 var(--mono); letter-spacing: .03em; text-transform: uppercase; color: var(--graphite); background: var(--white); }

/* ---------- Kort och ytor ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); }
.rule-top { border-top: 1px solid var(--ink); padding-top: 18px; }

/* ---------- Sidhuvud ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: rgba(246, 245, 241, .86);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
}
.site-header.is-scrolled { background: rgba(255, 255, 255, .92); border-bottom-color: var(--line); }
.site-header .wrap { height: 100%; display: flex; align-items: center; gap: 28px; }
.brand-link { display: inline-flex; align-items: center; flex: none; border-radius: var(--r-sm); }
.brand-link img { height: 34px; width: auto; }
.site-nav { display: flex; align-items: center; gap: 2px; margin: 0 auto; }
.site-nav a {
  padding: 8px 12px; border-radius: var(--r);
  color: var(--ink-2); text-decoration: none; font-size: .9375rem; font-weight: 500;
}
.site-nav a:hover { color: var(--ink); background: rgba(18, 24, 32, .045); }
.site-nav a[aria-current='page'] { color: var(--ink); font-weight: 580; }
.header-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.header-actions .login { padding: 8px 12px; color: var(--ink); text-decoration: none; font-weight: 540; font-size: .9375rem; border-radius: var(--r); }
.header-actions .login:hover { background: rgba(18, 24, 32, .045); }
.menu-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--white); align-items: center; justify-content: center; }
.menu-toggle span, .menu-toggle span::before, .menu-toggle span::after { display: block; width: 16px; height: 1.6px; background: var(--ink); position: relative; transition: transform .2s var(--ease), background-color .2s; }
.menu-toggle span::before, .menu-toggle span::after { content: ''; position: absolute; left: 0; }
.menu-toggle span::before { top: -5px; }
.menu-toggle span::after { top: 5px; }
.menu-toggle[aria-expanded='true'] span { background: transparent; }
.menu-toggle[aria-expanded='true'] span::before { transform: translateY(5px) rotate(45deg); }
.menu-toggle[aria-expanded='true'] span::after { transform: translateY(-5px) rotate(-45deg); }

@media (max-width: 900px) {
  .site-nav { display: none; }
  .header-actions { margin-left: auto; }
  .header-actions .login { display: none; }
  .menu-toggle { display: inline-flex; }
  .site-header.menu-open { background: var(--white); border-bottom-color: var(--line); }
  .site-header.menu-open .site-nav {
    display: flex; flex-direction: column; align-items: stretch; gap: 0;
    position: fixed; top: var(--header-h); left: 0; right: 0; height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h));
    background: var(--white); padding: 12px var(--gutter) 32px; margin: 0; overflow-y: auto;
  }
  .site-header.menu-open .site-nav a { padding: 16px 4px; border-bottom: 1px solid var(--line); border-radius: 0; font-size: 1.125rem; }
  .site-header.menu-open .site-nav .nav-mobile-only { display: block; }
}
.nav-mobile-only { display: none; }
@media (max-width: 420px) { .header-actions .btn { padding: 0 12px; } }

/* ---------- Sidfot ---------- */
.site-footer { background: var(--ink); color: #B9C0C8; padding: 72px 0 36px; font-size: .9375rem; }
.site-footer a { color: #D9DEE3; text-decoration: none; }
.site-footer a:hover { color: var(--white); text-decoration: underline; }
.footer-top { display: grid; grid-template-columns: 1.3fr repeat(3, 1fr); gap: 40px; }
.footer-brand img { height: 26px; width: auto; }
.footer-brand p { margin-top: 18px; max-width: 30ch; color: #98A1AB; }
.footer-col h2 { font: 500 .75rem/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: #7E8893; margin-bottom: 16px; }
.footer-col ul { list-style: none; display: grid; gap: 10px; }
.footer-bottom { margin-top: 64px; padding-top: 22px; border-top: 1px solid #27303A; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; color: #7E8893; font-size: .8125rem; }
.footer-bottom .mono { font-size: .8125rem; }
.footer-ruler { height: 10px; margin-top: 56px; background-image: repeating-linear-gradient(90deg, #2E3742 0 1px, transparent 1px 8px); }
@media (max-width: 820px) { .footer-top { grid-template-columns: 1fr 1fr; } .footer-brand { grid-column: 1 / -1; } }

/* ---------- Testlägesbanner ---------- */
.testmode-bar { background: var(--ink); color: var(--paper); font-size: .8125rem; text-align: center; padding: 7px 16px; line-height: 1.4; }
.testmode-bar strong { color: var(--brass-light); font-weight: 600; font-family: var(--mono); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; margin-right: 8px; }

/* ---------- Toast ---------- */
.toast-region { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r); font-size: .9063rem; box-shadow: 0 8px 24px rgba(18, 24, 32, .18); animation: toast-in .25s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Rörelse ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
