:root {
  --header-height: 74px;
  --top-message-height: 48px;
  --menu-top-offset: var(--header-height);

  /* Editorial palette — reuses the site's own tokens where possible. */
  --menu-bg: #ffffff;
  --menu-ink: #111111;
  --menu-muted: #8a8a8a;
  --menu-line: rgba(17, 17, 17, 0.1);
  --menu-backdrop-tint: rgba(17, 17, 17, 0.35);
  --menu-accent: var(--color-text-accent, #b9cdcc);
  --menu-font-display: var(--font-header, "IBM Plex Sans"), sans-serif;
  --menu-font-label: var(--font-menu, "IBM Plex Sans"), sans-serif;

  /* --content-standard: 1400px; */

  --section-large: 40px;
  --section-large-tablet: 30px;
  --section-large-phone: 24px;
  --section-standard: 24px;
  --section-standard-tablet: 24px;
  --section-standard-phone: 18px;

  --content-padding-phone: 22px;

  --color-skiffer: #2c4a43;
  --color-varsel: #d6f5a0;
  --color-dis: #0e1f38;
  --color-oxid: #6e2c22;
  --color-flöde: #b7d9e1;
  --color-mineral: #dbd6cd;
}

body {
  /* background-color: #ffffff !important; */
}

/* .cms-controller {
  position: fixed;
  bottom: 0;
  width: 100%;
} */

main .content-standard {
  max-width: calc(var(--content-small) + var(--content-padding) * 2) !important;
}

.avatar {
  background-image: url(/upl/images/1302996.png);
  background-size: cover;
}

@property --menu-top-offset {
  syntax: "<length>";
  inherits: true;
  initial-value: 74px;
}

:root:has(header.cm-header > user-container .top-message) {
  --menu-top-offset: calc(var(--header-height) + var(--top-message-height));
}

@supports (animation-timeline: scroll()) {
  :root:has(header.cm-header > user-container .top-message) {
    animation: cm-menu-offset linear both;
    animation-timeline: scroll(root block);
    animation-range: 0 var(--top-message-height);
  }
}

@keyframes cm-menu-offset {
  from {
    --menu-top-offset: calc(var(--header-height) + var(--top-message-height));
  }
  to {
    --menu-top-offset: var(--header-height);
  }
}

header.cm-header {
  & .cm-top-message {
    /* background-color: var(--menu-accent); */
    font-weight: 600;
  }

  & > .content-standard {
    position: relative;
  }

  & > div.content-standard {
    padding-top: 25px;
    padding-bottom: 25px;
  }

  /* Centre the logo in the bar. It is taken out of the flow so the nav and
     the buttons keep their positions and the logo sits at the exact midpoint
     regardless of how wide the left and right groups are. */
  & > .content-standard .logo {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    z-index: 1;
  }

  & .m-r-4 {
    margin-right: var(--spacing-2);
  }

  & .btn {
    box-shadow: unset !important;
  }

  & .btn-secondary {
    background-color: var(--header-bg) !important;
    border: unset;
    color: unset !important;
  }

  & user-container > button {
    border: 1px solid var(--btn-outline-border) !important;
  }

  & ul.mainmenu {
    & li {
      margin-right: var(--spacing-6) !important;

      & a {
        font-size: 16px;
      }
    }
  }

  /* hide search button */
  button[aria-label="Öppna sök"] {
    display: none;
  }

  @media (max-width: 680px) {
    /* Fixed bar height so --header-height is exact and the hamburger panel
       opens flush under the bar. Content centres inside the bar. */

    & header > div.content-standard {
      padding-bottom: 0 !important;
    }

    & > .content-standard {
      box-sizing: border-box;
      height: var(--header-bar-height);
      align-items: center;
    }

    /* Bigger logo. The SVG is only 77x46 intrinsically, so max-* cannot
       enlarge it; set an explicit height and let the width follow. The bar
       height is derived from this (see --header-bar-height below). */
    & > .content-standard .logo img {
      height: var(--mobile-logo-height);
      width: auto;
      max-height: none;
      max-width: none;
    }
  }
}

@media (max-width: 680px) {
  :root {
    /* Logo height on phones (the SVG renders 46px tall on desktop). */
    --mobile-logo-height: 44px;
    /* Logo/buttons row: tallest item (logo) + 15px bar padding top and bottom. */
    --header-bar-height: calc(var(--mobile-logo-height) + 30px);
    /* So the sticky offset and hamburger menu line up with the bar. */
    --header-height: var(--header-bar-height);
  }
}

/* ---------------------------------------------------------------------------
   Ads styling
--------------------------------------------------------------------------- */
section.cm-ad.m-standard {
  margin: 24px 0;
}

section.m-standard {
  margin: 40px 0;

  @media (max-width: 680px) {
    margin: 24px 0;
  }
}

.widescreen::before,
.panorama::before,
.mobile::before {
  content: "annons";
}

.bgcolor-ad {
  background: unset !important;
  background-color: unset !important;
}

.cm-hero-news-ad {
  margin-bottom: var(--spacing-3);
}

/* ---------------------------------------------------------------------------
   General styling
--------------------------------------------------------------------------- */

.btn {
  font-weight: 400;
}

/* Hover-fade only on plain text links. Links that wrap media or block content
   (ads, article cards, teasers, image links) are left untouched. */
a:not(
  :has(
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    img,
    picture,
    video,
    svg,
    iframe,
    figure,
    div,
    article,
    section,
    p,
    ul,
    ol
  )
) {
  transition: opacity 0.4s ease;
}

a:hover:not(
    :has(
      h1,
      h2,
      h3,
      h4,
      h5,
      h6,
      img,
      picture,
      video,
      svg,
      iframe,
      figure,
      div,
      article,
      section,
      p,
      ul,
      ol
    )
  ) {
  opacity: 0.6;
  text-decoration: none !important;
}

/* ---------------------------------------------------------------------------
   Footer Styles
--------------------------------------------------------------------------- */

footer.cm-footer {
  background: var(--color-dis);

  @media (max-width: 680px) {
    & > div {
      gap: 20px;

      & .text-block {
        text-align: start !important;
      }
    }
  }

  & div.content-standard {
    padding: 24px var(--content-padding);

    @media (max-width: 680px) {
      padding: 24px var(--content-padding-phone);
    }
  }

  & div.content-standard > div:first-child {
    @media (max-width: 680px) {
      & .footer-logo-m {
        display: none;
      }
    }
  }

  & ul.link-list {
    text-align: start;
    font-size: 18px;
  }
}

/* MENY CSS - Behavior changes */

.hamburger-menu-wrapper.ews-modal-wrapper[ews-modal-type="slidein"] {
  overflow: visible;
}
.hamburger-menu-wrapper .ews-modal-backdrop {
  top: var(--menu-top-offset);
  background-color: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transition: background-color 0.4s ease;
}
.hamburger-menu-wrapper.ews-modal-wrapper[ews-modal-type="slidein"].active
  .ews-modal-backdrop {
  background-color: var(--menu-backdrop-tint);
}

.hamburger-menu-wrapper.ews-modal-wrapper[ews-modal-type="slidein"]
  .ews-modal-el {
  top: var(--menu-top-offset);
  right: 0;
  left: 0;
  bottom: auto;

  width: 100%;
  max-width: none;
  height: auto;
  max-height: calc(100vh - var(--menu-top-offset));
  max-height: calc(100dvh - var(--menu-top-offset));

  padding: clamp(28px, 5vw, 64px) clamp(20px, 6vw, 80px) clamp(36px, 5vw, 56px);
  background: var(--menu-bg);
  color: var(--menu-ink);

  /* Subtle drop shadow. It rides on the panel's opacity, which is 0 when the
     menu is closed, so the shadow is only visible while the menu is open. */
  box-shadow: 0 24px 40px -28px rgba(0, 0, 0, 0.25);

  transform: translateY(-14px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.35s ease,
    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0s linear 0.4s;

  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Open state */
.hamburger-menu-wrapper.ews-modal-wrapper[ews-modal-type="slidein"].active
  .ews-modal-el {
  /* transform: translateY(0); */
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 0.4s ease,
    transform 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0s linear 0s;
}

/* Flush-left content (Atlantic-style), using the full width of the sheet.
   No auto-centering — everything hangs off the left edge. */
.hamburger-menu-wrapper #hamburger-menu-content {
  max-width: calc(var(--content-standard) + var(--content-padding) * 2);
  width: 100%;
  height: auto;
  margin: 0 auto;

  flex-direction: row;
  align-items: start;

  & nav {
    order: 2;
  }
}

/* ---------------------------------------------------------------------------
   3. TOP BAR (profile shortcut + close button)
--------------------------------------------------------------------------- */
.hamburger-menu-wrapper .top {
  justify-content: flex-end;
  gap: var(--spacing-3, 12px);
  margin-bottom: clamp(20px, 3vw, 36px);
}

.hamburger-menu-wrapper #hamburger-menu-close {
  transition: color 0.2s ease;
}
.hamburger-menu-wrapper #hamburger-menu-close:hover {
  color: var(--menu-accent);
}

