/* FIX: convert invalid JS-style comment to proper CSS comment */

html, body {
  height: 100%;
  margin: 0;
}

:root {
  /* EY Brand Colors */
  --ey-yellow: #ffe600;
  --ey-black: #2e2e38;
  --ey-gray-dark: #1a1a24;
  --ey-gray-medium: #747480;
  --ey-gray-light: #f5f5f5;
  --ey-white: #ffffff;

  /* Applied color scheme */
  --primary: var(--ey-yellow);
  --secondary: var(--ey-black);
  --bg: var(--ey-gray-light);
  --card: var(--ey-white);
  --text-primary: var(--ey-black);
  --text-secondary: var(--ey-gray-medium);

  /* UI Variables */
  --font: 'Inter', Arial, sans-serif;
  --rad: 4px;
  --trans: .3s;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 20px rgba(0,0,0,0.15);

  /* New semantic tokens for theming */
  --primary-hover: #e6d000; /* EY default hover for primary */
  --primary-active: #ccb800; /* EY default active for primary */
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
}

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

/* Modern animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Mobile overlay */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none; /* NEW: do not capture taps when inactive */
}
.mobile-overlay.active {
  opacity: 1;
  pointer-events: auto; /* NEW: only capture taps when active */
}

/* Hamburger menu */
.hamburger {
  display: none;
  background: var(--ey-white);
  border: none;
  font-size: 24px;
  padding: 12px;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1002;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--rad);
  box-shadow: var(--shadow-md);
  transition: all var(--trans);
}
.hamburger:hover {
  background: var(--bg);
}

@media (max-width: 768px) {
  .hamburger { display: block; }
  /* FIX: overlay must not be displayed unless active */
  .mobile-overlay { display: none; }              /* CHANGED from display: block */
  .mobile-overlay.active { display: block; }      /* NEW: show only when active */

  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1001;
    width: 280px !important;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }
  .sidebar.open { transform: translateX(0); }
  .content {
    margin-left: 0 !important;
    padding: 80px 20px 20px !important;
    padding-bottom: 100px !important; /* Extra bottom padding for button visibility */
  }
  .content-section {
    padding: 24px;
    margin-bottom: 16px;
  }
  .content-section:last-child {
    margin-bottom: 60px; /* Extra margin for last section */
  }
}

/* Sidebar */
.sidebar {
  width: 300px;
  background: var(--ey-black);
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  transition: all var(--trans);
}

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

/* Navigation items */
.chapter, .single-item {
  margin-bottom: 4px;
}

.chapter > div,
.sub-item,
.single-item {
  cursor: pointer;
  padding: 12px 16px;
  border-radius: var(--rad);
  transition: all var(--trans);
  display: flex;
  align-items: center;
  color: var(--ey-white);
  position: relative;
  user-select: none;
}

.chapter > div {
  font-weight: 500;
}

.chapter > div:hover,
.sub-item:hover,
.single-item:hover {
  background: rgba(255, 230, 0, 0.1);
  color: var(--ey-yellow);
}

.separator {
  padding: 16px 16px 8px;
  margin: 16px 0 8px;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 1px;
  color: var(--ey-gray-medium);
  text-transform: uppercase;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.separator:first-child {
  border-top: none;
  margin-top: 0;
}

/* Completed state */
.completed > div::before,
.sub-item.completed::before,
.single-item.completed::before {
  content: '✓';
  color: var(--ey-yellow);
  margin-right: 8px;
  font-weight: bold;
}

/* Active state */
.active > div,
.sub-item.active,
.single-item.active {
  background: var(--ey-yellow);
  color: var(--ey-black);
  font-weight: 600;
}

.sub-list {
  padding-left: 32px;
  margin-top: 4px;
  animation: slideInLeft 0.3s ease-out;
}

.arrow {
  margin-right: 12px;
  font-size: 0.75em;
  transition: transform 0.2s;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

/* Make entire chapter header clickable for expand/collapse */
.chapter > div {
  position: relative;
  padding-left: 40px;
}
.chapter > div .arrow {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}
.chapter.expanded > div .arrow {
  transform: translateY(-50%) rotate(90deg);
}

/* Main content */
.content {
  flex: 1;
  padding: 40px;
  overflow-y: auto;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  margin-left: 300px; /* Offset for fixed sidebar */
}

/* Page content container */
.page-content {
  background: transparent;
  border-radius: var(--rad);
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative; /* Add relative positioning */
  z-index: 1; /* Ensure content is above background */
}

/* Content sections */
.content-section {
  background: var(--card);
  border-radius: var(--rad);
  padding: 48px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  animation: fadeInUp 0.6s ease-out forwards;
  transition: all 0.3s ease;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.content-section:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Typography */
.content-section h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
  line-height: 1.2;
}

.content-section h2 {
  font-size: 1.875rem;
  font-weight: 600;
  margin: 2rem 0 1rem;
  color: var(--text-primary);
  position: relative;
  padding-bottom: 0.5rem;
}

.content-section h2::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 60px;
  height: 3px;
  background: var(--ey-yellow);
}

.content-section h3 {
  font-size: 1.375rem;
  font-weight: 600;
  margin: 1.5rem 0 1rem;
  color: var(--text-primary);
}

.content-section h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 1.2rem 0 0.8rem;
  color: var(--text-primary);
}

.content-section p {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: 1.2rem;
}

.content-section blockquote {
  border-left: 4px solid var(--ey-yellow);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background: var(--bg);
  border-radius: 0 var(--rad) var(--rad) 0;
  color: var(--text-primary);
}

.content-section ul, .content-section ol {
  margin: 1rem 0;
  padding-left: 2rem;
  color: var(--text-secondary);
}

.content-section li {
  margin-bottom: 0.5rem;
  line-height: 1.75;
}

