/* Personal welcome and WhiteV (whitev.js): a HUD console, not a chat widget. Square
   edges with cut corners, mono readouts, the intro bar's segmented meter. Colours are
   theme tokens only, so both themes get this for free.

   Cut corners: the shape is painted by ::before (line) and ::after (fill) behind the
   content, never clip-path on the element itself. That would also clip focus rings
   and the country dropdown.

   Phones follow the scale at the top of the phone block in option3.css: 20 edge and
   card padding, 12 between and inside cards, 8 label to value, 4 tight pairs.
   Controls 48 tall, inputs 16px. */

:root { --wv-glow: rgb(198 255 61 / 0.14); --wv-scan: rgb(198 255 61 / 0.018); }
html[data-theme="light"] { --wv-glow: rgba(12, 13, 10, 0.18); --wv-scan: rgba(12, 13, 10, 0.02); }
/* Light theme: lime text becomes ink on a lime marker (see styles.css). */
html[data-theme="light"] :is(.hero__hi, .player__status, .wv__status, .wv__quest p span:last-child, .wv-msg a) {
  color: var(--on-accent); background: var(--accent-fill); padding-inline: 0.4em;
}
html[data-theme="light"] .hero__hi { width: fit-content; }
html[data-theme="light"] :is(.wv__status, .wv-msg a) { justify-self: start; }
html[data-theme="light"] .wv-msg--bot::before { justify-self: start; color: var(--on-accent); background: var(--accent-fill); padding: 1px 4px; }
html[data-theme="light"] .wv-choice > span::before { color: var(--on-accent); background: var(--accent-fill); padding: 2px 4px; }

.player__box, .wv, .wv-tip, .wv-choice, .wv-msg--you, .player__start, .wv__send {
  --cut: 10px; --cut-line: var(--line-strong); --cut-fill: var(--surface);
  position: relative; isolation: isolate; border-radius: 0; background: none; box-shadow: none;
}
:is(.player__box, .wv, .wv-tip, .wv-choice, .wv-msg--you, .player__start, .wv__send)::before,
:is(.player__box, .wv, .wv-tip, .wv-choice, .wv-msg--you, .player__start, .wv__send)::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}
:is(.player__box, .wv, .wv-tip, .wv-choice, .wv-msg--you, .player__start, .wv__send)::before { background: var(--cut-line); }
:is(.player__box, .wv, .wv-tip, .wv-choice, .wv-msg--you, .player__start, .wv__send)::after { inset: 1px; background: var(--cut-fill); }

/* Brackets on the two corners that aren't cut. */
.hud-brackets {
  position: absolute; inset: -6px; pointer-events: none; color: var(--accent);
  background:
    linear-gradient(currentColor, currentColor) right top / 16px 1px no-repeat,
    linear-gradient(currentColor, currentColor) right top / 1px 16px no-repeat,
    linear-gradient(currentColor, currentColor) left bottom / 16px 1px no-repeat,
    linear-gradient(currentColor, currentColor) left bottom / 1px 16px no-repeat;
}

/* The segmented meter, from the intro's loading bar. */
.hud-meter { position: relative; height: 8px; background: repeating-linear-gradient(90deg, var(--surface-3) 0 8px, transparent 8px 11px); }
.hud-meter i {
  position: absolute; inset: 0; background: repeating-linear-gradient(90deg, var(--accent) 0 8px, transparent 8px 11px);
  clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0); transition: clip-path 280ms var(--ease-out);
}

