/* ============================================================
   Binary Search Visualizer — style.css
   ============================================================ */

:root {
  --bg:          #080c14;
  --surface:     #0d1220;
  --surface-2:   #111827;
  --border:      #1e2d45;
  --border-hi:   #1e3a5f;

  --text:        #e2e8f5;
  --text-muted:  #5a6a85;
  --text-dim:    #8899bb;

  --accent:      #00c3ff;

  --left-clr:    #38bdf8;
  --mid-clr:     #f97316;
  --right-clr:   #a78bfa;
  --elim-clr:    #ef4444;
  --found-clr:   #22c55e;
  --default-clr: #1e3a5f;

  --font-mono:   'JetBrains Mono', monospace;
  --font-disp:   'Syne', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Background ── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(0,195,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,195,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}
.bg-glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 50% -10%, rgba(0,195,255,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 80% 90%,  rgba(167,139,250,0.05) 0%, transparent 50%);
}

/* ── Wrapper ── */
.app-wrapper {
  position: relative; z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ── Header ── */
.header { text-align: center; margin-bottom: 52px; }
.header-badge {
  display: inline-block;
  font-size: 11px; letter-spacing: 3px; color: var(--accent);
  border: 1px solid rgba(0,195,255,0.3);
  padding: 5px 14px; border-radius: 100px;
  background: rgba(0,195,255,0.04);
  margin-bottom: 20px;
}
.title {
  font-family: var(--font-disp);
  font-size: clamp(48px, 8vw, 88px);
  font-weight: 800; line-height: 0.95; letter-spacing: -2px;
  margin-bottom: 16px;
}
.title-accent { color: var(--accent); text-shadow: 0 0 40px rgba(0,195,255,0.4); }
.subtitle { font-size: 13px; color: var(--text-muted); letter-spacing: 0.5px; }

/* ── Step Cards ── */
.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 28px;
  margin-bottom: 16px;
}
.step-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
}
.step-badge {
  font-family: var(--font-disp);
  font-size: 11px; font-weight: 800; letter-spacing: 2px;
  color: var(--accent);
  background: rgba(0,195,255,0.08);
  border: 1px solid rgba(0,195,255,0.2);
  padding: 3px 10px; border-radius: 6px;
}
.step-badge--2 {
  color: var(--right-clr);
  background: rgba(167,139,250,0.08);
  border-color: rgba(167,139,250,0.2);
}
.step-title {
  font-family: var(--font-disp);
  font-size: 18px; font-weight: 700; color: var(--text);
}

/* ── Control label ── */
.control-label {
  display: block;
  font-size: 10px; letter-spacing: 2px;
  color: var(--text-muted); margin-bottom: 8px;
}
.control-group { display: flex; flex-direction: column; }

/* ── Array input row ── */
.array-input-row {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.input-array {
  flex: 1; min-width: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 11px 16px;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.input-array::placeholder { color: var(--text-muted); }
.input-array:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,195,255,0.08);
}
.input-array.error { border-color: var(--elim-clr); box-shadow: 0 0 0 3px rgba(239,68,68,0.1); }

.hint {
  font-size: 11px; color: var(--text-muted); letter-spacing: 0.3px;
  transition: color 0.2s;
}
.hint.error { color: var(--elim-clr); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  letter-spacing: 0.4px; padding: 10px 20px;
  border-radius: 9px; border: none; cursor: pointer;
  transition: transform 0.12s, box-shadow 0.18s, opacity 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn-icon { font-size: 14px; }

.btn-build {
  background: rgba(0,195,255,0.12);
  color: var(--accent);
  border: 1px solid rgba(0,195,255,0.3);
}
.btn-build:hover:not(:disabled) {
  background: rgba(0,195,255,0.2);
  box-shadow: 0 0 20px rgba(0,195,255,0.15);
}

.btn-random {
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-random:hover:not(:disabled) { border-color: var(--text-dim); color: var(--text); }

.btn-search {
  background: linear-gradient(135deg, #0080cc, #00c3ff);
  color: #000; font-weight: 700;
  box-shadow: 0 4px 20px rgba(0,195,255,0.25);
}
.btn-search:hover:not(:disabled) { box-shadow: 0 6px 30px rgba(0,195,255,0.45); }

.btn-reset {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-reset:hover:not(:disabled) { border-color: var(--elim-clr); color: var(--elim-clr); }

/* ── Search Row ── */
.search-row {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
}
.input-target {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono); font-size: 15px; font-weight: 600;
  padding: 10px 14px; border-radius: 9px;
  width: 140px; outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  -moz-appearance: textfield;
}
.input-target::-webkit-outer-spin-button,
.input-target::-webkit-inner-spin-button { -webkit-appearance: none; }
.input-target::placeholder { color: var(--text-muted); font-size: 13px; }
.input-target:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,195,255,0.08);
}
.input-target:disabled { opacity: 0.4; }

/* ── Speed ── */
.speed-group { display: flex; flex-direction: column; }
.speed-track { display: flex; align-items: center; gap: 10px; }
.speed-label { font-size: 10px; letter-spacing: 2px; color: var(--text-muted); }
.slider {
  -webkit-appearance: none; appearance: none;
  width: 120px; height: 4px;
  background: var(--border); border-radius: 100px; outline: none; cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(0,195,255,0.5);
  transition: transform 0.15s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.25); }

