/* ============================================================
   Tech-Priest Payback Calculator — styles
   Lives on the wiki (reference.css, 16px root). All text is #fff
   and >=1rem per project rules. Differentiation is via background
   fills and accent borders, never dimmed text.
   ============================================================ */

:root { --tpp-purchaser: #b66ad9; }

/* give this tool a wider band than the default wiki max-width */
.wiki-main { max-width: 1340px; }

.tpp-intro {
  font-size: 1.05rem;
  color: #fff;
  line-height: 1.55;
  margin: 0 0 24px;
}

/* info icon next to the page title (mechanics summary in its tooltip) */
.tpp-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  color: var(--gold);
  font-size: 1.15rem;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  cursor: help;
  margin-left: 12px;
  vertical-align: middle;
  user-select: none;
  transition: background .15s;
}
.tpp-info:hover, .tpp-info:focus { background: var(--gold-glow); outline: none; }
/* smaller info icon for sub-section / heading labels */
.tpp-info-sm { width: 16px; height: 16px; font-size: 0.72rem; margin-left: 5px; border-width: 1.5px; }
/* let the plain-text info tooltips keep their line breaks (scoped to this page) */
.rw-tip {
  white-space: pre-line;
  background: #34344c !important;
  border: 2px solid var(--gold) !important;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.7) !important;
  font-size: 0.95rem !important;
}

/* rich (HTML) tooltip for the payout-timeline icon — bullets + colored break-even terms */
.tpp-tl-infowrap { position: relative; display: inline-block; vertical-align: middle; }
.tpp-tl-tip {
  position: absolute;
  left: 0;
  top: calc(100% + 7px);
  z-index: 200;
  display: none;
  width: 340px;
  max-width: 78vw;
  background: #34344c;
  border: 2px solid var(--gold);
  border-radius: 4px;
  padding: 11px 13px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.7);
  font-size: 0.95rem;
  font-weight: 400;
  font-style: normal;
  line-height: 1.45;
  color: #fff;
  text-align: left;
  white-space: normal;
}
.tpp-tl-infowrap:hover .tpp-tl-tip,
.tpp-tl-infowrap:focus-within .tpp-tl-tip { display: block; }
/* flip above the icon when JS finds there is no room below */
.tpp-tl-infowrap.flip-up .tpp-tl-tip { top: auto; bottom: calc(100% + 7px); }
.tpp-tl-tip-lead { display: block; margin-bottom: 8px; }
.tpp-tl-tip-item { display: block; position: relative; padding-left: 16px; margin-bottom: 5px; }
.tpp-tl-tip-item:last-child { margin-bottom: 0; }
.tpp-tl-tip-item::before { content: "\2022"; position: absolute; left: 2px; color: var(--gold); }
.tpp-be-group { color: var(--blue); font-weight: 700; }
.tpp-be-purchaser { color: var(--tpp-purchaser); font-weight: 700; }

.tpp-tool { display: flex; flex-direction: column; gap: 24px; }

.tpp-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}
.tpp-panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 6px;
}

/* ============================================================
   Inputs
   ============================================================ */
/* inputs zone is framed as a gold card (matches the gold active toggles)
   so it reads clearly as "what you set", vs the plain output tiles below */
.tpp-inputs {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* difficulty / players / current wave share one row, each its own bordered sub-card */
.tpp-settings-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; }
.tpp-setting {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  padding: 12px 10px;
}
.tpp-setting-duration { gap: 9px; flex: 1 1 340px; }
/* count selectors (tech-priests / turrets / mines / commissar) — buttons already fill
   the card via the rule below; allow up to 4 to sit on one line in a narrow card */
.tpp-seg-count .tpp-seg-btn { min-width: 0; padding-left: 4px; padding-right: 4px; }
/* difficulty / player count / current wave cards stretch to fill the row,
   their segmented buttons fill each card so there is no gap on the right */