/* ── Name in the page ── */
.hero__hi { margin: 0; font: 700 clamp(0.875rem, 1.1vw, 1rem)/1.2 var(--font-mono); letter-spacing: 0.04em; color: var(--accent); overflow-wrap: anywhere; }
.hero__hi::before { content: "> "; opacity: 0.7; }
.hud-mission__player { display: block; margin-bottom: 8px; color: var(--text); overflow-wrap: anywhere; }
.hud-mission__player[hidden], .menu__notme[hidden] { display: none; }
.menu__notme { display: block; margin-top: var(--s4); padding: var(--s2) 0; border: 0; background: none; color: var(--text-2); font: 400 0.8125rem/1.2 var(--font-mono); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ── Name prompt ── */
.player { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: var(--s4); }
.player[hidden] { display: none; }
html:not([data-boot]) .player { background: var(--scrim); }
.player__box {
  --cut: 18px; --cut-line: var(--accent);
  display: grid; gap: var(--s4); width: min(460px, 100%); padding: var(--s5); outline: 0;
  filter: drop-shadow(0 0 32px var(--wv-glow));
}
.player__bar { display: flex; justify-content: space-between; gap: var(--s3); padding-bottom: var(--s3); border-bottom: 1px solid var(--line); color: var(--text-3); font-size: 0.6875rem; }
.player__status { display: inline-flex; align-items: center; gap: var(--s2); color: var(--accent); white-space: nowrap; }
.player__status b { width: 6px; height: 6px; background: currentColor; }
.player__title { margin: 0; font: 600 clamp(1.625rem, 3vw, 2rem)/1.1 var(--font-display); letter-spacing: -0.03em; color: var(--text); overflow-wrap: anywhere; }
.player__field { display: flex; align-items: center; gap: var(--s3); min-height: 52px; padding: 0 var(--s3); background: var(--surface-2); border-bottom: 2px solid var(--line-strong); transition: border-color 160ms ease; }
.player__field:focus-within { border-color: var(--accent); }
.player__caret { flex: none; font: 700 1rem/1 var(--font-mono); color: var(--accent); }
.player__input { flex: 1 1 auto; min-width: 0; min-height: 48px; padding: 0; border: 0; outline: 0; background: none; color: var(--text); caret-color: var(--accent); font: 400 1rem/1.2 var(--font-mono); }
.player__input::placeholder { color: var(--text-3); }
.player__err { margin: 0; color: var(--danger); font: 400 0.8125rem/1.4 var(--font-mono); }
.player__err:empty { display: none; }
.player__err::before { content: "! "; font-weight: 700; }
.player__actions { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); }
.player__start {
  --cut-line: var(--accent-fill); --cut-fill: var(--accent-fill);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 52px; border: 0; cursor: pointer;
  color: var(--on-accent); font: 700 0.875rem/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  transition: transform 160ms var(--ease-out);
}
.player__start svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 200ms var(--ease-out); }
.player__start:active { transform: scale(0.98); }
.player__start:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 0; }
.player__skip { min-height: 52px; padding: 0 var(--s4); border: 0; background: none; color: var(--text-2); font: 400 0.8125rem/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; }
.player__skip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 0; }
.player__fine { margin: 0; color: var(--text-3); font: 400 0.6875rem/1.4 var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
/* Accepted: the box confirms the name for a moment before the page opens. */
.player__box.is-granted :is(.player__field, .player__err, .player__actions, .player__fine) { display: none; }
@media (any-hover: hover) and (any-pointer: fine) {
  .player__skip:hover { color: var(--text); }
  .player__start:hover svg { transform: translateX(3px); }
}
@media (prefers-reduced-motion: no-preference) {
  .player__box { animation: hud-open 320ms var(--ease-out); }
  .player__status b { animation: hud-blink 1.2s steps(2, jump-none) infinite; }
}

/* ── Launcher: a hexagon, directly above the WhatsApp button at every width ── */
.wv-launch {
  position: fixed; right: 29px; bottom: calc(184px + env(safe-area-inset-bottom, 0px)); z-index: 33;
  display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--accent); filter: drop-shadow(0 0 14px var(--wv-glow));
  transition: transform 160ms var(--ease-out);
}
.wv-launch[hidden], .wv-tip[hidden] { display: none; }
.wv-launch svg { grid-area: 1 / 1; width: 100%; height: 100%; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.25; stroke-linejoin: round; stroke-linecap: round; }
.wv-launch__hex { fill: var(--surface); }
.wv-launch svg.wv-launch__mark { grid-area: auto; fill: var(--text); stroke: none; }
.wv-launch__ping { transform-box: fill-box; transform-origin: center; opacity: 0; }
.wv-launch:active { transform: scale(0.94); }
.wv-launch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 0; }
@media (any-hover: hover) and (any-pointer: fine) { .wv-launch:hover { transform: translateY(-3px) scale(1.05); } }

.wv-tip {
  --cut: 8px; --cut-line: var(--accent);
  position: fixed; right: 96px; bottom: calc(190px + env(safe-area-inset-bottom, 0px)); z-index: 33;
  max-width: min(300px, calc(100vw - 110px)); padding: var(--s3) var(--s4); border: 0; cursor: pointer; text-align: left;
  color: var(--text); font: 500 0.875rem/1.35 var(--font-body); text-wrap: balance;
}
.wv-tip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 0; }
@media (prefers-reduced-motion: no-preference) {
  .wv-launch:not([hidden]), .wv-tip:not([hidden]) { animation: hud-rise 320ms var(--ease-out); }
  .wv-launch__ping { animation: hud-ping 3.2s var(--ease-out) infinite; }
}
.menu-open :is(.wv-launch, .wv-tip) { display: none; }

@media (max-width: 768px) {
  .wv-launch { right: 15px; bottom: calc(148px + env(safe-area-inset-bottom, 0px)); width: 52px; height: 52px; }
  .wv-tip { right: 76px; bottom: calc(152px + env(safe-area-inset-bottom, 0px)); }
}

