@import url('https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic:wght@400;500;700;900&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons+Round');

:root {
  /* Material Design 3 Color Tokens - Light */
  --md-sys-color-primary: #005AC1;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #D8E2FF;
  --md-sys-color-on-primary-container: #001A41;
  
  --md-sys-color-secondary: #575E71;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #DBE2F9;
  --md-sys-color-on-secondary-container: #141B2C;

  --md-sys-color-background: #FEFBFF;
  --md-sys-color-on-background: #1B1B1F;
  --md-sys-color-surface: #FEFBFF;
  --md-sys-color-on-surface: #1B1B1F;
  --md-sys-color-surface-variant: #E1E2EC;
  --md-sys-color-on-surface-variant: #44474F;
  
  --md-sys-color-outline: #75777F;
  --md-sys-color-outline-variant: #C5C6D0;

  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 16px;
  --border-radius-xl: 28px;

  --transition-speed: 0.3s;
  
  --neumorphism-shadow-dark: rgba(0, 0, 0, 0.15);
  --neumorphism-shadow-light: rgba(255, 255, 255, 0.8);
}

/* Base Dark Theme (Shared between Manual and System) */
.theme-dark {
  --md-sys-color-primary: #ADC6FF;
  --md-sys-color-on-primary: #002E69;
  --md-sys-color-primary-container: #004494;
  --md-sys-color-on-primary-container: #D8E2FF;
  
  --md-sys-color-background: #1B1B1F;
  --md-sys-color-on-background: #E3E2E6;
  --md-sys-color-surface: #1B1B1F;
  --md-sys-color-on-surface: #E3E2E6;
  --md-sys-color-surface-variant: #44474F;
  --md-sys-color-on-surface-variant: #C5C6D0;
  
  --md-sys-color-outline: #8F9099;
  --md-sys-color-outline-variant: #44474F;

  --neumorphism-shadow-dark: rgba(0, 0, 0, 0.5);
  --neumorphism-shadow-light: rgba(255, 255, 255, 0.05);
}

/* Apply Dark Theme based on Attribute OR System Preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --md-sys-color-primary: #ADC6FF;
    --md-sys-color-on-primary: #002E69;
    --md-sys-color-primary-container: #004494;
    --md-sys-color-on-primary-container: #D8E2FF;
    --md-sys-color-background: #1B1B1F;
    --md-sys-color-on-background: #E3E2E6;
    --md-sys-color-surface: #1B1B1F;
    --md-sys-color-on-surface: #E3E2E6;
    --md-sys-color-surface-variant: #44474F;
    --md-sys-color-on-surface-variant: #C5C6D0;
    --md-sys-color-outline: #8F9099;
    --md-sys-color-outline-variant: #44474F;

    --neumorphism-shadow-dark: rgba(0, 0, 0, 0.5);
    --neumorphism-shadow-light: rgba(255, 255, 255, 0.05);
  }
}

[data-theme='dark'] {
  --md-sys-color-primary: #ADC6FF;
  --md-sys-color-on-primary: #002E69;
  --md-sys-color-primary-container: #004494;
  --md-sys-color-on-primary-container: #D8E2FF;
  --md-sys-color-background: #1B1B1F;
  --md-sys-color-on-background: #E3E2E6;
  --md-sys-color-surface: #1B1B1F;
  --md-sys-color-on-surface: #E3E2E6;
  --md-sys-color-surface-variant: #44474F;
  --md-sys-color-on-surface-variant: #C5C6D0;
  --md-sys-color-outline: #8F9099;
  --md-sys-color-outline-variant: #44474F;

  --neumorphism-shadow-dark: rgba(0, 0, 0, 0.5);
  --neumorphism-shadow-light: rgba(255, 255, 255, 0.05);
}

.icon-dent {
  background: var(--md-sys-color-surface-variant);
  box-shadow: inset 8px 8px 16px var(--neumorphism-shadow-dark), 
              inset -8px -8px 16px var(--neumorphism-shadow-light);
  padding: 10px; /* Reduced from 16px to make image larger within the dent */
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  aspect-ratio: 1 / 1;
}

.icon-dent-sm {
  background: var(--md-sys-color-surface-variant);
  box-shadow: inset 3px 3px 6px var(--neumorphism-shadow-dark), 
              inset -3px -3px 6px var(--neumorphism-shadow-light);
  padding: 4px; /* Reduced from 6px */
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
}

