/*
 * Educational Empire Hub - Responsive Design
 * Media queries and mobile-first adaptations
 */

/* ===================================
   BREAKPOINT: LARGE DESKTOP (1440px+)
   =================================== */

@media (min-width: 1440px) {
    .container {
        max-width: var(--container-max);
    }

    /* Extra spacing for large screens */
    .section {
        padding-block: var(--space-3xl);
    }

    /* Hero adjustments */
    .hero .heading-display {
        font-size: 8rem;
    }
}

/* ===================================
   BREAKPOINT: DESKTOP (1024px - 1439px)
   =================================== */

@media (min-width: 1024px) and (max-width: 1439px) {
    .container {
        max-width: var(--container-wide);
    }
}

/* ===================================
   BREAKPOINT: TABLET (768px - 1023px)
   =================================== */

@media (max-width: 1023px) {

    /* Navigation */
    .nav__menu {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(20px);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: var(--space-lg);
        transform: translateX(100%);
        transition: transform var(--duration-slow) var(--ease-out);
        z-index: var(--z-modal);
    }

    .nav__menu.is-open {
        transform: translateX(0);
    }

    .nav__menu .nav-link {
        font-size: var(--text-h2);
        color: var(--color-text-inverse);
    }

    .nav__hamburger {
        display: flex;
        flex-direction: column;
        gap: 6px;
        cursor: pointer;
        z-index: var(--z-modal);
    }

    .nav__hamburger span {
        display: block;
        width: 30px;
        height: 2px;
        background: currentColor;
        transition: all var(--duration-normal);
    }

    .nav__hamburger.is-open span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }

    .nav__hamburger.is-open span:nth-child(2) {
        opacity: 0;
    }

    .nav__hamburger.is-open span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }

    /* Grid adjustments */
    .grid--4 {
        grid-template-columns: repeat(2, 1fr);
    }

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

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

    /* Bento grid tablet */
    .grid--bento {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
    }

    .grid--bento .bento-featured,
    .grid--bento .bento-description {
        grid-column: span 2;
    }

    .grid--bento .bento-stat,
    .grid--bento .bento-samples,
    .grid--bento .bento-testimonial {
        grid-column: span 1;
    }

    /* Editorial layout */
    .grid--editorial {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }

    .grid--editorial> :first-child {
        order: -1;
    }

    /* Split layouts */
    .split {
        flex-direction: column;
        gap: var(--space-lg);
    }

    .split--40-60> :first-child,
    .split--40-60> :last-child {
        flex: none;
        width: 100%;
    }

    /* Horizontal scroll */
    .scroll-panel {
        padding: var(--space-lg);
    }

    /* Typography scaling */
    .heading-display {
        font-size: clamp(3rem, 8vw, 5rem);
    }

    /* Reduce complex animations */
    .parallax-layer {
        transform: none !important;
    }
}

/* ===================================
   BREAKPOINT: MOBILE (320px - 767px)
   =================================== */

