/* Switzer Font Family */
@font-face {
  font-family: 'Switzer';
  src: local('Switzer-Regular'), url('fonts/Switzer-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Switzer';
  src: local('Switzer-Medium'), url('fonts/Switzer-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Switzer';
  src: local('Switzer-Bold'), url('fonts/Switzer-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Switzer';
  src: local('Switzer-Extrabold'), url('fonts/Switzer-Extrabold.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

/* Design System Variables */
:root {
  /* Primary Colors */
  --primary: #6CC5A2;
  --primary-dark: #60B997;
  --primary-light: #78D1AD;
  
  /* General Colors */
  --red: #F03A3A;
  --gray: #D4D3D3;
  --black: #161616;
  --white: #FFFFFF;
  --yellow: #EED202;
  --dark-gray: #3B3B3B;
  --light-gray: #F0F0F0;
  
  /* Light Theme (default) */
  --background: #FFFFFF;
  --card: #F4F4F4;
  --text: #161616;
  --border: #D4D4D4;
  --shadow: rgba(35, 35, 35, 0.1);
  --text-secondary: #3B3B3B;
  
  /* Typography */
  --font-family: 'Switzer', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Arial, sans-serif;
}

/* Dark Theme */
body.dark-theme {
  --background: #181818;
  --card: #232323;
  --text: #FFFFFF;
  --border: #2D2D2D;
  --shadow: rgba(45, 45, 45, 0.5);
  --text-secondary: #D4D3D3;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-weight: normal;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header */
header {
  background: var(--card);
  color: var(--text);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 4px var(--shadow);
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

/* Navigation */
nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Language Selector Wrapper */
.lang-select-wrapper {
  position: relative;
  display: inline-block;
}

.lang-select-wrapper::after {
  content: '';
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%) rotate(0deg);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-secondary);
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              border-top-color 0.3s ease;
  z-index: 1;
}

/* Arrow color change on hover */
.lang-select-wrapper:hover::after {
  border-top-color: var(--primary);
}

/* Arrow rotation when dropdown is open */
.lang-select-wrapper.open::after,
.lang-select-wrapper:has(select:focus)::after {
  border-top-color: var(--primary);
  transform: translateY(-50%) rotate(180deg);
}

nav select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: var(--background);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 2.5rem 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: var(--font-family);
  font-weight: 500;
  min-width: 120px;
  outline: none;
  transition: border-color 0.2s ease;
}

/* Remove default focus outline - we'll add custom for keyboard navigation only */
nav select:focus {
  outline: none;
}

/* Accessibility: Show focus indicator only for keyboard navigation */
nav select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Remove any persistent focus styles */
nav select:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

nav select option {
  background: var(--card);
  color: var(--text);
  padding: 0.5rem;
}

/* Theme Toggle Button */
.theme-toggle {
  background: var(--background);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  font-family: var(--font-family);
  font-weight: 500;
}

.theme-toggle:hover {
  border-color: var(--primary);
  background: var(--card);
}

/* Main Content */
main {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px var(--shadow);
  position: relative;
}

section[data-lang] {
  display: none;
  padding: 2.5rem;
  min-height: 400px;
}

/* Typography */
section h2 {
  margin-top: 0;
  padding-top: 1rem;
  scroll-margin-top: 1rem;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

section h3 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-top: 1rem;
  scroll-margin-top: 1rem;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
}

section h4 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  scroll-margin-top: 1rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-secondary);
}

section p {
  margin-bottom: 1.2rem;
  text-align: justify;
  font-weight: 400;
  color: var(--text);
}

section ul, section ol {
  margin-bottom: 1.5rem;
  padding-left: 2rem;
}

section li {
  margin-bottom: 0.5rem;
  color: var(--text);
}

section strong {
  font-weight: 600;
  color: var(--text);
}

section a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, color 0.2s;
  font-weight: 500;
}

section a:hover {
  border-bottom-color: var(--primary);
  color: var(--primary-dark);
}

/* Table of Contents */
.toc {
  background: var(--background);
  border-left: 4px solid var(--primary);
  padding: 1.5rem;
  margin-bottom: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow);
}

.toc h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

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

.toc li {
  margin-bottom: 0.5rem;
}