/* ---------------------------------------------------------------------------
   4. "Meny" heading -> editorial eyebrow label
--------------------------------------------------------------------------- */
.hamburger-menu-wrapper .inner-content h3 {
  display: none;
}

/* ---------------------------------------------------------------------------
   5. NAV COLUMNS  ->  each top-level item is a COLUMN, ruled at the top.
   The parent link is the column header; its dropdown children stack as ROWS
   beneath it (Atlantic-style). No numbers.
--------------------------------------------------------------------------- */
.hamburger-menu-wrapper .cm-header-hamburger-menu > ul.menu {
  /* Grid so every column gets the same width and wraps by itself. The
     columns have a fixed width and pack from the left, so they sit close
     together instead of stretching across the whole sheet. */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 200px));
  justify-content: start;
  column-gap: clamp(24px, 3vw, 40px);
  row-gap: clamp(28px, 3vw, 44px);
  align-items: start;
  padding: 0 var(--content-padding);

  @media (max-width: 680px) {
    padding: 0;
  }
}

/* Kill the theme's pill / card / active fills. */
.hamburger-menu-wrapper .inner-content .menu > li,
.hamburger-menu-wrapper .inner-content .menu > li.active,
.hamburger-menu-wrapper .inner-content .menu > li:has(.submenu > li.active) {
  box-shadow: none !important;
  background: transparent !important;
  border-radius: 0;
}

