/* ==========================================
   Responsive Design - Mobile & Tablet
   ========================================== */

/* Tablet (max-width: 1024px) */
@media (max-width: 1024px) {
    .hero-container {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .hero-visual {
        order: -1;
    }

    .encryption-visual {
        width: 200px;
        height: 200px;
    }

    .lock-icon {
        width: 80px;
        height: 80px;
    }

    .architecture-content {
        grid-template-columns: 1fr;
    }

    .getting-started-content {
        grid-template-columns: 1fr;
    }

    .features-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
    /* Typography adjustments */
    .hero-title {
        font-size: 2.5rem;
    }

    .section-header h2 {
        font-size: 2rem;
    }

    /* Navigation */
    .mobile-menu-toggle {
        display: flex;
        z-index: 1001;
    }

    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: var(--bg-secondary);
        flex-direction: column;
        align-items: flex-start;
        padding: 80px var(--spacing-md) var(--spacing-md);
        box-shadow: var(--shadow-xl);
        transition: right var(--transition-base);
        z-index: 1000;
    }

    .nav-links.active {
        right: 0;
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links a {
        display: block;
        width: 100%;
    }

    /* Hero section */
    #hero {
        padding-top: 100px;
    }

    .hero-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    /* Features */
    .features-grid {
        grid-template-columns: 1fr;
    }

    /* API Tabs */
    .api-tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1;
        min-width: 150px;
    }

    /* Security */
    .security-grid {
        grid-template-columns: 1fr;
    }

    .threats {
        grid-template-columns: 1fr;
    }

    .principles-grid {
        grid-template-columns: 1fr;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
    }

    /* Spacing adjustments */
    section {
        padding: var(--spacing-xl) 0;
    }

    .container {
        padding: 0 var(--spacing-sm);
    }
}

/* Small mobile (max-width: 480px) */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .hero-title {
        font-size: 2rem;
    }

    .section-header h2 {
        font-size: 1.75rem;
    }

    .hero-stats {
        grid-template-columns: 1fr;
    }

    .stat {
        padding: var(--spacing-xs);
    }

    .feature-card,
    .api-method,
    .security-pillar {
        padding: var(--spacing-md);
    }

    .code-example pre {
        font-size: 0.75rem;
        padding: var(--spacing-sm);
    }

    .method-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }

    .step {
        flex-direction: column;
    }

    .step-number {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
}

/* Landscape phone */
@media (max-width: 896px) and (orientation: landscape) {
    #hero {
        padding-top: 80px;
        padding-bottom: var(--spacing-lg);
    }

    .hero-visual {
        display: none;
    }

    section {
        padding: var(--spacing-lg) 0;
    }
}

/* Print styles */
@media print {
    .mobile-menu-toggle,
    .nav-links,
    .hero-visual,
    .copy-btn {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    .hero-title,
    .section-header h2 {
        color: black;
    }

    a {
        color: black;
        text-decoration: underline;
    }

    section {
        page-break-inside: avoid;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .hero-content,
    .hero-visual,
    .feature-card,
    .layer-card,
    .security-pillar,
    .step {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Dark mode support (if system prefers dark) */
@media (prefers-color-scheme: dark) {
    /* Already dark by default, but can add overrides here if needed */
}

/* Light mode override (if system prefers light) */
@media (prefers-color-scheme: light) {
    /* User can uncomment this to support light mode */
    /*
    :root {
        --bg-primary: #ffffff;
        --bg-secondary: #f8fafc;
        --bg-tertiary: #e2e8f0;
        --bg-card: #ffffff;

        --text-primary: #0f172a;
        --text-secondary: #475569;
        --text-muted: #64748b;
    }
    */
}

/* Accessibility - Focus styles */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Hide scrollbar but keep functionality */
.code-example pre::-webkit-scrollbar {
    height: 8px;
}

.code-example pre::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
}

.code-example pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
}

.code-example pre::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Loading state for images */
img {
    background: rgba(255, 255, 255, 0.05);
}

img[src$=".svg"] {
    max-width: 100%;
    height: auto;
}

/* Overlay for mobile menu */
.nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(4px);
}

@media (max-width: 768px) {
    .nav-overlay.active {
        display: block;
    }
}

/* Improve touch targets on mobile */
@media (max-width: 768px) {
    .nav-links a,
    .btn,
    .tab-btn,
    .copy-btn {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* Support for notch/safe areas on newer phones */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(var(--spacing-md), env(safe-area-inset-left));
        padding-right: max(var(--spacing-md), env(safe-area-inset-right));
    }

    #navbar {
        padding-top: env(safe-area-inset-top);
    }
}
