/* web/hud/tap.css
   Every tappable thing's mark, and tapping a name in a room's text (web/hud/tap_names.js):
   what a tap opens (web/hud/tap_menu.js) -- with touch controls a sheet from the bottom of the
   screen, with a mouse a small menu under the word -- its card at the top (web/hud/card.js,
   drawn the same in a side panel's item menu and in an item's tooltip), then the choices, each
   naming its command. Settings' Pinned emotes topic (web/hud/emote_settings.js). */

/* Settings, Tapping: the Tap indicator (data-tap-mark) at rest, and the Tap indicator under
   the pointer (data-tap-point) while the pointer is on the thing or its menu is open. The
   marked words are a name or exit in the game window or the room box, or a panel's .tap-words inside its
   .tap-host (web/hud/tap_words.js). Every mark is in the words' own colours: currentColor,
   or a look's own stops, which web/hud/tap_words.js hands over as --tap-fill and --tap-edge. */
:root {
  --tap-rest-line: none; --tap-rest-band: 10%;
  --tap-point-line: none; --tap-point-band: 16%; --tap-point-ring: 0;
  --tap-strength: 1;
}
:root[data-tap-mark="dashed"] { --tap-rest-line: underline; --tap-rest-band: 0%; }
:root[data-tap-mark="whisper"] { --tap-rest-line: none; --tap-rest-band: 6%; }
:root[data-tap-mark="soft"] { --tap-rest-line: none; --tap-rest-band: 10%; }
:root[data-tap-mark="none"] { --tap-rest-line: none; --tap-rest-band: 0%; }
:root[data-tap-point="dashed"] { --tap-point-line: underline; --tap-point-band: 0%; --tap-point-ring: 0; }
:root[data-tap-point="whisper"] { --tap-point-line: none; --tap-point-band: 6%; --tap-point-ring: 0; }
:root[data-tap-point="soft"] { --tap-point-line: none; --tap-point-band: 10%; --tap-point-ring: 0; }
:root[data-tap-point="strong"] { --tap-point-line: none; --tap-point-band: 16%; --tap-point-ring: 0; }
:root[data-tap-point="outline"] { --tap-point-line: none; --tap-point-band: 0%; --tap-point-ring: .75; }
:root[data-tap-point="none"] { --tap-point-line: none; --tap-point-band: 0%; --tap-point-ring: 0; }

:is(#screen, #roombox) .tap, .tap-host .tap-words {
  --tap-line: var(--tap-rest-line); --tap-band: min(100%, calc(var(--tap-rest-band) * var(--tap-strength))); --tap-ring: 0;
  --tap-ink: min(100%, calc(60% * var(--tap-strength)));
  position: relative; cursor: pointer; border-radius: 3px; padding: 0 .12em; margin: 0 -.12em;
  background: var(--tap-fill, color-mix(in srgb, currentColor var(--tap-band), transparent));
  text-decoration-line: var(--tap-line); text-decoration-style: dashed; text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, currentColor var(--tap-ink), transparent);
  text-underline-offset: .28em;
}
/* A holder inside a panel's row that cuts its words short leaves room for the mark's edge. */
.tap-host :has(> .tap-words) { padding-inline: .12em; margin-inline: -.12em; }
:is(#screen, #roombox) .tap:is(:hover, .on, .pointed), .tap-host:is(:hover, .on, .pointed) .tap-words {
  --tap-line: var(--tap-point-line);
  --tap-band: min(100%, calc(var(--tap-point-band) * var(--tap-strength)));
  --tap-ring: min(1, calc(var(--tap-point-ring) * var(--tap-strength)));
  --tap-ink: min(100%, calc(100% * var(--tap-strength)));
}
/* Words in a look carry the line letter by letter, each in its own live colour. */
:is(#screen .tap, #roombox .tap, .tap-host .tap-words):has(.mk) { text-decoration-line: none; }
:is(#screen .tap, #roombox .tap, .tap-host .tap-words):has(.mk) span:not(.speck, .pw, .orn, .gr, .mkx):not(:has(span)) {
  text-decoration-line: var(--tap-line); text-decoration-style: dashed; text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, currentColor var(--tap-ink), transparent);
  text-underline-offset: .28em;
}
/* The thin outline: a 1px ring in the same colours, still under a moving look. */
:is(#screen, #roombox) .tap::after, .tap-host .tap-words::after {
  content: ""; position: absolute; inset: -1px 0; border-radius: 4px; padding: 1px;
  background: var(--tap-edge, currentColor); opacity: var(--tap-ring); pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
/* No mark on a word while any of its letters is hidden or a symbol (web/decode.js): it
   goes as the word starts to scramble away, and returns once it has settled. */
#screen .tap:has(.dc-hide, .dc[data-sym]) {
  --tap-line: none; --tap-ring: 0; background: none; text-decoration-line: none;
}
:is(#screen, #roombox) .tap:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.tap-scrim { position: fixed; inset: 0; z-index: 44; background: rgba(0, 0, 0, .45); }
.tap-scrim[hidden], .tap-box[hidden] { display: none; }

.tap-box {
  position: fixed; z-index: 45; background: var(--tip-bg, #12141a); border: 1px solid #3a3f4b;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5); overflow-y: auto; box-sizing: border-box;
  font: 13px/1.45 var(--mono); color: var(--pn-text);
}
/* Wide enough for an item card's two columns of numbers, 46 characters of the card's mono. */
.tap-box.pop {
  width: min(28em, calc(100vw - 16px)); max-height: min(70vh, 34em);
  border-radius: 6px; padding: .35em;
}
.tap-box.sheet {
  left: 0; right: 0; bottom: 0; border-radius: 16px 16px 0 0;
  max-height: calc(var(--seen-h, 100dvh) * .78);
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -12px 30px rgba(0, 0, 0, .6); font-size: 15px;
}
.tap-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--cell-edge); margin: 2px auto 8px; }

