/* ===========================================================================
   app.css — shared component library for OpportunitySense AI
   Owned by the SCAFFOLD session — shared, read-only across all screens.
   Brand tokens come from brand.css; this file builds on-brand components.
   Loaded after brand.css and before each page's own stylesheet.
   =========================================================================== */

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */

.os-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.os-container {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding-left: var(--page-pad);
  padding-right: var(--page-pad);
}

#view {
  flex: 1 0 auto;
  width: 100%;
}

.os-section {
  padding-top: var(--space-7);
  padding-bottom: var(--space-7);
}

.os-stack > * + * { margin-top: var(--space-3); }
.os-stack-lg > * + * { margin-top: var(--space-5); }

.os-grid {
  display: grid;
  gap: var(--space-4);
}
.os-grid-2 { grid-template-columns: repeat(2, 1fr); }
.os-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* --------------------------------------------------------------------------
   App header — sits directly on the background, no heavy container box
   -------------------------------------------------------------------------- */

#app-header {
  flex: 0 0 auto;
  width: 100%;
  border-bottom: 1px solid var(--athera-line);
  background: var(--athera-off-white);
}

.os-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-3) var(--page-pad);
  flex-wrap: wrap;
}

.os-header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.os-header-logo {
  height: 30px;
  width: auto;
}

.os-header-divider {
  width: 1px;
  height: 28px;
  background: var(--athera-line);
}

.os-product-name {
  font-family: var(--athera-display);
  font-size: 24px;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--athera-charcoal);
  line-height: 1;
  white-space: nowrap;
}
.os-product-name .mark { color: var(--athera-blue); }

/* --------------------------------------------------------------------------
   Step navigation: Setup -> Signals -> Results -> Brief
   -------------------------------------------------------------------------- */

.os-stepnav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.os-step {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--athera-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--athera-grey-light);
  text-decoration: none;
  padding: 6px 4px;
  transition: color var(--ease);
}
.os-step:hover { color: var(--athera-charcoal); }

.os-step .os-step-num {
  font-family: var(--athera-mono);
  font-size: 10px;
  letter-spacing: 0;
  color: var(--athera-grey-light);
}

.os-step.is-active {
  color: var(--athera-blue-deep);
}
.os-step.is-active .os-step-num { color: var(--athera-blue); }

.os-step-sep {
  color: var(--athera-line);
  font-size: 11px;
  user-select: none;
}

/* --------------------------------------------------------------------------
   App footer — small A!thera emblem + the quiet disclaimer line
   -------------------------------------------------------------------------- */

#app-footer {
  flex: 0 0 auto;
  width: 100%;
  border-top: 1px solid var(--athera-line);
  margin-top: var(--space-7);
}

.os-footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-4) var(--page-pad);
}

.os-footer-emblem {
  height: 22px;
  width: auto;
  opacity: 0.9;
  flex: 0 0 auto;
}

.os-footer-text {
  font-family: var(--athera-sans);
  font-size: 12px;
  font-weight: 300;
  line-height: 1.6;
  color: var(--athera-grey);
}

/* --------------------------------------------------------------------------
   Section headers — eyebrow label + display title + optional blue rule
   -------------------------------------------------------------------------- */

.os-section-head {
  margin-bottom: var(--space-5);
}
.os-eyebrow {
  font-family: var(--athera-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--athera-blue-deep);
  display: block;
  margin-bottom: var(--space-2);
}
.os-section-head h2 { margin-bottom: var(--space-2); }
.os-section-intro {
  font-family: var(--athera-sans);
  font-size: 18px;
  font-weight: 300;
  line-height: 1.7;
  color: var(--athera-charcoal-light);
  max-width: 560px;
}
.os-section-head .athera-blue-rule { margin-top: var(--space-3); }

.os-section-number {
  font-family: var(--athera-mono);
  font-size: 11px;
  color: var(--athera-grey-light);
  display: block;
  margin-bottom: var(--space-1);
}

/* --------------------------------------------------------------------------
   Buttons — primary, secondary, ghost
   -------------------------------------------------------------------------- */

.os-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--athera-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--ease), color var(--ease), border-color var(--ease);
  text-decoration: none;
  line-height: 1;
}
.os-btn:disabled,
.os-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.os-btn-primary {
  background: var(--athera-blue);
  color: var(--athera-navy);
}
.os-btn-primary:hover { background: var(--athera-blue-deep); color: #fff; }

.os-btn-secondary {
  background: transparent;
  color: var(--athera-charcoal);
  border-color: var(--athera-line);
}
.os-btn-secondary:hover { background: var(--athera-white); border-color: var(--athera-grey-light); }

.os-btn-ghost {
  background: transparent;
  color: var(--athera-grey);
  padding: 10px 12px;
}
.os-btn-ghost:hover { color: var(--athera-charcoal); }

.os-btn-sm { padding: 8px 16px; font-size: 11px; }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.os-card {
  background: var(--athera-white);
  border: 1px solid var(--athera-line);
  border-radius: var(--radius);
  padding: var(--space-4);
}
.os-card-dark {
  background: var(--athera-navy);
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--athera-line-dark);
  border-radius: var(--radius);
  padding: var(--space-4);
}
.os-card-quiet {
  background: var(--athera-surface);
  border: 1px solid var(--athera-line-light);
  border-radius: var(--radius);
  padding: var(--space-4);
}

