html,
body {
  height: 100%;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f4f7fb;
  margin: 0;
  padding: 0;
  /* layout: make header/main/footer stack and allow main to expand */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header/navigation styles (moved here so header.html looks consistent across pages) */
.site-header {
  background: #fff;
  border-bottom: 1px solid #e6eef8;
}
.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-weight: 700;
  color: #111;
  text-decoration: none;
  font-size: 1.2rem;
}
.site-nav a {
  margin-left: 16px;
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
}
.site-nav a.active {
  color: #0f172a;
  text-decoration: underline;
}
.site-header .main-container {
  margin-top: 0;
  padding: 20px;
}

.main-container {
  /* allow the container to span the full viewport width while constraining
     readable line-length on very large screens */
  width: 100%;
  max-width: 1400px;
  margin: 0 auto; /* center the container on wide viewports */
  /* use logical padding so it behaves well in different writing modes */
  padding-inline: 20px;
  padding-block: 20px;
  box-sizing: border-box;
}

.content-wrapper {
  display: flex;
  gap: 30px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 24px #0002;
  overflow: hidden;
  /* let the parent (main) control sizing; keep min-height when needed for editor layout */
  min-height: calc(100vh - 80px);
}

/* allow main content area to grow so footer stays at bottom on short pages */
main {
  flex: 1 0 auto;
}

/* The main page content (hero + sections) should grow to fill available
   vertical space so footer sits at the bottom on short pages */
.page-content {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
}

.learning-section {
  flex: 1 1 0%;
  padding: 32px 24px;
  overflow-y: auto;
  max-height: calc(100vh - 80px);
}

.editor-section {
  flex: 1 1 0%;
  padding: 32px 24px;
  background: #fafbfc;
  border-left: 1px solid #e1e5e9;
  display: flex;
  flex-direction: column;
  min-width: 0; /* allow flex children to shrink instead of overflowing */
}

/* Ensure learning section can shrink in tight layouts */
.learning-section {
  min-width: 0;
}

h1 {
  color: #2563eb;
  margin-bottom: 8px;
}

.subtitle {
  color: #555;
  font-size: 1.1em;
  margin-bottom: 24px;
}

.learning-path {
  background: #eaf2ff;
  border-left: 4px solid #2563eb;
  padding: 18px 18px 8px 18px;
  margin-bottom: 28px;
  border-radius: 6px;
}

.learning-path h2 {
  color: #2563eb;
  font-size: 1.15em;
  margin-top: 0;
}

.learning-path ol {
  margin-left: 1em;
  padding-left: 0.5em;
}

.examples-exercises {
  margin-bottom: 32px;
}

.exercise-controls {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.exercise-level {
  font-size: 0.95em;
  color: #333;
}

.exercise-btn {
  margin-left: 8px;
  background: #4e9cff;
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.exercise-btn:hover {
  background: #3a86e0;
}

.examples-exercises h2 {
  color: #2563eb;
  font-size: 1.08em;
  margin-bottom: 10px;
}

details {
  background: #f8fafc;
  border: 1px solid #e0e7ef;
  border-radius: 6px;
  margin-bottom: 12px;
  padding: 8px 12px;
  transition: box-shadow 0.2s;
}

details[open] {
  box-shadow: 0 2px 8px #0001;
}

summary {
  font-size: 1.04em;
  font-weight: 600;
  color: #2563eb;
  cursor: pointer;
  outline: none;
}

pre {
  background: #f6f8fa;
  padding: 10px;
  border-radius: 4px;
  font-size: 0.98em;
  margin: 8px 0 8px 0;
  overflow-x: auto;
}

.instructions {
  background: #f1f5fb;
  border-left: 4px solid #2563eb;
  padding: 16px;
  margin-bottom: 24px;
  border-radius: 4px;
  color: #333;
}

.editor-label {
  font-weight: 500;
  margin-bottom: 6px;
  color: #2563eb;
}

.kbd-hint {
  font-weight: 400;
  font-size: 0.85em;
  color: #666;
  margin-left: 8px;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.editor-toolbar select {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
}

#editor {
  width: 100%;
  height: 300px;
  border-radius: 6px;
  border: 1px solid #b6c6e3;
  overflow: hidden;
  box-sizing: border-box;
}

.ace_editor.ace-monokai {
  border-radius: 6px;
}

#code {
  width: 100%;
  height: 250px;
  font-family: "Fira Mono", monospace;
  font-size: 16px;
  border-radius: 6px;
  border: 1.5px solid #b6c6e3;
  padding: 12px;
  margin-bottom: 12px;
  background: #fafdff;
  transition: border 0.2s;
  resize: vertical;
}

#code:focus {
  border: 1.5px solid #2563eb;
  outline: none;
}

.editor-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.run-btn {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.run-btn:hover {
  background: #1741a6;
}

.reset-btn {
  background: #e0e7ef;
  color: #2563eb;
  border: none;
  padding: 10px 24px;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.reset-btn:hover {
  background: #cbd5e1;
}

.output-label {
  margin-top: 18px;
  font-weight: 600;
  color: #2563eb;
}

#output {
  background: #181c24;
  color: #e2e2e2;
  min-height: 150px;
  flex: 1;
  border-radius: 4px;
  padding: 16px;
  margin-top: 8px;
  font-family: "Fira Mono", monospace;
  white-space: pre-wrap;
  font-size: 1em;
  overflow-y: auto;
}

@media (max-width: 1024px) {
  .content-wrapper {
    flex-direction: column;
    min-height: auto;
  }

  .learning-section {
    max-height: none;
    overflow-y: visible;
  }

  .editor-section {
    border-left: none;
    border-top: 1px solid #e1e5e9;
  }

  .main-container {
    padding: 10px;
  }
}

@media (max-width: 600px) {
  .main-container {
    padding: 5px;
  }

  #code {
    font-size: 15px;
    height: 200px;
  }

  .learning-section,
  .editor-section {
    padding: 20px 16px;
  }
}
