/* ============================================================================
   Blog — index, article and the landing-page teaser.

   Loaded only by /blogg and /blogg/{slug} (plus the teaser styles, which the
   landing page needs, hence blog.css is linked there too). Everything here
   composes the tokens in theme.css and the scaffolding in home.css — .section,
   .section-head, .section-label, .section-title, .container, .btn-primary,
   .prose — rather than restating them. The design system's rules hold: display
   type is uppercase Barlow Condensed, buttons are 6px and never pill,
   160ms cubic-bezier(.2,.7,.3,1).
   ========================================================================== */

/* ── Index ──────────────────────────────────────────────────── */

.blog-index {
  background: var(--paper-1);
}

/* The index is the only page whose h1 is a section heading rather than the hero
   headline, so it takes the display-lg step rather than the hero's display-xl. */
.blog-index-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: var(--display-tracking);
  text-transform: uppercase;
  color: var(--ink-900);
  padding-block: 0.04em;
}

.blog-empty {
  font: var(--body-lg);
  color: var(--text-muted);
}

/* ── Card grid ──────────────────────────────────────────────── */

.blog-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-5);
}

.blog-card {
  min-width: 0;
}

.blog-card > a {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface-card);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-md);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-card);
  transition:
    transform var(--speed) var(--ease),
    box-shadow var(--speed) var(--ease),
    border-color var(--speed) var(--ease);
}

.blog-card > a:hover {
  transform: translateY(-1px);
  border-color: var(--blue-200);
  box-shadow: var(--shadow-raised);
}

.blog-card > a:active {
  transform: translateY(1px);
}

/* The focus ring goes on the link, not the card, so keyboard focus lands
   exactly where the click target is. */
.blog-card > a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--blue-500);
}

.blog-card-media {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--paper-2);
}

.blog-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 320ms var(--ease);
}

.blog-card > a:hover .blog-card-media img {
  transform: scale(1.03);
}

.blog-card-body {
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  /* Push the meta line to the bottom so a row of cards with titles of
     different lengths still has its dates on one line. */
  flex: 1;
}

.blog-card-title {
  font: var(--display-sm);
  line-height: 1.25;
  letter-spacing: var(--display-tracking);
  text-transform: uppercase;
  color: var(--ink-900);
  padding-block: 0.05em;
}

.blog-card-excerpt {
  font: var(--body-sm);
  color: var(--text-body);
  text-wrap: pretty;
}

.blog-card-meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font: var(--body-sm);
  color: var(--text-muted);
}

/* ── Pagination ─────────────────────────────────────────────── */

.blog-pagination {
  margin-top: var(--sp-7);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  flex-wrap: wrap;
}

.blog-pagination-count {
  font: var(--body-sm);
  color: var(--text-muted);
}

/* ── The embed slot ─────────────────────────────────────────────
   A widget from an external article service (/admin/cms/kunskap), rendered
   verbatim below the archive. The markup inside is the vendor's, usually with
   its own stylesheet, so this styles only the frame around it - a section gap
   and our own optional heading - and never reaches into the widget. */

.blog-embed {
  margin-top: var(--sp-8);
}

.blog-embed-title {
  margin-bottom: var(--sp-6);
}

/* ── Article hero ───────────────────────────────────────────── */

.article-hero {
  position: relative;
  min-height: clamp(280px, 42vw, 460px);
  display: flex;
  align-items: flex-end;
  background: var(--ink-900);
  overflow: hidden;
  /* The nav is fixed and translucent over the landing hero; here the hero is
     the first thing under it, so it reserves the nav's height itself. */
  padding-top: var(--nav-total, 65px);
  padding-bottom: var(--sp-7);
}

.article-hero--plain {
  min-height: 0;
  padding-top: calc(var(--nav-total, 65px) + var(--sp-7));
}

.article-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Bottom-weighted so the copy sitting on it stays legible whatever the photo
   is, while the top of the image — usually the sky or the roof itself — stays
   close to unmodified. */
.article-hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    0deg,
    rgb(16 24 32 / 88%) 0%,
    rgb(16 24 32 / 55%) 45%,
    rgb(16 24 32 / 12%) 100%
  );
}

.article-hero-copy {
  position: relative;
  max-width: 68ch;
}

.article-title {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 5.2vw, 3.2rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: var(--display-tracking);
  text-transform: uppercase;
  color: #fff;
  padding-block: 0.04em;
  margin-top: var(--sp-3);
  text-wrap: balance;
}

.article-meta {
  margin-top: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  font: var(--body-sm);
  color: rgb(255 255 255 / 78%);
}

/* ── Article body ───────────────────────────────────────────── */

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--sp-8);
  align-items: start;
  padding-block: var(--sp-8);
}

/* The body reuses .prose from home.css for headings, links and lists, and adds
   only what an article body has that the privacy page does not. */
.article-body > * + * {
  margin-top: var(--sp-4);
}

.article-body h2,
.article-body h3,
.article-body h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: var(--display-tracking);
  text-transform: uppercase;
  color: var(--ink-900);
  margin-top: var(--sp-7);
  padding-block: 0.05em;
}

.article-body h2 {
  font-size: 1.75rem;
}
.article-body h3 {
  font-size: 1.3rem;
}
.article-body h4 {
  font-size: 1.1rem;
}

.article-body ul,
.article-body ol {
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.article-body li::marker {
  color: var(--blue-400);
}

.article-body blockquote {
  border-left: 3px solid var(--blue-400);
  padding-left: var(--sp-4);
  color: var(--text-muted);
  font-style: italic;
}

.article-body img {
  border-radius: var(--radius-md);
}

/* Wide content must scroll inside its own box; the page body must never
   scroll horizontally. */
.article-body table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  font: var(--body-sm);
  width: 100%;
}

