/* ==========================================================================
   Graveyard: A Funeral for Dead Code
   Theme: Halloween, "Ghost in the Machine"
   Strictly self-contained CSS (No external CDN fonts or scripts)
   ========================================================================== */

:root {
  --bg-abyss: #07080a;
  --bg-mausoleum: #0f1117;
  --bg-stone-dark: #161821;
  --bg-stone-light: #232733;
  --border-stone: #2f3545;
  --border-highlight: #464f66;

  --text-ethereal: #f2efe9;
  --text-muted: #9ba3b8;
  --text-bone: #c8cbd5;

  --candle-flame: #ffaa33;
  --candle-glow: rgba(255, 170, 51, 0.25);
  --candle-amber: #e58e26;

  --spectral-teal: #38d9a9;
  --curse-crimson: #ff6b6b;
  --warning-amber: #fcc419;

  --font-gothic: 'Cinzel', 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  --font-terminal: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;

  --tombstone-radius: 80px 80px 12px 12px;
  --transition-speed: 0.2s;
}

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

html {
  font-family: var(--font-terminal);
  font-size: 16px;
  line-height: 1.6;
  background-color: var(--bg-abyss);
  color: var(--text-ethereal);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(229, 142, 38, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 20% 90%, rgba(56, 217, 169, 0.04) 0%, transparent 40%),
    linear-gradient(180deg, #090a0d 0%, #050607 100%);
  position: relative;
  overflow-x: hidden;
}

/* Background fog & mist */
.mist-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(20, 24, 34, 0.6) 0%, transparent 70%);
  z-index: 0;
}

.main-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem 1.5rem;
  flex: 1;
}

/* --------------------------------------------------------------------------
   Candle Vigil Header
   -------------------------------------------------------------------------- */
.vigil-header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border-stone);
  margin-bottom: 2rem;
  position: relative;
}

.candles-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2.5rem;
  margin-bottom: 1.25rem;
}

.candle {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.candle-wax {
  width: 18px;
  background: linear-gradient(180deg, #d3cbbd 0%, #8c8273 100%);
  border-radius: 3px 3px 1px 1px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.candle-tall .candle-wax { height: 48px; }
.candle-med .candle-wax { height: 36px; }
.candle-short .candle-wax { height: 26px; }

.candle-wick {
  width: 2px;
  height: 8px;
  background-color: #222;
}

.candle-flame {
  width: 12px;
  height: 20px;
  background: radial-gradient(ellipse at 50% 80%, #fff 0%, #ffcc00 35%, #ff6600 75%, transparent 100%);
  border-radius: 50% 50% 35% 35%;
  box-shadow:
    0 0 16px 4px var(--candle-glow),
    0 -4px 10px #ff9900;
  animation: flicker 1.8s infinite ease-in-out alternate;
  transform-origin: 50% 90%;
}

.candle:nth-child(2) .candle-flame { animation-duration: 1.4s; animation-delay: 0.2s; }
.candle:nth-child(3) .candle-flame { animation-duration: 2.1s; animation-delay: 0.5s; }
.candle:nth-child(4) .candle-flame { animation-duration: 1.6s; animation-delay: 0.1s; }
.candle:nth-child(5) .candle-flame { animation-duration: 1.9s; animation-delay: 0.4s; }

@keyframes flicker {
  0% { transform: scale(1) rotate(-1deg); opacity: 0.92; }
  25% { transform: scale(1.05, 0.95) rotate(1.5deg); opacity: 1; }
  50% { transform: scale(0.96, 1.04) rotate(-2deg); opacity: 0.88; }
  75% { transform: scale(1.03, 0.98) rotate(1deg); opacity: 0.98; }
  100% { transform: scale(0.98, 1.02) rotate(-0.5deg); opacity: 0.94; }
}

@media (prefers-reduced-motion: reduce) {
  .candle-flame {
    animation: none;
    transform: none;
    opacity: 0.95;
  }
}

.app-title {
  font-family: var(--font-gothic);
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-ethereal);
  text-shadow:
    0 0 20px rgba(255, 170, 51, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.9);
  margin-bottom: 0.5rem;
}

.app-subtitle {
  font-size: 1.05rem;
  color: var(--candle-amber);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.app-tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 680px;
  margin: 0 auto;
}

/* --------------------------------------------------------------------------
   Privacy & Mode Bar
   -------------------------------------------------------------------------- */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-mausoleum);
  border: 1px solid var(--border-stone);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.mode-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mode-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.mode-switch-group {
  display: inline-flex;
  background-color: var(--bg-stone-dark);
  border: 1px solid var(--border-stone);
  border-radius: 6px;
  padding: 3px;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-terminal);
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.mode-btn:hover {
  color: var(--text-ethereal);
}

.mode-btn.active {
  background-color: var(--bg-stone-light);
  color: var(--candle-flame);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-bone);
  background-color: rgba(22, 24, 33, 0.8);
  border: 1px solid var(--border-stone);
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
}

.privacy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--spectral-teal);
  box-shadow: 0 0 8px var(--spectral-teal);
}