/* ── Console ── */
.wv {
  --cut: 20px; --cut-line: var(--accent);
  position: fixed; right: 30px; bottom: calc(30px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  display: flex; flex-direction: column; width: 400px; height: min(620px, calc(100dvh - 104px));
  filter: drop-shadow(0 0 28px var(--wv-glow));
}
.wv[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) { .wv { animation: hud-open 300ms var(--ease-out); } }

.wv__head { flex: none; display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s3) var(--s3) var(--s5); border-bottom: 1px solid var(--line); }
.wv__avatar { flex: none; width: 28px; height: 28px; fill: var(--text); }
.wv__id { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; margin: 0; }
.wv__name { font: 700 0.875rem/1.1 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text); }
.wv__status { display: inline-flex; align-items: center; gap: 6px; font: 400 0.6875rem/1.1 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.wv__dot { width: 6px; height: 6px; background: currentColor; }
@media (prefers-reduced-motion: no-preference) { .wv__dot { animation: hud-blink 1.6s steps(2, jump-none) infinite; } }
.wv__close { flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; background: none; color: var(--text-2); cursor: pointer; box-shadow: inset 0 0 0 1px var(--line); transition: color 160ms ease, box-shadow 160ms ease; }
.wv__close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.wv__close:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 0; }
@media (any-hover: hover) and (any-pointer: fine) { .wv__close:hover { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); } }

.wv__quest { flex: none; display: grid; gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); background: var(--accent-tint); }
.wv__quest[hidden] { display: none; }
.wv__quest p { display: flex; justify-content: space-between; gap: var(--s3); margin: 0; font: 400 0.6875rem/1.3 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.wv__quest p span:last-child { flex: none; color: var(--accent); font-weight: 700; }

.wv__log {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: var(--s3); padding: var(--s4); overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  background: repeating-linear-gradient(0deg, transparent 0 3px, var(--wv-scan) 3px 4px);
}
.wv-msg { flex: none; max-width: 92%; font-size: 0.9375rem; line-height: 1.45; overflow-wrap: anywhere; }
.wv-msg p { margin: 0; }
.wv-msg a { display: inline-block; margin-top: var(--s2); color: var(--accent); font: 700 0.75rem/1.3 var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; text-underline-offset: 3px; }
.wv-msg--bot { align-self: flex-start; display: grid; gap: var(--s1); padding: 2px 0 2px var(--s3); border-left: 2px solid var(--accent); color: var(--text); }
.wv-msg--bot::before { content: "WHITEV"; font: 700 0.625rem/1.2 var(--font-mono); letter-spacing: 0.1em; color: var(--accent); }
.wv-msg--you { --cut: 8px; --cut-line: var(--accent); --cut-fill: var(--surface-2); align-self: flex-end; padding: 10px 14px; color: var(--text); font-weight: 500; }
.wv-msg--typing { display: flex; align-items: center; gap: 4px; }
.wv-msg--typing::before { content: "PROCESSING"; margin-right: var(--s1); color: var(--text-3); font-weight: 400; }
.wv-msg--typing i { width: 6px; height: 6px; background: var(--accent); animation: hud-blink 900ms steps(2, jump-none) infinite; }
.wv-msg--typing i:nth-child(2) { animation-delay: 150ms; }
.wv-msg--typing i:nth-child(3) { animation-delay: 300ms; }
@media (prefers-reduced-motion: no-preference) {
  .wv-msg--bot:not(.wv-msg--typing) { animation: hud-scan 280ms var(--ease-out); }
}

.wv-choices { flex: none; display: grid; gap: var(--s2); counter-reset: wv-choice; }
.wv-choice {
  --cut: 8px;
  display: flex; align-items: center; min-height: 40px; padding: var(--s2) var(--s3); border: 0; cursor: pointer; text-align: left; text-decoration: none;
  color: var(--text); font: 500 0.875rem/1.3 var(--font-body); counter-increment: wv-choice;
}
.wv-choice > span { flex: 1 1 auto; display: flex; align-items: baseline; gap: var(--s3); min-width: 0; }
.wv-choice > span::before { content: counter(wv-choice, decimal-leading-zero); flex: none; font: 400 0.6875rem/1 var(--font-mono); color: var(--accent); }
.wv-choice > span::after { content: "›"; flex: none; margin-inline-start: auto; color: var(--text-3); font-family: var(--font-mono); transition: transform 160ms var(--ease-out), color 160ms ease; }
.wv-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 0; }
@media (any-hover: hover) and (any-pointer: fine) {
  .wv-choice:hover { --cut-line: var(--accent); --cut-fill: var(--surface-2); }
  .wv-choice:hover > span::after { color: var(--accent); transform: translateX(3px); }
}

