/* Shared phone and touch reliability layer. Loaded after page-specific styles. */
:root { --mobile-safe-bottom: env(safe-area-inset-bottom, 0px); }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-width: 0; overflow-x: hidden; }
main, header, footer, section, article, aside, nav, div { min-width: 0; }
img, video, canvas, svg, iframe { max-width: 100%; }
input, select, textarea, button { max-width: 100%; }
textarea { resize: vertical; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, a { min-height: 44px; }
input, select, textarea { font-size: max(16px, 1em); }

:focus-visible {
  outline: 3px solid #a78bfa !important;
  outline-offset: 3px;
}

@media (hover: none), (pointer: coarse) {
  body, a, button, input, select, textarea, .nav-item, .btn-primary, .btn-ghost { cursor: auto !important; }
  #cursor-dot, #cursor-ring, #cursor-glow { display: none !important; }
}

@media (max-width: 768px) {
  body { padding-bottom: var(--mobile-safe-bottom); }
  /* Homepage header: keep the brand and account controls on one aligned row. */
  nav .home-header {
    height: 64px;
    min-height: 64px;
    padding: .5rem 1rem;
    display: flex !important;
    align-items: center;
    gap: .5rem;
  }
  nav .home-header-left { width: auto; flex: 1 1 auto; justify-content: flex-start; gap: .5rem; }
  nav .home-header-left > a { font-size: 1.1rem; }
  nav .home-header-left > a span { display: none; }
  nav .home-nav-links { display: flex !important; align-items: center; gap: .75rem; }
  nav .home-nav-links > a { min-height: 38px; font-size: .8rem; white-space: nowrap; }
  nav .home-nav-desktop-only { display: none !important; }
  nav .home-nav-auth { flex: 0 0 auto; gap: .25rem; justify-self: auto; }
  nav #home-login { min-height: 38px; padding: .5rem; font-size: .75rem; }
  nav #home-signup { min-height: 38px; padding: .6rem .75rem; font-size: .75rem; }
  .fixed, [style*="position: fixed"] { max-width: 100vw; }
  table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  pre, code { overflow-wrap: anywhere; white-space: pre-wrap; }

  /* Shared floating navigation becomes a bottom navigation without covering content. */
  body.has-sidebar main, body.has-sidebar .page-content { padding-bottom: calc(88px + var(--mobile-safe-bottom)); }
  #sidebar { padding-bottom: var(--mobile-safe-bottom); }

  /* Sidebar-based Tailwind pages (admin, profile and search). */
  aside.fixed.left-0, .sidebar.fixed { transform: translateX(-100%); }
  header.fixed.top-0.right-0 { left: 0; right: 0; width: 100% !important; padding-left: 1rem !important; padding-right: 1rem !important; }
  main.ml-64, .ml-64 { margin-left: 0 !important; }

  .nav-inner { padding-left: 1rem; padding-right: 1rem; }
  .nav-auth { gap: .35rem; }
  .nav-link, .btn-ghost, .btn-primary { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
}

/* Consistent navigation and clear feedback on pages without the app sidebar. */
.ariexo-mobile-nav, #ariexo-status-toast { display: none; }
.ariexo-media-holder { position: relative; }
.ariexo-media-retry {
  position: absolute; inset: auto 1rem 1rem 1rem; z-index: 2;
  border: 1px solid rgba(255,255,255,.22); border-radius: .75rem;
  background: rgba(15, 23, 42, .94); color: #fff; padding: .75rem 1rem;
  box-shadow: 0 12px 28px rgba(0,0,0,.35);
}

@media (max-width: 768px) {
  body.has-ariexo-mobile-nav { padding-bottom: calc(82px + var(--mobile-safe-bottom)); }
  .ariexo-mobile-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 999;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch;
    min-height: calc(68px + var(--mobile-safe-bottom)); padding: 7px 6px calc(7px + var(--mobile-safe-bottom));
    background: rgba(11, 11, 16, .96); border-top: 1px solid rgba(255,255,255,.12);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  }
  .ariexo-mobile-nav a { display: grid; place-items: center; gap: 2px; min-height: 54px; color: #a1a1b4; font: 600 10px/1 Inter, sans-serif; }
  .ariexo-mobile-nav a > span:first-child { font-size: 20px; line-height: 1; }
  .ariexo-mobile-nav a.active { color: #c4b5fd; }
  #ariexo-status-toast {
    position: fixed; left: 1rem; right: 1rem; bottom: calc(84px + var(--mobile-safe-bottom)); z-index: 1100;
    display: block; padding: .85rem 1rem; border: 1px solid rgba(255,255,255,.15); border-radius: .8rem;
    background: rgba(15,23,42,.97); color: #f8fafc; box-shadow: 0 14px 36px rgba(0,0,0,.38); font-size: .9rem;
  }
  #ariexo-status-toast[data-kind="error"] { border-color: rgba(248,113,113,.55); }
  #ariexo-status-toast[data-kind="success"] { border-color: rgba(74,222,128,.55); }
  #ariexo-status-toast[hidden] { display: none; }
}

@media (max-width: 480px) {
  body { overflow-wrap: break-word; }
  .nav-inner { gap: .5rem; }
  .nav-brand-fallback, .nav-brand-text { font-size: 1.2rem; }
  .nav-logo-img { max-width: 124px; }
  .hero-section, .content-section, .site-footer { padding-left: 1rem; padding-right: 1rem; }
  .hero-ctas > *, .hero-ctas a, .hero-ctas button { width: 100%; }
  .footer-links { gap: .75rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
