/* A dashboard on its own page, and the parts every dashboard shares (.w-).
   One screen, no scrolling. A slim bar on top with the only way off the page, then the picture.
   On arrival: one number, one sentence, one control and a More button. The rest waits behind More or a tap. */

html.world, html.world body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background: #05060a; }
html.world body { position: fixed; inset: 0; }


/* ---------- The picture ---------- */

.world-stage { position: absolute; inset: 56px 0 0 0; overflow: hidden; background: #05060a; }
.world-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* If it can't run: the still, its line and Back. Never a blank box. */
.world-still { position: absolute; inset: 0; z-index: 8; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 24px; background: #05060a; text-align: center; }
.world-still img { width: min(760px, 100%); height: auto; border-radius: 14px; box-shadow: 0 0 0 1px var(--line); }
.world-still p { max-width: 34em; color: var(--ink); }
html.world-failed .world-still { display: flex; }
html.world-failed .world-canvas, html.world-failed .w-hud { display: none; }


/* ---------- What floats over the picture ---------- */

.w-hud {
  position: absolute;
  inset: 0;
  z-index: 3;
  container: hud / size;
  pointer-events: none;
  color: var(--ink);
  --hud-bot: 0px;
  --hud-top: clamp(16px, 2.6vh, 28px);
  --hud-pad: clamp(14px, 3vw, 44px);
}
/* Whatever the picture's doing, the number and the sentence always read. */
.w-hud::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: min(680px, 60cqw);
  height: min(380px, 60cqh);
  pointer-events: none;
  background: radial-gradient(100% 100% at 0 0, rgba(3, 4, 8, .88) 24%, rgba(3, 4, 8, .5) 58%, transparent 100%);
}
.w-hud a, .w-hud button, .w-hud input, .w-hud label, .w-hud output, .w-hud .w-panel, .w-hud .w-drawer { pointer-events: auto; }

.w-kicker { display: block; font-size: 16px; font-weight: 500; line-height: 1.3; color: var(--ink-2); }

.w-big {
  display: block;
  font-size: clamp(38px, 4.4cqw, 64px);
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.035em;
}
.w-sub {
  font-size: 18px;
  line-height: 1.36;
  color: var(--ink);
  text-wrap: pretty;
  text-shadow: 0 1px 12px rgba(5, 6, 10, .95), 0 0 2px rgba(5, 6, 10, .6);
}

/* What the number is: small, muted and right beside it. */
.w-figure { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; min-width: 0; }
.w-unit { font-size: 17px; font-weight: 500; line-height: 1.3; color: var(--ink-2); white-space: nowrap; text-shadow: 0 1px 12px rgba(5, 6, 10, .95); }

/* The world's own top block: the number and the sentence and nothing else. */
html.world .w-hud > [class$="-top"] .w-kicker { display: none; }
html.world .w-hud.is-sel > [class$="-top"] .w-kicker { display: block; }
html.world .w-hud > [class$="-top"] { max-width: min(460px, 40cqw); gap: 8px; }

html.world .w-hud > [class$="-top"] > [class$="-feed"]:not(.is-on) { display: none; }

/* The how-to line. */
.w-howto {
  position: absolute;
  z-index: 1;
  left: calc(var(--hud-pad) - 11px);
  bottom: calc(var(--dock-h, 80px) + 22px);
  max-width: calc(100cqw - 2 * var(--hud-pad));
  margin: 0;
  padding: 5px 11px;
  border-radius: 9px;
  background: rgba(5, 6, 10, .78);
  font-size: 16px;
  line-height: 1.32;
  color: var(--ink);
  transition: opacity .4s;
  pointer-events: none;
}
.w-howto.is-used { opacity: 0; }
.w-hud.is-sel .w-howto, .w-hud.is-drawer-open .w-howto { display: none; }

.w-panel {
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 16px;
  background: #0b0d14;
}
.w-panel .w-kicker { font-size: 16px; }

.w-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .04);
  font-size: 16px;
  font-weight: 550;
  line-height: 1.15;
  color: var(--ink);
  transition: border-color .2s, background-color .2s, color .2s;
}
.w-btn:hover { border-color: rgba(255, 255, 255, .5); }
.w-btn[disabled] { opacity: .55; cursor: default; }
.w-btn[hidden] { display: none; }
.w-btn-gold { border-color: var(--gold-edge); background: var(--gold-wash); color: var(--gold-hi); }
.w-btn-gold:hover { border-color: var(--gold); color: #fff3d0; }
.w-icon { width: 44px; padding: 0; flex: none; }
.w-icon svg { width: 18px; height: 18px; }

/* Slider. The input fills a 44px tall track, so the whole height is the target. */
.w-slider { display: grid; gap: 0; min-width: 0; }
.w-slider-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.w-slider-value { font-size: 17px; font-weight: 600; letter-spacing: -.012em; color: var(--ink); white-space: nowrap; }
.w-slider-track { position: relative; height: 44px; --p: 0; }
.w-slider-track::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 4px;
  background:
    linear-gradient(90deg, var(--gold-lo), var(--gold-hi)) 0 0 / calc(12px + (100% - 24px) * var(--p)) 100% no-repeat,
    rgba(255, 255, 255, .2);
}
.w-slider input {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  background: none;
  cursor: grab;
  touch-action: none;
}
.w-slider input:active { cursor: grabbing; }
.w-slider input::-webkit-slider-runnable-track { height: 100%; background: none; }
.w-slider input::-moz-range-track { height: 100%; background: none; }
.w-slider input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin-top: 10px;
  border: 0;
  border-radius: 50%;
  background: var(--gold-hi);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .6);
}
.w-slider input::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: var(--gold-hi);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .6);
}
.w-slider input:focus-visible { outline: none; }
.w-slider input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px #05060a, 0 0 0 5px var(--gold-hi); }
.w-slider-ticks { display: none; }

