/* ============================================
   Read the Docs Theme Customization
   Modern Dark/Light Mode & Multi-language Support
   ============================================ */

:root {
  /* Light mode colors - Warm neutral tones */
  --bg-primary: #faf9f4;
  --bg-secondary: #f5f3ed;
  --bg-tertiary: #f0eee9;
  --text-primary: #2c3e50;
  --text-secondary: #555555;
  --text-tertiary: #999999;
  --border-color: #e8e4db;
  --accent-color: #0066cc;
  --accent-hover: #0052a3;
  --link-color: #0066cc;
  --code-bg: #f5f3ed;
  --code-text: #d63384;
  --sidebar-bg: #f5f3ed;
  --sidebar-text: #2c3e50;
  --sidebar-border: #e8e4db;
  --nav-bg: #faf9f4;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3a3a3a;
  --text-primary: #e8e8e8;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  --border-color: #404040;
  --accent-color: #4a9eff;
  --accent-hover: #6ab0ff;
  --link-color: #4a9eff;
  --code-bg: #2d2d2d;
  --code-text: #ff79c6;
  --sidebar-bg: #1a1a1a;
  --sidebar-text: #e8e8e8;
  --sidebar-border: #404040;
  --nav-bg: #242424;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Global Styles
   ============================================ */

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ============================================
   Controls Container (Fixed at top-right)
   ============================================ */

.controls-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.75rem;
  z-index: 1000;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.9);
  padding: 0.75rem;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  border: 1px solid var(--border-color);
}

html[data-theme="dark"] .controls-container {
  background: rgba(26, 26, 26, 0.95);
  border-color: var(--border-color);
}

/* Language Switcher */
.language-switcher {
  display: flex;
  gap: 0.5rem;
}

.language-dropdown {
  position: relative;
  display: inline-block;
}

.lang-toggle-btn {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: var(--transition);
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
}

.lang-toggle-btn:hover {
  background-color: var(--bg-secondary);
  border-color: var(--accent-color);
  transform: scale(1.1);
}

.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  animation: slideInDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.lang-option {
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  font-size: 0.95rem;
  transition: var(--transition);
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-option:first-child {
  border-radius: 6px 6px 0 0;
}

.lang-option:last-child {
  border-radius: 0 0 6px 6px;
}

.lang-option:hover {
  background-color: var(--bg-secondary);
  color: var(--accent-color);
  padding-left: 1.25rem;
}

.lang-option:active {
  background-color: var(--accent-color);
  color: white;
}

/* Theme Toggle */
.theme-toggle {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-color);
  transform: rotate(20deg) scale(1.1);
}

/* ============================================
   RTD Theme Overrides
   ============================================ */

.wy-nav-content-wrap {
  background: var(--bg-primary);
  transition: var(--transition);
}

.wy-nav-content {
  background: var(--nav-bg);
  color: var(--text-primary);
  transition: var(--transition);
}

.wy-nav-side {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  transition: var(--transition);
}

.wy-menu-vertical {
  width: 300px;
}

.wy-menu-vertical a {
  color: var(--sidebar-text);
  transition: var(--transition);
}

.wy-menu-vertical a:hover {
  color: var(--accent-color);
  background-color: var(--bg-secondary);
}

.wy-menu-vertical li.current > a {
  border-left: 3px solid var(--accent-color);
  color: var(--accent-color);
  background-color: var(--bg-secondary);
}

.rst-content {
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition);
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  transition: var(--transition);
  font-weight: 600;
}

h1 {
  font-size: 2.2rem;
  margin-top: 1em;
  margin-bottom: 0.5em;
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 0.5em;
}

h2 {
  font-size: 1.8rem;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  color: var(--accent-color);
}

h3 {
  font-size: 1.4rem;
  margin-top: 1.2em;
}

p {
  margin-bottom: 1em;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* ============================================
   Links
   ============================================ */

a {
  color: var(--link-color);
  text-decoration: none;
  transition: var(--transition);
  position: relative;
}

a:hover {
  color: var(--accent-hover);
}

.rst-content a {
  border-bottom: 1px solid var(--accent-color);
}

.rst-content a:hover {
  color: var(--accent-hover);
}

/* ============================================
   Code & Blocks
   ============================================ */

code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  transition: var(--transition);
}

