/* ============================================
   CVI – Mobile enhancements (desktop untouched)
   All rules scoped to max-width breakpoints only
   ============================================ */

/* Prevent horizontal scroll on small screens */
@media (max-width: 980px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* Larger touch targets for menu */
  .nav-toggle {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
  }

  .nav-mobile a {
    padding: 0.95rem 1.1rem;
    min-height: 48px;
    display: flex;
    align-items: center;
    font-size: 1.08rem;
  }

  .nav-mobile .mobile-dropdown a {
    min-height: 44px;
    padding: 0.7rem 1.1rem;
  }

  /* Cards more comfortable */
  .next-regata-card {
    padding: 1.25rem 1.15rem;
  }

  .gara-card,
  .team-card,
  .content-box {
    padding: 1.25rem 1.1rem;
  }

  /* Ranking / lists */
  #home-ranking li,
  .rank-list li {
    padding: 0.75rem 0.5rem;
    gap: 0.6rem;
  }

  /* FAB Discord: non coprire contenuto */
  #cvi-discord-fab {
    bottom: max(1rem, env(safe-area-inset-bottom)) !important;
    right: max(1rem, env(safe-area-inset-right)) !important;
    width: 48px !important;
    height: 48px !important;
  }

  .page-content,
  .site-footer {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 600px) {
  /* Safe area for notched phones */
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  header {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .page-content {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  /* Typography */
  .hero-section h1 {
    font-size: clamp(1.75rem, 8vw, 2.15rem);
    line-height: 1.2;
  }

  .page-hero h1 {
    font-size: clamp(1.6rem, 7vw, 2rem);
  }

  /* Full-width primary actions */
  .btn-primary,
  .btn-secondary,
  .btn-segui-live,
  .btn-live-gara,
  .btn-iscriviti,
  .btn-disiscriviti {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 1rem;
    box-sizing: border-box;
  }

  .hero-actions {
    width: 100%;
  }

  .hero-actions .btn-primary,
  .hero-actions .btn-secondary {
    width: 100%;
  }

  /* Live badge more visible */
  .badge-live {
    font-size: 0.78rem !important;
    padding: 0.28rem 0.7rem !important;
  }

  .btn-segui-live {
    margin-top: 1rem !important;
    width: 100%;
    text-align: center;
  }

  /* Gare cards stack actions */
  .gara-actions {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100%;
  }

  .gara-actions > * {
    width: 100%;
  }

  .gara-card-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }

  .gara-card-badges {
    flex-wrap: wrap;
  }

  /* Tables: horizontal scroll instead of squashing */
  .results-table,
  .members-table,
  table.rank-table,
  .table-wrap {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .results-table table,
  .members-table table {
    min-width: 480px;
  }

  /* Forms – 16px avoids iOS zoom on focus */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="datetime-local"],
  select,
  textarea {
    font-size: 16px !important;
    min-height: 44px;
  }

  button,
  .btn,
  [type="submit"] {
    min-height: 44px;
  }

  /* Bacheca / avvisi */
  .bacheca-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .avviso-item {
    padding: 0.85rem 1rem;
  }

  /* Stats */
  .stats-row,
  .stat-grid {
    gap: 0.75rem;
  }

  .stat-number {
    font-size: 1.5rem;
  }

  /* Footer */
  .footer-links {
    flex-direction: column;
    gap: 1.5rem;
  }

  .footer-col a {
    padding: 0.4rem 0;
    min-height: 40px;
  }

  /* Live page */
  .live-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Admin cards */
  .admin-card-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .admin-card-actions button {
    flex: 1 1 auto;
    min-height: 44px;
  }

  .content-box {
    padding: 1.15rem 1rem;
  }
}

/* Extra small phones */
@media (max-width: 380px) {
  .hero-section h1 {
    font-size: 1.55rem;
  }

  .logo-text {
    font-size: 0.95rem;
  }

  .page-content {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
}
