/**
 * Veggie Vendetta - Game Styles
 *
 * Physics-based slingshot puzzle game styling
 * Mobile-first, responsive design with light/dark theme support
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

.veggie-vendetta {
    /* Game-specific colors */
    --vv-bg-game: #87ceeb;
    --vv-bg-game-dark: #1a3a4a;
    --vv-ground: #8b5a2b;
    --vv-ground-dark: #5a3a1b;
    --vv-grass: #228b22;
    --vv-wood: #cd853f;
    --vv-stone: #708090;
    --vv-accent: #ff6b35;
    --vv-accent-hover: #ff5722;
    --vv-star-gold: #ffd700;
    --vv-star-empty: #ccc;

    /* Vegetable colors */
    --vv-carrot: #ff7f00;
    --vv-tomato: #ff4444;
    --vv-onion: #9b59b6;
    --vv-pumpkin: #ff8c00;

    /* UI colors */
    --vv-overlay-bg: rgba(0, 0, 0, 0.7);
    --vv-btn-primary-bg: var(--vv-accent);
    --vv-btn-primary-text: #fff;
    --vv-btn-secondary-bg: #4a5568;
    --vv-btn-secondary-text: #fff;

    /* Sizes */
    --vv-canvas-max-width: 900px;
    --vv-canvas-aspect-ratio: 16 / 9;
    --vv-hud-height: 48px;
    --vv-veggie-queue-height: 60px;
}

[data-theme="dark"] .veggie-vendetta {
    --vv-bg-game: var(--vv-bg-game-dark);
    --vv-star-empty: #555;
    --vv-btn-secondary-bg: #2d3748;
}

/* ==========================================================================
   Container
   ========================================================================== */

.app-container.vv-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0;
}

.veggie-vendetta {
    position: relative;
    width: 100%;
    max-width: var(--vv-canvas-max-width);
    margin: 0 auto;
    background-color: var(--vv-bg-game);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Screen reader only status */
.vv-sr-status {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Screens
   ========================================================================== */

.vv-screen {
    width: 100%;
    min-height: 400px;
}

/* Title Screen */
.vv-title-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    min-height: 450px;
    background: linear-gradient(180deg, #87ceeb 0%, #98d8ef 50%, #c8e6c9 100%);
}

[data-theme="dark"] .vv-title-screen {
    background: linear-gradient(180deg, #1a3a4a 0%, #1e4d5a 50%, #1a3a2a 100%);
}

.vv-title-content {
    max-width: 400px;
}

.vv-game-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--vv-accent);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 0.5rem;
}

.vv-game-tagline {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 2rem;
    opacity: 0.9;
}

.vv-title-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.vv-title-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Level Select Screen */
.vv-level-select {
    padding: 1rem;
}

.vv-level-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
}

.vv-level-header h2 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--text-primary);
}

.vv-total-stars {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--vv-star-gold);
}

.vv-star-icon {
    font-size: 1.4rem;
}

.vv-levels-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
    max-width: 500px;
    margin: 0 auto;
}

.vv-level-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    padding: 0.5rem;
    background: linear-gradient(145deg, #fff, #f0f0f0);
    border: 2px solid var(--vv-accent);
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

[data-theme="dark"] .vv-level-btn {
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
}

.vv-level-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.vv-level-btn:focus-visible {
    outline: 3px solid var(--vv-accent);
    outline-offset: 2px;
}

.vv-level-btn.locked {
    background: #ccc;
    border-color: #999;
    cursor: not-allowed;
    opacity: 0.7;
}

[data-theme="dark"] .vv-level-btn.locked {
    background: #444;
    border-color: #666;
}

.vv-level-btn.locked .vv-level-number,
.vv-level-btn.locked .vv-level-stars {
    display: none;
}

.vv-level-btn:not(.locked) .vv-lock-icon {
    display: none;
}

.vv-level-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--vv-accent);
}

.vv-level-stars {
    display: flex;
    gap: 2px;
    font-size: 0.9rem;
}

.vv-level-stars .vv-star {
    color: var(--vv-star-empty);
}

