/* [s63-gamepad] Update "Gamepad-Steuerung" (docs/design/gamepad.md §5.4): button badges, focus ring and hint bar in
   the three UI styles. Everything here waits for html[data-input='gamepad'] (set by client/js/input/gamepad.js only
   after a pad button) – with mouse, touch or keyboard none of these rules match. */

/* ---------------------------------------------------------------------------------------------------- badges
   One badge = span.gp-btn[data-gp-b] or a key hint kbd[data-gp-b]. The symbol comes from --gp-g by the layout
   (html[data-gp-layout]: xbox default, ps, nintendo) – the same table as client/js/input/gamepad-glyphs.js GLYPHS
   (tests/client/gamepad-nav.js compares them). */
[data-gp-b='A'] { --gp-g: 'A'; --gp-c: #5fc24a; }
[data-gp-b='B'] { --gp-g: 'B'; --gp-c: #e0473c; }
[data-gp-b='X'] { --gp-g: 'X'; --gp-c: #3f8ce8; }
[data-gp-b='Y'] { --gp-g: 'Y'; --gp-c: #e8b72c; }
[data-gp-b='LB'] { --gp-g: 'LB'; }
[data-gp-b='RB'] { --gp-g: 'RB'; }
[data-gp-b='LT'] { --gp-g: 'LT'; }
[data-gp-b='RT'] { --gp-g: 'RT'; }
[data-gp-b='Back'] { --gp-g: '⧉'; }
[data-gp-b='Start'] { --gp-g: '☰'; }
[data-gp-b='LS'] { --gp-g: 'LS'; }
[data-gp-b='RS'] { --gp-g: 'RS'; }
[data-gp-b='DUp'] { --gp-g: '↑'; }
[data-gp-b='DDown'] { --gp-g: '↓'; }
[data-gp-b='DLeft'] { --gp-g: '←'; }
[data-gp-b='DRight'] { --gp-g: '→'; }
html[data-gp-layout='ps'] [data-gp-b='A'] { --gp-g: '✕'; --gp-c: #7fa7e6; }
html[data-gp-layout='ps'] [data-gp-b='B'] { --gp-g: '○'; --gp-c: #e8687a; }
html[data-gp-layout='ps'] [data-gp-b='X'] { --gp-g: '□'; --gp-c: #d68bd0; }
html[data-gp-layout='ps'] [data-gp-b='Y'] { --gp-g: '△'; --gp-c: #45c2a6; }
html[data-gp-layout='ps'] [data-gp-b='LB'] { --gp-g: 'L1'; }
html[data-gp-layout='ps'] [data-gp-b='RB'] { --gp-g: 'R1'; }
html[data-gp-layout='ps'] [data-gp-b='LT'] { --gp-g: 'L2'; }
html[data-gp-layout='ps'] [data-gp-b='RT'] { --gp-g: 'R2'; }
html[data-gp-layout='ps'] [data-gp-b='Back'] { --gp-g: 'Create'; }
html[data-gp-layout='ps'] [data-gp-b='Start'] { --gp-g: 'Options'; }
html[data-gp-layout='ps'] [data-gp-b='LS'] { --gp-g: 'L3'; }
html[data-gp-layout='ps'] [data-gp-b='RS'] { --gp-g: 'R3'; }
html[data-gp-layout='nintendo'] [data-gp-b='A'] { --gp-g: 'B'; --gp-c: currentColor; }
html[data-gp-layout='nintendo'] [data-gp-b='B'] { --gp-g: 'A'; --gp-c: currentColor; }
html[data-gp-layout='nintendo'] [data-gp-b='X'] { --gp-g: 'Y'; --gp-c: currentColor; }
html[data-gp-layout='nintendo'] [data-gp-b='Y'] { --gp-g: 'X'; --gp-c: currentColor; }
html[data-gp-layout='nintendo'] [data-gp-b='LB'] { --gp-g: 'L'; }
html[data-gp-layout='nintendo'] [data-gp-b='RB'] { --gp-g: 'R'; }
html[data-gp-layout='nintendo'] [data-gp-b='LT'] { --gp-g: 'ZL'; }
html[data-gp-layout='nintendo'] [data-gp-b='RT'] { --gp-g: 'ZR'; }
html[data-gp-layout='nintendo'] [data-gp-b='Back'] { --gp-g: '−'; }
html[data-gp-layout='nintendo'] [data-gp-b='Start'] { --gp-g: '+'; }
html[data-gp-layout='nintendo'] [data-gp-b='LS'] { --gp-g: 'LS'; }
html[data-gp-layout='nintendo'] [data-gp-b='RS'] { --gp-g: 'RS'; }

/* symbols the bundled and the common system fonts may lack (☰ ⧉ ✕ ○ □ △ – the s63 sandbox has only Noto Sans):
   drawn in CSS. --gp-g keeps the table entry (names, tests); these rules only replace how it is painted. */
:is(.gp-btn, html[data-input='gamepad'] kbd)[data-gp-b]::before { display: inline-block; }
html:not([data-gp-layout='ps']):not([data-gp-layout='nintendo']) :is(.gp-btn, html[data-input='gamepad'] kbd)[data-gp-b='Start']::before {
  content: ''; width: 0.72em; height: 0.56em; color: inherit;
  background: linear-gradient(currentColor 0 0) 0 0 / 100% 0.12em no-repeat, linear-gradient(currentColor 0 0) 0 50% / 100% 0.12em no-repeat, linear-gradient(currentColor 0 0) 0 100% / 100% 0.12em no-repeat;
}
html:not([data-gp-layout='ps']):not([data-gp-layout='nintendo']) :is(.gp-btn, html[data-input='gamepad'] kbd)[data-gp-b='Back']::before {
  content: ''; width: 0.46em; height: 0.4em; margin: 0.12em 0.1em 0 0; color: inherit; border: 0.11em solid currentColor; border-radius: 0.06em;
  box-shadow: 0.17em -0.17em 0 -0.05em currentColor;
}
html[data-gp-layout='ps'] :is(.gp-btn, html[data-input='gamepad'] kbd)[data-gp-b='A']::before {
  content: ''; width: 0.74em; height: 0.74em;
  background: linear-gradient(45deg, transparent 43%, currentColor 43% 57%, transparent 57%), linear-gradient(-45deg, transparent 43%, currentColor 43% 57%, transparent 57%);
}
html[data-gp-layout='ps'] :is(.gp-btn, html[data-input='gamepad'] kbd)[data-gp-b='B']::before { content: ''; width: 0.62em; height: 0.62em; box-sizing: border-box; border: 0.13em solid currentColor; border-radius: 50%; }
html[data-gp-layout='ps'] :is(.gp-btn, html[data-input='gamepad'] kbd)[data-gp-b='X']::before { content: ''; width: 0.58em; height: 0.58em; box-sizing: border-box; border: 0.13em solid currentColor; }
html[data-gp-layout='ps'] :is(.gp-btn, html[data-input='gamepad'] kbd)[data-gp-b='Y']::before {
  content: ''; width: 0.72em; height: 0.64em; background: currentColor;
  clip-path: polygon(evenodd, 50% 0, 100% 100%, 0 100%, 50% 0, 50% 33%, 22% 82%, 78% 82%, 50% 33%);
}

.gp-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.45em; height: 1.45em; padding: 0 0.32em;
  border-radius: 999px; border: 1.5px solid currentColor; font-family: var(--f-num); font-weight: 700; font-size: 0.82em;
  line-height: 1; letter-spacing: 0; vertical-align: -0.12em; box-sizing: border-box; white-space: nowrap;
}
.gp-btn::before { content: var(--gp-g, ''); color: var(--gp-c, currentColor); }
.gp-btn:is([data-gp-b='LB'], [data-gp-b='RB'], [data-gp-b='LT'], [data-gp-b='RT'], [data-gp-b='Back'], [data-gp-b='Start']) { border-radius: 0.35em; }

/* key hints on buttons (<kbd>Esc</kbd> …): the gamepad symbol in the gamepad mode, hidden when there is none */
html[data-input='gamepad'] .btn kbd:not([data-gp-b]) { display: none; }
html[data-input='gamepad'] kbd[data-gp-b] { font-size: 0; display: inline-flex; align-items: center; }
html[data-input='gamepad'] kbd[data-gp-b]::before { content: var(--gp-g, ''); font-size: 0.75rem; }

/* texts for one input kind (loading-screen hint …) */
html:not([data-input='gamepad']) .gp-only { display: none !important; }
html[data-input='gamepad'] .gp-hide { display: none !important; }
.gp-line .gp-btn { margin: 0 0.15em; }

/* -------------------------------------------------------------------------------------------- focus ring
   An own rule (scripted focus() after a click shows no :focus-visible, docs/notes/s63-gamepad.md Messung 1) for real
   targets only – headings focused by the router (tabindex -1) stay plain, a switch rings its track. :where() keeps the
   list at zero specificity so the theme rules below and the screens' own :focus-visible styles still apply. Outside
   the box by default, inside with data-gp-inset (below). */
html[data-input='gamepad'] :where(button, a[href], input:not(.toggle input), select, textarea, summary, [tabindex]:not([tabindex='-1']), [role='tab']):focus {
  outline: 4px double var(--c-accent-2); outline-offset: 3px;
  box-shadow: 0 0 0 1px rgba(20, 14, 6, 0.6), 0 0.45rem 1rem rgba(0, 0, 0, 0.45);
}
html[data-input='gamepad'] .toggle:has(input:focus) .toggle-track { outline: 4px double var(--c-accent-2); outline-offset: 3px; }

:root[data-theme='coldwar'][data-input='gamepad'] :where(button, a[href], input:not(.toggle input), select, textarea, summary, [tabindex]:not([tabindex='-1']), [role='tab']):focus,
:root[data-theme='coldwar'][data-input='gamepad'] .toggle:has(input:focus) .toggle-track {
  outline: 2px solid var(--c-accent); outline-offset: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), 0 0 0.8rem 0.15rem color-mix(in srgb, var(--c-accent) 55%, transparent);
}
/* a slight phosphor flicker – it repaints the ring, so never with reduced motion and not at lite / low (the menus
   have no continuous animation there, tests/client/shell.js) */
@media (prefers-reduced-motion: no-preference) {
  :root[data-theme='coldwar'][data-input='gamepad']:not(.ui-lite):not([data-q='low']):not(.reduced-motion):not(.reduce-motion) :where(button, a[href], select, summary, [tabindex]:not([tabindex='-1']), [role='tab']):focus,
  :root[data-theme='coldwar'][data-input='gamepad']:not(.ui-lite):not([data-q='low']):not(.reduced-motion):not(.reduce-motion) .toggle:has(input:focus) .toggle-track {
    animation: gp-phosphor 2.6s steps(1, end) infinite;
  }
}

:root[data-theme='modern'][data-input='gamepad'] :where(button, a[href], input:not(.toggle input), select, textarea, summary, [tabindex]:not([tabindex='-1']), [role='tab']):focus,
:root[data-theme='modern'][data-input='gamepad'] .toggle:has(input:focus) .toggle-track {
  outline: 2px solid var(--c-accent); outline-offset: 2px;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--c-accent) 22%, transparent), 0 0 1.1rem color-mix(in srgb, var(--c-accent) 45%, transparent);
}

/* inside the box when an overflow ancestor or the element's own clip-path would cut the ring (gamepad-nav.js onFocusIn) */
html[data-input='gamepad'] [data-gp-inset]:focus { outline-offset: -5px !important; box-shadow: none !important; }

@keyframes gp-phosphor {
  0%, 100% { outline-color: var(--c-accent); }
  47% { outline-color: color-mix(in srgb, var(--c-accent) 70%, transparent); }
  50% { outline-color: var(--c-accent); }
  83% { outline-color: color-mix(in srgb, var(--c-accent) 82%, transparent); }
}

/* ---------------------------------------------------------------------------------------------- hint bar
   --gp-lift (gamepad-nav.js placeHints): px above its spot when a fixed target (a screen footer) would sit under it */
.gp-hints {
  position: fixed; right: 1rem; bottom: calc(0.9rem + var(--gp-lift, 0px)); z-index: 65; pointer-events: none; display: flex; gap: 0.9rem; align-items: center;
  padding: 0.35rem 0.75rem; font-family: var(--f-ui); font-size: 0.9rem; color: var(--c-paper);
  background: color-mix(in srgb, var(--c-bg) 86%, transparent); border: 1px solid var(--c-line-2); border-radius: var(--r, 3px);
  box-shadow: 0 0.4rem 1.2rem rgba(0, 0, 0, 0.45);
}
html:not([data-input='gamepad']) .gp-hints, .gp-hints[hidden] { display: none; }
.gp-hint { display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; }
.gp-hint .gp-btn + .gp-btn { margin-left: -0.1rem; }
.gp-hint-label { text-transform: uppercase; letter-spacing: 0.04em; }

/* ww2: a typed strip of paper under the brass */
:root:not([data-theme='coldwar']):not([data-theme='modern']) .gp-hints {
  background: var(--c-paper); color: var(--c-ink); border: 1px solid #b9a77a; border-radius: 1px; font-family: var(--f-type); font-size: 0.85rem;
  box-shadow: 0 0 0 3px rgba(20, 14, 6, 0.35), 0 0.5rem 1rem rgba(0, 0, 0, 0.55); rotate: -0.6deg;
}
:root:not([data-theme='coldwar']):not([data-theme='modern']) .gp-hints .gp-btn { border-color: var(--c-ink); }
:root:not([data-theme='coldwar']):not([data-theme='modern']) .gp-hint-label { text-transform: none; letter-spacing: 0; }

/* cold war: a phosphor terminal line */
:root[data-theme='coldwar'] .gp-hints {
  background: rgba(3, 14, 6, 0.92); color: var(--c-accent); border: 1px solid color-mix(in srgb, var(--c-accent) 55%, transparent); border-radius: 0;
  font-family: var(--f-type); text-shadow: 0 0 6px color-mix(in srgb, var(--c-accent) 60%, transparent);
  box-shadow: inset 0 0 1rem rgba(93, 255, 122, 0.08), 0 0 0.9rem rgba(0, 0, 0, 0.6);
}
:root[data-theme='coldwar'] .gp-hints .gp-btn { --gp-c: currentColor; }

/* modern: a glass panel with the accent edge */
:root[data-theme='modern'] .gp-hints {
  background: rgba(14, 19, 26, 0.9); border: 1px solid rgba(214, 224, 240, 0.25); border-left: 2px solid var(--c-accent); border-radius: 1px;
}

/* ------------------------------------------------------------------------------------------- battle cursor
   client/js/input/gamepad-battle.js (design §6.1): div.gp-cursor in #ui, moved by transform only, never catches the
   mouse. The mark per style – WK2 a crosshair, Cold War a phosphor dot in brackets, Modern a ring with a dot – takes
   the colour of the mouse cursor's state (data-state from game/orders.js CURSORS). is-dim = the HUD focus mode. */
.gp-cursor { position: fixed; left: 0; top: 0; z-index: 59; width: 0; height: 0; pointer-events: none; will-change: transform; }
.gp-cursor[hidden], html:not([data-input='gamepad']) .gp-cursor { display: none; }
.gp-cursor.is-dim { opacity: 0.32; }
.gp-cursor-mark { position: absolute; left: -16px; top: -16px; width: 32px; height: 32px; color: #f6ead0; filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.9)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }
.gp-cursor-mark::before, .gp-cursor-mark::after { content: ''; position: absolute; box-sizing: border-box; }
/* ww2: a crosshair with a gap and a small ring */
.gp-cursor-mark::before {
  inset: 0;
  background:
    linear-gradient(currentColor 0 0) 50% 0 / 2px 11px no-repeat, linear-gradient(currentColor 0 0) 50% 100% / 2px 11px no-repeat,
    linear-gradient(currentColor 0 0) 0 50% / 11px 2px no-repeat, linear-gradient(currentColor 0 0) 100% 50% / 11px 2px no-repeat;
}
.gp-cursor-mark::after { left: 12px; top: 12px; width: 8px; height: 8px; border: 1.5px solid currentColor; border-radius: 50%; }
/* cold war: a phosphor dot in four corner brackets */
:root[data-theme='coldwar'] .gp-cursor-mark { color: var(--c-accent, #5dff7a); filter: drop-shadow(0 0 3px color-mix(in srgb, currentColor 70%, transparent)) drop-shadow(0 0 1px #000); }
:root[data-theme='coldwar'] .gp-cursor-mark::before {
  inset: 3px;
  background:
    linear-gradient(currentColor 0 0) 0 0 / 8px 2px no-repeat, linear-gradient(currentColor 0 0) 0 0 / 2px 8px no-repeat,
    linear-gradient(currentColor 0 0) 100% 0 / 8px 2px no-repeat, linear-gradient(currentColor 0 0) 100% 0 / 2px 8px no-repeat,
    linear-gradient(currentColor 0 0) 0 100% / 8px 2px no-repeat, linear-gradient(currentColor 0 0) 0 100% / 2px 8px no-repeat,
    linear-gradient(currentColor 0 0) 100% 100% / 8px 2px no-repeat, linear-gradient(currentColor 0 0) 100% 100% / 2px 8px no-repeat;
}
:root[data-theme='coldwar'] .gp-cursor-mark::after { left: 13px; top: 13px; width: 6px; height: 6px; border: 0; background: currentColor; box-shadow: 0 0 6px 1px currentColor; }
/* modern: a ring with a dot */
:root[data-theme='modern'] .gp-cursor-mark { color: var(--c-accent, #4aa8ff); }
:root[data-theme='modern'] .gp-cursor-mark::before { inset: 5px; background: none; border: 2px solid currentColor; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 8px color-mix(in srgb, currentColor 45%, transparent); }
:root[data-theme='modern'] .gp-cursor-mark::after { left: 14px; top: 14px; width: 4px; height: 4px; border: 0; border-radius: 50%; background: currentColor; }
/* states of the mouse cursor (same colours as game/orders.js CURSORS) */
.gp-cursor[data-state='attack'] .gp-cursor-mark, .gp-cursor[data-state='target'] .gp-cursor-mark { color: #ff5a40; }
.gp-cursor[data-state='amove'] .gp-cursor-mark { color: #ffa040; }
.gp-cursor[data-state='move'] .gp-cursor-mark { color: #6ad8ff; }
.gp-cursor[data-state='patrol'] .gp-cursor-mark { color: #b49aff; }
.gp-cursor[data-state='guard'] .gp-cursor-mark { color: #70ffd8; }
.gp-cursor[data-state='repair'] .gp-cursor-mark { color: #ffd36a; }
.gp-cursor[data-state='select'] .gp-cursor-mark { color: #ffffff; }
.gp-cursor[data-state='build'] .gp-cursor-mark { color: #7dff8a; }
.gp-cursor[data-state='noBuild'] .gp-cursor-mark { color: #a8a8a8; opacity: 0.8; }
.gp-cursor[data-state='target'] .gp-cursor-mark { transform: scale(1.2); }
/* the prompt next to the cursor while it aims: "Ⓐ Feuern  Ⓑ Abbrechen" */
.gp-cursor-tip {
  position: absolute; left: 22px; top: 20px; display: flex; gap: 0.6rem; align-items: center; white-space: nowrap;
  padding: 0.2rem 0.5rem; font-family: var(--f-ui); font-size: 0.78rem; color: var(--c-paper, #f2ecdc);
  background: rgba(10, 12, 14, 0.82); border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 2px;
}
.gp-cursor-tip[hidden] { display: none; }
:root:not([data-theme='coldwar']):not([data-theme='modern']) .gp-cursor-tip { background: var(--c-paper, #efe4c8); color: var(--c-ink, #2a2218); border-color: #b9a77a; font-family: var(--f-type); }
:root:not([data-theme='coldwar']):not([data-theme='modern']) .gp-cursor-tip .gp-btn { border-color: var(--c-ink, #2a2218); }
:root[data-theme='coldwar'] .gp-cursor-tip { background: rgba(3, 14, 6, 0.92); color: var(--c-accent); border-color: color-mix(in srgb, var(--c-accent) 55%, transparent); border-radius: 0; font-family: var(--f-type); }
:root[data-theme='coldwar'] .gp-cursor-tip .gp-btn { --gp-c: currentColor; }
:root[data-theme='modern'] .gp-cursor-tip { border-left: 2px solid var(--c-accent); }

/* [s9-tech] settings › Gamepad: the binding editor reuses the keybind editor's rows (.hud-ke, hud.css) */
.gp-keyed .hud-ke-list { max-height: none; overflow: visible; min-height: 0; }
.gp-ke-layer { margin: 0.6em 0 0.15em; font-size: 0.8em; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-dim); }
.gp-ke-line .gp-btn { margin: 0 0.12em; }
.gp-ke .hud-ke-key { min-width: 5.2em; }
.gp-ke-ask { display: flex; gap: 0.4em; justify-content: flex-end; }

/* [s9-tech] replays (§8): the replay bar's badge line of the pad buttons takes the place of its key text */
html[data-input='gamepad'] .rp-status .rp-keys { display: none; }
.rp-keys-gp { margin-left: auto; color: var(--c-dim); font-size: 0.92em; white-space: nowrap; }
.hud.is-touch .rp-keys-gp { display: none !important; }
@media (max-width: 1000px) { .rp-keys-gp { display: none !important; } }
/* [s9-tech] map editor (§8, gamepad-modes.js): the pad buttons on their own line under the editor's key help */
.ed-help .ed-keys-gp { display: block; margin-top: 0.2rem; }

/* [s9-tech] gamepad-final: pause › Gamepad-Belegung (gamepad-help.js), inside the scrolling pause box */
.gp-help { margin-top: 0.7em; padding: 0.6em; font-size: 0.88em; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--c-line); }
.gp-help-hint { margin: 0 0 0.3em; color: var(--c-dim); }
.gp-help-title { margin: 0.7em 0 0.25em; font-size: 0.85em; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-dim); }
.gp-help-row { display: grid; grid-template-columns: 7.5em 1fr; gap: 0.6em; align-items: baseline; padding: 0.12em 0; }
.gp-help-row.is-wide { grid-template-columns: 1fr; }
.gp-help-keys { white-space: nowrap; }
.gp-help-keys .gp-btn, .gp-help-text .gp-btn { margin: 0 0.1em; }