/* --------------------------------------------------------------------------
   Local Ollama Instructions Banner
   -------------------------------------------------------------------------- */
.local-banner {
  background-color: rgba(30, 20, 15, 0.85);
  border: 1px solid var(--candle-amber);
  border-left: 4px solid var(--candle-amber);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-ethereal);
  display: none;
}

.local-banner.active {
  display: block;
}

.local-banner-title {
  font-weight: 700;
  color: var(--candle-flame);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.code-snippet {
  background-color: #0d0e12;
  border: 1px solid #332211;
  color: #ffcc66;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-terminal);
  font-size: 0.85rem;
}

/* --------------------------------------------------------------------------
   Data Input Panel (Collapsible or Tabbed)
   -------------------------------------------------------------------------- */
.input-panel {
  background-color: var(--bg-mausoleum);
  border: 1px solid var(--border-stone);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 2rem;
}

.input-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.input-panel-title {
  font-family: var(--font-gothic);
  font-size: 1.15rem;
  color: var(--text-ethereal);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.input-panel-content {
  margin-top: 1.25rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .input-panel-content {
    grid-template-columns: 1fr 1fr;
  }
}

.input-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.json-textarea {
  width: 100%;
  height: 110px;
  background-color: var(--bg-stone-dark);
  border: 1px solid var(--border-stone);
  border-radius: 6px;
  color: var(--text-ethereal);
  font-family: var(--font-terminal);
  font-size: 0.8rem;
  padding: 0.75rem;
  resize: vertical;
  line-height: 1.4;
}

.json-textarea:focus, .file-input:focus {
  outline: 2px solid var(--candle-amber);
  outline-offset: 1px;
}

.file-input {
  background-color: var(--bg-stone-dark);
  border: 1px dashed var(--border-stone);
  border-radius: 6px;
  padding: 0.75rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.action-btn {
  background-color: var(--bg-stone-light);
  border: 1px solid var(--border-highlight);
  color: var(--text-ethereal);
  font-family: var(--font-terminal);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-speed);
}

.action-btn:hover:not(:disabled) {
  background-color: #313747;
  border-color: var(--candle-amber);
  color: var(--candle-flame);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-btn-primary {
  background-color: var(--candle-amber);
  border-color: #ffaa33;
  color: #120e06;
}

.action-btn-primary:hover:not(:disabled) {
  background-color: #ffaa33;
  color: #000;
  box-shadow: 0 0 12px var(--candle-glow);
}

/* --------------------------------------------------------------------------
   Metrics & Failure Dashboard
   -------------------------------------------------------------------------- */
.metrics-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  background-color: var(--bg-mausoleum);
  border: 1px solid var(--border-stone);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  display: flex;
  flex-direction: column;
}

.metric-name {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.metric-val {
  font-family: var(--font-gothic);
  font-size: 1.35rem;
  color: var(--text-ethereal);
  font-weight: 700;
}

.metric-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  grid-column: 1 / -1;
  border-top: 1px solid var(--border-stone);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   Live Status Announcement
   -------------------------------------------------------------------------- */
.status-banner {
  background-color: rgba(22, 24, 33, 0.9);
  border: 1px solid var(--border-highlight);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-ethereal);
  display: none;
}

.status-banner.visible {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-banner.error {
  border-color: var(--curse-crimson);
  background-color: rgba(50, 15, 15, 0.8);
  color: #ffb3b3;
}

.status-banner.success {
  border-color: var(--spectral-teal);
  background-color: rgba(10, 40, 30, 0.8);
  color: #a7f3d0;
}

/* --------------------------------------------------------------------------
   Tombstone Cemetery Grid
   -------------------------------------------------------------------------- */
.cemetery-section {
  margin-top: 1rem;
}

.cemetery-title {
  font-family: var(--font-gothic);
  font-size: 1.5rem;
  letter-spacing: 0.08em;
  color: var(--text-ethereal);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cemetery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 2rem 1.5rem;
}

/* The CSS-only Arched Tombstone */
.tombstone {
  position: relative;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 60%),
    linear-gradient(180deg, #242938 0%, #151821 30%, #0e1017 100%);
  border: 2px solid #363c4f;
  border-radius: var(--tombstone-radius);
  padding: 2.25rem 1.5rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.8),
    inset 0 2px 4px rgba(255, 255, 255, 0.1),
    inset 0 -8px 20px rgba(0, 0, 0, 0.7);
  transition: transform var(--transition-speed), border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.tombstone:hover {
  transform: translateY(-4px);
  border-color: var(--candle-amber);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.9),
    0 0 20px rgba(255, 170, 51, 0.15),
    inset 0 2px 4px rgba(255, 255, 255, 0.15);
}

/* Tombstone Headstone Ornament / Cross or Monogram */
.tombstone-ornament {
  align-self: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-stone);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  color: var(--candle-amber);
  font-family: var(--font-gothic);
  font-size: 1.1rem;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
}

.tombstone-header {
  text-align: center;
  margin-bottom: 1rem;
}

.tombstone-name {
  font-family: var(--font-terminal);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-ethereal);
  word-break: break-all;
  line-height: 1.35;
  margin-bottom: 0.35rem;
}

