/* Resources page and blog posts. Loaded after style.css by resources.njk and
   layouts/post.njk (front matter `css: blog.css`).

   Screen sizes, as in style.css: phones are the base rules, tablets
   @media (min-width: 768px), desktop @media (min-width: 1025px).
   Blog cards themselves are styled in style.css (.blog-card). */

/* ================= Resources page (resources.njk) ================= */

/* Top: the <h1> with the blog search box beside it (below it on phones). */
.resources-top {
  padding-block: 70px;
}

.resources-top h1 {
  margin: 0;
}

.resources-top__inner {
  display: grid;
  gap: 30px;
  align-items: center;
}

/* Blog search: a rounded box with a magnifying glass (js/blog-search.js). */
.blog-search {
  position: relative;
  width: 100%;
  max-width: 290px;
}

/* Until js/blog-search.js shows it, the box is invisible but keeps its space,
   so the posts below don't jump down when it appears (layout shift, T17 N2). */
.blog-search[hidden] {
  display: block;
  visibility: hidden;
}

.blog-search__input {
  width: 100%;
  height: 42px;
  padding: 0 44px 0 22px;
  border: 1px solid var(--green);
  border-radius: 999px;
  background: var(--white);
  color: var(--green);
  font: 14px var(--font);
}

.blog-search__input::placeholder {
  color: var(--green);
  opacity: 1;
}

/* The magnifying glass is the search button; it jumps to the list. */
.blog-search__button {
  position: absolute;
  top: 0;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--green);
  cursor: pointer;
}

/* "No posts match your search." under the list; takes no space when empty. */
.blog-search__status {
  margin: 20px 0 0;
}

.blog-search__status:empty {
  display: none;
}

.resources-blog {
  padding-bottom: var(--section-space);
}

/* 50 px from the last "Read More" to the calculator section, as live. */
@media (min-width: 768px) {
  .resources-blog {
    padding-bottom: 50px;
  }
}

.resources-blog .blog-grid > li[hidden] {
  display: none;
}

/* Blog cards, spaced as live: 15 px between photo, title, summary and link.
   "Read More →" is a full-width line pinned to the bottom of the card, so the
   links in a row line up. (Fonts and colours are in style.css, .blog-card.) */
.resources-blog .blog-grid > li {
  display: flex;
}

.resources-blog .blog-card {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.blog-card__img-link {
  display: block;
  overflow: hidden; /* keeps the zoomed photo inside its rounded corners */
  border-radius: var(--radius-button);
}

/* Hovering a card zooms its photo a little, as live. */
@media (prefers-reduced-motion: no-preference) {
  .resources-blog .blog-card__img {
    transition: transform 0.2s ease-out;
  }

  .resources-blog .blog-card:hover .blog-card__img {
    transform: scale(1.06);
  }
}

.resources-blog .blog-card__title {
  margin: 15px 0;
}

.resources-blog .blog-card__text {
  margin: 0 0 15px;
}

.resources-blog .blog-card__more {
  display: block;
  margin-top: auto;
  line-height: 27px;
}

/* Phones: smaller title, summary and link, and 15 px below the link, as live. */
@media (max-width: 767px) {
  .resources-blog .blog-card {
    padding-bottom: 15px;
  }

  .resources-blog .blog-card__title {
    font-size: 20px;
  }

  .resources-blog .blog-card__text {
    font-size: 14px;
  }

  .resources-blog .blog-card__more {
    font-size: 16px;
    line-height: 24px;
  }
}

@media (min-width: 768px) {
  /* The h1 starts 259 px down the page (139 below the page's 120 px offset,
     see "Header and menu" in style.css), and 150 px from the h1 to the first
     photo, as live. */
  .resources-top {
    padding-block: 139px 150px;
  }

  /* The search box sits level with the top of the h1, not its middle, as live:
     180 px wide on tablets, 300 px on desktops. */
  .resources-top__inner {
    grid-template-columns: 1fr 180px;
    gap: 20px;
    align-items: start;
  }

  .blog-search {
    margin-top: 39px;
  }

  .resources-top h1 {
    max-width: 760px;
  }

  .blog-search {
    max-width: none;
  }

  .blog-search__input {
    height: 40px;
  }
}

@media (min-width: 1025px) {
  .resources-top {
    padding-block: 140px 150px;
  }

  .resources-top__inner {
    grid-template-columns: 1fr 300px;
    gap: 40px;
  }
}

/* ================= Cubic yard calculator (partials/calculator.njk) ================= */

.calc-section {
  padding-top: 25px;
}

@media (min-width: 768px) {
  .calc-section {
    padding-top: 60px;
  }
}

.calc-section h2 {
  margin-bottom: 10px;
  color: var(--red);
}

/* The intro sentence sits 12 px above the calculator, as live. */
.calc-section .container > p {
  margin-bottom: 12px;
}

/* The calculator card, laid out like live's Calconic one:
   - phones: the title bar, the three boxes one above another, then the result;
   - 768 px and up: the three boxes side by side, the result a full-width tile below;
   - 1200 px and up: four equal columns, with the result in the fourth.
   Columns use minmax(0, 1fr) so none can grow wider than its share. The card
   hides its overflow, so anything wider would be cut off (T10 F75). */
.calc {
  margin-top: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--white);
}