.content-section code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: var(--rad);
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.875em;
  color: var(--text-primary);
}

.content-section pre {
  background: var(--ey-gray-dark);
  color: var(--ey-white);
  padding: 1.5rem;
  border-radius: var(--rad);
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.875rem;
}

.content-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  border: 1px solid #e0e0e0;
  border-radius: var(--rad);
  overflow: hidden;
}

.content-section th {
  background: var(--bg);
  color: var(--text-primary);
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid #e0e0e0;
}

.content-section td {
  padding: 1rem;
  border-bottom: 1px solid #e0e0e0;
}

.content-section tr:hover {
  background: var(--bg);
}

.content-section a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  position: relative;
  transition: color 0.3s ease;
  border-bottom: 2px solid var(--ey-yellow);
}

.content-section a:hover {
  color: var(--ey-gray-medium);
}

/* Stagger animations */
.content-section:nth-child(1) { animation-delay: 0.1s; }
.content-section:nth-child(2) { animation-delay: 0.2s; }
.content-section:nth-child(3) { animation-delay: 0.3s; }
.content-section:nth-child(4) { animation-delay: 0.4s; }

/* Demo scenarios */
.demo-scenarios {
  display: flex;
  gap: 20px;
  margin: 32px 0;
  flex-wrap: wrap;
}
.demo-scenarios .scenario {
  cursor: pointer;
  text-align: center;
  flex: 1;
  min-width: 200px;
  padding: 20px;
  border-radius: var(--rad);
  background: var(--bg);
  transition: all 0.3s ease;
  border: 1px solid transparent;
}
.demo-scenarios .scenario:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--ey-yellow);
  background: var(--card);
}
.demo-scenarios .scenario img {
  width: 100%;
  border-radius: var(--rad);
  transition: transform var(--trans);
}
.demo-scenarios .scenario:hover img {
  transform: scale(1.05);
}

/* Form elements */
.editable-html {
  flex: 1;
  width: 100%;
  min-height: 300px;
  padding: 16px;
  border: 1px solid #e0e0e0;
  border-radius: var(--rad);
  background: var(--ey-white);
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  transition: all 0.3s ease;
}
.editable-html:focus {
  border-color: var(--ey-yellow);
  box-shadow: 0 0 0 3px rgba(255, 230, 0, 0.2);
  outline: none;
}

.instructions {
  margin: 20px 0;
  padding: 20px;
  background: var(--bg);
  border-radius: var(--rad);
  color: var(--text-primary);
  border-left: 4px solid var(--ey-yellow);
}

/* Buttons */
.btn {
  font-size: 16px;
  padding: 12px 28px;
  margin: 10px 5px;
  border: none;
  border-radius: var(--rad);
  cursor: pointer;
  transition: all var(--trans);
  font-weight: 500;
  position: relative;
  overflow: hidden;
  display: inline-block;
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
  touch-action: manipulation; /* Improve touch responsiveness */
  user-select: none; /* Prevent text selection on double tap */
  -webkit-user-select: none;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.btn-primary {
  background: var(--ey-yellow);
  color: var(--ey-black);
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-secondary {
  background: var(--ey-black);
  color: var(--ey-white);
}
.btn-secondary:hover {
  background: var(--ey-gray-dark);
}
.btn-danger {
  background: #dc3545;
  color: white;
}
.btn-danger:hover {
  background: #c82333;
}

/* Mobile-specific button fixes */
@media (max-width: 768px) {
  .btn {
    font-size: 18px; /* Larger font for better touch targets */
    padding: 16px 32px; /* Larger padding for easier tapping */
    min-height: 48px; /* Ensure minimum touch target size */
    width: 100%; /* Full width on mobile */
    max-width: 300px; /* But with a max width */
    margin: 10px auto; /* Center the button */
    display: block; /* Block display for centering */
    position: relative; /* Ensure proper stacking */
    z-index: 100; /* High z-index to ensure clickability */
  }

  /* Fix for button containers */
  .content-section {
    position: relative;
    z-index: 1;
  }

  /* Ensure interactive elements are above others */
  .btn:active {
    transform: scale(0.98); /* Visual feedback on tap */
  }
}

/* Messages */
.message {
  padding: 16px 20px;
  margin-bottom: 16px;
  border-radius: var(--rad);
  animation: fadeInUp 0.4s ease-out;
  position: relative;
}
.message.user {
  background: var(--bg);
  margin-left: 20%;
  border: 1px solid #e0e0e0;
}
.message.server {
  background: var(--ey-yellow);
  margin-right: 20%;
  color: var(--ey-black);
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  background: var(--ey-black);
  font-size: 0.875rem;
  color: var(--ey-white);
}
.footer a {
  margin: 0 16px;
  color: var(--ey-white);
  text-decoration: none;
  transition: all 0.3s ease;
  opacity: 0.8;
}
.footer a:hover {
  opacity: 1;
  color: var(--ey-yellow);
}

/* Loading skeleton */
@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}
.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
  height: 20px;
  border-radius: var(--rad);
  margin: 10px 0;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1001;
    width: 280px !important;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }
  .sidebar.open { transform: translateX(0); }
  .content {
    margin-left: 0 !important;
    padding: 80px 20px 20px !important;
    padding-bottom: 100px !important; /* Extra bottom padding for button visibility */
  }
  .content-section {
    padding: 24px;
    margin-bottom: 16px;
  }
  .content-section:last-child {
    margin-bottom: 60px; /* Extra margin for last section */
  }
  .content-section h1 { font-size: 1.875rem; }
  .content-section h2 { font-size: 1.5rem; }
  .demo-scenarios { flex-direction: column; }
}

/* Add smooth scrolling */
html {
  scroll-behavior: smooth;
}
