/* Material Design 3 - Custom Implementation */

/* Font Declarations */
/* Inter will be loaded from Google Fonts */
/* Keep Google Sans Mono for code elements */
@font-face {
  font-family: 'Google Sans Mono';
  src: url('../css/font/GoogleSansMono-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Material 3 Color Tokens - Light Theme */
  --md-sys-color-primary: #6750A4;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #EADDFF;
  --md-sys-color-on-primary-container: #21005D;
  
  --md-sys-color-secondary: #625B71;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #E8DEF8;
  --md-sys-color-on-secondary-container: #1D192B;
  
  --md-sys-color-tertiary: #7D5260;
  --md-sys-color-on-tertiary: #FFFFFF;
  --md-sys-color-tertiary-container: #FFD8E4;
  --md-sys-color-on-tertiary-container: #31111D;
  
  --md-sys-color-surface: #FFFBFE;
  --md-sys-color-on-surface: #1C1B1F;
  --md-sys-color-surface-variant: #E7E0EC;
  --md-sys-color-on-surface-variant: #49454F;
  --md-sys-color-surface-container: #F3EDF7;
  --md-sys-color-surface-container-low: #F7F2FA;
  --md-sys-color-surface-container-high: #ECE6F0;
  --md-sys-color-surface-container-highest: #E6E0E9;
  
  --md-sys-color-background: #FFFBFE;
  --md-sys-color-on-background: #1C1B1F;
  
  --md-sys-color-outline: #79747E;
  --md-sys-color-outline-variant: #CAC4D0;
  
  /* Dark Theme */
  --md-sys-color-primary-dark: #D0BCFF;
  --md-sys-color-on-primary-dark: #381E72;
  --md-sys-color-primary-container-dark: #4F378B;
  --md-sys-color-on-primary-container-dark: #EADDFF;
  
  --md-sys-color-secondary-dark: #CCC2DC;
  --md-sys-color-on-secondary-dark: #332D41;
  --md-sys-color-secondary-container-dark: #4A4458;
  --md-sys-color-on-secondary-container-dark: #E8DEF8;
  
  --md-sys-color-surface-dark: #10121C;
  --md-sys-color-on-surface-dark: #E6E0E9;
  --md-sys-color-surface-variant-dark: #49454F;
  --md-sys-color-on-surface-variant-dark: #CAC4D0;
  --md-sys-color-surface-container-dark: #211F26;
  --md-sys-color-surface-container-low-dark: #1C1B1F;
  --md-sys-color-surface-container-high-dark: #2B2930;
  --md-sys-color-surface-container-highest-dark: #36343B;
  
  --md-sys-color-background-dark: #10121C;
  --md-sys-color-on-background-dark: #E6E0E9;
  
  --md-sys-color-outline-dark: #938F99;
  --md-sys-color-outline-variant-dark: #49454F;
  
  /* Material 3 Typography - Using Inter */
  --md-sys-typescale-display-large-font: 'Inter', system-ui, sans-serif;
  --md-sys-typescale-display-large-size: 57px;
  --md-sys-typescale-display-large-line-height: 64px;
  --md-sys-typescale-display-large-weight: 300;
  
  --md-sys-typescale-headline-large-font: 'Inter', system-ui, sans-serif;
  --md-sys-typescale-headline-large-size: 32px;
  --md-sys-typescale-headline-large-line-height: 40px;
  --md-sys-typescale-headline-large-weight: 500;
  
  --md-sys-typescale-body-large-font: 'Inter', system-ui, sans-serif;
  --md-sys-typescale-body-large-size: 16px;
  --md-sys-typescale-body-large-line-height: 24px;
  --md-sys-typescale-body-large-weight: 400;
  
  --md-sys-typescale-body-medium-font: 'Inter', system-ui, sans-serif;
  --md-sys-typescale-body-medium-size: 14px;
  --md-sys-typescale-body-medium-line-height: 20px;
  --md-sys-typescale-body-medium-weight: 400;
  
  --md-sys-typescale-label-large-font: 'Inter', system-ui, sans-serif;
  --md-sys-typescale-label-large-size: 14px;
  --md-sys-typescale-label-large-line-height: 20px;
  --md-sys-typescale-label-large-weight: 600;
  
  /* Material 3 Elevation */
  --md-sys-elevation-1: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-2: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.3);
  --md-sys-elevation-4: 0px 6px 10px 4px rgba(0, 0, 0, 0.15), 0px 2px 3px 0px rgba(0, 0, 0, 0.3);
  --md-sys-elevation-5: 0px 8px 12px 6px rgba(0, 0, 0, 0.15), 0px 4px 4px 0px rgba(0, 0, 0, 0.3);
  
  /* Shape tokens */
  --md-sys-shape-corner-extra-small: 4px;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-extra-large: 28px;
}

