/**
 * responsive.css - 반응형 스타일
 * Mobile First Approach
 */

/* ============================================
   Small Mobile (320px - 374px)
   ============================================ */
@media (max-width: 374px) {
    :root {
        --font-base: 14px;
        --space-lg: 16px;
        --space-xl: 24px;
    }

    .loader-icon .letter {
        width: 36px;
        height: 36px;
        font-size: var(--font-lg);
    }

    .btn-large {
        padding: var(--space-md) var(--space-lg);
        font-size: var(--font-base);
    }

    .section-title {
        font-size: var(--font-xl);
    }

    .modal-content {
        padding: var(--space-lg);
    }

    .modal-icon {
        font-size: 40px;
    }
}

/* ============================================
   Mobile (375px - 767px)
   ============================================ */
@media (max-width: 767px) {
    .nav-desktop {
        display: none;
    }

    .header-inner {
        padding: 0 var(--space-md);
    }

    .section {
        padding: var(--space-xl) var(--space-md);
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }

    .app-footer {
        padding-bottom: calc(var(--space-xl) + var(--bottom-nav-height) + 20px);
    }

    /* Game specific mobile styles */
    .game-letter-container {
        gap: var(--space-sm);
    }

    .game-letter {
        width: 44px;
        height: 54px;
        font-size: var(--font-xl);
    }

    .game-answer-slot {
        width: 36px;
        height: 44px;
        font-size: var(--font-lg);
    }

    .game-keyboard-key {
        min-width: 28px;
        height: 40px;
        font-size: var(--font-sm);
    }
}

/* ============================================
   Tablet (768px - 1023px)
   ============================================ */
@media (min-width: 768px) {
    .nav-desktop {
        display: block;
    }

    .menu-toggle {
        display: none;
    }

    .bottom-nav {
        display: none;
    }

    .app-main {
        padding-bottom: 0;
    }

    .app-footer {
        padding-bottom: var(--space-2xl);
    }

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

    .section {
        padding: var(--space-3xl) var(--space-xl);
    }

    .section-title {
        font-size: var(--font-3xl);
    }

    /* Hero section tablet */
    .hero-title {
        font-size: var(--font-4xl);
    }

    .hero-subtitle {
        font-size: var(--font-lg);
    }

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

    /* Game container */
    .game-container {
        max-width: var(--game-max-width);
        margin: 0 auto;
    }
}

/* ============================================
   Desktop (1024px - 1279px)
   ============================================ */
@media (min-width: 1024px) {
    .footer-grid {
        grid-template-columns: 2fr 1fr 1fr 1fr;
    }

    .footer-bottom {
        flex-direction: row;
        justify-content: space-between;
    }

    /* Stats grid desktop */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Features grid */
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Rankings table */
    .ranking-list {
        display: table;
        width: 100%;
    }

    .ranking-item {
        display: table-row;
    }

    .ranking-item > * {
        display: table-cell;
        padding: var(--space-md);
        vertical-align: middle;
    }
}

/* ============================================
   Large Desktop (1280px+)
   ============================================ */
@media (min-width: 1280px) {
    :root {
        --max-width: 1280px;
    }

    .hero-title {
        font-size: var(--font-5xl);
    }

    .section-title {
        font-size: var(--font-4xl);
    }
}

/* ============================================
   Height-based Responsive
   ============================================ */
@media (max-height: 600px) and (orientation: landscape) {
    .app-header {
        height: 56px;
    }

    :root {
        --header-height: 56px;
    }

    .bottom-nav {
        height: 56px;
    }

    .page-loader .loader-icon .letter {
        width: 40px;
        height: 40px;
    }
}

/* ============================================
   Hover & Touch Device Detection
   ============================================ */
@media (hover: hover) and (pointer: fine) {
    /* Desktop hover styles */
    .btn:hover {
        transform: translateY(-2px);
    }

    .card:hover {
        transform: translateY(-4px);
    }

    .game-letter:hover:not(.selected):not(.locked) {
        transform: translateY(-4px);
        box-shadow: var(--shadow-lg);
    }

    .ranking-item:hover {
        background: var(--bg-tertiary);
    }

    .achievement-card:hover {
        transform: scale(1.02);
    }
}

@media (hover: none) and (pointer: coarse) {
    /* Touch device styles */
    .btn:active {
        transform: scale(0.98);
    }

    .game-letter:active:not(.selected):not(.locked) {
        transform: scale(0.95);
    }

    /* Larger touch targets */
    .nav-list a {
        padding: var(--space-md);
    }

    .mobile-nav a {
        padding: var(--space-lg);
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .app-header,
    .bottom-nav,
    .mobile-menu,
    .page-loader,
    .toast-container,
    .achievement-popup,
    .modal {
        display: none !important;
    }

    .app-main {
        margin-top: 0;
        padding-bottom: 0;
    }

    .app-footer {
        padding-bottom: var(--space-xl);
    }

    body {
        background: white;
        color: black;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

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

    html {
        scroll-behavior: auto;
    }
}

/* ============================================
   High Contrast Mode
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --primary: #0000ff;
        --text-primary: #000000;
        --text-secondary: #333333;
        --bg-primary: #ffffff;
        --bg-secondary: #f0f0f0;
    }

    .btn-primary {
        background: var(--primary);
        box-shadow: none;
    }

    .card {
        border: 2px solid #000;
    }

    a:focus,
    button:focus {
        outline: 3px solid #000;
        outline-offset: 2px;
    }
}

/* ============================================
   Safe Area Insets (Notched Phones)
   ============================================ */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    }

    .app-main {
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    }

    .app-footer {
        padding-bottom: calc(var(--space-2xl) + var(--bottom-nav-height) + env(safe-area-inset-bottom));
    }

    @media (min-width: 768px) {
        .app-footer {
            padding-bottom: calc(var(--space-2xl) + env(safe-area-inset-bottom));
        }
    }

    .modal-content {
        padding-bottom: calc(var(--space-2xl) + env(safe-area-inset-bottom));
    }
}

/* ============================================
   Orientation Specific
   ============================================ */
@media (orientation: landscape) and (max-height: 500px) {
    .page-loader {
        padding: var(--space-md);
    }

    .loader-icon .letter {
        width: 32px;
        height: 32px;
        font-size: var(--font-base);
    }

    .modal-content {
        max-height: 95vh;
        overflow-y: auto;
    }
}
