/* =====================================================================
   tower.css — Template 06's live preview: the Control Tower dashboard
   (js/tower.js). The board keeps its own blue / white screen palette in
   both themes: it is a product screen shown inside the page.
   Motion: transform, opacity and stroke-dashoffset only.
   ===================================================================== */

/* the board stands on a navy panel, as a screen on display: its own app
   colours inside, the website's dark band around it */
.tower[data-theme="dark"] {
  padding: clamp(18px, 2.4vw, 32px); border-radius: var(--radius-lg);
  background: radial-gradient(60% 80% at 100% 100%, rgba(var(--steel-rgb), .14), transparent 70%), linear-gradient(180deg, var(--fw-navy) 0%, var(--fw-s80) 100%);
  color: var(--text);
}
.tower {
  --tw-ink: var(--fw-s60);
  --tw-muted: var(--fw-s10);
  --tw-line: var(--fw-t80);
  --tw-bg: var(--fw-t90);
  --tw-card: #ffffff;
  --tw-pale: var(--fw-t80);
  --tw-mid: var(--fw-t50);
  --tw-blue: var(--fw-s10);
  --tw-navy: var(--fw-s60);
  --tw-navy-2: var(--fw-s50);
  --tw-green: #65b387;
  --tw-red: #d23a40;
  --tw-orange: #f08a24;
  margin-top: 48px;
}
.tower[hidden] { display: none; }

/* A template with a live dashboard drops the video kiosk: the info
   column comes first, the kiosk keeps only its chrome bar (template
   name + Previous / Next), and the board follows. */
.detail-body.is-dashboard { grid-template-columns: 1fr; gap: 22px; }
.detail-body.is-dashboard > :first-child { order: 2; }
.detail-body.is-dashboard .kiosk-screen { display: none; }
@media (min-width: 901px) {
  .detail-body.is-dashboard > :last-child {
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 36px; align-items: start;
  }
  .detail-body.is-dashboard .stat-row { grid-column: 1 / -1; }
  .detail-body.is-dashboard .info-block + .info-block { margin-top: 0; }
}

/* ── the template's description, folded (#pl-about) ──
   Any other template: always open, no bar — the page as it was. A
   dashboard template (.is-folding): the board is the first thing seen;
   the description folds into one bar above it, opened on demand. */
.detail-about:not(.is-folding) > .detail-about-bar { display: none; }
.detail-about-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
  padding: 14px 20px; border-radius: var(--radius-lg); cursor: pointer; list-style: none;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-fast) var(--ease-out-quart), box-shadow var(--dur-fast) var(--ease-out-quart);
}
.detail-about-bar::-webkit-details-marker { display: none; }
.detail-about-bar:hover { border-color: var(--blue); }
.detail-about-bar:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.detail-about-text { display: flex; align-items: baseline; gap: 4px 14px; flex-wrap: wrap; min-width: 0; }
.detail-about-text .detail-tagline { margin: 0; }
.detail-about-name { font-size: 17px; font-weight: 800; color: var(--navy-deep); }
.detail-about-cta { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; color: var(--blue); white-space: nowrap; }
.detail-about-chev {
  width: 26px; height: 26px; border-radius: 50%; background: var(--blue-dim); position: relative; flex: none;
  transition: transform var(--dur-fast) var(--ease-out-quart);
}
.detail-about-chev::before {
  content: ""; position: absolute; left: 50%; top: 45%; width: 7px; height: 7px;
  border: solid currentColor; border-width: 0 2px 2px 0; transform: translate(-50%, -50%) rotate(45deg);
}
.detail-about[open] .detail-about-chev { transform: rotate(180deg); }
.detail-about.is-folding[open] > .detail-about-bar { margin-bottom: 24px; }
/* the bar already names it, and the board says "live preview": no second title row */
.detail-about.is-folding .detail-title-row { display: none; }
.detail-about.is-folding + .tower { margin-top: 28px; }
/* where supported, the description slides open rather than snapping */
@supports (interpolate-size: allow-keywords) {
  .detail-about.is-folding { interpolate-size: allow-keywords; }
  .detail-about.is-folding::details-content {
    block-size: 0; overflow: clip;
    transition: block-size var(--dur-base) var(--ease-out-quart), content-visibility var(--dur-base) allow-discrete;
  }
  .detail-about.is-folding[open]::details-content { block-size: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .detail-about-chev, .detail-about.is-folding::details-content { transition: none; }
}

.tw-head { margin-bottom: 18px; }
.tw-kicker {
  font-family: var(--font-mono, monospace);
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent, var(--tw-blue)); margin: 0 0 6px;
}
.tw-heading { font-size: clamp(20px, 2.2vw, 28px); margin: 0 0 6px; color: var(--text, var(--tw-ink)); }
.tw-sub { margin: 0; color: var(--text-muted, var(--tw-muted)); }

