/* Word Games - Responsive No-Scroll Layout */

* {
    box-sizing: border-box;
}

/* Prevent iOS bounce/scroll issues - for game pages */
html, body {
    height: 100%;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Allow scrolling on archive/hub page - override the above */
html.word-games-hub-html,
body.word-games-hub,
body.post-type-archive-word_game {
    height: auto !important;
    overflow: visible !important;
    overflow-y: auto !important;
    position: static !important;
    width: auto !important;
}

/* Full viewport game container */
.word-game-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    /* Fallback for older browsers */
    height: 100vh;
    /* iOS Safari fix */
    height: -webkit-fill-available;
    /* Modern browsers - dynamic viewport height accounts for browser chrome */
    height: 100dvh;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    z-index: 9999;
    /* Ensure content doesn't go behind iOS home indicator */
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Minimal header */
.game-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    height: 50px;
    position: relative;
    z-index: 1000;
}

.game-header__left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.game-header__back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: #666;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    /* Override theme link styles */
    background-image: none !important;
    animation: none !important;
    border: 2px solid transparent;
}

.game-header__back:hover {
    background: transparent;
    background-image: none !important;
    color: #333;
    border-color: #ccc;
}

.game-header__back svg {
    width: 20px;
    height: 20px;
}

.game-header__title {
    font-size: 1rem;
    font-weight: 700;
    color: #111;
    margin: 0;
}

.game-header__actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: -2px;
}

/* Account Button */
.account-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.account-btn .account-level {
    font-size: 0.65rem;
    font-weight: 700;
    color: #6366f1;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    min-width: 32px;
    text-align: center;
}

.account-btn .account-level:empty {
    display: none;
}

.game-header__btn {
    background: none;
    border: none;
    padding: 0.4rem;
    cursor: pointer;
    color: #666;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-header__btn:hover {
    background: #f0f0f0;
    color: #333;
}

.game-header__btn svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* Language Selector */
.language-selector {
    position: relative;
    margin-left: 0.5rem;
}

.lang-current {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    color: #666;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.lang-current:hover {
    background: #f5f5f5;
    border-color: #ccc;
    color: #333;
}

.lang-flag {
    font-size: 1rem;
    line-height: 1;
}

.lang-code {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lang-arrow {
    opacity: 0.6;
    transition: transform 0.2s ease;
}

.language-selector.open .lang-arrow {
    transform: rotate(180deg);
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    min-width: 140px;
    z-index: 1001;
    overflow: hidden;
}

.language-selector.open .lang-dropdown {
    display: block;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: #333;
    transition: background 0.15s ease;
}

.lang-option:hover {
    background: #f5f5f5;
}

.lang-option.active {
    background: #e8f0fe;
    color: #1a73e8;
}

.lang-option .lang-flag {
    font-size: 1.1rem;
}

.lang-option .lang-name {
    flex: 1;
}

/* Main game area - fills remaining space */
.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Use stretch to ensure game takes full width during overlays */
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    gap: 0;
    min-height: 0;
    overflow: hidden;
}

/* Game Hub / Archive Styles */
.game-hub-wrapper {
    min-height: 100vh;
    background: #fafafa;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.game-hub-header {
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    padding: 2rem 1rem;
    text-align: center;
}

.game-hub-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #111;
    margin: 0 0 0.5rem 0;
}

.game-hub-header p {
    color: #666;
    margin: 0;
    font-size: 1rem;
}

.game-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Game Card - Apple TV style 3D effect */
.game-card,
.game-card:link,
.game-card:visited,
.game-card:hover,
.game-card:active,
.game-card:focus {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-decoration: none !important;
    color: #111 !important;
    display: block;
    border: 1px solid #e5e5e5;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    outline: none;
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1),
                box-shadow 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    will-change: transform, box-shadow;
    position: relative;
}

.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow:
        0 20px 40px rgba(0,0,0,0.15),
        0 10px 20px rgba(0,0,0,0.1),
        0 0 0 1px rgba(0,0,0,0.05);
}