.tpp-settings-row > .tpp-setting:not(.tpp-setting-duration):not(.tpp-setting-support) { flex: 1 1 auto; }
.tpp-settings-row > .tpp-setting:not(.tpp-setting-duration):not(.tpp-setting-support) .tpp-seg { width: 100%; }
.tpp-settings-row > .tpp-setting:not(.tpp-setting-duration):not(.tpp-setting-support) .tpp-seg-btn { flex: 1 1 0; }
.tpp-label {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}
/* underlined section-label text (white); the info icon stays outside the underline */
.tpp-label-text {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.tpp-hint {
  display: inline-block;
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  border-bottom: 1px dotted var(--gold);
  cursor: help;
}
.tpp-sub { font-size: 1rem; color: #fff; line-height: 1.5; margin: 0; }

/* segmented controls — content-sized, uniform */
.tpp-seg { display: flex; gap: 11px; flex-wrap: wrap; }
.tpp-seg-btn {
  flex: 0 0 auto;
  min-width: 52px;
  font-size: 1.05rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  background: var(--surface2);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius);
  padding: 9px 18px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.2;
  white-space: nowrap;
}
.tpp-seg-btn:hover { border-color: var(--gold-dim); background: var(--surface3); }
.tpp-seg-btn:active { transform: translateY(1px); }
.tpp-seg-btn.active {
  border-color: var(--gold);
  background: var(--surface3);
  box-shadow: inset 0 0 0 1px var(--gold);
  color: #fff;
}
.tpp-seg-sub { font-size: 1rem; font-weight: 600; color: var(--gold); }
/* difficulty emblem on the Normal/Hard buttons (sits above the label) */
.tpp-diff-icon { width: 50px; height: 50px; object-fit: contain; opacity: 0.5; transition: opacity .15s; }
.tpp-seg-btn.active .tpp-diff-icon { opacity: 1; filter: brightness(1.7); }
.tpp-diff-rate { font-size: 1rem; font-weight: 600; color: var(--gold); }
.tpp-diff-meta { color: var(--gold); font-weight: 600; font-size: 1rem; }
/* per-unit cost shown at the bottom of each purchase card */
.tpp-cost { text-align: center; color: #fff; font-size: 1.05rem; font-weight: 600; }
/* right-justify the difficulty payout and reserve a fixed width so swapping
   Normal/Hard (different text widths) no longer shifts the cards */
.tpp-setting-diff .tpp-label { display: flex; align-items: baseline; }
.tpp-setting-diff .tpp-diff-meta { margin-left: auto; min-width: 175px; text-align: right; white-space: nowrap; }
/* Current Wave card ~10% wider (Player Count has the buffer to give) */
.tpp-setting-cw { min-width: 215px; }

/* ============================================================
   icon-fill selectors (tech-priests / turrets / mines / commissar)
   replaces the 0-3 number buttons. Cumulative: tile k filled => count == k.
   White in-game icon in a square tile; filled = gold border + gold glow
   (matches .tpp-seg-btn.active), empty = neutral border + dimmed icon.
   ============================================================ */
.tpp-iconfill {
  display: flex;
  gap: 11px;
  justify-content: center;
  flex-wrap: nowrap;
}
.tpp-iconfill-tile {
  flex: 0 0 auto;
  min-width: 34px;
  height: 50px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius);
  padding: 0 4px;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
/* count is shown by the number of icons (1, 2 or 3); they sit almost edge to edge
   with just a hair of overlap so each one stays distinct */
.tpp-iconfill-tile img + img { margin-left: -5px; }
/* per-control icon overlap tuning */
#tpp-players .tpp-iconfill-tile img + img { margin-left: -11px; }
#tpp-priests .tpp-iconfill-tile img + img { margin-left: -3px; }
.tpp-iconfill-tile img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  /* keep the source art as-is (crisp); the dark filled tile means it never
     reads yellow, and opacity below just dims the unselected ones */
  opacity: 0.5;
  transition: opacity .15s;
  pointer-events: none;
}
.tpp-iconfill-tile:hover { border-color: var(--gold-dim); background: var(--surface3); }
.tpp-iconfill-tile:hover img { opacity: 0.75; }
.tpp-iconfill-tile:active { transform: translateY(1px); }
.tpp-iconfill-tile.filled {
  border-color: var(--gold);
  background: var(--surface3);
  box-shadow: inset 0 0 0 1px var(--gold);
}
/* selected icons brightened toward white (shop icons read grey/dim otherwise) */
.tpp-iconfill-tile.filled img { opacity: 1; filter: brightness(1.7); }
.tpp-iconfill-tile.filled:hover { border-color: var(--gold); }
.tpp-iconfill-tile:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* in-game Siege currency symbol, prefixed on every currency value like a $ sign.
   ID selectors used so it survives the JS className swap on the net (pos/neg) tiles. */
#tpp-buyer-buyin::before, #tpp-buyergross::before, #tpp-yournet::before,
#tpp-buyin-val::before, #tpp-squadgross::before, #tpp-squadnet::before,
.tpp-diff-rate::before, .tpp-cost::before {
  content: "";
  display: inline-block;
  width: 0.92em;
  height: 0.92em;
  margin-right: 0.16em;
  vertical-align: -0.1em;
  background: url("/assets/shop-icons/currency.png") center / contain no-repeat;
}

/* range slider */
.tpp-slider-row { display: flex; align-items: center; gap: 16px; width: 100%; }
.tpp-range {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 auto;
  height: 8px;
  border-radius: 6px;
  background: var(--surface3);
  border: 1px solid var(--border);
  outline: none;
}
.tpp-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #0b0b12;
  cursor: pointer;
}
.tpp-range::-moz-range-thumb {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #0b0b12;
  cursor: pointer;
}
.tpp-range-out { font-size: 1.1rem; font-weight: 800; color: var(--gold); min-width: 66px; text-align: right; }

