/**
 * VECTOR Game v2.0 - Responsive Styles
 * Media queries and responsive adjustments
 */

/* ============================================
   LARGE DESKTOP (1440px+)
   ============================================ */
@media (min-width: 1440px) {
    :root {
        --panel-width: 360px;
        --board-size: 600px;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .control-panel {
        padding: 20px;
    }
}

/* ============================================
   DESKTOP (1200px - 1439px)
   ============================================ */
@media (min-width: 1200px) and (max-width: 1439px) {
    :root {
        --panel-width: 340px;
        --board-size: 540px;
    }
}

/* ============================================
   SMALL DESKTOP / LARGE TABLET (900px - 1199px)
   ============================================ */
@media (min-width: 900px) and (max-width: 1199px) {
    :root {
        --panel-width: 300px;
        --board-size: min(480px, calc(100vw - 360px));
    }
    
    .game-title {
        font-size: 1.5rem;
    }
    
    .game-subtitle {
        display: none;
    }
    
    .control-panel {
        padding: 12px;
        gap: 12px;
    }
    
    .panel-card {
        border-radius: var(--radius-sm);
    }
}

/* ============================================
   TABLET LAYOUT (768px - 899px)
   Stacked: panels above board
   ============================================ */
@media (min-width: 768px) and (max-width: 899px) {
    :root {
        --board-size: min(450px, calc(100vw - 48px));
    }
    
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .header {
        padding: 0 16px;
    }
    
    .header-center {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 8px;
    }
    
    .header {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
    }
    
    .header-left {
        flex: 1;
    }
    
    .control-panel {
        flex-direction: row;
        flex-wrap: wrap;
        max-height: none;
        border-right: none;
        border-bottom: var(--border-subtle);
        padding: 12px;
        gap: 12px;
    }
    
    .panel-card {
        flex: 1 1 calc(50% - 6px);
        min-width: 200px;
    }
    
    .board-area {
        padding: 24px;
    }
}

/* ============================================
   MOBILE LANDSCAPE / SMALL TABLET (600px - 767px)
   ============================================ */
@media (min-width: 600px) and (max-width: 767px) {
    :root {
        --board-size: min(400px, calc(100vw - 32px));
    }
    
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .header {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
        gap: 8px;
    }
    
    .header-left {
        flex: 1;
    }
    
    .header-center {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    
    .game-subtitle {
        display: none;
    }
    
    .control-panel {
        flex-direction: row;
        flex-wrap: wrap;
        max-height: none;
        border-right: none;
        border-bottom: var(--border-subtle);
        padding: 12px;
        gap: 8px;
    }
    
    .panel-card {
        flex: 1 1 100%;
    }
    
    .board-area {
        padding: 16px;
    }
    
    .mode-selector {
        flex-direction: row;
    }
}

/* ============================================
   MOBILE PORTRAIT (< 600px)
   Compact layout for phones
   ============================================ */
@media (max-width: 599px) {
    :root {
        --board-size: min(340px, calc(100vw - 24px));
        --header-height: 56px;
    }
    
    .header {
        padding: 8px 12px;
        gap: 8px;
    }
    
    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
    }
    
    .game-title {
        font-size: 1.25rem;
        letter-spacing: 0.1em;
    }
    
    .game-subtitle {
        display: none;
    }
    
    .header-center {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        padding: 8px 12px;
        border-bottom: var(--border-subtle);
        z-index: 50;
        justify-content: center;
        gap: 12px;
    }
    
    .header-right {
        gap: 4px;
    }
    
    .turn-badge {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    .mode-badge {
        padding: 4px 8px;
        font-size: 0.625rem;
    }
    
    /* Adjust main content for fixed header elements */
    .main-content {
        padding-top: 40px;
    }
    
    /* Full-width panels */
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        flex-direction: column;
        max-height: none;
        border-right: none;
        border-bottom: var(--border-subtle);
        padding: 12px;
        gap: 8px;
    }
    
    .panel-card {
        border-radius: var(--radius-sm);
    }
    
    .panel-header {
        padding: 10px 12px;
    }
    
    .panel-header h3 {
        font-size: 0.625rem;
    }
    
    .panel-body {
        padding: 12px;
    }
    
    /* Compact turn info */
    .turn-number {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }
    
    .current-player {
        margin-bottom: 8px;
    }
    
    .mode-selector {
        flex-direction: row;
    }
    
    .btn-mode {
        padding: 6px 8px;
        font-size: 0.625rem;
    }
    
    /* Compact AI config */
    .form-group {
        margin-bottom: 12px;
    }
    
    .strength-desc {
        font-size: 0.625rem;
    }
    
    /* Compact game log */
    .game-log {
        max-height: 80px;
    }
    
    .log-entry {
        font-size: 0.625rem;
    }
    
    /* Compact move history */
    .move-history {
        max-height: 60px;
    }
    
    .history-row {
        font-size: 0.625rem;
    }
    
    /* Board area */
    .board-area {
        padding: 12px;
    }
    
    /* Hide some view options on mobile */
    #panel-view .checkbox-label:nth-child(n+3) {
        display: none;
    }
    
    /* Compact notifications */
    .notifications {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }
    
    .notification {
        padding: 10px 12px;
        font-size: 0.75rem;
    }
    
    /* Compact buttons */
    .btn {
        padding: 8px 12px;
        font-size: 0.8125rem;
    }
    
    .btn-sm {
        padding: 5px 8px;
        font-size: 0.625rem;
    }
    
    .btn-icon {
        padding: 6px;
    }
    
    .btn-icon svg {
        width: 16px;
        height: 16px;
    }
    
    /* Compact new game button */
    #btn-new-game {
        padding: 12px;
        font-size: 0.875rem;
    }
}

