/* /css/mobile.css — phone fit + touch tap targets.
 *
 * HEROEZ is POINTER-NATIVE: you tap cards, heroes and buttons. There is no
 * virtual stick and no control overlay — the whole job here is (a) making the
 * board fit a phone screen and (b) making every hotspot big enough for a thumb.
 *
 * ORIENTATION NOTE (2026-07-26). This game is NOT gated to landscape, and that
 * is deliberate. Its playfield is a vertical stack — opponent hand, opponent
 * board, message bar, player board, player hand — that needs about 640 CSS px
 * of HEIGHT and only ~360 px of width (the boards and hands scroll sideways).
 * Measured at 844x390 landscape, 0 of 5 hand cards were on screen at all; at
 * 390x844 portrait everything fits with room to spare. The playfield's natural
 * aspect is roughly 0.55:1 — portrait-shaped. So the gate points the other way:
 * see the "turn your phone upright" gate in js/touchFit.js.
 *
 * Loaded LAST so it can override the desktop sheets. Nothing here applies above
 * 900px, so the desktop layout is untouched.
 */

/* ------------------------------------------------------------- tap targets */
/* 44 CSS px minimum on the shortest side, measured at a 390x844 viewport.
 * These apply at every width: a bigger button hurts nobody on desktop. */

#end-turn-button {
    min-height: 48px;
    min-width: 110px;
}

#forfeit-button,
#pause-button {
    min-height: 44px;
    min-width: 44px;
}

.select-hero-button,
.select-deck-button,
#confirm-mulligan-button,
#settings-back-button,
.deck-editor-controls button,
.deck-editor-controls select,
.deck-editor-controls input {
    min-height: 44px;
}

.toggle-switch {
    /* The switch itself stays 50x26 visually; the hit area grows underneath it. */
    height: 44px;
    border-radius: 22px;
    background-clip: content-box;
    padding: 9px 0;
    box-sizing: border-box;
}
.toggle-switch::before {
    top: 11px;
}
.volume-slider {
    height: 44px;
    background-clip: content-box;
    padding: 18px 0;
    box-sizing: border-box;
    /* A range input needs the gesture; the page-wide lock must not eat it. */
    touch-action: none;
}

/* --------------------------------------------------- gesture pass-throughs */
/* lockViewport() puts `touch-action: none` on <body> to kill pinch and
 * double-tap zoom. Everything that legitimately scrolls has to opt back in. */

.hand,
.board,
#mulligan-hand-container {
    touch-action: pan-x;
}

#message-log-content,
#message-log-panel,
.card-list-container,
.deck-editor-main,
#hero-selection-screen,
#hero-options-container,
#deck-selection-screen,
#deck-editor-screen,
#settings-screen,
#pause-overlay,
#mulligan-overlay {
    touch-action: pan-y;
}

/* ---------------------------------------------------------- the pause menu */
/* Mid-match there was previously no way to reach the options at all — mute
 * lived only on the opening menu. On a phone that is a dead end. */

#forfeit-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

#pause-button {
    padding: 8px 14px;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #3a4a63;
    color: white;
    opacity: 0.85;
}
#pause-button:hover {
    opacity: 1;
    background-color: #4a5e7d;
}

#pause-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 2400;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}
#pause-overlay.hidden {
    display: none !important;
}

.pause-panel {
    background: linear-gradient(to bottom right, #4a6b96, #7890b3);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    padding: 24px 28px;
    color: white;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    width: min(320px, 100%);
    max-height: 100%;
    overflow-y: auto;
}

.pause-panel h2 {
    margin: 0 0 6px 0;
    font-size: 1.8em;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.pause-hint {
    margin: 0 0 4px 0;
    font-size: 0.85em;
    opacity: 0.85;
    line-height: 1.35;
}

.pause-button {
    min-height: 48px;
    padding: 12px 18px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.25);
    color: white;
    transition: background-color 0.2s ease;
}
.pause-button:hover {
    background-color: rgba(255, 255, 255, 0.25);
}
.pause-button.pause-danger {
    background-color: rgba(200, 40, 40, 0.55);
    border-color: rgba(255, 170, 170, 0.8);
}

/* The battle log is a permanent side panel on desktop, so there is nothing to
 * open there. It only becomes a drawer on a narrow screen. */
#pause-log {
    display: none;
}

