/* ============================================================
   mobile.css - Portside Mobile Reporter v3
   iOS / Android fixes, safe areas, touch targets, a11y
   ============================================================ */

/* --- Viewport & Safe Areas --- */

@supports (padding: env(safe-area-inset-top)) {
  .app-container {
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }

  .reports-header {
    padding-top: calc(20px + env(safe-area-inset-top));
  }

  .toast {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }
}


/* --- iOS Rubber-Band Scrolling Fix --- */

.scanner-overlay,
.modal-overlay {
  overscroll-behavior: contain;
}

.view,
.reports-overlay {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}


/* --- iOS Input Zoom Prevention --- */
/* Font size >= 16px on focus prevents Safari zoom.
   Already set in components.css, but enforce here as safety net. */

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea {
  font-size: 16px;
}


/* --- backdrop-filter Fallback --- */

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .glass,
  .glass-card,
  .header,
  .form-card,
  .violation-btn,
  .report-card,
  .stat-card,
  .modal-card,
  .toast,
  .success-card,
  .ticket-preview {
    background: rgba(18, 18, 26, 0.95);
  }

  .reports-header {
    background: rgba(10, 10, 15, 0.97);
  }
}


/* --- Touch Behavior --- */

button,
.violation-btn,
.date-filter,
.photo-btn,
.ai-btn,
.submit-btn,
.photo-remove,
.success-link,
.btn-back {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}


/* --- Prevent Text Selection on Interactive Elements --- */

.violation-btn .label,
.date-filter,
.photo-badge,
.report-status,
.stat-label {
  -webkit-user-select: none;
  user-select: none;
}


/* --- Very Small Screens (< 360px, e.g. Galaxy S7, SE 1st gen) --- */

@media screen and (max-width: 359px) {
  .app-container {
    padding: 12px;
    padding-top: calc(12px + var(--safe-top));
    padding-bottom: calc(16px + var(--safe-bottom));
  }

  .header {
    padding: 20px 16px 18px;
    border-radius: var(--radius-lg);
  }

  .header-title {
    font-size: 19px;
  }

  .btn-grid {
    gap: 8px;
  }

  .violation-btn {
    min-height: 88px;
    padding: 14px 10px;
  }

  .violation-btn .icon {
    width: 40px;
    height: 40px;
  }

  .violation-btn .label {
    font-size: 12px;
  }

  .form-card {
    padding: 18px 14px;
  }

  .submit-btn {
    padding: 16px 20px;
    font-size: 16px;
    min-height: 54px;
  }

  .stats-grid {
    gap: 8px;
    padding: 0 12px;
  }

  .stat-card .stat-value {
    font-size: 24px;
  }
}


/* --- Landscape Orientation --- */

@media screen and (orientation: landscape) and (max-height: 500px) {
  .app-container {
    max-width: 600px;
    padding-top: 12px;
  }

  .header {
    padding: 16px 20px;
    margin-bottom: 16px;
  }

  .violation-btn {
    min-height: 80px;
  }

  .scanner-frame {
    max-height: 50vh;
    aspect-ratio: auto;
  }

  .success-card {
    padding: 24px 20px;
  }

  .success-icon {
    width: 48px;
    height: 48px;
    font-size: 24px;
    margin-bottom: 12px;
  }

  .success-ticket-id {
    font-size: 22px;
  }
}


/* --- Reduced Motion (a11y) --- */

@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;
  }

  .scan-line,
  .scan-pulse,
  .scan-dot,
  .ai-btn.ready,
  .submit-btn.submitting,
  .header::before,
  .scanner-frame,
  .scan-status,
  .success-overlay.active::before,
  .success-overlay.active .success-card::before,
  .success-overlay.active .success-card::after {
    animation: none !important;
  }

  body {
    animation: none !important;
    background-size: 100% 100% !important;
  }
}


/* --- Print Styles --- */

@media print {
  .scanner-overlay,
  .modal-overlay,
  .toast,
  .reports-overlay,
  .success-overlay {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .glass-card,
  .header,
  .form-card,
  .violation-btn,
  .ticket-preview {
    background: #fff;
    border: 1px solid #ccc;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
  }
}


/* --- High Contrast Mode --- */

@media (forced-colors: active) {
  .violation-btn.selected {
    border: 2px solid Highlight;
  }

  .report-status {
    border: 1px solid currentColor;
  }

  .photo-preview.primary {
    border: 2px solid Highlight;
  }

  .submit-btn,
  .ai-btn,
  .photo-btn {
    border: 1px solid ButtonText;
  }

  .scan-line,
  .scan-corner::before,
  .scan-corner::after {
    background: Highlight;
  }
}


/* --- Samsung Internet Fixes --- */
/* Samsung Internet sometimes clips border-radius on transformed elements */

@supports (-webkit-appearance: none) and (not (overflow: overlay)) {
  .violation-btn:active,
  .submit-btn:active,
  .photo-btn:active {
    will-change: transform;
  }
}
