/*
  =====================================================================================
  06-RESPONSIVE.CSS - Houtini WordPress Theme
  Responsive design patterns and breakpoint management
  =====================================================================================
*/

/* ===== BREAKPOINT VARIABLES ===== */
:root {
  --breakpoint-xs: 360px;
  --breakpoint-sm: 576px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 992px;
  --breakpoint-xl: 1200px;
  --breakpoint-xxl: 1920px;
}

/* ===== SMALL MOBILE DEVICES (< 360px) ===== */
@media (max-width: 360px) {
  .houtini-hero h1 {
    font-size: 1.75rem;
    line-height: 1.3;
  }
  
  .houtini-prompt-container {
    padding: 16px;
    font-size: 0.9rem;
  }
  
  .btn-primary, .btn-secondary {
    padding: 10px 16px;
    font-size: 0.875rem;
    min-height: 44px;
    min-width: 44px;
  }
  
  .houtini-theme-toggle {
    width: 48px;
    height: 48px;
    bottom: 16px;
    right: 16px;
  }
}

/* ===== MOBILE DEVICES (< 768px) ===== */
@media (max-width: 768px) {
  /* Theme toggle improvements */
  .houtini-theme-toggle {
    width: 52px;
    height: 52px;
    font-size: 1.5rem;
    z-index: 9999;
    touch-action: manipulation;
    bottom: max(24px, env(safe-area-inset-bottom));
    right: max(24px, env(safe-area-inset-right));
  }
  
  /* Social section safe areas */
  .houtini-social-section {
    /* No padding on social section - let social-bar-links handle spacing */
    padding: 0 !important;
  }
  
  /* Content overflow prevention */
  .houtini-prompt-container {
    width: calc(100% - 32px);
    max-width: none;
    word-break: break-word;
    overflow-wrap: break-word;
  }
  
  .container, .container-fluid {
    overflow-x: hidden;
  }
  
  /* Email form mobile layout */
  .houtini-email-form {
    flex-direction: column;
    gap: 12px;
  }
  
  .houtini-email-input {
    width: 100%;
  }
  
  .houtini-email-submit-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ===== EMAIL SIGNUP MOBILE (< 480px) ===== */
@media (max-width: 480px) {
  .houtini-email-form {
    flex-direction: column;
    gap: 12px;
  }
  
  .houtini-email-input {
    width: 100%;
  }
  
  .houtini-email-submit-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ===== TABLETS (769px - 1024px) ===== */
@media (min-width: 769px) and (max-width: 1024px) {
  .houtini-hero {
    padding: 100px 0 60px;
  }
  
  .houtini-hero h1 {
    font-size: 3.5rem;
  }
  
  .houtini-prompt-container {
    max-width: 600px;
  }
}

/* ===== ULTRA-WIDE SCREENS (1920px+) ===== */
@media (min-width: 1920px) {
  .container {
    max-width: 1400px;
  }
  
  .houtini-hero h1 {
    font-size: 5rem;
  }
  
  .houtini-prompt-container {
    max-width: 800px;
    padding: 32px;
    font-size: 1.25rem;
  }
}

/* ===== LANDSCAPE MOBILE OPTIMIZATION ===== */
@media (max-height: 480px) and (orientation: landscape) {
  .houtini-hero {
    min-height: auto;
    padding: 40px 0;
  }
  
  .houtini-hero h1 {
    margin-bottom: 0.5rem;
  }
  
  .houtini-hero h2 {
    margin: 8px 0 16px 0;
  }
  
  .houtini-prompt-container {
    margin: 16px auto;
    min-height: 40px;
  }
}

/* ===== RESPONSIVE TYPOGRAPHY WITH CLAMP ===== */
@media (min-width: 320px) {
  .houtini-hero h1 {
    font-size: clamp(1.75rem, 8vw, 4rem);
  }
  
  .houtini-hero h2 {
    font-size: clamp(1rem, 3vw, 1.5rem);
  }
  
  .houtini-hero p {
    font-size: clamp(0.875rem, 2.5vw, 1.125rem);
  }
}

/* ===== ACCESSIBILITY: REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  .houtini-theme-toggle,
  .btn-primary,
  .btn-secondary,
  .houtini-prompt-container {
    transition: none;
    animation: none;
  }
  
  .houtini-hero h1 {
    background: var(--houtini-primary);
    -webkit-text-fill-color: initial;
    background-clip: initial;
    -webkit-background-clip: initial;
    color: var(--houtini-primary);
  }
}

/* ===== ACCESSIBILITY: HIGH CONTRAST ===== */
@media (prefers-contrast: high) {
  .houtini-prompt-container {
    border-width: 3px;
    background: white;
    backdrop-filter: none;
  }
  
  .dark-theme .houtini-prompt-container {
    background: black;
    border-color: white;
  }
  
  .btn-primary {
    background: #0000FF;
    border: 2px solid #0000FF;
  }
  
  .btn-secondary {
    background: white;
    color: #0000FF;
    border: 2px solid #0000FF;
  }
}

/* ===== FOCUS MANAGEMENT ===== */
.houtini-theme-toggle:focus-visible {
  outline: 3px solid var(--houtini-primary);
  outline-offset: 2px;
}

/* ===== CODE BLOCK RESPONSIVE (JS-Generated) ===== */
@media (max-width: 768px) {
  /* Code blocks in HTML widgets need specific responsive handling */
  .code-block-wrapper {
    margin: 1rem 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    box-sizing: border-box !important;
  }
  
  .code-block-header {
    padding: 0.75rem 1rem !important;
    font-size: 0.875rem !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }
  
  .copy-code-btn {
    position: static !important;
    margin-left: auto !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem !important;
    min-width: auto !important;
  }
  
  .code-block-wrapper pre {
    padding: 1rem !important;
    font-size: 0.8rem !important;
    line-height: 1.4 !important;
    overflow-x: auto !important;
    white-space: pre !important;
    word-wrap: normal !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  .code-block-wrapper code {
    font-size: inherit !important;
    word-break: normal !important;
    white-space: pre !important;
    display: block !important;
    width: max-content !important;
    min-width: 100% !important;
  }
}

@media (max-width: 480px) {
  .code-block-wrapper {
    margin: 0.75rem -15px !important; /* Extend to container edges on very small screens */
    border-radius: 0 !important;
  }
  
  .code-block-header {
    padding: 0.5rem 1rem !important;
    font-size: 0.8rem !important;
  }
  
  .copy-code-btn {
    padding: 0.4rem 0.8rem !important;
    font-size: 0.8rem !important;
  }
  
  .code-block-wrapper pre {
    padding: 0.75rem 1rem !important;
    font-size: 0.75rem !important;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .houtini-theme-toggle,
  .houtini-social-section,
  .navbar-toggler {
    display: none;
  }
  
  .houtini-hero {
    min-height: auto;
    padding: 2rem 0;
  }
  
  .houtini-prompt-container {
    border: 2px solid #000;
    background: white;
    backdrop-filter: none;
  }
  
  .btn-primary, .btn-secondary {
    border: 2px solid #000;
    color: #000;
    background: white;
  }
  
  /* Hide copy buttons in print */
  .copy-code-btn,
  .code-block-header {
    display: none !important;
  }
}