/**
 * Responsive Design Enhancements
 * Cup Code Studio - 2025
 * Mobile-first responsive utilities and breakpoints
 */

/* ==================== Breakpoints ==================== */
:root {
    --breakpoint-xs: 320px;
    --breakpoint-sm: 576px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 992px;
    --breakpoint-xl: 1200px;
    --breakpoint-xxl: 1400px;
}

/* ==================== Container Responsive ==================== */
.container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* ==================== Typography Responsive ==================== */
h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
}

h2 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
}

h3 {
    font-size: clamp(1.5rem, 3.5vw, 2rem);
}

h4 {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
}

p, li, a {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
}

/* ==================== Grid System Responsive ==================== */
.grid {
    display: grid;
    gap: 20px;
}

.grid-1 { grid-template-columns: repeat(1, 1fr); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }

@media (max-width: 768px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ==================== Navigation Responsive ==================== */
@media (max-width: 968px) {
    .nav-menu {
        position: fixed;
        top: 70px;
        right: -100%;
        width: 100%;
        max-width: 300px;
        height: calc(100vh - 70px);
        background: white;
        flex-direction: column;
        padding: 30px 20px;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
        transition: right 0.3s ease;
        overflow-y: auto;
        z-index: 1000;
    }

    .nav-menu.active {
        right: 0;
    }

    .nav-menu li {
        width: 100%;
        margin: 10px 0;
    }

    .nav-menu a {
        display: block;
        padding: 15px 20px;
        border-radius: 10px;
        transition: all 0.3s ease;
    }

    .nav-menu a:hover,
    .nav-menu a.active {
        background: #76AD3F;
        color: white;
    }

    .menu-toggle {
        display: flex;
        flex-direction: column;
        gap: 5px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 10px;
    }

    .menu-toggle span {
        width: 25px;
        height: 3px;
        background: #333;
        border-radius: 3px;
        transition: all 0.3s ease;
    }

    .menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translateY(8px);
    }

    .menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translateY(-8px);
    }
}

/* ==================== Hero Section Responsive ==================== */
@media (max-width: 768px) {
    .hero {
        padding: 80px 20px 60px;
        min-height: auto;
    }

    .hero-content h1 {
        font-size: 2rem;
    }

    .hero-content p {
        font-size: 1rem;
    }

    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }

    .hero-buttons .btn {
        width: 100%;
    }
}

/* ==================== Cards Responsive ==================== */
@media (max-width: 576px) {
    .card,
    .project-card,
    .game-card,
    .app-card {
        margin: 10px 0;
    }

    .card-image {
        height: 200px;
    }

    .card-content {
        padding: 20px 15px;
    }
}

/* ==================== Footer Responsive ==================== */
@media (max-width: 768px) {
    .footer-container {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .footer-section {
        text-align: center;
    }

    .social-links {
        justify-content: center;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

/* ==================== Utility Classes ==================== */
/* Hide/Show based on screen size */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }

    .desktop-only {
        display: none;
    }
}

/* Spacing Responsive */
.section {
    padding: clamp(40px, 8vw, 80px) 20px;
}

/* Text Alignment Responsive */
@media (max-width: 768px) {
    .text-center-mobile {
        text-align: center;
    }
}

/* ==================== Touch-Friendly Elements ==================== */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch target size for mobile */
    button,
    a,
    input[type="button"],
    input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
    }

    /* Remove hover effects on touch devices */
    .card:hover,
    .project-card:hover,
    .game-card:hover {
        transform: none;
    }

    /* Add tap highlight */
    button,
    a {
        -webkit-tap-highlight-color: rgba(118, 173, 63, 0.2);
    }
}

/* ==================== Landscape Mobile Optimization ==================== */
@media (max-width: 968px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 60px 20px;
    }

    .nav-menu {
        max-height: 70vh;
    }
}

/* ==================== Print Styles ==================== */
@media print {
    .header,
    .footer,
    .nav-menu,
    .theme-toggle-btn,
    .back-to-top,
    .menu-toggle {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .container {
        max-width: 100%;
    }

    a {
        text-decoration: underline;
        color: black;
    }
}

/* ==================== Reduced Motion ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .animate-fade-in-up,
    .animate-fade-in-down,
    .animate-fade-in,
    .reveal {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ==================== High Contrast Mode ==================== */
@media (prefers-contrast: high) {
    :root {
        --text-primary: #000000;
        --bg-primary: #ffffff;
        --border-color: #000000;
    }

    button,
    a,
    .card {
        border: 2px solid currentColor;
    }
}

/* ==================== Dark Mode Responsive ==================== */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #1a1a2e;
        --bg-secondary: #16213e;
        --text-primary: #ffffff;
        --text-secondary: #b8b8b8;
    }
}

/* ==================== Image Optimization ==================== */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Lazy loading images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Low quality image placeholder */
.img-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==================== Form Inputs Responsive ==================== */
@media (max-width: 576px) {
    input,
    textarea,
    select,
    button {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* ==================== Scroll Behavior ==================== */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* ==================== Focus Visible ==================== */
:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ==================== Selection Styles ==================== */
::selection {
    background: var(--accent-color);
    color: white;
}

::-moz-selection {
    background: var(--accent-color);
    color: white;
}

/* ==================== Scrollbar Styles ==================== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) var(--bg-secondary);
}

/* ==================== Safe Area (Notch Support) ==================== */
@supports (padding: env(safe-area-inset-top)) {
    .header {
        padding-top: env(safe-area-inset-top);
    }

    .footer {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
