/* elvi-console.css: Elvi's own operating console (black body, green lines and type, electronic keys) and her hand tray.
   Everything is scoped to html[data-protagonist="elvi"], which renderer.syncProtagonistUi() sets; Liz (the default) never matches and keeps the existing terminal.
   Portrait: touchControls.js paints the chassis, panels and key glyphs on the .ui-native-frame canvas (ELVI_PORTRAIT_META) for PS1-2D, PS1-3D and GB; the real buttons stay
   transparent on top, so this file only adds the pressed / focus states and tints the LCD strips.
   Landscape / keyboard: the existing deck and guide keys are re-skinned here. This sheet loads last and is unlayered, so it wins over the @layer skin rules without !important;
   the layered !important states (aiming red WAIT glow, blue ACTION glow) still win over it, which keeps them intact. */

html[data-protagonist="elvi"] {
  --ec-bg0: #010302; --ec-bg1: #07110b; --ec-panel: #04120a; --ec-line: #27d97a; --ec-dim: #145a35; --ec-hi: #8dffbd; --ec-ink: #bff5d6; --ec-glow: rgb(39 217 122 / 0.35); --ec-lcd: #020a05;
  --key: #06110a;                 /* the GB plain WAIT key reads var(--key) */
  --native-lcd-bg: var(--ec-lcd); /* the portrait HUD strip */
}
html[data-protagonist="elvi"][data-skin="gb"] {
  --ec-bg0: #071207; --ec-bg1: #0c1f0c; --ec-panel: #0f380f; --ec-line: #8bac0f; --ec-dim: #306230; --ec-hi: #9bbc0f; --ec-ink: #9bbc0f; --ec-glow: transparent; --ec-lcd: #0f380f;
}
html[data-protagonist="elvi"], html[data-protagonist="elvi"] body { background: var(--ec-bg0); }

/* ---- keys Elvi does not have: inventory and handset (the hand key reuses the book key's action). !important + the repeated attribute outrank the native-key `display:block !important`. ---- */
html[data-protagonist="elvi"][data-protagonist][data-protagonist] body :is(.ui-deck [data-action="item-list"], .ui-deck [data-action="contact-elvi"], .ui-deck .ui-phone, .ui-guide [data-action="item-list"], .ui-guide [data-guide="item"], .ui-guide [data-guide="contact"], .ui-guide [data-action="contact-elvi"]) { display: none !important; }

/* the normal menu's tab strip has no 所持品 / 呪文書 page for Elvi (renderer redirects those entries to the hand); status / log / settings pages stay */
html[data-protagonist="elvi"][data-protagonist] body #sidebarTabs :is([data-sidebar-tab="ITEM"], [data-sidebar-tab="SPELL"]) { display: none !important; }

/* ---- portrait console: pressed / focus on the transparent native keys, LCD strips in green ---- */
html[data-protagonist="elvi"][data-native-frame]:not([data-inspect="1"]) body .ui-deck [data-native-key]:is(:active, .is-pressed):not(:disabled) { background: color-mix(in srgb, var(--ec-line) 28%, transparent) !important; }
html[data-protagonist="elvi"][data-native-frame]:not([data-inspect="1"]) body .ui-deck [data-native-key]:focus-visible { outline: 2px solid var(--ec-hi); outline-offset: -3px; }
html[data-protagonist="elvi"]:not([data-skin="gb"]) body .ui-rail > .ui-hud :is(.ui-title__main, .ui-title__meta, .ui-gauge__label, .ui-gauge__value, .ui-gauge__value b, .ui-stat__label, .ui-stat__value, .ui-status__item) { color: var(--ec-ink); }
html[data-protagonist="elvi"]:not([data-skin="gb"]) body .ui-rail > .ui-log { color: var(--ec-ink); background: rgb(1 8 4 / 0.9); border-top: 1px solid var(--ec-dim); }

