/**
 * Community Safety Lab - Mobile & Responsive Styles
 * THE VAULT Design System — Global mobile-friendly CSS
 * DO NOT modify JavaScript or functional logic
 */

/* ==========================================================================
   1. RESPONSIVE TYPOGRAPHY - Base scaling using clamp()
   ========================================================================== */

html {
  font-size: 16px;
}

/* ==========================================================================
   2. MOBILE BREAKPOINT STYLES (≤768px)
   ========================================================================== */

@media screen and (max-width: 768px) {

  /* --- Base Typography --- */
  body {
    font-size: 1rem;
    line-height: 1.7;
  }

  /* Headings - larger and clearer on mobile */
  h1 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    line-height: 1.3;
  }

  h2 {
    font-size: clamp(1.35rem, 4.5vw, 1.8rem);
    line-height: 1.3;
  }

  h3 {
    font-size: clamp(1.15rem, 4vw, 1.4rem);
    line-height: 1.4;
  }

  /* Paragraphs - increased size for readability */
  p, li {
    font-size: 1rem;
    line-height: 1.75;
  }

  /* Labels - larger for mobile forms */
  label {
    font-size: 1rem;
    line-height: 1.5;
  }

  /* --- Form Elements - Improved tap targets --- */

  /* Inputs, textareas, selects - min 44px height for touch */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="url"],
  input[type="number"],
  input[type="search"],
  input:not([type]),
  textarea,
  select {
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 14px 16px;
    min-height: 48px;
    border-radius: 10px;
    box-sizing: border-box;
  }

  /* Textarea - taller on mobile */
  textarea {
    min-height: 140px;
    line-height: 1.6;
  }

  /* File inputs */
  input[type="file"] {
    font-size: 1rem;
    padding: 12px;
    min-height: 48px;
  }

  /* Checkboxes and radio buttons - larger tap area */
  input[type="checkbox"],
  input[type="radio"] {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    margin-right: 10px;
  }

  /* --- Buttons - Easy to tap with thumbs --- */
  button,
  input[type="submit"],
  input[type="button"],
  .btn-primary,
  .btn-secondary {
    font-size: 1.05rem;
    padding: 16px 20px;
    min-height: 52px;
    border-radius: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  /* --- Layout Adjustments --- */

  /* Reduce horizontal padding on containers */
  .container,
  .box {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Cards - less padding on mobile */
  .card {
    padding: 20px;
    margin-top: 24px;
    border-radius: 12px;
  }

  /* Header - compact on mobile */
  header {
    padding: 16px;
    flex-direction: row;
    align-items: center;
  }

  header h1 {
    font-size: 1.1rem;
    margin-bottom: 2px;
  }

  header span,
  header .subtitle {
    font-size: 0.75rem;
  }

  .header-brand {
    gap: 10px;
  }

  .header-icon {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }

  /* --- Hero Section — THE VAULT Mobile --- */
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 40px 16px 32px;
    gap: 32px;
  }

  .hero-content {
    order: 1;
  }

  .hero-visual {
    order: 0;
    min-height: 180px;
  }

  .hero-badge {
    font-size: 0.7rem;
    padding: 6px 12px;
  }

  .hero h2 {
    font-size: 1.6rem;
    line-height: 1.25;
  }

  .hero h2 .secure-tag {
    font-size: 0.95rem;
    display: block;
    margin-top: 8px;
  }

  .hero-subtitle {
    font-size: 0.95rem;
    line-height: 1.7;
    margin: 16px auto 24px;
  }

  .hero-actions {
    margin: 0 auto;
    max-width: 100%;
    gap: 12px;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    justify-content: center;
  }

  /* Vault Graphic - Scaled Down */
  .vault-graphic {
    width: 160px;
    height: 160px;
  }

  .vault-inner {
    width: 100px;
    height: 100px;
  }

  .vault-lock {
    font-size: 1.8rem;
  }

  .vault-ring {
    width: 200px;
    height: 200px;
  }

  .vault-ring:nth-child(2) {
    width: 240px;
    height: 240px;
  }

  /* --- Trust signals - wrap nicely on mobile --- */
  .trust,
  .trust-signals {
    flex-direction: column;
    gap: 12px;
    font-size: 0.9rem;
    justify-content: center;
    align-items: center;
  }

  .trust-item {
    font-size: 0.85rem;
  }

  /* --- Section Grid --- */
  .section-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  /* --- Card Headers --- */
  .card-header {
    flex-direction: row;
    gap: 10px;
  }

  .card h3 {
    font-size: 1.1rem;
  }

  .card-description {
    font-size: 0.85rem;
    line-height: 1.6;
    margin: 10px 0 20px 0;
  }

  /* --- Safety Strip --- */
  .safety-strip {
    padding: 28px 16px;
    margin: 40px 0;
  }

  .safety-strip-badge {
    font-size: 0.7rem;
    padding: 8px 12px;
    margin-bottom: 16px;
  }

  .safety-strip p {
    font-size: 0.9rem;
    line-height: 1.7;
  }

  /* --- Support Section --- */
  .support-section {
    padding: 0 16px;
    margin: 32px auto;
  }

  .support-card {
    padding: 24px 20px;
  }

  .support-card h3 {
    font-size: 1rem;
  }

  .support-card p {
    font-size: 0.85rem;
  }

  .support-btn {
    padding: 12px 24px;
    font-size: 0.9rem;
    display: block;
    text-align: center;
  }

  /* --- Footer - responsive --- */
  footer,
  .csl-footer {
    padding: 32px 16px;
    font-size: 0.9rem;
    line-height: 1.8;
  }

  .footer-links {
    grid-template-columns: 1fr;
    gap: 24px;
    text-align: center;
  }

  .footer-column h4 {
    margin-bottom: 12px;
  }

  .footer-column a {
    padding: 8px 0;
    font-size: 0.9rem;
  }

  footer a,
  .csl-footer a {
    display: inline-block;
    padding: 4px 2px;
  }

  .footer-bottom {
    padding-top: 20px;
  }

  .footer-statement {
    font-size: 0.8rem;
  }

  .footer-copyright {
    font-size: 0.75rem;
  }

  .footer-translation-notice {
    font-size: 0.7rem;
    margin-top: 12px;
  }

  /* --- Tables - responsive handling --- */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  th, td {
    padding: 12px 10px;
    font-size: 0.9rem;
    min-width: 100px;
  }

  /* --- Alert rows - stack on mobile --- */
  .alert-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }

  .alert-severity {
    width: auto;
    margin-right: 0;
    margin-bottom: 8px;
  }

  /* --- Login box - full width on mobile --- */
  .login-box {
    padding: 24px 20px;
    margin: 16px;
    max-width: calc(100% - 32px);
  }

  /* --- Subscribe section --- */
  .subscribe-section {
    padding: 16px;
  }

  /* --- Result/output areas --- */
  .result,
  #lookupResult,
  #output {
    padding: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
  }

  /* --- Modal adjustments --- */
  .modal-inner {
    margin: 20px;
    padding: 20px;
    max-width: calc(100% - 40px);
  }

  /* --- Report note --- */
  .report-note,
  .form-note {
    font-size: 0.85rem;
    line-height: 1.5;
  }

  /* --- Field hints --- */
  .field-hint {
    font-size: 0.75rem;
  }

  /* --- Badge sizing --- */
  .badge {
    font-size: 0.85rem;
    padding: 6px 12px;
  }

  /* --- Error messages --- */
  .error {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  /* --- Subtitle text --- */
  .subtitle {
    font-size: 0.9rem;
    line-height: 1.6;
  }

  /* --- Empty state --- */
  .empty {
    font-size: 1rem;
    padding: 20px 0;
  }

  /* --- Privacy disclaimer --- */
  .privacy-disclaimer {
    padding: 14px;
    margin-top: 20px;
  }

  .privacy-disclaimer p {
    font-size: 0.75rem;
    line-height: 1.6;
  }

  /* --- Checkbox labels --- */
  .checkbox-label {
    gap: 10px;
  }

  .checkbox-label span {
    font-size: 0.8rem;
    line-height: 1.45;
  }
}

