/* Mobile-first responsive design enhancements */

/* Fix for mobile scrolling issues */
html, body {
  -webkit-overflow-scrolling: touch;
  overflow-x: hidden;
  position: relative;
  height: auto;
  min-height: 100%;
}

/* Prevent any element from overflowing horizontally */
* {
  max-width: 100%;
}

/* Ensure all containers can scroll properly on mobile */
.main-container,
.content-wrapper,
#content,
#sidebar {
  -webkit-overflow-scrolling: touch;
  overflow: visible;
  width: 100%;
  max-width: 100%;
}

/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {
  .header-container {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .nav {
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 0.95rem;
  }

  .main-container {
    padding: 0 1rem;
  }

  .card {
    padding: 1.5rem;
  }

  #signup_form {
    padding: 1.5rem;
  }

  #signup_form form input[type="submit"] {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
  }

  .footer-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {
  .hero h1 {
    font-size: 2.25rem;
  }

  .hero p {
    font-size: 1.1rem;
  }
}

/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {
  .header-container {
    padding: 1rem 2rem;
  }

  .main-container {
    padding: 0 2rem;
  }

  .content-wrapper {
    gap: 2rem;
  }

  #signup_form {
    padding: 2rem;
  }
}

/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {
  .content-wrapper {
    grid-template-columns: 2fr 1fr;
  }

  .hero h1 {
    font-size: 3rem;
  }

  .hero p {
    font-size: 1.25rem;
  }

  .card {
    padding: 2.5rem;
  }
}

/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {
  .main-container {
    max-width: 1400px;
  }

  .header-container {
    max-width: 1400px;
  }

  .footer-container {
    max-width: 1400px;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Increase tap targets for touch */
  #signup_form form input[type="text"],
  #signup_form form input[type="email"],
  #signup_form form input[type="tel"],
  #signup_form form select,
  #signup_form form textarea {
    padding: 1rem;
  }

  #signup_form form input[type="submit"] {
    padding: 1rem 2rem;
    min-height: 48px;
  }

  .nav a {
    padding: 0.5rem;
  }

  /* Remove hover effects on touch devices */
  .post:hover,
  #sidebar li:hover,
  .card:hover {
    transform: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --text-primary: #000000;
    --text-secondary: #333333;
  }

  #signup_form form input[type="text"],
  #signup_form form input[type="email"],
  #signup_form form input[type="tel"],
  #signup_form form select,
  #signup_form form textarea {
    border-width: 3px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
  }

  body {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  }

  .header {
    background: rgba(30, 41, 59, 0.95);
    border-bottom-color: var(--border-color);
  }

  .logo {
    color: #60a5fa;
  }

  .nav a {
    color: var(--text-secondary);
  }

  .nav a:hover {
    color: #60a5fa;
  }

  .card,
  .post,
  #sidebar li {
    background: var(--surface-color);
  }

  #signup_form form input[type="text"],
  #signup_form form input[type="email"],
  #signup_form form input[type="tel"],
  #signup_form form select,
  #signup_form form textarea {
    background-color: #0f172a;
    color: var(--text-primary);
    border-color: var(--border-color);
  }

  #signup_form form input[type="text"]:focus,
  #signup_form form input[type="email"]:focus,
  #signup_form form input[type="tel"]:focus,
  #signup_form form select:focus,
  #signup_form form textarea:focus {
    background-color: #1e293b;
  }

  .footer {
    background: rgba(15, 23, 42, 0.95);
  }
}

/* Landscape phone adjustments */
@media only screen and (max-width: 768px) and (orientation: landscape) {
  .hero {
    padding: 2rem 0;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 0.9rem;
  }
}

/* Print optimizations */
@media print {
  .header,
  .footer,
  #sidebar,
  .hero {
    display: none;
  }

  #content {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .post {
    box-shadow: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  #signup_form {
    box-shadow: none;
    border: 1px solid #ccc;
  }

  body {
    background: white;
  }
}
