/* ============================================================
   Kunskapsbank (/wiki, /en/wiki and the article pages generated from the
   native "wiki" collection). Loaded only on those four templates, after
   animed.css, whose tokens it uses. Layout steps are @container queries
   against .uk-container, like the rest of the site.
   ============================================================ */

:root {
  --wk-side-w: 20rem;
  --wk-urgent-bg: var(--animed-red-100);
  --wk-urgent-fg: var(--animed-red-700);
}

/* ---------------------------------------------------------- shared bits */
.wk-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 0.8125rem; font-weight: 600; color: var(--animed-teal-800); line-height: 1.4; }
.wk-meta-sep { color: var(--animed-ink-300); font-weight: 400; }
/* Topic on article pages: a pill like the Akut badge, linking to the list. */
.wk-badge.wk-topic-pill { background: var(--animed-teal-100); color: var(--animed-teal-800); text-decoration: none; transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.wk-badge.wk-topic-pill:hover { background: var(--animed-teal-800); color: #fff; }
.wk-read { display: inline-flex; align-items: center; gap: 5px; color: var(--fg-muted); font-weight: 500; }
.wk-read svg { flex: none; }
.wk-badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--wk-urgent-bg); color: var(--wk-urgent-fg); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; }

/* Long Swedish compounds ("Livmoderinflammation") must wrap on small phones. */
.wk-title, .wk-card-title, .wk-row-title, .wk-opt-title, .wk-hero-title { overflow-wrap: break-word; }
@container (max-width: 420px) { .wk-title { hyphens: auto; } }

/* Placeholder until a banner is uploaded to the entry's image field. */
.wk-ph svg { position: relative; z-index: 1; width: 44px; height: 44px; opacity: 0.55; }
.wk-banner .wk-ph svg { width: 72px; height: 72px; }

/* ---------------------------------------------------------- hub: hero */
.wk-hero { padding: 0 0 var(--space-12); }
.wk-hero-panel { padding: var(--space-10) 0 var(--space-4); text-align: center; }
.wk-hero-title { margin: 0 auto var(--space-4); max-width: 18ch; }
.wk-hero-lead { margin: 0 auto var(--space-8); max-width: 60ch; }
.wk-hero-note { margin: var(--space-5) 0 0; font-size: 0.9375rem; color: var(--fg-muted); }
@container (max-width: 560px) {
  .wk-hero-panel { padding: var(--space-6) 0 0; }
  .wk-hero-lead { font-size: 1.0625rem; }
}
.wk-hero-note a { color: var(--wk-urgent-fg); font-weight: 600; white-space: nowrap; }