/* Each top-level item = a column, ruled at the top. */
.hamburger-menu-wrapper .cm-header-hamburger-menu > ul.menu > li {
  display: block;
}

/* Column header = the parent link. */
.hamburger-menu-wrapper .cm-header-hamburger-menu > ul.menu > li > a {
  display: block;
  padding: 0 !important;
  font-family: var(--font-header), sans-serif;
  color: var(--color-skiffer);
  text-transform: uppercase;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.15;
  text-decoration: none;
}

.hamburger-menu-wrapper .inner-content button.dropdown-toggle,
.hamburger-menu-wrapper .cm-header-hamburger-menu .dropdown-toggle,
.hamburger-menu-wrapper .dropdown-toggle {
  display: none !important;
}

.hamburger-menu-wrapper .cm-header-hamburger-menu .submenu,
.hamburger-menu-wrapper .cm-header-hamburger-menu .submenu.open {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  margin: clamp(10px, 1.2vw, 10px) 0 0;
  padding: 0;
  width: 100%;
}
.hamburger-menu-wrapper .cm-header-hamburger-menu .submenu > li > a {
  display: block;
  padding: 0 !important;
  font-size: 16px;
  color: var(--color-text-surface-primary);
  text-decoration: none;
}

.hamburger-menu-wrapper nav.m-t-auto {
  margin-top: clamp(28px, 4vw, 48px);
}
.hamburger-menu-wrapper nav.m-t-auto > ul.menu {
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--spacing-3, 12px);
}
.hamburger-menu-wrapper nav.m-t-auto > ul.menu > li {
  flex: 1 1 200px;
  border: 0;
}
.hamburger-menu-wrapper nav.m-t-auto .btn {
  width: 100%;
}
.hamburger-menu-wrapper nav.m-t-auto user-container > .btn[login-btn] {
  background: none !important;
  border: 1px solid var(--header-bg) !important;
  color: var(--header-bg) !important;
  box-shadow: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .hamburger-menu-wrapper .ews-modal-el {
    transition-duration: 0.001s !important;
    transform: none !important;
  }
}

header.cm-header {
  position: sticky;
  top: 0;
  z-index: 101;
}

/* Hide-on-scroll, driven by js/header-scroll.js. While the user scrolls the
   script writes an inline translateY so the bar follows the scroll 1:1. When
   scrolling stops mid-slide it adds .is-settling and the bar eases to fully
   shown or fully hidden. */
header.cm-header.is-settling {
  transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  header.cm-header.is-settling {
    transition: none;
  }
}

:root:has(header.cm-header > user-container .top-message) header.cm-header {
  top: calc(-1 * var(--top-message-height));
}

/* 
_____________________________________________________________________
    Artikelpage - styles related to articles
_____________________________________________________________________
*/