.rst-content code {
  background: var(--code-bg);
  color: var(--code-text);
}

pre {
  background: var(--code-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-color);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  font-size: 16px;
  line-height: 1.6;
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: none;
}

.highlight {
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  font-size: 16px;
}

blockquote {
  border-left: 4px solid var(--accent-color);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--bg-secondary);
  padding: 1rem;
  border-radius: 4px;
}

/* ============================================
   Admonitions
   ============================================ */

.admonition {
  background: var(--bg-secondary);
  border-left: 4px solid var(--accent-color);
  padding: 1rem;
  border-radius: 4px;
  margin: 1rem 0;
}

.admonition.note {
  border-left-color: #0066cc;
}

.admonition.warning {
  border-left-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
}

.admonition.tip {
  border-left-color: #51cf66;
  background: rgba(81, 207, 102, 0.1);
}

.admonition.danger {
  border-left-color: #fa5252;
  background: rgba(250, 82, 82, 0.1);
}

/* ============================================
   Buttons & Interactive Elements
   ============================================ */

button {
  transition: var(--transition);
  font-weight: 500;
}

button:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.btn {
  background: var(--accent-color);
  color: white;
  padding: 0.5rem 1.5rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

/* ============================================
   Tables
   ============================================ */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  transition: var(--transition);
}

table td, table th {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

table th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
}

table tr:hover {
  background: var(--bg-secondary);
}

/* ============================================
   Search Box
   ============================================ */

.search input {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  transition: var(--transition);
}

.search input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1024px) {
  .controls-container {
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.5rem;
  }

  .theme-toggle {
    padding: 0.4rem 0.6rem;
  }
}

@media (max-width: 768px) {
  .controls-container {
    flex-direction: column;
    gap: 0.5rem;
    top: 0.5rem;
    right: 0.5rem;
  }

  .language-switcher {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding-right: 0;
    padding-bottom: 0.5rem;
  }

  h1 {
    font-size: 1.8rem;
  }

  h2 {
    font-size: 1.4rem;
  }

  h3 {
    font-size: 1.1rem;
  }

  .wy-nav-side {
    width: 100%;
    height: auto;
    position: relative;
  }

  .wy-nav-content-wrap {
    margin-left: 0;
  }

  .wy-nav-content {
    padding: 1.5rem;
  }
}

@media (max-width: 600px) {
  .controls-container {
    gap: 0.25rem;
    padding: 0.35rem;
  }

  .theme-toggle {
    padding: 0.3rem 0.45rem;
    font-size: 1rem;
    min-width: 40px;
    min-height: 40px;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  h3 {
    font-size: 1rem;
  }
}

/* ============================================
   Animations & Transitions
   ============================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.rst-content {
  animation: fadeIn 0.4s ease-out;
}

.wy-nav-side {
  animation: slideInLeft 0.5s ease-out;
}

/* ============================================
   Accessibility & Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  .controls-container {
    display: none;
  }

  html[data-theme="dark"] {
    color-scheme: light;
    --bg-primary: #ffffff;
    --text-primary: #2c3e50;
  }
}

/* ============================================
   Godot-Style Customizations
   ============================================ */

.rst-content > h1:first-child {
  border-bottom: 3px solid var(--accent-color);
  padding-bottom: 1rem;
  margin-bottom: 2rem;
}

.toctree-wrapper {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin: 2rem 0;
}

.toctree-wrapper > ul {
  margin: 0;
}

.toctree-wrapper li {
  margin: 0.5rem 0;
}

.toctree-wrapper a {
  transition: var(--transition);
}

.toctree-wrapper a:hover {
  color: var(--accent-color);
  padding-left: 0.5rem;
}

/* Sphinx version badges */
.wy-breadcrumbs {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  color: var(--text-secondary);
}

.wy-breadcrumbs a {
  color: var(--link-color);
}

.wy-breadcrumbs li + li:before {
  color: var(--text-tertiary);
}

/* Footer styling */
.rst-footer-buttons {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.rst-footer-buttons a {
  background: var(--bg-secondary);
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  display: inline-block;
  text-decoration: none;
}

.rst-footer-buttons a:hover {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}
