/* app/static/css/layouts/newspaper.css */
/* Newspaper Layout Specific CSS using base variables - Mobile First */

/* --- Base Header Overrides (Applies to all sizes unless overridden) --- */
.layout-newspaper .header--newspaper-override {
  padding: 0;
  border-bottom: none;
  position: relative;
  background-color: transparent;
  box-shadow: none;
  color: var(--color-text-primary);

  /* --- Mobile Header Grid Layout (Default) --- */
  display: grid;
  grid-template-columns: 2.5rem 1fr 2.5rem; /* Toggle | Masthead | Spacer */
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-bottom: var(--border-width-default) solid var(--color-border);
  background-color: var(--color-surface-2);
  min-height: 50px;
  gap: var(--spacing-sm);
}

/* Style the toggle wrapper (Grid Item 1 - Mobile) */
.layout-newspaper .masthead-mobile-toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-column: 1 / 2;
  width: 2.5rem;
  height: 2.2rem;
}
.layout-newspaper .masthead-mobile-toggle-wrapper .header__toggle {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}
.layout-newspaper .masthead-mobile-toggle-wrapper .header__toggle-line {
  background-color: var(--color-text-primary);
}

/* --- Masthead Component Styling (Base/Mobile) --- */
.layout-newspaper .masthead {
  border-bottom: none;
  padding: 0;
  margin-bottom: 0;
  width: 100%;
  background-color: transparent;
  text-align: center;
  overflow: hidden;
  grid-column: 2 / 3;
  min-width: 0;
}
.layout-newspaper .masthead__container {
  padding: 0;
}
.layout-newspaper .masthead__date {
  display: none;
}
.layout-newspaper .masthead__title {
  font-family: var(--font-family-heading);
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  line-height: 1;
  margin: 0;
  color: inherit;
}
.layout-newspaper .masthead__title-link {
  display: block;
  color: inherit;
}
.layout-newspaper .masthead__tagline {
  display: none;
}

/* --- Navigation (Single nav element for mobile + desktop) --- */

/* Mobile: wrapper is transparent, nav uses base header.css dropdown behavior */
.layout-newspaper .nav-background-wrapper {
  grid-column: 1 / -1;
  background-color: transparent;
  border: none;
}

/* Mobile dropdown styling when nav is toggled active */
.layout-newspaper .header--newspaper-override .header__nav.active {
  background-color: var(--color-surface-2);
  border-bottom: var(--border-width-default) solid var(--color-border);
  border-top: var(--border-width-default) solid var(--color-border);
  z-index: var(--z-index-dropdown);
  padding: var(--spacing-md);
  gap: var(--spacing-sm);
  flex-direction: column;
  box-shadow: var(--shadow-md);
}
.layout-newspaper .header--newspaper-override .header__nav .header__link {
  color: var(--color-text-primary);
  padding: var(--spacing-xs) 0;
  font-family: var(--font-family-base);
  text-decoration: none;
}
.layout-newspaper .header--newspaper-override .header__nav .header__link:hover {
  color: var(--color-link);
}

/* Override header.css: keep nav as mobile dropdown between 768px-1024px */
@media (min-width: 768px) and (max-width: 1023px) {
  .layout-newspaper .header--newspaper-override .header__nav {
    display: none;
    position: absolute;
    flex-direction: column;
  }
  .layout-newspaper .header--newspaper-override .header__nav.active {
    display: flex;
  }
  .layout-newspaper .masthead-mobile-toggle-wrapper .header__toggle {
    display: block;
  }
}

