/* Pixel Runner page integration for SeiboldSoft Blog.
   All selectors are scoped to the runner template to avoid leaking game styles into Publii. */

.runner-page {
    padding-bottom: 32px;
}

.runner-page__header,
.runner-page__content {
    max-width: var(--content-width);
}

.runner-page__header {
    margin: 6px 0 24px;
}

.runner-page__eyebrow {
    margin: 0 0 6px !important;
    color: var(--link-color) !important;
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.runner-page__header h1 {
    margin-top: 0;
}

.runner-page__subtitle {
    max-width: 680px;
    margin-bottom: 0 !important;
    color: var(--muted-color) !important;
    font-size: 1.05rem;
}

.pixel-runner {
    --runner-game-width: 960px;
    --runner-control: var(--primary-color);
    --runner-control-text: var(--primary-text-color);
    width: min(100%, var(--runner-game-width));
    margin: 0 0 32px;
    padding: 12px;
    overflow: hidden;
    border: 1px solid var(--soft-divider);
    border-radius: calc(var(--border-radius) + 6px);
    background: var(--soft-background);
    box-shadow: var(--box-shadow);
}

.pixel-runner,
.pixel-runner *,
.pixel-runner *::before,
.pixel-runner *::after {
    box-sizing: border-box;
}

.pixel-runner .game-shell {
    width: 100%;
    color: var(--text-color);
    user-select: none;
}

.pixel-runner .game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
    padding: 10px 12px;
}

.pixel-runner .game-heading {
    min-width: 0;
}

.pixel-runner .game-title {
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: .01em;
}

.pixel-runner .version-badge {
    display: inline-grid;
    place-items: center;
    margin-left: 5px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--runner-control);
    color: var(--runner-control-text);
    font-size: .72rem;
    font-weight: 900;
    vertical-align: middle;
}

.pixel-runner .game-subtitle,
.pixel-runner .game-help,
.pixel-runner .game-focus-hint {
    color: var(--muted-color);
}

.pixel-runner .game-subtitle {
    margin-top: 2px;
    font-size: .82rem;
}

.pixel-runner .game-actions {
    flex: 0 0 auto;
}

.pixel-runner .game-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--soft-divider);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    color: var(--text-color);
    font: inherit;
    font-size: .88rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease, transform .2s ease;
}

.pixel-runner .game-action-button:hover {
    border-color: var(--primary-color);
    background: var(--background-color);
    transform: translateY(-1px);
}

.pixel-runner .game-help {
    margin: 0 12px 10px;
    font-size: .82rem;
    line-height: 1.45;
}

.pixel-runner .game-stage {
    position: relative;
    min-width: 0;
}

.pixel-runner canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border: 1px solid rgba(15, 23, 42, .22);
    border-radius: calc(var(--border-radius) + 4px);
    background: #77c8ff;
    box-shadow: 0 14px 32px rgba(0, 0, 0, .20);
    image-rendering: pixelated;
    touch-action: none;
}

html[data-theme="dark"] .pixel-runner canvas {
    border-color: rgba(255, 255, 255, .16);
    box-shadow: 0 16px 34px rgba(0, 0, 0, .45);
}

.pixel-runner canvas:focus-visible {
    outline: 3px solid var(--focus-color);
    outline-offset: 4px;
}

.pixel-runner .game-focus-hint {
    margin: 10px 12px 2px;
    font-size: .78rem;
}

.pixel-runner .game-noscript {
    margin: 12px;
    padding: 10px 12px;
    border: 1px solid #c62828;
    border-radius: var(--border-radius);
    background: rgba(198, 40, 40, .08);
}

.pixel-runner .touch-controls {
    display: none;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-top: 12px;
    padding: 0 4px 4px;
    touch-action: none;
}

.pixel-runner .touch-stick {
    width: 136px;
    min-width: 136px;
    display: grid;
    justify-items: center;
    gap: 6px;
    touch-action: none;
}

.pixel-runner .touch-stick-ring {
    position: relative;
    width: 122px;
    height: 122px;
    border: 2px solid rgba(248, 250, 252, .28);
    border-radius: 999px;
    background: rgba(15, 23, 42, .72);
    box-shadow: inset 0 0 28px rgba(15, 23, 42, .55), 0 10px 24px rgba(0, 0, 0, .22);
}

.pixel-runner .touch-stick-ring::before {
    content: "";
    position: absolute;
    inset: 26px;
    border: 1px dashed rgba(248, 250, 252, .24);
    border-radius: inherit;
}

.pixel-runner .touch-stick-knob {
    --stick-x: 0px;
    --stick-y: 0px;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 56px;
    height: 56px;
    border: 2px solid rgba(255, 255, 255, .42);
    border-radius: 999px;
    background: var(--runner-control);
    box-shadow: inset 0 -5px rgba(0, 0, 0, .18), 0 8px 18px rgba(0, 0, 0, .24);
    transform: translate(calc(-50% + var(--stick-x)), calc(-50% + var(--stick-y)));
    transition: transform 80ms ease-out, filter 120ms ease-out;
}

