/* ==========================================================================
   Parallexus Swift — Base Styles
   ========================================================================== */

@import url('../src/shared/lib/design-tokens.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(38, 166, 154, 0.02) 0%, transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='46' viewBox='0 0 40 46'%3E%3Cpath fill='%23131826' fill-opacity='0.3' d='M20 0l20 11.547v23.094L20 46.188 0 34.641V11.547z'/%3E%3C/svg%3E");
  background-attachment: fixed;
}

.numeric { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   App container
   ========================================================================== */

.swift-app {
  max-width: 1200px;
  margin: var(--space-5) auto;
  padding: 0 var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-height: calc(100vh - var(--space-7));
}

/* RAG state: default neutral gray, only colors when explicitly set */
.swift-app                     { --rag-color: var(--border-default); }
.swift-app[data-rag="neutral"] { --rag-color: var(--border-default); }
.swift-app[data-rag="green"]   { --rag-color: var(--color-safety); }
.swift-app[data-rag="yellow"]  { --rag-color: var(--color-warn); }
.swift-app[data-rag="red"]     { --rag-color: var(--color-risk); }

/* ==========================================================================
   The report stack — single continuous panel with internal dividers
   ========================================================================== */

.report-stack {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition-normal);
  overflow: visible;
  box-shadow: 0 0 12px -2px var(--rag-color);
}

/* Internal section dividers — subtle lines between regions */
.report-stack > * + * {
  border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Memo header section
   ========================================================================== */

.memo-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--space-4) var(--space-5);
}

.memo-brand { display: flex; align-items: center; gap: var(--space-3); }

.memo-brand-mark {
  width: 24px;
  height: 24px;
  background-color: var(--brand-primary);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.memo-brand-name {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

.memo-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
}

.memo-meta-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.memo-meta-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

/* ==========================================================================
   Content section — two-column report layout
   ========================================================================== */

.swift-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.content-left, .content-right {
  padding: var(--space-6) var(--space-5);
  display: flex;
  flex-direction: column;
}

.content-right {
  justify-content: space-between;
}

.content-left {
  border-right: 1px solid var(--border-subtle);
}

.report-title {
  font-size: 36px;
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: var(--leading-tight);
  margin-bottom: var(--space-2);
  text-align: center;
}

.memo-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slogan {
  font-style: italic;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.venn-placeholder {
  margin-top: var(--space-4);
  margin-bottom: calc(var(--space-6) * -1);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.venn-placeholder svg {
  display: block;
  width: 100%;
  max-width: 320px;
  height: auto;
  margin-bottom: 0;
}

.venn-citation {
  font-size: 10px;
  color: var(--text-tertiary);
  line-height: 1.5;
  letter-spacing: 0.02em;
  margin-top: var(--space-4);
  text-align: center;
  font-style: normal;
}

.venn-citation em {
  font-style: italic;
  color: var(--text-secondary);
}

.section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-5);
}

.horseman-bars { display: flex; flex-direction: column; gap: var(--space-6); }

.horseman-bar { display: flex; flex-direction: column; gap: var(--space-2); }

.horseman-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.horseman-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  flex-shrink: 0;
}

.horseman-description {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: var(--weight-regular);
  line-height: 1.4;
}

.horseman-track {
  position: relative;
  height: 6px;
  background: linear-gradient(to right,
    var(--color-safety) 0%, var(--color-safety) 30%,
    var(--color-warn) 50%,
    var(--color-risk) 70%, var(--color-risk) 100%);
  border-radius: var(--radius-sm);
  opacity: 0.5;
}

.horseman-marker {
  position: absolute;
  top: -3px;
  width: 4px;
  height: 12px;
  background-color: var(--text-primary);
  border-radius: 1px;
  transform: translateX(-50%);
  transition: left var(--transition-normal);
}

/* ==========================================================================
   Findings section — currently empty
   ========================================================================== */

.swift-findings {
  padding: var(--space-6) var(--space-5);
  min-height: 280px;
}

/* ==========================================================================
   Bottom CTAs — separate from the RAG-bordered stack
   ========================================================================== */

.swift-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
}

.cta {
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cta-primary {
  background-color: var(--brand-primary);
  color: var(--text-inverse);
  border-color: var(--brand-primary);
}

.cta-primary:hover {
  background-color: transparent;
  color: var(--brand-primary);
}

.cta-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.cta-secondary:hover {
  border-color: var(--text-primary);
  background-color: var(--bg-elevated);
}

/* ==========================================================================
   Venn score display — gold-glowing card above the diagram
   ========================================================================== */

.venn-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-3);
  padding: var(--space-2) var(--space-4);
  width: fit-content;
  background: var(--bg-elevated);
  border: 1px solid var(--color-warn);
  border-radius: var(--radius-md);
  box-shadow: 0 0 12px rgba(255, 193, 7, 0.2),
              inset 0 0 8px rgba(255, 193, 7, 0.1);
}