/* ==========================================================================
   3. SMALL MOBILE DEVICES (≤480px)
   ========================================================================== */

@media screen and (max-width: 480px) {

  /* Even more compact padding */
  .container,
  .box {
    padding-left: 12px;
    padding-right: 12px;
  }

  .card {
    padding: 16px;
    margin-top: 20px;
  }

  /* Buttons full width on small screens */
  button,
  input[type="submit"],
  input[type="button"],
  .btn-primary,
  .btn-secondary {
    width: 100%;
  }

  /* Headings */
  h1 {
    font-size: 1.4rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  h3 {
    font-size: 1.1rem;
  }

  /* Hero adjustments */
  .hero {
    padding: 32px 12px 24px;
  }

  .hero h2 {
    font-size: 1.4rem;
  }

  .hero h2 .secure-tag {
    font-size: 0.85rem;
  }

  .hero-subtitle {
    font-size: 0.9rem;
  }

  /* Vault graphic smaller */
  .vault-graphic {
    width: 140px;
    height: 140px;
  }

  .vault-inner {
    width: 85px;
    height: 85px;
  }

  .vault-lock {
    font-size: 1.5rem;
  }

  .vault-ring {
    width: 170px;
    height: 170px;
  }

  .vault-ring:nth-child(2) {
    width: 200px;
    height: 200px;
  }

  /* Safety strip compact */
  .safety-strip {
    padding: 24px 12px;
    margin: 32px 0;
  }

  .safety-strip-badge {
    font-size: 0.65rem;
    padding: 6px 10px;
  }

  .safety-strip p {
    font-size: 0.85rem;
  }

  /* Support section compact */
  .support-section {
    padding: 0 12px;
  }

  .support-card {
    padding: 20px 16px;
  }

  /* Footer compact */
  footer {
    padding: 24px 12px;
  }

  .footer-links {
    gap: 20px;
  }
}

/* ==========================================================================
   4. TOUCH DEVICE OPTIMIZATIONS
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
  /* Ensure adequate tap target sizes on touch devices */
  button,
  input[type="submit"],
  input[type="button"],
  .btn-primary,
  .btn-secondary,
  a {
    min-height: 44px;
  }

  /* Remove hover states that don't work well on touch */
  button:hover,
  input[type="submit"]:hover,
  input[type="button"]:hover,
  .btn-primary:hover,
  .btn-secondary:hover {
    transform: none;
  }

  /* Active state for touch feedback */
  button:active,
  input[type="submit"]:active,
  input[type="button"]:active,
  .btn-primary:active,
  .btn-secondary:active {
    opacity: 0.9;
    transform: scale(0.98);
  }

  /* Card tap state */
  .card:active {
    transform: scale(0.995);
  }
}