/* --------------------------------------------------------------------------
   Opportunity card shell
   title row · score chip · evidence list · action block · meta row
   -------------------------------------------------------------------------- */

.os-opp {
  background: var(--athera-white);
  border: 1px solid var(--athera-line);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.os-opp.is-dismissed { opacity: 0.6; }
.os-opp.is-pursue { border-color: var(--athera-blue); }

.os-opp-titlerow {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.os-opp-eyebrow {
  font-family: var(--athera-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--athera-grey);
  margin-bottom: 6px;
  display: block;
}
.os-opp-title {
  font-family: var(--athera-display);
  font-size: 26px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--athera-charcoal);
  margin: 0;
}
.os-opp-property {
  font-family: var(--athera-sans);
  font-size: 13px;
  color: var(--athera-grey);
  margin-top: 4px;
}

/* Score chip */
.os-score {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 10px 14px;
  border: 1px solid var(--athera-line);
  border-radius: var(--radius);
  background: var(--athera-off-white);
}
.os-score-value {
  font-family: var(--athera-display);
  font-size: 32px;
  font-weight: 300;
  line-height: 1;
  color: var(--athera-charcoal);
}
.os-score-label {
  font-family: var(--athera-sans);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--athera-grey-light);
  margin-top: 6px;
}
.os-score.is-high .os-score-value { color: var(--athera-blue-deep); }

.os-opp-summary {
  font-family: var(--athera-sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.65;
  color: var(--athera-charcoal-light);
  margin: 0;
}

/* Evidence list */
.os-evidence {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--athera-line-light);
}
.os-evidence li {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--athera-line-light);
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--space-2);
}
.os-evidence-label {
  font-family: var(--athera-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--athera-grey);
  padding-top: 2px;
}
.os-evidence-detail {
  font-family: var(--athera-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--athera-charcoal);
}
.os-evidence-source {
  font-family: var(--athera-mono);
  font-size: 10px;
  color: var(--athera-grey-light);
  display: block;
  margin-top: 4px;
}

/* Action block */
.os-action {
  background: var(--athera-off-white);
  border-left: 2px solid var(--athera-blue);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}
.os-action-label {
  font-family: var(--athera-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--athera-blue-deep);
  display: block;
  margin-bottom: 6px;
}
.os-action-text {
  font-family: var(--athera-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--athera-charcoal);
  margin: 0;
}

/* Meta row (impact / difficulty / confidence / horizon) */
.os-opp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  border-top: 1px solid var(--athera-line-light);
  padding-top: var(--space-3);
}
.os-meta-item { display: flex; flex-direction: column; gap: 4px; }
.os-meta-key {
  font-family: var(--athera-sans);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--athera-grey-light);
}
.os-meta-val {
  font-family: var(--athera-sans);
  font-size: 13px;
  color: var(--athera-charcoal);
}

/* --------------------------------------------------------------------------
   Badges — priority / confidence / difficulty / status
   Brand blue for emphasis; grey/charcoal otherwise. Amber reserved for charts.
   -------------------------------------------------------------------------- */

.os-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--athera-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--athera-line);
  color: var(--athera-grey);
  background: var(--athera-white);
  white-space: nowrap;
}
.os-badge-blue {
  color: var(--athera-blue-deep);
  border-color: var(--athera-blue);
  background: rgba(95, 184, 214, 0.08);
}
.os-badge-charcoal {
  color: var(--athera-charcoal);
  border-color: var(--athera-line);
}
.os-badge-muted {
  color: var(--athera-grey-light);
  background: var(--athera-off-white);
}

/* Status badges (triage) */
.os-badge-status[data-status="pursue"] {
  color: var(--athera-blue-deep);
  border-color: var(--athera-blue);
  background: rgba(95, 184, 214, 0.10);
}
.os-badge-status[data-status="monitor"] {
  color: var(--athera-grey);
  border-color: var(--athera-line);
}
.os-badge-status[data-status="dismiss"] {
  color: var(--athera-grey-light);
  background: var(--athera-off-white);
  border-color: var(--athera-line-light);
}

/* --------------------------------------------------------------------------
   Forms — text, select, multiselect chips, date, textarea
   -------------------------------------------------------------------------- */

.os-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: var(--space-3); }

.os-field-label {
  font-family: var(--athera-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--athera-grey);
}
.os-field-hint {
  font-family: var(--athera-sans);
  font-size: 12px;
  color: var(--athera-grey-light);
  line-height: 1.5;
}