/* --- Desktop Layout Adjustments (min-width: 1024px) --- */
@media (min-width: 1024px) {
  /* Reset header display from grid to block */
  .layout-newspaper .header--newspaper-override {
    display: block;
    grid-template-columns: none;
    gap: 0;
    padding: 0;
    border-bottom: none;
    background-color: transparent;
    min-height: auto;
  }

  /* Hide the mobile toggle wrapper */
  .layout-newspaper .masthead-mobile-toggle-wrapper {
    display: none;
  }

  /* Show the desktop nav bar wrapper with full-width background */
  .layout-newspaper .nav-background-wrapper {
    background-color: var(--color-surface-2);
    border-bottom: var(--border-width-default) solid var(--color-border);
  }
  .layout-newspaper .header__nav-container--newspaper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-xs) var(--container-padding-x);
    max-width: none;
  }
  .layout-newspaper .nav-background-wrapper .header__nav {
    display: inline-flex;
    flex-direction: row;
    gap: var(--spacing-md);
    position: static;
    background: none;
    border: none;
    padding: 0;
    box-shadow: none;
    width: auto;
  }
  .layout-newspaper .nav-background-wrapper .header__link {
    padding: 0;
    font-family: var(--font-family-base);
    color: var(--color-text-primary);
    text-decoration: none;
    font-size: var(--font-size-sm);
  }
  .layout-newspaper .nav-background-wrapper .header__link:hover {
    color: var(--color-link);
  }

  /* Restore masthead styles for desktop */
  .layout-newspaper .masthead {
    padding: var(--spacing-md) 0;
    margin-bottom: 0;
    text-align: center;
    width: 100%;
    overflow: visible;
    border-bottom: none;
    grid-column: auto;
    background-color: var(--color-surface-1);
  }
  .layout-newspaper .masthead__container {
    padding: 0 var(--spacing-sm);
  }
  .layout-newspaper .masthead__date {
    display: block;
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-xs);
  }
  .layout-newspaper .masthead__title {
    font-size: clamp(2rem, 8vw, 4rem);
    line-height: var(--line-height-heading);
    margin: var(--spacing-xs) 0;
    color: var(--color-text-primary);
  }
  .layout-newspaper .masthead__tagline {
    display: block;
    font-size: var(--font-size-sm);
    margin: 0;
  }

  /* --- Desktop Grid Structure (Main Content + Sidebar) --- */
  .layout-newspaper .layout {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-md);
  }
  .layout-newspaper .layout__main {
    grid-column: 1;
    width: auto;
  }
  .layout-newspaper .layout__sidebar {
    grid-column: 2;
    margin-top: 0;
    width: auto;
    border-left: var(--border-width-default) solid var(--color-border);
    padding-left: var(--spacing-lg);
  }

  /* --- Newspaper Article Grid Container --- */
  .layout-newspaper .layout__main .card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: auto;
    gap: var(--spacing-md);
  }

  /* --- Base newspaper card: chromeless with separator --- */
  .layout-newspaper .layout__main .card-grid > .slot > .card {
    --card-title-size: var(--font-size-md);
    background-color: transparent;
    border: none;
    border-bottom: var(--border-width-default) solid var(--color-border);
    box-shadow: none;
    border-radius: 0;
    padding-bottom: var(--spacing-sm);
    overflow: visible;
  }
  .layout-newspaper .layout__main .card-grid > .slot > .card:hover {
    box-shadow: none;
  }
  .layout-newspaper .layout__main .card-grid > .slot .card__content {
    padding: 0;
  }
  .layout-newspaper .layout__main .card-grid > .slot .card__description {
    font-size: var(--font-size-sm);
    line-height: 1.3;
  }

  /* --- Card 1: Lead article --- */
  .layout-newspaper .layout__main .content-section:first-child .card-grid > .slot:first-child {
    grid-column: 1 / 3;
    grid-row: 1 / 4;
  }
  /* Solo lead: full-width with text overlay on image */
  .layout-newspaper .layout__main .content-section:first-child .card-grid > .slot:only-child {
    grid-column: 1 / -1;
    grid-row: auto;
  }
  .layout-newspaper .layout__main .content-section:first-child .card-grid > .slot:only-child > .card {
    --card-title-size: var(--font-size-2xl);
    --card-line-clamp: 3;
    min-height: 28rem;
    justify-content: flex-end;
    border-bottom: none;
    padding-bottom: 0;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:only-child
    .card__image-container {
    position: absolute;
    inset: 0;
    z-index: 1;
    margin: 0;
    aspect-ratio: unset;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:only-child
    .card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:only-child
    > .card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.7) 100%);
    pointer-events: none;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:only-child
    .card__content {
    position: relative;
    z-index: 3;
    padding: var(--spacing-md) var(--spacing-lg);
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:only-child
    .card__title,
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:only-child
    .card__description,
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:only-child
    .card__category,
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:only-child
    .card__meta {
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6);
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:only-child
    .card__title a {
    color: inherit;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:only-child
    .card__description {
    display: -webkit-box !important;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Multi-card lead (non-solo): standard newspaper treatment */
  .layout-newspaper .layout__main .content-section:first-child .card-grid > .slot:first-child > .card {
    --card-title-size: var(--font-size-xl);
    --card-line-clamp: 4;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:first-child
    .card__image-container {
    margin-bottom: var(--spacing-sm);
    aspect-ratio: unset;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:first-child
    .card__content {
    padding: 0 var(--spacing-xs);
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:first-child
    .card__description {
    display: -webkit-box !important;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: var(--spacing-xs);
    line-height: 1.4;
  }

  /* --- Cards 2-4: Stacked headlines (no image, no description) --- */
  .layout-newspaper .layout__main .content-section:first-child .card-grid > .slot:nth-child(2) {
    grid-row: 1 / 2;
    grid-column: 3 / 4;
  }
  .layout-newspaper .layout__main .content-section:first-child .card-grid > .slot:nth-child(3) {
    grid-row: 2 / 3;
    grid-column: 3 / 4;
  }
  .layout-newspaper .layout__main .content-section:first-child .card-grid > .slot:nth-child(4) {
    grid-row: 3 / 4;
    grid-column: 3 / 4;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 2):nth-child(-n + 4)
    .card__image-container,
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 2):nth-child(-n + 4)
    .card__description {
    display: none !important;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 2):nth-child(-n + 4)
    .card__content {
    padding: 0 var(--spacing-xs);
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 2):nth-child(-n + 4)
    .card__title {
    margin-top: var(--spacing-xs);
    margin-bottom: 0;
  }

  /* --- Cards 5+: Staggered visibility pattern --- */
  /* Base: hide image, show description */
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 5)
    .card__image-container {
    display: none !important;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 5)
    .card__title {
    margin-top: var(--spacing-xs);
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 5)
    .card__description {
    --card-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Cards 5-7: show image + description */
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 5):nth-child(-n + 7)
    .card__image-container {
    display: block !important;
    margin-bottom: var(--spacing-sm);
    aspect-ratio: unset;
    height: auto;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 5):nth-child(-n + 7)
    .card__title {
    margin-top: 0;
  }

  /* Cards 8-10: hide image + description (headline only) */
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 8):nth-child(-n + 10)
    .card__description {
    display: none !important;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 8):nth-child(-n + 10)
    .card__title {
    margin-bottom: 0;
  }

  /* Cards 11-13: show image + description */
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 11):nth-child(-n + 13)
    .card__image-container {
    display: block !important;
    margin-bottom: var(--spacing-xs);
    aspect-ratio: unset;
    height: auto;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 11):nth-child(-n + 13)
    .card__description {
    display: block !important;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 11):nth-child(-n + 13)
    .card__title {
    margin-top: 0;
  }

  /* Cards 14+: hide image + description (headline only) */
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 14)
    .card__description {
    display: none !important;
  }
  .layout-newspaper
    .layout__main
    .content-section:first-child
    .card-grid
    > .slot:nth-child(n + 14)
    .card__title {
    margin-bottom: 0;
  }
  /* --- Section Spacing --- */
  .layout-newspaper .content-section {
    margin-bottom: var(--spacing-xl, 2rem);
    padding-top: var(--spacing-md);
  }
  .layout-newspaper .content-section:first-child {
    border-top: none;
    padding-top: 0;
  }
  .layout-newspaper .content-section + .content-section {
    border-top: var(--border-width-default) solid var(--color-border);
  }

  /* --- Section Headings: newspaper style --- */
  .layout-newspaper .content-section__heading {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: var(--font-size-sm, 0.875rem);
  }

  /* --- Card Meta Visibility --- */
  .layout-newspaper .card__meta {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xs);
    font-size: var(--font-size-xs, 0.75rem);
    color: var(--color-text-muted);
  }

  /* --- Sidebar Sticky --- */
  .layout-newspaper .layout__sidebar .sidebar {
    position: sticky;
    top: var(--spacing-md);
  }
} /* End Desktop Media Query (min-width: 1024px) */