/* ----------------------------------------------------------- intro prompt */

#intro-prompt {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
    margin: 0;
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: rgba(255, 255, 255, 0.92);
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px black;
    pointer-events: none;
    animation: heroez-prompt-pulse 2.2s ease-in-out infinite;
}
@keyframes heroez-prompt-pulse {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    #intro-prompt { animation: none; }
}

/* -------------------------------------------------------- the upright gate */

.heroez-rotate-gate {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: none;
    place-items: center;
    background: #07080c;
    color: rgba(255, 255, 255, 0.85);
    text-align: center;
    padding: 24px;
    font-family: system-ui, sans-serif;
}
.heroez-rotate-gate.is-on {
    display: grid;
}
.heroez-rotate-inner {
    max-width: 22ch;
}
.heroez-rotate-icon {
    font-size: 56px;
    line-height: 1;
    margin-bottom: 14px;
    animation: heroez-rotate-hint 2.4s ease-in-out infinite;
}
.heroez-rotate-gate p {
    font-size: 16px;
    margin: 0;
}
@keyframes heroez-rotate-hint {
    0%, 60%, 100% { transform: rotate(0deg); }
    30% { transform: rotate(-90deg); }
}
@media (prefers-reduced-motion: reduce) {
    .heroez-rotate-icon { animation: none; }
}

/* ------------------------------------------------------ touch-only tweaks */
/* Hover effects that lift a card leave it stuck "lifted" after a tap on a
 * phone, because there is no mouseout. Turn them off when the hands are the
 * input device (js/touchFit.js sets data-input-device on <html>). */

html[data-input-device="touch"] .hero-option:hover,
html[data-input-device="touch"] .deck-option:hover,
html[data-input-device="touch"] #mulligan-hand-container .card:hover,
html[data-input-device="touch"] .card:hover {
    transform: none;
}

/* ============================================================ NARROW FIT ==
 * Everything below only applies to a phone-width viewport. */

