﻿@import url(fonts.css);

:root {
    /* these will be filled by JS; numbers below are harmless fallbacks */
    --launcher-default-w: 706px; /* content width (≈ 700 + borders fallback) */
    --launcher-default-h: 546px; /* content height (≈ 520 + titlebar + borders fallback) */

    --launcher-default-inner-w: 700px; /* exact inner canvas width after scale */
    --launcher-default-inner-h: 520px; /* exact inner canvas height after scale */
}

/* local body overrides */
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%; /* allow the page to resize with OSK */
    font: 12px/1.2 NotoMono;
    background-color: rgb(60,80,100); /* fallback tone */
    overflow: hidden;
}

#overlay {
    position: fixed;
    visibility: hidden;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(ellipse at center, rgba(50,50,150,.3) 0%, #000000 50%);
    pointer-events: none;
    opacity: 1;
    z-index: 99999;
    mix-blend-mode: screen;
    transition: opacity 3s ease, filter 3s ease;
    transition: background 0.2s ease, filter 0.2s ease;
}

/* prefer dynamic viewport height where supported (Android Chrome, iOS 16+) */
@supports (height: 100dvh) {
    /* only apply dvh while OSK is active to make Android consistently 'push' */
    body.osk-active #desktop {
        height: 100dvh;
    }
}

#desktop {
    visibility: hidden;
    width: 100vw;
    height: 100vh; /* fallback (older browsers) */
    background-color: rgb(160,180,200); /* fallback tone */
    opacity: 0;
    transition: opacity 3s ease, filter 3s ease;
}

    #desktop::after {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        pointer-events: none;
        box-shadow: rgba(0,0,0,0.6) 0px 0px 8px 2px inset;
        z-index: 99999;
    }

.desktop-icon {
    width: 80px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    align-items: center;
    color: white;
    cursor: default;
    user-select: none;
    text-align: center;
    transition: transform 0.1s ease;
    touch-action: none; /* prevents scroll conflicts */
}

    .desktop-icon.selected, .desktop-icon.dragging {
        filter: grayscale(100%) invert(1) brightness(1.2);
    }

.icon-img {
    font-size: 28px;
    margin-bottom: 4px;
    pointer-events: none;
}

    .icon-img.large {
        font-size: 48px;
    }

