/* ========================================
   PhyEdu Class — Deep Ocean Design System
   "깊은 바다" — 물리학의 깊이를 탐구하다
   WikiDocs-style sidebar + content layout
   ======================================== */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.8/dist/web/static/pretendard.css');

/* --- Design Tokens: Deep Ocean --- */
:root {
  /* Sellas (Starry Deep Sea) depths palette */
  --ocean-surface: #050a1a;
  --ocean-mid: #0a0d23;
  --ocean-deep: #0f0a20;
  --ocean-abyss: #130b26;

  /* Backgrounds */
  --bg-primary: #050a1a;
  --bg-secondary: rgba(10, 13, 35, 0.4);
  --bg-sidebar: rgba(5, 10, 26, 0.6);
  --bg-sidebar-hover: rgba(72, 247, 255, 0.07);
  --bg-sidebar-active: rgba(72, 247, 255, 0.12);
  --bg-card: rgba(10, 13, 35, 0.35);
  --bg-card-hover: rgba(15, 10, 32, 0.45);
  --bg-accent: rgba(168, 85, 247, 0.08);
  --bg-glass: rgba(10, 13, 35, 0.5);

  /* Text */
  --text-primary: #ccd6f6;
  --text-secondary: #8892b0;
  --text-muted: #4a5568;
  --text-accent: #64ffda;
  --text-sidebar-title: #8892b0;
  --text-heading: #e6f1ff;

  /* Ocean accent colors */
  --accent-primary: #48f7ff;        /* Neon Cyan (Erda/Sellas) */
  --accent-secondary: #818cf8;      /* Deep Sea Indigo */
  --accent-tertiary: #a855f7;       /* Electric Purple */
  --accent-warm: #fef08a;           /* Starlight */

  --accent-gradient: linear-gradient(135deg, #48f7ff, #a855f7);
  --accent-gradient-vivid: linear-gradient(135deg, #48f7ff, #818cf8);
  --accent-glow: 0 0 25px rgba(72, 247, 255, 0.25);
  --accent-glow-blue: 0 0 25px rgba(168, 85, 247, 0.25);

  /* Borders */
  --border-color: rgba(72, 247, 255, 0.12);
  --border-sidebar: rgba(72, 247, 255, 0.06);
  --border-glow: rgba(72, 247, 255, 0.2);

  /* Layout */
  --sidebar-width: 280px;
  --header-height: 60px;
  --content-max-width: 860px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(100, 255, 218, 0.08);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-float: 3s ease-in-out;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Global Scrollbar & Selection --- */
::selection {
  background: rgba(72, 247, 255, 0.3);
  color: #ffffff;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(72, 247, 255, 0.2);
  border-radius: 5px;
  border: 2px solid var(--bg-primary);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(72, 247, 255, 0.4);
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  overflow-x: hidden;
  min-height: 100vh;
  /* Deep ocean gradient background */
  background: linear-gradient(180deg,
    var(--ocean-surface) 0%,
    var(--ocean-mid) 30%,
    var(--ocean-deep) 70%,
    var(--ocean-abyss) 100%
  );
  background-attachment: fixed;
}

/* --- Ambient Ocean Particles (CSS-only) --- */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(1px 1px at 10% 20%, rgba(100, 255, 218, 0.3), transparent),
    radial-gradient(1.5px 1.5px at 25% 45%, rgba(56, 189, 248, 0.25), transparent),
    radial-gradient(1px 1px at 40% 15%, rgba(100, 255, 218, 0.2), transparent),
    radial-gradient(2px 2px at 55% 60%, rgba(129, 140, 248, 0.2), transparent),
    radial-gradient(1px 1px at 70% 35%, rgba(56, 189, 248, 0.3), transparent),
    radial-gradient(1.5px 1.5px at 85% 75%, rgba(100, 255, 218, 0.15), transparent),
    radial-gradient(1px 1px at 15% 80%, rgba(129, 140, 248, 0.2), transparent),
    radial-gradient(1px 1px at 60% 90%, rgba(56, 189, 248, 0.2), transparent),
    radial-gradient(1.5px 1.5px at 90% 10%, rgba(100, 255, 218, 0.25), transparent),
    radial-gradient(1px 1px at 35% 55%, rgba(56, 189, 248, 0.15), transparent),
    radial-gradient(1px 1px at 50% 30%, rgba(100, 255, 218, 0.2), transparent),
    radial-gradient(2px 2px at 75% 50%, rgba(129, 140, 248, 0.15), transparent),
    radial-gradient(1px 1px at 20% 65%, rgba(56, 189, 248, 0.2), transparent),
    radial-gradient(1.5px 1.5px at 80% 85%, rgba(100, 255, 218, 0.2), transparent),
    radial-gradient(1px 1px at 45% 75%, rgba(129, 140, 248, 0.15), transparent);
  pointer-events: none;
  z-index: 0;
  animation: floatParticles 20s ease-in-out infinite alternate;
}

@keyframes floatParticles {
  0% { transform: translateY(0) translateX(0); opacity: 0.6; }
  50% { opacity: 1; }
  100% { transform: translateY(-30px) translateX(15px); opacity: 0.6; }
}

/* --- Layout Shell --- */
.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ========================================
   SIDEBAR — Depth Gauge
   ======================================== */

.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transform: translateX(-100%);
  transition: transform var(--transition-slow);
  overflow: hidden;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(7, 13, 26, 0.92);
}

/* Subtle depth line on sidebar right */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg,
    rgba(100, 255, 218, 0.2) 0%,
    rgba(56, 189, 248, 0.1) 50%,
    rgba(129, 140, 248, 0.05) 100%
  );
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-sidebar);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.sidebar-logo .logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  box-shadow: var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.2);
  flex-shrink: 0;
  position: relative;
  animation: iconPulse 4s ease-in-out infinite;
}

