/* ============================================================================
   Vscore Planning PG · Soll/Ist — the product-ad section (tool.html #planning-pg)
   ============================================================================

   The four views are RENDERED, not screenshotted, with example figures — the
   same choice #statements already makes ("Illustrative Darstellung"). Real
   captures of the live product carry the customer name and their whole P&L,
   which cannot go on a public page.

   Rendering also animates better: numbers count up, variances land in colour,
   rows stagger in. A pan across a flat PNG cannot do any of that, and goes
   soft the moment it zooms.

   Everything below uses the tokens from styles.css — no new colours.
   ========================================================================== */

.pgad {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 0;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 24px 60px -32px oklch(0.265 0.030 205 / 0.45);
}

/* Below 1040px the chat cannot sit beside a financial table and stay legible,
   so it drops underneath rather than squeezing the numbers. */
@media (max-width: 1040px) {
  .pgad { grid-template-columns: 1fr; }
}

/* ── The stage and its views ──────────────────────────────────────────────── */

.pgad__stage {
  position: relative;
  overflow: hidden;
  background: var(--bg);
  min-height: 452px;
}

/* One view. Absolutely stacked so a cross-fade has something to fade between. */
.pgad__shot {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.85s var(--ease-out), visibility 0s linear 0.85s;
}

.pgad__shot.is-on {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.85s var(--ease-out), visibility 0s;
}

/* Product chrome — enough of it to be recognisable, not a pixel copy. */
.pgv__chrome {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-2);
  font-size: 0.74rem;
  color: var(--muted);
}

.pgv__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--brand);
}

.pgv__pg {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.pgv__field {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.pgv__field b {
  font-weight: 500;
  color: var(--ink);
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.pgv__tabs {
  display: flex;
  gap: 0.3rem;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--line-soft);
}

.pgv__tab {
  font-size: 0.72rem;
  padding: 0.28rem 0.62rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--bg);
}

.pgv__tab.is-on {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  font-weight: 500;
}

.pgv__tabs .pgv__sep { width: 0.5rem; }

/* The table. */
.pgv__wrap { flex: 1; overflow: hidden; }

.pgv table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.pgv th,
.pgv td {
  padding: 0.34rem 0.5rem;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}

.pgv thead th {
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
  font-size: 0.66rem;
  border-bottom: 0;
  position: sticky;
  top: 0;
}

.pgv thead th.grp {
  text-align: center;
  border-left: 1px solid var(--on-brand-line);
  font-size: 0.7rem;
}

.pgv thead tr + tr th { background: var(--brand-600); font-weight: 500; }

.pgv .lbl {
  text-align: left;
  font-weight: 500;
  color: var(--ink);
  width: 34%;
  padding-left: 1.4rem;
  position: relative;
}

.pgv .lbl::before {
  content: "▸";
  position: absolute;
  left: 0.55rem;
  color: var(--brand);
  opacity: 0.55;
  font-size: 0.65rem;
}

.pgv tr.sum .lbl::before { content: none; }

/* Subtotals — the cream band the real grid uses. */
.pgv tr.sum td {
  background: oklch(0.968 0.030 96);
  font-weight: 600;
}

.pgv tr.tot td {
  background: oklch(0.955 0.038 96);
  font-weight: 700;
  border-bottom: 0;
}

.pgv td.total { background: oklch(0.955 0.010 190); font-weight: 600; }
.pgv tr.sum td.total,
.pgv tr.tot td.total { background: oklch(0.936 0.026 150); }

.pgv .up   { color: var(--accent-ink); }
.pgv .down { color: oklch(0.545 0.150 25); }

/* Rows stagger in when their view becomes active — the product-ad beat. */
.pgad__shot tbody tr {
  opacity: 0;
  transform: translateY(6px);
}

.pgad__shot.is-on tbody tr {
  animation: pgv-row 0.5s var(--ease-out) forwards;
}

@keyframes pgv-row {
  to { opacity: 1; transform: none; }
}

/* The slogan is a BAR under the table, not a scrim over it: a financial table
   has no dead space to overlay, and covering the last rows to make room for
   the claim would be exactly the wrong trade. */
.pgad__slogan {
  margin: 0;
  padding: 0.8rem clamp(0.9rem, 2vw, 1.2rem);
  background: var(--brand);
  color: var(--on-brand);
  font-family: var(--font-display);
  font-size: clamp(0.92rem, 1.35vw, 1.15rem);
  line-height: 1.3;
  letter-spacing: -0.01em;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.pgad__shot.is-on .pgad__slogan {
  opacity: 1;
  transform: none;
  transition-delay: 0.5s;
}

/* Progress pips — also the manual control, so the sequence is not a thing that
   only happens TO the visitor. */
.pgad__pips {
  position: absolute;
  top: 0.62rem;
  right: 0.8rem;
  display: flex;
  gap: 0.4rem;
  z-index: 3;
}

.pgad__pip {
  width: 24px; height: 4px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--line);
  cursor: pointer;
  transition: background 0.3s var(--ease-out);
}

.pgad__pip[aria-current="true"] { background: var(--accent); }
.pgad__pip:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ── The chat panel ───────────────────────────────────────────────────────── */

.pgad__chat {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--bg-2);
  overflow: hidden;
}

@media (max-width: 1040px) {
  .pgad__chat { border-left: 0; border-top: 1px solid var(--line); min-height: 320px; }
}

.pgad__chatbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-2);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.pgad__chatbar i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.715 0.140 112 / 0.18);
}

.pgad__log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: clamp(0.9rem, 2vw, 1.25rem);
  justify-content: flex-end;
}

.pgad__msg {
  max-width: 92%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.pgad__msg--user {
  align-self: flex-end;
  background: var(--brand);
  color: var(--on-brand);
  border-bottom-right-radius: 4px;
}

.pgad__msg--bot {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

/* The caret only exists while something is being typed. */
.pgad__msg.is-typing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: currentColor;
  animation: pgad-caret 1s steps(2, start) infinite;
}

@keyframes pgad-caret { to { opacity: 0; } }

/* Three dots while the answer is being "thought about" — the one moment the
   real product also makes you wait, so pretending otherwise would ring false. */
.pgad__thinking {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 0.8rem 0.9rem;
}

.pgad__thinking span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: pgad-dot 1.2s var(--ease-out) infinite;
}

.pgad__thinking span:nth-child(2) { animation-delay: 0.15s; }
.pgad__thinking span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pgad-dot {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-3px); }
}

.pgad__note {
  margin: clamp(1rem, 2vw, 1.4rem) 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Reduced motion ───────────────────────────────────────────────────────────
   Not "slightly calmer" — OFF. The first shot, its slogan, and the full chat
   transcript are all shown at once, so nothing is lost by not animating. */
@media (prefers-reduced-motion: reduce) {
  .pgad__shot,
  .pgad__slogan {
    transition: none;
  }
  .pgad__shot tbody tr { opacity: 1; transform: none; animation: none; }
  .pgad__shot.is-on .pgad__slogan { transition-delay: 0s; }
  .pgad__msg.is-typing::after,
  .pgad__thinking span { animation: none; }
  .pgad__thinking { display: none; }
}