.article-body th,
.article-body td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--line-2);
  text-align: left;
  vertical-align: top;
}

.article-body th {
  font-weight: 600;
  color: var(--ink-900);
  background: var(--paper-1);
  white-space: nowrap;
}

.article-disclosure {
  margin-top: var(--sp-7);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line-1);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font: var(--body-sm) !important;
  color: var(--text-muted) !important;
}

/* ── In-article CTA ─────────────────────────────────────────── */

.article-cta {
  position: sticky;
  top: calc(var(--nav-total, 65px) + var(--sp-5));
  background: var(--paper-2);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  align-items: flex-start;
}

.article-cta h2 {
  font: var(--display-sm);
  line-height: 1.25;
  letter-spacing: var(--display-tracking);
  text-transform: uppercase;
  color: var(--ink-900);
  padding-block: 0.05em;
}

.article-cta p {
  font: var(--body-sm);
  color: var(--text-body);
}

.article-cta-phone {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font: var(--label);
  /* The CTA panel behind this is --paper-2, where blue-600 measures 4.21 and
     this small text needs 4.5. Same reason .section-label moved: blue-600 only
     clears the bar on pure white. Hover deepens one more step so the state is
     still visible after the base darkened. */
  color: var(--blue-700);
}

.article-cta-phone:hover {
  color: var(--blue-800);
}

/* The linked service page, chosen in the article editor. Separated from the
   quote actions above it by a hairline so it reads as "further reading", not
   as a third way to ask for a quote. */
.article-cta-service {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  /* Stretch so the hairline spans the whole box; the parent's own gap
     provides the spacing above it. */
  align-self: stretch;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line-1);
  font: var(--label);
  color: var(--blue-600);
}

.article-cta-service:hover {
  color: var(--blue-700);
}

/* ── Teaser on the landing page ─────────────────────────────── */

.blog-teaser {
  background: var(--paper-0);
}

.blog-teaser-more {
  margin-top: var(--sp-6);
  display: flex;
  justify-content: center;
}

.blog-related {
  padding-block: var(--sp-8);
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 1040px) {
  .article-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-6);
  }

  /* Sticky is meaningless once the CTA is stacked under the article — it would
     pin a block the reader has already scrolled past. */
  .article-cta {
    position: static;
  }
}

@media (max-width: 900px) {
  .blog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .blog-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The hover lift and the image zoom are decoration, not information. */
@media (prefers-reduced-motion: reduce) {
  .blog-card > a,
  .blog-card-media img {
    transition: none;
  }

  .blog-card > a:hover {
    transform: none;
  }

  .blog-card > a:hover .blog-card-media img {
    transform: none;
  }
}

/* ── The archive's category filter ────────────────────────────────────────── */

/* Real links to real addresses. A category has exactly one URL
   (/kunskap/kategori/<slug>) and the chips lead there, so the filtered list is
   bookmarkable and crawlable rather than a state that only exists in one
   browser tab. */
/* Symmetric margins: .blog-grid sets margin:0, so a top-only margin here left
   the first row of cards flush against the chips and the filter read as part of
   the first card rather than as a control above the list. */
.blog-cats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: var(--sp-6) 0;
}

.blog-cat {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px var(--sp-4);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  font: var(--body-sm);
  color: var(--text-body);
  text-decoration: none;
  transition:
    border-color var(--speed) var(--ease),
    background var(--speed) var(--ease);
}

.blog-cat:hover {
  border-color: var(--blue-300);
}

.blog-cat--on {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: #fff;
}

.blog-cat-n {
  font-size: 12px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* The chip on a card, and the linked one over an article title. */
.blog-card-cat {
  display: inline-block;
  font: var(--kicker);
  letter-spacing: var(--kicker-tracking);
  text-transform: uppercase;
  color: var(--blue-600);
}

.article-cat {
  display: inline-block;
  text-decoration: none;
}

.article-cat:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* ── The landing page's article rail ──────────────────────────────────────── */

.section-head--rail {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-5);
}

.rail-nav {
  display: flex;
  gap: var(--sp-2);
  flex: 0 0 auto;
}

.rail-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-1);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--ink-900);
  cursor: pointer;
  transition:
    border-color var(--speed) var(--ease),
    opacity var(--speed) var(--ease);
}

.rail-btn:hover:not(:disabled) {
  border-color: var(--blue-300);
}

.rail-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* The rail itself is the scroll container. Everything below is CSS the arrows
   are NOT required for: it scrolls with a finger, a trackpad, a scrollbar and
   the keyboard before rail.js has loaded. */
.blog-rail {
  margin-top: var(--sp-6);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  /* Keeps a horizontal fling inside the rail instead of chaining into the
     browser's back gesture, which is what makes a rail feel like a trap. */
  overscroll-behavior-x: contain;
  /* Room for the cards' shadow, which an overflow container would otherwise
     clip flat along the top and bottom edges. */
  padding: 4px 4px 12px;
  margin-inline: -4px;
  scrollbar-width: thin;
}

.blog-rail:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-md);
}

.blog-rail-track {
  display: flex;
  gap: var(--sp-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A fixed basis rather than a fraction of the container: the point of a rail is
   that the next card is partly visible, which is what says "this scrolls". */
.blog-rail-track > li {
  flex: 0 0 340px;
  scroll-snap-align: start;
}

@media (max-width: 700px) {
  .section-head--rail {
    display: block;
  }

  .rail-nav {
    display: none;
  }

  .blog-rail-track > li {
    flex-basis: 82%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .blog-rail {
    scroll-behavior: auto;
  }
}