/* Dark theme styles */
[data-theme="dark"] {
  --md-sys-color-primary: var(--md-sys-color-primary-dark);
  --md-sys-color-on-primary: var(--md-sys-color-on-primary-dark);
  --md-sys-color-primary-container: var(--md-sys-color-primary-container-dark);
  --md-sys-color-on-primary-container: var(--md-sys-color-on-primary-container-dark);
  
  --md-sys-color-secondary: var(--md-sys-color-secondary-dark);
  --md-sys-color-on-secondary: var(--md-sys-color-on-secondary-dark);
  --md-sys-color-secondary-container: var(--md-sys-color-secondary-container-dark);
  --md-sys-color-on-secondary-container: var(--md-sys-color-on-secondary-container-dark);
  
  --md-sys-color-surface: var(--md-sys-color-surface-dark);
  --md-sys-color-on-surface: var(--md-sys-color-on-surface-dark);
  --md-sys-color-surface-variant: var(--md-sys-color-surface-variant-dark);
  --md-sys-color-on-surface-variant: var(--md-sys-color-on-surface-variant-dark);
  --md-sys-color-surface-container: var(--md-sys-color-surface-container-dark);
  --md-sys-color-surface-container-low: var(--md-sys-color-surface-container-low-dark);
  --md-sys-color-surface-container-high: var(--md-sys-color-surface-container-high-dark);
  --md-sys-color-surface-container-highest: var(--md-sys-color-surface-container-highest-dark);
  
  --md-sys-color-background: var(--md-sys-color-background-dark);
  --md-sys-color-on-background: var(--md-sys-color-on-background-dark);
  
  --md-sys-color-outline: var(--md-sys-color-outline-dark);
  --md-sys-color-outline-variant: var(--md-sys-color-outline-variant-dark);
}

/* Base styles */
* {
  box-sizing: border-box;
}

/* Remove default browser outline and focus styles */
*:focus {
    outline: none;
}

/* Custom focus styles for better accessibility */
button:focus-visible,
.md3-button:focus-visible,
.md3-chip:focus-visible,
.md3-fab:focus-visible,
.md3-icon-button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

/* Remove tap highlight on mobile */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection for content elements */
p, h1, h2, h3, h4, h5, h6, span, .md3-body-large, .md3-body-medium, .md3-headline-large, .md3-display-large, input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Google Sans Rounded', system-ui, sans-serif;
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
  background-color: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Material 3 App Bar */
.md3-top-app-bar {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: 64px;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--md-sys-elevation-2);
  display: flex;
  align-items: center;
  padding: 0 16px;
}

.md3-top-app-bar-title {
  font-family: var(--md-sys-typescale-headline-large-font);
  font-size: 22px;
  font-weight: 400;
  margin-left: 16px;
  flex: 1;
}

.md3-icon-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--md-sys-color-on-surface);
  transition: background-color 0.2s ease;
}

.md3-icon-button:hover {
  background-color: var(--md-sys-color-on-surface);
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

/* Material 3 Navigation Rail */
.md3-navigation-rail {
  position: fixed;
  left: 0;
  top: 64px;
  width: 80px;
  height: calc(100vh - 64px);
  background-color: var(--md-sys-color-surface);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 100;
  box-shadow: var(--md-sys-elevation-1);
}

.md3-navigation-rail-item {
  width: 56px;
  height: 56px;
  border-radius: var(--md-sys-shape-corner-large);
  margin: 4px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--md-sys-color-on-surface-variant);
  position: relative;
}

.md3-navigation-rail-item.active {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.md3-navigation-rail-item:hover:not(.active) {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

/* Material 3 Cards */
.md3-card {
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-1);
  transition: all 0.2s ease;
  overflow: hidden;
}

.md3-card:hover {
  box-shadow: var(--md-sys-elevation-2);
}

.md3-card-elevated {
  background-color: var(--md-sys-color-surface-container-low);
  box-shadow: var(--md-sys-elevation-1);
}

.md3-card-filled {
  background-color: var(--md-sys-color-surface-container-highest);
  box-shadow: none;
}

.md3-card-outlined {
  background-color: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: none;
}

.md3-card-content {
  padding: 16px;
}

.md3-card-header {
  padding: 16px 16px 0 16px;
}

.md3-card-actions {
  padding: 8px 16px 16px 16px;
  display: flex;
  gap: 8px;
}

/* Material 3 Typography */
.md3-display-large {
  font-family: var(--md-sys-typescale-display-large-font);
  font-size: var(--md-sys-typescale-display-large-size);
  line-height: var(--md-sys-typescale-display-large-line-height);
  font-weight: var(--md-sys-typescale-display-large-weight);
  color: var(--md-sys-color-on-surface);
  margin: 0;
}

.md3-headline-large {
  font-family: var(--md-sys-typescale-headline-large-font);
  font-size: var(--md-sys-typescale-headline-large-size);
  line-height: var(--md-sys-typescale-headline-large-line-height);
  font-weight: var(--md-sys-typescale-headline-large-weight);
  color: var(--md-sys-color-on-surface);
  margin: 0 0 16px 0;
}

.md3-body-large {
  font-family: var(--md-sys-typescale-body-large-font);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
  font-weight: var(--md-sys-typescale-body-large-weight);
  color: var(--md-sys-color-on-surface);
  margin: 0 0 16px 0;
}

.md3-body-medium {
  font-family: var(--md-sys-typescale-body-medium-font);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
  font-weight: var(--md-sys-typescale-body-medium-weight);
  color: var(--md-sys-color-on-surface-variant);
  margin: 0 0 12px 0;
}

/* Material 3 Buttons */
.md3-button {
  height: 40px;
  border-radius: var(--md-sys-shape-corner-extra-large);
  padding: 0 24px;
  border: none;
  cursor: pointer;
  font-family: var(--md-sys-typescale-label-large-font);
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.md3-button-filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.md3-button-filled:hover {
  box-shadow: var(--md-sys-elevation-1);
  background-color: color-mix(in srgb, var(--md-sys-color-on-primary) 8%, var(--md-sys-color-primary));
}

.md3-button:focus {
  box-shadow: var(--md-sys-elevation-1), 0 0 0 2px var(--md-sys-color-primary);
}

.md3-button-outlined {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
}

.md3-button-outlined:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 8%, transparent);
}

