/* NOIR DESIGN SYSTEM - INDUSTRIAL MINIMALISM WITH THEME SUPPORT */

:root {
  /* Dark Theme (Noir) */
  --base-bg: #000000;
  --elevated-surface: #09090b;
  --component-border: #18181b;
  --text-primary: #FFFFFF;
  --text-secondary: #71717a;
  --text-mono: #a1a1aa;
  --focus-accent: #FFFFFF;
  
  --system-rail-width: 260px;
  --utility-bar-height: 56px;
  
  --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Theme */
body.light-theme {
  --base-bg: #FFFFFF;
  --elevated-surface: #F9FAFB;
  --component-border: #E5E7EB;
  --text-primary: #000000;
  --text-secondary: #6B7280;
  --text-mono: #4B5563;
  --focus-accent: #000000;
}

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

/* Override border-radius only for specific elements that need sharp corners */
.sidebar,
.top-bar,
.chapter-link,
.nav-btn,
.theme-toggle,
.content table,
.content th,
.content td,
.chapter-card,
.chapter-tag,
.chapter-duration,
.auth-card,
.auth-feature-icon {
  border-radius: 0 !important;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--base-bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background var(--transition-fast), color var(--transition-fast);
}

/* Automatically increase font weight in light theme */
body.light-theme {
  font-weight: 500;
}

body.light-theme .content p,
body.light-theme .content li,
body.light-theme .chapter-title,
body.light-theme .chapter-card-description {
  font-weight: 500;
}

/* Scrollbar Noir */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: var(--base-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--component-border);
  transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Auth Modal - Compact 80% Size */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity var(--transition-slow);
}

.auth-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-card {
  background: var(--base-bg);
  border: 2px solid var(--text-primary);
  width: 100%;
  max-width: 400px;
  padding: 48px 40px;
  text-align: center;
  animation: authEntryFade 0.8s ease-out;
  position: relative;
}

@keyframes authEntryFade {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-transform: uppercase;
}

.auth-card h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  line-height: 1.1;
}

.auth-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.5;
  font-weight: 400;
}

.auth-cta-button {
  display: inline-block;
  background: var(--text-primary);
  color: var(--base-bg);
  padding: 14px 40px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 2px solid var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-cta-button:hover {
  background: transparent;
  color: var(--text-primary);
  transform: translateY(-2px);
}

.auth-features {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--component-border);
}

.auth-features-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.auth-feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-mono);
}

.auth-feature-icon {
  width: 16px;
  height: 16px;
  border: 1px solid var(--component-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-feature-icon svg {
  width: 10px;
  height: 10px;
  stroke: var(--text-primary);
}

.auth-instruction {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--component-border);
  text-align: center;
}

.auth-instruction p {
  font-size: 10px;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  margin: 0;
}

/* App Container */
.app-container {
  display: flex;
  height: 100vh;
  position: relative;
}

/* Sidebar: The System Rail */
.sidebar {
  width: var(--system-rail-width);
  min-width: var(--system-rail-width);
  background: var(--base-bg);
  border-right: 1px solid var(--component-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  transition: background var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--component-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-branding {
  flex: 1;
}

.brand-label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.05em;
}

.system-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.4;
  font-weight: 500;
}

.close-sidebar {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  font-size: 20px;
  line-height: 1;
}

/* Progress Section */
.progress-section {
  padding: 24px;
  border-bottom: 1px solid var(--component-border);
}

.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.progress-bar {
  height: 2px;
  background: var(--component-border);
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: var(--text-primary);
  width: 0%;
  transition: width 0.4s ease;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Table of Contents */
.toc {
  padding-bottom: 48px;
}

.phase-header {
  padding: 24px 24px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 600;
}

.chapter-link {
  width: 100%;
  background: transparent;
  border: none;
  padding: 10px 24px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  border-left: 2px solid transparent;
}

.chapter-link:hover {
  color: var(--text-primary);
}

.chapter-link.active {
  color: var(--text-primary);
  background: var(--elevated-surface);
  border-left-color: var(--text-primary);
}

.chapter-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
}

.chapter-title {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--base-bg);
  transition: background var(--transition-fast);
  min-width: 0;
}

/* Utility Bar */
.top-bar {
  height: var(--utility-bar-height);
  background: var(--base-bg);
  border-bottom: 1px solid var(--component-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background var(--transition-fast);
}

.utility-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  font-size: 20px;
  line-height: 1;
}

.breadcrumbs {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
}

.utility-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.search-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--component-border);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 4px 0;
  width: 180px;
  font-weight: 500;
}

.search-input:focus {
  outline: none;
  border-color: var(--text-primary);
}

/* Theme Toggle - Contrasting Colors */
.theme-toggle {
  background: var(--text-primary);
  border: 1px solid var(--text-primary);
  color: var(--base-bg);
  padding: 6px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.theme-toggle:hover {
  opacity: 0.85;
}

/* Content Wrapper */
.content-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 64px 24px;
}

.content-container {
  max-width: 1200px;
  margin: 0 auto;
}

.content {
  animation: pageEntry var(--transition-slow);
}

@keyframes pageEntry {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Typography Overrides for Content */
.content h1 {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
  margin-bottom: 32px;
  text-transform: uppercase;
}

.content h2 {
  font-size: 32px;
  font-weight: 600;
  border-bottom: 1px solid var(--component-border);
  padding-bottom: 16px;
  margin: 48px 0 24px;
}

.content h3 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 24px 0 12px;
  font-weight: 600;
}