.calc__title {
  margin: 0;
  padding: 10px 25px;
  background: rgb(236 236 236);
  color: rgb(51 51 51);
  font-size: 20px;
  font-weight: 700;
  line-height: 27px;
}

.calc__fields {
  padding-block: 10px;
}

.calc__field {
  padding: 15px 25px 10px;
}

.calc__label {
  display: block;
  margin-bottom: 8px;
  color: rgb(51 51 51);
  font-size: 14px;
  font-weight: 700;
  line-height: 17px;
}

/* The input box with its unit ("feet", "inches") to the right. */
.calc__input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.calc__input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid rgb(204 204 204);
  border-radius: 4px;
  background: var(--white);
  color: var(--text);
  font: 16px var(--font);
}

.calc__input[aria-invalid="true"] {
  border-color: var(--red);
  outline: 1px solid var(--red);
}

.calc__unit {
  color: var(--muted);
  font-size: 14px;
}

/* Dark result tile, 102 px tall like live's. Square corners; the card rounds
   the bottom ones when the tile sits at the bottom. */
.calc__result {
  padding: 20px 25px 15px;
  background: rgb(51 51 51);
  color: var(--white);
}

.calc__result-label {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 17px;
}

.calc__result-value {
  display: block;
  margin-top: 5px;
  font-size: 34px;
  font-weight: 700;
  line-height: 45px;
}

.calc__error {
  margin: 5px 0 0;
  font-size: 15px;
}

.calc__error:empty {
  display: none;
}

.calc__noscript {
  margin: 0;
  padding: 0 25px 20px;
}

@media (min-width: 768px) {
  .calc__fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding-block: 0;
  }

  .calc__field {
    padding: 25px 25px 20px;
  }
}

/* Small desktops: the card is at most 960 px wide, centred, as live. */
@media (min-width: 1025px) and (max-width: 1199px) {
  .calc {
    max-width: 960px;
    margin-inline: auto;
  }
}

/* Side by side. The result keeps its 102 px height, so a white strip shows
   below it, as on live. */
@media (min-width: 1200px) {
  .calc__body {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
    align-items: start;
  }
}

/* ================= Blog posts (layouts/post.njk) ================= */

/* The article text: tighter line spacing than the rest of the site, as live,
   with one blank line between paragraphs and lists. */
.post__body {
  padding-block: 90px 0;
}

.prose {
  line-height: 1.38;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.38em;
}

/* A paragraph that introduces a list sits right on top of it, as live. */
.prose p:has(+ ul),
.prose p:has(+ ol) {
  margin-bottom: 0;
}

.prose ul,
.prose ol {
  padding-left: 32px;
}

.prose li {
  margin: 0;
}

.prose h2,
.prose h3 {
  margin: 0;
  line-height: normal;
}

/* <h2 class="h3"> and <h3 class="h4">: headings that keep the right order for
   screen readers and search engines but look like the smaller live heading.
   Used in two posts (see the note in their front matter). */
.prose .h3 {
  color: var(--red);
  font-size: var(--h3);
}

.prose .h4 {
  color: var(--red);
  font-size: 20px;
}

@media (min-width: 768px) {
  .prose .h4 {
    font-size: 24px;
  }
}

/* "Get a Quote" button inside a post: a blank line above and below. */
.prose .btn {
  margin-block: 0.5em;
}

/* "< Older Post" and "Newer Post >" links, then the share icons. */
.post-after {
  max-width: calc(1100px + 2 * var(--gutter));
  padding-block: 73px 60px;
}

.post-pager {
  display: flex;
  justify-content: space-between;
}

/* Each link takes half the row, as live, so the whole half is clickable. */
.post-pager > a {
  flex: 0 0 50%;
}

/* Keeps "Newer Post >" on the right when there is no older post. */
.post-pager__newer {
  margin-left: auto;
  text-align: right;
}

.share {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin: 55px 0 0;
  padding: 0;
  list-style: none;
}

.share__link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  fill: currentColor;
  transition: background-color 0.2s;
}

.share__link:hover {
  background: var(--green);
}

/* Glyph sizes as live's. Facebook's and LinkedIn's drawings leave more empty
   space in their box, so their boxes are larger. */
.share__link svg {
  width: 21px;
  height: 21px;
}

.share__link .share__icon--large {
  width: 24px;
  height: 24px;
}

/* The article text on phones starts 5 px further in than the page edge, as live. */
@media (max-width: 767px) {
  .post__body .prose {
    padding-left: calc(var(--gutter) + 5px);
  }
}

@media (min-width: 768px) {
  .post__body {
    padding-top: 110px;
  }

  .prose ul,
  .prose ol {
    padding-left: 36px;
  }

  .post-after {
    padding-block: 100px 115px;
  }

  .share {
    margin-top: 45px;
  }
}

/* Tablets: the article text, older/newer links and share icons sit 10 px
   further in from each side, as live. */
@media (min-width: 768px) and (max-width: 1024px) {
  .post__body .prose,
  .post-after {
    padding-inline: calc(var(--gutter) + 10px);
  }
}
