/* =========================================================
   FoUsmart – grund (biljett 01)
   Tokens, typsnitt, typografi, layout, knappar, statusfärger,
   produktytor och reveal. Sektionsfiler ligger bredvid:
   assets/css/<sektions-id>.css
   ========================================================= */

/* ---------- Typsnitt (lokala, OFL, latin-delmängd) ---------- */
@font-face { font-family: "Inter"; src: url("../fonts/inter-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter Display"; src: url("../fonts/inter-display-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter Display"; src: url("../fonts/inter-display-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("../fonts/instrument-serif-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("../fonts/instrument-serif-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  /* Märkesfärger (HEMSIDESPEC.md) */
  --paper: #f6f4ef;          /* varm benvit, sidans bakgrund */
  --paper-2: #eeebe3;        /* alternativ ljus yta för omväxling mellan sektioner */
  --card: #fcfbf8;           /* kort och produktytor på ljus botten */
  --white: #fff;             /* ljusaste yta inne i produktbilder */
  --card-2: #f9f8f4;         /* namnraden i produktfönster */
  --ink: #111214;            /* text och mörka sektioner */
  --ink-2: #44464b;          /* sekundär text på ljus botten */
  --ink-3: #64666b;          /* etiketter, mono, 4.9:1 mot --paper */
  --line: #dcd7cb;           /* hårlinjer på ljus botten */
  --line-2: #cbc5b7;

  --green: #1f4d45;          /* märkesfärg, djupgrön */
  --green-deep: #173b35;
  --green-ink: #e9f0ec;      /* text på grön botten */
  --green-ink-2: #b9cdc6;    /* sekundär text på grön botten, 6.9:1 */
  --green-line: #2f6158;

  --lime: #c6f36b;           /* accent: knappar, markeringar */
  --lime-deep: #b4e352;      /* hover */
  --lime-wash: #e6f8bf;      /* markerad mening i källutdrag */

  --night: #111214;          /* mörka sektioner */
  --night-2: #1a1b1e;        /* kort på mörk botten */
  --night-3: #24262a;
  --night-line: #2c2e33;
  --night-ink: #f1efe9;
  --night-ink-2: #a9aaa7;    /* 7.6:1 mot --night */

  /* Statusfärger för utlåtanden. -fg är text på ljus botten (>=4.5:1 mot --card), -bg chipbotten, -on-dark på mörk botten */
  --ok-fg: #1d6b3f;   --ok-bg: #dff1e3;   --ok-dot: #2f9e5c;   --ok-on-dark: #7fdca2;
  --warn-fg: #8a5300; --warn-bg: #f8e8c6; --warn-dot: #e09a1a; --warn-on-dark: #f3be5a;
  --no-fg: #a7291d;   --no-bg: #f8dfd9;   --no-dot: #d6463a;  --no-on-dark: #ff9d90;

  /* Typsnittsfamiljer */
  --font-display: "Inter Display", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-serif: "Instrument Serif", ui-serif, Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Typskala */
  --fs-h1: clamp(2.75rem, 1.3rem + 5.4vw, 6rem);
  --fs-h2: clamp(2.125rem, 1.35rem + 3vw, 4rem);
  --fs-h3: 1.1875rem;
  --fs-lead: clamp(1.125rem, 1.04rem + 0.35vw, 1.3125rem);
  --fs-body: 1.0625rem;
  --fs-small: 0.9375rem;
  --fs-mono: 0.8125rem;
  --fs-label: 0.75rem;

  /* Layout */
  --wrap: 1240px;
  --gutter: clamp(20px, 4.2vw, 56px);
  --section-y: clamp(96px, 7rem + 4vw, 184px);
  --nav-h: 68px;

  /* Form */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Djup: produktytor får skugga, inget annat */
  --shadow-product: 0 1px 2px rgb(17 18 20 / 0.06), 0 12px 32px -8px rgb(17 18 20 / 0.14), 0 32px 64px -24px rgb(31 77 69 / 0.18);
  --shadow-lift: 0 1px 2px rgb(17 18 20 / 0.06), 0 8px 20px -6px rgb(17 18 20 / 0.16);

  /* Rörelse */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);      /* reveal, glid in (Ramp) */
  --ease-out-soft: cubic-bezier(0.33, 1, 0.68, 1); /* skugga, små tillstånd (Attio ease-out-cubic) */
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);   /* utfällning, byte på plats (Attio) */
  --ease-std: cubic-bezier(0.4, 0, 0.2, 1);        /* fokus-blur, dialog (Ramp) */
  --ease-draw: linear;                             /* linjer och ramar som ritas */
  --dur-press: 50ms;
  --dur-1: 160ms;
  --dur-2: 320ms;
  --dur-3: 600ms;
  --dur-reveal: 900ms;
  --dur-draw: 1800ms;
  --dur-think: 2000ms;                             /* text-svep "tänker" */

  color-scheme: light;
}

/* ---------- Bas ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }

[hidden] { display: none !important; }

::selection { background: var(--lime); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
  border-radius: 4px;
}
.tone-dark :focus-visible,
.tone-green :focus-visible { outline-color: var(--lime); }

a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }

p { margin: 0; }

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  color: inherit;
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-h1);
  line-height: 0.98;
  letter-spacing: -0.035em;
}

h2 {
  font-size: var(--fs-h2);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

h3 {
  font-family: var(--font-body);
  font-size: var(--fs-h3);
  line-height: 1.3;
  letter-spacing: -0.012em;
}

.lead {
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--ink-2);
  text-wrap: pretty;
  max-width: 36em;
}

.prose { max-width: 38em; text-wrap: pretty; }
.prose p + p { margin-top: 1em; }

.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0;
  font-feature-settings: "zero" 0;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Markerad mening (källutdrag, fakta) */
mark,
.mark {
  background: var(--lime-wash);
  color: inherit;
  padding: 0.05em 0.2em;
  margin: 0 -0.1em;
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  padding-block: var(--section-y);
}

.section-head { display: grid; gap: 24px; max-width: 46rem; }
.section-head h2 { max-width: 16em; }

/* Toner för sektioner: ljus (standard), alternativ ljus, mörk, grön */
.tone-paper-2 { background: var(--paper-2); }
.tone-dark { background: var(--night); color: var(--night-ink); }
.tone-dark .lead, .tone-dark .muted { color: var(--night-ink-2); }
.tone-green { background: var(--green); color: var(--green-ink); }
.tone-green .lead, .tone-green .muted { color: var(--green-ink-2); }

.muted { color: var(--ink-2); }

/* Hoppa till innehållet */
.skip-link {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-150%);
}
.skip-link:focus-visible { transform: none; }

/* ---------- Sidhuvud ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgb(246 244 239 / 0.94);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-2) var(--ease-out);
}
@supports (backdrop-filter: blur(1px)) {
  .site-header { background: rgb(246 244 239 / 0.82); backdrop-filter: saturate(1.4) blur(14px); }
}
.site-header.is-scrolled { border-bottom-color: var(--line); }

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--nav-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1875rem;
  letter-spacing: -0.02em;
}
.brand__mark { width: 22px; height: 22px; flex: none; }

.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a:not(.btn) {
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  transition: color var(--dur-1) ease, background-color var(--dur-1) ease;
}
.site-nav a:not(.btn):hover { color: var(--ink); background: rgb(17 18 20 / 0.05); }
.site-nav .btn { margin-left: 12px; }

@media (max-width: 860px) {
  .site-nav a:not(.btn) { display: none; }
  .site-nav .btn { margin-left: 0; }
}

/* ---------- Knappar ---------- */
.btn {
  --btn-bg: var(--lime);
  --btn-fg: var(--ink);
  --btn-bg-hover: var(--lime-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  box-shadow: inset 0 -1px 0 rgb(17 18 20 / 0.12), 0 1px 2px rgb(17 18 20 / 0.08);
  transition: background-color var(--dur-1) ease, transform var(--dur-1) var(--ease-out), box-shadow var(--dur-1) ease;
}
.btn:hover { background: var(--btn-bg-hover); transform: translateY(-1px); box-shadow: inset 0 -1px 0 rgb(17 18 20 / 0.12), 0 6px 16px -6px rgb(17 18 20 / 0.3); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn__arrow { width: 16px; height: 16px; transition: transform var(--dur-2) var(--ease-out); }
.btn:hover .btn__arrow { transform: translateX(3px); }

.btn--sm { min-height: 40px; padding: 0 16px; font-size: var(--fs-small); border-radius: 10px; }

.btn--ink { --btn-bg: var(--ink); --btn-fg: var(--paper); --btn-bg-hover: #2a2c30; }

/* Textlänk med pil */
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-underline-offset: 0.25em;
}

/* ---------- Märkning och etiketter ---------- */

/* Pill som visar att tjänsten är under utveckling */
.notice {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--card);
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--ink-2);
}
.notice__dot {
  position: relative;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--warn-dot);
  box-shadow: 0 0 0 3px rgb(224 154 26 / 0.18);
}