@keyframes iconPulse {
  0%, 100% { box-shadow: var(--accent-glow); }
  50% { box-shadow: 0 0 35px rgba(100, 255, 218, 0.25), 0 0 60px rgba(100, 255, 218, 0.08); }
}

.sidebar-logo .logo-text {
  display: flex;
  flex-direction: column;
}

.sidebar-logo .logo-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-logo .logo-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
  letter-spacing: 0.3px;
}

/* Search */
.sidebar-search {
  padding: 12px 16px;
  flex-shrink: 0;
}

.sidebar-search input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background: rgba(100, 255, 218, 0.03);
  border: 1px solid rgba(100, 255, 218, 0.08);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-normal);
}

.sidebar-search input::placeholder {
  color: var(--text-muted);
}

.sidebar-search input:focus {
  border-color: rgba(100, 255, 218, 0.3);
  background: rgba(100, 255, 218, 0.05);
  box-shadow: 0 0 0 3px rgba(100, 255, 218, 0.06), 0 0 20px rgba(100, 255, 218, 0.05);
}

.sidebar-search-wrapper {
  position: relative;
}

.sidebar-search-wrapper::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  pointer-events: none;
  opacity: 0.5;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 255, 218, 0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(100, 255, 218, 0.15);
  border-radius: 2px;
}

.nav-section { margin-bottom: 4px; }

.nav-section-title {
  padding: 10px 20px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-sidebar-title);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: color var(--transition-fast);
}

.nav-section-title:hover { color: var(--accent-primary); }

.nav-section-title .toggle-icon {
  font-size: 10px;
  transition: transform var(--transition-normal);
  opacity: 0.5;
}

.nav-section-title .toggle-icon.collapsed { transform: rotate(-90deg); }

.nav-section-items {
  overflow: hidden;
  transition: max-height var(--transition-normal);
}

/* Subsection */
.nav-subsection { margin-bottom: 2px; }

.nav-subsection-title {
  padding: 7px 20px 5px 32px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-sidebar-title);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: color var(--transition-fast);
  opacity: 0.85;
}

.nav-subsection-title:hover { color: var(--accent-primary); opacity: 1; }

.nav-subsection-title .toggle-icon {
  font-size: 9px;
  transition: transform var(--transition-normal);
  opacity: 0.5;
}

.nav-subsection-title .toggle-icon.collapsed { transform: rotate(-90deg); }

