/**
 * @file src/ui/four_point_ruler.css
 * @description Obsidian Dark (#090A0F) Design Tokens & Responsive Bento Layout for 4-Point Break-Even Ruler.
 * Chief Quantitative Architect Directive: Google Gemini 4 Argon
 */

:root {
  --fpr-bg-obsidian: #090A0F;
  --fpr-bg-surface: #10121A;
  --fpr-bg-cell: #0D0F17;
  --fpr-border-subtle: rgba(255, 255, 255, 0.07);
  --fpr-border-focus: rgba(255, 255, 255, 0.16);

  --fpr-text-primary: #F3F4F8;
  --fpr-text-secondary: #9499AD;
  --fpr-text-muted: #5E6478;

  /* Regime & Zone Chromatics */
  --fpr-drawdown-crimson: #FF3B5C;
  --fpr-friction-amber: #F59E0B;
  --fpr-friction-amber-glow: rgba(245, 158, 11, 0.22);
  --fpr-profit-emerald: #10B981;
  --fpr-profit-cyan: #06B6D4;
  --fpr-profit-glow: rgba(16, 185, 129, 0.24);

  --fpr-font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  --fpr-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.fpr-card {
  background: var(--fpr-bg-obsidian);
  border: 1px solid var(--fpr-border-subtle);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--fpr-text-primary);
  font-family: var(--fpr-font-sans);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
  box-sizing: border-box;
  transition: border-color 180ms ease;
}

.fpr-card[data-regime="0"] { border-color: rgba(255, 59, 92, 0.35); }
.fpr-card[data-regime="1"] { border-color: rgba(245, 158, 11, 0.35); }
.fpr-card[data-regime="2"],
.fpr-card[data-regime="3"] { border-color: rgba(16, 185, 129, 0.40); }

/* Header Bar */
.fpr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.fpr-title-group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.fpr-symbol {
  font-family: var(--fpr-font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--fpr-text-primary);
}

.fpr-badge {
  font-family: var(--fpr-font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--fpr-bg-surface);
  border: 1px solid var(--fpr-border-subtle);
  color: var(--fpr-text-secondary);
}

.fpr-telemetry {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fpr-regime-pill {
  font-family: var(--fpr-font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: 4px;
  text-transform: uppercase;
}

.fpr-card[data-regime="0"] .fpr-regime-pill {
  background: rgba(255, 59, 92, 0.14);
  color: var(--fpr-drawdown-crimson);
  border: 1px solid rgba(255, 59, 92, 0.3);
}

.fpr-card[data-regime="1"] .fpr-regime-pill {
  background: rgba(245, 158, 11, 0.14);
  color: var(--fpr-friction-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.fpr-card[data-regime="2"] .fpr-regime-pill,
.fpr-card[data-regime="3"] .fpr-regime-pill {
  background: rgba(16, 185, 129, 0.14);
  color: var(--fpr-profit-emerald);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.fpr-pnl-value {
  font-family: var(--fpr-font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.fpr-card[data-regime="0"] .fpr-pnl-value {
  color: var(--fpr-drawdown-crimson);
}

.fpr-card[data-regime="1"] .fpr-pnl-value {
  color: var(--fpr-friction-amber);
}

.fpr-card[data-regime="2"] .fpr-pnl-value,
.fpr-card[data-regime="3"] .fpr-pnl-value {
  color: var(--fpr-profit-emerald);
}

/* Ruler Track Viewport */
.fpr-track-viewport {
  position: relative;
  padding-top: 30px;
  padding-bottom: 14px;
  margin: 0 6px;
}

.fpr-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #141722;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: visible;
}

/* Friction Zone (P1 -> P3) & Profit Zone (P3 -> P4) */
.fpr-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: none;
}

.fpr-zone--friction {
  border-radius: 999px 0 0 999px;
  background: repeating-linear-gradient(
    -45deg,
    rgba(245, 158, 11, 0.28),
    rgba(245, 158, 11, 0.28) 5px,
    rgba(245, 158, 11, 0.10) 5px,
    rgba(245, 158, 11, 0.10) 10px
  );
  border-right: 1px dashed var(--fpr-friction-amber);
}

.fpr-zone--profit {
  border-radius: 0 999px 999px 0;
  background: linear-gradient(
    90deg,
    rgba(16, 185, 129, 0.18) 0%,
    rgba(6, 182, 212, 0.30) 100%
  );
}

.fpr-zone-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.35;
  will-change: width;
  transition: width 90ms linear;
}

.fpr-card[data-regime="0"] .fpr-zone-fill { background: var(--fpr-drawdown-crimson); }
.fpr-card[data-regime="1"] .fpr-zone-fill { background: var(--fpr-friction-amber); }
.fpr-card[data-regime="2"] .fpr-zone-fill,
.fpr-card[data-regime="3"] .fpr-zone-fill {
  background: linear-gradient(90deg, var(--fpr-profit-emerald), var(--fpr-profit-cyan));
}

/* Coordinate Nodes along the Track */
.fpr-node {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.fpr-tick-mark {
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--fpr-text-secondary);
  box-shadow: 0 0 0 2px var(--fpr-bg-obsidian);
}

.fpr-node--p2 .fpr-tick-mark {
  background: var(--fpr-friction-amber);
}

.fpr-tick-mark--anchor {
  width: 5px;
  height: 18px;
  background: var(--fpr-profit-emerald);
  box-shadow: 0 0 8px var(--fpr-profit-emerald), 0 0 0 2px var(--fpr-bg-obsidian);
}

.fpr-node--p4 .fpr-tick-mark {
  background: var(--fpr-profit-cyan);
}

/* Live LTP Beacon */
.fpr-ltp-beacon {
  position: absolute;
  top: 2px;
  left: 0%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 5;
  pointer-events: none;
  will-change: left;
  transition: left 90ms linear;
}

.fpr-ltp-Readout {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 5px;
  background: #161925;
  border: 1px solid var(--fpr-border-focus);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.65);
  white-space: nowrap;
  font-family: var(--fpr-font-mono);
  /* Dynamic viewport-aware horizontal shift prevents clipping at 0% and 100% */
  transform: translateX(calc(50% - (var(--beacon-pct, 50) * 1%)));
}

.fpr-ltp-tag {
  font-size: 0.60rem;
  font-weight: 700;
  color: var(--fpr-text-secondary);
}

.fpr-ltp-price {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--fpr-text-primary);
  font-variant-numeric: tabular-nums;
}

.fpr-ltp-delta {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--fpr-text-secondary);
  font-variant-numeric: tabular-nums;
}

.fpr-ltp-stem {
  width: 1.5px;
  height: 7px;
  background: var(--fpr-text-primary);
}

.fpr-ltp-Reticle {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--fpr-text-primary);
  border: 2px solid var(--fpr-bg-obsidian);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

/* 4-Point Matrix Grid */
.fpr-matrix {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
  box-sizing: border-box;
}

.fpr-cell {
  background: var(--fpr-bg-cell);
  border: 1px solid var(--fpr-border-subtle);
  border-radius: 7px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-sizing: border-box;
  min-width: 0;
}

.fpr-cell--p2 {
  border-left: 2px solid rgba(245, 158, 11, 0.55);
}

.fpr-cell--p3 {
  border-left: 2px solid var(--fpr-profit-emerald);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.06) 0%, var(--fpr-bg-cell) 100%);
}

