/* Field keys: the spell key holds quick access; search sits by the direction keys. */
:root {
  --iw-key-art: url("../../../assets/ui/ps1/inspect-wheel-2026-10-14/inspect-key.png");
  --iw-z-wheel: calc(var(--vp-z-popup, 90) + 20);
}
.ui-actions .ui-inspect-key, .ui-actions [data-action="spell-list"] {
  position: relative; left: auto; top: auto; transform: none; min-width: 44px; min-height: 44px; touch-action: none;
}
/* Authored GB/PS1 caps otherwise restore manipulation and cancel a held swipe as a scroll. */
:is(#controls, #fieldGuide) [data-action="spell-list"],
:is(#controls, #fieldGuide) [data-action="item-list"],
#inspectKey, #fieldGuide [data-action="inspect"] { touch-action: none !important; }
html[data-skin="ps1"] .ui-actions .ui-inspect-key {
  background: var(--iw-key-art) center / auto 145% no-repeat; border: 0; box-shadow: none;
}
html[data-skin="ps1"] .ui-actions .ui-inspect-key::after { content: ""; position: absolute; inset: 0; background: var(--iw-key-art) center / auto 145% no-repeat; pointer-events: none; }
html[data-skin="ps1"] .ui-inspect-key__ico { opacity: 0; }
html[data-skin="gb"] .ui-inspect-key__ico { opacity: 1; }
.ui-inspect-key[aria-pressed="true"] { filter: brightness(1.25); }
.ui-inspect-key:focus-visible, .ui-actions [data-action="spell-list"]:focus-visible { outline: 2px solid #efe2c4; outline-offset: 2px; }
body.spell-wheel-open .ui-deck { pointer-events: none; }
html[data-skin="ps1"] .title-anim-pending .title-art__frame, html[data-skin="ps1"] .title-anim-pending .title-diorama { visibility: hidden; }
html[data-skin="ps1"] .ui-guide [data-guide="inspect"] { background: var(--iw-key-art) center / auto 145% no-repeat; }
html[data-skin="ps1"] .ui-guide [data-guide="inspect"] .ui-key__ico { opacity: 0; }

/* Gate notices stay inside the renderer's free area; inventory overflow remains legible. */
html .ui-field .ui-gate { bottom: var(--gate-safe-bottom, var(--sp-2)); max-height: var(--gate-safe-height, calc(100% - 16px)); overflow-y: auto; white-space: pre-line; }
.ui-menu[data-tab="ITEM"] [data-inventory-overflow="1"] { border-left: 3px solid #8c6325; font-weight: 700; }
html[data-skin="gb"] .ui-menu[data-tab="ITEM"] [data-inventory-overflow="1"] { border-color: var(--gb-3); }

/* ---- the wheel (overlay on <body>, built by SpellWheelView) ---- */
.spell-wheel { position: fixed; inset: 0; z-index: var(--iw-z-wheel); pointer-events: auto; background: rgb(4 3 8 / 0.34); touch-action: none; }
.spell-wheel[hidden] { display: none; }
.spell-wheel[data-mode="sticky"] { pointer-events: auto; background: rgb(4 3 8 / 0.5); }
.spell-wheel__ring { position: absolute; left: var(--wheel-x, 50%); top: var(--wheel-y, 50%); width: 0; height: 0; }
.spell-wheel__slot {
  position: absolute; left: 0; top: 0; box-sizing: border-box; width: var(--wheel-sw, 84px); min-height: 44px; padding: 4px 6px; margin: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; text-align: center;
  transform: translate(-50%, -50%) rotate(var(--a, 0deg)) translateY(calc(var(--r, var(--wheel-r, 110px)) * -1)) rotate(calc(var(--a, 0deg) * -1));
  font: inherit; font-size: clamp(12px, calc(var(--wheel-sw, 84px) / 6.5), 14px); line-height: 1.2; color: #efe2c4; background: rgb(14 12 18 / 0.92);
  border: 1px solid #9a7a45; border-radius: 10px; box-shadow: 0 2px 6px rgb(0 0 0 / 0.55);
  touch-action: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.spell-wheel__slot[hidden] { display: none; }
.spell-wheel__name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; max-width: 100%; overflow: hidden; white-space: normal; overflow-wrap: anywhere; font-weight: 700; }
.spell-wheel__meta { display: block; max-width: 100%; white-space: normal; overflow-wrap: anywhere; font-size: max(10px, 0.82em); opacity: 0.85; }
.spell-wheel__tag { font-style: normal; margin-right: 0.4em; padding: 0 0.3em; border: 1px dashed currentColor; border-radius: 4px; }
.spell-wheel__slot[data-source="scroll"], .spell-wheel__slot[data-source="book"] { border-style: dashed; background: rgb(28 22 12 / 0.92); }
.spell-wheel__slot[data-source="page"] { border-color: #efe2c4; background: rgb(40 36 50 / 0.95); }
.spell-wheel__slot[data-usable="0"] { opacity: 0.55; }
.spell-wheel__slot.is-active, .spell-wheel__slot:focus-visible { color: #14110c; background: #efe2c4; border-color: #fff6df; outline: 2px solid #fff6df; outline-offset: 1px; transform: translate(-50%, -50%) rotate(var(--a, 0deg)) translateY(calc(var(--r, var(--wheel-r, 110px)) * -1)) rotate(calc(var(--a, 0deg) * -1)) scale(1.08); z-index: 2; }
.spell-wheel__hub {
  /* a disc on the launcher's real centre: JS sizes it so it stays on screen (--wheel-hub); its words are in the caption */
  position: absolute; left: 0; top: 0; box-sizing: border-box; transform: translate(-50%, -50%); width: var(--wheel-hub, calc(var(--wheel-r, 110px) * 1.1)); height: var(--wheel-hub, calc(var(--wheel-r, 110px) * 1.1)); padding: 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; line-height: 1.2; border-radius: 999px;
  color: #efe2c4; background: rgb(8 7 11 / 0.9); border: 1px solid rgb(239 226 196 / 0.45); pointer-events: none;
}
.spell-wheel[data-mode="sticky"] .spell-wheel__hub { pointer-events: auto; }
.spell-wheel__hub small { font-size: 11px; opacity: 0.85; max-width: 100%; white-space: nowrap; }
/* Only the page label moves into the safe area; the wheel's press centre stays fixed. */
.spell-wheel__hub > [data-wheel-page]:not(:empty) {
  flex: none; max-width: none; padding: 2px 4px; background: inherit; pointer-events: none;
  transform: translate(
    clamp(calc(var(--safe-l, 0px) + 6px + 50% - var(--wheel-x, 50vw)), 0px, calc(100dvw - var(--safe-r, 0px) - 6px - 50% - var(--wheel-x, 50vw))),
    clamp(calc(var(--safe-t, 0px) + 6px + 50% - var(--wheel-y, 50vh)), 0px, calc(100dvh - var(--safe-b, 0px) - 6px - 50% - var(--wheel-y, 50vh)))
  );
}
/* name and hint of the highlighted direction: always fully on screen, placed clear of the slots (wheelGeometry) */
.spell-wheel__caption {
  position: absolute; left: var(--cap-x, 8px); top: var(--cap-y, 8px); width: var(--cap-w, 200px); box-sizing: border-box; padding: 6px 8px; min-height: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; line-height: 1.25; border-radius: 10px;
  color: #efe2c4; background: rgb(8 7 11 / 0.9); border: 1px solid rgb(239 226 196 / 0.45); pointer-events: none;
}
.spell-wheel__caption b { font-size: 12px; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.spell-wheel__caption span { font-size: 11px; opacity: 0.85; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.spell-wheel[data-empty="1"] .spell-wheel__slot { display: none; }
/* the concentric spell ring (layout set by the caller): a name that wraps (as many lines as the longest name needs, the same for every button) and one line of meta, so every button keeps the height the
   geometry measured; the full name, tag and cost are in the caption and the accessible name. The caption keeps the height it was laid out with. */
.spell-wheel[data-layout="concentric"] { overflow: hidden; }
.spell-wheel[data-layout="concentric"] .spell-wheel__ring { z-index: 1; }
.spell-wheel[data-layout="concentric"] .spell-wheel__slot { min-height: var(--wheel-sh, 46px); padding: 3px 4px; }   /* the drawn box is the hit box */
/* tracks under the buttons (one per circle, plus the jog band); only a skin with dial art shows them */
.spell-wheel__tracks { position: absolute; left: var(--wheel-x, 50%); top: var(--wheel-y, 50%); width: 0; height: 0; z-index: 0; pointer-events: none; }
.spell-wheel__track { display: none; }
/* the name wraps over as many lines as the longest name of the list needs (--wheel-name-lines, set by SpellWheelView.fitNames) and every button reserves them */
.spell-wheel[data-layout="concentric"] .spell-wheel__name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--wheel-name-lines, 1); min-height: calc(var(--wheel-name-lines, 1) * 1.2em); white-space: normal; overflow: hidden; overflow-wrap: anywhere; word-break: normal; }
.spell-wheel[data-layout="concentric"] .spell-wheel__meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spell-wheel[data-layout="concentric"] .spell-wheel__caption { height: var(--cap-h, 60px); overflow: hidden; }
.spell-wheel[data-layout="concentric"] .spell-wheel__caption b { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.spell-wheel[data-layout="concentric"] .spell-wheel__caption span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[data-skin="gb"] .spell-wheel { background: rgb(0 0 0 / 0.3); }
html[data-skin="gb"] .spell-wheel__slot { color: var(--gb-3); background: var(--gb-0); border: var(--gb-dot, 2px) solid var(--gb-3); border-radius: 0; box-shadow: none; }
html[data-skin="gb"] .spell-wheel__slot.is-active, html[data-skin="gb"] .spell-wheel__slot:focus-visible { color: var(--gb-0); background: var(--gb-3); outline: 0; }
html[data-skin="gb"] :is(.spell-wheel__hub, .spell-wheel__caption) { color: var(--gb-3); background: var(--gb-0); border: var(--gb-dot, 2px) solid var(--gb-3); border-radius: 0; }
@media (prefers-reduced-motion: reduce) { .spell-wheel__slot.is-active { transform: translate(-50%, -50%) rotate(var(--a, 0deg)) translateY(calc(var(--r, var(--wheel-r, 110px)) * -1)) rotate(calc(var(--a, 0deg) * -1)); } }

/* ======================= 3. the inspect layout ======================= */
/* Portrait: board above, information below. Landscape: board left, information right. Safe areas are respected; the board box is what the slice renderer
   fits its cells into (SliceRenderer.fieldCounts reshapes the cell counts to it), the information box is the only part that scrolls. */
html[data-inspect="1"] {
  --ins-pad: 6px;
  --ins-l: calc(env(safe-area-inset-left, 0px) + var(--ins-pad)); --ins-t: calc(env(safe-area-inset-top, 0px) + var(--ins-pad));
  --ins-r: calc(env(safe-area-inset-right, 0px) + var(--ins-pad)); --ins-b: calc(env(safe-area-inset-bottom, 0px) + var(--ins-pad));
  --ins-w: calc(100vw - var(--ins-l) - var(--ins-r)); --ins-h: calc(100vh - var(--ins-t) - var(--ins-b));
}
@supports (height: 100dvh) {
  html[data-inspect="1"] { --ins-h: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - var(--ins-pad) * 2); }
}
html[data-inspect="1"] body .ui-field { background: #0b0a10 !important; }
html[data-skin="gb"][data-inspect="1"] body .ui-field { background: var(--gb-0) !important; }
html[data-inspect="1"] body .ui-field::before, html[data-inspect="1"] body .ui-field::after { content: none !important; display: none !important; }
html[data-inspect="1"] body::after { display: none !important; }
/* collapsed: status, log, minimap, threat, the deck / keys / guide and every card that lies over the board */
html[data-inspect="1"] body :is(.ui-rail > *, .ui-field > .ui-guide--field, .ui-field > .ui-trackball, .ui-field > .ui-inspect-key, #spellTargetHud, #gateInfoCard, #interactionCard, #fieldHud, #fieldThreat) { display: none !important; }
html[data-inspect="1"] body .ui-field > .ui-map {
  position: fixed !important; z-index: 5; margin: 0 !important; border-radius: 0 !important; aspect-ratio: auto !important; box-shadow: none !important; transform: none !important;
  right: auto !important; bottom: auto !important; overflow: hidden;
  left: var(--ins-l) !important; top: var(--ins-t) !important;
}
@media (orientation: portrait) {
  html[data-inspect="1"] body .ui-field > .ui-map { width: var(--ins-w) !important; height: calc((var(--ins-h) - var(--ins-pad)) * 0.54) !important; }
  html[data-inspect="1"] body > #tapInspectPanel.ui-inspect:not([hidden]) {
    left: var(--ins-l) !important; width: var(--ins-w) !important;
    top: calc(var(--ins-t) + (var(--ins-h) - var(--ins-pad)) * 0.54 + var(--ins-pad)) !important; height: calc((var(--ins-h) - var(--ins-pad)) * 0.46) !important;
  }
}
@media (orientation: landscape) {
  html[data-inspect="1"] body .ui-field > .ui-map { width: calc((var(--ins-w) - var(--ins-pad)) * 0.58) !important; height: var(--ins-h) !important; }
  html[data-inspect="1"] body > #tapInspectPanel.ui-inspect:not([hidden]) {
    left: calc(var(--ins-l) + (var(--ins-w) - var(--ins-pad)) * 0.58 + var(--ins-pad)) !important; width: calc((var(--ins-w) - var(--ins-pad)) * 0.42) !important;
    top: var(--ins-t) !important; height: var(--ins-h) !important;
  }
}
html[data-inspect="1"] body > #tapInspectPanel.ui-inspect:not([hidden]) {
  position: fixed !important; right: auto !important; bottom: auto !important; max-height: none !important; min-height: 0 !important; min-width: 0 !important;
  z-index: 40; display: flex !important; flex-direction: column; transform: none !important; box-shadow: none; overflow: hidden;
}
html[data-inspect="1"] body > #tapInspectPanel .tap-inspect-head { cursor: default; touch-action: auto; flex: 0 0 auto; }
html[data-inspect="1"] body > #tapInspectPanel > .inspect-body { flex: 1 1 0 !important; min-height: 0 !important; overflow-y: auto !important; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
/* the back button: always inside the head, never scrolled away, a real 44px target */
html body > #tapInspectPanel .ui-popup-x.inspect-back {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: auto; min-width: 88px; height: 44px; padding: 0 12px;
  font: inherit; font-weight: 700; white-space: nowrap;
}
html body > #tapInspectPanel .ui-popup-x.inspect-back > span { pointer-events: none; }
html body > #tapInspectPanel .inspect-target-step { flex: 0 0 44px; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; margin: 0; font: inherit; font-size: 22px; touch-action: manipulation; }
html body > #tapInspectPanel .inspect-target-step[hidden] { display: none !important; }
html[data-inspect="1"] body > #tapInspectPanel[data-inspect-mode="visible"] .tap-inspect-head { grid-template-columns: minmax(0, 1fr) 44px 44px 88px; column-gap: 4px; }
html[data-inspect="1"] body > #tapInspectPanel[data-inspect-mode="visible"] .inspect-target-step { grid-row: 1 / span 2; }
html[data-inspect="1"] body > #tapInspectPanel[data-inspect-mode="visible"] [data-inspect-step="-1"] { grid-column: 2; }
html[data-inspect="1"] body > #tapInspectPanel[data-inspect-mode="visible"] [data-inspect-step="1"] { grid-column: 3; }
html[data-inspect="1"] body > #tapInspectPanel[data-inspect-mode="visible"] .ui-popup-x.inspect-back { grid-column: 4; }
html[data-inspect="1"] body > #tapInspectPanel .tap-inspect-head > b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ui-menu[data-tab="ITEM"] [data-inventory-summary]:not([hidden]) { display: block !important; flex: 0 0 auto; margin: 0; padding: 6px 8px; color: inherit; font-size: inherit; line-height: 1.35; white-space: pre-line; overflow-wrap: anywhere; }

/* ======================= 4. two-stage taps: a first tap on a list row leaves the summary ======================= */
html .ui-menu[data-detail="peek"] .ui-detail .ui-detail__actions { display: none; }
html .ui-menu[data-detail="peek"] .ui-detail .ui-detail__head::after { opacity: 0.9; }
html .product-flow-overlay [data-flow-open][data-tap-armed="true"] { outline: 2px solid currentColor; outline-offset: -3px; }

/* Search is a direction-side key in landscape as well. The five right guide caps remain independent. */
@media (orientation: landscape) {
  html[data-skin]:not([data-inspect="1"]) body #controls > #inspectKey {
    position: fixed !important; display: flex !important; align-items: center; justify-content: center;
    left: calc(var(--safe-l, 0px) + 48px) !important; right: auto !important; top: auto !important; bottom: calc(var(--safe-b, 0px) + 8px) !important;
    width: var(--field-key-w, 44px) !important; height: 44px !important; min-width: 44px; min-height: 44px; margin: 0; padding: 6px;
    transform: none !important; pointer-events: auto; color: var(--c-ink-1); background: var(--c-surface); border: var(--bw-panel, 1px) solid var(--c-line); z-index: var(--z-touch, 20);
  }
  html[data-skin] body #controls > #inspectKey svg { display: block; opacity: 1; width: 26px; height: 26px; }
  /* The map key sits right beside search: the same size (--field-key-w wide, 44px by default), one gap to its right. */
  html[data-skin]:not([data-inspect="1"]) body #controls > #mapKey {
    position: fixed !important; display: flex !important; align-items: center; justify-content: center;
    left: calc(var(--safe-l, 0px) + 48px + var(--field-key-w, 44px) + 8px) !important; right: auto !important; top: auto !important; bottom: calc(var(--safe-b, 0px) + 8px) !important;
    width: var(--field-key-w, 44px) !important; height: 44px !important; min-width: 44px; min-height: 44px; margin: 0; padding: 6px;
    transform: none !important; pointer-events: auto; color: var(--c-ink-1); background: var(--c-surface); border: var(--bw-panel, 1px) solid var(--c-line); z-index: var(--z-touch, 20);
  }
  html[data-skin] body #controls > #mapKey svg { display: block; opacity: 1; width: 26px; height: 26px; fill: currentColor; }
  html[data-skin]:not([data-inspect="1"]) body #controls > .ui-dpad { left: calc(var(--safe-l, 0px) + 6px) !important; right: auto !important; bottom: calc(var(--safe-b, 0px) + 58px) !important; }
}
/* Native key faces are in the chassis raster. Only the spell book's SP notification is drawn over its transparent hit area. */
html[data-native-frame] body #controls [data-native-key][data-action="spell-list"] > .sp-badge { display: block !important; }