/* On a touch screen: the same size of dot, inside a 44px target. The bar starts and ends where the dot does. */
@media (hover: none) {
  .w-slider-track::before {
    left: 10px;
    right: 10px;
    background:
      linear-gradient(90deg, var(--gold-lo), var(--gold-hi)) 0 0 / calc(12px + (100% - 24px) * var(--p)) 100% no-repeat,
      rgba(255, 255, 255, .2);
  }
  .w-slider input::-webkit-slider-thumb {
    width: 44px;
    height: 44px;
    margin-top: 0;
    border-radius: 0;
    background: radial-gradient(circle at 50% 50%, var(--gold-hi) 0, var(--gold-hi) 13px, transparent 14px);
    box-shadow: none;
  }
  .w-slider input::-moz-range-thumb {
    width: 44px;
    height: 44px;
    border-radius: 0;
    background: radial-gradient(circle at 50% 50%, var(--gold-hi) 0, var(--gold-hi) 13px, transparent 14px);
    box-shadow: none;
  }
}

/* Labels that follow points in the picture. */
.w-labs { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.w-lab {
  position: absolute;
  left: 0; top: 0;
  opacity: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--ink);
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(4, 5, 9, 1), 0 0 3px rgba(4, 5, 9, 1);
  transition: opacity .28s;
  will-change: transform;
}
.w-lab.is-on { opacity: 1; }


/* ---------- The panel at the bottom: one control and More ---------- */

html.world .w-hud .w-drawer {
  position: absolute;
  z-index: 2;
  left: var(--hud-pad);
  right: auto;
  top: auto;
  bottom: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 18px;
  width: min(620px, calc(100cqw - 2 * var(--hud-pad)));
  max-height: calc(100cqh - var(--hud-top) - 28px);
  padding: 8px 12px 6px 20px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 16px;
  background: #0b0d14;
}
html.world .w-hud .w-drawer-handle {
  grid-column: 2;
  grid-row: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  font-size: 16px;
  font-weight: 550;
  color: var(--ink);
  transition: border-color .2s;
}
html.world .w-hud .w-drawer-handle:hover { border-color: rgba(255, 255, 255, .56); }
html.world .w-hud .w-drawer-head { grid-column: 1; grid-row: 1; display: block; min-width: 0; }
html.world .w-hud .w-drawer-body { grid-column: 1 / -1; grid-row: 2; display: none; gap: 12px; min-width: 0; padding: 4px 0 4px; }
html.world .w-hud .w-drawer.is-open .w-drawer-body { display: grid; }
html.world .w-hud .w-drawer-body p { font-size: 16px; line-height: 1.4; color: var(--ink-2); }
html.world .w-hud .w-drawer-body [class$="-btns"] { display: flex; flex-wrap: wrap; gap: 8px; }
html.world .w-hud .w-drawer-body [class$="-btns"] .w-btn { white-space: normal; }
html.world .w-hud .w-drawer-body [class$="-keys"] { position: static; display: grid; gap: 4px; justify-items: start; text-align: left; pointer-events: auto; }
html.world .w-hud .w-drawer-body [class$="-hint"] { display: none; }
html.world .w-hud .w-drawer-body [class$="-key"] { display: block; }