/* sliders with a tick scale + the value shown underneath */
.tpp-slider-col { display: flex; flex-direction: column; width: 100%; margin: auto 0; }
.tpp-slider-col .tpp-range { width: 100%; }
.tpp-scale { position: relative; height: 27px; margin: 7px 12px 0; }
.tpp-scale .tk { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 1rem; font-weight: 600; color: #fff; white-space: nowrap; }
.tpp-scale .tk::before { content: ""; width: 1px; height: 7px; background: var(--gold-dim); }
.tpp-scale .tk.tk-minor::before { height: 4px; }
.tpp-scale .tk.tk-active { color: var(--gold); font-weight: 800; font-size: 1.15rem; }
.tpp-scale .tk.tk-active::before { background: var(--gold); height: 9px; }
.tpp-out-below { align-self: center; min-width: 0; text-align: center; margin-top: 4px; }
.tpp-setting-duration .tpp-label { display: flex; align-items: center; }
.tpp-pace-time { margin-left: auto; font-size: 1.1rem; font-weight: 800; color: var(--gold); }

/* ============================================================
   Verdict
   ============================================================ */
/* no master card / no verdict badge: the tool's sections (inputs, KPI tiles,
   timeline) sit directly in the page with no wrapping border */
.tpp-verdict {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: none;
  background: none;
  padding: 0;
}

.tpp-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.tpp-stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.tpp-stat-val { font-size: 1.8rem; font-weight: 800; color: #fff; line-height: 1; }
.tpp-stat-val.pos { color: var(--green); }
.tpp-stat-val.neg { color: var(--red); }
.tpp-stat-label { font-size: 1rem; font-weight: 600; color: #fff; }

/* ============================================================
   Payout timeline
   ============================================================ */
/* z-index lifts the header (and its drop-down info tooltip) above the timeline
   cells below it, so the tooltip never paints underneath them */
.tpp-tl-header { position: relative; z-index: 30; margin-bottom: 14px; }
.tpp-tl-header .tpp-panel-title { margin: 0; }
.tpp-tl-empty { grid-column: 1 / -1; font-size: 1.05rem; color: #fff; line-height: 1.55; margin: 0; }
.tpp-timeline {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin: 14px 0 44px;
}
.tpp-tick {
  position: relative;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 6px;
  min-height: 68px;
  text-align: center;
  border: 1px solid var(--border);
  background: var(--surface3);
  cursor: default;
}
.tpp-tick.is-collected {
  background: linear-gradient(160deg, var(--gold), var(--gold-dim));
  border-color: var(--gold);
}
.tpp-tick.is-lost { background: var(--surface2); opacity: 0.45; }
.tpp-tick-num { font-size: 1.05rem; font-weight: 800; color: #fff; line-height: 1.15; }
.tpp-tick-time { font-size: 1rem; font-weight: 600; color: #fff; line-height: 1.1; }
.tpp-tick.is-collected .tpp-tick-num,
.tpp-tick.is-collected .tpp-tick-time { color: #0b0b12; }
/* two break-even rings: group (blue, whole squad) and purchaser (violet, the buyer) */
/* break-even cells keep the lost-cell opacity, so an unreached marker greys out
   with its payout (no opacity override here on purpose) */
.tpp-tick.is-be-group,
.tpp-tick.is-be-purchaser,
.tpp-tick.is-be-both { outline: 3px solid var(--blue); outline-offset: 2px; }
.tpp-tick.is-be-purchaser { outline-color: var(--tpp-purchaser); }
.tpp-tick-label {
  position: absolute;
  bottom: -48px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
}
.tpp-tick-label.is-group,
.tpp-tick-label.is-both { color: var(--blue); }
.tpp-tick-label.is-purchaser { color: var(--tpp-purchaser); }
.tpp-timeline-legend { font-size: 1.05rem; color: #fff; line-height: 1.5; margin: 22px 0 0; }

/* ============================================================
   Notes
   ============================================================ */
.tpp-notes-list { margin: 8px 0 0; padding-left: 22px; }
.tpp-notes-list li {
  font-size: 1.05rem;
  color: #fff;
  line-height: 1.55;
  margin-bottom: 10px;
}
.tpp-notes-list li:last-child { margin-bottom: 0; }
.tpp-notes-list strong { color: var(--gold); }

/* ============================================================
   Narrow screens (kept functional; tool is desktop-first)
   ============================================================ */
@media (max-width: 620px) {
  .tpp-field { grid-template-columns: 1fr; gap: 8px; align-items: start; }
  .tpp-stats { grid-template-columns: repeat(2, 1fr); }
  /* 8 columns do not fit a phone. Grid items default to min-width: auto, so the
     ticks refused to shrink below their content and the grid ran to 667px on a
     393px screen, putting the later ticks off-screen entirely. */
  .tpp-timeline { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .tpp-tick { min-width: 0; padding: 12px 4px; }
  .tpp-tick-num, .tpp-tick-time { overflow-wrap: anywhere; }
  .tpp-tick-num { font-size: 1rem; }
  .tpp-tick-label { bottom: -44px; }
}

/* ---- Payout decay by wave (P14.1 spline chart) ------------------------- */
:root { --tpp-normal-line: #5aa9e6; --tpp-hard-line: #e6872e; }

.tpp-dc-block { margin-top: 26px; }
.tpp-decay { width: 100%; }
.tpp-dc-svg { width: 100%; height: auto; display: block; overflow: visible; }

.tpp-dc-grid { stroke: var(--gold-dim); stroke-width: 1; opacity: .35; }
.tpp-dc-grid.is-floor { stroke: var(--gold); opacity: .55; stroke-dasharray: 5 4; }
.tpp-dc-ylab { fill: #fff; font-size: 15px; font-weight: 600; text-anchor: end; }
.tpp-dc-xlab { fill: #fff; font-size: 15px; font-weight: 600; text-anchor: middle; }
.tpp-dc-axis { fill: #fff; font-size: 15px; font-weight: 600; text-anchor: middle; }

.tpp-dc-line { fill: none; stroke-width: 2; opacity: .5; stroke-linecap: round; }
.tpp-dc-line.is-normal { stroke: var(--tpp-normal-line); }
.tpp-dc-line.is-hard { stroke: var(--tpp-hard-line); }
.tpp-dc-line.is-active { stroke-width: 4; opacity: 1; }

.tpp-dc-marker { stroke: var(--gold); stroke-width: 2; stroke-dasharray: 6 5; opacity: .85; }
.tpp-dc-dot { fill: var(--gold); stroke: #12100c; stroke-width: 2; }
.tpp-dc-now { fill: var(--gold); font-size: 17px; font-weight: 800; }

.tpp-dc-legend { display: flex; gap: 26px; flex-wrap: wrap; margin: 14px 0 0; }
.tpp-dc-key { display: inline-flex; align-items: center; gap: 9px; color: #fff; font-size: 1rem; font-weight: 600; }
.tpp-dc-key::before { content: ""; width: 20px; height: 4px; border-radius: 2px; background: var(--gold); }
.tpp-dc-key.is-normal::before { background: var(--tpp-normal-line); }
.tpp-dc-key.is-hard::before { background: var(--tpp-hard-line); }
.tpp-dc-key.is-dot::before { width: 12px; height: 12px; border-radius: 50%; }

/* Run Wave card: 30-stop slider needs real width, and its readout sits on the
   label line like the pace card's does. */
.tpp-setting-cw { min-width: 320px; flex: 1 1 420px; }
.tpp-setting-cw .tpp-label { display: flex; align-items: center; gap: 8px; }
.tpp-setting-cw #tpp-wave-out { margin-left: auto; }

/* Run Wave carries 30 stops, so it takes the wide slot and the pace slider
   (5 stops) sits narrow beside it. */
.tpp-settings-row > .tpp-setting-cw { flex: 2 1 560px; min-width: 420px; }
.tpp-settings-row > .tpp-setting-duration { flex: 1 1 300px; min-width: 280px; }

/* Pace joins difficulty + player count on the top row; Run Wave gets a row of
   its own so its 30 stops have the full width. */
.tpp-settings-row > .tpp-setting-cw { flex: 1 1 100%; min-width: 0; }

/* Current Wave: a minor tick per integer, labelled majors every 5. Minors are
   unlabelled so they need a shorter mark and no reserved text height. */
#tpp-waves-scale .tk.tk-minor::before { height: 5px; }
#tpp-waves-scale .tk.tk-minor.tk-active::before { background: var(--gold); height: 11px; width: 2px; }

/* Decay chart: per-wave payout counts, annotating the curve dot with "xN". */
.tpp-dc-mult { fill: var(--gold); font-size: 15px; font-weight: 800; text-anchor: middle; }

/* Timeline tiles carry three lines now: the running payout count, that tick's
   per-player amount, and the wave it lands in with its fighting time. */
.tpp-tick { min-height: 94px; gap: 3px; }
.tpp-tick-amt { font-size: 1.5rem; font-weight: 800; color: #fff; line-height: 1.1; }
.tpp-tick.is-collected .tpp-tick-amt { color: #0b0b12; }
.tpp-tl-header { display: flex; align-items: baseline; gap: 14px; }
.tpp-tl-note { margin-left: auto; font-size: 1rem; font-weight: 600; color: #fff; white-space: nowrap; }

/* Each tile pairs the tick's own payout with the running per-player total. */
.tpp-tick-amtrow { display: flex; align-items: baseline; justify-content: center; gap: 6px; flex-wrap: nowrap; }
.tpp-tick-amt { font-size: 1.35rem; }
.tpp-tick-cum { font-size: 1.05rem; font-weight: 700; color: #fff; white-space: nowrap; }
.tpp-tick.is-collected .tpp-tick-cum { color: #0b0b12; }

/* Game Mode toggle (Siege / Chaos Siege). It sits on the right of the intro
   text (the text takes about 75% of the width) and is sized to its content.
   Both labels stay full white (project text rule); the gold border and fill
   mark the active mode. The two buttons share one width. */
.tpp-intro-row { display: flex; align-items: center; gap: 24px; margin: 0 0 24px; }
.tpp-intro-row > .tpp-intro { flex: 0 1 75%; margin: 0; }
.tpp-intro-row > .tpp-setting-mode { flex: 0 0 auto; margin-left: auto; }
@media (max-width: 620px) {
  .tpp-intro-row { flex-direction: column; align-items: stretch; gap: 16px; }
  .tpp-intro-row > .tpp-setting-mode { margin-left: 0; align-self: flex-start; }
}
.tpp-setting-mode .tpp-seg { display: grid; grid-template-columns: 1fr 1fr; }
.tpp-setting-mode .tpp-seg-btn { color: #fff; min-width: 0; }