/* ---- landscape / keyboard: the existing deck and guide keys re-skinned as console keys ---- */
html[data-protagonist="elvi"]:not([data-native-frame]) body .ui-deck :is(.ui-dpad__btn, .ui-five, .ui-inspect-key, .ui-map-key),
html[data-protagonist="elvi"] body .ui-guide--field .ui-key {
  background: linear-gradient(180deg, var(--ec-panel), var(--ec-bg0)); color: var(--ec-hi); border: 1px solid var(--ec-line); border-radius: 2px;
  box-shadow: inset 0 0 0 3px var(--ec-bg0), inset 0 0 0 4px var(--ec-dim), 0 0 8px var(--ec-glow); text-shadow: none; filter: none;
}
html[data-protagonist="elvi"]:not([data-native-frame]) body .ui-deck :is(.ui-dpad__btn, .ui-five, .ui-inspect-key, .ui-map-key)::before,
html[data-protagonist="elvi"]:not([data-native-frame]) body .ui-deck :is(.ui-dpad__btn, .ui-five, .ui-inspect-key, .ui-map-key)::after { content: none; }
html[data-protagonist="elvi"]:not([data-native-frame]) body .ui-deck :is(.ui-dpad__btn, .ui-five, .ui-inspect-key, .ui-map-key) { contain: layout; }   /* the key becomes the containing block of its glyph without changing its own positioning */
html[data-protagonist="elvi"]:not([data-native-frame]) body .ui-deck :is(.ui-dpad__btn, .ui-five, .ui-inspect-key, .ui-map-key) > svg.ui-sym { display: block; position: absolute; inset: 0; margin: auto; width: 52%; height: 52%; color: var(--ec-hi); fill: currentColor; stroke: none; pointer-events: none; }
html[data-protagonist="elvi"]:not([data-native-frame]) body .ui-deck .ui-five > svg[data-sym="hand"] { fill: none; }
html[data-protagonist="elvi"] body .ui-guide--field .ui-key :is(kbd, span) { color: inherit; }
html[data-protagonist="elvi"]:not([data-native-frame]) body .ui-deck :is(.ui-dpad__btn, .ui-five, .ui-inspect-key, .ui-map-key):is(:active, .is-pressed):not(:disabled),
html[data-protagonist="elvi"] body .ui-guide--field .ui-key:is(:active, .is-pressed):not(:disabled) { background: var(--ec-line); color: var(--ec-bg0); }
html[data-protagonist="elvi"]:not([data-native-frame]) body .ui-deck :is(.ui-dpad__btn, .ui-five, .ui-inspect-key, .ui-map-key):focus-visible,
html[data-protagonist="elvi"] body .ui-guide--field .ui-key:focus-visible { outline: 2px solid var(--ec-hi); outline-offset: -3px; }
html[data-protagonist="elvi"]:not([data-native-frame]) body .ui-deck :is(.ui-dpad__btn, .ui-five, .ui-inspect-key, .ui-map-key):disabled { opacity: 0.45; }
/* the PS1 plain WAIT key keeps its own layered !important face; the outline makes it a console key too */
html[data-protagonist="elvi"]:not([data-native-frame]) body .ui-deck :is(.ui-dpad__btn[data-dir="wait"], .ui-actions button[data-slot="wait"]) { outline: 1px solid var(--ec-line); outline-offset: -1px; }