/* default label: light, slightly raised */
.icon-label {
    background: linear-gradient(to bottom, #ffffff, #f0f3f6);
    color: #111;
    padding: 2px 6px;
    white-space: nowrap;
    text-align: center;
    border: 1px solid #cfd5dc; /* base stroke */
    border-top-color: #e7ebef; /* lighter top edge = bevel */
    border-bottom-color: #b7bec6; /* darker bottom edge = depth */
    border-radius: 0px;
    /* subtle depth */
    box-shadow: inset 0 1px 0 rgba(255,255,255,.85), /* inner top highlight */
    0 1px 1px rgba(0,0,0,.18); /* tiny drop shadow */
    text-shadow: 0 1px 0 rgba(255,255,255,.6); /* crisp on light bg */
    line-height: 1.2; /* keep your spacing */
}

    /* selected: dark, still beveled and legible */
    .icon-label.selected {
        background: linear-gradient(to bottom, #3a4046, #16181b);
        color: #fff;
        border: 1px solid #2b3137;
        border-top-color: #4a5058; /* lighter top */
        border-bottom-color: #0b0d10; /* darker bottom */

        box-shadow: inset 0 1px 0 rgba(255,255,255,.08), /* faint inner highlight */
        0 1px 1px rgba(0,0,0,.25);
        text-shadow: 0 1px 0 rgba(0,0,0,.6); /* keeps white text crisp */
    }

/* launcher */
:root {
    /* these will be filled by JS; numbers below are harmless fallbacks */
    --launcher-default-w: 746px; /* content width (≈ 700 + borders fallback) */
    --launcher-default-h: 546px; /* content height (≈ 520 + titlebar + borders fallback) */

    --launcher-default-inner-w: 700px; /* exact inner canvas width after scale */
    --launcher-default-inner-h: 520px; /* exact inner canvas height after scale */
}

.launcher-window {
    position: absolute;
    display: flex;
    border: 3px solid rgb(200,210,225);
    border-left-color: rgb(175,185,200);
    border-bottom-color: rgb(150,160,175);
    border-radius: 0;
    background: #fff;
    box-shadow: 0 0 4px rgb(0 0 0);
    min-width: 300px;
    min-height: 150px;
    z-index: 30000;
    resize: none;
    flex-direction: column;
    user-select: none;
    width: var(--launcher-default-w);
    height: var(--launcher-default-h);
}

.launcher-titlebar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgb(200,210,225);
    color: #fff;
    padding: 0 4px;
    height: 26px;
    cursor: move;
    user-select: none;
    touch-action: none;
}

/* optional: if a window *does* have a standard body area, it can fill remaining height */
.launcher-body {
    height: calc(100% - 26px);
    overflow: hidden;
    display: block;
}

/* all app windows */
.launcher-window {
    /* allow scrolling normally, but we'll disable during an active resize/drag */
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

    /* while actively resizing/dragging we set this class in JS */
    .launcher-window.wm-gesturing {
        touch-action: none; /* prevents browser panning/zoom while resizing */
    }

    .launcher-window.focused .launcher-titlebar {
        background-color: rgb(0,118,215);
        color: white;
        z-index: 2;
    }

    /* --- touch-friendly resize grabs --- */
    .launcher-window .resize-grab {
      position: absolute;
      pointer-events: auto;
      /* make them finger-sized without being visually intrusive */
      background: transparent; /* keep invisible; add a faint outline if you want */
      touch-action: none;
      /* no cursor on touch; desktop still sees the edge cursors you set in JS */
    }

    /* edges (thicker on touch) */
    .launcher-window .grab-n { top: -6px; left: 16px; right: 16px; height: 18px; }
    .launcher-window .grab-s { bottom: -6px; left: 16px; right: 16px; height: 18px; }
    .launcher-window .grab-w { left: -6px; top: 16px; bottom: 16px; width: 18px; }
    .launcher-window .grab-e { right: -6px; top: 16px; bottom: 16px; width: 18px; }

    /* corners (nice, chunky targets) */
    .launcher-window .grab-nw { left: -6px; top: -6px; width: 24px; height: 24px; }
    .launcher-window .grab-ne { right: -6px; top: -6px; width: 24px; height: 24px; }
    .launcher-window .grab-sw { left: -6px; bottom: -6px; width: 24px; height: 24px; }
    .launcher-window .grab-se { right: -6px; bottom: -6px; width: 24px; height: 24px; }

    /* keep your existing rule; this is what the JS toggles while gesturing */
    .launcher-window.wm-gesturing { touch-action: none; }

.launcher-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 5px;
}

.titlebar-icon {
    display: inline-block;
    object-fit: contain;
    vertical-align: middle;
}

/* button group */
.launcher-buttons {
    display: flex;
    gap: 24px;
    align-items: center;
    margin-left: auto;
    padding-right: 10px;
}

/* shared button styles */
.launcher-maximize, .launcher-close {
    display: flex;
    width: 16px;
    height: 14px;
    border: none;
    cursor: pointer;
    padding: 0;
    align-items: center;
    justify-content: center;
}

    /* pressed state */
    .launcher-close:active, .launcher-maximize:active {
        border: none;
    }

    .launcher-maximize::before {
        content: "🔳"; /* 🖐️ default: maximize */
        display: inline-block;
        font-size: 14px;
        text-align: center;
        line-height: 1;
    }

    .launcher-maximize.maximized::before {
        content: "🔳"; /* ✊ alternate: restore */
    }

    .launcher-close::before {
        content: "❌";
        display: inline-block;
        font-size: 14px;
        text-align: center;
        line-height: 1;
    }

.launcher-toc {
    font-size: 16px;
    align-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

    .launcher-toc::before {
        content: "📚"; /* 📖 📚 📑 */
        display: inline-block;
        font-size: 14px;
        text-align: center;
        line-height: 1;
        user-select: none
    }

    .launcher-toc.disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

/* display of non-html files in app wins */
.text-preview {
    background-color: white;
    color: black;
}

/* icon locking */
.desktop-icon.locked {
    cursor: not-allowed !important;
}

    .desktop-icon.locked .icon-img {
        /*filter: saturate(40%) brightness(0.9);
        opacity: 0.7;*/
    }

/* overlay for locked icons */
.lock-overlay {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 16px;
    pointer-events: none;
    filter: none !important;
    will-change: transform;
    z-index: 10;
}

/* overlay for other icons */
.gen-overlay {
    position: absolute;
    top: 0px;
    right: 40px; /* leave room if lock is also present; tweak if needed */
    font-size: 16px;
    pointer-events: none;
    filter: none !important;
    will-change: transform;
    z-index: 10;
}

.launcher-content {
    flex: 1;
    overflow: auto;
    transition: opacity 1s ease, filter 1s ease;
    backface-visibility: hidden;
    transform: translate3d(0, 0, 0);
}

    .launcher-content iframe {
        width: 100%;
        height: 100%;
        border: none;
    }

    .launcher-content .icon-grid {
        background: white;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        grid-auto-rows: auto;
        gap: 12px;
        padding: 12px;
        box-sizing: border-box;
        align-content: start;
    }

/* touch controls */
:root {
    --action-size: 64px; /* jump/melee/cast */
    --mini-gap: 10px;
    --edge-pad: clamp(16px, 2.5vw, 32px); /* min/max */
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

#touch-ui {
    display: flex; /* stays measurable for layout */
    visibility: hidden; /* not visually shown */
    opacity: 0;
    pointer-events: none; /* no clicks while hidden */
    touch-action: none;
    position: absolute;
    left: calc(env(safe-area-inset-left, 0px) + var(--edge-pad, 0px));
    right: calc(env(safe-area-inset-right, 0px) + var(--edge-pad, 0px));
    flex-direction: column;
    gap: var(--mini-gap, 8px);
    z-index: 999999;
    transition: opacity 150ms ease; /* faster feels snappier on mobile */
}

    #touch-ui.is-active {
        visibility: visible;
        opacity: 1;
        pointer-events: auto; /* buttons work */
    }

/* while interacting with touch UI, desktop icons are inert */
.ui-capture .desktop-icon,
.ui-capture .desktop-window {
    pointer-events: none !important;
}

/* row 1: joystick + action buttons */
.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    gap: var(--mini-gap);
}