.fpr-cell--p4 {
  border-left: 2px solid var(--fpr-profit-cyan);
}

.fpr-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.fpr-point-id {
  font-family: var(--fpr-font-mono);
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--fpr-text-primary);
}

.fpr-point-name {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--fpr-text-secondary);
}

.fpr-point-price {
  font-family: var(--fpr-font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--fpr-text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fpr-point-sub {
  font-family: var(--fpr-font-mono);
  font-size: 0.65rem;
  color: var(--fpr-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Deck Slot Container */
.fpr-deck-slot {
  min-width: 0;
  width: 100%;
  display: block;
  box-sizing: border-box;
}

/* Dynamic 2.5x ATR Chandelier Trailing Stop Strip */
.fpr-badge--slot {
  background: rgba(6, 182, 212, 0.08);
  border-color: rgba(6, 182, 212, 0.3);
  color: var(--fpr-profit-cyan);
}

.fpr-chandelier-strip {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  box-sizing: border-box;
  flex-wrap: wrap;
  gap: 8px;
}

.fpr-chandelier-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.fpr-chandelier-icon {
  font-size: 0.85rem;
}

.fpr-chandelier-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--fpr-text-muted);
  text-transform: uppercase;
}

.fpr-chandelier-price {
  font-family: var(--fpr-font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.fpr-chandelier-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fpr-chandelier-badge {
  font-family: var(--fpr-font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--fpr-friction-amber);
}

.fpr-chandelier-badge--locked {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--fpr-profit-emerald);
}

.fpr-chandelier-cushion {
  font-family: var(--fpr-font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--fpr-profit-emerald);
  font-variant-numeric: tabular-nums;
}

.fpr-chandelier-cushion--breached {
  color: var(--fpr-drawdown-crimson);
}

/* Invalidation Alert State */
.fpr-card[data-invalidation="true"] {
  border-color: #ef4444 !important;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.35), inset 0 1px 0 rgba(239, 68, 68, 0.2);
  animation: invalidationPulse 2s infinite ease-in-out;
}

@keyframes invalidationPulse {
  0%, 100% { border-color: rgba(239, 68, 68, 0.5); }
  50% { border-color: rgba(239, 68, 68, 1.0); }
}

/* Thesis Invalidation Alert Toast System */
.fpr-toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 440px;
  width: calc(100% - 32px);
}

.fpr-toast {
  pointer-events: auto;
  background: #0d0f17;
  border: 1px solid #ef4444;
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8), 0 0 16px rgba(239, 68, 68, 0.3);
  color: #fff;
  font-family: var(--fpr-font-sans);
  animation: slideInToast 260ms cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  transition: transform 200ms ease, opacity 200ms ease;
}

.fpr-toast--dismissing {
  transform: translateX(110%);
  opacity: 0;
}

@keyframes slideInToast {
  from { transform: translateX(110%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.fpr-toast-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.fpr-toast-title {
  color: #ef4444;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  font-weight: 800;
  text-transform: uppercase;
}

.fpr-toast-close {
  background: none;
  border: none;
  color: var(--fpr-text-muted);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.fpr-toast-close:hover {
  color: #fff;
}

.fpr-toast-body {
  font-size: 0.78rem;
  color: var(--fpr-text-primary);
  line-height: 1.45;
}

.fpr-toast-sym {
  font-weight: 800;
  color: var(--fpr-profit-cyan);
  margin-right: 4px;
}

.fpr-toast-moc {
  font-size: 0.68rem;
  color: var(--fpr-friction-amber);
  margin-top: 6px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  padding: 3px 7px;
  border-radius: 4px;
  display: inline-block;
}

/* Mobile Responsive (< 640px) */
@media (max-width: 640px) {
  .fpr-matrix {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .fpr-ltp-delta {
    display: none;
  }
  .fpr-toast-container {
    top: 10px;
    right: 10px;
    width: calc(100% - 20px);
  }
}