/* ==========================================================================
   5. ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

/* PayPal donation button container - responsive */
#paypal-container-UA5G4LP355AWY {
  max-width: 100%;
  margin: 12px auto 0;
  display: flex;
  justify-content: center;
}

@media screen and (max-width: 768px) {
  #paypal-container-UA5G4LP355AWY {
    max-width: 250px;
    margin: 16px auto 0;
  }
}

/* Focus states for keyboard navigation - Steel blue for THE VAULT */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible {
  outline: 2px solid #2F80ED;
  outline-offset: 2px;
}

/* Ensure checkbox/radio labels are clickable */
label {
  cursor: pointer;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .vault-ring {
    animation: none !important;
  }
}

/* ==========================================================================
   6. HIGH CONTRAST MODE SUPPORT
   ========================================================================== */

@media (prefers-contrast: high) {
  :root {
    --vault-card-border: rgba(47, 128, 237, 0.5);
    --border-subtle: rgba(255, 255, 255, 0.2);
  }

  .card {
    border-width: 2px;
  }

  button,
  .btn-primary,
  .btn-secondary {
    border: 2px solid currentColor;
  }

  input,
  textarea,
  select {
    border-width: 2px;
  }
}

/* ==========================================================================
   7. PRINT STYLES
   ========================================================================== */

@media print {
  body {
    background: white !important;
    color: black !important;
  }

  .hero-visual,
  .vault-graphic,
  .vault-ring {
    display: none !important;
  }

  header,
  footer,
  .support-section {
    background: white !important;
  }

  .card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }

  a {
    text-decoration: underline;
  }

  a::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}