/* ---------------------------------------------------------- hub: search */
.wk-search { position: relative; max-width: 640px; margin: 0 auto; text-align: left; }
.wk-search-box { position: relative; }
.wk-search-box svg { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); color: var(--animed-teal-800); pointer-events: none; }
.wk-search-input { width: 100%; padding: 18px 22px 18px 54px; border-radius: var(--radius-pill); border: 1.5px solid var(--border-default); background: #fff; font: inherit; font-size: 1.0625rem; color: var(--fg-default); box-shadow: var(--shadow-sm); -webkit-appearance: none; appearance: none; }
.wk-search-input::placeholder { color: var(--fg-subtle); }
.wk-search-input:focus-visible { outline: none; border-color: var(--border-focus); box-shadow: var(--shadow-focus), var(--shadow-sm); }
.wk-search-input::-webkit-search-cancel-button { cursor: pointer; }
.wk-search.is-open .wk-search-input { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

.wk-suggest { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: -1.5px 0 0; padding: var(--space-2); list-style: none; background: #fff; border: 1.5px solid var(--border-focus); border-top-color: var(--border-subtle); border-radius: 0 0 var(--radius-lg) var(--radius-lg); box-shadow: var(--shadow-lg); max-height: min(28rem, 70vh); overflow-y: auto; }
.wk-suggest[hidden] { display: none; }
.wk-opt { display: flex; align-items: center; gap: var(--space-3); padding: 10px 12px; border-radius: var(--radius-md); cursor: pointer; }
.wk-opt-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.wk-opt-title { font-family: var(--font-display); font-weight: 600; font-size: 1rem; line-height: 1.3; color: var(--fg-default); }
.wk-opt-title mark { background: var(--animed-amber-100); color: inherit; border-radius: 3px; padding: 0 1px; }
.wk-opt .wk-meta { font-weight: 500; color: var(--fg-muted); }
.wk-opt .wk-read, .wk-opt .wk-meta-sep:nth-last-child(2) { display: none; }
.wk-opt > svg { flex: none; color: var(--animed-teal-800); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
.wk-opt:hover, .wk-opt.is-active { background: var(--animed-cream-100); }
.wk-opt.is-active > svg, .wk-opt:hover > svg { opacity: 1; }
.wk-opt--more { border-top: 1px solid var(--border-subtle); border-radius: 0 0 var(--radius-md) var(--radius-md); margin-top: var(--space-1); }
.wk-opt--more .wk-opt-title { color: var(--fg-link); font-size: 0.9375rem; flex: 1; }
.wk-opt--more > svg { opacity: 1; }
.wk-empty { padding: 12px; margin: 0; font-size: 0.9375rem; color: var(--fg-muted); }
.wk-empty a { color: var(--fg-link); font-weight: 600; white-space: nowrap; }

/* ---------------------------------------------------------- hub: sections */
.wk-section { padding: var(--space-8) 0 var(--space-16); }
.wk-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
.wk-section-head .uk-h3 { margin: 0; }

.wk-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6); }
@container (max-width: 860px) { .wk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (max-width: 560px) { .wk-grid { grid-template-columns: minmax(0, 1fr); } }

.wk-card { display: flex; flex-direction: column; text-decoration: none; color: inherit; background: #fff; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out); }
.wk-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.wk-card-media { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--animed-cream-200); }
.wk-card-media .wk-badge { position: absolute; z-index: 2; top: 12px; left: 12px; }
.wk-card-body { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-5) var(--space-6) var(--space-6); flex: 1; }
.wk-card-title { font-family: var(--font-display); font-weight: 600; font-size: 1.1875rem; line-height: 1.25; letter-spacing: -0.01em; margin: 0; }
.wk-card-text { margin: 0; font-size: 0.9375rem; line-height: 1.55; color: var(--fg-muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wk-card .wk-read { margin-top: auto; padding-top: var(--space-2); font-size: 0.8125rem; }

.wk-filter { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.wk-chip { font-family: var(--font-display); font-weight: 600; font-size: 0.875rem; line-height: 1; padding: 10px 16px; border-radius: var(--radius-pill); border: 1.5px solid var(--animed-teal-800); background: transparent; color: var(--animed-teal-800); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.wk-chip:hover { background: var(--animed-teal-100); }
.wk-chip[aria-pressed="true"] { background: var(--animed-teal-800); color: #fff; }
.wk-select { font-family: var(--font-display); font-weight: 600; font-size: 0.875rem; line-height: 1; padding: 10px 36px 10px 16px; border-radius: var(--radius-pill); border: 1.5px solid var(--animed-teal-800); color: var(--animed-teal-800); background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%232E6868' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center; -webkit-appearance: none; appearance: none; cursor: pointer; max-width: 100%; }
.wk-select:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.wk-active { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin: 0 0 var(--space-4); font-size: 0.9375rem; color: var(--fg-muted); }
.wk-active[hidden] { display: none; }
.wk-clear { font: inherit; font-weight: 600; color: var(--fg-link); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.wk-pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--space-2); margin: var(--space-8) 0 0; }
.wk-pager[hidden] { display: none; }
.wk-page { font-family: var(--font-display); font-weight: 600; font-size: 0.9375rem; min-width: 44px; height: 44px; padding: 0 14px; border-radius: var(--radius-pill); border: 1.5px solid transparent; background: transparent; color: var(--animed-teal-800); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.wk-page:hover { background: var(--animed-teal-100); }
.wk-page[aria-current="page"] { background: var(--animed-teal-800); color: #fff; }
.wk-page-of { font-weight: 600; font-size: 0.9375rem; color: var(--fg-default); padding: 0 var(--space-3); }
.wk-page-gap { min-width: 20px; text-align: center; color: var(--fg-muted); }
.wk-page:disabled { opacity: 0.35; cursor: default; background: transparent; }
.wk-page--step { border-color: var(--animed-teal-800); }
@container (max-width: 520px) { .wk-page-label { display: none; } }
.wk-chip-n { font-family: var(--font-body); font-weight: 600; font-size: 0.75rem; opacity: 0.75; }

.wk-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-6); }
@container (max-width: 720px) { .wk-list { grid-template-columns: minmax(0, 1fr); } }
.wk-list > li[hidden] { display: none; }
/* A new page of the list fades in row by row (delay set per item in wiki.js). */
.wk-list > li.wk-in { animation: fadeUp 420ms var(--ease-out) both; }
.wk-row { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3); border-radius: var(--radius-md); text-decoration: none; color: inherit; background: #fff; box-shadow: var(--shadow-xs); transition: background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.wk-row:hover { box-shadow: var(--shadow-sm); background: var(--animed-cream-50); }
.wk-row-media { position: relative; flex: none; width: 64px; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--animed-cream-200); }
.wk-row-media .wk-ph svg { width: 26px; height: 26px; }
.wk-row-media .am-slot { padding: 0; }
.wk-row-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.wk-row-title { font-family: var(--font-display); font-weight: 600; font-size: 1rem; line-height: 1.3; }
.wk-row .wk-meta { font-weight: 500; color: var(--fg-muted); font-size: 0.8125rem; }
.wk-row > svg { flex: none; color: var(--animed-teal-800); }
.wk-list-empty { margin: var(--space-4) 0 0; color: var(--fg-muted); }

.wk-disclaimer { margin: var(--space-10) 0 0; font-size: 0.875rem; color: var(--fg-muted); max-width: 70ch; }

/* ---------------------------------------------------------- article */
.wk-layout { display: grid; grid-template-columns: minmax(0, 1fr) var(--wk-side-w); gap: var(--space-16); align-items: start; padding-bottom: var(--space-20); }
@container (max-width: 960px) { .wk-layout { gap: var(--space-10); --wk-side-w: 17rem; } }
@container (max-width: 820px) { .wk-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-12); } }

.wk-article { max-width: 760px; }
.wk-banner { position: relative; aspect-ratio: 2 / 1; border-radius: var(--radius-2xl); overflow: hidden; background: var(--animed-cream-200); margin: 0 0 var(--space-8); }
.wk-article .wk-meta { margin-bottom: var(--space-3); }
.wk-title { margin: 0 0 var(--space-4); }
.wk-lead { margin: 0 0 var(--space-8); font-size: 1.1875rem; line-height: 1.6; font-weight: 500; color: var(--animed-ink-900); text-wrap: pretty; }
.wk-h2 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.35rem, 1rem + 1.2vw, 1.625rem); letter-spacing: -0.01em; line-height: 1.2; margin: 0 0 var(--space-3); }
.wk-body { font-size: 1.0625rem; line-height: 1.7; color: var(--fg-default); }
.wk-body p { margin: 0 0 var(--space-5); }
.wk-body a { color: var(--fg-link); }

.wk-cta { margin: var(--space-8) 0 0; }
.wk-cta-text { margin: 0 0 var(--space-5); font-family: var(--font-display); font-weight: 600; font-size: 1.125rem; line-height: 1.4; color: var(--fg-default); text-wrap: pretty; }
.wk-cta-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.wk-cta--urgent .wk-badge { margin-bottom: var(--space-3); }
@container (max-width: 520px) {
  .wk-cta-actions .uk-btn { flex: 1 1 100%; }
}

.wk-sources { margin: var(--space-10) 0 0; padding-top: var(--space-6); border-top: 1px solid var(--border-subtle); }
.wk-sources-title { font-family: var(--font-display); font-weight: 600; font-size: 1.0625rem; margin: 0 0 var(--space-3); }
.wk-sources ol { margin: 0; padding-left: 1.3em; font-size: 0.875rem; line-height: 1.55; color: var(--fg-muted); }
.wk-sources li { margin: 0 0 var(--space-2); padding-left: 2px; }
.wk-sources a { color: var(--fg-link); font-weight: 500; overflow-wrap: anywhere; }
.wk-article .wk-disclaimer { margin-top: var(--space-6); }

/* "Se mer från AniMed på Google": a link to Google's preferred-source page,
   after the disclaimer on the hub and on every article. */
.wk-gsource { display: flex; align-items: flex-start; gap: var(--space-5); margin: var(--space-10) 0 0; padding-top: var(--space-6); border-top: 1px solid var(--border-subtle); }
.wk-gsource-icon { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--animed-teal-100); color: var(--animed-teal-800); }
.wk-gsource-body { flex: 1; min-width: 0; }
.wk-gsource-title { font-family: var(--font-display); font-weight: 600; font-size: 1.0625rem; line-height: 1.3; margin: 0 0 var(--space-1); }
.wk-gsource-text { margin: 0; font-size: 0.9375rem; line-height: 1.5; color: var(--fg-muted); max-width: 52ch; text-wrap: pretty; }
.wk-gsource-btn { margin-top: var(--space-4); }
@container (max-width: 420px) { .wk-gsource { gap: var(--space-4); } .wk-gsource-icon { width: 40px; height: 40px; } }
@container (max-width: 380px) { .wk-gsource-icon { display: none; } }

/* ---------------------------------------------------------- article: side */
.wk-side { position: sticky; top: 120px; }
@container (max-width: 820px) { .wk-side { position: static; } }
.wk-side-title { font-family: var(--font-display); font-weight: 600; font-size: 1.0625rem; margin: 0 0 var(--space-4); }
.wk-side-list { list-style: none; margin: 0 0 var(--space-5); padding: 0; display: grid; gap: var(--space-3); }
@container (min-width: 560px) and (max-width: 820px) { .wk-side-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.wk-side .wk-row { background: #fff; }
.wk-side .wk-row-media { width: 56px; }
.wk-side .wk-row-title { font-size: 0.9375rem; }
/* Narrow column: topic and species only, no reading time. */
.wk-side .wk-read, .wk-side .wk-meta-sep:nth-last-child(2) { display: none; }
.wk-side-all { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9375rem; color: var(--fg-link); }
.wk-index { display: none; }

@media (prefers-reduced-motion: reduce) {
  .wk-card, .wk-row, .wk-chip, .wk-opt > svg, .wk-topic-pill { transition: none; }
  .wk-list > li.wk-in { animation: none; }
  .wk-card:hover { transform: none; }
}