.os-input,
.os-select,
.os-textarea {
  width: 100%;
  font-family: var(--athera-sans);
  font-size: 15px;
  font-weight: 400;
  color: var(--athera-charcoal);
  background: var(--athera-white);
  border: 1px solid var(--athera-line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  line-height: 1.5;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.os-input::placeholder,
.os-textarea::placeholder { color: var(--athera-grey-light); }

.os-input:focus,
.os-select:focus,
.os-textarea:focus {
  outline: none;
  border-color: var(--athera-blue);
  box-shadow: 0 0 0 3px rgba(95, 184, 214, 0.18);
}

.os-textarea { min-height: 96px; resize: vertical; }

.os-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* Multiselect chips */
.os-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.os-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--athera-line);
  border-radius: 999px;
  background: var(--athera-white);
  font-family: var(--athera-sans);
  font-size: 13px;
  color: var(--athera-charcoal);
  cursor: pointer;
  user-select: none;
  transition: border-color var(--ease), background-color var(--ease), color var(--ease);
}
.os-chip:hover { border-color: var(--athera-grey-light); }
.os-chip.is-selected,
.os-chip[aria-pressed="true"] {
  border-color: var(--athera-blue);
  background: rgba(95, 184, 214, 0.10);
  color: var(--athera-blue-deep);
}
.os-chip input { position: absolute; opacity: 0; pointer-events: none; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.os-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--athera-sans);
  font-size: 13px;
}
.os-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--athera-grey-light);
  border-bottom: 1px solid var(--athera-line);
  white-space: nowrap;
}
.os-table td {
  padding: 12px 16px;
  color: var(--athera-charcoal);
  border-bottom: 1px solid var(--athera-line-light);
  vertical-align: top;
}
.os-table tbody tr:hover { background: var(--athera-off-white); }
.os-table .num { text-align: right; font-family: var(--athera-mono); font-size: 12px; }

/* --------------------------------------------------------------------------
   State blocks — empty / loading / error
   -------------------------------------------------------------------------- */

.os-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  max-width: 520px;
  margin: 0 auto;
}
.os-state-title {
  font-family: var(--athera-display);
  font-size: 28px;
  font-weight: 300;
  color: var(--athera-charcoal);
  margin: 0 0 var(--space-2);
}
.os-state-text {
  font-family: var(--athera-sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--athera-grey);
  margin: 0 0 var(--space-4);
}

.os-state-error .os-state-title { color: var(--athera-charcoal); }
.os-state-error {
  border: 1px solid var(--athera-line);
  border-left: 2px solid var(--athera-amber);
  border-radius: var(--radius);
  background: var(--athera-white);
  text-align: left;
  padding: var(--space-4);
}
.os-state-error .os-state-title { font-size: 20px; }

/* Loading: spinner + skeleton */
.os-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-7);
  color: var(--athera-grey);
  font-family: var(--athera-sans);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.os-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--athera-line);
  border-top-color: var(--athera-blue);
  border-radius: 50%;
  animation: os-spin 0.7s linear infinite;
}
@keyframes os-spin { to { transform: rotate(360deg); } }

.os-skeleton {
  background: linear-gradient(90deg, var(--athera-surface) 25%, var(--athera-off-white) 37%, var(--athera-surface) 63%);
  background-size: 400% 100%;
  animation: os-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
  height: 14px;
}
@keyframes os-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* --------------------------------------------------------------------------
   "Suggestion, not decision" callout
   -------------------------------------------------------------------------- */

.os-callout {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  border: 1px solid var(--athera-line);
  border-left: 2px solid var(--athera-blue);
  border-radius: var(--radius);
  background: var(--athera-white);
  padding: var(--space-3);
}
.os-callout-mark {
  font-family: var(--athera-display);
  font-size: 20px;
  font-weight: 300;
  color: var(--athera-blue);
  line-height: 1;
  flex: 0 0 auto;
}
.os-callout-text {
  font-family: var(--athera-sans);
  font-size: 13px;
  font-weight: 300;
  line-height: 1.6;
  color: var(--athera-grey);
  margin: 0;
}

/* --------------------------------------------------------------------------
   Metric figures (for summary stats)
   -------------------------------------------------------------------------- */

.os-metric { display: flex; flex-direction: column; gap: 6px; }
.os-metric-value {
  font-family: var(--athera-display);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 300;
  line-height: 1;
  color: var(--athera-charcoal);
  letter-spacing: -0.01em;
}
.os-metric-label {
  font-family: var(--athera-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--athera-grey);
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.os-flex { display: flex; }
.os-flex-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.os-flex-wrap { flex-wrap: wrap; }
.os-gap-1 { gap: var(--space-1); }
.os-gap-2 { gap: var(--space-2); }
.os-gap-3 { gap: var(--space-3); }
.os-mt-2 { margin-top: var(--space-2); }
.os-mt-3 { margin-top: var(--space-3); }
.os-mt-5 { margin-top: var(--space-5); }
.os-mb-3 { margin-bottom: var(--space-3); }
.os-text-grey { color: var(--athera-grey); }
.os-text-center { text-align: center; }
.os-hide { display: none !important; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  :root { --page-pad: 24px; }
  .os-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .os-header { gap: var(--space-2); }
}

@media (max-width: 680px) {
  .os-grid-2,
  .os-grid-3 { grid-template-columns: 1fr; }
  .os-evidence li { grid-template-columns: 1fr; gap: 4px; }
  .os-opp-titlerow { flex-direction: column; }
  .os-header { flex-direction: column; align-items: flex-start; }
  .os-stepnav { width: 100%; }
}
