:root {
  --bg: #f7f5f0;
  --text: #1f2933;
  --muted: #52606d;
  --accent: #0b5a4a;
  --accent-bg: #e3f0ec;
  --card: #ffffff;
  --line: #d9d4c7;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
header, main, footer { max-width: 860px; margin: 0 auto; padding: 0 16px; }
header { padding-top: 28px; }
#brand { font-size: 1.9rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
#brand a { color: inherit; text-decoration: none; }
#brand a:hover, #brand a:focus-visible { text-decoration: underline; text-underline-offset: 4px; }
#brand span { display: block; font-size: 0.85rem; font-weight: 400; color: var(--muted); margin-top: 4px; }
.intro { color: var(--muted); margin: 12px 0 20px; }

#fragor { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
#fragor button {
  font: inherit; font-size: 0.95rem; text-align: left;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text); cursor: pointer;
}
#fragor button[aria-selected="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
#fragor button:hover { border-color: var(--accent); }
:focus-visible { outline: 3px solid #b45309; outline-offset: 2px; }

#svar { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 20px 16px; margin-bottom: 20px; }
#svar h2 { font-size: 1.25rem; margin: 14px 0 8px; }
#svar h3 { font-size: 1rem; margin: 18px 0 6px; color: var(--accent); }
#svar p { margin: 8px 0; }
#svar h4 { font-size: 1rem; margin: 16px 0 4px; }
#svar a.verktyg { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

h3.grupp { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); margin: 22px 0 8px; }
.grupp-d { margin: 12px 0; }
.grupp-d > summary {
  cursor: pointer; list-style: none; position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 44px 12px 16px; display: flex; flex-direction: column; gap: 2px;
}
.grupp-d > summary::-webkit-details-marker { display: none; }
.grupp-d > summary::after { content: "＋"; position: absolute; right: 16px; top: 14px; color: var(--accent); }
.grupp-d[open] > summary::after { content: "－"; }
.grupp-d > summary:hover { border-color: var(--accent); }
.grupp-titel { font-size: 0.95rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
.grupp-text { color: var(--text); font-size: 0.95rem; }
.grupp-antal { color: var(--muted); font-size: 0.82rem; }
.grupp-inre { padding-top: 8px; }
h4.undergrupp { font-size: 0.95rem; color: var(--text); margin: 14px 0 8px; }
.kort { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 0 16px; }
.kort summary { cursor: pointer; padding: 12px 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.kort summary::-webkit-details-marker { display: none; }
.kort summary::before { content: "＋"; float: right; color: var(--accent); }
.kort[open] summary::before { content: "－"; }
.kort .kategori { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.kort .rubrik { font-weight: 650; }
.kort .rubrik-ar { font-weight: 400; color: var(--muted); white-space: nowrap; }
.kort p { margin: 6px 0; }
.kort .markning { font-size: 0.85rem; color: var(--muted); background: var(--accent-bg); display: inline-block; padding: 2px 8px; border-radius: 6px; }

/* Uppdatering 2026-10-01: pulserande variant för "Siffrorna är påhittade"
   — synlig rörelse utan att skrika, respekterar prefers-reduced-motion. */
@keyframes markning-puls {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}
.kort .markning.pulsande {
  animation: markning-puls 1.6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .kort .markning.pulsande { animation: none; }
}
.kort .lank { display: table; margin: 6px 0; color: var(--accent); font-weight: 600; }
.kort .lank:last-child { margin-bottom: 14px; }
.kort.utan-lank { background: #fbfaf7; }
.kort .medie-ar { font-weight: 700; margin: 14px 0 2px; }
.kort .medie { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; margin: 6px 0; }
.kort .medium { flex: none; width: 88px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.kort .medie a.lank { display: inline; margin: 0; }
.kort .medie-not { font-size: 0.85rem; color: var(--muted); }
.kort .medie-grupp:last-child { margin-bottom: 14px; }

/* Ämne över flera år: när kortet fälls ut tonas äldre år ut medan det senaste tonas fram. */
.kort.med-rorelse .medie-grupp.aldre { opacity: var(--mal, 0.45); transition: opacity 0.2s ease; }
.kort.med-rorelse .medie-grupp.aldre:hover,
.kort.med-rorelse .medie-grupp.aldre:focus-within { opacity: 1; }
.kort.med-rorelse[open] .medie-grupp.nyast { animation: tona-fram 2s ease 0.3s backwards; }
.kort.med-rorelse[open] .medie-grupp.aldre { animation: tona-ut 2s ease 0.3s backwards; }
@keyframes tona-fram { from { opacity: 0.25; } }
@keyframes tona-ut { from { opacity: 1; } }
.kort .info-knapp { flex: none; border: 0; background: none; color: var(--accent); font-size: 1rem; line-height: 1; padding: 0 4px; cursor: pointer; }
.kort .medie-info { margin: 2px 0 8px 98px; padding: 8px 10px; background: var(--accent-bg); border-radius: 6px; font-size: 0.9rem; }
.kort .medie a.lank[title] { text-decoration-style: dotted; }
@media (prefers-reduced-motion: reduce) {
  .kort.med-rorelse[open] .medie-grupp { animation: none; }
}
.kort.med-bild summary { flex-direction: row; align-items: center; gap: 12px; }
.kort.med-bild summary::before { float: none; order: 3; margin-left: auto; }
.kort.med-bild .rubrik { flex: 1; }
.bild-miniatyr { width: 88px; height: 60px; object-fit: cover; border-radius: 6px; flex: none; }
.kort[open] .bild-miniatyr { display: none; }
.bild-stor { display: none; max-width: 100%; height: auto; border-radius: 8px; margin: 4px 0 8px; }
.kort[open] .bild-stor { display: block; }
/* Flera bilder på ett kort växlar mjukt (script.js byter klassen `syns` var fjärde sekund). */
.bild-vaxel { display: grid; }
.bild-vaxel img { grid-area: 1 / 1; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1s ease; }
.bild-vaxel img.syns { opacity: 1; }
.bild-vaxel.bild-stor { overflow: hidden; }
.kort[open] .bild-vaxel.bild-stor { display: grid; }
.bild-vaxel.bild-miniatyr { overflow: hidden; }
.bild-text { font-size: 0.85rem; color: var(--muted); margin: 0 0 8px; }
@media (prefers-reduced-motion: reduce) { .bild-vaxel img { transition: none; } }

footer { padding: 24px 16px 40px; color: var(--muted); font-size: 0.9rem; }
footer a, noscript a { color: var(--accent); }

.corner {
  position: fixed; bottom: 14px; z-index: 10;
  font-family: "Courier New", Courier, monospace; font-size: 0.78rem;
  color: var(--muted); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.3rem 0.7rem; text-decoration: none; cursor: pointer;
  opacity: 0.55; transition: opacity 0.2s ease, color 0.2s ease;
}
.corner:hover { opacity: 1; color: var(--accent); }
.corner-left { left: 14px; }
.corner-right { right: 14px; }

.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 20; padding: 1rem;
  background: rgba(31, 41, 51, 0.55); align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  position: relative; background: var(--bg); border-radius: 16px;
  max-width: 640px; width: 100%; max-height: 85vh; overflow-y: auto; padding: 2rem;
}
.modal h2 { color: var(--accent); margin: 0 0 0.5rem; font-size: 1.4rem; }
.modal > p { color: var(--muted); font-size: 0.92rem; margin: 0 0 1.4rem; }
.modal a { color: var(--accent); }
.modal-close {
  position: absolute; top: 1rem; right: 1rem; background: none; border: none;
  font-size: 1.4rem; line-height: 1; color: var(--muted); cursor: pointer;
}
.tech-section-title { font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 1.4rem 0 0.7rem; }
.tech-section-title:first-of-type { margin-top: 0.4rem; }
.tech-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.tech-card h3 { font-size: 0.95rem; color: var(--accent); margin: 0 0 0.3rem; }
.tech-card p { font-size: 0.85rem; line-height: 1.5; margin: 0; }
.tech-card code { background: var(--accent-bg); border-radius: 4px; padding: 0.05rem 0.3rem; font-size: 0.82em; }

@media (max-width: 480px) {
  .kort .medie-info { margin-left: 0; }
  body { font-size: 16px; }
  #fragor button { width: 100%; }
}
@media (max-width: 640px) {
  .tech-grid { grid-template-columns: 1fr; }
  .modal { padding: 1.4rem; }
}
@media print {
  body { background: #fff; }
  #fragor, .corner, .modal-overlay { display: none; }
  .kort.med-rorelse .medie-grupp { opacity: 1 !important; animation: none !important; }
  .kort > * { display: block; }
  details.kort:not([open]) > *:not(summary) { display: block; }
  .kort summary::before { content: ""; }
}
