/* 
 * Responsive CSS for iReadWise
 * Include this file in all PHP files for consistent responsive behavior
 */

/* Base responsive breakpoints */
:root {
  --breakpoint-sm: 576px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 992px;
  --breakpoint-xl: 1200px;
  --breakpoint-xxl: 1440px;
  --breakpoint-md-lg: 1024px;
  --breakpoint-sm-md: 768px;
  --breakpoint-xs-sm: 375px;
}

/* Large desktops (1440px and up) */
@media (min-width: 1440px) {
  .container {
    max-width: 1400px;
    margin: 0 auto;
  }
  
  .card, .login-box, .modal-content {
    max-width: 1400px;
    margin: 0 auto 30px;
  }
}

/* Large desktops (1200px to 1439px) */
@media (min-width: 1200px) and (max-width: 1439px) {
  .container {
    max-width: 1200px;
    margin: 0 auto;
  }
  
  .card, .login-box, .modal-content {
    max-width: 1200px;
    margin: 0 auto 25px;
  }
}

/* Medium desktops and tablets (1024px to 1199px) */
@media (min-width: 1024px) and (max-width: 1199px) {
  .container {
    max-width: 100%;
    padding: 0 15px;
  }
  
  h1, .main-title {
    font-size: 2.4rem !important;
  }
  
  .features-section {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
    gap: 20px !important;
  }
}

/* Tablets (768px to 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .container {
    padding: 15px;
  }
  
  h1, .main-title {
    font-size: 2rem !important;
  }
  
  h2 {
    font-size: 1.6rem !important;
  }
  
  .card, .login-box, .modal-content {
    padding: 20px !important;
    margin: 15px auto !important;
    width: 90% !important;
  }
  
  .features-section {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
    gap: 15px !important;
  }
}

/* Large phones (577px to 767px) */
@media (min-width: 577px) and (max-width: 767px) {
  .container {
    padding: 15px;
  }
  
  h1, .main-title {
    font-size: 1.8rem !important;
  }
  
  h2 {
    font-size: 1.5rem !important;
  }
  
  .card, .login-box, .modal-content {
    padding: 20px !important;
    margin: 10px auto !important;
    width: 95% !important;
  }
}

/* Small phones (376px to 576px) */
@media (min-width: 376px) and (max-width: 576px) {
  .container {
    padding: 12px;
  }
  
  h1, .main-title {
    font-size: 1.6rem !important;
  }
  
  h2 {
    font-size: 1.4rem !important;
  }
  
  h3 {
    font-size: 1.2rem !important;
  }
  
  .card, .login-box, .modal-content {
    padding: 15px !important;
    margin: 10px auto !important;
    width: 100% !important;
  }
  
  button, .btn {
    padding: 10px 16px !important;
    font-size: 0.95rem !important;
  }
}

/* Extra small phones (up to 375px) */
@media (max-width: 375px) {
  .container {
    padding: 10px;
  }
  
  h1, .main-title {
    font-size: 1.5rem !important;
  }
  
  h2 {
    font-size: 1.3rem !important;
  }
  
  h3 {
    font-size: 1.1rem !important;
  }
  
  p, .description {
    font-size: 0.9rem !important;
  }
  
  .card, .login-box, .modal-content {
    padding: 12px !important;
    margin: 8px auto !important;
    border-radius: 12px !important;
    width: 100% !important;
  }
  
  button, .btn {
    padding: 8px 14px !important;
    font-size: 0.9rem !important;
    min-height: 44px !important;
  }
  
  input, textarea, select {
    font-size: 16px !important;
    padding: 10px 12px !important;
  }
  
  .nav-links a {
    padding: 8px 12px !important;
    font-size: 0.9rem !important;
  }
  
  .container {
    max-width: 95%;
  }
  
  .features-section {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    gap: 25px !important;
  }
}

/* Extra large devices (large desktops, 1200px and down) */
@media (max-width: 1200px) {
  .container {
    max-width: 100%;
  }
}

/* Landscape orientation fixes */
@media (max-height: 500px) and (orientation: landscape) {
  .login-box, .modal-content {
    position: relative !important;
    top: 0 !important;
    transform: none !important;
    margin: 20px auto !important;
  }
  
  .video-bg {
    object-position: center 20% !important;
  }
  
  .hero-section {
    margin-bottom: 30px !important;
  }
  
  .features-section {
    margin-bottom: 30px !important;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .card, .feature-card {
    min-height: 120px !important;
    cursor: pointer !important;
  }
  
  .nav-links a, .modal-btn {
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  .user-icon, .toggle-password {
    min-width: 44px !important;
    min-height: 44px !important;
  }
  
  input, textarea, select {
    min-height: 44px !important;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .card, .login-box, .modal-content {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3) !important;
  }
  
  .feature-card {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
  }
}

/* Print styles */
@media print {
  .video-bg, .overlay {
    display: none !important;
  }
  
  .card, .login-box, .modal-content {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }
  
  button, .btn {
    display: none !important;
  }
}

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

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --white: #1a1a1a;
    --light-gray: #2d2d2d;
    --dark-gray: #e0e0e0;
  }
  
  .card, .login-box, .modal-content {
    background-color: rgba(45, 45, 45, 0.95) !important;
    color: #e0e0e0 !important;
  }
}