.nav-subsection .nav-item {
  padding-left: 40px;
  font-size: 12.5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px 8px 28px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  position: relative;
}

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

.nav-item.active {
  color: var(--accent-primary);
  background: var(--bg-sidebar-active);
  border-left-color: var(--accent-primary);
  font-weight: 500;
}

/* Bioluminescent glow on active item */
.nav-item.active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-primary);
  box-shadow: 0 0 12px rgba(100, 255, 218, 0.4);
}

.nav-item .item-icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.nav-item .item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-empty {
  padding: 8px 20px 8px 28px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

.nav-item .item-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(100, 255, 218, 0.1);
  color: var(--accent-primary);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.nav-item.active .item-number {
  background: var(--accent-primary);
  color: var(--ocean-deep);
  box-shadow: 0 0 10px rgba(100, 255, 218, 0.3);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-sidebar);
  flex-shrink: 0;
}

.sidebar-footer-text {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.sidebar-footer-text a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.sidebar-footer-text a:hover { opacity: 0.8; }

/* Sidebar extras */
.nav-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-glow), transparent);
  margin: 6px 16px;
}

.nav-home { padding: 10px 20px; }


/* ========================================
   MAIN CONTENT AREA
   ======================================== */

.main-wrapper {
  flex: 1;
  margin-left: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header — Frosted Glass */
.main-header {
  height: var(--header-height);
  background: rgba(6, 16, 30, 0.75);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.mobile-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(10, 13, 35, 0.8);
  border: 1px solid rgba(72, 247, 255, 0.3);
  color: var(--accent-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  text-shadow: 0 0 10px rgba(72, 247, 255, 0.5);
  animation: pulseNeon 2s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu-btn:hover {
  text-shadow: 0 0 20px rgba(72, 247, 255, 0.9);
  background: rgba(72, 247, 255, 0.1);
  transform: scale(1.05);
  color: white;
}

@keyframes pulseNeon {
  0%, 100% { box-shadow: 0 0 10px rgba(72, 247, 255, 0.2); }
  50% { box-shadow: 0 0 20px rgba(72, 247, 255, 0.6); border-color: rgba(72, 247, 255, 0.8); }
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
}

.breadcrumb-separator {
  color: var(--text-muted);
  font-size: 11px;
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.header-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.header-btn:hover {
  color: var(--accent-primary);
  border-color: rgba(100, 255, 218, 0.3);
  background: rgba(100, 255, 218, 0.05);
}

.header-btn.active {
  color: #fff;
  border-color: rgba(72, 247, 255, 0.6);
  background: rgba(72, 247, 255, 0.15);
  box-shadow: 0 0 10px rgba(72, 247, 255, 0.3);
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

/* Content Area */
.main-content {
  flex: 1;
  padding: 32px 40px;
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
}


/* ========================================
   CONTENT STYLES — Material Pages
   ======================================== */

.material-content {
  animation: riseFromDepth 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes riseFromDepth {
  from {
    opacity: 0;
    transform: translateY(20px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* Headings */
.material-content h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
  line-height: 1.3;
}

.material-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-heading);
  margin: 2.5rem 0 12px;
  padding-bottom: 8px;
  padding-top: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
}

.material-content h2:first-of-type {
  border-top: none;
  padding-top: 0;
}

.material-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent-secondary);
  margin: 1.8rem 0 8px;
}

.material-content p {
  margin-bottom: 16px;
  color: var(--text-primary);
  line-height: 1.8;
}

.material-content .lead {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 2rem;
  border-left: 3px solid var(--accent-primary);
  padding-left: 16px;
}

.material-content ul, .material-content ol {
  padding-left: 24px;
  margin: 0.8rem 0;
}

.material-content li {
  margin-bottom: 6px;
  color: var(--text-primary);
  line-height: 1.7;
}

.material-content li .katex { font-size: 1em; }

.material-content strong { color: var(--text-heading); }

.material-content a {
  color: var(--accent-primary);
  text-decoration: none;
  border-bottom: 1px solid rgba(100, 255, 218, 0.2);
  transition: all var(--transition-fast);
}

.material-content a:hover {
  border-bottom-color: var(--accent-primary);
  text-shadow: 0 0 8px rgba(100, 255, 218, 0.3);
}

/* Tables — Deep Ocean */
.material-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.92rem;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.material-content thead th {
  background: rgba(100, 255, 218, 0.07);
  color: var(--accent-primary);
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid rgba(100, 255, 218, 0.1);
}

.material-content tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: top;
}

.material-content tbody tr:last-child td { border-bottom: none; }

.material-content tbody tr:hover {
  background: rgba(100, 255, 218, 0.03);
}

/* Code */
.material-content code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  background: rgba(100, 255, 218, 0.08);
  color: var(--accent-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}

.material-content pre {
  background: var(--ocean-abyss);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin: 1.2rem 0;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.65;
}

.material-content pre code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  color: #c9d1d9;
  background: none;
  padding: 0;
  border: none;
  font-size: inherit;
}

.material-content img {
  max-width: 100%;
  border-radius: var(--radius-md);
  margin: 16px 0;
  box-shadow: var(--shadow-md);
}

/* Blockquotes */
.material-content blockquote {
  border-left: 3px solid var(--accent-secondary);
  background: rgba(56, 189, 248, 0.05);
  padding: 14px 20px;
  margin: 1.2rem 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-primary);
  font-style: italic;
}

.material-content blockquote p { margin: 0; }

/* KaTeX */
.material-content .katex-display {
  margin: 1.2rem 0;
  padding: 14px 18px;
  background: rgba(4, 14, 31, 0.6);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  overflow-y: hidden;
}

.material-content .katex {
  font-size: 1.1em;
  color: var(--text-primary);
}


/* ========================================
   INFO CARDS — Underwater Glass
   ======================================== */

.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin: 1.5rem 0;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 rgba(100, 255, 218, 0.1);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

/* Subtle shimmer on hover */
.info-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 50%,
    rgba(100, 255, 218, 0.03) 0%,
    transparent 50%
  );
  opacity: 0;
  transition: opacity var(--transition-slow);
  pointer-events: none;
  z-index: 0;
}

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

