/* ============================================================
   Mobile comfort and performance layer
   Loaded last on every page. Small-screen refinements only.
   ============================================================ */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

a,
button,
[role="button"],
label,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

img,
video,
canvas,
svg,
iframe {
  max-width: 100%;
}

img,
video {
  height: auto;
}

code,
pre,
.invite-val,
.lc-card-url,
.wallet-address {
  overflow-wrap: anywhere;
}

/* Overlay panels scroll with momentum instead of jitter */
.sidebar,
.modal,
.modal-body,
.modal-overlay,
[class*="drawer"] {
  -webkit-overflow-scrolling: touch;
}

/* Anchor jumps should not hide behind the fixed top bar */
[id] {
  scroll-margin-top: 64px;
}

@media (max-width: 820px) {
  /* iOS zooms any field below 16px, which breaks the page layout */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  select,
  textarea,
  [contenteditable="true"] {
    font-size: 16px !important;
  }

  /* Comfortable thumb targets for the main actions */
  .tb-btn,
  .dl-btn,
  .btn,
  .submit-btn,
  .footer-btn,
  .buy-offer-cta,
  .pkg-cta,
  .gate-cta,
  .gate-btn,
  .auth-submit,
  .btn-primary,
  .btn-secondary,
  .action-btn {
    min-height: 44px;
  }

  .modal-close,
  .sb-close,
  .mob-menu {
    min-width: 44px;
    min-height: 44px;
  }

  /* Fixed bars respect notches and rounded corners */
  .topbar {
    padding-left: max(10px, var(--safe-left));
    padding-right: max(10px, var(--safe-right));
  }

  .sidebar {
    padding-bottom: calc(10px + var(--safe-bottom));
  }

  .main {
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(18px + var(--safe-bottom));
  }

  .main-inner {
    padding-left: max(12px, var(--safe-left));
    padding-right: max(12px, var(--safe-right));
  }

  .notif {
    top: calc(20px + var(--safe-top));
    right: calc(20px + var(--safe-right));
  }

  /* Frosted glass is expensive on mobile GPUs: drop the blur on small screens */
  .sidebar,
  .topbar,
  .modal,
  .modal-overlay,
  .notif,
  .sb-overlay,
  [class*="glass"] {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  /* Tall modal content scrolls inside the viewport instead of under it */
  .modal,
  .modal-body {
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (max-width: 480px) {
  .main-inner {
    padding: 12px max(12px, var(--safe-right)) calc(20px + var(--safe-bottom)) max(12px, var(--safe-left));
  }

  .hero {
    padding: 16px 14px;
  }

  .videos-grid {
    gap: 10px;
  }
}

/* Touch devices: keep tap feedback instant and skip sticky hover states */
@media (hover: none) {
  .video-card:hover,
  .pkg-card:hover,
  .tier-card:hover,
  .card:hover,
  .hero:hover,
  .btn:hover,
  .buy-offer-cta:hover {
    transform: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