.toc a {
  color: var(--text-secondary);
  text-decoration: none;
  display: block;
  padding: 0.4rem 0;
  transition: color 0.2s, padding-left 0.2s;
  font-weight: 400;
}

.toc a:hover {
  color: var(--primary);
  padding-left: 0.5rem;
}

.toc li.level-2 {
  padding-left: 0;
}

.toc li.level-3 {
  padding-left: 1.5rem;
  font-size: 0.95rem;
}

.toc li.level-4 {
  padding-left: 3rem;
  font-size: 0.9rem;
}

/* Back to top button */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--shadow);
  transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              box-shadow 0.3s ease;
  z-index: 1000;
  padding: 0;
}

/* Custom arrow pointing up */
.back-to-top::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 8px solid var(--white);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.back-to-top:hover {
  background: var(--primary-dark);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(108, 197, 162, 0.4);
}

.back-to-top:hover::before {
  transform: translate(-50%, -60%);
}

.back-to-top:active {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow);
}

.back-to-top.visible {
  display: flex;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* Tables */
section table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  overflow-x: auto;
  display: block;
  background: var(--background);
  border-radius: 8px;
  border: 1px solid var(--border);
}

section table th,
section table td {
  border: 1px solid var(--border);
  padding: 0.75rem;
  text-align: left;
}

section table th {
  background: var(--card);
  font-weight: 600;
  color: var(--text);
}

section table td {
  color: var(--text);
}

/* Images */
section img {
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow);
}

/* Blockquotes */
section blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--background);
  padding: 1rem 1.5rem;
  border-radius: 4px;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
  body {
    padding: 0;
  }

  main {
    margin: 0.75rem;
    padding: 0;
    border-radius: 8px;
    max-width: calc(100% - 1.5rem);
  }

  section[data-lang] {
    padding: 1.5rem 1.25rem;
  }

  header {
    padding: 1rem 1.25rem;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  header h1 {
    font-size: 1.3rem;
  }

  nav {
    width: 100%;
    justify-content: space-between;
  }

  nav select {
    min-width: 110px;
    padding: 0.5rem 0.875rem;
    font-size: 0.85rem;
  }

  .back-to-top {
    bottom: 1.25rem;
    right: 1.25rem;
    width: 45px;
    height: 45px;
    font-size: 1rem;
  }

  .toc {
    padding: 1.25rem;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
  }

  section h2 {
    font-size: 1.6rem;
    padding-bottom: 0.75rem;
  }

  section h3 {
    font-size: 1.2rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
  }

  section p {
    margin-bottom: 1rem;
    text-align: left;
  }

  section ul,
  section ol {
    padding-left: 1.5rem;
    margin-bottom: 1.25rem;
  }

  section blockquote {
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
  }

  section table {
    font-size: 0.85rem;
  }

  section table th,
  section table td {
    padding: 0.5rem;
  }

  footer {
    padding: 1.5rem 1.25rem;
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  main {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
    border-radius: 6px;
  }

  section[data-lang] {
    padding: 1.25rem 1rem;
  }

  header {
    padding: 0.875rem 1rem;
  }

  header h1 {
    font-size: 1.2rem;
  }

  section h2 {
    font-size: 1.4rem;
  }

  section h3 {
    font-size: 1.1rem;
  }

  .toc {
    padding: 1rem;
    font-size: 0.85rem;
  }

  .back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
  }

  .back-to-top::before {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 7px solid var(--white);
  }
}

/* Print styles for long documents */
@media print {
  :root {
    --background: #FFFFFF;
    --card: #FFFFFF;
    --text: #000000;
    --border: #000000;
    --shadow: transparent;
  }

  header {
    background: white;
    color: black;
    border-bottom: 2px solid #000;
    box-shadow: none;
  }

  nav,
  .theme-toggle,
  .back-to-top {
    display: none;
  }

  .toc {
    page-break-after: always;
    border: 1px solid #ccc;
    background: white;
    box-shadow: none;
  }

  section[data-lang] {
    page-break-inside: avoid;
    padding: 1rem;
  }

  section h2,
  section h3 {
    page-break-after: avoid;
  }

  main {
    box-shadow: none;
    max-width: 100%;
    border: none;
  }

  footer {
    page-break-inside: avoid;
  }

  section a {
    color: #000;
    text-decoration: underline;
  }
}
