/* ============================================================
   oriqenLabs alpha 0.1.1.3.4.7 – Style Sheet
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0f;
  --bg-light: #12121a;
  --cyan: #00ffd5;
  --orange: #ff6b35;
  --text: #c0c8d8;
  --text-dim: #5a6070;
  --text-bright: #e8ecf4;
  --mono: 'Courier New', 'Consolas', monospace;
  --sans: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --glow-cyan: 0 0 8px rgba(0, 255, 213, 0.4);
  --glow-orange: 0 0 8px rgba(255, 107, 53, 0.4);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* --- CRT Scanline Overlay --- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
}

/* --- Glitch Overlay --- */
#glitch-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.05s;
  mix-blend-mode: screen;
}

#glitch-overlay.active {
  opacity: 1;
}

/* --- Layout --- */
#app {
  display: grid;
  grid-template-rows: 48px 1fr 140px;
  grid-template-columns: 1fr 72px;
  grid-template-areas:
    "header header"
    "habitat sidebar"
    "console sidebar";
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* --- Header --- */
#header {
  grid-area: header;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  background: linear-gradient(180deg, rgba(10,10,15,0.95), rgba(10,10,15,0.7));
  border-bottom: 1px solid rgba(0, 255, 213, 0.1);
  z-index: 100;
}

#header-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

#brand {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}

#brand span {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 1px;
}

#meta-info {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

#header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

#rec-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--orange);
  letter-spacing: 1px;
}

#rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: var(--glow-orange);
  animation: rec-pulse 1.5s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

#audio-toggle {
  background: none;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}

#audio-toggle:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

#audio-toggle.active {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: var(--glow-cyan);
}

/* --- Habitat (main canvas area) --- */
#habitat {
  grid-area: habitat;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

#habitat-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* --- Level / XP indicator overlay --- */
#level-display {
  position: absolute;
  bottom: 12px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  z-index: 10;
}

#level-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

#xp-bar-outer {
  width: 120px;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

#xp-bar-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--orange));
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* --- State indicator overlay --- */
#state-display {
  position: absolute;
  top: 12px;
  left: 16px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  pointer-events: none;
  z-index: 10;
}

/* --- Sidebar --- */
#sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  background: linear-gradient(90deg, rgba(0,255,213,0.02), transparent);
  border-left: 1px solid rgba(0, 255, 213, 0.08);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
}

#sidebar::-webkit-scrollbar {
  width: 0;
}

.item-slot {
  position: relative;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  cursor: grab;
  transition: all 0.2s;
  user-select: none;
  flex-shrink: 0;
}

.item-slot:hover {
  border-color: rgba(0, 255, 213, 0.3);
  background: rgba(0, 255, 213, 0.04);
  box-shadow: var(--glow-cyan);
}

.item-slot:active {
  cursor: grabbing;
}

.item-slot .emoji {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 0 4px rgba(0, 255, 213, 0.2));
  transition: transform 0.15s;
}

.item-slot:hover .emoji {
  transform: scale(1.15);
}

.item-slot.on-cooldown {
  opacity: 0.35;
  pointer-events: none;
}

.item-slot .cooldown-ring {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  border: 2px solid transparent;
  border-top-color: var(--orange);
  animation: cooldown-spin 3s linear forwards;
}

@keyframes cooldown-spin {
  to { transform: rotate(360deg); }
}

/* Item tooltip */
.item-slot::after {
  content: attr(data-tooltip);
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(10, 10, 15, 0.95);
  border: 1px solid rgba(0, 255, 213, 0.2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
}

.item-slot:hover::after {
  opacity: 1;
}

/* --- Drag ghost --- */
.drag-ghost {
  position: fixed;
  font-size: 28px;
  pointer-events: none;
  z-index: 10000;
  filter: drop-shadow(0 0 10px rgba(0, 255, 213, 0.5));
  transform: translate(-50%, -50%);
}

/* --- Console / Log --- */
#console {
  grid-area: console;
  background: rgba(5, 5, 10, 0.9);
  border-top: 1px solid rgba(0, 255, 213, 0.08);
  padding: 8px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  z-index: 100;
}

#console::-webkit-scrollbar {
  width: 4px;
}

#console::-webkit-scrollbar-track {
  background: transparent;
}

#console::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 213, 0.15);
  border-radius: 2px;
}

.log-entry {
  color: var(--text-dim);
  opacity: 0;
  animation: log-fade-in 0.3s ease forwards;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-entry .cycle {
  color: var(--text-dim);
}

.log-entry .key {
  color: var(--cyan);
}

.log-entry .value {
  color: var(--orange);
}

.log-entry .info {
  color: var(--text);
}

@keyframes log-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Placed items in habitat --- */
.habitat-item {
  position: absolute;
  font-size: 20px;
  pointer-events: none;
  z-index: 5;
  animation: item-appear 0.4s ease;
  transition: opacity 1s ease;
}

.habitat-item.fading {
  opacity: 0;
}

@keyframes item-appear {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  60% { transform: scale(1.2) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  #app {
    grid-template-rows: 44px 1fr 60px 100px;
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "habitat"
      "sidebar"
      "console";
  }

  #sidebar {
    flex-direction: row;
    border-left: none;
    border-top: 1px solid rgba(0, 255, 213, 0.08);
    padding: 4px 8px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .item-slot {
    width: 44px;
    height: 44px;
  }

  .item-slot::after {
    right: auto;
    bottom: calc(100% + 8px);
    top: auto;
    left: 50%;
    transform: translateX(-50%);
  }

  #console {
    padding: 6px 12px;
    font-size: 10px;
  }
}

/* --- Utility / Animations --- */
@keyframes glow-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Evolution flash overlay */
#evolution-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  background: radial-gradient(circle at center, rgba(0,255,213,0.3), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

#evolution-flash.active {
  opacity: 1;
  animation: evo-flash 1.5s ease-out forwards;
}

@keyframes evo-flash {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}