/* The main action and the second step of More. */
html.world .w-hud .w-drawer-body > .w-main { width: 100%; white-space: normal; }
.w-fold { min-width: 0; }
.w-fold-sum {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 2px;
  font-size: 16px;
  font-weight: 550;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  pointer-events: auto;
}
.w-fold-sum::-webkit-details-marker { display: none; }
.w-fold-sum::after {
  content: '';
  width: 8px;
  height: 8px;
  margin-top: -3px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}
.w-fold[open] .w-fold-sum::after { margin-top: 3px; transform: rotate(-135deg); }
.w-fold-in { display: grid; gap: 12px; padding: 4px 0 6px; min-width: 0; }

@container hud (max-width: 640px) {
  .w-big { font-size: 40px; }
  .w-sub { font-size: 16px; }
  html.world .w-hud .w-drawer {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    /* About 40% of the phone at most, so the picture stays in view while a slider moves. Anything past that scrolls inside it. */
    max-height: max(168px, 42cqh);
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom)) 16px;
    border-width: 1px 0 0;
    border-radius: 16px 16px 0 0;
  }
  html.world .w-hud .w-drawer-body { gap: 6px; padding: 0; }
  html.world .w-hud .w-drawer { row-gap: 2px; }
  html.world .w-hud > [class$="-top"] { max-width: none; left: 14px; right: 14px; }
  .w-hud.is-drawer-open::before { height: 96px; }
  .w-howto { bottom: calc(var(--dock-h, 80px) + 10px); left: 3px; right: auto; max-width: calc(100cqw - 6px); }
  .w-hud.is-drawer-open > [class$="-top"] .w-sub { display: none; }
  .w-hud::before { width: 100%; height: min(190px, 40cqh); background: linear-gradient(180deg, rgba(3, 4, 8, .86) 55%, rgba(3, 4, 8, .4) 82%, transparent); }
}

/* A very narrow phone: the label and its value still share one line. */
@container hud (max-width: 340px) {
  .w-slider-head { gap: 8px; }
}

/* A phone on its side: the picture gets the room, the words get small. */
@container hud (max-height: 420px) and (min-width: 560px) {
  .w-big { font-size: 32px; }
  html.world .w-hud .w-drawer { left: auto; right: var(--hud-pad); width: min(420px, 56cqw); bottom: 8px; border-width: 1px; border-radius: 14px; max-height: calc(100cqh - 16px); }
  html.world .w-hud > [class$="-top"] { max-width: 38cqw; right: auto; }
  .w-howto { left: calc(var(--hud-pad) - 11px); bottom: 12px; right: auto; max-width: 38cqw; font-size: 15px; }
  /* Money has no cost labels on its side, so there's nothing named to drag. */
  .mx-top .w-howto { display: none; }
}

/* Money: the labels on the river are the control, so the panel is only the More button until it's open. Its how-to sits up by the sentence, clear of the big number. */
html.world .w-hud .mx-dock:not(.is-open) { left: auto; right: var(--hud-pad); bottom: 14px; width: auto; grid-template-columns: auto; padding: 0; border: 0; border-radius: var(--r-pill); background: #0b0d14; }
html.world .w-hud .mx-dock:not(.is-open) .w-drawer-head { display: none; }
html.world .w-hud .mx-dock:not(.is-open) .w-drawer-handle { grid-column: 1; }
html.world .w-hud .mx-dock.is-open .w-drawer-head { display: none; }
html.world .w-hud .mx-dock.is-open .w-drawer-handle { grid-column: 2; grid-row: 1; justify-self: end; }
/* Open: the slider sits beside Less, the same as every other dashboard. */
html.world .w-hud .mx-dock.is-open .w-drawer-body { display: contents; }
html.world .w-hud .mx-dock.is-open .w-drawer-body > .w-slider { grid-column: 1; grid-row: 1; }
html.world .w-hud .mx-dock.is-open .w-drawer-body > :not(.w-slider) { grid-column: 1 / -1; }
@container hud (min-width: 641px) { html.world .w-hud .mx-dock.is-open { width: min(500px, 42cqw); } }
.mx-top .w-howto { position: static; left: auto; bottom: auto; justify-self: start; max-width: none; margin-left: -11px; }

@media (prefers-reduced-motion: reduce) {
  .w-btn, .w-lab, .w-howto { transition: none !important; }
}
