/* -------------------------------------------------------------
 * AetherDict Stylesheet
 * Custom CSS Custom Properties for Theme Control & Responsive Layout
 * ------------------------------------------------------------- */

:root {
  /* Dark Void Theme Colors */
  --bg-primary: #0a0f1d;
  --bg-secondary: #0d1527;
  --bg-card: rgba(255, 255, 255, 0.03);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(0, 242, 254, 0.4);
  
  --text-primary: #f8fafc;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  
  /* Semantic Accent Colors with Matching Shadows */
  --color-center: #ffffff;
  --glow-center: rgba(255, 255, 255, 0.4);
  
  --color-syn: #00f2fe;
  --color-syn-rgb: 0, 242, 254;
  --color-syn-grad: linear-gradient(135deg, #00f2fe, #4facfe);
  
  --color-ant: #ff0844;
  --color-ant-rgb: 255, 8, 68;
  --color-ant-grad: linear-gradient(135deg, #ff0844, #ffb199);
  
  --color-ex: #d4a5ff;
  --color-ex-rgb: 212, 165, 255;
  --color-ex-grad: linear-gradient(135deg, #a18cd1, #fbc2eb);
  
  /* Typography */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Layout Consts */
  --header-height: 80px;
  --footer-height: 48px;
}

/* Reset & Core Page Layout */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  background-image: radial-gradient(circle at 50% 50%, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden; /* Prevent scrolling outside the web workspace */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* -------------------------------------------------------------
 * Header & Controls (Glassmorphism & Neon Shadows)
 * ------------------------------------------------------------- */
.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background: rgba(10, 15, 29, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-logo {
  font-size: 1.5rem;
  filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.4));
}

.brand-name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.gradient-text {
  background: var(--color-syn-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Search Form */
.search-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-grow: 0;
  flex-shrink: 1;
  width: 480px;
  max-width: 100%;
}

.search-input-wrapper {
  position: relative;
  flex-grow: 1;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

#search-input:focus {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--color-syn);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.15);
}

.clear-btn {
  position: absolute;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.clear-btn:hover {
  color: var(--text-primary);
}

.search-submit-btn {
  background: var(--color-syn-grad);
  color: #050a14;
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0, 242, 254, 0.25);
}

.search-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 242, 254, 0.4);
}

.search-submit-btn:active {
  transform: translateY(1px);
}

/* Offline/Online Indicator Status */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.5rem 0.85rem;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.3s;
}

.status-indicator.online .status-dot {
  background-color: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-indicator.offline .status-dot {
  background-color: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

/* -------------------------------------------------------------
 * Main Workspace & Coordinates Layer
 * ------------------------------------------------------------- */
.workspace-wrapper {
  position: relative;
  flex-grow: 1;
  height: calc(100vh - var(--header-height) - var(--footer-height));
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.dictionary-space {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
}

/* Space Guides (Dotted concentric circles in background) */
.space-guides {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-circle {
  position: absolute;
  border: 1px dashed rgba(255, 255, 255, 0.025);
  border-radius: 50%;
  pointer-events: none;
}

.ring-1 { width: 300px; height: 300px; }
.ring-2 { width: 550px; height: 550px; }
.ring-3 { width: 800px; height: 800px; }

/* Quadrant Text Labels */
.guide-quadrant {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  pointer-events: none;
}

.synonym-zone-label {
  top: 8%;
  left: 8%;
  color: rgba(0, 242, 254, 0.15);
  border-left: 1px solid rgba(0, 242, 254, 0.05);
  border-top: 1px solid rgba(0, 242, 254, 0.05);
  padding: 0.5rem;
}

.antonym-zone-label {
  top: 8%;
  right: 8%;
  color: rgba(255, 8, 68, 0.15);
  border-right: 1px solid rgba(255, 8, 68, 0.05);
  border-top: 1px solid rgba(255, 8, 68, 0.05);
  padding: 0.5rem;
}

.example-zone-label {
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(212, 165, 255, 0.15);
  border-bottom: 1px solid rgba(212, 165, 255, 0.05);
  padding: 0.25rem 1rem;
}

/* -------------------------------------------------------------
 * Dynamic Floating elements & Central Node
 * ------------------------------------------------------------- */
.center-word-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(10, 15, 29, 0.8) 40%, rgba(10, 15, 29, 0) 100%);
  padding: 2.5rem;
  border-radius: 50%;
}

.center-word {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -1.5px;
  color: var(--color-center);
  text-shadow: 0 0 25px var(--glow-center);
  line-height: 1.1;
  transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.center-phonetic {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-top: 0.4rem;
  opacity: 0.8;
}

.pronounce-btn {
  margin-top: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.pronounce-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  transform: scale(1.1);
}

/* Floating Words Layer */
.words-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none; /* Let clicks pass to children, handled individually */
}

/* Word Node Templates styling */
.word-node {
  position: absolute;
  pointer-events: auto; /* Re-enable clicks */
  cursor: pointer;
  white-space: nowrap;
  padding: 0.4rem 0.85rem;
  border-radius: 12px;
  font-weight: 500;
  user-select: none;
  will-change: transform, left, top;
  transition: opacity 0.5s ease, scale 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Gentle Drift Animation applied dynamically with random offsets */
.drift-anim {
  animation: float-drift var(--drift-duration, 5s) ease-in-out var(--drift-delay, 0s) infinite alternate;
}

@keyframes float-drift {
  0% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(calc(var(--drift-amplitude, 8px) * -1)) rotate(calc(var(--drift-angle, 1.5deg) * -1));
  }
  100% {
    transform: translateY(var(--drift-amplitude, 8px)) rotate(var(--drift-angle, 1.5deg));
  }
}

/* Synonyms */
.word-node.synonym {
  color: var(--color-syn);
  background: rgba(var(--color-syn-rgb), 0.05);
  border: 1px solid rgba(var(--color-syn-rgb), 0.15);
}

.word-node.synonym:hover {
  background: var(--color-syn-grad);
  color: #050a14;
  border-color: transparent;
  box-shadow: 0 0 20px rgba(0, 242, 254, 0.5);
  scale: 1.15;
  z-index: 50;
}

/* Antonyms */
.word-node.antonym {
  color: var(--color-ant);
  background: rgba(var(--color-ant-rgb), 0.05);
  border: 1px solid rgba(var(--color-ant-rgb), 0.15);
}

.word-node.antonym:hover {
  background: var(--color-ant-grad);
  color: #050a14;
  border-color: transparent;
  box-shadow: 0 0 20px rgba(255, 8, 68, 0.5);
  scale: 1.15;
  z-index: 50;
}

/* Examples (Capsules that expand on hover/tap) */
.word-node.example-capsule {
  color: var(--color-ex);
  background: rgba(var(--color-ex-rgb), 0.05);
  border: 1px solid rgba(var(--color-ex-rgb), 0.15);
  border-radius: 9999px;
  max-width: 140px; /* Highly collapsed initially */
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0.5rem 1rem;
  transition: max-width 0.4s cubic-bezier(0.25, 1, 0.5, 1), 
              background 0.3s, 
              border-color 0.3s, 
              color 0.3s,
              scale 0.3s;
}

.word-node.example-capsule:hover {
  max-width: 480px; /* Expand dynamically */
  background: rgba(var(--color-ex-rgb), 0.12);
  color: #ffffff;
  border-color: rgba(var(--color-ex-rgb), 0.4);
  box-shadow: 0 4px 15px rgba(212, 165, 255, 0.2);
  z-index: 60;
  scale: 1.05;
}

/* -------------------------------------------------------------
 * Landing, Loading, Offline Overlays
 * ------------------------------------------------------------- */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 30;
  padding: 2rem;
  text-align: center;
}

.overlay-screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* Landing state specifics */
.intro-content h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 0.75rem;
  background: var(--color-syn-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.intro-content p {
  color: var(--text-dim);
  font-size: 1.1rem;
  max-width: 500px;
  margin: 0 auto 2.5rem auto;
  line-height: 1.5;
}

.demo-suggestions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.suggestions-title {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.suggestion-chips {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  max-width: 600px;
}

.suggestion-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-dim);
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.suggestion-chip:hover {
  background: rgba(0, 242, 254, 0.08);
  color: var(--color-syn);
  border-color: var(--color-syn);
  transform: translateY(-1px);
}

/* Spinner for loading state */
.spinner {
  width: 50px;
  height: 50px;
  position: relative;
  margin: 0 auto 1.5rem auto;
}

.double-bounce1, .double-bounce2 {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--color-syn);
  opacity: 0.6;
  position: absolute;
  top: 0;
  left: 0;
  animation: sk-bounce 2.0s infinite ease-in-out;
}

.double-bounce2 {
  animation-delay: -1.0s;
  background-color: var(--color-ex);
}

@keyframes sk-bounce {
  0%, 100% { 
    transform: scale(0.0);
  } 50% { 
    transform: scale(1.0);
  }
}

#loading-screen p {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

/* Offline state styling */
.offline-content .offline-icon,
.error-content .error-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

.offline-content h2,
.error-content h2 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.offline-content p,
.error-content p {
  color: var(--text-dim);
  margin-bottom: 2rem;
  max-width: 420px;
}

/* -------------------------------------------------------------
 * Footer & Instructions
 * ------------------------------------------------------------- */
.app-footer {
  height: auto;
  min-height: var(--footer-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  gap: 0.25rem;
  border-top: 1px solid var(--border-color);
  background: rgba(10, 15, 29, 0.8);
  z-index: 100;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.attribution-badge {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.35);
  font-family: var(--font-mono);
  text-align: center;
}


/* -------------------------------------------------------------
 * Responsive Adaptations
 * ------------------------------------------------------------- */
@media (max-width: 768px) {
  body {
    overflow: auto; /* Let overflow occur if necessary on tiny devices */
  }
  
  .app-header {
    flex-direction: column;
    height: auto;
    padding: 1rem;
    gap: 1rem;
  }
  
  .search-form {
    width: 100%;
  }
  
  .workspace-wrapper {
    height: auto;
    min-height: calc(100vh - 180px - var(--footer-height));
  }
  
  .space-guides {
    display: none; /* Hide rings on mobile to reduce noise */
  }
  
  .center-word-container {
    padding: 1.5rem;
  }
  
  .center-word {
    font-size: 2.25rem;
  }

  /* Make expanding easier on mobile */
  .word-node.example-capsule:active,
  .word-node.example-capsule:focus {
    max-width: 90vw;
  }
}
