/**
 * Workshop Strategist — stylesheet.
 * Red-unified per D1: platform tokens only, no per-phase colors (PRD's amber/green/purple
 * overridden by design decision 2026-07-06). Status colors are functional encoding,
 * always paired with text labels.
 */

@import url('/design-system/platform-tokens.css');

/* ========================================================================
   SHELL — header, phase tabs, asymmetric main+sidebar grid
   ======================================================================== */

.st-app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-body);
}

/* Form elements carry a darker resting border than the platform default so
   fields read as distinct, fillable targets against the cream surface. */
.st-app .ws-input,
.st-app .ws-select,
.st-app .st-list__row .ws-input,
.st-app .st-chat__input {
  border-color: var(--gray-400);
}
.st-app .ws-input:hover:not(:disabled):not(:focus),
.st-app .ws-select:hover:not(:disabled) {
  border-color: var(--gray-500);
}

.st-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6) var(--space-2);
}
.st-header__title {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.st-header__sub { font-size: var(--text-sm); color: var(--text-tertiary); }
.st-header__save {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
.st-header__save[data-state="saved"]  { color: var(--color-success); }
.st-header__save[data-state="error"]  { color: var(--color-error); }

/* Phase tabs: number + icon + label — never phase-colored */
.st-tabs {
  display: flex;
  gap: var(--space-2);
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--gray-200);
}
.st-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.st-tab:hover { color: var(--text-primary); }
.st-tab:focus-visible { outline: 2px solid var(--mainsite-primary); outline-offset: -2px; }
.st-tab[aria-selected="true"] {
  color: var(--mainsite-dark);
  border-bottom-color: var(--mainsite-primary);
}
.st-tab__num {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  color: var(--text-secondary);
}
.st-tab[aria-selected="true"] .st-tab__num {
  background: var(--mainsite-light);
  color: var(--mainsite-dark);
}
.st-tab__done {
  font-size: var(--text-2xs, 0.6875rem);
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* Main grid: content + persistent sidebar (asymmetric, sidebar fixed) */
.st-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: var(--space-6);
  align-items: start;
  padding: var(--space-5) var(--space-6) var(--space-10);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.st-phase[hidden] { display: none; }

/* ========================================================================
   FORM SECTIONS — logic-grouped by rules + dividers, not card-boxed
   ======================================================================== */

.st-section { padding: var(--space-5) 0; border-top: 1px solid var(--gray-200); }
.st-section:first-child { border-top: none; padding-top: 0; }
.st-section__title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.st-section__hint {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  max-width: 65ch;
  margin-bottom: var(--space-4);
}

.st-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.st-field-block { display: flex; flex-direction: column; gap: var(--space-4); }

[data-s-show-when] { display: none; }
[data-s-show-when].st-visible { display: block; }

/* ========================================================================
   BUY-IN WIZARD — stepper nav + per-step transition + footer
   ======================================================================== */

.st-wizard { padding: var(--space-4) 0 var(--space-5); }
.st-wizard__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}
.st-wizard__step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  cursor: pointer;
  min-height: 44px;
}
.st-wizard__step:hover { color: var(--text-primary); background: var(--gray-50); }
.st-wizard__step:focus-visible { outline: 2px solid var(--mainsite-primary); outline-offset: 2px; }
.st-wizard__num {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  color: var(--gray-500);
}
.st-wizard__label { color: inherit; }

/* Touched: been here, left something — quieter than active */
.st-wizard__step--touched .st-wizard__num {
  background: var(--gray-200);
  color: var(--text-secondary);
}

/* Active: red family, per D1 unification */
.st-wizard__step[aria-current="step"] { color: var(--mainsite-dark); }
.st-wizard__step[aria-current="step"] .st-wizard__num {
  background: var(--mainsite-light);
  color: var(--mainsite-dark);
}
.st-wizard__step--touched[aria-current="step"] .st-wizard__num { background: var(--mainsite-light); }

.st-step[hidden] { display: none; }
.st-step--entering { animation: st-step-in .2s ease-out; }
@keyframes st-step-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.st-wizard__footer {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--gray-200);
}

/* ========================================================================
   REPEATING LISTS — roster, outputs, pressure-tested-with
   ======================================================================== */

.st-list { display: flex; flex-direction: column; gap: var(--space-2); }
.st-list__row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.8fr 1.4fr auto;
  gap: var(--space-2);
  align-items: end;
}
.st-list__row--outputs { grid-template-columns: 1.4fr 0.9fr 0.9fr 0.9fr auto; }
.st-list__row--pressure { grid-template-columns: 1fr 1.6fr auto; }
.st-list__remove {
  min-width: 44px; min-height: 44px;
  display: grid; place-items: center;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-tertiary);
  cursor: pointer;
}
.st-list__remove:hover { color: var(--color-error); border-color: var(--color-error); }
.st-list__remove:focus-visible { outline: 2px solid var(--mainsite-primary); outline-offset: 2px; }
.st-list__empty { font-size: var(--text-sm); color: var(--text-tertiary); padding: var(--space-3) 0; }