.venn-score-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: var(--weight-medium);
}

.venn-score-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-warn);
  line-height: 1;
  margin-top: 2px;
}

/* ==========================================================================
   Findings section — Represents card and MIN/MAX shell
   ========================================================================== */

.swift-findings {
  padding: var(--space-5);
  min-height: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.represents-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ==========================================================================
   Opportunity Cost — bracket-and-track scale
   ========================================================================== */

.oc-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.oc-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: var(--weight-medium);
}

.oc-card {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* The DELTA callout: bracketed gold value floating above the track */
.oc-delta-callout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
}

.oc-delta-bracket-left,
.oc-delta-bracket-right {
  flex: 1;
  height: 1px;
  background: var(--text-primary);
  opacity: 0.4;
  position: relative;
  margin: 0 var(--space-3);
}

.oc-delta-bracket-left::before,
.oc-delta-bracket-right::after {
  content: '';
  position: absolute;
  top: -4px;
  width: 1px;
  height: 9px;
  background: var(--text-primary);
  opacity: 0.4;
}

.oc-delta-bracket-left::before {
  left: 0;
}

.oc-delta-bracket-right::after {
  right: 0;
}

.oc-delta-value {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.oc-delta-dollars {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1;
}

.oc-delta-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: var(--weight-medium);
}

/* The track: full-width gradient bar (matches horsemen bars) */
.oc-track {
  height: 8px;
  width: 100%;
  background: linear-gradient(
    to right,
    var(--color-safety) 0%,
    var(--color-safety) 30%,
    var(--color-warn) 50%,
    var(--color-risk) 70%,
    var(--color-risk) 100%
  );
  border-radius: var(--radius-sm);
  opacity: 0.65;
}

/* The endpoints: MIN at left edge, MAX at right edge */
.oc-endpoints {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.oc-endpoint {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.oc-endpoint-min {
  align-items: flex-start;
}

.oc-endpoint-max {
  align-items: flex-end;
}

.oc-min-dollars,
.oc-max-dollars {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  line-height: 1;
}

.oc-max-dollars {
  color: var(--text-primary);
}

.oc-endpoint-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: var(--weight-medium);
}

.oc-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Mobile: hide MIN/MAX endpoints, shrink DELTA to fit */
@media (max-width: 700px) {
  .oc-endpoints {
    display: none;
  }

  .oc-delta-dollars {
    font-size: var(--text-2xl);
  }

  .oc-delta-bracket-left,
  .oc-delta-bracket-right {
    display: none;
  }
}

.represents-card {
  padding: var(--space-3) 0 var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.represents-card.rag-bordered {
  border: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--rag-color) 12%, var(--bg-elevated));
  transition: background-color var(--transition-normal),
              box-shadow var(--transition-normal);
  box-shadow: 0 0 16px -2px var(--rag-color),
              inset 0 0 24px 0 color-mix(in srgb, var(--rag-color) 20%, transparent);
}

.represents-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: var(--weight-medium);
}

.represents-stats {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  min-height: 56px;
}

.represents-stat {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: var(--space-2);
}

.represents-stat-comparison {
  gap: var(--space-1);
}

/* Middle stat (percent) centers on the percentage number, not the whole group */
.represents-stat:nth-child(2) {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translateY(-50%);
  align-items: baseline;
}

.represents-stat:nth-child(2) .represents-percent {
  transform: translateX(-50%);
}

.represents-stat:nth-child(2) .represents-stat-label {
  position: absolute;
  left: 50%;
  bottom: 0;
  margin-left: var(--space-2);
  white-space: nowrap;
}

/* The percent number itself becomes the centered anchor point */
.represents-stat:nth-child(2) .represents-percent {
  /* The label sits beside it; only this number is the anchor */
}

.represents-stat-primary .represents-dollars {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.04em;
}

.represents-stat .represents-percent {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.04em;
}

.represents-stat-comparison .represents-industry {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  line-height: 1;
  color: var(--rag-color, var(--text-primary));
  transition: color var(--transition-normal);
  letter-spacing: -0.04em;
}

.represents-direction {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  margin-left: 0;
  letter-spacing: -1px;
}

.represents-stat-comparison[data-direction="above"] .represents-direction {
  color: var(--color-risk);
}

.represents-stat-comparison[data-direction="below"] .represents-direction {
  color: var(--color-safety);
}

.represents-stat-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: var(--weight-medium);
}

.represents-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

@media (max-width: 900px) {
  .represents-stat-primary .represents-dollars,
  .represents-stat .represents-percent,
  .represents-stat-comparison .represents-industry {
    font-size: var(--text-2xl);
  }
}

