/* ==========================================================================
   Learning Notes Theme - Premium UI & System Tokens
   ========================================================================== */

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

:root {
  /* Light Mode Variables */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(79, 70, 229, 0.1);
  --accent: #06b6d4;
  --accent-light: #ecfeff;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.15);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Fira Code', monospace;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables Override */
[data-theme="dark"] {
  --bg-primary: #0b0f19;
  --bg-secondary: #131b2e;
  --bg-tertiary: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #1e293b;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.15);
  --accent: #22d3ee;
  --accent-light: rgba(34, 211, 238, 0.08);
  
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.08);
  --warning: #fbbf24;
  --warning-light: rgba(251, 191, 36, 0.08);
  --danger: #f87171;
  --danger-light: rgba(248, 113, 113, 0.08);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.2);
}

/* ==========================================================================
   Base Elements
   ========================================================================== */

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

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.625;
  min-height: 100vh;
  transition: background var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

/* ==========================================================================
   Animations & Keyframes
   ========================================================================== */

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

@keyframes pulse-soft {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

.fade-in {
  animation: fadeIn var(--transition-normal) forwards;
}

/* Decorative Mesh Backgrounds */
.bg-grid-mesh {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.bg-mesh-1 {
  position: absolute;
  top: -10%; right: -10%;
  width: 50vw; height: 50vw;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  filter: blur(80px);
  animation: pulse-soft 8s infinite alternate;
}

.bg-mesh-2 {
  position: absolute;
  bottom: -10%; left: -10%;
  width: 45vw; height: 45vw;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.1) 0%, transparent 70%);
  filter: blur(80px);
  animation: pulse-soft 12s infinite alternate-reverse;
}

/* ==========================================================================
   Responsive Shell Layout
   ========================================================================== */

.shell {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Header & Mobile Nav Bar */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  padding: 0 1.5rem;
  align-items: center;
  justify-content: space-between;
}

/* Left Sidebar styling */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  padding: 2.25rem 0;
  z-index: 50;
  transition: transform var(--transition-normal), background var(--transition-normal);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 1.75rem 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem;
}

.logo-circle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.logo-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  line-height: 1.2;
}

.logo-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.sidebar-search {
  padding: 0 1.25rem;
  margin-bottom: 1.5rem;
  position: relative;
}

.sidebar-search input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  transition: all var(--transition-fast);
}

.sidebar-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-secondary);
}

.sidebar-search::before {
  content: "🔍";
  position: absolute;
  left: 32px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  pointer-events: none;
  opacity: 0.6;
}

.nav-section {
  padding: 0 1.25rem;
  margin-bottom: 1.75rem;
}

.nav-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-left: 0.5rem;
  margin-bottom: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transform: translateX(2px);
}

.nav-item.active {
  background: var(--primary-glow);
  color: var(--primary);
  font-weight: 600;
}

.nav-item-icon {
  font-size: 1rem;
  display: flex;
  align-items: center;
}