.pixel-runner .touch-stick.is-touched .touch-stick-knob,
.pixel-runner .touch-stick.is-active .touch-stick-knob {
    filter: brightness(1.1);
}

.pixel-runner .touch-stick.is-jump .touch-stick-knob {
    filter: brightness(1.18) saturate(1.12);
    box-shadow: inset 0 -5px rgba(0, 0, 0, .16), 0 0 0 8px rgba(255, 255, 255, .12), 0 10px 20px rgba(0, 0, 0, .26);
}

.pixel-runner .touch-stick.is-crouch .touch-stick-knob {
    filter: brightness(1.05) saturate(.92);
}

.pixel-runner .touch-hint {
    min-height: 16px;
    color: var(--muted-color);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.pixel-runner .touch-actions {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
}

.pixel-runner .touch-button {
    min-width: 118px;
    min-height: 82px;
    padding: 10px 14px;
    border: 2px solid rgba(255, 255, 255, .28);
    border-radius: 999px;
    background: var(--runner-control);
    color: var(--runner-control-text);
    font: inherit;
    font-size: .92rem;
    font-weight: 900;
    letter-spacing: .03em;
    cursor: pointer;
    box-shadow: inset 0 -5px rgba(0, 0, 0, .18), 0 9px 18px rgba(0, 0, 0, .22);
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 80ms ease-out, filter 120ms ease-out;
}

.pixel-runner .touch-button.is-pressed,
.pixel-runner .touch-button:active {
    transform: translateY(2px) scale(.97);
    filter: brightness(1.08);
}

.runner-page__content {
    margin-top: 30px;
    padding-top: 26px;
    border-top: 1px solid var(--soft-divider);
}

.pixel-runner:fullscreen {
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    border: 0;
    border-radius: 0;
    background: #070b12;
    box-shadow: none;
}

.pixel-runner:fullscreen .game-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.pixel-runner:fullscreen .game-header {
    flex: 0 0 auto;
    color: #f8fafc;
}

.pixel-runner:fullscreen .game-title { color: #f8fafc; }
.pixel-runner:fullscreen .game-subtitle,
.pixel-runner:fullscreen .game-help,
.pixel-runner:fullscreen .game-focus-hint { color: #a7b1c2; }

.pixel-runner:fullscreen .game-action-button {
    border-color: rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
    color: #f8fafc;
}

.pixel-runner:fullscreen .game-stage {
    flex: 1 1 auto;
    min-height: 0;
}

.pixel-runner:fullscreen canvas {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 10px;
    box-shadow: none;
    aspect-ratio: auto;
}

@media (hover: none), (pointer: coarse) {
    .pixel-runner .touch-controls {
        display: flex;
    }

    .pixel-runner .game-help {
        display: none;
    }

    .pixel-runner .game-focus-hint {
        display: none;
    }

    .pixel-runner:fullscreen .game-header {
        display: none;
    }

    .pixel-runner:fullscreen .game-stage {
        position: relative;
    }

    .pixel-runner:fullscreen .touch-controls {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 5;
        margin: 0;
        padding: 0 max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
        pointer-events: none;
    }

    .pixel-runner:fullscreen .touch-stick,
    .pixel-runner:fullscreen .touch-actions,
    .pixel-runner:fullscreen .touch-button {
        pointer-events: auto;
    }
}

@media (max-width: 768px) {
    .runner-page {
        padding-right: 4px;
        padding-left: 4px;
    }

    .runner-page__header,
    .runner-page__content {
        padding-right: 6px;
        padding-left: 6px;
    }

    .pixel-runner {
        padding: 8px;
        border-radius: 10px;
    }

    .pixel-runner .game-header {
        gap: 10px;
        padding: 8px 4px;
    }

    .pixel-runner .game-subtitle {
        display: none;
    }

    .pixel-runner .game-action-button {
        padding: 8px 10px;
    }
}

@media (max-width: 560px) and (hover: none), (max-width: 560px) and (pointer: coarse) {
    .pixel-runner .touch-controls {
        gap: 10px;
    }

    .pixel-runner .touch-stick {
        width: 116px;
        min-width: 116px;
    }

    .pixel-runner .touch-stick-ring {
        width: 106px;
        height: 106px;
    }

    .pixel-runner .touch-stick-knob {
        width: 48px;
        height: 48px;
    }

    .pixel-runner .touch-button {
        min-width: 96px;
        min-height: 72px;
        font-size: .82rem;
    }
}

@media (orientation: landscape) and (hover: none), (orientation: landscape) and (pointer: coarse) {
    .pixel-runner:fullscreen .touch-stick {
        width: clamp(122px, 18vw, 160px);
        min-width: clamp(122px, 18vw, 160px);
    }

    .pixel-runner:fullscreen .touch-stick-ring {
        width: clamp(112px, 16vw, 142px);
        height: clamp(112px, 16vw, 142px);
    }

    .pixel-runner:fullscreen .touch-actions {
        width: clamp(108px, 17vw, 154px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .pixel-runner *,
    .pixel-runner *::before,
    .pixel-runner *::after {
        transition-duration: .01ms !important;
    }
}