.md3-button-text {
  background-color: transparent;
  color: var(--md-sys-color-primary);
}

.md3-button-text:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 8%, transparent);
}

/* Material 3 FAB */
.md3-fab {
  width: 56px;
  height: 56px;
  border-radius: var(--md-sys-shape-corner-large);
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--md-sys-elevation-3);
  transition: all 0.2s ease;
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 1000;
}

.md3-fab:hover {
  box-shadow: var(--md-sys-elevation-4);
}

.md3-fab:focus {
  box-shadow: var(--md-sys-elevation-4), 0 0 0 2px var(--md-sys-color-primary);
}

/* Material 3 Chips */
.md3-chip {
  height: 32px;
  border-radius: var(--md-sys-shape-corner-small);
  padding: 0 16px;
  border: 1px solid var(--md-sys-color-outline);
  background-color: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-family: var(--md-sys-typescale-label-large-font);
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.md3-chip:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface-variant) 8%, transparent);
}

.md3-chip:focus {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface-variant) 8%, transparent);
  box-shadow: 0 0 0 2px var(--md-sys-color-primary);
}

.md3-chip.selected {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

/* Code block styling - Minimal to preserve Prism.js original */
.md3-code-block {
  border-radius: var(--md-sys-shape-corner-medium);
  margin: 16px 0;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

/* Let Prism.js handle all the styling */
.md3-code-block pre[class*="language-"] {
  border-radius: var(--md-sys-shape-corner-medium);
  overflow-x: auto;
  max-width: 100%;
}

.md3-code-block code {
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Use local Google Sans Mono for code */
code, pre, .language-html, .language-css, .language-javascript {
  font-family: 'Google Sans Mono', 'Consolas', 'Monaco', monospace !important;
}

/* Responsive code blocks */
@media (max-width: 768px) {
  .md3-code-block {
    margin: 12px 0;
    font-size: 13px;
  }
  
  .md3-code-block pre[class*="language-"] {
    padding: 12px;
    font-size: 13px;
    line-height: 1.4;
  }
}

/* Layout */
.md3-content {
  margin-left: 80px;
  padding: 24px;
  min-height: calc(100vh - 64px);
}

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

/* Breadcrumb */
.md3-breadcrumb {
  margin: 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.md3-breadcrumb-item {
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s ease;
}

.md3-breadcrumb-item:hover {
  color: var(--md-sys-color-primary);
}

.md3-breadcrumb-item.current {
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
}

.md3-breadcrumb-separator {
  color: var(--md-sys-color-outline);
  margin: 0 4px;
}

/* Table of Contents */
.md3-toc {
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 16px;
  margin: 24px 0;
}

.md3-toc-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.md3-toc-item {
  margin: 8px 0;
}

.md3-toc-link {
  color: var(--md-sys-color-primary);
  text-decoration: none;
  font-size: 14px;
  line-height: 20px;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.md3-toc-link:hover {
  color: var(--md-sys-color-on-primary-container);
}

/* Section spacing */
.md3-section {
  margin: 32px 0;
}

.md3-section-header {
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

/* Responsive */
@media (max-width: 768px) {
  .md3-navigation-rail {
    display: none;
  }
  
  .md3-content {
    margin-left: 0;
    padding: 16px;
  }
  
  .md3-top-app-bar {
    padding: 0 16px;
  }
  
  .md3-fab {
    bottom: 16px;
    right: 16px;
  }
}

/* Smooth transitions */
* {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
