/* ─────────────────────────────────────────────
   TOKENS
───────────────────────────────────────────── */
:root {
  --bg:         #0c0d10;
  --surface:    #13141a;
  --surface2:   #1a1c25;
  --border:     rgba(255,255,255,0.07);
  --border2:    rgba(255,255,255,0.13);

  --gold:       #d4a843;
  --gold-dim:   rgba(212,168,67,0.15);
  --gold-glow:  rgba(212,168,67,0.35);

  --text:       #e8e6df;
  --text-muted: #6b6a66;
  --text-dim:   #9b9892;

  --green:      #4caf82;
  --green-dim:  rgba(76,175,130,0.15);
  --red:        #e05c5c;
  --red-dim:    rgba(224,92,92,0.12);
  --blue:       #5b9bd5;
  --blue-dim:   rgba(91,155,213,0.12);

  --radius:     6px;
  --mono:       'DM Mono', monospace;
  --serif:      'Cormorant Garamond', serif;
  --sans:       'DM Sans', sans-serif;
}

/* ─────────────────────────────────────────────
   RESET & BASE
───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* animated grid background */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* ─────────────────────────────────────────────
   HEADER
───────────────────────────────────────────── */
.site-header {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  padding: 32px 48px 28px;
  background: linear-gradient(180deg, rgba(12,13,16,0.95) 0%, transparent 100%);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.logo-symbol {
  font-family: var(--serif);
  font-size: 32px;
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 0 24px var(--gold-glow);
}

.logo-text {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text);
}

.header-sub {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding-left: 44px;
  font-family: var(--mono);
}

/* ─────────────────────────────────────────────
   MAIN LAYOUT
───────────────────────────────────────────── */
.main-content {
  position: relative;
  z-index: 10;
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 48px 80px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* ─────────────────────────────────────────────
   PANELS
───────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 40px;
  position: relative;
  overflow: hidden;
  animation: panelIn 0.5s ease both;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 28px;
  opacity: 0.85;
}

/* ─────────────────────────────────────────────
   SETUP CONTROLS
───────────────────────────────────────────── */
.setup-controls {
  display: flex;
  gap: 40px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ctrl-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--mono);
}

.size-buttons {
  display: flex;
  gap: 6px;
}

.size-btn, .mode-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.size-btn:hover, .mode-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.size-btn.active, .mode-btn.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold);
}

/* ─────────────────────────────────────────────
   MATRIX INPUT
───────────────────────────────────────────── */
.matrix-wrapper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 36px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.matrix-bracket {
  width: 10px;
  height: auto;
  flex-shrink: 0;
  align-self: stretch;
  border-color: var(--gold);
  border-style: solid;
  opacity: 0.6;
  min-height: 60px;
}

.left-bracket {
  border-width: 2px 0 2px 2px;
  border-radius: 4px 0 0 4px;
  margin-right: 6px;
}

.right-bracket {
  border-width: 2px 2px 2px 0;
  border-radius: 0 4px 4px 0;
  margin-left: 6px;
}

.augmented-line {
  width: 1px;
  align-self: stretch;
  background: var(--gold);
  opacity: 0.4;
  margin: 0 10px;
  min-height: 60px;
}

.matrix-input-grid {
  display: grid;
  gap: 8px;
}

.rhs-input-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.matrix-cell, .rhs-cell {
  width: 72px;
  height: 44px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.matrix-cell:focus, .rhs-cell:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.matrix-cell:hover, .rhs-cell:hover {
  border-color: var(--border2);
}

/* ─────────────────────────────────────────────
   BUTTONS
───────────────────────────────────────────── */
.setup-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gold);
  border: none;
  color: #0c0d10;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  padding: 12px 28px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.05em;
}

.btn-primary:hover {
  background: #e0b84f;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--gold-glow);
}

.btn-primary:active { transform: translateY(0); }

.btn-icon {
  font-size: 16px;
  transition: transform 0.2s;
}

