/* THE FAXET MATRIX — panel styling.
   Dark-fintech IDE aesthetic: near-black translucent panels, hairline borders, single mint
   neon accent (#10b981) with amber (#f59e0b), sky (#38bdf8), violet (#a78bfa) and danger
   orange/red secondaries. JetBrains Mono for data, Outfit for headings. Reuses THE VAULT
   CSS vars (--text-main, --text-muted) from styles.css, which loads first. */

.faxet-shell { position: relative; }

.faxet-heading {
  font-family: 'Outfit', sans-serif; font-weight: 900; font-size: 1.05rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-main);
  background: linear-gradient(90deg, #10b981, #38bdf8); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent;
}
.faxet-subhead { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; font-family: 'JetBrains Mono', monospace; }

.faxet-ghost-btn {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; font-weight: 700;
  color: var(--text-muted); border: 1px solid rgba(100,116,139,0.3); border-radius: 0.5rem;
  padding: 0.25rem 0.55rem; background: transparent; cursor: pointer; transition: all 0.15s ease;
}
.faxet-ghost-btn:hover { color: #10b981; border-color: rgba(16,185,129,0.5); }

/* --- Resource tiles --- */
.faxet-tile {
  border: 1px solid rgba(100,116,139,0.2); border-radius: 0.65rem; background: rgba(13,14,17,0.4);
  padding: 0.6rem 0.7rem; display: flex; flex-direction: column; gap: 2px;
}
.faxet-tile-label { font-family: 'JetBrains Mono', monospace; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.faxet-tile-value { font-family: 'Outfit', sans-serif; font-weight: 900; font-size: 1.05rem; color: var(--text-main); line-height: 1.1; }
.faxet-tile-sub { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--text-muted); }
.faxet-shard-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.faxet-shard-chip { display: inline-flex; align-items: center; gap: 3px; }
.faxet-shard-chip i { width: 7px; height: 7px; border-radius: 9999px; display: inline-block; }

/* --- Panels --- */
.faxet-panel {
  border: 1px solid rgba(100,116,139,0.2); border-radius: 0.75rem; background: rgba(13,14,17,0.24); padding: 0.85rem;
}
.faxet-panel-title { font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-main); }
.faxet-panel-sub { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--text-muted); }

