/* Field Deck web shell — work in progress.
   The readable portfolio is the default view; the interactive runtime stays
   one click away. The view switch is a game-styled pill after Unleashed's
   PRESS START chrome. */

#portfolio-view-toggle {
    position: fixed;
    top: auto;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    right: 0.75rem;
    z-index: 9991;
    padding: 0.55rem 1.4rem 0.5rem;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #2e2200;
    background: linear-gradient(180deg, #ffe428 0%, #f5c410 55%, #e09e00 100%);
    border: 2px solid rgba(20, 28, 0, 0.75);
    border-radius: 999px;
    box-shadow: 0 0 0 2px rgba(255, 228, 40, 0.28), 0 2px 10px rgba(0, 0, 0, 0.65);
    cursor: pointer;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease;
}

#portfolio-view-toggle.is-idle {
    opacity: 0;
    transform: translateY(calc(100% + 1.25rem));
    pointer-events: none;
}

#portfolio-view-toggle:hover {
    background: linear-gradient(180deg, #fff06a 0%, #ffd83e 55%, #f0b41e 100%);
}

#portfolio-view-toggle:focus-visible {
    outline: 3px solid #eaffd8;
    outline-offset: 3px;
}

#hedgeui-runtime[hidden] {
    display: none;
}

#hedgeui-runtime {
    position: fixed;
    inset: 0;
    z-index: 9990;
    display: block;
    /* The readable stylesheet pads generic sections; this one is a viewport. */
    padding: 0;
    margin: 0;
    background: #000;
}

#work-adventure-touch[hidden] {
    display: none !important;
}

#work-adventure-touch .work-adventure-touch-orientation[hidden],
#work-adventure-touch .work-adventure-touch-controls[hidden] {
    display: none;
}

#work-adventure-touch {
    position: fixed;
    inset: 0;
    z-index: 9990;
    box-sizing: border-box;
    padding: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
    pointer-events: none;
}

#work-adventure-touch.is-portrait {
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 50% 35%, rgba(48, 91, 28, 0.32), rgba(0, 0, 0, 0.96) 66%);
}

#work-adventure-touch .work-adventure-touch-orientation {
    width: min(32rem, 100%);
    box-sizing: border-box;
    padding: clamp(1.25rem, 6vw, 2.5rem);
    text-align: center;
    color: #e9f7df;
    background: rgba(3, 10, 2, 0.92);
    border: 1px solid rgba(141, 235, 89, 0.55);
    border-radius: 1rem;
    box-shadow: 0 1.2rem 4rem rgba(0, 0, 0, 0.72);
    pointer-events: auto;
}

#work-adventure-touch .work-adventure-touch-orientation p {
    margin: 0 0 1.25rem;
    font: 700 clamp(1.1rem, 5vw, 1.5rem)/1.35 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

#work-adventure-touch .work-adventure-touch-controls {
    position: absolute;
    inset: 0;
    box-sizing: border-box;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding-right: max(0.5rem, env(safe-area-inset-right));
    padding-bottom: max(4.5rem, calc(0.75rem + env(safe-area-inset-bottom)));
    padding-left: max(0.5rem, env(safe-area-inset-left));
}

#work-adventure-touch.is-portrait .work-adventure-touch-controls {
    display: none !important;
}

#work-adventure-touch:not(.is-portrait) .work-adventure-touch-controls:not([hidden]) {
    display: flex !important;
}

#work-adventure-touch .work-adventure-touch-dpad,
#work-adventure-touch .work-adventure-touch-actions {
    display: grid;
    gap: 0.45rem;
}

#work-adventure-touch .work-adventure-touch-dpad {
    grid-template-columns: repeat(3, minmax(44px, 4rem));
    grid-template-rows: repeat(3, minmax(44px, 4rem));
}

#work-adventure-touch .work-adventure-touch-actions {
    grid-template-columns: repeat(3, minmax(44px, 4rem));
}

#work-adventure-touch .work-adventure-touch-button.is-up {
    grid-column: 2;
}

#work-adventure-touch .work-adventure-touch-button.is-left {
    grid-column: 1;
    grid-row: 2;
}

#work-adventure-touch .work-adventure-touch-button.is-right {
    grid-column: 3;
    grid-row: 2;
}

#work-adventure-touch .work-adventure-touch-button.is-down {
    grid-column: 2;
    grid-row: 3;
}

#work-adventure-touch button {
    min-width: 44px;
    min-height: 44px;
    box-sizing: border-box;
    padding: 0.55rem 0.8rem;
    font: 700 0.78rem/1 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    letter-spacing: 0.06em;
    color: #202600;
    background: linear-gradient(180deg, #f3ffbf, #a7d958);
    border: 2px solid rgba(231, 255, 205, 0.8);
    border-radius: 0.75rem;
    box-shadow: 0 0.3rem 0.9rem rgba(0, 0, 0, 0.58);
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: auto;
}