/* Focus styles for keyboard navigation */
@media (any-hover: hover) {
  .card:hover, .feature-card:hover {
    transform: translateY(-5px) !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2) !important;
  }
  
  button:hover, .btn:hover {
    transform: translateY(-2px) !important;
  }
}

/* Utility classes for responsive design */
.responsive-hidden-xs { display: block !important; }
.responsive-hidden-sm { display: block !important; }
.responsive-hidden-md { display: block !important; }

@media (max-width: 576px) {
  .responsive-hidden-xs { display: none !important; }
}

@media (max-width: 768px) {
  .responsive-hidden-sm { display: none !important; }
}

@media (max-width: 992px) {
  .responsive-hidden-md { display: none !important; }
}

/* Responsive text utilities */
.text-responsive-xs { font-size: 0.9rem !important; }
.text-responsive-sm { font-size: 1rem !important; }
.text-responsive-md { font-size: 1.1rem !important; }
.text-responsive-lg { font-size: 1.2rem !important; }

@media (max-width: 576px) {
  .text-responsive-xs { font-size: 0.8rem !important; }
}

/* Responsive spacing utilities */
.spacing-responsive-xs { padding: 10px !important; margin: 8px !important; }
.spacing-responsive-sm { padding: 15px !important; margin: 10px !important; }
.spacing-responsive-md { padding: 20px !important; margin: 15px !important; }
.spacing-responsive-lg { padding: 25px !important; margin: 20px !important; }

@media (max-width: 576px) {
  .spacing-responsive-xs { padding: 8px !important; margin: 6px !important; }
  .spacing-responsive-sm { padding: 10px !important; margin: 8px !important; }
  .spacing-responsive-md { padding: 15px !important; margin: 10px !important; }
  .spacing-responsive-lg { padding: 20px !important; margin: 15px !important; }
}

@media (max-width: 768px) {
  .spacing-responsive-sm { padding: 12px !important; margin: 8px !important; }
  .spacing-responsive-md { padding: 18px !important; margin: 12px !important; }
  .spacing-responsive-lg { padding: 22px !important; margin: 18px !important; }
}

/* Step 3 overlay and non-scrolling background (applies across all *_reading.php) */
/* Make section 3 a full-screen fixed overlay */
#section3 {
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

#section3.active {
  position: fixed !important;
  inset: 0 !important; /* top/right/bottom/left: 0 */
  z-index: 1000 !important;
  overflow: hidden !important;
  overscroll-behavior: contain !important;
  max-height: 100dvh !important;
}

#section3 h2 { display: none !important; }
#section3 #resultsContent { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden !important; }

/* Lock page scroll only when step 3 is active */
html:has(#section3.active),
body:has(#section3.active) {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100dvh !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

/* Hide page scrollbar when step 3 is active */
body:has(#section3.active) { scrollbar-width: none; }
body:has(#section3.active)::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* Remove body padding to avoid accidental viewport overflow on step 3 */
body:has(#section3.active) {
  padding: 0 !important;
}

/* Ensure container doesn't introduce scrolling during step 3 */
.container:has(#section3.active) {
  max-width: 100% !important;
  width: 100% !important;
  height: 100vh !important;
  max-height: 100vh !important;
  overflow: hidden !important;
}

/* Since #section3 is also .section, make sure no internal scrollbar shows */
#section3.section {
  max-height: 100dvh !important;
  overflow: clip !important;
}

/* Hide any scrollbar that might still render within #section3 */
#section3::-webkit-scrollbar { display: none; width: 0; height: 0; }
#section3 { scrollbar-width: none; }

/* Mobile styles for reading pages */
@media (max-width: 768px) {
  /* Specific background for Anansi's Web reading page */
  body[style*="anansiweb_reading.php"] {
    background-image: url('../../assets/images/grade4photo/anansiweb.jpg') !important;
    background-attachment: fixed !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
  }
  
  /* For all other reading pages */
  body[style*="background-image"]:not([style*="anansiweb_reading.php"]) {
    background-attachment: fixed !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
  }
  
  /* For step 1, 2, and 3 sections */
  #section1, #section2, #section3 {
    background-color: rgba(255, 255, 255, 0.95) !important;
    margin: 10px !important;
    padding: 20px !important;
    border-radius: 15px !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2) !important;
  }
  
  /* Ensure content is readable on top of background */
  .section h1, .section h2, .section h3, 
  .section p, .section div, .section span {
    color: #333 !important;
    text-shadow: none !important;
  }
  
  /* Adjust progress bar for better visibility */
  .progress-bar {
    background-color: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid #ddd !important;
  }
  
  .progress-fill {
    background-color: #4CAF50 !important;
  }
  
  /* Step indicator styling */
  .step-indicator {
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #333 !important;
    padding: 5px 10px !important;
    border-radius: 15px !important;
    margin: 10px auto !important;
    display: inline-block !important;
  }
}

/* Prevent the results card from exceeding viewport to avoid scrollbars */
.wr-result {
  max-width: 100vw !important;
  max-height: 100dvh !important;
  width: min(880px, 100vw) !important;
  height: min(1030px, 100dvh) !important;
}