.btn-primary:hover .btn-icon { transform: translateX(3px); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  padding: 12px 22px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-ghost:hover {
  border-color: var(--border2);
  color: var(--text-dim);
}

/* ─────────────────────────────────────────────
   STEPS
───────────────────────────────────────────── */
.steps-container {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.step-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 32px;
  opacity: 0;
  transform: translateY(20px);
  animation: stepReveal 0.4s ease forwards;
  position: relative;
}

.step-card::after {
  content: '';
  position: absolute;
  left: 0; top: 20px; bottom: 20px;
  width: 2px;
  border-radius: 0 2px 2px 0;
}

.step-card.type-initial::after { background: var(--blue); }
.step-card.type-pivot::after   { background: var(--gold); }
.step-card.type-eliminate::after { background: var(--red); }
.step-card.type-echelon::after { background: var(--green); }
.step-card.type-back::after    { background: var(--gold); }

@keyframes stepReveal {
  to { opacity: 1; transform: translateY(0); }
}

.step-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 16px;
}

.step-num {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  white-space: nowrap;
}

.step-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

.step-op {
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  margin-left: auto;
  white-space: nowrap;
}

.op-pivot   { background: var(--gold-dim);  color: var(--gold);  border: 1px solid rgba(212,168,67,0.25); }
.op-elim    { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(224,92,92,0.25); }
.op-echelon { background: var(--green-dim); color: var(--green); border: 1px solid rgba(76,175,130,0.25); }
.op-back    { background: var(--blue-dim);  color: var(--blue);  border: 1px solid rgba(91,155,213,0.25); }

.step-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 20px;
  font-family: var(--mono);
  line-height: 1.7;
}

.step-desc .highlight {
  color: var(--gold);
}

.step-desc .op-text {
  color: var(--red);
}

/* ─────────────────────────────────────────────
   AUGMENTED MATRIX DISPLAY
───────────────────────────────────────────── */
.aug-matrix-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
}

.aug-matrix-wrap .matrix-bracket {
  pointer-events: none;
}

.matrix-display-grid {
  display: grid;
  gap: 4px;
}

.rhs-display-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.aug-sep {
  width: 1px;
  align-self: stretch;
  background: rgba(212,168,67,0.35);
  margin: 0 10px;
  min-height: 40px;
}

.cell {
  width: 68px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 13px;
  border-radius: 5px;
  border: 1px solid transparent;
  transition: all 0.35s ease;
  background: rgba(255,255,255,0.02);
  color: var(--text-dim);
  position: relative;
}

.cell.pivot-row {
  color: var(--gold);
  background: var(--gold-dim);
  border-color: rgba(212,168,67,0.2);
}

.cell.modified {
  color: var(--red);
  background: var(--red-dim);
  border-color: rgba(224,92,92,0.2);
  animation: cellPop 0.5s ease;
}

.cell.pivot-element {
  color: #fff;
  background: rgba(212,168,67,0.3);
  border-color: var(--gold);
  box-shadow: 0 0 12px var(--gold-glow);
}

.cell.zero {
  color: var(--text-muted);
  opacity: 0.5;
}

.cell.rhs {
  color: var(--blue);
}

.cell.rhs.pivot-row {
  color: var(--gold);
  background: var(--gold-dim);
}

.cell.rhs.modified {
  color: var(--red);
  background: var(--red-dim);
}

@keyframes cellPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* ─────────────────────────────────────────────
   SOLUTION
───────────────────────────────────────────── */
.solution-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.solution-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.solution-var {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: panelIn 0.5s ease both;
  position: relative;
  overflow: hidden;
}

.solution-var::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.var-name {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--text-muted);
  font-style: italic;
}

.var-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--gold);
  text-shadow: 0 0 20px var(--gold-glow);
}

.var-fraction {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.solution-note {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  padding: 12px 16px;
  background: var(--surface2);
  border-radius: var(--radius);
  border-left: 2px solid var(--gold);
}

.solution-error {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--red);
  padding: 16px 20px;
  background: var(--red-dim);
  border-radius: var(--radius);
  border: 1px solid rgba(224,92,92,0.25);
}

/* ─────────────────────────────────────────────
   NAVIGATION CONTROLS
───────────────────────────────────────────── */
.step-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.nav-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-btn.active-play {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold);
}

.step-counter {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.progress-bar {
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 28px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #e0b84f);
  border-radius: 2px;
  transition: width 0.4s ease;
  box-shadow: 0 0 8px var(--gold-glow);
}

/* ─────────────────────────────────────────────
   UTILITIES
───────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─────────────────────────────────────────────
   FOOTER
───────────────────────────────────────────── */
.site-footer {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */
@media (max-width: 640px) {
  .site-header { padding: 24px 20px; }
  .main-content { padding: 28px 16px 60px; }
  .panel { padding: 24px 20px; }
  .setup-controls { gap: 24px; }
  .step-card { padding: 20px 18px; }
}