.vv-level-stars .vv-star.filled {
    color: var(--vv-star-gold);
}

.vv-lock-icon {
    font-size: 1.5rem;
    opacity: 0.5;
}

/* Game Screen */
.vv-game-screen {
    display: flex;
    flex-direction: column;
    min-height: auto;
}

/* HUD */
.vv-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--vv-hud-height);
    padding: 0 1rem;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
}

.vv-hud-left,
.vv-hud-center,
.vv-hud-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.vv-hud-left {
    flex: 1;
}

.vv-hud-center {
    flex: 1;
    justify-content: center;
}

.vv-hud-right {
    flex: 1;
    justify-content: flex-end;
}

.vv-hud-stars {
    display: flex;
    gap: 4px;
    font-size: 1.5rem;
}

.vv-hud-stars .vv-star {
    color: var(--vv-star-empty);
}

.vv-hud-stars .vv-star.filled {
    color: var(--vv-star-gold);
}

.vv-level-indicator {
    font-weight: 600;
}

.vv-score-label {
    opacity: 0.8;
}

.vv-score-value {
    font-weight: 700;
    font-size: 1.2rem;
}

/* Canvas Container */
.vv-canvas-container {
    position: relative;
    width: 100%;
    aspect-ratio: var(--vv-canvas-aspect-ratio);
    background: var(--vv-bg-game);
    overflow: hidden;
}

#vv-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

#vv-canvas:focus {
    outline: 3px solid var(--vv-accent);
    outline-offset: -3px;
}

/* Vegetable Queue */
.vv-veggie-queue {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: var(--vv-veggie-queue-height);
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.2);
}

.vv-veggie-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    transition: transform 0.2s, opacity 0.3s;
}

.vv-veggie-indicator.active {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.vv-veggie-indicator.used {
    opacity: 0.3;
    transform: scale(0.8);
}

.vv-veggie-indicator.carrot {
    background: var(--vv-carrot);
}

.vv-veggie-indicator.tomato {
    background: var(--vv-tomato);
}

.vv-veggie-indicator.onion {
    background: var(--vv-onion);
}

.vv-veggie-indicator.pumpkin {
    background: var(--vv-pumpkin);
}

/* ==========================================================================
   Overlays
   ========================================================================== */

.vv-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--vv-overlay-bg);
    z-index: 100;
}

.vv-overlay-content {
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    max-width: 90%;
    width: 360px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.vv-overlay-content h2 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.vv-overlay-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Level Complete Stars */
.vv-complete-stars {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.vv-star-large {
    font-size: 3rem;
    color: var(--vv-star-empty);
    transition: color 0.3s, transform 0.3s;
}

.vv-star-large.filled {
    color: var(--vv-star-gold);
    animation: starPop 0.4s ease-out;
}

@keyframes starPop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

/* Score Breakdown */
.vv-score-breakdown {
    margin-bottom: 1.5rem;
    text-align: left;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.vv-score-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.vv-score-row:last-child {
    border-bottom: none;
}

.vv-score-total {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--vv-accent);
}

/* Failed Overlay */
.vv-failed-message {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.vv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.vv-btn:focus-visible {
    outline: 3px solid var(--vv-accent);
    outline-offset: 2px;
}

.vv-btn:active {
    transform: scale(0.98);
}

.vv-btn-primary {
    background: var(--vv-btn-primary-bg);
    color: var(--vv-btn-primary-text);
}

.vv-btn-primary:hover {
    background: var(--vv-accent-hover);
}

.vv-btn-secondary {
    background: var(--vv-btn-secondary-bg);
    color: var(--vv-btn-secondary-text);
}

.vv-btn-secondary:hover {
    background: #5a6778;
}

.vv-btn-large {
    padding: 1rem 2.5rem;
    font-size: 1.25rem;
}

.vv-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-primary);
    transition: background-color 0.2s;
}

.vv-btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

.vv-btn-icon:focus-visible {
    outline: 3px solid var(--vv-accent);
    outline-offset: 2px;
}

.vv-back-btn {
    font-size: 1.5rem;
}

.vv-pause-btn {
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 600px) {
    .vv-game-title {
        font-size: 1.8rem;
    }

    .vv-levels-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.5rem;
    }

    .vv-level-btn {
        border-radius: 8px;
    }

    .vv-level-number {
        font-size: 1.2rem;
    }

    .vv-level-stars {
        font-size: 0.7rem;
    }

    .vv-hud {
        padding: 0 0.5rem;
        font-size: 0.9rem;
    }

    .vv-hud-stars {
        font-size: 1.2rem;
    }

    .vv-overlay-content {
        padding: 1.5rem;
    }

    .vv-star-large {
        font-size: 2.5rem;
    }

    .vv-veggie-queue {
        height: 50px;
    }

    .vv-veggie-indicator {
        width: 32px;
        height: 32px;
        font-size: 1.2rem;
    }
}

