/* base.css – återställning, designtokens, typografi och formulärgrunder */

/* Designtokens (ljust tema som standard) */

:root {
  color-scheme: light;

  /* Papper och ytor */
  --c-bg: #f6f3ed;
  --c-bg-alt: #eee9df;
  --c-surface: #fffefb;
  --c-surface-2: #f2eee6;

  /* Linjer är tunna och ljusa – ingen svart inramning */
  --c-ink: #2a2622;
  --c-border: #e0d9cc;
  --c-border-strong: #cbc2b1;

  --c-text: #2a2622;
  --c-text-soft: #4f4941;
  --c-muted: #837b6f;

  /* Spelfärger, dämpade ett snäpp */
  --c-red: #b8462f;
  --c-yellow: #e0b23f;
  --c-teal: #2c8175;
  --c-blue: #3a6398;

  --c-accent: #b8462f;
  --c-accent-hover: #9c3a26;
  --c-accent-soft: #f6e3dd;
  --c-on-accent: #fffefb;

  --c-ok: #2b7350;
  --c-ok-soft: #dcece2;
  --c-warn: #8a6314;
  --c-warn-soft: #f4e8cd;
  --c-danger: #a93c2b;
  --c-danger-soft: #f6e0da;
  --c-info: #2d5c85;
  --c-info-soft: #dee8f1;

  /* Kanter och mjuka skuggor */
  --border-w: 1px;
  --border-w-thin: 1px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  --shadow-1: 0 1px 2px rgb(42 38 34 / 5%);
  --shadow-2: 0 2px 10px rgb(42 38 34 / 7%);
  --shadow-3: 0 10px 28px rgb(42 38 34 / 10%);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  --font-body: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --font-heading: "Segoe UI Semibold", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --font-mono: "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

  --content-width: 76rem;
  --header-height: 4.5rem;
  --transition: 120ms ease;
}

/* Återställning */

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--c-text);
  background-color: var(--c-bg);
  transition: background-color var(--transition), color var(--transition);
}

/* hidden ska slå igenom även på element med egen display */
[hidden] { display: none !important; }

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

/* Typografi */

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 var(--space-3);
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.25rem); }
h2 { font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem); }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

p { margin: 0 0 var(--space-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--c-accent);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--c-accent) 35%, transparent);
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--c-accent-hover);
  text-decoration-color: currentColor;
}

ul, ol { margin: 0 0 var(--space-4); padding-left: 1.25rem; }

code, kbd, pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

code {
  background: var(--c-surface-2);
  border-radius: var(--radius-sm);
  padding: 0.05em 0.35em;
}

pre {
  background: var(--c-surface-2);
  border: var(--border-w) solid var(--c-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
}

hr {
  border: 0;
  border-top: var(--border-w) solid var(--c-border);
  margin: var(--space-5) 0;
}

/* Fokus och tillgänglighet */

:focus-visible {
  outline: 2px solid var(--c-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -5rem;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--c-surface);
  color: var(--c-text);
  border: var(--border-w) solid var(--c-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--transition);
}

.skip-link:focus {
  top: var(--space-3);
  color: var(--c-text);
}

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

.noscript {
  margin: var(--space-5);
  padding: var(--space-4);
  border: var(--border-w) solid var(--c-border);
  border-left: 3px solid var(--c-danger);
  border-radius: var(--radius-md);
  background: var(--c-danger-soft);
  color: var(--c-text);
  font-weight: 600;
}

/* Formulärgrunder */

input, select, textarea, button {
  font: inherit;
  color: inherit;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.7rem;
  background: var(--c-surface);
  color: var(--c-text);
  border: var(--border-w) solid var(--c-border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:hover, select:hover, textarea:hover {
  border-color: var(--c-muted);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-accent) 15%, transparent);
}

textarea { min-height: 6rem; resize: vertical; }

fieldset {
  border: 0;
  border-top: var(--border-w) solid var(--c-border);
  padding: var(--space-4) 0 0;
  margin: 0 0 var(--space-5);
}

legend {
  padding: 0 var(--space-2) 0 0;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--c-muted);
}

label { font-weight: 600; }

::placeholder { color: var(--c-muted); opacity: 1; }

/* Tabellgrunder */

table {
  width: 100%;
  border-collapse: collapse;
}

caption {
  text-align: left;
  color: var(--c-muted);
  padding-bottom: var(--space-2);
}

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