/* Responsive tabs -> accordion (see js/responsive-tabs.js).
   Loaded last so it can override enhanced-tabs.css, which forces the strip to
   flex/nowrap with !important on nearly every declaration.

   Desktop (>=768px): unchanged tab strip.
   Mobile (<768px): strip hidden, panels become stacked collapsible sections so
   all 3-5 category names are visible without sideways scrolling. */

/* Accordion headers only exist in accordion mode. */
.rt-acc-header {
  display: none;
}

/* ============================ MOBILE ================================== */
@media (max-width: 767px) {

  /* Hide the tab strip and its separator — the accordion headers replace it. */
  .rt-accordion .about-tabs-container,
  .rt-accordion .tab-separator {
    display: none !important;
  }

  /* All panels present in the flow; the header stays visible, the body is
     what collapses. The page's own JS uses .active to show one panel, so we
     have to un-hide the others here. */
  /* position:static is the critical one. Something injects
     `.tab-content { position: absolute }` at runtime to stack the panels for
     the desktop crossfade, which made all the collapsed panels pile up at the
     same coordinates (measured: 5 headers, 2 distinct positions). */
  .rt-accordion .tab-content,
  .rt-accordion .tab-content:not(.active),
  .rt-accordion .about-content .tab-content {
    position: static !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    pointer-events: auto !important;
  }

  /* Flex column so the `order` set in JS takes effect — panels aren't always
     authored in tab order (projects.html has fire-rebuilds last in the DOM). */
  .rt-accordion .rt-panels {
    display: flex !important;
    flex-direction: column !important;
  }

  .rt-accordion .rt-panel {
    border-bottom: 1px solid rgba(28, 63, 96, 0.14);
    /* Cancel any per-page panel padding so the header spans edge to edge. */
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  /* :first-of-type follows source order, not flex order, so the top border
     goes on whichever panel we placed first. */
  .rt-accordion .rt-panel[style*="order: 0"] {
    border-top: 1px solid rgba(28, 63, 96, 0.14);
  }

  /* ---- header (the control) ------------------------------------------- */
  .rt-accordion .rt-acc-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    /* 56px tap target */
    min-height: 56px;
    padding: 16px 18px;
    margin: 0;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary-color, #1c3f60);
    -webkit-tap-highlight-color: transparent;
  }

  .rt-accordion .rt-acc-header:focus-visible {
    outline: 2px solid var(--primary-color, #1c3f60);
    outline-offset: -3px;
  }

  .rt-accordion .rt-acc-label {
    flex: 1 1 auto;
    line-height: 1.3;
  }

  /* +/- built from two bars so there's no icon-font dependency. */
  .rt-accordion .rt-acc-icon {
    position: relative;
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
  }

  .rt-accordion .rt-acc-icon::before,
  .rt-accordion .rt-acc-icon::after {
    content: '';
    position: absolute;
    background: currentColor;
    transition: transform 0.25s ease, opacity 0.25s ease;
  }

  /* horizontal bar */
  .rt-accordion .rt-acc-icon::before {
    top: 6px;
    left: 0;
    width: 14px;
    height: 2px;
  }

  /* vertical bar — rotates away when open, turning + into - */
  .rt-accordion .rt-acc-icon::after {
    top: 0;
    left: 6px;
    width: 2px;
    height: 14px;
  }

  .rt-accordion .rt-panel.rt-open .rt-acc-icon::after {
    transform: rotate(90deg);
    opacity: 0;
  }

  /* Open section reads as active */
  .rt-accordion .rt-panel.rt-open > .rt-acc-header {
    color: var(--primary-color, #1c3f60);
    background: rgba(28, 63, 96, 0.04);
  }

  /* ---- body (the disclosure) ------------------------------------------
     Everything in the panel except the header. Collapsed by default; the
     .rt-open panel shows its content. */
  .rt-accordion .rt-panel > *:not(.rt-acc-header) {
    display: none !important;
  }

  .rt-accordion .rt-panel.rt-open > *:not(.rt-acc-header) {
    display: revert !important;
  }

  /* All-collapsed is the mobile default. A tab still carries .active (the
     desktop model needs it), so suppress its body explicitly here. */
  .rt-accordion.rt-all-closed .rt-panel > *:not(.rt-acc-header) {
    display: none !important;
  }

  .rt-accordion.rt-all-closed .rt-panel {
    padding-bottom: 0 !important;
  }

  /* Give the open body a little breathing room from the next header. */
  .rt-accordion .rt-panel.rt-open {
    padding-bottom: 22px !important;
  }

  /* Headers span edge to edge (so the dividers read as full-width rules), but
     the disclosed content needs its own gutter back. */
  .rt-accordion .about-content > .container {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .rt-accordion .rt-panel.rt-open > *:not(.rt-acc-header) {
    padding-left: 18px;
    padding-right: 18px;
    box-sizing: border-box;
  }

  /* Full-bleed children opt out — otherwise banded sections inherit a gutter
     and stop reaching the screen edge. */
  .rt-accordion .rt-panel.rt-open > .process-accordion-section,
  .rt-accordion .rt-panel.rt-open > .wide-section-container,
  .rt-accordion .rt-panel.rt-open > .container {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .rt-accordion .about-section {
    padding-top: 0 !important;
  }
}