@media (max-width: 767px) {

    /* Spacing adjustments */
    .section {
        padding-block: var(--space-xl);
    }

    .container {
        padding-inline: var(--space-sm);
    }

    /* Typography */
    .heading-display {
        font-size: clamp(2.5rem, 10vw, 4rem);
    }

    .heading-1 {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .heading-2 {
        font-size: clamp(1.5rem, 6vw, 2rem);
    }

    .heading-3 {
        font-size: clamp(1.25rem, 5vw, 1.5rem);
    }

    /* All grids single column */
    .grid--2,
    .grid--3,
    .grid--4,
    .card-grid {
        grid-template-columns: 1fr;
    }

    /* Bento full width */
    .grid--bento {
        grid-template-columns: 1fr;
    }

    .grid--bento .bento-featured,
    .grid--bento .bento-description,
    .grid--bento .bento-stat,
    .grid--bento .bento-samples,
    .grid--bento .bento-testimonial {
        grid-column: span 1;
    }

    /* Horizontal scroll becomes vertical */
    .scroll-container {
        overflow-x: visible;
        overflow-y: visible;
    }

    .scroll-track {
        flex-direction: column;
        width: 100%;
    }

    .scroll-panel {
        width: 100%;
        min-height: auto;
        scroll-snap-align: none;
        padding: var(--space-lg) var(--space-md);
    }

    /* Buttons */
    .btn--xl {
        min-width: 100%;
        padding: var(--space-md) var(--space-lg);
    }

    .btn--lg {
        padding: var(--space-sm) var(--space-md);
    }

    /* Cards */
    .card--book:hover {
        transform: translateY(-8px);
    }

    /* Forms */
    .form-input--ornate {
        height: 50px;
        padding: var(--space-sm) var(--space-md);
        font-size: var(--text-body);
    }

    /* Hero section mobile */
    .section--hero {
        min-height: 100svh;
        padding-top: calc(var(--nav-height) + var(--space-md));
        padding-bottom: var(--space-xl);
        text-align: center;
    }

    /* Pull quote mobile */
    .pull-quote {
        padding: var(--space-md);
        font-size: var(--text-body-lg);
    }

    .pull-quote::before {
        font-size: 4em;
    }

    /* Drop cap smaller */
    .drop-cap::first-letter {
        font-size: 3.5em;
    }

    /* Statistics */
    .stat {
        padding: var(--space-sm);
    }

    .stat__number {
        font-size: var(--text-h1);
    }

    /* Timeline vertical */
    .timeline {
        padding-left: var(--space-lg);
    }

    /* Seal smaller */
    .seal {
        width: 100px;
        height: 100px;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    /* Hide decorative elements on mobile */
    .decorative-corners::before,
    .decorative-corners::after {
        display: none;
    }

    /* Reduce animation complexity */
    [data-scroll] {
        opacity: 1;
        transform: none;
    }

    .parallax-layer {
        transform: none !important;
    }

    .particle-container {
        display: none;
    }
}

/* ===================================
   SMALL MOBILE (320px - 375px)
   =================================== */

@media (max-width: 375px) {
    body {
        font-size: 15px;
    }

    .container {
        padding-inline: var(--space-xs);
    }

    .heading-display {
        font-size: 2rem;
    }

    .btn {
        padding: var(--space-xs) var(--space-sm);
        font-size: var(--text-small);
    }
}

/* ===================================
   TALL MOBILE (height consideration)
   =================================== */

@media (max-height: 600px) and (max-width: 767px) {
    .section--hero {
        min-height: auto;
        padding-block: var(--space-xl);
    }

    .hero-decorative {
        display: none;
    }
}

/* ===================================
   ACCESSIBILITY: REDUCED MOTION
   =================================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .scroll-container {
        scroll-behavior: auto;
    }

    [data-scroll] {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .parallax-layer {
        transform: none !important;
    }

    .letter-animate {
        opacity: 1;
        transform: none;
    }

    .particle-container,
    .cursor-trail {
        display: none !important;
    }
}

/* ===================================
   ACCESSIBILITY: HIGH CONTRAST
   =================================== */

@media (prefers-contrast: high) {
    :root {
        --color-text: #000000;
        --color-text-muted: #333333;
        --color-border: #000000;
        --color-background: #FFFFFF;
    }

    .btn {
        border: 2px solid currentColor;
    }

    .card {
        border: 2px solid var(--color-border);
    }

    .text-gradient {
        background: none;
        -webkit-text-fill-color: var(--color-text);
    }
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }

    .nav,
    .footer,
    .btn,
    .scroll-progress,
    .theme-toggle,
    .particle-container {
        display: none !important;
    }

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

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }
}

/* ===================================
   LANDSCAPE MOBILE
   =================================== */

@media (max-height: 500px) and (orientation: landscape) {
    .section--hero {
        min-height: auto;
        padding-block: var(--space-lg);
    }

    .heading-display {
        font-size: 2.5rem;
    }

    .hero-decorative {
        display: none;
    }
}

/* ===================================
   TOUCH DEVICE OPTIMIZATIONS
   =================================== */

@media (hover: none) and (pointer: coarse) {

    /* Larger tap targets */
    .btn {
        min-height: 48px;
        min-width: 48px;
    }

    .nav-link {
        padding: var(--space-sm);
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    /* Remove hover effects that don't work on touch */
    .hover-lift:hover,
    .hover-scale:hover,
    .hover-glow:hover {
        transform: none;
        box-shadow: var(--shadow-md);
    }

    .hover-underline::after {
        display: none;
    }

    /* Card book no 3D effect */
    .card--book:hover {
        transform: translateY(-8px);
    }

    /* Remove cursor effects */
    .custom-cursor,
    .cursor-particle {
        display: none !important;
    }
}

/* ===================================
   DARK MODE SYSTEM PREFERENCE
   =================================== */

@media (prefers-color-scheme: dark) {
    :root:not([data-mode]) {
        --color-background: #1A1A1A;
        --color-surface: #2C2C2C;
        --color-text: #F5F1E8;
        --color-text-muted: #8A8A8A;
        --color-border: #5A5A5A;
    }
}

/* ===================================
   CONTAINER QUERIES (Progressive)
   =================================== */

@supports (container-type: inline-size) {
    .card-container {
        container-type: inline-size;
    }

    @container (max-width: 400px) {
        .card__content {
            padding: var(--space-sm);
        }

        .card__title {
            font-size: var(--text-body-lg);
        }
    }
}