body.type-articles {
  & .article-layout {
    max-width: 1020px;
    grid-template-columns: 1fr 300px;
    margin: 0 auto;

    @media (max-width: 870px) {
      grid-template-columns: 1fr;
      justify-items: center;
    }

    & > * {
      min-width: 0;
    }

    & aside.article-navigation {
      display: none;
      & nav {
        position: unset;
      }
    }

    & article.article-content {
      overflow-wrap: anywhere;

      & .text-block {
        margin: 0 auto;
        max-width: 665px;
      }

      /* Author block */
      & .m-v-7.m-tablet-v-6.display-flex.align-items-center {
        & .weight-bold {
          font-weight: 500 !important;
        }
      }

      & .ew-media-description,
      figcaption {
        font-size: 14px;
        opacity: 0.6;
      }

      & div {
        &
          span.size-sm.color-accent.font-header.text-uppercase.display-block.m-b-4.m-tablet-b-3.m-lgphone-b-2 {
          font-family: var(--font-main);
          font-size: 14px;
          font-style: normal;
          font-weight: 500;
          line-height: 120%;
          text-transform: uppercase;
        }

        & .color-accent {
          color: inherit;
        }

        & .avatar {
          /* margin-right: 12px; */
        }

        & h1 {
          font-size: 40px;
          font-style: normal;
          font-weight: 700;
          line-height: 44px;

          @media (max-width: 680px) {
            font-size: 24px;
            font-style: normal;
            font-weight: 700;
            line-height: 120%; /* 28.8px */
          }
        }

        & p.font-ingress {
          font-size: 22px;
          font-style: normal;
          font-weight: 400;
          line-height: 140%;

          @media (max-width: 680px) {
            font-size: 18px;
          }
        }

        & div.cm-article-content,
        div.article-teaser-content {
          margin: 0 auto;
          max-width: 665px;

          & h2,
          h3,
          h4,
          h5,
          h6 {
            font-size: 24px;
            font-style: normal;
            font-weight: 700;
            line-height: 120%;
          }

          & p,
          li {
            font-size: 18px;
            font-style: normal;
            font-weight: 400;
            line-height: 160%;
            letter-spacing: -0.054px;

            @media (max-width: 680px) {
              font-size: 1rem;
              line-height: 1.7;
            }
          }
        }
      }

      & ul {
        & li {
        }
      }

      & p.card {
      }

      & blockquote {
        & p {
          /* font-weight: 500 !important;
          font-size: 34px !important;
          line-height: 1.12 !important;
          letter-spacing: -0.03em !important;
          text-wrap: pretty;

          @media (max-width: 680px) {
            font-size: 24px !important;
          } */
        }

        & cite {
          /* position: relative;
          padding-left: 18px;
          font-weight: 500 !important;
          font-size: 17px !important;

          &::before {
            content: "";
            position: absolute;
            left: 0;
            top: 0.5em;
            width: 10px;
            height: 10px;
            background-image: url('data:image/svg+xml,<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 0H8.99996C14.1702 0 17.9999 2.29786 17.9999 8.99996V17.9999H7.7872C3.44679 17.9999 0 15.0638 0 9.57443V0Z" fill="%230D3047"/></svg>');
            background-repeat: no-repeat;
            background-size: contain; */
        }
      }

      &::before {
        /* content: unset; */
      }
    }

    & aside.article-aside {
      & async-fetch-template {
        & user-container {
          & .cm-articles-aside {
            & h2.size-md.m-v-z {
              font-family: var(--font-header);
              font-size: 18px;
              font-weight: 600;
            }

            & h3.size-xs.font-text.weight-normal.m-v-z {
              font-family: var(--font-main);
              font-style: normal;
              font-weight: 700;
              line-height: 120%;
              letter-spacing: -0.4px;
            }

            & .articles-aside-list {
              padding: 0;
            }

            & .articles-aside-item {
              align-items: start;

              & .media-block {
                height: 45px;
              }
            }
          }

          & .cm-block-aside {
            & .card {
              & .btn {
                border: none;
              }
            }

            & .bgcolor-surface-primary {
              background: var(--color-skiffer);
              color: var(--color-varsel);

              & .btn {
                background: var(--color-varsel);
                color: var(--color-skiffer);
              }
            }
            & .bgcolor-surface-secondary {
              background: var(--color-varsel);
              color: var(--color-skiffer);

              & .btn {
                background: var(--color-skiffer);
                color: var(--color-varsel);
              }
            }
            & .bgcolor-accent {
              background: var(--color-mineral);
              color: var(--color-dis);

              & .btn {
                background: var(--color-dis);
                color: var(--color-flöde);
              }
            }
          }
        }

        /* TOP 5 */
      }
    }

    & .tag-list .tag {
      background: #000000;
      color: #ffffff;
      border-radius: 4px;
      padding: inherit 8px;
    }

    & div[role="region"] {
      & .text-block {
        display: none;
      }

      & .btn-secondary {
        border: none;
        background-color: transparent;
        color: #000000;
      }

      & .box-shadow-primary {
        box-shadow: none;
      }
    }
  }

  a.btn-icon {
    /* background: #ffffff !important;
      border: unset !important;

      &:first-child {
        display: none;
      } */
  }
}

/* Newsletter signup on article pages: same look as in ettan (see
   div.news-hero.cm-news-hero .grid-layout .newsletter-blurb), plus spacing
   below the block. */
body.type-articles .newsletter-blurb {
  background: var(--color-skiffer);
  margin-bottom: var(--section-standard);

  & .content h2,
  & .ew-html {
    color: var(--color-varsel) !important;
  }

  &::after {
    background: linear-gradient(
      180deg,
      rgba(0, 0, 0, 0) 21.86%,
      rgba(0, 0, 0, 0.15) 99.95%
    ) !important;
  }
}

/* Native-specifika styles för artikelinnehållet läggs här */
body.type-articles
  .article-layout
  article.article-content:has(.bgcolor-ad-card) {
  /* Annonsmarkeringen */
  background: var(--color-neutral-100);
  padding-bottom: 24px;

  & .bgcolor-ad-card {
    margin-bottom: 24px;
    justify-content: center;

    & .label {
      display: none;
    }

    & p {
      font-weight: 500;

      &::before {
        content: "Sponsrat ";
      }
    }
  }
}

.bgcolor-ad-card {
  background: var(--color-neutral-100) !important;
}
/* 
_____________________________________________________________________
    Loginpage - styles related to login and register pages
_____________________________________________________________________
*/

body.view-signin {
  & .cm-sign-in {
    display: flex;
    background: var(--color-mineral);
  }

  & .cm-signin-form {
    border-radius: 12px;

    /* Primary action (log in / submit) in the dark green brand colour. */
    & button[type="submit"],
    & input[type="submit"],
    & .btn-primary {
      background: var(--color-skiffer) !important;
      border-color: var(--color-skiffer) !important;
      color: #ffffff !important;
    }
  }
}

