/* ============================================================
   STICKY NAVBAR — TABLET + MOBILE STYLES
   Owns all viewports ≤1024px.

   - Hides desktop chrome (ticker, CTAs, message, mega menu)
   - Renders the Miller column pattern (col1: top-level, col2: sub-links)
   - JS counterpart: js/navbar.miller.js builds col1/col2 DOM, renders
     the optional search input + featured card, and toggles the
     .miller-item-active / .miller-active classes.
   - --miller-list-top is set by JS from the wrapper height.
   ============================================================ */

@media (max-width: 1024px) {

  /* ── Hide desktop chrome (Phase 2.2: ticker added) ── */

  .sticky-navbar__ticker,
  .sticky-navbar__cta,
  .sticky-navbar__message,
  .sticky-navbar__megamenu {
    display: none;
  }

  .region.region-header {
    display: none;
  }


  /* ── Navbar bar layout ── */

  .sticky-navbar__inner {
    justify-content: space-between;
    padding: 0 4px;
  }

  .sticky-navbar__brand {
    padding: 12px 16px;
    width: auto;
  }

  .sticky-navbar__brand-logo {
    max-height: 56px;
    width: auto;
  }

  .sticky-navbar__toggle {
    display: flex;
    margin-left: auto;
    order: 2;
    padding: 12px 16px;
  }


  /* ── Miller list: asymmetric 2-column grid (Phase 2.1) ──
     col1 narrow + fixed (top-level labels are short),
     col2 fluid (sub-links need horizontal room for text + tag + desc). */

  .sticky-navbar__list,
  .sticky-navbar__list.sticky-navbar__list--open {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0;
    padding: 0;
    position: absolute;
    top: var(--miller-list-top, 97px);
    left: 0;
    right: 0;
    background: #fff;
    box-shadow: 0 4px 12px rgba(25, 44, 41, 0.12);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    height: auto;
  }

  .sticky-navbar__list.sticky-navbar__list--open {
    max-height: 80vh;
    overflow: visible;
  }


  /* ── Column 1: top-level links ── */

  .sticky-navbar__miller-col1 {
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(74, 107, 104, 0.15);
    background: #ffffff;
  }

  .sticky-navbar__list > li {
    height: auto;
    display: block;
    position: static;
    background: transparent;
  }

  /* Phase 2.4: larger padding for ≥44px touch target.
     Issue 2 (final fix): the link is a plain block (not flex). The chevron
     is absolutely positioned at the right edge, so a wrapping label can
     never push the chevron onto its own line. Right padding reserves room
     for the chevron so it never overlaps the text. */
  .sticky-navbar__list > li > a:link,
  .sticky-navbar__list > li > a:visited {
    display: block;
    position: relative;
    padding: 18px 36px 18px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--cf-dark, #192c29);
    text-decoration: none;
    border-bottom: 1px solid rgba(74, 107, 104, 0.1);
    border-radius: 0;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
  }

  /* Active state: left accent bar */
  .sticky-navbar__list > li.miller-item-active > a:link,
  .sticky-navbar__list > li.miller-item-active > a:visited {
    background: rgba(74, 107, 104, 0.09);
    color: var(--cf-leaf, #4a6b68);
    border-left: 3px solid var(--cf-leaf, #4a6b68);
    padding-left: 11px;
    font-weight: 600;
  }

  /* Chevron on expandable items — absolutely positioned at the right edge,
     vertically centered. Label text wraps within the link's right-padding
     and never collides with the chevron. */
  .sticky-navbar__item--has-mega > a::after {
    content: "›";
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4em;
    font-weight: 200;
    opacity: 0.35;
    line-height: 1;
    pointer-events: none;
    transition: opacity 0.2s;
  }

  .sticky-navbar__item--has-mega.miller-item-active > a::after {
    opacity: 0.9;
    color: var(--cf-leaf, #4a6b68);
  }


  /* ── Column 2: sub-link panels ── */

  .sticky-navbar__miller-col2 {
    display: flex;
    flex-direction: column;
    background: #f7f8f7;
    overflow-y: auto;
    min-height: 200px;
  }

  /* Issue 1: empty-state element (rendered by Miller JS, text comes from
     drupalSettings.stickyNavbar.emptyStateTagline so admins can edit it).
     Two flavors:
       --col2  : sits at the bottom of col2, hidden when any panel is active
       --panel : injected inside an empty panel as fallback content */
  .miller-empty-state {
    display: block;
    font-size: 1.15rem;
    font-weight: 500;
    font-style: italic;
    color: rgba(74, 107, 104, 0.55);
    padding: 40px 24px;
    text-align: center;
    letter-spacing: -0.01em;
    line-height: 1.3;
  }

  .sticky-navbar__miller-col2:has(.miller-active) .miller-empty-state--col2 {
    display: none;
  }

  .sticky-navbar__miller-col2-inner {
    display: none;
    flex-direction: column;
  }

  .sticky-navbar__miller-col2-inner.miller-active {
    display: flex;
  }

  /* Back button */
  .sticky-navbar__miller-col2-back {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--cf-mid, #5a6b66);
    padding: 14px 16px;
    cursor: pointer;
    background: none;
    border: none;
    border-bottom: 1px solid rgba(74, 107, 104, 0.15);
  }


  /* ── Section groups in col2 panels ── */

  .miller-section-group {
    background: transparent;
  }

  .miller-section-group + .miller-section-group {
    border-top: 1px solid rgba(74, 107, 104, 0.1);
  }

  /* Phase 2.6: accent treatment for groups built from card-type cols
     (i.e. mega-cols with backgroundColor set in JSON). */
  .miller-section-group--accent {
    background: rgba(74, 107, 104, 0.04);
    border-left: 3px solid rgba(74, 107, 104, 0.5);
  }

  /* Context header (section title + description from a description-type col) */
  .miller-color-header {
    padding: 12px 16px 8px;
  }

  .miller-color-header__title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--cf-leaf, #4a6b68);
  }

  /* Section description (paragraph from a description-type mega-col).
     Explicitly resets text-transform and letter-spacing so it doesn't
     inherit the uppercase/wide tracking from any parent / sibling rule. */
  .miller-color-header__desc {
    display: block;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--cf-mid, #69758c);
    line-height: 1.4;
    margin-top: 4px;
    text-transform: none;
    letter-spacing: normal;
  }

  /* Section headings (link group labels) */
  .miller-section-heading {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--cf-leaf, #4a6b68);
    padding: 12px 16px 4px;
    opacity: 0.8;
    background: transparent;
  }


  /* ── Sub-links (Phase 2.4 + 2.5: bigger touch targets, descriptions) ── */

  .miller-sublink:link,
  .miller-sublink:visited {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    font-size: 0.9375rem;
    font-weight: 400;
    line-height: 1.3;
    color: var(--cf-dark, #192c29);
    text-decoration: none;
    border-bottom: 1px solid rgba(74, 107, 104, 0.07);
    background: transparent;
  }

  .miller-sublink:hover,
  .miller-sublink:active {
    background: rgba(0, 0, 0, 0.04);
    color: var(--cf-leaf, #4a6b68);
  }

  /* Top row: link text + optional tag inline */
  .miller-sublink__row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .miller-sublink__text {
    font-weight: 500;
  }

  /* Phase 2.5: link description — visible on mobile. */
  .miller-sublink__desc {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--cf-mid, #69758c);
    line-height: 1.4;
  }

  /* Tag inside sublink — uses the modifier classes from the desktop styles. */
  .miller-sublink .sticky-navbar__link-tag {
    margin-left: 0;
  }


  /* ── Phase 2.6: featured card pinned to bottom of panel ── */

  .miller-section-group--featured {
    margin-top: auto;            /* push to bottom of flex column */
    background: rgba(126, 230, 161, 0.06);
    border-top: 2px solid rgba(74, 107, 104, 0.2);
    padding-bottom: 12px;
  }

  .miller-featured-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    margin: 8px 12px;
    text-decoration: none;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    color: inherit;
  }

  .miller-featured-card:hover,
  .miller-featured-card:active {
    background: #fafafa;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  }

  .miller-featured-card__img {
    width: 100%;
    max-height: 120px;
    object-fit: cover;
    border-radius: 4px;
  }

  .miller-featured-card__label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cf-leaf, #4a6b68);
  }

  .miller-featured-card__title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--cf-dark, #192c29);
    line-height: 1.3;
  }


  /* ── Phase 2.10: search input (only rendered if Drupal `search` is enabled) ── */

  .miller-search {
    padding: 12px 12px 10px;
    border-bottom: 1px solid rgba(74, 107, 104, 0.12);
    background: #fff;
    margin: 0;
  }

  .miller-search__input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    font-size: 0.875rem;
    border: 1px solid rgba(74, 107, 104, 0.2);
    border-radius: 4px;
    background: #fff;
    color: var(--cf-dark, #192c29);
    -webkit-appearance: none;
    appearance: none;
  }

  .miller-search__input:focus {
    outline: 2px solid var(--cf-leaf, #4a6b68);
    outline-offset: 1px;
    border-color: var(--cf-leaf, #4a6b68);
  }

  .miller-search__input::placeholder {
    color: rgba(74, 107, 104, 0.5);
  }

}