.info-card:hover {
  border-color: rgba(100, 255, 218, 0.12);
  box-shadow: var(--shadow-glow);
}

.info-card.accent {
  border-left: 3px solid var(--accent-primary);
  background: linear-gradient(135deg,
    rgba(100, 255, 218, 0.04),
    rgba(56, 189, 248, 0.03)
  );
}

.info-card h3 {
  margin-top: 0;
  font-size: 1.05rem;
  color: var(--accent-primary);
}

.info-card p:last-child,
.info-card ul:last-child,
.info-card table:last-child {
  margin-bottom: 0;
}


/* ========================================
   CATEGORY SELECTION — Deep Ocean Portal
   ======================================== */

.category-select {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 20px;
}

.category-header {
  text-align: center;
  margin-bottom: 40px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 36px 30px;
  cursor: pointer;
  transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(72, 247, 255, 0.2);
  will-change: transform, box-shadow;
}

/* Wave accent line on top */
.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-accent, var(--accent-gradient));
  opacity: 0.7;
  transition: all var(--transition-normal);
}

/* Bioluminescence Hover Glow */
.category-card::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0%;
  height: 0%;
  background: radial-gradient(circle, rgba(72, 247, 255, 0.15) 0%, rgba(168, 85, 247, 0.05) 50%, transparent 80%);
  transform: translate(-50%, -50%);
  transition: width 0.6s ease-out, height 0.6s ease-out, opacity 0.4s ease;
  opacity: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.category-card * {
  position: relative;
  z-index: 1; /* keep above glow */
}

.category-card:hover {
  transform: translateY(-8px) scale(1.02);
  background: var(--bg-card-hover);
  border-color: rgba(72, 247, 255, 0.4);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3), 0 0 25px rgba(72, 247, 255, 0.2), inset 0 1px 0 rgba(168, 85, 247, 0.3);
}

.category-card:hover::before { opacity: 1; height: 4px; }
.category-card:hover::after { opacity: 1; }

.category-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 8px rgba(100, 255, 218, 0.2));
}

.category-label {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 8px;
}