/* --- Grid tabs --- */
.faxet-tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.faxet-tab {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700; padding: 0.2rem 0.5rem;
  border-radius: 0.4rem; border: 1px solid transparent; color: var(--text-muted); background: rgba(13,14,17,0.4); cursor: pointer;
}
.faxet-tab-active { color: #10b981; border-color: rgba(16,185,129,0.5); background: rgba(16,185,129,0.1); }

/* --- The circuit grid --- */
.faxet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.faxet-cell {
  aspect-ratio: 1 / 1; position: relative; display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(100,116,139,0.22); border-radius: 0.6rem; background: rgba(13,14,17,0.45);
  cursor: pointer; padding: 8px; transition: border-color 0.15s ease, box-shadow 0.2s ease, transform 0.1s ease;
}
.faxet-cell:hover { border-color: rgba(16,185,129,0.5); transform: translateY(-1px); }
.faxet-cell:active { transform: scale(0.96); }
.faxet-cell-hot {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16,185,129,0.35), 0 0 16px rgba(16,185,129,0.55);
  animation: faxet-pulse 0.9s ease-in-out;
}
@keyframes faxet-pulse {
  0% { box-shadow: 0 0 0 2px rgba(16,185,129,0.7), 0 0 22px rgba(16,185,129,0.85); }
  100% { box-shadow: 0 0 0 2px rgba(16,185,129,0.2), 0 0 8px rgba(16,185,129,0.3); }
}
.faxet-cell.faxet-crit {
  border-color: #fde047;
  box-shadow: 0 0 0 2px rgba(250,204,21,0.75), 0 0 22px rgba(250,204,21,0.9);
  animation: faxet-crit-flash 0.7s ease-out;
}
@keyframes faxet-crit-flash {
  0% { box-shadow: 0 0 0 3px rgba(250,204,21,1), 0 0 30px rgba(250,204,21,1); transform: scale(1.06); }
  100% { box-shadow: 0 0 0 0 rgba(250,204,21,0); transform: scale(1); }
}
.faxet-reduced .faxet-cell.faxet-crit { animation: none; }
.faxet-cell-fault {
  border-color: rgba(239,68,68,0.6);
  background: repeating-linear-gradient(45deg, rgba(239,68,68,0.1) 0 6px, rgba(13,14,17,0.5) 6px 12px);
}
.faxet-null { color: #ef4444; font-family: 'JetBrains Mono', monospace; font-weight: 900; font-size: 10px; text-align: center; line-height: 1.1; }
.faxet-null small { color: rgba(239,68,68,0.7); font-size: 8px; }
.faxet-slot-plus { color: rgba(148,163,184,0.35); font-size: 1.4rem; font-weight: 300; }

/* Gem level pip (overclock affordance) — bottom-right corner of a placed gem. */
.faxet-level-pip {
  position: absolute; bottom: 3px; right: 3px; z-index: 2;
  min-width: 15px; height: 14px; padding: 0 3px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-size: 8px; font-weight: 800; letter-spacing: 0.02em;
  color: rgba(203,213,225,0.85); background: rgba(2,6,12,0.78);
  border: 1px solid rgba(100,116,139,0.4); cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}
.faxet-level-pip:hover { border-color: rgba(148,163,184,0.7); }
.faxet-level-pip.faxet-level-ready {
  color: #6ee7b7; border-color: rgba(16,185,129,0.8);
  box-shadow: 0 0 8px rgba(16,185,129,0.55); animation: faxet-pip-glow 1.6s ease-in-out infinite;
}
.faxet-level-pip.faxet-level-max { color: #f59e0b; border-color: rgba(245,158,11,0.7); cursor: default; }
@keyframes faxet-pip-glow {
  0%, 100% { box-shadow: 0 0 5px rgba(16,185,129,0.4); }
  50% { box-shadow: 0 0 11px rgba(16,185,129,0.75); }
}
.faxet-reduced .faxet-level-pip.faxet-level-ready { animation: none; }

/* --- Build Orders (contracts) --- */
.faxet-contracts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.5rem; }
.faxet-contract {
  border: 1px solid rgba(100,116,139,0.22); border-radius: 0.6rem;
  background: rgba(13,14,17,0.4); padding: 0.55rem 0.65rem;
}
.faxet-contract-done { border-color: rgba(16,185,129,0.5); box-shadow: 0 0 10px rgba(16,185,129,0.25); }
.faxet-contract-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.4rem; margin-bottom: 0.25rem; }
.faxet-contract-title { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 800; color: var(--text-main); }
.faxet-contract-reward { font-family: 'JetBrains Mono', monospace; font-size: 8.5px; color: #10b981; white-space: nowrap; }
.faxet-contract-desc { font-size: 10px; color: var(--text-muted); line-height: 1.35; margin-bottom: 0.4rem; }
.faxet-contract-bar { height: 0.35rem; border-radius: 9999px; background: rgba(13,14,17,0.7); border: 1px solid rgba(100,116,139,0.22); overflow: hidden; }
.faxet-contract-bar span { display: block; height: 100%; background: linear-gradient(90deg, #10b981, #f59e0b); transition: width 0.3s ease; }
.faxet-contract-foot { display: flex; justify-content: flex-end; margin-top: 0.25rem; }
.fx-contract-label { font-family: 'JetBrains Mono', monospace; font-size: 8.5px; color: var(--text-muted); }

/* --- Equilibrium + action button --- */
.faxet-eq { height: 0.4rem; border-radius: 9999px; background: rgba(13,14,17,0.6); border: 1px solid rgba(100,116,139,0.24); overflow: hidden; }
.faxet-eq span { display: block; height: 100%; background: linear-gradient(90deg, #10b981, #38bdf8); transition: width 0.3s ease; }
.faxet-action-btn {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 800; text-transform: uppercase;
  border: 1px solid rgba(16,185,129,0.45); border-radius: 0.6rem; background: rgba(16,185,129,0.12);
  color: var(--text-main); padding: 0.45rem; cursor: pointer; transition: all 0.15s ease;
}
.faxet-action-btn:hover:not(:disabled) { background: #10b981; color: #0d0e11; border-color: #10b981; }
.faxet-action-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* --- Palette --- */
.faxet-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.4rem; }
.faxet-palette-btn {
  display: flex; align-items: center; gap: 0.5rem; text-align: left; padding: 0.4rem 0.5rem;
  border: 1px solid rgba(100,116,139,0.2); border-radius: 0.6rem; background: rgba(13,14,17,0.4); cursor: pointer; transition: all 0.15s ease;
}
.faxet-palette-btn:hover:not(:disabled) { border-color: rgba(16,185,129,0.5); transform: translateY(-1px); }
.faxet-palette-selected { border-color: #10b981 !important; box-shadow: 0 0 0 1px rgba(16,185,129,0.4), 0 0 12px rgba(16,185,129,0.25); }
.faxet-palette-poor { opacity: 0.5; cursor: not-allowed; }
.faxet-palette-anomaly { border-color: rgba(167,139,250,0.5); background: rgba(124,58,237,0.08); }
.faxet-palette-anomaly strong { color: #c4b5fd; }
.faxet-palette-anomaly.faxet-palette-selected { border-color: #a78bfa !important; box-shadow: 0 0 0 1px rgba(167,139,250,0.5), 0 0 12px rgba(167,139,250,0.35); }
.faxet-palette-gem { width: 34px; height: 34px; flex-shrink: 0; position: relative; }
.faxet-palette-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.faxet-palette-meta strong { font-size: 11px; color: var(--text-main); font-family: 'Outfit', sans-serif; font-weight: 700; }
.faxet-palette-meta em { font-style: normal; font-family: 'JetBrains Mono', monospace; font-size: 8px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.06em; }
.faxet-palette-cost { display: flex; gap: 0.4rem; font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--text-main); }
.faxet-palette-cost i { width: 6px; height: 6px; border-radius: 9999px; display: inline-block; margin-right: 2px; }
.faxet-hint { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--text-muted); }
.faxet-hint strong { color: #10b981; }

/* --- Macro matrix (N recursive tiers) --- */
.faxet-macro-tiers { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.faxet-macro-tier {
  border: 1px solid rgba(100,116,139,0.18); border-radius: 0.6rem; background: rgba(13,14,17,0.3);
  padding: 0.6rem; width: 15rem; flex: 0 0 auto;
}
.faxet-macro-tier-label { font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 800; text-transform: uppercase; color: #38bdf8; letter-spacing: 0.08em; }
.faxet-macro-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
.faxet-macro-cell {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; padding: 5px;
  border: 1px dashed rgba(100,116,139,0.25); border-radius: 0.5rem; background: rgba(13,14,17,0.35);
  transition: box-shadow 0.2s ease, border-color 0.15s ease;
}
.faxet-macro-filled { border-style: solid; border-color: rgba(16,185,129,0.4); box-shadow: inset 0 0 10px rgba(16,185,129,0.12); }
.faxet-macro-hot {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56,189,248,0.4), 0 0 14px rgba(56,189,248,0.5);
  animation: faxet-macro-pulse 0.9s ease-in-out;
}
@keyframes faxet-macro-pulse {
  0% { box-shadow: 0 0 0 2px rgba(56,189,248,0.7), 0 0 20px rgba(56,189,248,0.85); }
  100% { box-shadow: 0 0 0 2px rgba(56,189,248,0.2), 0 0 8px rgba(56,189,248,0.3); }
}
.faxet-reduced .faxet-macro-hot { animation: none; }

/* --- Terminal --- */
.faxet-terminal-panel { display: flex; flex-direction: column; min-height: 0; }
.faxet-term-head { display: flex; align-items: center; gap: 0.35rem; padding-bottom: 0.4rem; }
.faxet-term-dot { width: 8px; height: 8px; border-radius: 9999px; background: #ef4444; display: inline-block; }
.faxet-term-dot-amber { background: #f59e0b; }
.faxet-term-dot-mint { background: #10b981; }
.faxet-term-title { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--text-muted); margin-left: 0.3rem; }
.faxet-terminal {
  flex: 1 1 0; min-height: 12rem; overflow-y: auto; background: #07080a;
  border: 1px solid rgba(100,116,139,0.18); border-radius: 0.5rem; padding: 0.5rem 0.6rem;
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px; line-height: 1.55;
}
.faxet-term-line { white-space: pre-wrap; word-break: break-word; }
.faxet-term-t { color: #475569; margin-right: 0.4rem; }
.faxet-term-gen { color: #34d399; }
.faxet-term-tf { color: #38bdf8; }
.faxet-term-amp { color: #f59e0b; }
.faxet-term-master { color: #c4b5fd; font-weight: 500; }
.faxet-term-fracture { color: #94a3b8; }
.faxet-term-cascade { color: #a78bfa; }
.faxet-term-offline { color: #fbbf24; }
.faxet-term-fault { color: #f87171; }
.faxet-term-crit { color: #fde047; font-weight: 700; text-shadow: 0 0 8px rgba(250,204,21,0.5); }
.faxet-term-rare { color: #f472b6; font-weight: 600; }
.faxet-term-contract { color: #10b981; font-weight: 700; }
.faxet-term-sys { color: #64748b; }

/* --- Ingestion map --- */
.faxet-map { display: flex; flex-direction: column; gap: 0.3rem; }
.faxet-map-row {
  display: grid; grid-template-columns: minmax(0,0.9fr) minmax(0,1fr) minmax(0,1.4fr) minmax(0,0.9fr);
  gap: 0.5rem; align-items: center; padding: 0.45rem 0.6rem; border: 1px solid rgba(100,116,139,0.16);
  border-radius: 0.55rem; background: rgba(13,14,17,0.24); font-family: 'JetBrains Mono', monospace; font-size: 10px;
}
.faxet-map-metric { color: var(--text-main); font-weight: 800; text-transform: uppercase; font-size: 9px; letter-spacing: 0.04em; }
.faxet-map-source, .faxet-map-effect { color: var(--text-muted); }
.faxet-map-current { color: #10b981; font-weight: 800; text-align: right; }
@media (max-width: 720px) {
  .faxet-map-row { grid-template-columns: 1fr 1fr; }
  .faxet-map-effect { grid-column: 1 / -1; }
  .faxet-map-current { text-align: left; }
}

/* --- Offline "while you were away" modal --- */
.faxet-away {
  position: absolute; inset: -0.5rem; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: rgba(7,8,10,0.78); backdrop-filter: blur(8px); border-radius: 1rem;
}
.faxet-away-panel {
  width: min(94%, 30rem); border: 1px solid rgba(16,185,129,0.35); border-radius: 0.9rem;
  background: var(--dialog-bg, #161920); box-shadow: 0 24px 80px rgba(0,0,0,0.4); padding: 1rem;
}
.faxet-x { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; }
.faxet-x:hover { color: #ef4444; }

/* --- Compile fiero flash --- */
.faxet-compile-flash { background: rgba(7,8,10,0.86); }
.faxet-compile-panel {
  text-align: center; border-color: rgba(16,185,129,0.55);
  box-shadow: 0 0 40px rgba(16,185,129,0.35), 0 24px 80px rgba(0,0,0,0.5);
  animation: faxet-compile-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.faxet-compile-burst {
  font-size: 2.6rem; line-height: 1; color: #6ee7b7;
  filter: drop-shadow(0 0 14px rgba(16,185,129,0.9)); animation: faxet-burst 0.7s ease-out;
}
.faxet-compile-title { display: block; margin-top: 0.4rem; font-family: 'JetBrains Mono', monospace; font-size: 0.95rem; font-weight: 900; letter-spacing: 0.12em; color: #10b981; }
.faxet-compile-sub { margin-top: 0.35rem; font-size: 11px; color: var(--text-muted); }
.faxet-compile-yield { margin-top: 0.6rem; font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; color: var(--text-main); }
.faxet-compile-unit { color: var(--text-muted); font-weight: 400; }
.faxet-compile-peak {
  margin-top: 0.5rem; font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 800;
  color: #f59e0b; text-shadow: 0 0 10px rgba(245,158,11,0.5); animation: faxet-peak-pulse 1s ease-in-out infinite;
}
@keyframes faxet-compile-in { 0% { transform: scale(0.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes faxet-burst { 0% { transform: scale(0.2) rotate(-25deg); opacity: 0; } 60% { transform: scale(1.25) rotate(6deg); } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes faxet-peak-pulse { 0%, 100% { opacity: 0.8; } 50% { opacity: 1; text-shadow: 0 0 16px rgba(245,158,11,0.8); } }
.faxet-reduced .faxet-compile-panel, .faxet-reduced .faxet-compile-burst, .faxet-reduced .faxet-compile-peak { animation: none; }

/* --- Boot-sequence ritual --- */
.faxet-boot {
  position: absolute; inset: -0.5rem; z-index: 40; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(16,185,129,0.08), rgba(5,6,8,0.97));
  border-radius: 1rem; transition: opacity 0.5s ease; opacity: 1;
}
.faxet-boot-done { opacity: 0; }
.faxet-boot-inner { position: relative; text-align: left; padding: 1rem 1.4rem; }
.faxet-boot-scan {
  position: absolute; left: 0; right: 0; height: 2px; top: 0;
  background: linear-gradient(90deg, transparent, rgba(16,185,129,0.9), transparent);
  box-shadow: 0 0 12px rgba(16,185,129,0.8); animation: faxet-scan 1.6s ease-in-out infinite;
}
.faxet-boot-title {
  font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; font-weight: 900; letter-spacing: 0.14em;
  color: #10b981; text-shadow: 0 0 12px rgba(16,185,129,0.6); margin-bottom: 0.5rem;
}
.faxet-boot-log { font-family: 'JetBrains Mono', monospace; font-size: 11px; line-height: 1.7; color: #6ee7b7; white-space: pre-wrap; margin: 0; }
@keyframes faxet-scan { 0% { top: 8%; } 50% { top: 90%; } 100% { top: 8%; } }

/* --- Reduced motion --- */
.faxet-reduced .faxet-cell-hot { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .faxet-cell-hot { animation: none; }
}