#joystick {
    position: relative;
    flex-shrink: 0; /* don't let it shrink */
    margin-right: auto; /* push to far left */
    width: 120px;
    height: 120px;
    background: #d6e2ed;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0px 0px 4px rgb(0,0,0);
    pointer-events: auto;
}

#joystick-dot {
    position: absolute;
    width: 40px;
    height: 40px;
    top: 40px;
    left: 40px;
    background: rgb(255, 255, 255);
    border-radius: 50%;
    box-shadow: 0px 0px 4px rgb(0,0,0);
    pointer-events: none;
    /* emoji centering context */
    display: flex;
    align-items: center;
    justify-content: center;
}

    #joystick-dot::before {
        content: "🎯"; /* 🔴🎯🔘 */
        font-size: 36px;
        line-height: 1;
        pointer-events: none;
    }

/* main column */
.buttons {
    display: flex;
    flex-direction: column;
    gap: var(--mini-gap);
    margin-left: auto; /* keep pinned right */
    pointer-events: auto;
}

/* === ACTION BUTTONS (jump, melee, cast) — unified circle & chrome === */
#jumpSinkBtn, #meleeBtn, #castBtn {
    inline-size: var(--action-size);
    block-size: var(--action-size);
    display: inline-flex; /* CHANGED: give melee the same centering box */
    align-items: center;
    justify-content: center;
    background: #d6e2ed;
    color: white;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0px 0px 4px rgb(0,0,0);
    transition: filter .12s ease, transform .12s ease, box-shadow .12s ease;
}

    /* assign defaults prior to unity updates */
    #jumpSinkBtn:empty::before {
        content: "🦘";
    }

    #meleeBtn:empty::before {
        content: "👊";
    }