.wv__ask { flex: none; display: grid; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }
.wv__ask[hidden] { display: none; }
.wv__ask label { font: 400 0.6875rem/1.2 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.wv__row { display: flex; align-items: stretch; gap: var(--s2); min-width: 0; }
/* Wide enough for the longest code shown, "+1868 TT". */
.wv__cc { flex: none; width: 128px; }
.wv__cc[hidden] { display: none; }
.wv__cc .ui-select__btn { min-height: 44px; padding: 0 24px 0 12px; border-radius: 0; background-position: right 8px center; font-family: var(--font-mono); font-size: 0.875rem; }
.wv__cc .ui-select__pop { border-radius: 0; }
.wv__input { flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 0 var(--s3); border: 0; border-bottom: 2px solid var(--line-strong); border-radius: 0; outline: 0; background: var(--surface-2); color: var(--text); caret-color: var(--accent); font: 400 1rem/1.2 var(--font-mono); transition: border-color 160ms ease; }
.wv__input::placeholder { color: var(--text-3); }
.wv__input:focus { border-color: var(--accent); }
.wv__input[aria-invalid="true"] { border-color: var(--danger); }
.wv__send { --cut: 8px; --cut-line: var(--accent-fill); --cut-fill: var(--accent-fill); flex: none; display: grid; place-items: center; width: 44px; padding: 0; border: 0; color: var(--on-accent); cursor: pointer; }
.wv__send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wv__send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 0; }
.wv__err { margin: 0; color: var(--danger); font: 400 0.8125rem/1.35 var(--font-mono); }
.wv__err:empty { display: none; }
.wv__err::before { content: "! "; font-weight: 700; }
.wv__fine { margin: 0; color: var(--text-3); font-size: 0.75rem; line-height: 1.4; }
.wv__fine a { color: inherit; }
/* Off-screen, not display:none: bots skip fields that are plainly hidden. */
.wv__hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.wv__foot { flex: none; display: flex; justify-content: flex-end; padding: 0 var(--s5) var(--s3) var(--s4); }
.wv__foot:has(> [hidden]:only-child) { display: none; }
.wv__notme { padding: var(--s1) 0; border: 0; background: none; color: var(--text-3); font: 400 0.6875rem/1.2 var(--font-mono); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

@keyframes hud-open { from { opacity: 0; clip-path: inset(50% 0 50% 0); } to { opacity: 1; clip-path: inset(-40px -40px -40px -40px); } }
@keyframes hud-rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes hud-scan { from { opacity: 0; clip-path: inset(0 0 100% 0); } to { opacity: 1; clip-path: inset(0 -4px 0 -4px); } }
@keyframes hud-blink { 50% { opacity: 0.25; } }
@keyframes hud-ping { 0% { opacity: 0; transform: scale(1); } 12% { opacity: 0.6; } 45%, 100% { opacity: 0; transform: scale(1.32); } }

/* ── Phones ── */
@media (max-width: 760px) {
  .wv-launch { right: 10px; bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
  .wv-tip { right: 70px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 90px); }
  .player { padding: 20px; align-items: start; padding-top: max(20px, 12dvh); }
  .player__box { gap: 12px; padding: 20px; }
  .player__title { font-size: 1.875rem; }
  .player__field { min-height: 48px; }
  .player__start, .player__skip { min-height: 48px; }

  /* A sheet that lifts with the keyboard (fitToKeyboard in whitev.js). Both top corners cut. */
  .wv {
    --cut: 16px;
    left: 0; right: 0; bottom: var(--wv-bottom, 0px); width: auto;
    height: min(88dvh, var(--wv-max, 88dvh)); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .wv::before, .wv::after { clip-path: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%, 0 var(--cut)); }
  .wv > .hud-brackets { display: none; }
  .wv__head { padding: 4px 8px 4px 20px; }
  .wv__close { width: 48px; height: 48px; box-shadow: none; }
  .wv__quest { gap: 8px; padding: 12px 20px; }
  .wv__log { gap: 12px; padding: 12px 20px; }
  .wv-msg { font-size: 1rem; line-height: 1.5; }
  .wv-choices { gap: 8px; }
  .wv-choice { min-height: 48px; padding: 8px 12px; font-size: 1rem; }
  .wv__ask { gap: 8px; padding: 12px 20px; }
  .wv__cc .ui-select__btn, .wv__input { min-height: 48px; }
  .wv__send { width: 48px; }
  .wv__foot { padding: 0 20px 12px; }
  html.wv-open .fab-wa, html.wv-open .o3-zombie { visibility: hidden; }
}
/* 320px phones: a 10-digit number still has to fit beside the code. */
@media (max-width: 360px) {
  .wv__cc { width: 100px; }
  .wv__cc .ui-select__btn { padding: 0 22px 0 8px; background-position: right 6px center; font-size: 0.8125rem; }
  .wv__input { padding-inline: 8px; }
}