#work-adventure-touch button:active:not(:disabled) {
    transform: translateY(1px);
    background: #dffff0;
}

#work-adventure-touch button:disabled {
    opacity: 0.56;
}

#work-adventure-touch button:focus-visible {
    outline: 3px solid #eaffd8;
    outline-offset: 3px;
}

@media (max-height: 360px) and (orientation: landscape) {
    #work-adventure-touch .work-adventure-touch-dpad,
    #work-adventure-touch .work-adventure-touch-actions {
        gap: 0.3rem;
    }

    #work-adventure-touch .work-adventure-touch-dpad {
        grid-template-columns: repeat(3, minmax(40px, 3.4rem));
        grid-template-rows: repeat(3, minmax(40px, 3.4rem));
    }

    #work-adventure-touch .work-adventure-touch-actions {
        grid-template-columns: repeat(3, minmax(40px, 3.4rem));
    }

    #work-adventure-touch button {
        min-width: 40px;
        min-height: 40px;
        padding: 0.4rem 0.55rem;
    }
}

/* Keep the first paint aligned with the default view while the shell checks
   runtime capabilities. */
body:not(.view-decided) #portfolio-readable {
    display: block;
}

body:not(.view-decided) #hedgeui-runtime {
    display: none;
}

/* Script disabled: the readable portfolio is the only working view. */
@media (scripting: none) {
    #portfolio-readable {
        display: block !important;
    }

    #hedgeui-runtime,
    #portfolio-view-toggle {
        display: none !important;
    }
}

#swa-canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #000;
    border: 0;
    touch-action: none;
    overscroll-behavior: contain;
}

@media (max-width: 720px) and (orientation: portrait) {
    #portfolio-view-toggle {
        right: max(0.75rem, env(safe-area-inset-right));
        bottom: max(0.75rem, env(safe-area-inset-bottom));
        max-width: calc(100vw - 1.5rem);
    }
}

/* The runtime is its own visual world: no focus ring on the canvas — it read
   as a white flash on every click. Keyboard users still see the toggle ring. */
#swa-canvas:focus,
#swa-canvas:focus-visible {
    outline: none;
}

/* With the runtime present, the readable page uses the whole window instead
   of a boxed article column. */
#portfolio-readable main:not(.sfr),
#portfolio-readable header > div,
#portfolio-readable .header-inner {
    max-width: min(1400px, 92vw);
}

/* host.js swaps the canvas for a retry button when the runtime fails closed. */
#hedgeui-runtime > button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0.75rem 1.6rem;
    font: 700 0.85rem/1 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #2e2200;
    background: linear-gradient(180deg, #ffe428, #e09e00);
    border: 2px solid rgba(20, 28, 0, 0.75);
    border-radius: 999px;
    cursor: pointer;
}

#hedgeui-status {
    position: absolute;
    bottom: 0.6rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    max-width: calc(100vw - 2rem);
    margin: 0;
    padding: 0.2rem 0.7rem;
    font-size: 0.8rem;
    text-align: center;
    color: #d8e8c8;
    background: rgba(4, 10, 4, 0.6);
    border-radius: 999px;
    opacity: 0.85;
    pointer-events: none;
}

/* NOW LOADING beat between views, after the game's loading screen: black
   scanlined ground, stepped dot ring and the italic label, bottom-right. */
#garage-loading {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 1.1rem;
    padding: 0 3.5rem 2.9rem 0;
    background: #000;
    opacity: 0;
    transition: opacity 0.28s ease;
}

#garage-loading.on {
    opacity: 1;
}

#garage-loading[hidden] {
    display: none;
}

.garage-loading-grid {
    display: grid;
    grid-template-columns: repeat(3, 0.85rem);
    grid-template-rows: repeat(3, 0.85rem);
    gap: 0.18rem;
}

.garage-loading-grid i {
    background: #10310f;
    border: 1px solid rgba(110, 230, 80, 0.35);
    animation: garage-cell-fill 1.35s infinite;
}

.garage-loading-label {
    font: italic 700 1.5rem/1.9rem "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    letter-spacing: 0.08em;
    color: #6ee650;
    text-transform: uppercase;
    text-shadow: 0 0 12px rgba(110, 230, 80, 0.45), 0 2px 0 rgba(0, 0, 0, 0.85);
}

@keyframes garage-cell-fill {
    0%, 88% {
        background: #6ee650;
        box-shadow: 0 0 8px rgba(110, 230, 80, 0.7);
    }
    89%, 100% {
        background: #10310f;
        box-shadow: none;
    }
}


@media (prefers-reduced-motion: reduce) {
    #portfolio-view-toggle {
        transition: none;
    }

    .garage-loading-grid i {
        animation: none;
    }
}

@media (forced-colors: active) {
    #swa-canvas,
    #hedgeui-runtime > button,
    #portfolio-view-toggle {
        border: 1px solid CanvasText;
    }
}
