/* Level 114 Terminal Theme for MkDocs */

/* Import Fira Code font */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap');

:root {
  --md-primary-fg-color: #0d1117;
  --md-primary-bg-color: #0d1117;
  --md-accent-fg-color: #00ff00;
  --md-default-bg-color: #010409;
  --md-default-fg-color: #c9d1d9;
  --md-code-bg-color: #161b22;
  --md-code-fg-color: #00ff00;
  --neon-green: #00ff00;
  --bright-green: #39ff14;
  --dark-green: #00cc00;
  --terminal-bg: #0d1117;
  --terminal-dark: #010409;
  --terminal-border: #21262d;
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --accent-blue: #58a6ff;
  --warning-orange: #ff7b72;
}

/* Blinking terminal cursor */
.terminal-cursor {
  color: var(--neon-green);
  font-weight: normal;
  position: relative;
}

.terminal-cursor::after {
  content: " ";
  background-color: var(--neon-green);
  animation: cursor-blink 1.2s infinite;
  margin-left: 2px;
  display: inline-block;
  width: 8px;
  height: 1.2em;
  vertical-align: text-bottom;
}

@keyframes cursor-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Main body styling */
body {
  font-family: 'Fira Code', monospace !important;
  background: var(--terminal-dark) !important;
}

/* Header styling */
.md-header {
  background: var(--terminal-border) !important;
  border-bottom: 1px solid #30363d;
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.1);
  height: 3rem;
  min-height: 3rem;
}

.md-header__inner {
  max-width: none;
  padding: 0 1rem;
}

.md-header__title {
  font-family: 'Fira Code', monospace !important;
  font-weight: 600;
  color: var(--neon-green) !important;
  font-size: 0.9rem;
  line-height: 1.2;
}

.md-header__title::before {
  content: "level114:~$ ";
  color: var(--neon-green);
}

/* Navigation styling */
.md-nav {
  font-family: 'Fira Code', monospace !important;
  background: var(--terminal-dark) !important;
  font-size: 0.85rem;
}

.md-nav__title {
  color: var(--neon-green) !important;
  font-weight: 600;
  border-bottom: 1px solid var(--terminal-border);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  background: rgba(0, 255, 0, 0.05);
}

.md-nav__item {
  margin: 1px 0;
  line-height: 1.3;
}

/* Primary sidebar navigation only */
.md-sidebar--primary .md-nav__item {
  margin: 1px 0;
  line-height: 1.3;
}

/* Category headers (top-level items with children) - Primary sidebar only */
.md-sidebar--primary .md-nav__item--nested > .md-nav__link:not([for]) {
  color: var(--neon-green) !important;
  font-weight: 700 !important;
  font-size: 0.9rem !important;
  text-transform: uppercase !important;
  letter-spacing: 1px !important;
  border-left: 4px solid var(--neon-green) !important;
  background: linear-gradient(90deg, rgba(0,255,0,0.15) 0%, transparent 100%) !important;
  padding: 0.6rem 1rem 0.6rem 1.2rem !important;
  margin: 0.2rem 0 !important;
  border-radius: 0 4px 4px 0 !important;
  transition: all 0.3s ease;
}

.md-sidebar--primary .md-nav__item--nested > .md-nav__link:not([for]):hover {
  background: linear-gradient(90deg, rgba(0,255,0,0.25) 0%, transparent 100%) !important;
  transform: translateX(2px);
}

/* Add horizontal rule after each category - Primary sidebar only */
.md-sidebar--primary .md-nav__item--nested::after {
  content: "";
  display: block;
  height: 1px;
  background: linear-gradient(90deg, var(--neon-green) 0%, transparent 80%);
  margin: 0.5rem 1rem 1rem 1rem;
  opacity: 0.4;
}

/* Page links (sub-items under categories) - Primary sidebar only - ONLY <a> elements */
.md-sidebar--primary .md-nav__item--nested .md-nav__list .md-nav__item a.md-nav__link {
  color: var(--text-secondary) !important;
  font-weight: normal !important;
  font-size: 0.8rem !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  border-left: none !important;
  background: none !important;
  padding: 0.4rem 1rem 0.4rem 2rem !important;
  margin: 0 !important;
  border-radius: 4px;
  position: relative;
  transition: all 0.3s ease;
}