.icon-dent img {
  border-radius: 50% !important;
  margin: 0 !important;
  border: none !important;
  object-fit: cover;
}

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

body {
  font-family: 'Zen Maru Gothic', sans-serif;
  background-color: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

.theme-toggle-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 12px;
}

.theme-toggle-btn:hover {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

a {
  color: var(--md-sys-color-primary);
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

/* Material Header - Flat */
header {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid var(--md-sys-color-outline);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.hamburger-btn:hover {
  background-color: var(--md-sys-color-surface-variant);
}

.logo {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--md-sys-color-on-surface);
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: -0.5px;
}

.logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.nav-links {
  display: flex;
  gap: 6px;
  align-items: center;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--border-radius-md);
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
  transition: background-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}

.nav-item:hover, .nav-item.active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

@media (max-width: 1024px) {
  .hamburger-btn {
    display: flex;
    order: 3;
  }
  
  .nav-links {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background-color: var(--md-sys-color-surface);
    flex-direction: column;
    padding: 80px 16px 24px;
    box-shadow: -4px 0 16px rgba(0,0,0,0.15);
    z-index: 2100;
    transition: right 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    align-items: stretch;
    overflow-y: auto;
    gap: 0;
  }

  .nav-links.active {
    right: 0;
  }

  .nav-item {
    padding: 12px 16px;
    border-radius: 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    opacity: 0.8;
  }

  .nav-dropdown {
    width: 100%;
  }

  .nav-dropdown-content {
    position: static;
    display: none;
    width: 100%;
    box-shadow: none;
    border: none;
    background-color: var(--md-sys-color-surface-variant);
    border-radius: 0;
    padding: 0;
    max-height: none;
  }

  .nav-dropdown.active .nav-dropdown-content {
    display: flex;
  }

  .nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2050;
    backdrop-filter: blur(4px);
  }

  .nav-overlay.active {
    display: block;
  }
}

/* Hero Section */
.hero {
  padding: 64px 24px;
  text-align: center;
  background-color: var(--md-sys-color-surface-variant);
  border-bottom: 1px solid var(--md-sys-color-outline);
  margin-bottom: 48px;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 24px;
  line-height: 1.3;
}

.hero p {
  font-size: 1.25rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 40px;
}

/* Material Buttons - Flat */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.btn-primary {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.btn-primary:hover {
  filter: brightness(0.9);
}

.btn-secondary {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-outline);
}

.btn-secondary:hover {
  background-color: var(--md-sys-color-primary-container);
  border-color: var(--md-sys-color-primary-container);
}

/* Main Layout */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* Grid & Cards (Flat Outline style) */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 32px;
}

.card {
  background-color: var(--md-sys-color-surface);
  border-radius: var(--border-radius-md);
  padding: 24px;
  border: 1px solid var(--md-sys-color-outline);
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s;
  display: flex;
  flex-direction: column;
}

.card:hover {
  border-color: var(--md-sys-color-primary);
  background-color: var(--md-sys-color-surface-variant);
  transform: translateY(-2px);
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-sm);
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 12px;
}

.card-desc {
  color: var(--md-sys-color-on-surface-variant);
  flex-grow: 1;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.card-action {
  align-self: flex-start;
  color: var(--md-sys-color-primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.95rem;
}

.card:hover .card-action .material-icons-round {
  transform: translateX(4px);
}


/* Seamless Tool Embed Modal/Section */
.tool-viewer-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: var(--md-sys-color-background);
  z-index: 2000;
  flex-direction: column;
}

.tool-viewer-modal.active {
  display: flex;
}

.tool-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface);
}

.tool-viewer-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-iframe-container {
  flex-grow: 1;
  width: 100%;
  position: relative;
  background: var(--md-sys-color-surface-variant);
}

.tool-iframe-container iframe {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  border: none;
}


/* Theory / Content Pages */
.content-layout {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 40px;
  margin-top: 40px;
  align-items: start;
}

@media (max-width: 1200px) {
  .content-layout {
    grid-template-columns: 280px 1fr;
  }
  .right-sidebar {
    display: none;
  }
}