/* ── Chips ── */
.chips-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.chips-row {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.chip:hover {
  background: rgba(0,195,255,0.1);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,195,255,0.15);
}
.chip.chip-active {
  background: rgba(0,195,255,0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Status Bar ── */
.status-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 18px;
  font-size: 13px; color: var(--text-dim);
  margin-bottom: 16px;
  transition: border-color 0.3s;
}
.status-bar.searching { border-color: var(--mid-clr); }
.status-bar.found     { border-color: var(--found-clr); }
.status-bar.not-found { border-color: var(--elim-clr); }
.status-bar.sorting   { border-color: var(--right-clr); }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted); flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.status-bar.searching .status-dot {
  background: var(--mid-clr); box-shadow: 0 0 8px var(--mid-clr);
  animation: blink 0.9s ease-in-out infinite;
}
.status-bar.sorting .status-dot {
  background: var(--right-clr); box-shadow: 0 0 8px var(--right-clr);
  animation: blink 0.7s ease-in-out infinite;
}
.status-bar.found .status-dot {
  background: var(--found-clr); box-shadow: 0 0 10px var(--found-clr);
}
.status-bar.not-found .status-dot {
  background: var(--elim-clr); box-shadow: 0 0 8px var(--elim-clr);
}
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0.25; } }

.step-counter {
  margin-left: auto; font-size: 11px; letter-spacing: 2px;
  color: var(--accent); font-weight: 600;
}

/* ── Legend ── */
.pointer-legend {
  display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 16px;
}
.legend-item {
  display: flex; align-items: center; gap: 7px;
  font-size: 10px; letter-spacing: 2px; color: var(--text-muted);
}
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.ld-left  { background: var(--left-clr);  box-shadow: 0 0 6px var(--left-clr);  }
.ld-mid   { background: var(--mid-clr);   box-shadow: 0 0 6px var(--mid-clr);   }
.ld-right { background: var(--right-clr); box-shadow: 0 0 6px var(--right-clr); }
.ld-elim  { background: var(--elim-clr);  box-shadow: 0 0 6px var(--elim-clr);  }
.ld-found { background: var(--found-clr); box-shadow: 0 0 6px var(--found-clr); }

/* ── Visualizer ── */
.visualizer-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px 20px;
  margin-bottom: 28px;
  overflow-x: auto;
  min-height: 170px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--text-muted);
}
.empty-icon { font-family: var(--font-disp); font-size: 36px; opacity: 0.3; }
.empty-text { font-size: 13px; letter-spacing: 1px; }

.array-container {
  display: flex; gap: 8px; justify-content: center;
  flex-wrap: nowrap; margin-bottom: 10px;
  width: 100%;
}

/* Box */
.array-box {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  flex-shrink: 0;
}
.box-index {
  font-size: 9px; letter-spacing: 1px; color: var(--text-muted);
}
.box-value {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  background: var(--default-clr);
  border: 1.5px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  font-size: 14px; font-weight: 600; color: var(--text);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s, transform 0.25s, color 0.3s;
}
.box-value:hover { transform: translateY(-3px); }

/* Sorting swap highlight */
.array-box.state-swap .box-value {
  background: rgba(167,139,250,0.2);
  border-color: var(--right-clr);
  box-shadow: 0 0 16px rgba(167,139,250,0.4);
  color: var(--right-clr);
  transform: translateY(-5px) scale(1.06);
}
.array-box.state-sorted .box-value {
  border-color: rgba(34,197,94,0.35);
  background: rgba(34,197,94,0.06);
}

