/* Mobile layout + accessibility polish — loaded last so it can refine the earlier theme files. */

/* ---------- Accessibility ---------- */

/* A ring that stays visible on both light and dark surfaces and on filled buttons. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline-offset: 0;
}

/* The off-screen phone drawer must not be reachable with Tab while it is closed. */
@media (max-width: 900px) {
  .sidebar:not(.open) {
    visibility: hidden;
    transition: transform var(--transition), visibility 0s linear var(--transition);
  }
  .sidebar.open {
    visibility: visible;
    transition: transform var(--transition), visibility 0s;
  }
}

/* Footer links were ~13px tall; give them a real hit area without changing the look. */
.footer-note a {
  display: inline-block;
  padding: 8px 2px;
  margin: -8px 0;
}

/* ---------- Phone layout ---------- */
@media (max-width: 680px) {
  /* Top bar: title gets the room, the account pill collapses to its avatar. */
  .topbar {
    gap: 8px;
    padding: 8px 12px;
  }
  .page-title-wrap {
    flex: 1 1 auto;
    min-width: 0;
  }
  .page-title {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-actions {
    flex: 0 0 auto;
    gap: 6px;
  }
  .topbar-actions .user-name {
    display: none;
  }
  .topbar-actions .user-badge {
    padding: 3px;
    gap: 2px;
  }
  #resetDataBtn {
    padding-inline: 10px;
    font-size: 12.5px;
  }

  /* Touch targets: at least 44px on anything you tap. */
  .menu-toggle {
    width: 44px;
    height: 44px;
  }
  .btn,
  .theme-toggle,
  .yt-cat,
  .user-logout,
  .yt-check-btn,
  .nav-link {
    min-height: 44px;
  }
  .user-logout {
    min-width: 40px;
  }
  .yt-check-btn {
    min-width: 44px;
  }
  .btn-sm {
    min-height: 40px;
  }
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-height: 44px;
    font-size: 16px; /* stops iOS Safari zooming the page when a field is focused */
  }
  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
    margin: 0 6px 0 0;
  }
  label:has(> input[type="checkbox"]),
  label:has(> input[type="radio"]) {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  /* Button groups and chip rows wrap instead of running off the screen. */
  [role="group"],
  .tag-row {
    flex-wrap: wrap;
  }
  [role="group"] > .btn {
    flex: 1 1 auto;
  }
  .tag-row .chip {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Toasts sit above the chat button instead of covering it. */
  .toast-container {
    bottom: 84px;
    left: 12px;
    right: 12px;
  }
}

/* Honour the OS "reduce motion" setting everywhere, not just on the animated pages. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
