/* Mobile & Responsive Design Improvements */

/* Mobile First Base Styles */
:root {
  --mobile-safe-left: env(safe-area-inset-left, 0px);
  --mobile-safe-right: env(safe-area-inset-right, 0px);
}

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

body {
  overflow-x: hidden;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10000;
  padding: 10px 16px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(calc(-100% - 16px));
  transition: transform 0.15s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

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

button,
input,
select,
textarea {
  max-width: 100%;
}

.grid > *,
.grid-2 > *,
.grid-3 > *,
.grid-4 > *,
.grid-2col > *,
.grid-3col > *,
.grid-4col > * {
  min-width: 0;
}

/* Tablet (768px - 1024px) */
@media (min-width: 768px) {
  .container {
    padding: 0 24px;
  }

  .hero-section {
    padding: 64px 0;
  }

  .grid-2col {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3col {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Large Desktop (1024px+) */
@media (min-width: 1024px) {
  .container {
    padding: 0 32px;
  }

  .grid-4col {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Small Mobile (under 480px) */
@media (max-width: 480px) {
  :root {
    --font-size-2xl: 20px;
    --font-size-xl: 18px;
    --font-size-lg: 16px;
    --spacing-xl: 24px;
    --spacing-lg: 16px;
  }

  body {
    font-size: 14px;
  }

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

  .modern-header-content {
    flex-wrap: wrap;
    gap: 12px;
  }

  .modern-nav {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  .modern-nav-link {
    flex: 0 0 auto;
    padding: 8px;
    font-size: 12px;
  }

  .header-nav {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  .modern-hero {
    padding: 32px 16px;
  }

  .modern-hero-headline {
    font-size: 24px;
  }

  .modern-hero-subheadline {
    font-size: 14px;
    margin-bottom: 16px;
  }

  .modern-hero-cta {
    width: 100%;
    padding: 12px 16px;
  }

  .modern-trust-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .modern-trust-badge {
    padding: 12px;
  }

  .modern-trust-badge-icon {
    font-size: 24px;
    margin-bottom: 8px;
  }

  .modern-metrics-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .modern-metric-card {
    padding: 12px;
  }

  .modern-metric-value {
    font-size: 20px;
  }

  .modern-recommendations-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .modern-recommendation-card {
    padding: 12px;
    gap: 12px;
  }

  .modern-recommendation-action {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .modern-privacy-list {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
  }

  .modal-content {
    max-width: 100%;
    border-radius: 12px;
    max-height: 100vh;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 16px;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  button,
  .btn,
  a,
  .clickable {
    min-height: 44px;
    min-width: 44px;
  }

  input,
  textarea,
  select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Landscape Mode */
@media (orientation: landscape) and (max-height: 600px) {
  .modern-hero {
    padding: 24px 16px;
  }

  .modern-hero-headline {
    font-size: 20px;
    margin-bottom: 8px;
  }

  .modern-hero-subheadline {
    font-size: 12px;
    margin-bottom: 12px;
  }

  .modal-content {
    max-height: 90vh;
  }
}

/* Safe Area Support (notches and rounded display corners) */
@supports (padding: max(0px)) {
  .modern-header {
    padding-left: var(--mobile-safe-left);
    padding-right: var(--mobile-safe-right);
  }
}

/* High DPI / Retina */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .btn,
  .form-input,
  .card {
    border-width: 0.5px;
  }
}

/* Accessibility - Keyboard Navigation */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto !important;
  }
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #5865f2;
  outline-offset: 3px;
}

/* High Contrast Mode */
@media (prefers-contrast: more) {
  body {
    font-weight: 500;
  }

  .btn {
    border: 2px solid;
  }

  .border {
    border-width: 2px;
  }
}

/* Print Styles */
@media print {
  body {
    background: white;
    color: black;
  }

  .modern-header,
  .modern-hero,
  .modern-nav,
  button,
  .btn,
  .no-print {
    display: none !important;
  }

  .container {
    max-width: 100%;
  }

  a {
    text-decoration: underline;
    color: black;
  }

  .page-break {
    page-break-after: always;
  }
}

/* Flexbox & Grid Helpers */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-between {
  justify-content: space-between;
}

.flex-center {
  align-items: center;
  justify-content: center;
}

.gap-sm {
  gap: 8px;
}

.gap-md {
  gap: 16px;
}

.gap-lg {
  gap: 24px;
}

.grid {
  display: grid;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 767px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }

  table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Spacing Utilities */
.m-0 { margin: 0; }
.m-xs { margin: 4px; }
.m-sm { margin: 8px; }
.m-md { margin: 16px; }
.m-lg { margin: 24px; }
.m-xl { margin: 32px; }

.mt-0 { margin-top: 0; }
.mt-xs { margin-top: 4px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mt-xl { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-xs { margin-bottom: 4px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.mb-xl { margin-bottom: 32px; }

.p-0 { padding: 0; }
.p-xs { padding: 4px; }
.p-sm { padding: 8px; }
.p-md { padding: 16px; }
.p-lg { padding: 24px; }
.p-xl { padding: 32px; }

/* Text Utilities */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.text-xs { font-size: 12px; }
.text-sm { font-size: 14px; }
.text-base { font-size: 16px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-primary { color: #2c2f33; }
.text-secondary { color: #72767d; }
.text-muted { color: #99aab5; }

/* Display Utilities */
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.hidden { display: none !important; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

.w-full { width: 100%; }
.h-full { height: 100%; }

/* Opacity */
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }

/* Z-index */
.z-0 { z-index: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

/* Border Radius */
.rounded-none { border-radius: 0; }
.rounded-sm { border-radius: 4px; }
.rounded-md { border-radius: 8px; }
.rounded-lg { border-radius: 12px; }
.rounded-xl { border-radius: 16px; }
.rounded-full { border-radius: 9999px; }

/* Shadows */
.shadow-sm { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.shadow-md { box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); }
.shadow-lg { box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1); }
.shadow-xl { box-shadow: 0 20px 25px rgba(0, 0, 0, 0.1); }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-1 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.line-clamp-2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.line-clamp-3 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
