/*
 * .faq — eyebrow + photo, heading and a numbered accordion
 * (template-parts/global/faq.php: flexible layout `faq` and block acf/faq).
 * Figma: Plastics D 337:16498 / M 337:15818; Webinar D 337:9534 / M 337:10018.
 *
 * Phones and tablets: one column (eyebrow → photo → heading → list).
 * Desktop: eyebrow and photo in a 335 px column, heading and list on the right.
 * Native <details>: numbers come from a CSS counter, the open item turns blue;
 * faq.js slides answers open and shut (instant toggle without JS).
 */

.faq {
  padding-top: var(--nv-section-y);
  padding-bottom: var(--nv-section-y);
}

/* .faq[id] — the menu's FAQ link (/industries/plastics-manufacturing/#faq) stops below the fixed header */
.faq[id] {
  scroll-margin-top: 7.5rem;
}

/* .resources + .faq — the FAQ frame starts right under the resources block (Figma pad 0 … 100) */
.resources + .faq {
  padding-top: 0;
}

/* .faq--textured — webinar FAQ with the texture strip (D 337:9535; none on M) */
.faq--textured {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

/* .faq--textured:has(+ .testimonial-slider) — the webinar testimonials follow 50 → 175 px under the list:
   their own 50 → 100 px plus 0 → 75 px here (Figma 1574:10814 / 1574:10292, matched visually 2026-10-14);
   in the block editor content each block sits in its own .nv-block wrapper */
.faq--textured:has(+ .testimonial-slider),
.nv-block:has(+ .nv-block > .testimonial-slider) > .faq--textured {
  padding-bottom: clamp(0rem, -1.6659rem + 7.109vw, 4.6875rem);
}

/* .faq__texture — left edge, 410 of 1520 px, clipped to the section */
.faq__texture {
  display: none;

  /* @media (width >= 48em) .faq__texture */
  @media (width >= 48em) {
    display: block;
    position: absolute;
    z-index: -1;
    top: 0;
    left: 0;
    width: 26.97%;
    pointer-events: none;
  }
}

/* .page-id-116 .faq__texture — About only: the strip fades out towards the section bottom instead of being
   cut by it (Figma 18:42681 runs on behind the CTA; Vlad, 2026-11-18) */
.page-id-116 .faq__texture {
  /* @media (width >= 48em) .page-id-116 .faq__texture */
  @media (width >= 48em) {
    bottom: 0;
    overflow: hidden;
    mask-image: linear-gradient(to bottom, #000 50%, transparent);
  }
}

/* .faq__texture-image */
.faq__texture-image {
  display: block;
  width: 100%;
  height: auto;
}

/* .faq__container */
.faq__container {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.875rem;

  /* @media (width >= 64.0625em) .faq__container — 335 px column + 80 px gap */
  @media (width >= 64.0625em) {
    grid-template-columns: minmax(0, 20.9375rem) minmax(0, 1fr);
    gap: 5rem;
  }
}

/* .faq__aside — eyebrow above the photo */
.faq__aside {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(1.875rem, 0.8086rem + 4.5497vw, 4.875rem);
}

/* .faq__eyebrow — a word longer than the column breaks instead of running off the screen */
.faq__eyebrow {
  display: inline-flex;
  max-width: 100%;
  align-items: flex-start;
  overflow-wrap: anywhere;
  gap: 0.3125rem;
  padding: calc(0.625rem - 0.14em) 0.625rem;
  color: var(--nv-green);
  font-weight: 500;
  font-size: clamp(0.875rem, 0.7417rem + 0.5687vw, 1.25rem);
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;

  /* .faq__eyebrow::before — rhomb */
  &::before {
    content: "";
    flex-shrink: 0;
    width: 0.53rem;
    height: 0.53rem;
    margin-top: calc(0.5lh - 0.265rem);
    background: url("../../img/icons/rhomb.svg") center / contain no-repeat;
  }
}

/* .faq__media — 238 × 188 */
.faq__media {
  width: 14.875rem;
  max-width: 100%;
  aspect-ratio: 238 / 188;
  border-radius: var(--nv-radius-s);
  overflow: hidden;
}

/* .faq__image */
.faq__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* .faq__main — heading, 50 px, list */
.faq__main {
  display: flex;
  flex-direction: column;
  gap: 3.125rem;
  min-width: 0;

  /* @media (width >= 64.0625em) .faq__main — right column even without the aside */
  @media (width >= 64.0625em) {
    grid-column: 2;
  }
}

/* .faq__title — the phone frame trims the line box to cap / baseline, the desktop one does not
   (Figma M 269 px for 7 lines of 40, D 300 px for 4 lines of 75) */
.faq__title {
  color: var(--nv-navy);
  font-weight: 400;
  font-size: clamp(2.5rem, 1.7225rem + 3.3176vw, 4.6875rem);
  line-height: 1;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;

  /* @media (width < 48em) .faq__title */
  @media (width < 48em) {
    margin-top: -0.14em;
    margin-bottom: -0.14em;
  }

  & strong {
    color: var(--nv-green);
    font-weight: inherit;
  }
}

/* .faq__list — numbers 01., 02.… */
.faq__list {
  border-bottom: 1px solid rgba(19, 33, 50, 0.1);
  counter-reset: faq;
}

/* .faq__item */
.faq__item {
  border-top: 1px solid rgba(19, 33, 50, 0.1);
  padding: 1.25rem 0;
  counter-increment: faq;
  transition: padding 0.5s ease;

  /* @media (width >= 64.0625em) .faq__item — 25 px closed */
  @media (width >= 64.0625em) {
    padding: 1.5625rem 0;
  }
}

/* .faq__item[open] — 50 px on desktop; .faq__item--closing (faq.js) returns to 25 px while the answer collapses */
.faq__item[open]:not(.faq__item--closing) {
  /* @media (width >= 64.0625em) .faq__item[open] */
  @media (width >= 64.0625em) {
    padding: 3.125rem 0;
  }
}

/* .faq__question — number | question | chevron */
.faq__question {
  display: grid;
  grid-template-columns: clamp(2.125rem, 0.7032rem + 6.0664vw, 6.125rem) minmax(0, 1fr) auto;
  align-items: start;
  column-gap: clamp(0.625rem, 0.4028rem + 0.9479vw, 1.25rem);
  color: var(--nv-navy);
  list-style: none;
  cursor: pointer;

  /* .faq__question::-webkit-details-marker — no native triangle in Safari */
  &::-webkit-details-marker {
    display: none;
  }

  /* .faq__question::before — "01." */
  &::before {
    content: counter(faq, decimal-leading-zero) ".";
    color: var(--nv-blue);
    font-weight: 600;
    font-size: clamp(1.4375rem, 1.2375rem + 0.8531vw, 2rem);
    line-height: 1;
    letter-spacing: -0.04em;
    transition: color 0.5s ease;
  }

  /* .faq__question-text — 24 px at 90 % on phones (Figma M), 32 px at 115 % on desktop */
  & .faq__question-text {
    font-weight: 500;
    font-size: clamp(1.5rem, 1.3223rem + 0.7583vw, 2rem);
    margin-top: -0.09em;
    margin-bottom: -0.09em;
    line-height: 0.9;
    letter-spacing: -0.04em;
    overflow-wrap: break-word;
    transition: color 0.5s ease;

    /* @media (width >= 48em) .faq__question-text — Figma D says 120 % but keeps every row 75 px,
       so two lines must fit the 75 px min-height: 115 % (two one-line questions sit at 90 %) */
    @media (width >= 48em) {
      margin-top: 0;
      margin-bottom: 0;
      line-height: 1.15;
    }
  }

  /* .faq__question:focus-visible */
  &:focus-visible {
    outline: 0.125rem solid var(--nv-blue-light);
    outline-offset: 0.25rem;
  }

  /* @media (width >= 64.0625em) .faq__question — a 75 px row (Figma Frame 1216028130), number
     and chevron centred on the question */
  @media (width >= 64.0625em) {
    align-items: center;
    min-height: 4.6875rem;

    &::before {
      text-align: center;
    }
  }
}

/* .faq__chevron — 24 px on phones, 40 px on desktop */
.faq__chevron {
  width: clamp(1.5rem, 1.1445rem + 1.5165vw, 2.5rem);
  height: auto;
  margin-top: 0.375rem;
  color: var(--nv-blue);
  opacity: 0.4;
  transition: transform 0.5s ease, color 0.5s ease, opacity 0.5s ease;

  /* @media (width >= 64.0625em) .faq__chevron */
  @media (width >= 64.0625em) {
    margin-top: 0;
  }
}

/* .faq__item[open] — blue number, question and chevron (pointing up) */
.faq__item[open]:not(.faq__item--closing) .faq__question {
  color: var(--nv-blue-light);

  &::before {
    color: var(--nv-blue-light);
  }

  /* .faq__item[open] .faq__chevron */
  & .faq__chevron {
    color: var(--nv-blue-light);
    opacity: 1;
    transform: rotate(180deg);
  }
}

/* .faq__answer — under the question column; 18 px at 120 % on phones (0.24em trims),
   20 px at 140 % on desktop (0.34em) */
.faq__answer {
  max-width: 50.4375rem;
  margin-top: clamp(1.25rem, 0.5836rem + 2.8436vw, 3.125rem);
  margin-left: calc(clamp(2.125rem, 0.7032rem + 6.0664vw, 6.125rem) + clamp(0.625rem, 0.4028rem + 0.9479vw, 1.25rem));
  color: var(--nv-navy);
  /* .rich-text paragraphs space themselves by the flow gap: 20 px from a baseline to the next cap
     (Figma M 1574:16443 / D 1574:16970, matched visually 2026-10-14) */
  --nv-flow-gap: 1.25rem;

  /* 20 px from a baseline to the next cap top (both line boxes trimmed) */
  & > * + * {
    margin-top: calc(1.25rem - 0.48em);
  }

  & > :first-child {
    margin-top: -0.24em;
  }

  & > :last-child {
    margin-bottom: -0.24em;
  }

  /* @media (width >= 48em) .faq__answer > * + * */
  @media (width >= 48em) {
    & > * + * {
      margin-top: calc(1.25rem - 0.68em);
    }

    & > :first-child {
      margin-top: -0.34em;
    }

    & > :last-child {
      margin-bottom: -0.34em;
    }
  }

  & strong,
  & b {
    font-weight: 700;
  }

  /* .faq__answer > .nv-bold-line — a bold-only paragraph (class set in inc/wysiwyg-format.php):
     100 % on phones, 140 % as the rest on desktop (Figma M 1574:16443 / D 1574:16970; Pavlo, 2026-10-14) */
  & > .nv-bold-line {
    line-height: 1;

    /* @media (width >= 48em) .faq__answer > .nv-bold-line */
    @media (width >= 48em) {
      line-height: inherit;
    }
  }
}

/* .faq--plain — no numbers 01., 02.… (FAQ library, template-parts/flexible/faq-library.php):
   the question and its answer start at the left edge of the column */
.faq--plain {
  /* .faq--plain .faq__question */
  & .faq__question {
    grid-template-columns: minmax(0, 1fr) auto;

    &::before {
      content: none;
    }
  }

  /* .faq--plain .faq__answer */
  & .faq__answer {
    margin-left: 0;
  }
}

/* @media (hover: hover) .faq__question:hover */
@media (hover: hover) and (pointer: fine) {
  .faq__item:not([open]) .faq__question:hover {
    color: var(--nv-blue-light);

    & .faq__chevron {
      opacity: 1;
    }
  }
}

/* @media (prefers-reduced-motion: reduce) .faq */
@media (prefers-reduced-motion: reduce) {
  .faq__item,
  .faq__question::before,
  .faq__question-text,
  .faq__chevron {
    transition: none;
  }
}

/* Phase 2 industry pages (Specialty Metals, Chemicals, Process, Industrial) — Figma D 510:… FAQ frames.
   Plastics (.postid-77) and the sprint 2 pages keep the rules above. */
:is(.postid-78, .postid-79, .postid-80, .postid-81) {
  /* .faq__container — desktop: the heading and the list start 20 px (not 80 px) after the 335 px aside column */
  & .faq__container {
    /* @media (width >= 64.0625em) .faq__container */
    @media (width >= 64.0625em) {
      column-gap: 1.25rem;
    }
  }

  /* .faq__question::before — phones: every number is --nv-blue-light (Figma M 26,121,191), closed ones too */
  & .faq__question::before {
    color: var(--nv-blue-light);

    /* @media (width >= 48em) .faq__question::before */
    @media (width >= 48em) {
      color: var(--nv-blue);
    }
  }
}

/* .page-id-116 .faq — About only: the 1 px hairline above the section (Figma D 18:42596 / M 18:50273 top stroke,
   #1a79bf at 10 %); no other FAQ frame has it */
.page-id-116 .faq {
  border-top: 0.0625rem solid rgba(26, 121, 191, 0.1);

  /* .page-id-116 .faq__list — no line under the last question; on phones its row has no padding below (Figma M 18:50273) */
  & .faq__list {
    border-bottom: 0;
  }

  & .faq__item:last-child {
    @media (width < 48em) {
      padding-bottom: 0;
    }
  }

  /* .page-id-116 .faq__answer — 80 % on phones (Figma M 18:50273) */
  & .faq__answer {
    @media (width < 48em) {
      opacity: 0.8;
    }
  }

  /* @media (width >= 48em) .page-id-116 .faq — the D frame ends 47 px under the list and the CTA frame adds 100 px of its own padding */
  @media (width >= 48em) {
    padding-bottom: 9.1875rem;
  }
}