/* Add bullets to page links - Primary sidebar only - ONLY to <a> elements, not <label> elements */
.md-sidebar--primary .md-nav__item--nested .md-nav__list .md-nav__item a.md-nav__link::before {
  content: "• ";
  color: var(--neon-green) !important;
  font-weight: bold;
  margin-right: 0.5rem;
  font-size: 1rem;
  position: absolute;
  left: 1.2rem;
}

/* Regular nav links (like Home) - Primary sidebar only */
.md-sidebar--primary .md-nav__item:not(.md-nav__item--nested) .md-nav__link {
  color: var(--neon-green) !important;
  font-weight: 600 !important;
  border-radius: 4px;
  transition: all 0.3s ease;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Hover states - Primary sidebar only */
.md-sidebar--primary .md-nav__link:hover:not([for]) {
  color: var(--neon-green) !important;
  background: rgba(0, 255, 0, 0.1) !important;
  border-left: 3px solid var(--neon-green);
  transform: translateX(3px);
}

.md-sidebar--primary .md-nav__link--active {
  color: var(--neon-green) !important;
  background: rgba(0, 255, 0, 0.15) !important;
  border: 1px solid var(--terminal-border);
  border-left: 3px solid var(--neon-green) !important;
  box-shadow: 0 0 8px rgba(0, 255, 0, 0.2);
}

/* Active page under categories - Primary sidebar only - ONLY <a> elements */
.md-sidebar--primary .md-nav__item--nested .md-nav__list .md-nav__item a.md-nav__link--active {
  color: var(--bright-green) !important;
  background: rgba(0, 255, 0, 0.2) !important;
  border-left: 2px solid var(--bright-green) !important;
  font-weight: 600 !important;
  transform: translateX(2px);
}

/* Hide duplicate current page labels in navigation - both nested pages and home page */
.md-sidebar--primary .md-nav__item--active label.md-nav__link[for="__toc"] {
  display: none !important;
}

/* Default navigation link styling */
.md-nav__link {
  color: var(--text-secondary) !important;
  border-radius: 4px;
  transition: all 0.3s ease;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Sidebar width optimization */
.md-sidebar--primary {
  width: 16rem;
}

.md-sidebar--secondary {
  width: 12rem;
}

/* Table of contents styling */
.md-nav--secondary {
  border-left: 1px solid var(--terminal-border);
  background: rgba(0, 0, 0, 0.2);
}

.md-nav--secondary .md-nav__title {
  background: var(--terminal-border);
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
}

.md-nav--secondary .md-nav__link {
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  line-height: 1.4;
}

/* Content area */
.md-main__inner {
  margin: 0;
  padding: 0;
  max-width: none;
}

.md-content {
  background: linear-gradient(135deg, var(--terminal-bg) 0%, #161b22 100%) !important;
  margin: 0;
}

.md-content__inner {
  padding: 1.5rem 2rem;
  background: var(--terminal-bg);
  border: 1px solid var(--terminal-border);
  border-radius: 6px;
  margin: 0.5rem;
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.1);
  max-width: none;
}

/* Make the layout more compact */
.md-container {
  max-width: none;
}

.md-main {
  flex: 1;
}

.md-main .md-main__inner {
  margin-top: 0;
  padding-top: 0;
}

/* Typography */
h1 {
  color: var(--neon-green) !important;
  font-family: 'Fira Code', monospace !important;
  font-weight: 700;
  font-size: 1.8rem;
  text-shadow: 0 0 8px rgba(0, 255, 0, 0.4);
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--terminal-border);
  padding-bottom: 0.5rem;
}

h2 {
  color: var(--neon-green) !important;
  font-family: 'Fira Code', monospace !important;
  font-weight: 600;
  font-size: 1.4rem;
  text-shadow: 0 0 5px rgba(0, 255, 0, 0.3);
  margin: 1.5rem 0 0.75rem 0;
}

h3 {
  color: var(--accent-blue) !important;
  font-family: 'Fira Code', monospace !important;
  font-weight: 600;
  font-size: 1.2rem;
  margin: 1.2rem 0 0.6rem 0;
}

h4, h5, h6 {
  color: var(--text-primary) !important;
  font-family: 'Fira Code', monospace !important;
  font-weight: 600;
  margin: 1rem 0 0.5rem 0;
}

p, li, td {
  color: var(--text-primary) !important;
  font-family: 'Fira Code', monospace !important;
  line-height: 1.6;
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}

/* Lists */
.md-typeset ul, .md-typeset ol {
  margin: 0.5rem 0;
}

.md-typeset li {
  margin: 0.3rem 0;
  padding-left: 0.2rem;
}

/* Bullet points styling */
.md-typeset ul li::marker {
  color: var(--neon-green);
  font-weight: bold;
}

.md-typeset ol li::marker {
  color: var(--accent-blue);
  font-weight: bold;
}

/* Code blocks */
.md-typeset code {
  background: var(--code-bg-color) !important;
  color: var(--neon-green) !important;
  font-family: 'Fira Code', monospace !important;
  border: 1px solid var(--terminal-border);
}

.md-typeset pre {
  background: var(--terminal-dark) !important;
  border: 1px solid var(--terminal-border);
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.1);
}