/* ============================================
   VERY SMALL SCREENS (< 360px)
   ============================================ */
@media (max-width: 359px) {
    :root {
        --board-size: calc(100vw - 16px);
    }
    
    .header {
        padding: 6px 8px;
    }
    
    .game-title {
        font-size: 1rem;
    }
    
    .control-panel {
        padding: 8px;
    }
    
    .panel-body {
        padding: 8px;
    }
    
    .board-area {
        padding: 8px;
    }
    
    /* Hide even more elements */
    .square-label {
        display: none;
    }
    
    .mode-badge {
        display: none;
    }
}

/* ============================================
   LANDSCAPE ORIENTATION OVERRIDES
   ============================================ */
@media (max-height: 600px) and (orientation: landscape) {
    :root {
        --board-size: min(280px, calc(100vh - 80px));
    }
    
    .header {
        height: 48px;
        padding: 0 12px;
    }
    
    .game-title {
        font-size: 1rem;
    }
    
    .game-subtitle {
        display: none;
    }
    
    .main-content {
        grid-template-columns: 280px 1fr;
    }
    
    .control-panel {
        max-height: calc(100vh - 48px);
        overflow-y: auto;
    }
    
    .board-area {
        padding: 12px;
    }
    
    /* Smaller panels */
    .panel-card {
        border-radius: var(--radius-sm);
    }
    
    .panel-body {
        padding: 8px;
    }
    
    .turn-number {
        font-size: 1.25rem;
    }
    
    .game-log,
    .move-history {
        max-height: 50px;
    }
}

/* ============================================
   HIGH DPI / RETINA DISPLAYS
   ============================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Thinner borders on high DPI */
    .piece {
        border-width: 1.5px;
    }
    
    .board {
        border-width: 1.5px;
    }
}

/* ============================================
   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;
    }
    
    .square.nexus::before {
        animation: none;
    }
    
    .square.legal-move::after {
        animation: none;
    }
    
    .piece.collapsing {
        animation: none;
    }
    
    .piece.phase-shifting {
        animation: none;
    }
}

/* ============================================
   DARK/LIGHT MODE (future enhancement)
   ============================================ */
@media (prefers-color-scheme: light) {
    /* Light mode styles could go here */
    /* For now, we default to dark theme */
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .header,
    .control-panel,
    .notifications,
    .modal-overlay {
        display: none;
    }
    
    .main-content {
        display: block;
    }
    
    .board-area {
        padding: 0;
    }
    
    .board {
        box-shadow: none;
        border: 2px solid #333;
    }
    
    .piece {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

/* ============================================
   TOUCH DEVICE OPTIMIZATIONS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 44px;
    }
    
    .btn-sm {
        min-height: 36px;
    }
    
    .checkbox-label {
        min-height: 44px;
        padding: 10px 0;
    }
    
    .checkbox-label input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }
    
    /* Remove hover effects on touch */
    .piece:hover {
        transform: none;
    }
    
    .square:hover {
        background: inherit;
    }
    
    .btn:hover {
        background: inherit;
    }
    
    /* Add active states instead */
    .piece:active {
        transform: scale(0.95);
    }
    
    .btn:active {
        transform: scale(0.95);
    }
}

/* ============================================
   FOCUS VISIBLE (keyboard navigation)
   ============================================ */
@media (hover: hover) {
    /* Only show focus rings when using keyboard */
    .btn:focus:not(:focus-visible) {
        outline: none;
    }
}