.category-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.category-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.category-meta span {
  background: rgba(100, 255, 218, 0.04);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(100, 255, 218, 0.08);
}

.category-sections {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-arrow {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  font-size: 1.4rem;
  color: var(--text-muted);
  opacity: 0;
  transition: all var(--transition-normal);
}

.category-card:hover .category-arrow {
  opacity: 1;
  right: 16px;
  color: var(--accent-primary);
}


/* ========================================
   BOOK COVER / TOC — Ocean Surface
   ======================================== */

.book-cover { animation: riseFromDepth 0.5s cubic-bezier(0.4, 0, 0.2, 1); }

.book-cover-header {
  text-align: center;
  padding: 48px 20px 36px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 36px;
  position: relative;
}

/* Wavy underline */
.book-cover-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 3px;
  background: var(--accent-gradient);
  border-radius: 2px;
  box-shadow: 0 0 15px rgba(100, 255, 218, 0.3);
}

.book-badge {
  display: inline-block;
  padding: 6px 18px;
  background: rgba(100, 255, 218, 0.06);
  border: 1px solid rgba(100, 255, 218, 0.15);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-primary);
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

.book-title {
  font-size: 2.8rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  letter-spacing: -1px;
  line-height: 1.2;
  filter: drop-shadow(0 0 20px rgba(100, 255, 218, 0.15));
}

.book-subtitle {
  font-size: 1.3rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: 16px;
}

.book-description {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 20px;
  line-height: 1.7;
}

.book-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.book-meta-item {
  font-size: 13px;
  color: var(--text-secondary);
}

/* TOC */
.book-toc {
  max-width: 680px;
  margin: 0 auto;
}

.book-toc-heading {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(100, 255, 218, 0.15);
}

.toc-section { margin-bottom: 24px; }

.toc-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-sidebar-title);
  margin-bottom: 8px;
  padding-left: 4px;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

/* Bioluminescent hover */
.toc-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(90deg,
    rgba(100, 255, 218, 0.06),
    transparent
  );
  transition: width var(--transition-normal);
}

.toc-item:hover::before { width: 100%; }

.toc-item:hover {
  border-color: rgba(100, 255, 218, 0.2);
  transform: translateX(4px);
  box-shadow: 0 0 20px rgba(100, 255, 218, 0.05);
}

.toc-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-gradient);
  color: var(--ocean-deep);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(100, 255, 218, 0.2);
  position: relative;
  z-index: 1;
}

.toc-title {
  flex: 1;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-primary);
  z-index: 1;
}

.toc-arrow {
  color: var(--text-muted);
  font-size: 14px;
  transition: all var(--transition-fast);
  z-index: 1;
}

.toc-item:hover .toc-arrow {
  transform: translateX(3px);
  color: var(--accent-primary);
}

.toc-empty {
  padding: 10px 16px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

/* Start Reading */
.book-start {
  text-align: center;
  padding: 32px 0 16px;
}

.btn-start {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 34px;
  background: var(--accent-gradient);
  color: var(--ocean-deep);
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: var(--accent-glow);
  position: relative;
  overflow: hidden;
}

.btn-start::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.6s;
}

.btn-start:hover::before { left: 100%; }

.btn-start:hover {
  transform: translateY(-3px);
  box-shadow: 0 0 40px rgba(100, 255, 218, 0.3), 0 8px 25px rgba(0,0,0,0.3);
}

.btn-start .btn-arrow {
  transition: transform var(--transition-fast);
}

.btn-start:hover .btn-arrow { transform: translateX(4px); }


/* ========================================
   PAGE NAVIGATION — Ocean Current
   ======================================== */

.page-number-badge {
  display: inline-block;
  padding: 4px 14px;
  background: rgba(100, 255, 218, 0.06);
  border: 1px solid rgba(100, 255, 218, 0.12);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-primary);
  margin-bottom: 16px;
  letter-spacing: 0.3px;
}

.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.page-nav-btn {
  display: flex;
  flex-direction: column;
  padding: 18px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
}

.page-nav-btn:hover {
  border-color: rgba(100, 255, 218, 0.2);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.page-nav-btn.next { text-align: right; }

.page-nav-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.page-nav-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}