/* 
_____________________________________________________________________
    Kalenderpage
_____________________________________________________________________
*/
body.type-calendar {
  & div.hero-archive {
    & h1 {
    }

    & .hero-archive__illustration {
      display: none;
    }

    & custom-select button {
    }
  }

  & .events-list-item {
  }
}
/* 
_____________________________________________________________________
    Branschregister
_____________________________________________________________________
*/
body.type-businessdirectory {
  & div.businesses-list {
    @media (max-width: 870px) {
    }

    & .color-white {
    }

    & .businesses-list-item {
      & div.bg-media {
      }

      & .businesses-list-item__content {
        & div {
        }

        & div.overflow-hidden.display-flex.m-b-2 {
          width: 120px;
        }

        & img {
          width: 100%;
          object-fit: contain;
        }

        & h3 {
        }
      }
    }
  }

  & div.content-standard > div.card {
    & > div {
      & div {
      }

      & h3 {
      }
    }
  }

  & div.text-block {
    & .card {
      /* Kontaktuppgifter: texter i full bredd, alla länkar som knappar sida vid sida */
      & > div {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--spacing-2);

        & > span {
          flex: 0 0 100%;
        }

        & > span.weight-bold:first-child {
        }
      }

      & a {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        margin-top: var(--spacing-2);
        padding: 10px 18px;
        border: 1px solid var(--color-white);
        border-radius: 4px;
        background: transparent;
        color: var(--color-white) !important;
        font-weight: 500;
        line-height: 1;
        text-decoration: none !important;
        opacity: 1 !important;
        transition:
          background-color 0.15s ease,
          color 0.15s ease;

        /* Hover/fokus: invertera färgerna. !important så temats länkfärger inte slår igenom */
        &:hover,
        &:focus-visible {
        }

        &:focus-visible {
        }

        /* Mobil: knapparna delar raden */
        @media (max-width: 680px) {
        }
      }
    }
  }
}

/* 
_____________________________________________________________________
  
  BLOCKS - Styles related to Co-member site blocks
_____________________________________________________________________
*/

/* ETTAN Styles */

/* Main articles */
div.news-hero.cm-news-hero {
  & .top-bar {
    & div.label.bgcolor-white {
      display: none;
    }

    & div.label.bgcolor-accent {
      background: var(--color-skiffer);
    }

    & .label {
      padding: 5px 12px;
    }
  }

  & .article-list-large.cm-newslist-large {
    & .article-horizontal {
      & .image {
        width: 25%;
      }
    }

    & .card:not(:last-child) {
      padding-bottom: var(--spacing-4);
      border-bottom: 0.5px solid var(--color-mineral);
    }

    & .card {
      padding: 0;

      & h2.size-lg {
        margin-top: 4px;
        margin-bottom: 12px;
      }

      /* ellepsis över 3 rader */
      & p.m-t-z.m-b-6.size-sm {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      & p.m-z {
        color: var(--color-oxid);
        font-family: var(--font-main);
        font-size: 14px;
        font-weight: 700;
        line-height: 120%;
        text-transform: uppercase;
        letter-spacing: 0.3px;

        & .color-accent {
          color: inherit !important;
        }

        & span.size-xs,
        span {
          margin-left: 2px;
          color: var(--color-neutral-200);
        }
      }

      & span.m-z.weight-medium.color-accent.size-xs,
      .text span.m-z.weight-medium.color-accent.size-xs {
        color: var(--color-black) !important;
        text-transform: capitalize !important;
        font-style: normal;
        font-weight: 400;
        font-size: 12px;
      }
    }

    & .cm-native-card {
      & p,
      h2 {
      }
    }
  }

  /* TAGG / KATEGORI (card, topplista, mini) */
  & p .weight-bold,
  & p .color-accent {
    color: var(--color-oxid);
    font-family: var(--font-main);
    font-weight: 700;
    line-height: 120%;
    text-transform: uppercase;
  }

  /* headings */
  & h2.size-lg,
  & h2.size-md {
    @media (max-width: 870px) {
    }
  }

  /* Columns */
  & .grid-layout {
    border-top: 0.5px solid var(--color-mineral);
    padding-top: 10px;

    /* Kategorisidan: ettan modifierad till 2 kolumner */
    grid-template-columns: 1fr 300px;

    @media (max-width: 870px) {
      grid-template-columns: 1fr;
    }

    & > .col:first-child {
      grid-area: 1 / span 2;

      @media (max-width: 870px) {
        grid-area: 1;
      }

      & h2 {
        margin: 0 !important;
      }
    }

    /* Newsletter signup (1st col): softer bottom-weighted scrim */
    & .newsletter-blurb {
      background: var(--color-skiffer);

      & .content h2,
      .ew-html {
        color: var(--color-varsel) !important;
      }
    }

    & .newsletter-blurb::after {
      background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0) 21.86%,
        rgba(0, 0, 0, 0.15) 99.95%
      ) !important;
    }

    /* Tagg/kategori-raden under rubriken (topplista + mini) */
    & .article .text p {
      order: 2;
    }

    & .col {
      /* TOP 5 */
      .cm-news-toplist {
        @media (max-width: 870px) {
          padding: var(--spacing-4);
        }

        & .toggles {
          & button {
            border: unset;
            border-right: 1px solid var(--color-neutral-200);
          }

          & button:nth-child(1) {
            border-radius: 8px 0 0 8px;
          }

          & button:nth-child(3) {
            border-radius: 0 8px 8px 0;
            border: unset;
          }

          & button.active {
            color: #f2f2f2;
            background: var(--color-neutral-300);
          }
        }

        & h2.size-sm.m-z {
          /* font-family: var(--font-main);
          font-weight: 600;
          font-size: 12px;
          letter-spacing: -0.3px;
          text-transform: uppercase; */
        }

        & .article-list .article {
          /* border: none;
          padding-bottom: 0;
          margin-bottom: var(--spacing-3); */

          & .number > span {
            /* color: var(--color-neutral-200);
            font-family: var(--font-header);
            font-size: 30px;
            font-style: normal;
            font-weight: 600;
            line-height: 33px;
            letter-spacing: -1px; */
          }

          & .text {
            /* display: flex;
            flex-direction: column;
            gap: 2px;
            padding-top: 2px;
            padding-bottom: 4px; */

            & h3 {
              order: 1;
            }
          }
        }
      }

      /* CM-newslist mini */
      .cm-newslist-mini {
        padding: 0;

        & ul {
          padding: 0 var(--spacing-4);

          & .article {
            padding: 0;
            margin-bottom: var(--spacing-4);
            background: unset;

            & .img {
              width: 35%;
            }
          }
        }

        /* Kategorisidan */
        & .article-list {
          padding: 0 !important;
          margin: 0 !important;
        }

        & .article {
          padding: var(--spacing-3);
          background-color: #f8f8f8;

          & .img {
            width: 45%;

            @media (max-width: 980px) {
              width: 35%;
            }
          }
        }
      }

      /* article headings */
      & h3.size-xs.m-z {
        font-family: var(--font-main);
        font-size: 16px;
        font-style: normal;
        font-weight: 400;
        line-height: 120%;
      }

      /* Blockheadings */
      h2.size-sm.m-t-z {
      }
    }
  }
}