/* Search states */
.array-box.state-left .box-value {
  border-color: var(--left-clr);
  box-shadow: 0 0 14px rgba(56,189,248,0.3);
}
.array-box.state-right .box-value {
  border-color: var(--right-clr);
  box-shadow: 0 0 14px rgba(167,139,250,0.3);
}
.array-box.state-mid .box-value {
  background: rgba(249,115,22,0.18);
  border-color: var(--mid-clr);
  box-shadow: 0 0 20px rgba(249,115,22,0.45);
  color: var(--mid-clr);
  transform: translateY(-7px) scale(1.08);
}
.array-box.state-elim .box-value {
  background: rgba(239,68,68,0.07);
  border-color: rgba(239,68,68,0.2);
  color: rgba(239,68,68,0.35);
  opacity: 0.42;
}
.array-box.state-found .box-value {
  background: rgba(34,197,94,0.2);
  border-color: var(--found-clr);
  box-shadow: 0 0 28px rgba(34,197,94,0.55);
  color: var(--found-clr);
  transform: translateY(-10px) scale(1.12);
  animation: foundBounce 0.55s ease;
}
@keyframes foundBounce {
  0%   { transform: translateY(-10px) scale(1.12); }
  30%  { transform: translateY(-22px) scale(1.18); }
  65%  { transform: translateY(-6px)  scale(1.09); }
  100% { transform: translateY(-10px) scale(1.12); }
}

/* Pointer tags */
.pointer-row {
  display: flex; gap: 8px; justify-content: center; width: 100%;
}
.pointer-tag {
  width: 56px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; letter-spacing: 1.5px;
  border-radius: 4px; flex-shrink: 0;
  opacity: 0; transition: opacity 0.25s;
}
.pointer-tag.show { opacity: 1; }
.pointer-tag.tag-left  { background: rgba(56,189,248,0.15);  color: var(--left-clr);  }
.pointer-tag.tag-mid   { background: rgba(249,115,22,0.15);  color: var(--mid-clr);   }
.pointer-tag.tag-right { background: rgba(167,139,250,0.15); color: var(--right-clr); }

/* ── Info Grid ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 24px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.info-card:hover {
  border-color: var(--border-hi);
  box-shadow: 0 0 28px rgba(0,195,255,0.05);
}
.info-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.info-icon { font-size: 18px; }
.info-card-title { font-size: 10px; letter-spacing: 2.5px; color: var(--text-muted); }
.complexity-display { margin-bottom: 10px; }
.complexity-big {
  font-family: var(--font-disp); font-size: 42px; font-weight: 800;
  color: var(--accent); text-shadow: 0 0 40px rgba(0,195,255,0.35);
}
.info-text { font-size: 12px; line-height: 1.7; color: var(--text-muted); }
.how-list { list-style: none; display: flex; flex-direction: column; gap: 7px; counter-reset: how; }
.how-list li {
  counter-increment: how;
  display: flex; align-items: baseline; gap: 10px;
  font-size: 12px; color: var(--text-muted); line-height: 1.5;
}
.how-list li::before {
  content: counter(how);
  font-size: 10px; font-weight: 700; color: var(--accent);
  background: rgba(0,195,255,0.08); border: 1px solid rgba(0,195,255,0.2);
  min-width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.how-list strong { color: var(--text-dim); }
.how-list code {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--accent); background: rgba(0,195,255,0.07);
  padding: 1px 5px; border-radius: 4px;
}
.complexity-table { width: 100%; border-collapse: collapse; }
.complexity-table td {
  padding: 9px 0; font-size: 13px; color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.complexity-table tr:last-child td { border-bottom: none; }
.complexity-table td:last-child {
  text-align: right; font-weight: 700;
  font-family: var(--font-disp); font-size: 15px;
}
.tc-green  { color: var(--found-clr) !important; }
.tc-orange { color: var(--mid-clr)   !important; }
.tc-red    { color: var(--elim-clr)  !important; }
.tc-blue   { color: var(--left-clr)  !important; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .app-wrapper { padding: 28px 14px 60px; }
  .title { font-size: 48px; }
  .search-row { flex-direction: column; align-items: stretch; }
  .btn { justify-content: center; width: 100%; }
  .input-target { width: 100%; }
  .box-value { width: 42px; height: 42px; font-size: 12px; }
  .pointer-tag { width: 42px; }
  .array-container, .pointer-row { gap: 5px; }
}
@media (max-width: 420px) {
  .box-value { width: 34px; height: 34px; font-size: 11px; border-radius: 7px; }
  .pointer-tag { width: 34px; font-size: 8px; }
  .array-container, .pointer-row { gap: 3px; }
}