/* ========================================
   LOADING SKELETON — Depth Shimmer
   ======================================== */

.content-loading { padding: 32px 0; }

.skeleton {
  background: linear-gradient(90deg,
    rgba(10, 25, 47, 0.5) 25%,
    rgba(100, 255, 218, 0.03) 50%,
    rgba(10, 25, 47, 0.5) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-title { width: 60%; height: 36px; margin-bottom: 16px; }
.skeleton-text { width: 100%; height: 16px; margin-bottom: 10px; }
.skeleton-text:nth-child(3) { width: 85%; }
.skeleton-text:nth-child(4) { width: 92%; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}


/* ========================================
   SIMULATIONS SECTION — Bioluminescent
   ======================================== */

.sims-section {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border-color);
}

.sims-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.sims-icon {
  font-size: 2rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(129, 140, 248, 0.08);
  border-radius: 12px;
  border: 1px solid rgba(129, 140, 248, 0.15);
}

.sims-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0;
}

.sims-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.sims-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Simulation Group Accordion */
.sim-group {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
  transition: border-color var(--transition-normal);
}

.sim-group:hover {
  border-color: rgba(100, 255, 218, 0.12);
}

.sim-group-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 20px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  color: var(--text-primary);
  font-family: inherit;
  transition: background var(--transition-fast);
}

.sim-group-toggle:hover {
  background: rgba(100, 255, 218, 0.03);
}

.sim-group-icon {
  font-size: 1.4rem;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid;
  flex-shrink: 0;
}

.sim-group-info { flex: 1; min-width: 0; }

.sim-group-name {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-heading);
}

.sim-group-count {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.sim-group-chevron {
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: transform var(--transition-normal);
  flex-shrink: 0;
}

.sim-group.open .sim-group-chevron {
  transform: rotate(90deg);
  color: var(--accent-primary);
}

.sim-group-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.25s ease;
  padding: 0 16px;
  text-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
}

.sim-group.open .sim-group-content {
  max-height: 2000px;
  padding: 0 16px 16px;
  gap: 8px;
}

/* Simulation Cards */
.sim-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  color: var(--text-primary);
  position: relative;
}

.sim-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(100, 255, 218, 0.15);
  box-shadow: 0 0 20px rgba(100, 255, 218, 0.05), 0 4px 20px rgba(0, 0, 0, 0.2);
  transform: translateX(4px);
}

.sim-icon {
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(100, 255, 218, 0.04);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
  transition: all var(--transition-normal);
}

.sim-card:hover .sim-icon {
  border-color: rgba(100, 255, 218, 0.2);
  box-shadow: 0 0 15px rgba(100, 255, 218, 0.1);
}

.sim-info { flex: 1; min-width: 0; }

.sim-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 3px;
}

.sim-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sim-badge {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(100, 255, 218, 0.04);
  border: 1px solid rgba(100, 255, 218, 0.08);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.sim-arrow {
  font-size: 1.1rem;
  color: var(--text-muted);
  opacity: 0;
  transition: all var(--transition-normal);
  flex-shrink: 0;
}

.sim-card:hover .sim-arrow {
  opacity: 1;
  color: var(--accent-primary);
}


/* ========================================
   SIDEBAR OVERLAY
   ======================================== */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.1);
  z-index: 90;
}
.sidebar-overlay.active { display: block; }


/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .main-content { padding: 20px 16px; }
  .material-content h1 { font-size: 1.6rem; }
  .book-title { font-size: 2rem; }
  .book-subtitle { font-size: 1.1rem; }
  .page-nav { grid-template-columns: 1fr; }
  .toc-item { padding: 10px 12px; }
}

@media (max-width: 640px) {
  .category-grid { grid-template-columns: 1fr; }
  .category-card { padding: 24px 20px; }
  .sim-card { padding: 12px 14px; gap: 10px; }
  .sim-badge { display: none; }
  .sim-desc { white-space: normal; }
}

@media (max-width: 480px) {
  .book-meta { flex-direction: column; gap: 8px; }
}