/* Article Grid styles */

section.bgcolor-surface-secondary {
  & articles-masonry.cm-article-list-masonry,
  div.cm-article-list-masonry {
    & .articles-masonry-item {
      border-color: color-mix(
        in srgb,
        var(--color-text-surface-secondary) 40%,
        transparent
      );
      .card {
        background: none;
        color: var(--color-text-surface-secondary) !important;
      }
    }
  }
}

section.bgcolor-accent {
  background-color: var(--color-mineral);
  & articles-masonry.cm-article-list-masonry,
  div.cm-article-list-masonry {
    & .articles-masonry-item {
      border-color: var(--color-neutral-200);

      .card {
        background: none;
        /* color: var(--color-text-surface-secondary) !important; */
      }
    }
  }
}

articles-masonry.cm-article-list-masonry,
div.cm-article-list-masonry {
  gap: var(--spacing-4) 0 !important;

  /* @media (max-width: 680px) {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--spacing-4) !important;
  } */

  & .articles-masonry-item {
    border-right: 1px solid var(--color-mineral);

    & .card {
      padding: var(--spacing-3);
      @media (max-width: 680px) {
        padding: 0 !important;
      }
    }
  }

  /* No border on the last column of each row: 4 cols desktop, 3 cols 871-1200px, 2 cols 681-870px, 1 col mobile */
  @media (min-width: 1201px) {
    & > div:nth-child(4n) .articles-masonry-item,
    & > .articles-masonry-item:nth-child(4n) {
      border-right: 0;
    }
  }

  @media (min-width: 871px) and (max-width: 1200px) {
    & > div:nth-child(3n) .articles-masonry-item,
    & > .articles-masonry-item:nth-child(3n) {
      border-right: 0;
    }
  }

  @media (min-width: 681px) and (max-width: 870px) {
    & > div:nth-child(2n) .articles-masonry-item,
    & > .articles-masonry-item:nth-child(2n) {
      border-right: 0;
    }
  }

  @media (max-width: 680px) {
    & .articles-masonry-item {
      border-right: 0;
    }
  }

  &
    > div:has(.articles-masonry-item):not(:has(~ div .articles-masonry-item))
    .articles-masonry-item:last-child {
    border-right: 0;
  }
}

/* ---------------------------------------------------------------------------
   Mobile article feed rhythm (<= 680px)

   Articles arrive 8 per block, so the pattern repeats every 8 items:

     1      large   image on top, big heading, teaser
     2, 3   row     image left, text right
     4, 5   pair    two small cards side by side
     6      large
     7, 8   row

   "Row" is the default, so a list of any length still looks right; a pair
   card that would end up alone on its line (4th and last) stays a row.
   The start page category columns (.cm-column-list) keep their own layout.
--------------------------------------------------------------------------- */
:where(.cm-article-list-masonry) > .articles-masonry-item {
  border-top-color: var(--color-mineral);
}

