/* Pip-Boy 3000 (Fallout 3 style) */

/* Drop monofonto.ttf (the font used by Fallout 3/NV) into web/fonts/ to use it.
   Falls back to whatever monospace font the phone has. */
@font-face {
  font-family: 'Monofonto';
  src: url('../fonts/monofonto.ttf') format('truetype');
  font-display: swap;
}

:root {
  --pip: #1bff80;                                            /* set from data.js config.color */
  --pip-mid: color-mix(in srgb, var(--pip) 55%, black);
  --pip-dim: color-mix(in srgb, var(--pip) 28%, black);
  --bg: color-mix(in srgb, var(--pip) 5%, #020403);
  --glow: 0 0 0.25em color-mix(in srgb, var(--pip) 70%, transparent);
  --line: 0.32vmin;                                          /* UI stroke width */
  --u: 1vmin;                                                /* = 1vh in landscape */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

#screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding:
    max(calc(var(--u) * 4), env(safe-area-inset-top))
    max(calc(var(--u) * 6), env(safe-area-inset-right))
    max(calc(var(--u) * 3), env(safe-area-inset-bottom))
    max(calc(var(--u) * 6), env(safe-area-inset-left));
  background: radial-gradient(ellipse at center, color-mix(in srgb, var(--pip) 9%, #020403) 0%, var(--bg) 60%, #000 100%);
  color: var(--pip);
  font-family: 'Monofonto', 'Share Tech Mono', 'Roboto Mono', 'Droid Sans Mono', monospace;
  font-size: calc(var(--u) * 5.2);
  line-height: 1.25;
  letter-spacing: 0.02em;
  text-shadow: var(--glow);
}

/* ---------- Header: "┌ STATS   ‾LVL  12‾|‾HP 210/210‾|‾AP 82/82‾|‾XP 1020/1550‾|" ---------- */
#header {
  --hdr-line: 0.45em;             /* shared top line: ┌ bracket and every stat cell sit on it */
  display: flex;
  align-items: stretch;
  gap: 0.3em;
  flex: none;
  white-space: nowrap;
  position: relative;
}
#header::before {                 /* ┌ bracket left of the title */
  content: '';
  position: absolute;
  left: 0; top: var(--hdr-line); bottom: 0;
  width: 1.2em;
  border-top: var(--line) solid var(--pip);
  border-left: var(--line) solid var(--pip);
}
.hdr-title {                      /* same baseline as the stat cells, line just above */
  align-self: flex-end;
  padding: 0 0.3em 0 1.45em;
  margin-right: 0.3em;
  font-size: 1.15em;
}
.hdr-seg {                        /* each stat: line above, tick down on the right */
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.8em;
  margin-top: var(--hdr-line);
  padding: 0.1em 0.4em 0;
  border-top: var(--line) solid var(--pip);
  border-right: var(--line) solid var(--pip);
}

/* ---------- Footer sub-tabs: "└[Status]─ S.P.E.C.I.A.L. ── Skills ── Perks ─┘" ---------- */
#tabs {
  display: flex;
  align-items: center;
  flex: none;
  padding-top: 0.25em;
  white-space: nowrap;
}
.tab-line {                       /* line runs through the middle of the tab row */
  flex: 1 1 0;
  min-width: 0.6em;
  height: 0;
  border-top: var(--line) solid var(--pip);
  position: relative;
}
.tab-line.start, .tab-line.end { flex: 0 0 1.1em; }
.tab-line.start::before, .tab-line.end::before {   /* └ and ┘ corner ticks */
  content: '';
  position: absolute;
  bottom: 0;
  height: 0.95em;
  border-left: var(--line) solid var(--pip);
}
.tab-line.start::before { left: 0; }
.tab-line.end::before { right: 0; }
.tab {                            /* padding = gap between text and line; the active box touches it */
  padding: 0.15em 0.4em;
  color: var(--pip-mid);
  border: var(--line) solid transparent;
}
.tab.active {
  color: var(--pip);
  border-color: var(--pip);
}

/* ---------- Content area ---------- */
#content {
  flex: 1;
  min-height: 0;
  position: relative;
  padding: 0.6em 0;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 5%;
  height: 100%;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  scrollbar-width: none;
  height: 100%;
}
.list::-webkit-scrollbar { display: none; }
.list li {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.08em 0.4em;
  border: var(--line) solid transparent;
  white-space: nowrap;
}
.list li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.list li.sel { border-color: var(--pip); box-shadow: var(--glow), inset var(--glow); }
.list li.done { color: var(--pip-mid); }
.list li .mark {                  /* equipped / active square */
  width: 0.45em; height: 0.45em;
  flex: none;
  background: transparent;
}
.list li.on .mark { background: var(--pip); box-shadow: var(--glow); }

.detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}
.detail .big {
  font-size: 3.4em;
  line-height: 1;
  text-align: center;
  margin: 0.15em 0;
}
.detail .desc { color: var(--pip); flex: 1; overflow: hidden; }
.detail .desc p { margin: 0 0 0.5em; }

.stats {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0.35em;
  margin-top: 0.35em;
}
.stat {
  display: flex;
  justify-content: space-between;
  padding: 0.05em 0.35em;
  border-top: var(--line) solid var(--pip-mid);
  border-right: var(--line) solid var(--pip-mid);
}

.bar {
  height: 0.55em;
  border: var(--line) solid var(--pip);
  position: relative;
}
.bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--pip);
  box-shadow: var(--glow);
}
.cnd { display: flex; align-items: center; gap: 0.5em; }
.cnd .bar { flex: 1; }

/* ---------- STAT > Status ---------- */
.status {
  display: grid;
  grid-template-columns: auto 1fr;
  height: 100%;
  gap: 4%;
}
.status .list { height: auto; align-self: start; }
.status-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
}
.figure-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  aspect-ratio: 928 / 784;
}
/* White-on-transparent mask, tinted with the theme color */
.vaultboy {
  position: absolute;
  inset: 0;
  background: var(--pip);
  -webkit-mask: url('../img/vaultboy.png') center / contain no-repeat;
  mask: url('../img/vaultboy.png') center / contain no-repeat;
  filter: drop-shadow(0 0 0.15em var(--pip));
}
.limb {
  position: absolute;
  width: 19%;
  transform: translate(-50%, -50%);
}
.status-name { margin-top: 0.2em; }
.rad-meter { width: 100%; max-width: 70%; margin: auto 0; }
.rad-meter .bar { height: 1.1em; margin: 0.4em 0; }
.rad-scale { display: flex; justify-content: space-between; color: var(--pip-mid); font-size: 0.8em; }

/* ---------- Maps & radio ---------- */
.map {
  position: relative;
  height: 100%;
  border: var(--line) solid var(--pip-dim);
  overflow: hidden;
}
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-label {
  position: absolute;
  left: 0.5em; bottom: 0.3em;
  padding: 0 0.3em;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}
canvas.wave { width: 100%; flex: 1; min-height: 0; display: block; }

/* ---------- CRT overlay ---------- */
#crt {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0.28) 0, rgba(0,0,0,0.28) 1px, transparent 1px, transparent 3px);
  animation: flicker 0.15s infinite steps(2);
}
#crt::before {                    /* slow rolling refresh band */
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 25%;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--pip) 6%, transparent), transparent);
  animation: roll 7s linear infinite;
}
#crt::after {                     /* vignette */
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.65) 100%);
}
@keyframes flicker { 0% { opacity: 0.92; } 100% { opacity: 1; } }
@keyframes roll { from { top: -25%; } to { top: 100%; } }

/* CRT power-on */
.power-on { animation: power-on 0.6s ease-out; }
@keyframes power-on {
  0%   { transform: scale(1, 0.005); filter: brightness(4); }
  40%  { transform: scale(1, 0.005); filter: brightness(4); }
  70%  { transform: scale(1, 1.03); filter: brightness(1.6); }
  100% { transform: scale(1, 1); filter: brightness(1); }
}

#tap-hint {
  position: fixed;
  left: 50%; bottom: 18%;
  transform: translateX(-50%);
  z-index: 11;
  padding: 0.3em 0.8em;
  border: var(--line) solid var(--pip);
  background: var(--bg);
  color: var(--pip);
  font-family: 'Monofonto', 'Share Tech Mono', monospace;
  font-size: calc(var(--u) * 4.5);
  text-shadow: var(--glow);
  animation: blink 1.2s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.3; } }

@media (prefers-reduced-motion: reduce) {
  #crt, #crt::before, .power-on { animation: none; }
}

/* Invisible test hotspot (top right): double-tap cycles categories */
#next-cat {
  position: fixed; top: 0; right: 0;
  width: 15vmax; height: 15vmin;
  z-index: 10; background: transparent;
}