@media (max-width: 700px) {
  .represents-stats {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .represents-stat {
    justify-content: space-between;
  }

  .represents-stat-primary .represents-dollars,
  .represents-stat .represents-percent,
  .represents-stat-comparison .represents-industry {
    font-size: var(--text-xl);
  }
}

/* ==========================================================================
   Section 3 — Personality and Closer
   ========================================================================== */

.section-three {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Universal block treatment — matches the labeled-card pattern from Section 2 */
.s3-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.s3-block-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: var(--weight-medium);
}

/* Shared sub-block / horseman card treatment */
.s3-horseman-card,
.s3-sub-block {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.s3-horseman-title,
.s3-sub-title {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: 0.02em;
  margin-bottom: var(--space-2);
  line-height: 1.3;
}

.s3-horseman-body,
.s3-sub-body {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Block C and E (single block, no grid) — the inner title and body sit
   directly inside the .s3-block, with the same card treatment */
.s3-block-triggerless,
.s3-block-closer {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.s3-block-triggerless .s3-block-label,
.s3-block-closer .s3-block-label {
  margin-bottom: var(--space-1);
}

/* The triggerless block gets a subtle accent treatment since it's the
   "this is the Parallexus differentiator" moment — slightly elevated
   visual weight via a thin teal accent on the left */
.s3-block-triggerless {
  border-left: 2px solid var(--brand-primary);
}

/* Block A — Four Horsemen 2x2 grid */
.s3-horsemen-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* Block B — Score breakdown two-column grid */
.s3-score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* Block D — Compares three-column grid */
.s3-compares-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-3);
}

/* Responsive breakpoints */
@media (max-width: 900px) {
  .s3-horsemen-grid,
  .s3-score-grid,
  .s3-compares-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Section 1 Hover Zones — invisible triggers over the Venn
   ========================================================================== */

.venn-svg-wrapper {
  position: relative;
  display: inline-block;
}

.venn-hover-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  cursor: help;
  background: transparent;
}

/* Approximate zones over the Venn — left third for PREP, middle third for
   overlap, right third for RISK. These are wide enough that hover detection
   feels intuitive without requiring pixel-perfect targeting. */
.venn-hover-prep {
  left: 0;
  width: 33%;
}

.venn-hover-overlap {
  left: 33%;
  width: 34%;
}

.venn-hover-risk {
  left: 67%;
  width: 33%;
}

.venn-score {
  cursor: help;
}

/* ==========================================================================
   Hover Tooltip — shared popover that appears on hover
   ========================================================================== */

.hover-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 320px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 150ms ease, visibility 150ms ease;
  pointer-events: none;
}

.hover-tooltip[data-visible="true"] {
  opacity: 1;
  visibility: visible;
}

.hover-tooltip-title {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-2);
}

.hover-tooltip-body {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.5;
}

/* ==========================================================================
   Venn Footnotes — numbered methodology references rendered below citation
   ========================================================================== */

.venn-footnotes {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.venn-footnote {
  font-size: 10px;
  line-height: 1.5;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
  text-align: left;
  padding-left: var(--space-3);
  text-indent: calc(-1 * var(--space-3));
}

.venn-footnote strong {
  color: var(--text-secondary);
  font-weight: var(--weight-semibold);
}

.footnote-marker {
  display: inline-block;
  color: var(--text-secondary);
  font-weight: var(--weight-bold);
  margin-right: var(--space-1);
  font-size: 11px;
}

/* Hide footnotes on screen by default — they only appear in print */
@media screen {
  .venn-footnotes {
    display: none;
  }
}

@media print {
  .venn-footnotes {
    display: flex;
  }

  .hover-tooltip {
    display: none !important;
  }
}

/* ============================================================
   ADD MORE INPUTS BUTTON
   ============================================================ */

.swift-add-more-inputs-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  background-color: transparent;
  border: 1px solid rgba(38, 166, 154, 0.4);
  color: rgba(38, 166, 154, 0.85);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease;
  align-self: flex-end;
}

.swift-add-more-inputs-button:hover {
  background-color: rgba(38, 166, 154, 0.08);
  border-color: rgba(38, 166, 154, 0.7);
  color: rgba(38, 166, 154, 1);
}

.swift-add-more-inputs-button:active {
  transform: translateY(1px);
}

.swift-add-more-inputs-button .add-more-icon {
  font-size: 0.95rem;
  line-height: 1;
  font-weight: 700;
}

.swift-add-more-inputs-button .add-more-label {
  line-height: 1;
}


/* Per ADR-005: 4-digit PIN input group (used by morphic modal, PIN unlock overlay, set-pin page) */
.swift-pin-digit-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
}

.swift-pin-digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-family: monospace;
  background: var(--bg-input, #0e0e0e);
  border: 1px solid var(--border-input, #333);
  border-radius: 6px;
  color: var(--text-primary, #eee);
  box-sizing: border-box;
}

.swift-pin-digit:focus {
  outline: none;
  border-color: var(--brand-primary, #4A6FA5);
}
