/*
 * Startsida, mobil (under 1025px).
 *
 * Desktop B ligger i home-page.css. Här justeras bara telefon och surfplatta:
 * ordning på blocken, en toppnyhet i stället för karusell, svamptemat som
 * kompakt kort, premiumraden efter toppnyheten, kommunkort tre i bredd med
 * siluetten som kortbild och "Senaste nyheterna" som lista.
 *
 * Hubben renderar både mobil- och desktopträdet i anonym HTML (cache utan
 * User-Agent). Därför styrs allt här med viewport, inte wp_is_mobile().
 */

@media (max-width: 1024px) {
  .home-page--hub .home-hub {
    gap: 0;
  }

  .home-page--hub .home-hub__main {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
  }

  /* Ordning enligt mobilskissen. Desktop använder grid-areas och rörs inte. */
  .home-hub__block--kommun-tabs { order: 0; }
  .home-hub__block--hero { order: 1; }
  .home-hub__block--theme { order: 2; }
  .home-hub__block--ad-top-mobile { order: 3; }
  .home-hub__block--municipality { order: 4; }
  .home-hub__block--headlines-mobile { order: 5; }
  .home-hub__block--ad-mid { order: 6; }
  .home-hub__block--most-read-mobile { order: 7; }
  .home-hub__block--media { order: 8; }
  .home-hub__block--sport-mobile { order: 9; }
  .home-hub__block--events-mobile { order: 10; }
  .home-hub__block--weather-traffic-mobile { order: 11; }

  /* Dubbletter och karuseller som inte hör hemma på telefon. */
  .home-hub__block--local-news,
  .home-hub__block--municipality .home-topic-row,
  .home-hero-split__dots,
  .home-hub__block--hero .val-countdown,
  .home-municipality-hub__head,
  .home-municipality-hub__cta,
  .home-svamp-spotlight__lead,
  .home-svamp-spotlight__chips,
  .home-svamp-spotlight__news,
  .home-svamp-spotlight__cta--ghost,
  .home-play-listen--compact .home-play-listen__lead {
    display: none !important;
  }

  /* Kommunflikar */
  .home-kommun-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    margin: 0.1rem 0 0;
  }

  .home-kommun-tabs__tab {
    --kommun-tab-accent: var(--kommun-tab-light, var(--region-primary));
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.35rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid color-mix(in srgb, var(--kommun-tab-accent) 32%, var(--region-border) 68%);
    border-radius: 999px;
    background: color-mix(in srgb, var(--hub-panel, var(--region-bg)) 94%, transparent);
    color: var(--hub-text, var(--region-text));
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
  }

  [data-theme="dark"] .home-kommun-tabs__tab {
    --kommun-tab-accent: var(--kommun-tab-dark, var(--region-primary));
  }

  .home-kommun-tabs__tab.is-active {
    border-color: var(--kommun-tab-accent);
    background: var(--kommun-tab-accent);
    color: #fff;
    box-shadow: 0 6px 16px -10px var(--kommun-tab-accent);
  }

  .home-kommun-tabs__tab:focus-visible {
    outline: 2px solid var(--kommun-tab-accent);
    outline-offset: 2px;
  }

  /* Toppnyhet: bara första kortet, ingen karusell. */
  .home-hub__block--hero {
    gap: 0;
  }

  .home-hero-split__slide:not(.is-active) {
    display: none;
  }

  /* Texten ligger i flödet längst ned så kortet växer med långa rubriker i stället för att klippa etiketten. */
  .home-hero-split__slide .news-teaser--hero-hub .news-teaser__inner--featured {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: clamp(19rem, 82vw, 26rem);
  }

  .home-hero-split__slide .news-teaser--hero-hub .news-teaser__body--featured {
    position: relative;
    inset: auto;
    padding-top: clamp(4.5rem, 20vw, 7rem);
  }

  .home-hero-split__slide .news-teaser--hero-hub .news-teaser__title--featured {
    font-size: clamp(1.45rem, 6.4vw, 1.9rem);
  }

  /* Svamptemat som kompakt informationskort. */
  .home-hub__block--theme .home-svamp-spotlight {
    padding: 0.75rem 0.9rem 0.8rem;
    border-radius: 0.75rem;
    background-image:
      linear-gradient(115deg, rgba(10, 24, 16, 0.96) 0%, rgba(12, 28, 20, 0.9) 100%);
  }

  .home-hub__block--theme .home-svamp-spotlight__header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem 0.9rem;
    margin: 0;
  }

  .home-hub__block--theme .home-svamp-spotlight__kicker {
    margin: 0 0 0.15rem;
    font-size: 0.66rem;
    letter-spacing: 0.09em;
  }

  .home-hub__block--theme .home-svamp-spotlight__title {
    max-width: none;
    font-size: 1.02rem;
    line-height: 1.15;
    letter-spacing: -0.015em;
  }

  .home-hub__block--theme .home-svamp-spotlight__status {
    grid-column: 1 / -1;
    max-width: none;
    margin: 0.25rem 0 0;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    line-height: 1.4;
  }

  .home-hub__block--theme .home-svamp-spotlight__actions {
    grid-column: 1 / -1;
  }

  .home-hub__block--theme .home-svamp-spotlight__cta {
    min-height: 2.35rem;
    padding: 0.4rem 0.9rem;
    border-radius: 0.45rem;
    font-size: 0.86rem;
  }

  /* Premiumraden inuti hubben. Den gamla toppregeln dolde platsen från 768px. */
  .home-hub__block--ad-top-mobile .home-premium-banners-slot--mobile-top {
    display: block !important;
    margin: 0;
  }

  .home-hub__block--ad-top-mobile .home-premium-banners-slot--mobile-top:empty,
  .home-hub__block--ad-top-mobile .home-premium-banners-slot--mobile-top[hidden] {
    display: none !important;
  }

  .home-hub__block--ad-top-mobile:not(:has([data-banner-id])) {
    display: none;
  }

  /* Kommunkort: rubrikrad + tre kort i bredd med siluetten som bild. */
  .home-hub__block--municipality {
    gap: 0;
  }

  .home-municipality-hub__head-mobile {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 0.6rem;
  }

  .home-municipality-hub__title-mobile {
    color: var(--hub-text, var(--region-text));
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.01em;
  }

  .home-municipality-hub__more-mobile {
    color: var(--region-primary);
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
  }

  .home-municipality-hub__grid {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-flow: row;
    grid-auto-columns: unset;
    gap: 0.65rem;
    overflow: visible;
    scroll-snap-type: none;
  }

  .home-municipality-hub__card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-width: 1px;
    border-color: color-mix(in srgb, var(--hub-accent) 34%, var(--region-border) 66%);
    border-radius: 0.8rem;
    background: var(--hub-bg, var(--region-bg));
    box-shadow: 0 10px 24px -22px color-mix(in srgb, var(--hub-accent) 45%, transparent);
  }

  .home-municipality-hub__card:hover {
    transform: none;
  }

  /* Siluett till vänster, text till höger. Korten ligger under varandra. */
  .home-municipality-hub__stage {
    display: grid;
    grid-template-columns: 7.5rem minmax(0, 1fr);
    align-items: stretch;
    min-height: 6.25rem;
    padding: 0;
    gap: 0;
  }

  /* Siluettbild överst i kortet. Tonad bakgrund i kommunens färg. */
  .home-municipality-hub__art {
    position: relative;
    order: -1;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 6.25rem;
    aspect-ratio: auto;
    overflow: hidden;
    background:
      radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--hub-accent) 30%, transparent), transparent 70%),
      linear-gradient(180deg, color-mix(in srgb, var(--hub-accent) 18%, #fff 82%) 0%, color-mix(in srgb, var(--hub-accent) 8%, #fff 92%) 100%);
    isolation: isolate;
  }

  [data-theme="dark"] .home-municipality-hub__art {
    background:
      radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--hub-accent) 34%, transparent), transparent 70%),
      linear-gradient(180deg, #151a20 0%, #0d1116 100%);
  }

  .home-municipality-hub__silhouette {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background-image: var(--hub-silhouette-light, none);
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    mix-blend-mode: multiply;
    opacity: 0.88;
  }

  [data-theme="dark"] .home-municipality-hub__silhouette {
    background-image: var(--hub-silhouette-dark, var(--hub-silhouette-light, none));
    mix-blend-mode: screen;
    opacity: 0.8;
  }

  .home-municipality-hub__silhouette-video {
    display: none !important;
  }

  .home-municipality-hub__body {
    position: static;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.7rem 2rem 0.7rem 0.85rem;
    text-align: left;
  }

  .home-municipality-hub__name {
    position: static;
    display: inline-flex;
    align-self: flex-start;
    max-width: 100%;
    padding: 0.22rem 0.55rem;
    border-radius: 0.35rem;
    background: var(--hub-accent);
    color: #fff;
    font-size: 0.86rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0.01em;
    white-space: nowrap;
    box-shadow: none;
  }

  .home-municipality-hub__name-suffix {
    display: none;
  }

  .home-municipality-hub__stats {
    display: block;
    margin: 0;
    padding-right: 0;
    color: var(--hub-muted, var(--region-text-muted));
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.35;
  }

  .home-municipality-hub__chevron {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    bottom: auto;
    transform: translateY(-50%);
    color: var(--hub-accent);
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
  }

  /* Senaste nyheterna: lista med regionetikett, tid, rubrik och pil. */
  .home-hub__block--headlines-mobile .home-headlines-list {
    padding: 0.85rem 0.9rem 0.6rem;
    border: 1px solid color-mix(in srgb, var(--region-border) 84%, var(--region-primary) 16%);
    border-radius: 0.8rem;
  }

  .home-hub__block--headlines-mobile .home-headlines-list__title {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.01em;
  }

  .home-hub__block--headlines-mobile .home-headlines-list__more {
    font-weight: 700;
    color: var(--region-primary);
  }

  .home-hub__block--headlines-mobile .home-headlines-list__items {
    gap: 0;
  }

  .home-hub__block--headlines-mobile .home-headlines-list__item + .home-headlines-list__item {
    border-top: 1px solid color-mix(in srgb, var(--region-border) 88%, transparent);
  }

  .home-hub__block--headlines-mobile .home-headlines-list__card {
    grid-template-columns: 4.25rem minmax(0, 1fr) 1rem;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0;
  }

  .home-hub__block--headlines-mobile .home-headlines-list__card::after {
    content: "›";
    color: var(--hub-muted, var(--region-text-muted));
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
    text-align: right;
  }

  .home-hub__block--headlines-mobile .home-headlines-list__media {
    aspect-ratio: 4 / 3;
    min-height: 0;
    border-radius: 0.45rem;
  }

  .home-hub__block--headlines-mobile .home-headlines-list__media--empty::after {
    display: none;
  }

  .home-hub__block--headlines-mobile .home-headlines-list__preview {
    display: none;
  }

  .home-headlines-list__meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
  }

  .home-headlines-list__region {
    --headline-region-accent: var(--headline-region-light, var(--region-primary));
    display: inline-block;
    padding: 0.12rem 0.4rem;
    border-radius: 0.25rem;
    background: var(--headline-region-accent);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1.3;
    white-space: nowrap;
  }

  [data-theme="dark"] .home-headlines-list__region {
    --headline-region-accent: var(--headline-region-dark, var(--region-primary));
    color: #0b0d0f;
  }

  .home-hub__block--headlines-mobile .home-headlines-list__headline {
    font-size: 0.95rem;
    line-height: 1.28;
  }

  /* Mest läst: nummer i cirkel, region till höger. */
  .home-hub__block--most-read-mobile .home-most-read {
    padding: 0.85rem 0.9rem 0.5rem;
    border: 1px solid color-mix(in srgb, var(--region-border) 84%, var(--region-primary) 16%);
    border-radius: 0.8rem;
    background: var(--hub-panel, var(--region-bg));
  }

  .home-hub__block--most-read-mobile .home-most-read__item {
    grid-template-columns: 1.6rem minmax(0, 1fr);
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0;
  }

  .home-hub__block--most-read-mobile .home-most-read__rank {
    display: grid;
    place-items: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 999px;
    background: var(--region-primary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1;
  }

  .home-hub__block--most-read-mobile .home-most-read__content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.6rem;
  }

  .home-hub__block--most-read-mobile .home-most-read__title {
    font-size: 0.92rem;
    line-height: 1.28;
  }

  .home-hub__block--most-read-mobile .home-most-read__region {
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .home-hub__block--most-read-mobile .home-most-read__date,
  .home-hub__block--most-read-mobile .article-hover-teaser {
    display: none;
  }

  /* Play kompakt: mindre luft när blocket ligger längre ned. */
  .home-hub__block--media {
    gap: 0;
  }

  /* Senaste briefen: bilden fyller kortet och texten ligger över. */
  .home-play-listen--compact .home-play-listen__brief {
    display: block;
    position: relative;
    min-height: 15rem;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: #10161f;
  }

  .home-play-listen--compact .home-play-listen__brief-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: cover;
  }

  .home-play-listen--compact .home-play-listen__brief-body {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 15rem;
    padding: 0.75rem 0.85rem 0.85rem;
    background:
      linear-gradient(180deg, rgba(8, 12, 20, 0.42) 0%, rgba(8, 12, 20, 0.08) 34%, rgba(8, 12, 20, 0.86) 100%);
  }

  .home-play-listen--compact .home-play-listen__brief .home-play-listen__meta {
    margin-bottom: auto;
    color: #fff;
  }

  .home-play-listen--compact .home-play-listen__brief .home-play-listen__meta span {
    display: inline-flex;
    padding: 0.14rem 0.45rem;
    border-radius: 999px;
    background: rgba(8, 12, 20, 0.55);
    color: #fff;
    font-size: 0.62rem;
    letter-spacing: 0.06em;
  }

  .home-play-listen--compact .home-play-listen__brief-title,
  [data-theme="light"] .home-play-listen--compact .home-play-listen__brief-title {
    max-width: 16ch;
    margin-top: 0.55rem;
    color: #fff;
    font-size: 1.28rem;
    line-height: 1.1;
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
  }

  .home-play-listen--compact .home-play-listen__brief-description {
    display: none;
  }

  .home-play-listen--compact .home-play-listen__brief-actions {
    margin-top: 0.7rem;
  }

  .home-play-listen--compact .home-play-listen__brief .home-play-listen__open,
  [data-theme="light"] .home-play-listen--compact .home-play-listen__brief .home-play-listen__open {
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(8, 12, 20, 0.35);
    color: #fff;
  }
}

/* Surfplatta stående: två kolumner för kommunkorten blir för glest, behåll tre. */
@media (min-width: 640px) and (max-width: 1024px) {
  .home-kommun-tabs {
    max-width: 30rem;
  }

  .home-municipality-hub__grid {
    gap: 0.75rem;
  }

  .home-municipality-hub__stage {
    grid-template-columns: 9.5rem minmax(0, 1fr);
    min-height: 7rem;
  }
}

/* Desktop: flikar och mobilhuvud bort. Kommunhubben har egen rubrik och siluettvideo. */
@media (min-width: 1025px) {
  .home-hub__block--kommun-tabs,
  .home-kommun-tabs,
  .home-municipality-hub__head-mobile,
  .home-municipality-hub__chevron,
  .home-hub__block--ad-top-mobile,
  .home-headlines-list__region {
    display: none !important;
  }
}
