/* --------------------------------------------
   Overall styles for Newspaper layout
----------------------------------------------- */

main {
  font-family: Georgia, "Times New Roman", "Noto Serif", serif;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Masthead */
.masthead {
  border-block-end: 3px double light-dark(#111, #ccc);
  padding: 1.2rem 0 0.8rem;
}
.masthead-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 0.25rem 1rem;
  padding-inline: calc(4vw + 1rem);
}
.masthead h1 {
  font-family: Georgia, "Times New Roman", "Noto Serif", serif;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: light-dark(#111, #eee);
  white-space: nowrap;
  grid-column: 2;
  text-align: center;
}
.masthead-date {
  grid-column: 1;
}
.masthead-tagline {
  grid-column: 3;
  text-align: end;
}
.masthead-date,
.masthead-tagline {
  font-family: system-ui, sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: light-dark(#888, #777);
}
@media (max-width: 800px) {
  .masthead-inner {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .masthead-date,
  .masthead-tagline {
    grid-column: 1;
    grid-row: auto;
    text-align: center;
  }
  .masthead h1 {
    font-size: 1.8rem;
  }
}

/* Articles */
h2 {
  font-family: Georgia, "Times New Roman", "Noto Serif", serif;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
  margin: 0;
  color: light-dark(#1a1a1a, #eee);
  text-wrap: balance;
}
p {
  font-size: 0.82rem;
  line-height: 1.5;
  color: light-dark(#333, #bbb);
  margin-block: 0.4lh;
}
article {
  padding: 0.8lh 0;
  border-block-start: 3px solid light-dark(#111, #ccc);
  margin-trim: block;
}
article img {
  width: 100%;
  height: auto;
  display: block;
  margin-block-end: 0.5lh;
}

/* Lead story */
article.lead h2 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}
article.lead p {
  font-size: 1.1rem;
  line-height: 1.5;
  max-width: 65ch;
}

/* Secondary stories */
article.secondary h2 {
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
}

/* Feature stories */
article.feature h2 {
  font-size: clamp(1rem, 2vw, 1.2rem);
}

/* --------------------------------------------
   Basic layout for Newspaper
----------------------------------------------- */

main {
  padding-inline: calc(4vw + 1rem);
  padding-block-start: 1lh;
}
@media (max-width: 500px) {
  main {
    padding-inline: calc(2vw + 0.5rem);
  }
  .masthead-inner {
    padding-inline: calc(2vw + 0.5rem);
  }
}

/* --------------------------------------------
   Variations on the layout
----------------------------------------------- */

/* ---- Multicolumn layout ---- */
body:has(option[value="one"]:checked) main {
  display: block;
  columns: 25ch;
  column-gap: 2lh;
  article {
    break-inside: avoid;
  }
}

/* ---- CSS Grid level 1 (without Masonry) ---- */
body:has(option[value="two"]:checked) main {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16ch, 1fr));
  column-gap: 2lh;
  article.lead {
    grid-column: span 3;
  }
  article.secondary {
    grid-column: span 2;
  }
  article.feature {
    grid-column: span 2;
  }
}
@media (max-width: 600px) {
  body:has(option[value="two"]:checked) main {
    article.lead,
    article.secondary,
    article.feature {
      grid-column: span 1;
    }
  }
}
@media (max-width: 768px) and (min-width: 601px) {
  body:has(option[value="two"]:checked) main {
    article.lead {
      grid-column: span 2;
    }
    article.secondary,
    article.feature {
      grid-column: span 1;
    }
  }
}
@media (max-width: 1250px) and (min-width: 769px) {
  body:has(option[value="two"]:checked) main {
    article.lead {
      grid-column: span 2;
    }
  }
}

/* ---- Grid Lanes — Waterfall ---- */
body:has(option[value="three"]:checked) main {
  display: grid-lanes;
  grid-template-columns: repeat(auto-fill, minmax(16ch, 1fr));
  column-gap: 2lh;
  article.lead {
    grid-column: span 3;
  }
  article.secondary {
    grid-column: span 2;
  }
  article.feature {
    grid-column: span 2;
  }
}
@media (max-width: 600px) {
  body:has(option[value="three"]:checked) main {
    article.lead,
    article.secondary,
    article.feature {
      grid-column: span 1;
    }
    article.lead h2 {
      font-size: clamp(1.3rem, 4vw, 1.6rem);
    }
    article.lead p {
      font-size: 0.9rem;
    }
  }
}
@media (max-width: 768px) and (min-width: 601px) {
  body:has(option[value="three"]:checked) main {
    article.lead {
      grid-column: span 2;
    }
    article.secondary,
    article.feature {
      grid-column: span 1;
    }
  }
}
@media (max-width: 1250px) and (min-width: 769px) {
  body:has(option[value="three"]:checked) main {
    article.lead {
      grid-column: span 2;
    }
  }
}

/* --------------------------------------------
   Counters marking items (when enabled)
----------------------------------------------- */

body {
  counter-reset: item-counter 0;
}
article {
  position: relative;
  counter-increment: item-counter;
}
body:has(input[type="checkbox"]:checked) {
  article::before,
  article::after {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0.1em 0.5em 0.3em;
    min-width: 2ch;
    text-align: right;
  }
  article::after {
    content: counter(item-counter);
    background: rgba(65, 83, 47, 0.65);
    color: white;
    font-family: var(--font-text);
    font-size: 2rem;
  }
  article::before {
    content: counter(item-counter);
    color: white;
    font-family: var(--font-text);
    font-size: 2rem;
  }
}