@media (max-width: 900px) {
  .content-layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .sidebar, .right-sidebar {
    position: static;
    width: 100%;
  }
  .sidebar { order: 1; }
  .article-content { order: 2; padding: 24px; border-radius: 0; border-left: none; border-right: none; }
  .right-sidebar { order: 3; display: flex !important; }
}

.right-sidebar {
  position: sticky;
  top: 100px;
  height: max-content;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-card {
  background: var(--md-sys-color-surface);
  border-radius: var(--border-radius-md);
  padding: 24px;
  border: 1px solid var(--md-sys-color-outline);
}

.profile-card {
  text-align: center;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  margin-bottom: 16px;
  border: 1px solid var(--md-sys-color-outline);
}

.profile-name {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 4px;
  color: var(--md-sys-color-on-surface);
}

.profile-bio {
  font-size: 0.85rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 16px;
  line-height: 1.5;
}

.support-links-v {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.support-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface);
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  text-decoration: none;
}

.support-link-item:hover {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.sidebar {
  position: sticky;
  top: 100px;
  height: max-content;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--md-sys-color-on-surface);
  border-bottom: 2px solid var(--md-sys-color-primary-container);
  padding-bottom: 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  color: var(--md-sys-color-on-surface-variant);
  transition: background-color 0.2s, color 0.2s;
  text-decoration: none;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 700;
}

.article-content {
  background-color: var(--md-sys-color-surface);
  border-radius: var(--border-radius-md);
  padding: 48px;
  border: 1px solid var(--md-sys-color-outline);
  line-height: 1.8;
}

.article-content h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  margin-top: 48px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--md-sys-color-primary-container);
  display: flex;
  align-items: center;
  gap: 8px;
}

.article-content h2::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 24px;
  background-color: var(--md-sys-color-primary);
  border-radius: 4px;
}

.article-content h2:first-child {
  margin-top: 0;
}

.article-content h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  margin-top: 32px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.article-content h3::before {
  content: "■";
  font-size: 0.8rem;
  opacity: 0.5;
}

.article-content p {
  margin-bottom: 1.2rem;
  color: var(--md-sys-color-on-surface-variant);
}

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius-md);
  margin: 24px 0;
  border: 1px solid var(--md-sys-color-outline);
}

.video-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  max-width: 100%;
  border-radius: var(--border-radius-md);
  margin: 24px 0;
  border: 1px solid var(--md-sys-color-outline);
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.article-content h4 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--md-sys-color-secondary);
  margin-top: 24px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.article-content h4::before {
  content: "▶";
  font-size: 0.7rem;
  opacity: 0.7;
}

/* Table of Contents Styles */
.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.toc-header .toc-item-h2 {
  flex-grow: 1;
}

.toc-toggle {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  color: var(--md-sys-color-outline);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toc-toggle:hover {
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-primary);
}

.toc-group.open .toc-toggle {
  transform: rotate(180deg);
  color: var(--md-sys-color-primary);
}

.toc-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-group {
  display: flex;
  flex-direction: column;
}

.toc-item {
  display: block;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  color: var(--md-sys-color-on-surface-variant);
  transition: all 0.25s ease;
  font-size: 0.95rem;
  text-decoration: none;
  line-height: 1.4;
}

.toc-item:hover {
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-primary);
}

.toc-item.active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 700;
}

.toc-subnav {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.3s ease;
  opacity: 0;
  margin-left: 12px;
  border-left: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-group.open .toc-subnav {
  max-height: 1000px; /* Sufficient height */
  opacity: 1;
  margin-bottom: 8px;
}

.toc-item-h3 {
  font-size: 0.85rem;
  padding: 6px 16px;
}

.toc-item-h4 {
  font-size: 0.85rem;
  padding: 4px 16px;
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.8;
}

.toc-item-h4::before {
  content: "▶";
  font-size: 0.6rem;
  margin-right: 6px;
  opacity: 0.6;
}

/* Footer */
footer {
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  padding: 64px 24px;
  border-top: 1px solid var(--md-sys-color-outline);
  margin-top: 64px;
}

.footer-col h4 {
  font-family: 'Zen Maru Gothic', sans-serif;
  letter-spacing: 0.5px;
}

.footer-col nav a {
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.footer-col nav a:hover {
  color: var(--md-sys-color-primary);
}