/* ── the screen ─────────────────────────────────────────────────── */
.tw {
  color: var(--tw-ink);
  background: var(--tw-bg);
  border: 1px solid var(--tw-line);
  border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-md, 0 10px 30px rgba(var(--fw-s60-rgb), .12));
  overflow: hidden;
  font-size: 12px;
  line-height: 1.3;
}
.tw-board {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}
.tw-details     { grid-column: span 5; }
.tw-events      { grid-column: span 4; }
.tw-pct         { grid-column: span 3; }
.tw-batches-wrap{ grid-column: span 7; min-width: 0; }
.tw-phases      { grid-column: span 5; }
.tw-record,
.tw-charts      { grid-column: 1 / -1; }

.tw-card {
  background: var(--tw-card);
  border: 1px solid var(--tw-line);
  border-radius: 8px;
  padding: 10px;
  min-width: 0;
}
.tw-card-title, .tw-chart-title {
  margin: 0 0 8px;
  font-size: 11px; font-weight: 700;
  color: var(--tw-ink);
}
.tw-label { display: block; font-size: 10.5px; color: var(--tw-muted); }
.tw b { font-weight: 700; font-variant-numeric: tabular-nums; }
.tw svg { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

/* ── batch details ──────────────────────────────────────────────── */
.tw-details-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tw-kpi {
  background: var(--tw-pale);
  border-radius: 6px;
  padding: 8px 10px;
  position: relative;
}
.tw-kpi b { display: block; font-size: 20px; margin-top: 2px; }
.tw-kpi-xl { background: var(--tw-blue); color: #fff; }
.tw-kpi-xl .tw-label { color: rgba(255, 255, 255, .8); }
.tw-kpi-xl b { font-size: 30px; }
.tw-kpi-lg b { font-size: 26px; }
.tw-details-mid { display: grid; gap: 8px; }
.tw-trend { position: absolute; right: 8px; bottom: 8px; color: var(--tw-blue); }
.tw-trend svg { width: 18px; height: 18px; }
.tw-split { display: grid; gap: 4px; }
.tw-split-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-radius: 6px; padding: 5px 10px;
}
.tw-split-row b { font-size: 14px; }
.tw-split-row.is-strong { background: var(--tw-navy-2); color: #fff; }
.tw-split-row.is-strong .tw-label { color: rgba(255, 255, 255, .8); }
.tw-split-row.is-soft { background: var(--tw-mid); }
.tw-split-row.is-muted { background: var(--tw-pale); }

/* ── efficiency & events ────────────────────────────────────────── */
.tw-events-body { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tw-ev { display: grid; grid-template-rows: 1fr 1fr; border-radius: 6px; overflow: hidden; }
.tw-ev-top, .tw-ev-bot { padding: 7px 10px; display: flex; flex-direction: column; justify-content: center; }
.tw-ev b { font-size: 20px; }
.tw-ev-bot b { font-size: 15px; }
.tw-ev.is-cool .tw-ev-top { background: var(--tw-pale); }
.tw-ev.is-cool .tw-ev-bot { background: var(--fw-t90); }
.tw-ev.is-warm .tw-ev-top { background: var(--tw-blue); color: #fff; }
.tw-ev.is-warm .tw-ev-top .tw-label { color: rgba(255, 255, 255, .82); }
.tw-ev.is-warm .tw-ev-bot { background: var(--tw-mid); }
.tw-ev.is-split .tw-ev-top { background: var(--tw-green); color: #fff; }
.tw-ev.is-split .tw-ev-top .tw-label { color: rgba(255, 255, 255, .85); }
.tw-ev.is-split .tw-ev-bot { background: #fbe3e4; color: var(--tw-red); }
.tw-ev.is-split .tw-ev-bot .tw-label { color: var(--tw-red); }

/* ── average PCT cards ──────────────────────────────────────────── */
.tw-pct { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-content: stretch; }
.tw-pct-card {
  background: var(--tw-card);
  border: 1px solid var(--tw-line);
  border-radius: 8px;
  padding: 7px 9px;
  display: flex; flex-direction: column; justify-content: space-between;
  min-width: 0;
}
.tw-pct-card .tw-card-title { font-size: 10px; font-weight: 600; color: var(--tw-muted); margin-bottom: 4px; }
.tw-pct-body { display: flex; align-items: center; justify-content: space-between; }
.tw-pct-body b { font-size: 20px; color: var(--tw-navy-2); }
.tw-pct-icon {
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--tw-pale); color: var(--tw-blue);
}
.tw-pct-icon svg { width: 14px; height: 14px; }

/* ── product tabs + batches ─────────────────────────────────────── */
.tw-tabs {
  display: flex; gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
  margin-bottom: 6px;
}
.tw-tab {
  flex: none;
  font: inherit; font-size: 11.5px; font-weight: 600;
  color: var(--tw-muted);
  background: transparent;
  border: 0; border-bottom: 2px solid transparent;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
}
.tw-tab:hover { color: var(--tw-ink); background: var(--tw-pale); }
.tw-tab[aria-selected="true"] { color: var(--tw-blue); border-bottom-color: var(--tw-blue); background: var(--tw-card); }
.tw-tab:focus-visible, .tw-row:focus-visible { outline: 2px solid var(--tw-orange); outline-offset: 1px; }

.tw-table-card { padding: 0; overflow-x: auto; }
.tw-thead {
  font-size: 10.5px; font-weight: 700; color: var(--tw-ink);
  background: var(--fw-t90);
  border-bottom: 1px solid var(--tw-line);
}
.tw-thead > span, .tw-sort { display: flex; align-items: center; gap: 5px; padding: 8px 10px; white-space: nowrap; }
.tw-thead svg { width: 12px; height: 12px; color: var(--tw-muted); flex: none; }
.tw-sort {
  font: inherit; color: inherit; text-align: left;
  background: none; border: 0; cursor: pointer;
}
.tw-sort:hover { background: var(--tw-pale); }
.tw-sort:focus-visible { outline: 2px solid var(--tw-orange); outline-offset: -2px; }
.tw-sort i { font-style: normal; color: var(--tw-blue); margin-left: auto; }
.tw-sort[data-dir="asc"] i::after { content: '▲'; font-size: 8px; }
.tw-sort[data-dir="desc"] i::after { content: '▼'; font-size: 8px; }
.tw-sort.is-on { color: var(--tw-blue); }
.tw-batch-grid { display: grid; grid-template-columns: .9fr .95fr 1fr 1fr 1.15fr; min-width: 560px; }
.tw-phase-grid { display: grid; grid-template-columns: 1.25fr 1fr 1fr; min-width: 400px; }
.tw-rows { min-height: 120px; }
.tw-empty { margin: 0; padding: 20px 12px; color: var(--tw-muted); text-align: center; }

.tw-row {
  position: relative;
  width: 100%;
  font: inherit; font-size: 11px; text-align: left;
  border: 0; margin: 0;
  color: var(--tw-ink);
  background: var(--tw-card);
  border-bottom: 1px solid var(--tw-line);
}
/* a running batch: white, with its progress along the bottom */
.tw-prog {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: var(--tw-blue);
  transform: scaleX(var(--p, 0)); transform-origin: 0 50%;
  transition: transform .8s ease-out;
}
.tw-row:not(.is-running):not(.is-run) .tw-prog { display: none; }
.tw-row.is-running { background: var(--fw-t90); }
.tw-row.is-running.is-overdue { background: #fdeced; color: #a3242a; }
.tw-row.is-running.is-overdue .tw-prog { background: var(--tw-red); }
.tw-row > span { padding: 8px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.tw-row { cursor: pointer; transition: filter .15s, opacity .15s; }
button.tw-row:hover { filter: brightness(1.06); }
.tw-row.is-review    { background: var(--tw-green); color: #fff; }
.tw-row.is-late      { background: var(--tw-red); color: #fff; }
.tw-row.is-completed { background: var(--tw-blue); color: #fff; }
.tw-row.is-review, .tw-row.is-late, .tw-row.is-completed { border-bottom-color: rgba(255, 255, 255, .35); }
.tw-rows .tw-row:not(.is-picked) { opacity: .82; }
.tw-row.is-picked { box-shadow: inset 4px 0 0 var(--tw-orange); }
.tw-strong { font-weight: 700; }

/* ── filters + phases ───────────────────────────────────────────── */
.tw-phases { padding: 0; overflow-x: auto; }
.tw-filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px;
  padding: 10px;
}
.tw-filters label { flex: 1 1 110px; min-width: 0; }
.tw-input {
  display: block; width: 100%;
  min-height: 30px; margin-top: 3px; padding: 4px 8px;
  border: 1px solid var(--tw-line); border-radius: 5px;
  background: #fff; color: var(--tw-ink);
  font: inherit; font-size: 11px;
  color-scheme: light;
}
.tw-input:focus-visible { outline: 2px solid var(--tw-orange); outline-offset: 1px; }
.tw-history {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 6px; border: 0;
  background: var(--tw-blue); color: #fff; cursor: pointer;
}
.tw-history:hover { background: var(--tw-navy-2); }
.tw-history:focus-visible { outline: 2px solid var(--tw-orange); outline-offset: 2px; }
.tw-history svg { width: 16px; height: 16px; }
.tw-phase-rows .tw-row:nth-child(odd) { background: var(--fw-t90); }
.tw-phase-rows .tw-row.is-wait { color: var(--tw-muted); }
.tw-phase-rows .tw-row.is-run { background: var(--fw-t90); font-weight: 600; }
.tw-dot-state {
  display: inline-block; vertical-align: middle;
  width: 8px; height: 8px; margin-right: 7px; border-radius: 50%;
  border: 1.5px solid var(--tw-muted);
}
.is-done .tw-dot-state { background: var(--tw-green); border-color: var(--tw-green); }
.is-run .tw-dot-state { background: var(--tw-blue); border-color: var(--tw-blue); animation: tw-pulse 1.4s ease-in-out infinite; }
@keyframes tw-pulse { 50% { opacity: .3; } }

/* a product with a batch running gets a small blue dot */
.tw-tab-run { display: none; width: 5px; height: 5px; margin-left: 5px; border-radius: 50%; background: var(--tw-blue); vertical-align: 2px; }
.tw-tab.has-run .tw-tab-run { display: inline-block; }

/* ── the selected batch's record ────────────────────────────────── */
.tw-record {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px 16px;
  padding: 14px 16px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--tw-navy) 0%, var(--tw-navy-2) 100%);
  color: #fff;
}
.tw-rec-field { min-width: 0; }
.tw-rec-field .tw-label { color: var(--fw-t50); }
.tw-rec-field b { display: block; font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }

/* ── charts ─────────────────────────────────────────────────────── */
.tw-charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tw-chart { display: flex; flex-direction: column; }
.tw-svg { width: 100%; height: auto; display: block; overflow: visible; }
.tw .tw-svg { stroke: none; }
.tw-grid { stroke: var(--tw-line); stroke-width: 1; }
.tw-tick, .tw-legend text { fill: var(--tw-muted); font-size: 10px; font-family: inherit; }
.tw-s0 { fill: var(--tw-blue); }
.tw-s1 { fill: var(--tw-mid); }
.tw path.tw-line { fill: none; }
.tw-line { stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tw-line.tw-q0 { stroke: var(--tw-blue); }
.tw-line.tw-q1 { stroke: var(--tw-navy); }
.tw-q0, .tw-q0h { fill: var(--tw-blue); }
.tw-q1 { fill: var(--tw-navy); }
.tw-q2 { fill: var(--tw-orange); }
.tw-legend circle.tw-q0 { fill: var(--tw-blue); }
.tw-pareto { stroke: var(--tw-orange); }
.tw-pareto-dot { fill: var(--tw-orange); }

/* first view: bars rise, lines draw, dots land */
/* first view: bars rise, lines draw, dots land. After that the feed moves
   them: bars rescale, Pareto bars slide to their new rank, dots glide. */
.tw-col { transform-box: fill-box; transform-origin: 50% 100%; transform: scaleY(var(--s, 0)); }
.tw-line { stroke-dasharray: 1; stroke-dashoffset: 0; }
.tw:not(.is-in) .tw-col  { transform: scaleY(0); }
.tw:not(.is-in) .tw-line { stroke-dashoffset: 1; }
.tw:not(.is-in) .tw-dot  { opacity: 0; }
.tw.is-in .tw-col  { transition: transform .7s cubic-bezier(.2, .8, .2, 1) calc(var(--k, 0) * 40ms); }
.tw.is-in .tw-line { transition: stroke-dashoffset 1.2s cubic-bezier(.4, 0, .2, 1) .35s; }
.tw.is-in .tw-dot  { transition: transform .7s cubic-bezier(.2, .8, .2, 1), opacity .3s ease-out calc(var(--k, 0) * 70ms + 700ms); }
.tw-gm { transition: transform .7s cubic-bezier(.2, .8, .2, 1); }

/* ── footer bar ─────────────────────────────────────────────────── */
.tw-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px;
  padding: 9px 14px;
  background: var(--tw-navy);
  color: var(--fw-t80);
  font-size: 11.5px;
}
.tw-bar svg { width: 16px; height: 16px; vertical-align: middle; }
.tw-bar-icon { display: inline-grid; place-items: center; }
.tw-bar-app { color: #fff; font-size: 13px; }
.tw-bar-app span { color: var(--tw-mid); margin-right: 4px; }
.tw-bar-user { display: inline-flex; align-items: center; gap: 6px; }
.tw-bar-meta b { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }
.tw-live {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  color: #fff; background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px;
  padding: 3px 10px; cursor: pointer;
}
.tw-live:hover { background: rgba(255, 255, 255, .18); }
.tw-live:focus-visible { outline: 2px solid var(--tw-orange); outline-offset: 2px; }
.tw-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--fw-t30); }
.tw.is-live .tw-live i { background: #3ddc84; animation: tw-pulse 1.6s ease-in-out infinite; }
.tw-ticker {
  flex: 1 1 200px; min-width: 0;
  color: #fff; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tw-ticker::before { content: '● '; color: var(--tw-orange); }
.tw-bar-user i {
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--tw-blue); color: #fff;
  font-style: normal; font-size: 9.5px; font-weight: 700;
}

/* ── smaller screens ────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .tw-details, .tw-events { grid-column: span 6; }
  .tw-pct { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tw-batches-wrap, .tw-phases { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .tw-charts { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .tower { margin-top: 32px; }
  .tw-board { padding: 8px; gap: 8px; }
  .tw-details, .tw-events { grid-column: 1 / -1; }
  .tw-pct { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tw-record { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }
  .tw-bar-meta { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tw-col, .tw-line, .tw-dot, .tw-gm, .tw-prog, button.tw-row { transition: none !important; }
  .is-run .tw-dot-state, .tw.is-live .tw-live i { animation: none; }
}
