/* =========================================================
   PROMPT 4B - Home only. B1 (threads section) + B2 (FAQ). Loaded only
   on the front page.
   ========================================================= */

/* ---------------------------------------------------------
   B1 - "complexity to clarity" pinned threads section
   (Prompt 4C, C4: light bg, full-bleed canvas, stacked layout - see
   docs/4c-progress.md)
   --------------------------------------------------------- */
.dv-threads-section {
  position: relative;
  overflow: clip;
  padding-block: 0;
}
.dv-threads-section .dv-section-title { margin-bottom: 0; }

/* Full-bleed: a direct child of <section>, not nested in
   .section-container, so it spans the section edge to edge; it sits
   behind the pinned content (z-index 0 vs 1). */
.dv-threads-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.dv-threads-pin {
  position: relative;
  z-index: 1;
  overflow: hidden;
  padding-block: var(--dv-section-pad);
}
/* Prompt 4E, E10: matches isDesktopPin() in dv-4b-home.js exactly - a
   comma (OR) so a landscape phone (wide enough for 768px, far too
   short for a 100vh pin) also gets the unpinned/stacked layout. */
@media (max-width: 767px), (max-height: 559px) {
  .dv-threads-pin { height: auto; overflow: visible; }
}
.dv-threads-inner {
  position: relative;
  display: flex;
  flex-direction: column;
}
.dv-threads-head { margin-bottom: 1.5rem; }
/* Prompt 4I, I4: removed the one-off font-size override here (was
   clamp(2.25rem,4.5vw,3.75rem), one of the audit's flagged
   inconsistencies) - this heading now shares the one site-wide
   .dv-section-title size, which is smaller than this override's old
   max anyway, so the original fit concern (100vh pin) is unaffected. */

/* Prompt 4E, E2: paragraph (left) and chips (right), side by side,
   both vertically centered in the remaining space below the heading -
   replaces 4C/4D's stacked (text, then labels) column layout. */
.dv-threads-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 2rem;
}
@media (min-width: 768px) {
  .dv-threads-row {
    flex-direction: row;
    align-items: center;
    gap: clamp(2rem, 4vw, 4rem);
  }
}

/* D6: a soft light wash behind the text block - a radial fade of the
   section's own off-white, no hard box edge - so the paragraph stays
   clearly readable over the (now faded) strands at every scroll
   position. Sits above the canvas (z-index 0) and below the text. */
.dv-threads-text {
  position: relative;
  z-index: 2;
}
.dv-threads-text::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -2rem -2.5rem;
  background: radial-gradient(ellipse at 30% 30%, rgba(237, 243, 246, .85) 0%, rgba(237, 243, 246, .85) 45%, rgba(237, 243, 246, 0) 80%);
  pointer-events: none;
}

.dv-threads-text {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 48ch;
}
@media (min-width: 768px) {
  .dv-threads-text { flex: 0 0 45%; max-width: 45%; }
}
.dv-threads-line {
  font-size: clamp(1.125rem, 1.6vw, 1.5rem);
  line-height: 1.5;
  /* Prompt 4E, E2: full navy from the very first frame - no fade-in or
     line-by-line brightening (4C/4D's dim-then-brighten .is-bright
     mechanic is gone, along with the JS that drove it). */
  color: var(--navy);
}
.dv-threads-line:first-child {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.375rem, 2vw, 1.875rem);
}

/* Right column: six chips, stacked, each centered on its own band -
   the canvas measures these same rows live (dv-4b-home.js) so each
   chip sits exactly on top of its own resolved band. Centered as a
   group in the column (not bottom-anchored), consistent with the
   bands now converging on the panel's center line. */
.dv-threads-labels {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(12px, 1.6vw, 16px);
}
@media (min-width: 768px) {
  .dv-threads-labels { flex: 1 1 auto; }
}
/* Prompt 4D, D6: solid rectangular chips - the only solid elements in
   this section - lying on their own (now-faded) band, not plain text
   above it. Prompt 4E, E2: sized from the available height (48-56px)
   instead of a fixed padding figure. */