/* Print */
@media print {
  .sidebar, .main-header, .sidebar-overlay, .page-nav { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .material-content { max-width: 100%; }
  body::before { display: none; }
}

/* ========================================
   Intro Animation Overlay
   ======================================== */
.intro-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: var(--ocean-abyss);
  z-index: 99999;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1), transform 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center center;
}

.intro-overlay.hidden {
  opacity: 0;
  transform: scale(1.1);
  pointer-events: none;
}

.intro-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.intro-logo {
  font-size: 5rem;
  opacity: 0;
  transform: translateY(30px);
  animation: introRise 2.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s forwards;
  filter: drop-shadow(0 0 20px rgba(100, 255, 218, 0.4));
}

.intro-title {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  opacity: 0;
  transform: translateY(20px);
  animation: introRise 2.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0.8s forwards;
}

.intro-subtitle {
  font-size: 1.3rem;
  color: var(--text-secondary);
  font-weight: 300;
  letter-spacing: 0.25em;
  opacity: 0;
  animation: introFade 2s ease 1.6s forwards;
}

@keyframes introRise {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes introFade {
  to { opacity: 1; }
}

/* Page entrance */
body.intro-active .app-shell,
body.intro-active #ocean-canvas {
  opacity: 0;
}

body .app-shell,
body #ocean-canvas {
  transition: opacity 2.5s ease 0.5s;
}


/* ========================================================================= */
/* Floating Mini TOC (Right Side) */
/* ========================================================================= */
.toc-mini {
  position: fixed;
  top: 100px;
  right: 20px;
  width: 250px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  background: rgba(10, 13, 35, 0.4);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(72, 247, 255, 0.15);
  border-radius: 12px;
  padding: 16px;
  z-index: 50;
  display: none; /* Shown dynamically by JS */
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: opacity 0.3s ease;
}

@media (max-width: 1300px) {
  .toc-mini {
    display: none !important;
  }
}

.toc-mini::-webkit-scrollbar {
  width: 4px;
}
.toc-mini::-webkit-scrollbar-track {
  background: transparent;
}
.toc-mini::-webkit-scrollbar-thumb {
  background: rgba(72, 247, 255, 0.2);
  border-radius: 4px;
}

.toc-mini-title {
  color: #ccd6f6;
  font-weight: bold;
  font-size: 0.95rem;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(72, 247, 255, 0.2);
}

.toc-mini ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-mini li {
  margin-bottom: 8px;
}

.toc-mini a {
  color: #8b9bb4;
  text-decoration: none;
  font-size: 0.85rem;
  display: block;
  transition: all 0.2s ease;
  padding-left: 10px;
  border-left: 2px solid transparent;
  line-height: 1.4;
}

.toc-mini a:hover {
  color: #ccd6f6;
  border-left-color: rgba(72,247,255,0.5);
}

.toc-mini a.active {
  color: #48f7ff;
  font-weight: 600;
  border-left-color: #48f7ff;
  text-shadow: 0 0 8px rgba(72,247,255,0.4);
}

.toc-mini .toc-level-3 {
  padding-left: 20px;
  font-size: 0.8rem;
}

/* ========================================================================= */
/* Progress Tracker (Completion) */
/* ========================================================================= */
.nav-link-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.nav-status {
  font-size: 0.85rem;
  color: #4a5568;
  margin-left: 8px;
  opacity: 0.5;
  transition: all 0.3s;
}
.nav-status.completed {
  color: #48f7ff;
  opacity: 1;
  text-shadow: 0 0 8px rgba(72,247,255,0.6);
}

.progress-action {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px dashed rgba(72, 247, 255, 0.2);
  text-align: center;
}

.btn-complete {
  background: rgba(10, 13, 35, 0.8);
  border: 1px solid rgba(72, 247, 255, 0.4);
  color: rgba(255, 255, 255, 0.8);
  padding: 14px 28px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-complete:hover {
  background: rgba(72, 247, 255, 0.1);
  box-shadow: 0 0 15px rgba(72, 247, 255, 0.3);
  color: #fff;
}

.btn-complete.completed-state {
  background: rgba(72, 247, 255, 0.15);
  color: #48f7ff;
  border-color: #48f7ff;
  box-shadow: 0 0 20px rgba(72, 247, 255, 0.2);
}