.tombstone-dates {
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--candle-amber);
  text-transform: uppercase;
}

.tombstone-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  border-top: 1px dashed var(--border-stone);
  border-bottom: 1px dashed var(--border-stone);
  padding: 1rem 0;
  margin: 0.5rem 0 1.25rem 0;
}

.epitaph-box {
  font-style: italic;
  font-size: 0.92rem;
  color: var(--text-bone);
  line-height: 1.5;
  text-align: center;
  padding: 0 0.5rem;
}

.cause-box {
  background-color: rgba(10, 12, 16, 0.6);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.cause-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  display: flex;
  justify-content: space-between;
}

.commit-hash-pill {
  font-family: var(--font-terminal);
  color: var(--candle-amber);
  background-color: rgba(229, 142, 38, 0.1);
  padding: 0 0.35rem;
  border-radius: 3px;
}

.cause-desc {
  font-size: 0.85rem;
  color: var(--text-ethereal);
  line-height: 1.4;
}

.commit-real-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 0.3rem;
  font-family: var(--font-terminal);
}

/* Badges */
.badge-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
}

.badge-verified {
  background-color: rgba(56, 217, 169, 0.15);
  border: 1px solid rgba(56, 217, 169, 0.4);
  color: #38d9a9;
}

.badge-unverified {
  background-color: rgba(255, 107, 107, 0.15);
  border: 1px solid rgba(255, 107, 107, 0.4);
  color: #ff8787;
}

.badge-neutral {
  background-color: rgba(155, 163, 184, 0.15);
  border: 1px solid rgba(155, 163, 184, 0.3);
  color: var(--text-muted);
}

.badge-wronged {
  background-color: rgba(252, 196, 25, 0.2);
  border: 1px solid var(--warning-amber);
  color: #ffd43b;
}

/* Tombstone Footer Buttons */
.tombstone-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.btn-resurrect {
  flex: 1;
  background-color: var(--bg-stone-dark);
  border: 1px solid var(--border-stone);
  color: var(--candle-amber);
  font-family: var(--font-terminal);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.btn-resurrect:hover {
  background-color: var(--candle-amber);
  color: #111;
  border-color: #ffaa33;
}

.btn-mark-wrong {
  background-color: transparent;
  border: 1px solid var(--border-stone);
  color: var(--text-muted);
  font-family: var(--font-terminal);
  font-size: 0.75rem;
  padding: 0.45rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.btn-mark-wrong:hover {
  border-color: var(--curse-crimson);
  color: var(--curse-crimson);
}

.btn-mark-wrong.marked {
  border-color: var(--warning-amber);
  color: var(--warning-amber);
  background-color: rgba(252, 196, 25, 0.1);
}

/* --------------------------------------------------------------------------
   Resurrect Code Modal
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-dialog {
  background-color: var(--bg-stone-dark);
  border: 2px solid var(--border-highlight);
  border-radius: 10px;
  width: 100%;
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-stone);
  background-color: var(--bg-mausoleum);
}

.modal-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.modal-title {
  font-family: var(--font-gothic);
  font-size: 1.15rem;
  color: var(--text-ethereal);
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--candle-amber);
}

.modal-close-btn {
  background: transparent;
  border: 1px solid var(--border-stone);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-close-btn:hover {
  color: var(--text-ethereal);
  border-color: var(--curse-crimson);
}

.modal-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.code-container {
  background-color: #08090d;
  border: 1px solid var(--border-stone);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--font-terminal);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #d1d5db;
  white-space: pre;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-stone);
  background-color: var(--bg-mausoleum);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.vigil-footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-stone);
  margin-top: auto;
}

.footer-link {
  color: var(--candle-amber);
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

/* Focus styles for keyboard accessibility */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--candle-amber);
  outline-offset: 2px;
}