.dv-threads-label-row {
  display: flex;
  align-items: center;
  width: fit-content;
  min-height: 48px;
  max-height: 56px;
  padding: 0 20px;
  background: #10263e;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(16, 38, 62, .28);
}
.dv-threads-label-row--gold {
  border-left: 4px solid var(--dv-gold-deep);
  padding-left: 16px;
}
/* Pre-reveal (hidden/offset) state only applies when JS is actually
   present to remove it again - un-gated, a no-JS visitor would be
   stuck with opacity:0 forever (caught in verification: the earlier
   .dv-motion html.js ordering here could never match any real element,
   since <html> can never be a descendant of <body>, silently
   disabling this reveal everywhere it was used - fixed to the correct
   html.js .dv-motion order, and the hide rule itself moved behind the
   same gate so it degrades safely). Prompt 4E, E2: slides in from
   120px away now (was 40px). */
html.js .dv-motion .dv-threads-label-row {
  opacity: 0;
  transform: translateX(-120px);
}
html.js .dv-motion .dv-threads-section.is-resolved .dv-threads-label-row {
  opacity: 1;
  transform: translateX(0);
}
/* D6: the chip itself is now the only color cue (navy fill + gold left
   edge on the Data/Cybersecurity chips) - the separate small line
   swatch this replaced is no longer rendered (see dv_home_threads_section()). */
.dv-threads-label-text {
  font-size: 1.125rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

@media (max-width: 767px) {
  .dv-threads-inner { min-height: 0; }
  .dv-threads-label-row { transform: none; }
}

/* Reduced motion: no pin, text fully visible from the start, canvas
   (if JS draws it) shows one static resolved frame - no rAF loop, no
   scrub. Labels are visible immediately, not gated on JS adding
   .is-resolved. */
@media (prefers-reduced-motion: reduce) {
  .dv-threads-line { color: var(--navy); transition: none; }
  .dv-threads-label-row { opacity: 1; transform: none; transition: none; }
}

/* ---------------------------------------------------------
   B2 - FAQ (corrected by Prompt 4D, D5 - one chat bubble, not two;
   grid-stretched to match the question list exactly, no JS height
   sync - see docs/4d-progress.md)
   --------------------------------------------------------- */
.dv-faq-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 0;
}
.dv-faq-row { display: block; }
/* The <template> holding every answer's pre-rendered mask-line markup
   (see dv-4b-home.js) never renders on its own. */
.dv-faq-grid > template { display: none; }

.dv-faq-question {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  font-size: clamp(1.375rem, 2vw, 1.75rem);
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  opacity: 1;
  transition: opacity .35s var(--m-ease-out), color .35s var(--m-ease-out), background-color .35s var(--m-ease-out);
}
.dv-faq-row:first-child .dv-faq-question { border-top: none; }
html.js .dv-motion .dv-faq-question[aria-selected="false"] { opacity: .55; }
.dv-faq-question:hover,
.dv-faq-question:focus-visible { opacity: 1; }
/* Prompt 4E, E4: teal, not blue (#167b8c stays only on the Insights nav
   active row and the Business Outcomes chip) - active question
   highlighted in teal, light teal tint behind the row. */
html.js .dv-motion .dv-faq-question[aria-selected="true"] {
  color: #167B8C;
  background: rgba(22, 123, 140, .08);
}

.dv-faq-answer-mask { display: block; overflow: hidden; }
.dv-faq-answer-line { display: block; }

/* D5: exactly one bubble in the DOM - a blue chat-bubble-shaped
   panel (small tail on the left edge, pointing at the question list),
   the diagonal-line pattern reused at low opacity, white text only
   (no second/echoed question bubble). JS moves this single element
   into whichever row is active - see dv-4b-home.js. */