/* Theme Switcher Button */
.theme-switch-wrapper {
  padding: 0 1.25rem;
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.theme-switch-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-switch-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Main Reading Pane */
.main-wrapper {
  margin-left: 280px;
  flex: 1;
  display: flex;
  min-width: 0; /* Prevents flex children from stretching */
}

.main-content {
  flex: 1;
  max-width: 880px;
  padding: 4rem 3.5rem;
  min-width: 0;
}

/* ==========================================================================
   Table of Contents Sidebar (Right Side)
   ========================================================================== */

.toc-sidebar {
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 4rem 2rem 2rem 1.5rem;
  border-left: 1px solid var(--border);
  z-index: 40;
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toc-item {
  font-size: 0.85rem;
  line-height: 1.4;
}

.toc-link {
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  display: block;
}

.toc-link:hover, .toc-link.active {
  color: var(--primary);
  transform: translateX(1px);
}

.toc-item.depth-3 {
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

/* ==========================================================================
   Markdown Document Typography Styles
   ========================================================================== */

.markdown-body h1 {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.15;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

.markdown-body h2 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 3rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.markdown-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin: 2rem 0 0.75rem;
  color: var(--text-primary);
}

.markdown-body h4 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: var(--text-primary);
}

.markdown-body p {
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
  line-height: 1.75;
  font-size: 1.02rem;
}

.markdown-body hr {
  height: 1px;
  background-color: var(--border);
  border: none;
  margin: 2.5rem 0;
}

/* Lists styling */
.markdown-body ul, .markdown-body ol {
  margin-bottom: 1.25rem;
  padding-left: 1.75rem;
  color: var(--text-secondary);
}

.markdown-body li {
  margin-bottom: 0.35rem;
}

.markdown-body li::marker {
  color: var(--primary);
  font-weight: 600;
}

.markdown-body blockquote {
  border-left: 4px solid var(--primary);
  padding: 0.75rem 1.25rem;
  background: var(--bg-tertiary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1.5rem 0;
  color: var(--text-secondary);
}

.markdown-body blockquote p {
  margin-bottom: 0;
  font-style: italic;
}

/* Callouts system matching premium alerts */
.markdown-body blockquote.callout {
  border-left-width: 4px;
}

.callout-green, .markdown-body blockquote.callout-green {
  background: var(--success-light);
  border-left-color: var(--success);
  color: var(--text-primary);
}

.callout-amber, .markdown-body blockquote.callout-amber {
  background: var(--warning-light);
  border-left-color: var(--warning);
  color: var(--text-primary);
}

.callout-blue, .markdown-body blockquote.callout-blue {
  background: var(--accent-light);
  border-left-color: var(--accent);
  color: var(--text-primary);
}

.callout-red, .markdown-body blockquote.callout-red {
  background: var(--danger-light);
  border-left-color: var(--danger);
  color: var(--text-primary);
}

/* Code & Code block Styling */
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-tertiary);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.markdown-body pre {
  background: #0f172a;
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  position: relative;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: #e2e8f0;
  font-size: 0.85rem;
  line-height: 1.7;
}

/* Syntax Highlighting overrides */
.markdown-body .token.comment { color: #64748b; font-style: italic; }
.markdown-body .token.keyword { color: #f43f5e; }
.markdown-body .token.string { color: #10b981; }
.markdown-body .token.number { color: #38bdf8; }
.markdown-body .token.function { color: #6366f1; }

/* Table Styling */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 1.75rem 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.92rem;
}

.markdown-body th {
  background: var(--bg-tertiary);
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.markdown-body td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.markdown-body tr:last-child td {
  border-bottom: none;
}

.markdown-body tr:hover td {
  background: var(--bg-tertiary);
}

/* Images */
.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin: 1.5rem 0;
}

/* Floating Navigation Action Badge on standalone HTML pages */
.floating-home-btn {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--primary);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  z-index: 100;
  transition: all var(--transition-fast);
  border: none;
  cursor: pointer;
  text-decoration: none !important;
}

.floating-home-btn:hover {
  transform: translateY(-2px);
  background: var(--primary-hover);
  color: #ffffff;
  box-shadow: var(--shadow-lg), 0 0 25px rgba(79, 70, 229, 0.35);
}

/* ==========================================================================
   Wiki Portal Dashboard UI (index.html)
   ========================================================================== */

.portal-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 5rem 2rem;
}

.portal-hero {
  text-align: center;
  margin-bottom: 4rem;
  position: relative;
}

.portal-hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--primary-glow);
  color: var(--primary);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  margin-bottom: 1.5rem;
}

.portal-hero h1 {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.1;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.portal-hero h1 span {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.portal-hero p {
  color: var(--text-secondary);
  font-size: 1.15rem;
  max-width: 600px;
  margin: 0 auto 2.5rem;
}

/* Search bar styling */
.portal-search-box {
  max-width: 640px;
  margin: 0 auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all var(--transition-normal);
}

.portal-search-box:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.portal-search-box input {
  width: 100%;
  padding: 18px 24px 18px 56px;
  border: none;
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1.05rem;
  outline: none;
}

.portal-search-box::before {
  content: "🔍";
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
  pointer-events: none;
  opacity: 0.7;
}

/* Tab filter style */
.portal-filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2.5rem 0;
}

.filter-btn {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.filter-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Grid layout for note cards */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

.note-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  text-decoration: none !important;
  color: inherit;
}

.note-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.note-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.note-card:hover::before {
  opacity: 1;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
}

.note-card:hover .card-icon {
  background: var(--primary-glow);
  border-color: var(--primary);
}

.card-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.note-card:hover .card-badge {
  background: var(--accent-light);
  color: var(--accent);
}

.note-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.note-card p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1.5rem;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.card-read-more {
  color: var(--primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: gap var(--transition-fast);
}

.note-card:hover .card-read-more {
  gap: 8px;
}

/* Portal Footer */
.portal-footer {
  text-align: center;
  margin-top: 6rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Responsive Breakpoints & Media Queries
   ========================================================================== */

@media (max-width: 1200px) {
  .toc-sidebar {
    display: none; /* Hide Toc Sidebar on medium desktop screen */
  }
}

@media (max-width: 900px) {
  /* Setup mobile shell */
  .mobile-header {
    display: flex;
  }
  
  .sidebar {
    transform: translateX(-100%);
    top: 64px;
    height: calc(100vh - 64px);
    width: 100%;
    z-index: 99;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-wrapper {
    margin-left: 0;
    padding-top: 64px;
  }
  
  .main-content {
    padding: 2rem 1.5rem;
  }
  
  .markdown-body h1 {
    font-size: 2rem;
  }
}

@media (max-width: 600px) {
  .portal-hero h1 {
    font-size: 2.2rem;
  }
  
  .portal-hero p {
    font-size: 1rem;
  }
  
  .portal-grid {
    grid-template-columns: 1fr;
  }
}