.md-typeset pre code {
  background: none !important;
  color: var(--neon-green) !important;
}

/* Math formulas */
.MathJax {
  color: var(--accent-blue) !important;
}

/* Tables */
.md-typeset table {
  border: 1px solid var(--terminal-border);
  background: var(--terminal-dark);
  border-radius: 4px;
  overflow: hidden;
  margin: 1rem 0;
  font-size: 0.85rem;
}

.md-typeset th {
  background: var(--terminal-border) !important;
  color: var(--neon-green) !important;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  border-bottom: 2px solid #30363d;
}

.md-typeset td {
  border-color: var(--terminal-border) !important;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
}

.md-typeset tbody tr:hover {
  background: rgba(0, 255, 0, 0.05) !important;
}

/* Links */
.md-typeset a {
  color: var(--accent-blue) !important;
  transition: all 0.3s ease;
}

.md-typeset a:hover {
  color: var(--neon-green) !important;
  text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
}

/* Admonitions */
.md-typeset .admonition {
  border: 1px solid var(--terminal-border);
  background: rgba(0, 255, 0, 0.05);
}

.md-typeset .admonition-title {
  background: var(--terminal-border);
  color: var(--neon-green) !important;
  font-weight: 600;
}

/* Search */
.md-search__form {
  background: var(--terminal-dark) !important;
  border: 1px solid var(--terminal-border);
  border-radius: 4px;
  box-shadow: 0 0 5px rgba(0, 255, 0, 0.1);
}

.md-search__input {
  background: var(--terminal-dark) !important;
  color: var(--text-primary) !important;
  font-family: 'Fira Code', monospace !important;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
}

.md-search__input::placeholder {
  color: var(--text-secondary) !important;
}