/* ======================================================================================================
   HAND TRAY (Elvi). The existing tray (components.css, #actionSidebar[data-hand="1"]) keeps its slide-in, cards, handlers and scrim; here it only gets the console look and a geometry
   that leaves the board visible: portrait = a panel exactly over the key area (below the LCD, so the map / HUD / log stay visible and the keys beneath cannot be pressed: the product
   frame is inert and the scrim catches stray taps), landscape = a right-hand panel. Colour tokens are re-pointed inside the tray so cards, detail and buttons recolour consistently.
   ====================================================================================================== */
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] {
  --c-ground: var(--ec-bg0); --c-surface: var(--ec-panel); --c-surface-2: var(--ec-bg1); --c-ink-1: var(--ec-ink); --c-ink-2: var(--ec-ink); --c-ink-3: var(--ec-dim);
  --c-line: var(--ec-dim); --c-line-soft: var(--ec-dim); --c-line-strong: var(--ec-line); --c-inset-line: var(--ec-dim);
  --c-btn-bg: var(--ec-panel); --c-btn-fg: var(--ec-hi); --c-focus-bg: var(--ec-line); --c-focus-fg: var(--ec-bg0); --c-focus-ring: var(--ec-hi);
  --c-list-bg: transparent; --c-row-bg: var(--ec-panel); --c-row-fg: var(--ec-ink); --c-row-meta: var(--ec-hi); --c-row-focus-bg: var(--ec-line); --c-row-focus-fg: var(--ec-bg0);
  --c-desc-bg: var(--ec-panel); --c-desc-fg: var(--ec-ink); --c-disabled-fg: var(--ec-dim); --c-tag-line: var(--ec-dim);
  --nb-paper-2: var(--ec-panel); --nb-ink: var(--ec-ink); --nb-sheet: none; --nb-ruled: none; --nb-lamp: var(--ec-hi); --nb-pencil-line: var(--ec-dim);
  --hand-h: clamp(236px, calc(100dvh - var(--native-screen-y, 0px) - var(--native-screen-h, 0px) - 12px), 420px);
  background: linear-gradient(180deg, var(--ec-bg1), var(--ec-bg0)); border: 1px solid var(--ec-line); border-radius: 2px; color: var(--ec-ink);
  box-shadow: inset 0 0 0 3px var(--ec-bg0), inset 0 0 0 4px var(--ec-dim), 0 0 14px var(--ec-glow);
  pointer-events: auto;
}
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"][data-hand-state="closing"] { pointer-events: none; }
/* portrait: stays inside the lower (key) area of the console */
@media (orientation: portrait) {
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] { inset: auto calc(var(--safe-r, 0px) + 4px) calc(var(--safe-b, 0px) + 4px) calc(var(--safe-l, 0px) + 4px); height: var(--hand-h); max-height: var(--hand-h); width: auto; padding: 6px 8px 8px; }
}
/* landscape: a right-hand panel, the board stays on the left */
@media (orientation: landscape) {
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] {
    inset: calc(var(--safe-t, 0px) + 6px) calc(var(--safe-r, 0px) + 6px) calc(var(--safe-b, 0px) + 6px) auto; width: clamp(320px, 34vw, 440px); height: auto; max-height: none; padding: 6px 8px 8px;
    --hand-head: 30px; --card-h: clamp(92px, 19dvh, 140px); --card-w: clamp(66px, calc(var(--card-h) * 0.74), 100px);
    grid-template-rows: var(--hand-head) minmax(0, 1fr);
  }
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-menu__body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "list" "detail"; gap: 6px; }
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-menu__body > .ui-list { align-self: start; }
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-menu__body > .ui-detail { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; row-gap: 4px; min-height: 0; }
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-detail__head { grid-column: 1; grid-row: 1; }
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-detail__content { grid-column: 1; grid-row: 2; font-size: 12px; }
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-detail__actions { grid-column: 1; grid-row: 3; flex-direction: row; width: auto; min-width: 0; gap: 6px; }
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-detail__actions .ui-btn,
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-detail__actions > * { flex: 1 1 0; min-width: 0; min-height: 40px; max-height: 48px; padding: 2px 6px; font-size: 13px; }
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .hand-drawer__close { min-height: 28px; height: 28px; }
}
/* header: green type on the console panel */
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] > .ui-menu__head,
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] > .ui-menu__head :is(.ui-title, .ui-title__en, .ui-title__ja, .ui-title__main, .ui-title__meta, .ui-menu__meta, span, b, i, small, strong) { color: var(--ec-hi); text-shadow: none; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .hand-drawer__close { color: var(--ec-hi); background: var(--ec-panel); border: 1px solid var(--ec-line); border-radius: 2px; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .hand-drawer__close:is(:hover, :focus-visible, :active) { color: var(--ec-bg0); background: var(--ec-line); outline: none; }
/* cards: dark plates with a green edge; the element band on top keeps the card's own colour */
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-list .ui-row {
  background: var(--ec-panel); background-image: none; color: var(--ec-ink); border: 1px solid var(--ec-line); border-top: 6px solid var(--card-el); border-radius: 2px; box-shadow: 0 0 6px var(--ec-glow);
}
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-list .ui-row[aria-selected="true"] { background: var(--ec-line); background-image: none; color: var(--ec-bg0); outline: 2px solid var(--ec-hi); outline-offset: 1px; box-shadow: 0 0 12px var(--ec-glow); }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-list .ui-row .ui-row__name { font-family: inherit; }
/* the selected card is bright green: its small meta (消耗 x/y, chips) must be dark on it */
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-list .ui-row[aria-selected="true"] :is(.ui-row__meta, .ui-chip, .ui-row__name) { color: var(--ec-bg0); border-color: var(--ec-bg0); background: transparent; text-shadow: none; opacity: 1; font-weight: 700; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-list .ui-row[aria-selected="true"] .ui-row__meta { background: rgb(0 0 0 / 0.14); }
html[data-protagonist="elvi"][data-skin="gb"] body #actionSidebar[data-hand="1"] .ui-list .ui-row[aria-selected="true"] { color: var(--ec-bg0); }
html[data-protagonist="elvi"][data-skin="gb"] body #actionSidebar[data-hand="1"] .ui-list .ui-row .ui-sym { color: var(--ec-hi); opacity: 1; }
html[data-protagonist="elvi"][data-skin="gb"] body #actionSidebar[data-hand="1"] .ui-list .ui-row[aria-selected="true"] .ui-sym { color: var(--ec-bg0); }
/* detail strip and its buttons */
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-menu__body > .ui-detail { background: rgb(0 12 6 / 0.88); background-image: none; color: var(--ec-ink); border: 1px solid var(--ec-dim); border-radius: 2px; box-shadow: none; }
html[data-protagonist="elvi"][data-skin="gb"] body #actionSidebar[data-hand="1"] .ui-menu__body > .ui-detail { background: var(--ec-bg1); }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-detail__actions .ui-btn { color: var(--ec-hi); background: var(--ec-panel); border: 1px solid var(--ec-line); border-radius: 2px; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-detail__actions .ui-btn:is(:hover, :focus-visible, :active):not(:disabled) { color: var(--ec-bg0); background: var(--ec-line); outline: none; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] .ui-detail__actions .ui-btn:disabled { color: var(--ec-dim); border-style: dashed; }