.content h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 20px 0 12px;
}

.content p {
  font-weight: 400;
  color: var(--text-mono);
  font-size: 17px;
  margin-bottom: 16px;
  line-height: 1.7;
}

.content a {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity var(--transition-fast);
  font-weight: 500;
}

.content a:hover {
  opacity: 0.7;
}

.content code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--elevated-surface);
  border: 1px solid var(--component-border);
  padding: 2px 6px;
  font-size: 14px;
  font-weight: 500;
}

.content pre {
  background: var(--elevated-surface);
  border: 1px solid var(--component-border);
  padding: 24px;
  margin: 32px 0;
  overflow-x: auto;
}

.content pre code {
  background: transparent;
  border: none;
  padding: 0;
}

.content blockquote {
  border-left: 2px solid var(--text-primary);
  background: var(--elevated-surface);
  padding: 24px 32px;
  font-style: italic;
  margin: 32px 0;
  font-weight: 500;
}

/* Lists - Fixed Alignment */
.content ul, .content ol {
  margin: 16px 0 16px 24px;
  padding: 0;
}

.content li {
  margin-bottom: 8px;
  padding-left: 8px;
  line-height: 1.7;
  font-weight: 400;
}

.content ul li {
  list-style-type: disc;
}

.content ol li {
  list-style-type: decimal;
}

/* Credits CTA Block */
.credits-cta {
  background: #000000;
  border: 2px solid #000000;
  border-radius: 0;
  padding: 32px;
  margin: 48px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.credits-cta-content {
  position: relative;
  z-index: 1;
}

.credits-cta-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  padding: 6px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
  border-radius: 0;
}

.credits-cta h3 {
  color: white !important;
  font-size: 28px !important;
  font-weight: 700 !important;
  margin: 0 0 12px 0 !important;
  text-transform: none !important;
  font-family: 'Inter', sans-serif !important;
}

.credits-cta p {
  color: rgba(255, 255, 255, 0.9) !important;
  font-size: 16px !important;
  margin-bottom: 24px !important;
  font-weight: 400 !important;
}

.credits-cta-button {
  display: inline-block;
  background: #6c24db !important;
  color: #FFFFFF !important;
  padding: 14px 32px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none !important;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid #6c24db !important;
  border-radius: 0 !important;
}

.credits-cta-button:hover {
  background: #5a1db8 !important;
  border-color: #5a1db8 !important;
  opacity: 1 !important;
  text-decoration: none !important;
}

/* Navigation Buttons */
.navigation-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 80px;
  padding-top: 32px;
  border-top: 1px solid var(--component-border);
}

.nav-btn {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--text-primary);
  padding: 12px 24px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 600;
}

.nav-btn:hover {
  background: var(--text-primary);
  color: var(--base-bg);
}

/* Tables */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 32px 0;
  border: 1px solid var(--component-border);
  overflow-x: auto;
  display: block;
}

.content th {
  background: var(--elevated-surface);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-align: left;
  padding: 16px;
  border-bottom: 1px solid var(--component-border);
  font-weight: 600;
}

.content td {
  padding: 16px;
  border-bottom: 1px solid var(--component-border);
  font-size: 14px;
  font-weight: 500;
}

/* Homepage Chapter Grid */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin: 48px 0;
}

.chapter-card {
  background: var(--base-bg);
  border: 1px solid var(--component-border);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.chapter-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--text-primary);
  transition: width var(--transition-fast);
}

.chapter-card:hover {
  background: var(--elevated-surface);
  border-color: var(--text-primary);
}

.chapter-card:hover::before {
  width: 100%;
}

.chapter-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.chapter-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}

.chapter-duration {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--elevated-surface);
  padding: 4px 8px;
  border: 1px solid var(--component-border);
  font-weight: 600;
}

.chapter-card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.chapter-card-description {
  font-size: 14px;
  color: var(--text-mono);
  margin-bottom: 16px;
  line-height: 1.5;
  font-weight: 400;
}

.chapter-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chapter-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text-secondary);
  border: 1px solid var(--component-border);
  padding: 4px 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* Phase Dividers */
.phase-divider {
  margin: 64px 0 32px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--component-border);
}

.phase-divider h2 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
  border: none;
  padding: 0;
  font-weight: 600;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.sidebar-overlay.active {
  opacity: 1;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 101;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .sidebar-overlay {
    display: block;
  }
  
  .menu-toggle {
    display: block;
  }
  
  .close-sidebar {
    display: block;
  }
  
  .search-container {
    display: none;
  }
  
  .content h1 {
    font-size: 36px;
  }
  
  .content h2 {
    font-size: 24px;
  }
  
  .content-wrapper {
    padding: 32px 16px;
  }

  .chapter-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .auth-card {
    padding: 32px 24px;
    max-width: 360px;
  }

  .auth-card h1 {
    font-size: 26px;
  }

  .credits-cta {
    padding: 24px;
    margin: 32px 0;
  }

  .credits-cta h3 {
    font-size: 20px !important;
  }

  .credits-cta p {
    font-size: 14px !important;
  }

  .breadcrumbs {
    font-size: 9px;
  }

  .navigation-buttons {
    flex-direction: column;
    gap: 12px;
  }

  .nav-btn {
    width: 100%;
  }
}

/* Tablet Responsiveness */
@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar {
    width: 220px;
    min-width: 220px;
  }
  
  .content h1 {
    font-size: 48px;
  }
}