/**
 * Stage T3b — Header shell touch targets.
 * Overrides compact mobile sizes from style.css without editing style.css.
 */

.app-header .back-btn,
.app-header .info-btn {
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  flex: 0 0 44px;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.app-header .back-btn {
  margin-right: 0.25rem;
}

.app-header .back-btn svg,
.app-header .info-btn svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  pointer-events: none;
}

.app-header .back-btn:focus,
.app-header .info-btn:focus {
  outline: none;
}

.app-header .back-btn:focus-visible,
.app-header .info-btn:focus-visible {
  outline: 2px solid var(--teal, var(--color-primary));
  outline-offset: 2px;
}

.app-header .header-right-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  max-width: min(55vw, 16rem);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-right: 0.15rem;
  flex: 0 1 auto;
  min-width: 0;
}

.app-header .header-right-actions::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

@media (max-width: 480px) {
  .app-header {
    justify-content: flex-start;
    gap: 0 !important;
  }

  .app-header .back-btn,
  .app-header .info-btn,
  .app-header .header-right-actions .info-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    min-height: 44px;
    flex: 0 0 44px !important;
    margin: 0 !important;
  }

  .app-header .back-btn svg,
  .app-header .info-btn svg,
  .app-header .header-right-actions .info-btn svg {
    width: 20px !important;
    height: 20px !important;
  }

  .app-header .back-btn.hidden {
    display: none !important;
    visibility: hidden !important;
  }

  .app-header .back-btn:not(.hidden) + .header-title-container {
    display: none !important;
  }

  .app-header .header-title-container {
    flex: 0 0 auto !important;
    width: auto;
    max-width: none;
    min-width: 0;
    padding-left: 0 !important;
  }

  .app-header .app-title {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    width: auto;
  }

  .app-header .header-right-actions {
    gap: 0 !important;
    max-width: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin-left: auto;
    flex: 0 0 auto !important;
    min-width: 0;
  }
}

@media (max-width: 360px) {
  .app-header .header-title-container {
    width: 34px;
    flex-basis: 34px !important;
  }

  .app-header .app-title {
    width: 34px;
    justify-content: center;
    font-size: 0 !important;
    line-height: 1;
  }

  .app-header .app-title::before {
    content: "S+";
    color: var(--color-primary);
    font-size: 1rem;
    font-weight: 800;
  }
}

@media (min-width: 481px) {
  .app-header .header-right-actions {
    max-width: none;
    overflow: visible;
  }
}

/**
 * Stage U1a — Closed-overlay focus containment.
 *
 * The eight shared `.modal-overlay` dialogs close with `opacity:0` and
 * `pointer-events:none` only. Pointer-events stops the mouse; it never stops
 * the Tab key. Without `visibility:hidden` their controls stay rendered and
 * tabbable while fully invisible, so keyboard focus leaks into dialogs the
 * user cannot see (27 reachable controls across the 8 overlays).
 *
 * `visibility` is a discrete property, so transitioning it with a delay equal
 * to the existing 0.3s opacity fade (style.css) keeps the fade-out intact:
 * the overlay stays visible for the whole fade, then flips to hidden — at
 * which point it leaves the accessibility tree and the tab order.
 *
 * The open state deliberately declares NO transition. A transition on the base
 * rule — even a zero-duration one — defers the value commit to the next style
 * flush, and the dialogs focus their close button synchronously right after
 * dropping `.hidden-modal`; the element would still compute as hidden at that
 * instant and `.focus()` would be a silent no-op (caught by Zone 23). Leaving
 * the base rule untransitioned makes opening flip visibility immediately.
 * The opacity fade itself stays owned by style.css and is not restated here.
 */
.modal-overlay {
  visibility: visible;
}

.modal-overlay.hidden-modal {
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0s linear 0.3s;
}

/*
 * Scoped to the close buttons, which are the elements these dialogs focus
 * immediately after opening.
 *
 * Descendants inherit the overlay's `visibility`. `.close-btn` animates with
 * `transition: var(--transition)` — i.e. `all 0.3s` — and `all` covers
 * `visibility`; a discrete property flips at 50% of its duration, so the button
 * still computes as `hidden` for ~150ms after the dialog opens, exactly when
 * focus is handed to it. Naming the properties it animates drops `visibility`
 * from its transition list, making the inherited flip instant in both
 * directions. This rule targets `.close-btn` only; other controls inside the
 * overlays are left as they are.
 */
.modal-overlay .close-btn {
  transition-property:
    background-color, border-color, color, box-shadow, opacity, transform;
}
