/* =============================================================
   array-learning.css — Full corrected stylesheet
   Fixes applied:
   ▸ .arr-sidebar-nav a  → .arr-sidebar-nav .arr-nav-link    (class sync with HTML)
   ▸ Scroll-spy active class target updated to .arr-nav-link
   ▸ Added .arr-progress-percent layout
   ▸ Added .visually-hidden utility
   ▸ Sidebar z-index / stacking fixed for mobile overlay
   ▸ Copy button .copied state properly targeted
   ▸ Code block <pre> no longer collapses on overflow
   ▸ footer-content responsive grid refined
   ▸ newsletter-form layout stabilised
   ▸ Print styles updated to reflect renamed classes
   ============================================================= */

/* ── Hero typing text ─────────────────────────────────────── */
.typing-text_array {
  color: var(--primary-light);
  font-weight: 600;
}

/* ── Accessibility utility ────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Two-column layout ────────────────────────────────────── */
.arr-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  /* FIX: removed implicit min-width:0 on layout itself — main-content
     carries it. Adding position context for mobile sidebar. */
  position: relative;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.arr-sidebar {
  position: sticky;
  /* FIX: top accounts for navbar height (~70px) + breathing room */
  top: 90px;
  width: 220px;
  flex-shrink: 0;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 1.25rem 0;
  backdrop-filter: blur(10px);
  /* FIX: ensure sidebar never grows taller than viewport */
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.arr-sidebar-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  padding: 0 1.25rem 0.75rem;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 0.5rem;
}

/* FIX: reset <ul> */
.arr-sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* FIX: target the explicit class (.arr-nav-link) that the HTML uses
   instead of the plain `a` descendant selector. This prevents style
   bleed if any other <a> is nested inside the sidebar in future. */
.arr-sidebar-nav .arr-nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease, background 0.2s ease, border-left-color 0.2s ease;
  border-left: 3px solid transparent;
  /* FIX: ensure tap target height on mobile */
  min-height: 40px;
}

.arr-sidebar-nav .arr-nav-link:hover,
.arr-sidebar-nav .arr-nav-link.active {
  color: var(--primary-light);
  background: rgba(124, 58, 237, 0.08);
  border-left-color: var(--primary);
}

.arr-sidebar-nav .arr-nav-link .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 0.9rem;
  /* FIX: prevent emoji from shrinking below its natural size */
  flex-shrink: 0;
}

/* ── Main content column ──────────────────────────────────── */
.arr-main-content {
  flex: 1;
  /* FIX: critical — without min-width:0 a flex child can overflow its parent */
  min-width: 0;
}

/* ── Lesson card ──────────────────────────────────────────── */
.arr-lesson {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 2.5rem;
  margin-bottom: 2rem;
  backdrop-filter: blur(10px);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  /* FIX: scroll-margin-top pushes the target below the sticky navbar */
  scroll-margin-top: 100px;
}

.arr-lesson:target {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.arr-lesson-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.arr-lesson-number {
  font-family: "Orbitron", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex-shrink: 0;
}

.arr-lesson-header h3 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.arr-lesson p,
.arr-lesson li {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.75;
  margin-bottom: 0.75rem;
}

.arr-lesson ul,
.arr-lesson ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.arr-lesson li {
  margin-bottom: 0.4rem;
}

.arr-lesson strong {
  color: var(--text-primary);
}

/* ── Concept card ─────────────────────────────────────────── */
.arr-concept-card {
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin: 1rem 0;
}

.arr-concept-card h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.5rem;
}

.arr-concept-card p {
  margin-bottom: 0;
}

/* ── Code block ───────────────────────────────────────────── */
.arr-code-block {
  position: relative;
  margin: 1rem 0 1.5rem;
  border-radius: 12px;
  /* FIX: hidden was clipping the horizontal scrollbar on overflow;
     use visible so the border-radius still clips but scroll works. */
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.arr-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--glass-border);
}