@media (max-width: 680px) {
  .articles-masonry-list.cm-article-list-masonry:not(.cm-column-list *) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-4) var(--spacing-3) !important;

    & > .articles-masonry-item {
      grid-column: 1 / -1;
      min-width: 0;
      padding-top: var(--spacing-4);
      border-top-style: solid;
      border-top-width: 0.5px;

      & .m-t-auto > div {
        margin-top: var(--spacing-2);
      }
    }

    & > .articles-masonry-item:first-child {
      padding-top: 0;
      border-top-width: 0;
    }

    /* ---- Large: 1st and 6th of every 8 ---- */
    & > .articles-masonry-item:is(:nth-child(8n + 1), :nth-child(8n + 6)) {
      & .card > div > a:first-child,
      & .card figure {
        margin-bottom: var(--spacing-3);
      }

      & h3 {
        font-size: 24px;
        line-height: 115%;
      }
    }

    /* ---- Pair: 4th + 5th of every 8, side by side ---- */
    &
      > .articles-masonry-item:is(
        :nth-child(8n + 4):not(:last-child),
        :nth-child(8n + 5)
      ) {
      grid-column: span 1;

      & .card > div > a:first-child,
      & .card figure {
        margin-bottom: var(--spacing-2);
      }

      & h3 {
        font-size: 15px;
        line-height: 125%;
      }

      & .text-block > p.size-xs {
        display: none;
      }
    }

    /* ---- Row: everything else, image left and text right ---- */
    &
      > .articles-masonry-item:not(
        :nth-child(8n + 1),
        :nth-child(8n + 6),
        :nth-child(8n + 4):not(:last-child),
        :nth-child(8n + 5)
      ) {
      /* Real cards wrap their content in .direction-column; the loading
         skeleton puts it straight in .card. Cards without an image keep the
         normal stacked layout. */
      & .card > .direction-column:has(> a:first-child figure),
      & .card:not(.article-card) {
        display: grid !important;
        grid-template-columns: 36% minmax(0, 1fr);
        grid-template-rows: auto 1fr;
        column-gap: var(--spacing-3);
        align-items: start;

        & > :first-child {
          grid-row: 1 / span 2;
          margin-bottom: 0;
        }

        & figure {
          margin-bottom: 0;
        }

        /* 4:3 thumbnail instead of the wide default ratio */
        & figure.video::before {
          padding-top: 75%;
        }

        & > .text-block,
        & > .m-t-auto {
          grid-column: 2;
        }
      }

      & h3 {
        font-size: 16px;
        line-height: 125%;
      }

      & .text-block > p.size-xs {
        display: none;
      }
    }
  }
}

articles-swiper.cm-article-list-swiper {
  & .articles-swiper-item {
    border-right: 1px solid var(--color-text-surface-secondary);
  }

  & .swiper-wrapper > .articles-swiper-item:last-child {
    border-right: 0;
  }
}

div.cm-article-card {
  & .text-block {
    & > a {
      font-family: var(--font-main);
      font-size: 12px;
      font-weight: 700;
      line-height: 120%;
      text-transform: uppercase;
      color: var(--color-oxid) !important;
    }

    & .color-accent {
      color: var(--color-oxid) !important;
    }

    & h3 {
      font-size: 22px;
      font-weight: 600;
      letter-spacing: -0.4px;
      line-height: 1.2;

      @media (max-width: 680px) {
        font-size: 18px;
      }
    }
  }
}

/* Section Heading styles */
div.content-standard
  > div.text-block.display-flex.justify-between.align-items-end.direction-tablet-column.align-tablet-items-start.m-b-7.m-xlphone-b-5 {
  & h2.size-lg.m-z {
  }
}

/* TEXT & Media Styles */

section.cm-text-media {
  & div.content-standard {
    max-width: calc(
      var(--content-standard) + var(--content-padding) * 2
    ) !important;
  }

  & .card {
    background: var(--color-skiffer);
    color: var(--color-white);
    padding: 0;

    & > div {
      padding: 0;
      & > div:first-child {
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: var(--spacing-10);
      }
    }

    & figure {
      aspect-ratio: 1.2 / 1;
    }

    & .btn {
      margin-top: var(--spacing-6);
      background: var(--color-varsel);
      color: var(--color-skiffer);
    }

    & h2 {
      font-size: 40px;
      font-style: normal;
      font-weight: 700;
      line-height: 44px; /* 110% */

      color: var(--color-varsel);
    }

    @media (max-width: 680px) {
      & > div {
        padding: 0;
        & > div:first-child {
          padding: var(--spacing-6);
          padding-top: 0;
        }
      }

      & h2 {
        font-size: 24px;
        line-height: 140%;
      }
    }
  }
}

section.cm-text-media.text-media-0 {
  background: var(--color-mineral);
  margin: 0;
  padding-bottom: var(--section-standard);

  & .card {
    color: var(--color-mineral) !important;
    background: var(--color-dis);

    & h2 {
      color: var(--color-flöde);
    }

    & .btn {
      margin-top: var(--spacing-6);
      background: var(--color-flöde);
      color: var(--color-dis);
      border: none;
    }
  }
}