.game-card:active {
    transform: translateY(-4px) scale(1.01);
    box-shadow:
        0 10px 20px rgba(0,0,0,0.12),
        0 5px 10px rgba(0,0,0,0.08);
    transition-duration: 0.1s;
}

.game-card:focus {
    box-shadow:
        0 0 0 3px rgba(59, 130, 246, 0.5),
        0 20px 40px rgba(0,0,0,0.15);
}

/* Shine effect on hover */
.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        120deg,
        transparent 0%,
        rgba(255,255,255,0.1) 50%,
        transparent 100%
    );
    transition: left 0.6s ease;
    pointer-events: none;
    z-index: 1;
}

.game-card:hover::before {
    left: 100%;
}

.game-card__image {
    aspect-ratio: 16/10;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none;
}

.game-card:hover .game-card__image {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.game-card__icon {
    font-size: 3rem;
}

.game-card__content {
    padding: 1.25rem;
}

.game-card__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111;
    margin: 0 0 0.5rem 0;
}

.game-card__desc {
    font-size: 0.875rem;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

.game-card__play {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff !important;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
}

.game-card__play svg {
    stroke: #fff;
}

/* Override Ohio theme link underline animation */
.game-hub-grid .game-card:hover,
.game-hub-grid .game-card.-dashed,
.links-underline .game-card:hover,
.links-underline .game-card.-dashed {
    background-image: none !important;
    animation: none !important;
}

.game-card:hover {
    background-image: none !important;
}

/* Modal/Overlay styles - z-index 50000 to ensure modals are above all game overlays */
.game-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.game-modal.active {
    opacity: 1;
    visibility: visible;
}

.game-modal__content {
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.game-modal.active .game-modal__content {
    transform: scale(1);
}

.game-modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

/* Toast notifications */
.game-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: calc(100% - 2rem);
    max-width: 400px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
    z-index: 10001;
    border: 2px solid rgba(99, 102, 241, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 20px rgba(99, 102, 241, 0.2);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.game-toast.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .game-header {
        padding: 0.5rem 0.75rem;
        height: 50px;
    }

    .game-header__title {
        font-size: 1rem;
    }

    .game-container {
        padding: 0.5rem;
        gap: 0.75rem;
    }

    .game-hub-grid {
        padding: 0.75rem;
        gap: 0.75rem;
        grid-template-columns: repeat(2, 1fr);
    }

    .game-hub-header {
        padding: 1.5rem 1rem;
    }

    .game-hub-header h1 {
        font-size: 1.5rem;
    }

    .game-card__content {
        padding: 0.75rem;
    }

    .game-card__title {
        font-size: 1rem;
    }

    .game-card__desc {
        font-size: 0.75rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .game-card__play {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    .game-card__icon {
        font-size: 2.5rem;
    }

    .game-card__image {
        aspect-ratio: 16/9;
    }
}

/* Landscape phone optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .game-header {
        height: 44px;
        padding: 0.25rem 0.75rem;
    }

    .game-container {
        flex-direction: row;
        padding: 0.5rem;
    }
}

/* Dark mode - matches device theme */
@media (prefers-color-scheme: dark) {
    .word-game-wrapper {
        background: #0f0f0f;
    }

    .game-header {
        background: #1a1a2e;
        border-bottom-color: #2d2d44;
    }

    .game-header__title {
        color: #f0f0f0;
    }

    .game-header__back {
        color: #9ca3af;
    }

    .game-header__back:hover {
        background: #2d2d44;
        color: #f0f0f0;
    }

    .game-header__btn {
        color: #9ca3af;
    }

    .game-header__btn:hover {
        background: #2d2d44;
        color: #f0f0f0;
    }

    .account-btn .account-level {
        color: #a5b4fc;
        background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(139, 92, 246, 0.25) 100%);
        border-color: rgba(99, 102, 241, 0.4);
    }

    /* Language Selector Dark Mode */
    .lang-current {
        background: rgba(255,255,255,0.05);
        border-color: rgba(255,255,255,0.15);
        color: #9ca3af;
    }

    .lang-current:hover {
        background: rgba(255,255,255,0.1);
        border-color: rgba(255,255,255,0.25);
        color: #f0f0f0;
    }

    .lang-dropdown {
        background: #1a1a2e;
        border-color: #2d2d44;
        box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    }

    .lang-option {
        color: #d1d5db;
    }

    .lang-option:hover {
        background: rgba(255,255,255,0.08);
    }

    .lang-option.active {
        background: rgba(99, 102, 241, 0.2);
        color: #a5b4fc;
    }

    .game-modal {
        background: rgba(0, 0, 0, 0.7);
    }

    .game-toast {
        background: #2d2d44;
        color: #f0f0f0;
    }

    /* Game hub dark mode */
    .game-hub-wrapper {
        background: #0f0f0f;
    }

    .game-hub-header {
        background: #1a1a2e;
        border-bottom-color: #2d2d44;
    }

    .game-hub-header h1 {
        color: #f0f0f0;
    }

    .game-hub-header p {
        color: #9ca3af;
    }

    .game-card,
    .game-card:link,
    .game-card:visited,
    .game-card:hover,
    .game-card:active,
    .game-card:focus {
        background: #1a1a2e;
        border-color: #2d2d44;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        color: #f0f0f0 !important;
        text-decoration: none !important;
    }

    .game-card:hover {
        box-shadow:
            0 20px 40px rgba(0,0,0,0.4),
            0 10px 20px rgba(0,0,0,0.3),
            0 0 0 1px rgba(255,255,255,0.05);
    }

    .game-card:active {
        box-shadow:
            0 10px 20px rgba(0,0,0,0.35),
            0 5px 10px rgba(0,0,0,0.25);
    }

    .game-card:focus {
        box-shadow:
            0 0 0 3px rgba(59, 130, 246, 0.5),
            0 20px 40px rgba(0,0,0,0.4);
    }

    .game-card::before {
        background: linear-gradient(
            120deg,
            transparent 0%,
            rgba(255,255,255,0.05) 50%,
            transparent 100%
        );
    }

    .game-card__image {
        background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    }

    .game-card__title {
        color: #f0f0f0;
    }

    .game-card__desc {
        color: #9ca3af;
    }

    .game-card__play {
        background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    }
}

/* ==========================================
   COMING SOON CARD
   ========================================== */

.coming-soon-card {
    cursor: default;
    opacity: 0.85;
    position: relative;
    overflow: hidden;
}

.coming-soon-card:hover {
    transform: translateY(-4px) !important;
    opacity: 1;
}

.coming-soon-card .game-card__image {
    position: relative;
}

.coming-soon-icon {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.coming-soon-sparkles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.coming-soon-sparkles .sparkle {
    position: absolute;
    font-size: 1rem;
    animation: sparkle 2s ease-in-out infinite;
    opacity: 0;
}

.coming-soon-sparkles .sparkle:nth-child(1) {
    top: 20%;
    left: 20%;
    animation-delay: 0s;
}

.coming-soon-sparkles .sparkle:nth-child(2) {
    top: 30%;
    right: 25%;
    animation-delay: 0.7s;
}

.coming-soon-sparkles .sparkle:nth-child(3) {
    bottom: 25%;
    left: 35%;
    animation-delay: 1.4s;
}

@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0.5) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1) rotate(180deg);
    }
}

.coming-soon-badge {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%) !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: #48bb78;
    border-radius: 50%;
    animation: pulse-green 2s ease-in-out infinite;
}

@keyframes pulse-green {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(72, 187, 120, 0.7);
    }
    50% {
        opacity: 0.8;
        box-shadow: 0 0 0 6px rgba(72, 187, 120, 0);
    }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .coming-soon-card {
        border-color: #374151;
    }
    
    .coming-soon-badge {
        background: linear-gradient(135deg, #374151 0%, #1f2937 100%) !important;
    }
}

/* ==========================================
   GAME CARD WITH SCREENSHOT IMAGE
   ========================================== */

.game-card__image--screenshot {
    position: relative;
}

.game-card__image--screenshot::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to top, rgba(0,0,0,0.4) 0%, transparent 100%);
    pointer-events: none;
}

.game-card:hover .game-card__image--screenshot {
    transform: scale(1.05);
}