/* "Exempel med påhittade uppgifter" och liknande */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgb(17 18 20 / 0.06);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
.tone-dark .tag { background: rgb(255 255 255 / 0.08); color: var(--night-ink-2); }
.tone-green .tag { background: rgb(255 255 255 / 0.1); color: var(--green-ink-2); }

/* ---------- Statusfärger för utlåtanden ----------
   <span class="status status--ok">Har rätt</span>
   status--ok (har rätt) · status--warn (behöver granskas) · status--no (har inte rätt) */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 8px;
  border-radius: var(--r-pill);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.status--ok { color: var(--ok-fg); background: var(--ok-bg); }
.status--warn { color: var(--warn-fg); background: var(--warn-bg); }
.status--no { color: var(--no-fg); background: var(--no-bg); }
.status--ok::before { background: var(--ok-dot); }
.status--warn::before { background: var(--warn-dot); }
.status--no::before { background: var(--no-dot); }

/* ---------- Produktytor ----------
   Delas av inledningen, stegen och exemplet. */
.surface {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.app-frame {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow-product), 0 0 0 1px rgb(17 18 20 / 0.07);
  overflow: hidden;
  color: var(--ink);
}
.app-frame__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card-2);
  font-size: var(--fs-small);
}
.app-frame__crumb { color: var(--ink-3); font-family: var(--font-mono); font-size: var(--fs-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-frame__crumb b { color: var(--ink); font-weight: 500; }
.app-frame__bar .tag { margin-left: auto; }

/* Källa i mono */
.source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  color: var(--ink-3);
}
.source__doc {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgb(17 18 20 / 0.05);
  color: var(--ink-2);
}

/* Fotnot med källa */
.footnote {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  color: var(--ink-3);
}
.footnote a { color: inherit; }
.footnote a:hover { color: var(--ink); }
.tone-dark .footnote { color: var(--night-ink-2); }
.tone-dark .footnote a:hover { color: var(--night-ink); }

/* ---------- Reveal (motion.js) ----------
   Sätt data-reveal på ett element. motion.js lägger klassen .reveal-pending
   bara på element som ligger under skärmen när sidan laddas. När elementet syns
   byts den mot .reveal-run (övergången), som tas bort när övergången är klar så
   att elementets egna hover-övergångar fungerar igen. Utan JS eller vid minskad rörelse syns allt direkt.
   Fördröjning: style="--reveal-delay: 120ms" eller data-reveal-stagger på en förälder. */
@media (prefers-reduced-motion: no-preference) {
  [data-reveal].reveal-pending {
    opacity: 0;
    transform: translate3d(0, 24px, 0);
    filter: blur(4px);
  }
  [data-reveal].reveal-run {
    transition:
      opacity var(--dur-reveal) var(--ease-out),
      transform var(--dur-reveal) var(--ease-out),
      filter var(--dur-reveal) var(--ease-out);
    transition-delay: var(--reveal-delay, 0ms);
  }
}