.md-search__input:focus {
  border-color: var(--neon-green);
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

/* Search results */
.md-search-result {
  background: var(--terminal-dark) !important;
  border: 1px solid var(--terminal-border) !important;
}

.md-search-result__meta {
  background: var(--terminal-border) !important;
  color: var(--text-secondary) !important;
}

/* Buttons */
button, .md-button {
  background: transparent !important;
  border: 1px solid var(--neon-green) !important;
  color: var(--neon-green) !important;
  font-family: 'Fira Code', monospace !important;
  transition: all 0.3s ease;
}

button:hover, .md-button:hover {
  background: rgba(0, 255, 0, 0.1) !important;
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
  transform: translateY(-1px);
}

/* Footer */
.md-footer {
  background: var(--terminal-border) !important;
  color: var(--text-secondary) !important;
  border-top: 1px solid #30363d;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--terminal-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--neon-green);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bright-green);
}

/* Terminal cursor animation */
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.cursor::after {
  content: "_";
  color: var(--neon-green);
  animation: blink 1s infinite;
}

/* Glow effects */
@keyframes glow-pulse {
  from {
    text-shadow: 0 0 5px var(--neon-green);
  }
  to {
    text-shadow: 0 0 20px var(--neon-green), 0 0 30px var(--neon-green);
  }
}

.glow {
  animation: glow-pulse 2s ease-in-out infinite alternate;
}

/* Mobile responsiveness */
@media (max-width: 76.25rem) {
  .md-sidebar--primary {
    width: 14rem;
  }
  
  .md-sidebar--secondary {
    width: 10rem;
  }
}

/* Tablet and mobile navigation improvements */
@media (max-width: 60rem) {
  .md-content__inner {
    margin: 0.25rem;
    padding: 1rem 1.5rem;
  }
  
  /* Better mobile navigation */
  .md-nav__link {
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
    min-height: 44px; /* Better touch targets */
  }
  
  .md-nav__title {
    font-size: 0.9rem;
    padding: 0.75rem 0.75rem;
  }
  
  /* Mobile category headers */
  .md-sidebar--primary .md-nav__item--nested > .md-nav__link:not([for]) {
    font-size: 0.85rem !important;
    padding: 0.7rem 0.75rem 0.7rem 1rem !important;
  }
  
  /* Mobile bullets */
  .md-sidebar--primary .md-nav__item--nested .md-nav__list .md-nav__item a.md-nav__link {
    font-size: 0.8rem !important;
    padding: 0.6rem 0.75rem 0.6rem 1.8rem !important;
  }
  
  .md-sidebar--primary .md-nav__item--nested .md-nav__list .md-nav__item a.md-nav__link::before {
    left: 1rem;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  h2 {
    font-size: 1.2rem;
  }
  
  h3 {
    font-size: 1.1rem;
  }
}

/* Mobile phone navigation */
@media (max-width: 45rem) {
  .md-content__inner {
    margin: 0.1rem;
    padding: 0.75rem 1rem;
  }
  
  /* Smaller mobile header adjustments */
  .md-header__title {
    font-size: 0.8rem !important;
  }
  
  /* Smaller logo for mobile phones */
  .md-header__inner::before {
    width: 28px !important;
    height: 28px !important;
  }
  
  /* Mobile drawer navigation styling */
  .md-nav__link {
    font-size: 0.8rem;
    padding: 0.7rem 0.75rem;
    min-height: 48px; /* iOS recommended touch target */
    line-height: 1.4;
  }
  
  /* Mobile category styling in drawer */
  .md-nav--primary .md-nav__item--nested > .md-nav__link:not([for]) {
    font-size: 0.8rem !important;
    padding: 0.8rem 0.75rem !important;
    letter-spacing: 0.5px !important;
  }
  
  /* Mobile bullet points in drawer */
  .md-nav--primary .md-nav__item--nested .md-nav__list .md-nav__item a.md-nav__link {
    font-size: 0.75rem !important;
    padding: 0.7rem 0.75rem 0.7rem 1.5rem !important;
  }
  
  .md-nav--primary .md-nav__item--nested .md-nav__list .md-nav__item a.md-nav__link::before {
    left: 0.8rem;
    font-size: 0.9rem;
  }
  
  /* Horizontal rules in drawer */
  .md-nav--primary .md-nav__item--nested::after {
    margin: 0.3rem 0.75rem 0.8rem 0.75rem;
  }
}

/* Very small screens */
@media (max-width: 30rem) {
  /* Smaller header text and logo on very small screens */
  .md-header__title {
    font-size: 0.7rem !important;
  }
  
  /* Extra small logo for tiny screens */
  .md-header__inner::before {
    width: 24px !important;
    height: 24px !important;
  }
  
  /* Smaller header padding */
  .md-header__inner {
    padding: 0 0.25rem !important;
    gap: 0.25rem !important;
  }
  
  /* Drawer navigation - smaller fonts for tiny screens */
  .md-nav__link {
    font-size: 0.75rem;
    padding: 0.6rem 0.5rem;
  }
}

/* Mobile navigation improvements */
@media (max-width: 76.25em) {
  /* Hide secondary sidebar but keep primary for hamburger menu */
  .md-sidebar--secondary {
    display: none !important;
  }
  
  /* Hide desktop sidebar display but keep navigation data */
  .md-sidebar--primary {
    transform: translateX(-100%) !important;
    transition: transform 0.25s;
  }
  
  /* Make sidebar full overlay when hamburger menu is opened */
  #__drawer:checked ~ .md-container .md-sidebar--primary {
    transform: translateX(0) !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 200 !important;
    background: var(--terminal-dark) !important;
    border-right: none !important;
  }
  
  /* Make the navigation fill the overlay */
  #__drawer:checked ~ .md-container .md-sidebar--primary .md-sidebar__scrollwrap {
    width: 100% !important;
    height: 100% !important;
  }
  
  /* Style the navigation in overlay mode */
  #__drawer:checked ~ .md-container .md-sidebar--primary .md-nav--primary {
    height: 100% !important;
    padding: 2rem 1rem !important;
  }
  
  /* When drawer is opened via hamburger */
  .md-nav--primary {
    background: var(--terminal-dark) !important;
    border-right: 2px solid var(--neon-green);
  }
  
  .md-nav--primary .md-nav__title {
    background: var(--terminal-border) !important;
    color: var(--neon-green) !important;
    border-bottom: 1px solid var(--neon-green);
    font-family: 'Fira Code', monospace !important;
  }
  
  /* Mobile overlay */
  .md-overlay {
    background: rgba(1, 4, 9, 0.9) !important;
  }
  
  /* Make content full width */
  .md-main__inner {
    margin-left: 0 !important;
  }
  
  /* Complete mobile header restructure: Logo | Hamburger | Title (center) | Search */
  .md-header__inner {
    display: flex !important;
    align-items: center !important;
    padding: 0 0.5rem !important;
    gap: 0.5rem !important;
  }
  
  /* Logo - positioned first on the left */
  .md-header__inner::before {
    content: "";
    display: block;
    width: 32px;
    height: 32px;
    background-image: url('../img/logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    border: 1px solid var(--neon-green);
    border-radius: 3px;
    flex-shrink: 0;
    order: -3; /* Logo first */
  }
  
  /* Hamburger button - positioned after logo */
  .md-header__button[for="__drawer"] {
    order: -2; /* Hamburger second */
    color: var(--neon-green) !important;
    margin-right: 0.5rem;
  }
  
  .md-header__button[for="__drawer"]:hover {
    background: rgba(0, 255, 0, 0.1) !important;
  }
  
  /* Title - centered */
  .md-header__title {
    flex: 1 !important;
    text-align: center !important;
    order: -1; /* Title in middle */
    font-size: 0.85rem !important;
    margin: 0 !important;
  }
  
  /* Remove the ::after pseudo-element logo since we're using ::before on inner */
  .md-header__title::after {
    display: none !important;
  }
  
  /* Search button - positioned last on the right */
  .md-header__button[for="__search"] {
    order: 1; /* Search last */
    color: var(--neon-green) !important;
  }
  
  .md-header__button[for="__search"]:hover {
    background: rgba(0, 255, 0, 0.1) !important;
  }
}

/* Matrix rain background effect */
.md-container::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 100px,
    rgba(0, 255, 0, 0.01) 102px
  );
  pointer-events: none;
  z-index: -1;
  animation: matrixScroll 20s linear infinite;
}

@keyframes matrixScroll {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

/* Terminal prompt styling */
.terminal-prompt::before {
  content: "level114@bittensor:~$ ";
  color: var(--neon-green);
  font-weight: 600;
}

/* Status indicators */
.status-online {
  color: var(--neon-green) !important;
}

.status-warning {
  color: var(--warning-orange) !important;
}

.status-info {
  color: var(--accent-blue) !important;
}