/* Kategorier block */

section.cm-article-categories {
  background: unset;

  & div.content-standard {
    max-width: calc(
      var(--content-standard) + var(--content-padding) * 2
    ) !important;
  }

  div.text-block.m-b-7.m-xlphone-b-5 {
    margin-bottom: 0;
    color: var(--color-skiffer);
  }

  & .card {
    background: var(--color-skiffer);
    color: var(--color-varsel);

    & .icon {
      background: none;

      & img {
        width: 100%;
        object-fit: contain;
      }
    }
  }
}

/* Custom Columns block styles */
div.cm-column-list-wrapper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding-top: var(--spacing-4);
  border-top: 0.5px solid var(--color-mineral);

  @media (max-width: 680px) {
    grid-template-columns: 1fr;
    gap: var(--spacing-4);
  }

  & div.cm-column-list:last-child {
    border-right: 0;
  }

  & div.cm-column-list {
    padding: 0 12px;
    border-right: 0.5px solid var(--color-mineral);

    & > div.text-block {
      margin-bottom: var(--spacing-5);

      & h2 {
        color: var(--color-skiffer);
        font-size: 22px;
        font-style: normal;
        font-weight: 700;
        line-height: 120%;
      }
    }

    & .cm-article-list-masonry {
      grid-template-columns: 1fr;

      & .articles-masonry-item {
        border: none;

        & .card {
          border-bottom: 0.5px solid var(--color-mineral);
          padding: 0;
          /* !important: beats the general masonry rule's mobile `padding: 0 !important` */
          padding-bottom: var(--spacing-4) !important;

          /* Teaser text and date */
          & .text-block > p,
          & .m-t-auto span.color-neutral-300:not(.size-sm) {
            opacity: 0.7;
          }

          /* Space between author and date */
          & .m-t-auto span.color-neutral-300:not(.size-sm) {
            margin-top: 4px;
          }
        }

        & .bgcolor-ad-card {
          padding: 12px;
        }
      }

      & .articles-masonry-item:not(:first-child) {
        & .card {
          & a.display-block.m-b-5.m-tablet-b-4 {
            display: none;
          }
        }
      }

      /* Show at most 4 articles per column */
      & .articles-masonry-item:nth-child(n + 4) {
        display: none;
      }
    }
  }
}

/* 
_____________________________________________________________________
    LEGACY - blocks that only exist in article bodies imported from
    pvmagasinet.se (WordPress). Anything Co-member also produces
    (figure, blockquote, hr, table, headings) is styled by the normal
    article rules above and is NOT repeated here.

      div.factbox                  505 in 392 articles
      signature portrait           101 articles (chairman's column)
      several images in one <p>    366 images in 57 paragraphs
_____________________________________________________________________
*/

body.type-articles
  .article-layout
  article.article-content
  .text-block.ew-html.cm-article-content {
  /* ---- Faktaruta ------------------------------------------------------ */
  & .factbox {
    clear: both;
    margin: 32px 0;
    padding: 20px 24px;
    background: color-mix(in srgb, var(--color-mineral) 45%, #ffffff);
    border-top: 3px solid var(--color-skiffer);

    @media (max-width: 680px) {
      margin: 24px 0;
      padding: 16px;
    }

    & p,
    & li {
      font-size: 16px;
      line-height: 150%;
      letter-spacing: 0;
      margin: 0 0 12px;

      @media (max-width: 680px) {
        font-size: 15px;
      }
    }

    & > :last-child {
      margin-bottom: 0;
    }

    /* The first bold run is the title of the box. */
    & > p:first-child > strong:first-child,
    & > p:first-child > a:first-child > strong,
    & > strong:first-child {
      font-family: var(--font-header);
      color: var(--color-skiffer);
    }
  }

  /* ---- Signature portrait (chairman's column, 101 articles) ----------
     Was a small thumbnail in WordPress; the importer drops width/height so
     the 683px file would fill the column. Matched on the media id, because
     the file-name part of the URL varies (jorgen-rasmusson-jpg.jpg in the
     first import, jorgen-rasmusson.jpg in later articles). */
  & img[src*="/upl/images/1297431/"] {
    display: block;
    width: 250px;
    height: auto;
    margin: 0 0 12px;
  }

  /* ---- Picture series: several images in one paragraph ---------------- */
  & p:has(> img ~ img),
  & p > strong:has(> img ~ img),
  & p > em:has(> img ~ img) {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;

    & img {
      width: 100%;
      height: 100%;
      aspect-ratio: 3 / 2;
      object-fit: cover;
    }

    & br {
      display: none;
    }
  }

  @media (min-width: 681px) {
    & p:has(> img:nth-of-type(5)),
    & p > strong:has(> img:nth-of-type(5)),
    & p > em:has(> img:nth-of-type(5)) {
      grid-template-columns: repeat(3, 1fr);
    }
  }
}