/* Roster count + warning */
.st-roster-count { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--space-2); }

/* ========================================================================
   OBJECTION COACH
   ======================================================================== */

.st-pitch-card {
  padding: var(--space-4) var(--space-5);
  background: var(--mainsite-light);
  border: 1px solid var(--mainsite-primary);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}
.st-pitch-card__label {
  font-size: var(--text-2xs, 0.6875rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mainsite-dark);
  margin-bottom: var(--space-2);
}
.st-pitch-card__text { font-size: var(--text-sm); color: var(--text-primary); max-width: 68ch; }

.st-objections { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.st-objection {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font: inherit;
  background: var(--bg-surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  cursor: pointer;
  min-height: 44px;
}
.st-objection:hover { border-color: var(--gray-300); box-shadow: var(--shadow-sm); }
.st-objection:active { transform: translateY(1px); }
.st-objection:focus-visible { outline: 2px solid var(--mainsite-primary); outline-offset: 2px; }
.st-objection[aria-pressed="true"] { border-color: var(--mainsite-primary); background: var(--mainsite-light); }
.st-objection__quote { font-weight: 600; font-size: var(--text-sm); display: block; }
.st-objection__who { font-size: var(--text-xs); color: var(--text-tertiary); }

.st-scripts { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-4); }
.st-script {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}
.st-script__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--gray-100);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.st-script__body { padding: var(--space-3) var(--space-4); font-size: var(--text-sm); max-width: 70ch; }

/* Practice chat */
.st-chat {
  display: flex; flex-direction: column;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  margin-top: var(--space-4);
}
.st-chat__log {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4);
  max-height: 340px;
  overflow-y: auto;
}
.st-chat__msg {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  max-width: 85%;
}
.st-chat__msg--user { align-self: flex-end; background: var(--mainsite-light); }
.st-chat__msg--ai { align-self: flex-start; background: var(--gray-100); }
.st-chat__msg--error { align-self: stretch; background: var(--color-error-very-light); color: var(--text-primary); }
.st-chat__form { display: flex; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--gray-100); }
.st-chat__input {
  flex: 1;
  font: inherit; font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
}
.st-chat__input:focus-visible { outline: 2px solid var(--mainsite-primary); outline-offset: 1px; }
.st-chat__typing { font-size: var(--text-xs); color: var(--text-tertiary); padding: 0 var(--space-4) var(--space-2); }

/* ========================================================================
   EMAIL BUILDER — form + live preview
   ======================================================================== */

.st-email { display: grid; grid-template-columns: 1fr 1.1fr; gap: var(--space-5); align-items: start; }
.st-email__preview {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: var(--space-5);
  font-size: var(--text-sm);
  position: sticky;
  top: var(--space-4);
}
.st-email__subject { font-weight: 600; margin-bottom: var(--space-3); }
.st-email__preview h4 {
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-tertiary);
  margin: var(--space-3) 0 var(--space-1);
}
.st-email__preview .st-slot { color: var(--mainsite-dark); font-weight: 500; }
.st-email__preview .st-slot--empty { color: var(--text-tertiary); font-style: italic; font-weight: 400; }
.st-email__actions { display: flex; gap: var(--space-2); margin-top: var(--space-4); }

/* ========================================================================
   APPROVAL TRACKER
   ======================================================================== */

.st-approvals { display: flex; flex-direction: column; }
.st-approval {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1.4fr;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--gray-100);
}
.st-approval__label { font-size: var(--text-sm); font-weight: 500; }

/* Status colors: functional encoding, text always present */
.st-status { font-size: var(--text-xs); font-weight: 600; padding: 2px 10px; border-radius: var(--radius-full); }
.st-status--not_started { background: var(--gray-100); color: var(--text-secondary); }
.st-status--sent        { background: var(--color-warning-very-light); color: var(--color-warning); }
.st-status--approved    { background: var(--color-success-very-light); color: var(--color-success); }
.st-status--blocked     { background: var(--color-error-very-light); color: var(--color-error); }
.st-status--confirmed   { background: var(--color-success-very-light); color: var(--color-success); }

/* ========================================================================
   SIDEBAR — readiness + live brief
   ======================================================================== */