.tap-box, .tap-card { scrollbar-color: var(--cell-edge) transparent; scrollbar-width: thin; }
/* A long card scrolls on its own, so the choices under it stay in view. */
.tap-card { font-family: var(--mono); padding: 2px 6px 8px; overflow-y: auto; max-height: 15em; }
.tap-box.sheet .tap-card { max-height: calc(var(--seen-h, 100dvh) * .36); }
.tap-name { font-weight: 600; margin-bottom: 4px; }
.tap-rank { color: var(--dim); font-weight: 400; white-space: nowrap; }
.tap-type { color: var(--dim); margin: -2px 0 4px; }
.tap-part { color: #cfd3dc; }
.tap-part.ruled { margin-top: .6em; padding-top: .5em; border-top: 1px dashed var(--line); }
/* An item's card as its tooltip (web/hud/item_tip.js): the box is its frame, and it never
   scrolls, so the card takes the room it needs. */
.help-tip .tap-card { padding: 0; overflow: visible; max-height: none; white-space: normal; }
.help-tip .tap-line { white-space: pre-wrap; }
.tap-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.tap-gap { height: .6em; }
.tap-head { font-weight: 600; padding: 2px 6px 4px; }
.tap-note { color: var(--dim); padding: 4px 6px 6px; }

.tap-act {
  display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; border-top: 1px solid var(--line); border-radius: 0;
  color: var(--ink); font: inherit; padding: 6px 6px; cursor: pointer;
}
.tap-box.pop .tap-act { border-top: 0; border-radius: 5px; padding: 5px 8px; }
.tap-box.sheet .tap-act { align-items: center; min-height: 48px; }
.tap-act:hover { background: var(--cell); }
.tap-act:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tap-act.danger { color: #ff9c8a; }
.tap-back { color: var(--dim); }
.tap-label { flex: 1; min-width: 0; }
.tap-meta { color: var(--dim); }
.tap-cmd { flex: none; color: var(--dim); font: .9em var(--mono); white-space: nowrap; }
.tap-more-mark { flex: none; color: var(--dim); }
.tap-cancel {
  width: 100%; margin-top: 8px; min-height: 46px; border-radius: 10px;
  border: 1px solid var(--cell-edge); background: var(--cell); color: var(--ink); font: inherit;
}

/* Settings' Pinned emotes topic: a search over every emote, each with a Pin. */
.em-search { width: 100% !important; }
.em-list {
  max-height: min(50vh, 26em); overflow-y: auto;
  scrollbar-color: var(--cell-edge) transparent; scrollbar-width: thin;
}
.em-row .what span:first-child { color: var(--ink); }