.dv-faq-bubble {
  position: relative;
  /* Prompt 4E, E4: dark navy, not blue. */
  background: #167B8C;
  border-radius: 24px;
  padding: 1.75rem;
  color: #fff;
  font-size: clamp(1.25rem, 1.6vw, 1.5rem);
  line-height: 1.55;
  overflow-y: auto;
}
.dv-faq-bubble::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: repeating-linear-gradient(45deg, rgba(16,38,62,.08) 0, rgba(16,38,62,.08) 1.4px, transparent 1.4px, transparent 15px);
  pointer-events: none;
}
.dv-faq-typing {
  position: relative;
  display: inline-flex;
  gap: 4px;
  padding: .2rem 0;
}
.dv-faq-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,.75);
}
html.js .dv-motion .dv-faq-typing span { animation: dv-faq-dot 1s infinite ease-in-out; }
html.js .dv-motion .dv-faq-typing span:nth-child(2) { animation-delay: .15s; }
html.js .dv-motion .dv-faq-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes dv-faq-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.dv-faq-answer-lines { position: relative; }
.dv-faq-answer-lines[hidden] { display: none; }
.dv-faq-typing[hidden] { display: none; }

@media (min-width: 900px) {
  .dv-faq-grid {
    grid-template-columns: 1fr 1fr;
    /* `grid-row: 1 / -1` on the bubble (below) only resolves to "span
       every row" once the grid has this many EXPLICIT rows - left
       purely implicit, "-1" doesn't reliably mean "the last one" and
       the bubble collapsed to a single auto-placed row sized to its
       own content instead of spanning the full list (caught in
       verification: its height stayed fixed regardless of which
       question was open). */
    grid-template-rows: repeat(var(--dv-faq-rows, 7), auto);
    column-gap: clamp(2.5rem, 5vw, 5rem);
  }
  /* D5: each row is now the grid item directly (no `display:contents`
     promotion, simpler and more robust than nesting the bubble inside
     one). The bubble is a genuine direct child too, so its
     `grid-row: 1 / -1` + the default align-items:stretch reliably
     matches the question column's height exactly, top edge to bottom
     edge, with no JS measurement needed. */
  .dv-faq-row { grid-column: 1; }
  .dv-faq-bubble {
    grid-column: 2;
    grid-row: 1 / -1;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .dv-faq-bubble::after {
    content: "";
    position: absolute;
    left: -8px;
    top: 28px;
    width: 16px;
    height: 16px;
    background: #167B8C;
    clip-path: polygon(100% 0, 100% 100%, 0 50%);
  }

  /* Vertical indicator - slides to the active question, see dv-4b-home.js.
     Prompt 4E, E4: teal, matching the active question's color. */
  .dv-faq-indicator {
    grid-column: 1;
    grid-row: 1 / -1;
    position: relative;
    width: 3px;
    background: #167B8C;
    justify-self: start;
    margin-left: -1rem;
    height: 2.5em;
    transform: translateY(0);
    transition: transform .4s var(--m-ease-out), opacity .3s var(--m-ease-out);
    opacity: 0;
  }
  html.js .dv-motion .dv-faq-indicator.is-ready { opacity: 1; }

  /* Divider lines draw in left to right when the section enters. */
  html.js .dv-motion .dv-faq-question {
    border-top-color: transparent;
    position: relative;
  }
  html.js .dv-motion .dv-faq-row:not(:first-child) .dv-faq-question::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .6s var(--m-ease-out);
  }
  html.js .dv-motion [data-dv-faq].is-revealed .dv-faq-row .dv-faq-question::before {
    transform: scaleX(1);
  }
}
@media (max-width: 899px) {
  .dv-faq-bubble::after { display: none; }
}

/* Reduced motion / no-JS: everything visible, selection still works
   (tab/accordion logic itself isn't "motion"), just no sliding/masking,
   no typing dots. */
@media (prefers-reduced-motion: reduce) {
  .dv-faq-question,
  .dv-faq-indicator,
  html.js .dv-motion .dv-faq-row:not(:first-child) .dv-faq-question::before {
    transition: none;
  }
  html.js .dv-motion .dv-faq-question[aria-selected="false"] { opacity: .55; }
  html.js .dv-motion .dv-faq-row:not(:first-child) .dv-faq-question::before { transform: scaleX(1); }
  .dv-faq-typing span { animation: none !important; opacity: .35; }
}