.st-sidebar {
  position: sticky;
  top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Go / caution / not-yet recommendation banner — text-labeled, never color-alone */
.st-reco {
  padding: var(--space-4);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  font-size: var(--text-sm);
}
.st-reco:empty { display: none; }
.st-reco[data-level="go"] { border-color: var(--color-success); }
.st-reco[data-level="caution"] { border-color: var(--color-warning); }
.st-reco[data-level="not-yet"] { border-color: var(--gray-200); }
.st-reco__label { font-weight: 600; }
.st-reco__flags { margin: var(--space-2) 0 0; padding-left: var(--space-4); color: var(--text-secondary); }

.st-readiness {
  padding: var(--space-4);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}
.st-readiness__headline {
  display: flex; align-items: baseline; gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.st-readiness__pct {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.st-readiness__label { font-size: var(--text-sm); color: var(--text-secondary); }
.st-readiness__bar {
  height: 6px; border-radius: var(--radius-full);
  background: var(--gray-100); overflow: hidden;
  margin-bottom: var(--space-3);
}
.st-readiness__fill {
  height: 100%; width: 100%;
  transform-origin: left center;
  transform: scaleX(var(--st-fill, 0));
  border-radius: var(--radius-full);
  background: var(--gray-400);
  transition: transform .3s cubic-bezier(0.16,1,0.3,1), background-color .3s;
}
.st-readiness[data-band="low"]    .st-readiness__fill { background: var(--color-warning); }
.st-readiness[data-band="medium"] .st-readiness__fill { background: var(--color-warning); }
.st-readiness[data-band="ready"]  .st-readiness__fill { background: var(--color-success); }
.st-readiness__phases { display: flex; flex-direction: column; gap: var(--space-1); }
.st-readiness__phase {
  display: flex; justify-content: space-between;
  font-size: var(--text-xs); color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.st-brief {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  overflow: hidden;
}
.st-brief__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--gray-100);
  font-size: var(--text-xs); font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-tertiary);
}
.st-brief__body {
  padding: var(--space-4);
  font-size: var(--text-xs);
  line-height: 1.6;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-variant-numeric: tabular-nums;
}
.st-brief__body .st-slot--empty { color: var(--text-tertiary); font-style: italic; }

.st-sidebar__actions { display: flex; flex-direction: column; gap: var(--space-2); }
.st-sidebar__hint { font-size: var(--text-xs); color: var(--text-tertiary); }

.st-sidebar__section {
  padding: var(--space-4);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}
.st-sidebar__heading {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0 0 var(--space-1);
}
.st-docs { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
#stDocOut { margin-top: var(--space-3); }

/* Open in Planner CTA: affirmative state at >=80%, advisory only */
#stOpenPlanner[data-ready="true"] { }

/* ========================================================================
   STATES
   ======================================================================== */

.st-skeleton {
  height: 48px;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: st-shimmer 1.4s ease infinite;
}
@keyframes st-shimmer { to { background-position: -200% 0; } }

.st-toast-host {
  position: fixed; bottom: var(--space-4); left: 50%; transform: translateX(-50%);
  z-index: var(--z-tooltip, 700);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.st-toast {
  padding: var(--space-2) var(--space-4);
  background: var(--gray-900); color: #fff;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
}
.st-toast--error { background: var(--color-error); }

.st-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ========================================================================
   RESPONSIVE < 860px — sidebar stacks below, tabs scroll
   ======================================================================== */

@media (max-width: 859px) {
  .st-body { grid-template-columns: 1fr; padding: var(--space-4); }
  .st-sidebar { position: static; order: 2; }
  .st-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .st-grid-2, .st-email, .st-objections { grid-template-columns: 1fr; }
  .st-list__row, .st-list__row--outputs, .st-list__row--pressure { grid-template-columns: 1fr; }
  .st-approval { grid-template-columns: 1fr; gap: var(--space-1); }
  .st-email__preview { position: static; }
  .st-wizard__label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .st-skeleton { animation: none; }
  .st-readiness__fill, .st-objection { transition: none; }
  .st-step--entering { animation: none; }
}

/* Standalone shared-brief page */
.st-app--brief-view { max-width: 720px; margin: 0 auto; padding: var(--space-6) var(--space-4); }
.st-brief--standalone .st-brief__body { max-height: none; }

/* ========================================================================
   PRINT — the Brief alone, as a clean sheet
   ======================================================================== */

@media print {
  .st-header, .st-tabs, .st-phase, .st-sidebar__actions, .st-sidebar__section, .st-readiness,
  .st-brief__head, .st-toast-host { display: none !important; }
  .st-app, .st-body { display: block; padding: 0; margin: 0; background: var(--bg-surface); }
  .st-sidebar { position: static; }
  .st-brief { border: none; }
  .st-brief__body { max-height: none; overflow: visible; font-size: 11pt; }
  /* Buy-In wizard: if .st-phase print-hiding ever changes, steps must not stay hidden */
  [data-st-buyin-step][hidden] { display: block !important; }
  .st-wizard, .st-wizard__footer { display: none !important; }
}