#jumpSinkBtn, #meleeBtn {
    font-size: 22px;
}
    /* same emoji scale for both */
    #jumpSinkBtn:active, #meleeBtn:active, #castBtn:active {
        filter: brightness(.85);
        transform: translateY(1px);
        box-shadow: 0 0 2px rgba(0,0,0,.6), inset 0 2px 6px rgba(0,0,0,.5);
    }


/* cast controls */
.cast-wrap {
    position: relative;
    display: inline-block;
}

/* cast button: show emoji + number badge */
#castBtn {
    inline-size: var(--action-size);
    block-size: var(--action-size);
    position: relative;
    display: grid;
    place-items: center;
    line-height: 1;
    background: #d6e2ed;
    color: white;
    font-size: 18px;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0px 0px 4px rgb(0,0,0);
    isolation: isolate; /* so z-index:-1 stays behind only this button */
    overflow: visible; /* let the badge poke out below */
    transition: filter .12s ease, transform .12s ease, box-shadow .12s ease;
}
    /* emoji (center) */
    #castBtn::before {
        content: attr(data-emoji);
        font-size: 22px; /* tweak to taste */
        filter: drop-shadow(0 1px 0 rgba(0,0,0,.25));
    }

    /* number badge tucked under the button */
    #castBtn::after {
        content: attr(data-num);
        position: absolute;
        left: 50%;
        bottom: 1px;
        transform: translateX(-50%);
        height: 18px;
        color: white;
        font: 700 12px/18px NotoMono;
    }

/* row 2: chat input */
.chat-row {
    width: 100%;
    display: flex;
    justify-content: center;
    padding-bottom: 3%;
    pointer-events: auto;
}

/* map autosuggest list */
/* container */
#as-overlay{
  position: fixed;
  display: none;
  max-height: 50vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: rgb(1,36,86);
  border: 2px solid rgb(200,210,225);
  border-radius: 0;
  box-shadow: 0 0 4px rgb(0,0,0);
  box-sizing: border-box;
}

    /* list + rows */
    #as-overlay ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    #as-overlay li {
        padding: 0 8px;
        cursor: pointer;
        line-height: 1.1;
    }

        /* zebra; hover/active override */
        #as-overlay li:nth-child(odd) {
            background: rgba(255,255,255,0.03);
            border-bottom: 2px dashed rgb(0,150,100);
            border-top: 2px dashed rgb(0,150,100);
        }

        #as-overlay li:nth-child(even) {
            background: rgba(0,0,0,0.00);
        }

        #as-overlay li:hover {
            background: rgba(255,255,255,.06);
        }

        #as-overlay li.as-active {
            background: rgba(255,255,255,.12) !important;
        }

    /* row layout + bits */
    #as-overlay .result-row {
        display: flex;
        align-items: center;
        margin: 0;
        gap: .5rem;
        font-size: 13px;
    }

    #as-overlay .label {
        flex: 1 1 auto;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: rgb(0,255,255);
    }

    #as-overlay .pill {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        padding: 8px 16px;
        background: rgba(0,0,0,.3);
        color: rgb(0,255,0);
        border: 1px solid white;
        line-height: 1;
        font-size: 12px;
    }

/* prevent hilighting on select */
:focus {
    outline: none !important;
    -webkit-touch-callout: none;
    -webkit-text-size-adjust: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}