/* ==========================================================================
   Help Panel (Modal)
   ========================================================================== */

.help-panel {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4, 1rem);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.help-panel[hidden] {
    display: none;
}

.help-content {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background: var(--color-surface, #fff);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .help-content {
    background: var(--color-surface, #1e1e1e);
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4, 1rem);
    border-bottom: 1px solid var(--color-border, #e5e5e5);
}

[data-theme="dark"] .help-header {
    border-bottom-color: var(--color-border, #333);
}

.help-header h2 {
    margin: 0;
    font-size: var(--font-size-lg, 1.25rem);
    color: var(--color-text, #333);
}

[data-theme="dark"] .help-header h2 {
    color: var(--color-text, #fff);
}

.help-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--color-text-muted, #666);
    font-size: 1.5rem;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.help-close:hover,
.help-close:focus {
    background: var(--color-surface-alt, #f5f5f5);
    color: var(--color-text, #333);
}

[data-theme="dark"] .help-close:hover,
[data-theme="dark"] .help-close:focus {
    background: var(--color-surface-alt, #333);
    color: var(--color-text, #fff);
}

.help-body {
    padding: var(--space-4, 1rem);
}

.help-section {
    margin-bottom: var(--space-4, 1rem);
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    margin: 0 0 var(--space-2, 0.5rem);
    font-size: var(--font-size-base, 1rem);
    color: var(--color-text, #333);
}

[data-theme="dark"] .help-section h3 {
    color: var(--color-text, #fff);
}

.help-section p,
.help-section li {
    margin: 0;
    padding: var(--space-1, 0.25rem) 0;
    font-size: var(--font-size-sm, 0.875rem);
    color: var(--color-text-muted, #666);
    line-height: 1.5;
}

[data-theme="dark"] .help-section p,
[data-theme="dark"] .help-section li {
    color: var(--color-text-muted, #aaa);
}

.help-section ul,
.help-section ol {
    margin: 0;
    padding-left: var(--space-4, 1rem);
}

.help-shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-1, 0.25rem) 0;
}

.help-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 0.25rem 0.5rem;
    background: var(--color-surface-alt, #f5f5f5);
    border: 1px solid var(--color-border, #ddd);
    border-radius: 4px;
    font-family: monospace;
    font-size: var(--font-size-sm, 0.875rem);
    color: var(--color-text, #333);
}

[data-theme="dark"] .help-key {
    background: var(--color-surface-alt, #333);
    border-color: var(--color-border, #444);
    color: var(--color-text, #fff);
}

/* Mobile help panel adjustments */
@media (max-width: 600px) {
    .help-content {
        max-height: calc(100vh - 1rem);
        border-radius: 8px;
    }

    .help-header {
        padding: var(--space-3, 0.75rem);
    }

    .help-body {
        padding: var(--space-3, 0.75rem);
    }

    .help-close {
        width: 44px;
        height: 44px;
    }
}

/* RTL Support */
[dir="rtl"] .veggie-vendetta {
    direction: rtl;
}

[dir="rtl"] .vv-back-btn span {
    transform: scaleX(-1);
}

/* Print - hide game for printing */
@media print {
    .veggie-vendetta {
        display: none;
    }
}