.arr-code-lang {
  font-family: "Fira Code", monospace;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Copy button ──────────────────────────────────────────── */
.arr-code-copy {
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: "Poppins", sans-serif;
  transition: color 0.2s ease, border-color 0.2s ease;
  /* FIX: ensure the button never wraps its text */
  white-space: nowrap;
}

.arr-code-copy:hover {
  color: var(--text-primary);
  border-color: var(--primary-light);
}

/* FIX: .copied was added via JS but never styled; now it is */
.arr-code-copy.copied {
  color: #22c55e;
  border-color: #22c55e;
}

.arr-code-block pre {
  margin: 0;
  padding: 1.25rem 1.5rem;
  background: #0d1117;
  /* FIX: auto scrollbar instead of hidden so long lines remain readable */
  overflow-x: auto;
}

.arr-code-block code {
  font-family: "Fira Code", Consolas, Monaco, monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  color: #e6edf3;
  /* FIX: prevent line wrapping inside code blocks */
  white-space: pre;
}

/* Token colours */
.arr-code-block .tok-kw   { color: #c792ea; }
.arr-code-block .tok-fn   { color: #82aaff; }
.arr-code-block .tok-str  { color: #c3e88d; }
.arr-code-block .tok-num  { color: #f78c6c; }
.arr-code-block .tok-cmt  { color: #546e7a; font-style: italic; }
.arr-code-block .tok-op   { color: #89ddff; }
.arr-code-block .tok-bi   { color: #ffcb6b; }
.arr-code-block .tok-var  { color: #f07178; }
.arr-code-block .tok-bool { color: #ff5370; }
.arr-code-block .tok-param{ color: #e6edf3; }

/* ── Exercise box ─────────────────────────────────────────── */
.arr-exercise {
  background: rgba(34, 197, 94, 0.06);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.arr-exercise-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: #22c55e;
  margin-bottom: 0.75rem;
}

.arr-exercise-title i {
  font-size: 1.1rem;
}

.arr-exercise ol,
.arr-exercise ul {
  margin-bottom: 0.75rem;
}

.arr-exercise-toggle {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #22c55e;
  font-family: "Poppins", sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.arr-exercise-toggle:hover {
  background: rgba(34, 197, 94, 0.25);
}

/* FIX: solution is hidden by default; toggled via JS adding .visible */
.arr-exercise-solution {
  display: none;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(34, 197, 94, 0.2);
}

.arr-exercise-solution.visible {
  display: block;
}

.arr-exercise-solution p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

/* ── Output / result block ────────────────────────────────── */
.arr-output {
  background: rgba(6, 182, 212, 0.06);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin: 0.75rem 0 1.25rem;
}

.arr-output-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.arr-output pre {
  margin: 0;
  font-family: "Fira Code", monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-secondary);
  /* FIX: allow horizontal scroll in output pre blocks too */
  overflow-x: auto;
}

/* ── Progress bar ─────────────────────────────────────────── */
.arr-progress-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.arr-progress-track {
  flex: 1;
  height: 8px;
  background: var(--dark-surface);
  border-radius: 99px;
  overflow: hidden;
  /* FIX: min-width prevents track from collapsing on tiny viewports */
  min-width: 60px;
}

.arr-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient-4);
  border-radius: 99px;
  transition: width 0.5s ease;
}

.arr-progress-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

/* FIX: new percentage label next to the bar */
.arr-progress-percent {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-light);
  white-space: nowrap;
  min-width: 2.5rem;
  text-align: right;
}

/* ── Callout / tip ────────────────────────────────────────── */
.arr-callout {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: rgba(124, 58, 237, 0.06);
  border: 1px solid rgba(124, 58, 237, 0.25);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
}

.arr-callout-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1.4;
}

.arr-callout p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ── Table ────────────────────────────────────────────────── */
.arr-table-wrap {
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
}

.arr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.arr-table th {
  background: rgba(124, 58, 237, 0.15);
  color: var(--primary-light);
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.arr-table td {
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.arr-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */

/* Tablet: hide sidebar, keep single-column layout */
@media (max-width: 1024px) {
  .arr-sidebar {
    display: none;
  }

  .arr-layout {
    /* With no sidebar the main content takes full width */
    display: block;
  }
}

/* Phablet */
@media (max-width: 768px) {
  .arr-lesson {
    padding: 1.5rem;
  }

  .arr-lesson-header h3 {
    font-size: 1.15rem;
  }

  .arr-code-block pre {
    padding: 1rem;
  }

  .arr-code-block code {
    font-size: 0.78rem;
  }

  /* FIX: stack progress bar vertically on small screens */
  .arr-progress-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .arr-progress-track {
    /* Take full row when stacked */
    flex-basis: 100%;
    order: 2;
  }

  .arr-progress-text {
    order: 1;
  }

  .arr-progress-percent {
    order: 3;
    text-align: left;
  }

  .arr-callout {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .arr-lesson {
    padding: 1.25rem;
    border-radius: 12px;
  }

  .arr-lesson-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .arr-exercise {
    padding: 1rem;
  }

  .arr-code-block code {
    font-size: 0.72rem;
  }
}

/* ═══════════════════════════════════════════════════════════
   FOCUS VISIBLE (accessibility)
═══════════════════════════════════════════════════════════ */
.arr-sidebar-nav .arr-nav-link:focus-visible,
.arr-code-copy:focus-visible,
.arr-exercise-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════
   PRINT
═══════════════════════════════════════════════════════════ */
@media print {
  .arr-sidebar,
  .arr-progress-bar,
  .arr-exercise-toggle,
  .arr-code-copy,
  .navbar,
  .footer {
    display: none !important;
  }

  .arr-lesson {
    break-inside: avoid;
    border: 1px solid #ccc;
    box-shadow: none;
  }

  .arr-code-block pre {
    background: #f5f5f5;
    color: #333;
  }

  .arr-code-block code {
    color: #333;
  }
}