@media (max-width: 900px) {
    body {
        margin: 0;
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
        min-height: 100dvh;
        overflow: hidden;
    }

    #game-container {
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: none;
        border: none;
        border-radius: 0;
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-sizing: border-box;
    }

    /* The 250px battle-log column is a desktop affordance. On a 390px phone it
     * ate two thirds of the width and squeezed the whole board into a 120px
     * strip. Here it becomes a drawer the pause menu opens. */
    #message-log-panel {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: min(86%, 320px);
        z-index: 1200;
        transform: translateX(101%);
        transition: transform 0.25s ease;
        box-shadow: -4px 0 16px rgba(0, 0, 0, 0.4);
    }
    #message-log-panel.log-open {
        transform: none;
    }
    #pause-log {
        display: block;
    }

    /* Compact the vertical stack so both hands and both boards fit at 844px —
     * and still very nearly fit on a 667px-tall phone. */
    .player-area {
        padding: 6px;
        min-height: 0;
        /* Keep the boards and hands clear of the absolutely-positioned hero
         * panel on the left, so no card is stranded underneath it. */
        padding-left: 88px;
    }
    .board {
        height: 148px;
        min-height: 148px;
        margin: 6px 0;
        gap: 6px;
        justify-content: flex-start;
    }
    .hand {
        height: 138px;
        gap: 6px;
        justify-content: flex-start;
    }

    /* On a phone the two corner buttons sat on top of the hands — End Turn over
     * the player's cards (badly, on a 640px-tall phone) and Forfeit over the
     * opponent's. So on a narrow screen End Turn moves onto the divider between
     * the two halves, where it covers nothing but the boards' empty margins,
     * and the top-right keeps only the 44px pause button.
     *
     * Forfeit is HIDDEN here rather than moved: it already lives in the pause
     * menu as "Forfeit Match", and a one-tap match-ending button under a
     * player's thumb is a mis-tap waiting to happen. */
    #game-controls {
        top: 50%;
        bottom: auto;
        right: 6px;
        transform: translateY(-50%);
    }
    #end-turn-button {
        margin-bottom: 0;
    }
    #forfeit-button {
        display: none;
    }
    #player-hand {
        padding-right: 6px;
    }

    /* The opponent's hand is a row of blank card backs — its only information
     * is how many there are. Shrink it on a phone: it clears the pause button
     * above it and hands ~40px of height back to the boards. Debug mode, which
     * reveals those cards, keeps them full size. */
    #opponent-hand {
        height: 96px;
        padding-right: 56px;
        align-items: flex-end;
    }
    #opponent-hand .card:not(.debug-visible) {
        width: 56px;
        height: 84px;
    }

    /* A slimmer hero panel: still a 78px-wide tap target, well over 44. */
    .hero-info {
        min-width: 0;
        width: 78px;
        padding: 5px 3px;
        gap: 2px;
        font-size: 11px;
        left: 5px;
    }
    #opponent-area .hero-info {
        top: 5px;
    }
    #player-area .hero-info {
        bottom: 5px;
    }
    .hero-portrait {
        width: 40px;
        height: 40px;
        margin-bottom: 0;
    }
    .hero-health {
        font-size: 1em;
    }
    .mana-container {
        flex-wrap: wrap;
        justify-content: center;
        height: auto;
        max-height: 28px;
        gap: 2px;
    }
    .mana-crystal {
        width: 11px;
        height: 11px;
        border-width: 2px;
    }
    .hero-draw-pile,
    .hero-discard-pile {
        font-size: 0.72em;
    }

    #center-display-area {
        height: 34px;
        /* Right padding keeps the message clear of the End Turn button, which
         * now sits on this divider. */
        padding: 4px 118px 4px 8px;
        gap: 8px;
    }
    #message-area,
    #turn-counter-display {
        font-size: 0.85em;
    }
    #turn-counter-display {
        flex-shrink: 0;
    }

    /* Card zoom must not overflow a narrow screen. */
    #card-zoom-container {
        width: min(240px, 86vw);
        height: min(360px, 62vh);
    }

    /* Pre-game screens: stack, scroll, and keep the buttons reachable. */
    #hero-selection-screen,
    #deck-selection-screen {
        padding: 16px 12px;
        justify-content: flex-start;
        overflow-y: auto;
    }
    #hero-selection-screen h2,
    #deck-selection-screen h2 {
        font-size: 1.7em;
        margin-bottom: 16px;
    }
    #hero-options-container,
    #deck-options-container {
        gap: 14px;
        width: 100%;
    }
    .hero-option {
        width: 100%;
        max-width: 320px;
        height: auto;
        padding: 12px;
    }
    .hero-option .hero-portrait {
        width: 72px;
        height: 72px;
        margin-bottom: 8px;
    }
    .hero-description {
        max-height: none;
    }
    .deck-option {
        width: 100%;
        max-width: 320px;
        padding: 16px;
    }

    .menu-button {
        padding: 14px 28px;
        font-size: 1.4em;
        margin: 8px;
        min-width: 220px;
    }

    #mulligan-overlay {
        padding: 12px;
    }
    #mulligan-overlay h2 {
        font-size: 1.6em;
        margin-bottom: 10px;
    }
    #mulligan-instructions {
        font-size: 0.95em;
        margin-bottom: 14px;
    }
    #mulligan-hand-container {
        gap: 8px;
        margin-bottom: 18px;
        max-width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
        padding: 8px 2px;
        flex-shrink: 0;
    }

    #settings-screen {
        width: calc(100% - 24px);
        padding: 20px 16px;
    }
    #settings-screen h2 {
        font-size: 1.8em;
        margin-bottom: 14px;
    }
    .setting-item {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Deck editor: a two-column desktop tool. Stack it. */
    #deck-editor-screen {
        padding: 10px;
        overflow: hidden;
    }
    .deck-editor-header {
        margin-bottom: 8px;
        padding-bottom: 8px;
        gap: 8px;
    }
    .deck-editor-header h2 {
        font-size: 1.2em;
        margin: 0;
    }
    .deck-editor-controls {
        gap: 6px;
    }
    #deck-editor-card-count {
        margin-left: 0;
        font-size: 1em;
    }
    .deck-editor-main {
        flex-direction: column;
        gap: 8px;
    }
    .card-list-container {
        padding: 8px;
        gap: 6px;
        min-height: 0;
    }

    #game-over-overlay h2 {
        font-size: 2em;
        padding: 0 16px;
    }
}
