/*
 * Network Lab refactor layer.
 * Kept separate from the legacy stylesheet so the redesign can be reviewed
 * and rolled back without touching the existing content renderer.
 */

:root {
  --lab-ink: #172033;
  --lab-muted: #667085;
  --lab-line: rgba(23, 32, 51, 0.12);
  --lab-surface: rgba(255, 255, 255, 0.92);
  --lab-brand: #087f8c;
  --lab-brand-dark: #075e68;
  --lab-cyan: #0ea5b7;
  --lab-violet: #6857d9;
  --lab-amber: #c47a12;
  --lab-green: #27815d;
  --lab-rose: #b4526e;
  --lab-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  --lab-shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.06);
}

body {
  background:
    linear-gradient(135deg, rgba(8, 127, 140, 0.055) 0%, transparent 35%),
    linear-gradient(315deg, rgba(104, 87, 217, 0.045) 0%, transparent 30%),
    #f7f8f6;
  color: var(--lab-ink);
}

.container {
  width: min(1240px, calc(100% - 40px));
}

.hero {
  padding: 1.25rem 0 1rem;
}

.hero .container {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #fdfefe 0%, #f3fbfa 58%, #f8f6ff 100%);
  border: 1px solid rgba(8, 127, 140, 0.12);
  border-radius: 28px;
  padding: clamp(1.4rem, 4vw, 3.4rem);
  box-shadow: var(--lab-shadow);
}

.hero .container::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  right: -90px;
  bottom: -140px;
  border: 1px solid rgba(104, 87, 217, 0.13);
  border-radius: 50%;
  box-shadow: 0 0 0 28px rgba(104, 87, 217, 0.035), 0 0 0 56px rgba(104, 87, 217, 0.025);
  pointer-events: none;
}

.hero-layout {
  position: relative;
  z-index: 1;
  gap: clamp(1.5rem, 5vw, 4rem);
}

.hero h1 {
  max-width: 11ch;
  letter-spacing: -0.055em;
  color: #102a35;
}

.hero-kicker,
.section-kicker,
.topic-kicker,
.quiz-kicker,
.study-path-kicker,
.pdf-meta {
  color: var(--lab-brand);
}

.hero-copy {
  max-width: 40rem;
  color: #526270;
  font-size: clamp(0.98rem, 1.5vw, 1.12rem);
}

.study-path-card {
  border-color: rgba(8, 127, 140, 0.14);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--lab-shadow-soft);
}

.study-path-item {
  border-color: rgba(8, 127, 140, 0.1);
  border-radius: 15px;
}

.study-path-item:hover,
.study-path-item:focus-visible {
  border-color: rgba(8, 127, 140, 0.32);
  transform: translateY(-2px);
}

.sticky-nav {
  background: rgba(247, 248, 246, 0.86);
  border-bottom-color: rgba(23, 32, 51, 0.13);
}

.nav-shell {
  min-height: 62px;
}

.sticky-nav ul {
  gap: 0.25rem;
}

.sticky-nav a {
  min-height: 2.4rem;
  border-radius: 12px;
  color: #526270;
  font-size: 0.86rem;
}

.sticky-nav a:hover,
.sticky-nav a:focus-visible,
.sticky-nav a.active {
  background: rgba(8, 127, 140, 0.1);
  color: var(--lab-brand-dark);
}

.btn-primary {
  background: var(--lab-brand);
  border-color: var(--lab-brand);
  box-shadow: 0 8px 18px rgba(8, 127, 140, 0.18);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--lab-brand-dark);
  border-color: var(--lab-brand-dark);
}

.btn-secondary {
  border-color: rgba(8, 127, 140, 0.2);
  color: var(--lab-brand-dark);
  background: rgba(255, 255, 255, 0.7);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  background: rgba(8, 127, 140, 0.08);
  border-color: rgba(8, 127, 140, 0.38);
}

main.container {
  padding-bottom: 2rem;
}

section {
  scroll-margin-top: 5.5rem;
}

#dashboard {
  border: 1px solid rgba(8, 127, 140, 0.1);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.64);
  padding: clamp(1rem, 3vw, 1.6rem);
}

.dashboard-intro {
  gap: 1.5rem;
}

.dashboard-intro h2,
.section-heading h2 {
  color: #152d38;
  letter-spacing: -0.04em;
}

.search-box input {
  min-height: 48px;
  border-color: rgba(8, 127, 140, 0.2);
  border-radius: 14px;
  background: #fff;
}

.search-box input:focus {
  border-color: var(--lab-brand);
  box-shadow: 0 0 0 4px rgba(8, 127, 140, 0.1);
}

.dashboard-stats {
  gap: 0.8rem;
}

.stat-card,
.exam-summary-card,
.topic-card,
.lab-card,
.viz-card,
#quiz-container {
  border-color: rgba(23, 32, 51, 0.1);
  border-radius: 18px;
  box-shadow: 0 7px 22px rgba(15, 23, 42, 0.035);
}

.stat-card {
  background: rgba(255, 255, 255, 0.84);
}

.quick-actions {
  align-items: center;
}

.learning-path-section,
.switching-section {
  padding-top: 0.5rem;
}

.learning-path-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 0.9rem;
}

.learning-track-card {
  display: flex;
  min-height: 300px;
  flex-direction: column;
  padding: 1.15rem;
  border: 1px solid var(--lab-line);
  border-radius: 20px;
  background: var(--lab-surface);
  color: var(--lab-ink);
  text-decoration: none;
  box-shadow: var(--lab-shadow-soft);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.learning-track-card:hover,
.learning-track-card:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--track-color) 42%, transparent);
  box-shadow: var(--lab-shadow);
}

.learning-track-card.tone-cyan { --track-color: var(--lab-cyan); }
.learning-track-card.tone-violet { --track-color: var(--lab-violet); }
.learning-track-card.tone-amber { --track-color: var(--lab-amber); }
.learning-track-card.tone-green { --track-color: var(--lab-green); }
.learning-track-card.tone-rose { --track-color: var(--lab-rose); }

.track-card-top,
.track-topics,
.switch-lab-meta,
.switch-step-heading,
.switch-result-grid {
  display: flex;
  align-items: center;
}

.track-card-top {
  justify-content: space-between;
  gap: 0.7rem;
}

.track-number {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--track-color) 12%, white);
  color: var(--track-color);
  font-weight: 800;
}

.track-label,
.callout-label,
.switch-lab-meta span,
.switch-step-heading span,
.switch-result span {
  color: var(--track-color, var(--lab-brand));
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.track-label {
  text-align: right;
}

.learning-track-card h3 {
  margin-top: 1.2rem;
  color: #15313a;
  font-size: 1.14rem;
  line-height: 1.25;
}

.learning-track-card > p:not(.arabic-text) {
  margin-top: 0.65rem;
  color: var(--lab-muted);
  font-size: 0.9rem;
}

.learning-track-card .arabic-text {
  margin-top: 0.55rem;
  color: #788694;
  font-family: var(--font-ar);
  font-size: 0.82rem;
}

.track-topics {
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 1rem;
}

.track-topics span {
  padding: 0.3rem 0.48rem;
  border: 1px solid color-mix(in srgb, var(--track-color) 17%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--track-color) 6%, white);
  color: color-mix(in srgb, var(--track-color) 76%, #1d2939);
  font-size: 0.72rem;
  font-weight: 700;
}

.track-link {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--lab-line);
  color: var(--track-color);
  font-size: 0.82rem;
  font-weight: 800;
}

.learning-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1rem;
  padding: 1.15rem 1.3rem;
  border: 1px solid rgba(104, 87, 217, 0.15);
  border-radius: 20px;
  background: linear-gradient(120deg, rgba(104, 87, 217, 0.07), rgba(8, 127, 140, 0.06));
}

.learning-callout h3 {
  margin-top: 0.35rem;
  color: #263453;
  font-size: clamp(1.05rem, 2vw, 1.4rem);
}

.learning-callout p {
  margin-top: 0.3rem;
  color: var(--lab-muted);
  font-size: 0.9rem;
}

.switch-lab-grid {
  display: grid;
  gap: 0.8rem;
}

.switch-lab-card {
  overflow: hidden;
  border: 1px solid var(--lab-line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--lab-shadow-soft);
}

.switch-lab-header {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 42px;
  align-items: start;
  gap: 0.95rem;
  padding: 1rem;
}

.switch-lab-number {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 14px;
  background: #e8f7f7;
  color: var(--lab-brand-dark);
  font-weight: 900;
}

.switch-lab-meta {
  flex-wrap: wrap;
  gap: 0.6rem;
}

.switch-lab-meta span {
  color: var(--lab-brand);
  letter-spacing: 0.05em;
}

.switch-lab-title h3 {
  margin-top: 0.25rem;
  color: #1b3340;
  font-size: 1.05rem;
}

.switch-lab-title > p:not(.arabic-text) {
  margin-top: 0.3rem;
  color: var(--lab-muted);
  font-size: 0.9rem;
}

.switch-lab-title .arabic-text {
  margin-top: 0.18rem;
  color: #7b8791;
  font-family: var(--font-ar);
  font-size: 0.8rem;
}

.lesson-toggle {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--lab-line);
  border-radius: 12px;
  background: #fff;
  color: var(--lab-brand-dark);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease;
}

.switch-lab-card.is-open .lesson-toggle {
  background: #e8f7f7;
  transform: rotate(180deg);
}

.switch-lab-body {
  display: none;
  padding: 0 1rem 1rem;
}

.switch-lab-card.is-open .switch-lab-body {
  display: block;
}

.switch-steps {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.switch-step {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid rgba(23, 32, 51, 0.09);
  border-radius: 16px;
  background: #fbfcfc;
}

.switch-step-index {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  background: #edf4f4;
  color: var(--lab-brand-dark);
  font-size: 0.78rem;
  font-weight: 900;
}

.switch-step-heading {
  justify-content: space-between;
  gap: 0.6rem;
}

.switch-step-heading h4 {
  color: #283945;
  font-size: 0.93rem;
}

.switch-step-heading span {
  flex: 0 0 auto;
  color: #87939b;
  letter-spacing: 0.04em;
}

.switch-step-content > p {
  margin-top: 0.45rem;
  color: var(--lab-muted);
  font-size: 0.85rem;
}

.switch-step-content > p.arabic-text {
  color: #7c8992;
  font-family: var(--font-ar);
  font-size: 0.78rem;
}

.switch-command-row {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.switch-command-row pre {
  min-width: 0;
  flex: 1;
  margin: 0;
  padding: 0.68rem 0.75rem;
  overflow-x: auto;
  border: 1px solid #223443;
  border-radius: 12px;
  background: #142431;
  color: #d9f9f5;
  font: 0.8rem/1.6 var(--font-mono);
  white-space: pre;
}

.switch-command-row pre code {
  color: inherit;
  background: transparent;
  white-space: inherit;
}

.copy-command {
  align-self: flex-start;
  min-width: 58px;
  padding: 0.55rem 0.55rem;
  border: 1px solid rgba(8, 127, 140, 0.22);
  border-radius: 10px;
  background: #effafa;
  color: var(--lab-brand-dark);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 800;
}

.copy-command:hover,
.copy-command:focus-visible,
.copy-command.is-copied {
  background: var(--lab-brand);
  color: #fff;
}

.switch-result-grid {
  align-items: stretch;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.switch-result {
  flex: 1;
  padding: 0.8rem;
  border-radius: 14px;
}

.switch-result p {
  margin-top: 0.35rem;
  color: #4f5e69;
  font-size: 0.82rem;
}

.verify-result {
  background: #effaf5;
  border: 1px solid rgba(39, 129, 93, 0.15);
}

.verify-result span {
  --track-color: var(--lab-green);
}

.mistake-result {
  background: #fff7ec;
  border: 1px solid rgba(196, 122, 18, 0.16);
}

.mistake-result span {
  --track-color: var(--lab-amber);
}

#commands .command-tabs {
  position: sticky;
  top: 4.25rem;
  z-index: 4;
  padding: 0.55rem;
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-radius: 16px;
  background: rgba(247, 248, 246, 0.88);
  backdrop-filter: blur(12px);
}

#commands .command-content,
#cheat-sheet .cheat-sheet-grid,
#visualizer .visualizer-grid,
#lectures .lecture-grid {
  min-width: 0;
}

#commands pre,
.command-block,
.command-block code {
  max-width: 100%;
}

#commands pre,
.command-block .cmd-line {
  overflow-x: auto;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

.site-footer {
  margin-top: 2rem;
  border-top-color: rgba(8, 127, 140, 0.13);
  background: #eef4f2;
}

.footer-social a[href="https://sitehie.info/"] {
  color: var(--lab-brand-dark);
  font-weight: 900;
}

.mobile-bottom-nav {
  display: none;
}

@media (max-width: 1024px) {
  .learning-path-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #commands .command-tabs {
    top: 6.9rem;
  }
}

@media (max-width: 720px) {
  .container {
    width: min(100% - 1.25rem, 100%);
  }

  .hero .container {
    border-radius: 22px;
    padding: 1.15rem;
  }

  .hero h1 {
    max-width: none;
    font-size: clamp(2rem, 11vw, 3.2rem);
  }

  .hero-copy {
    font-size: 0.94rem;
  }

  .hero-actions,
  .quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .hero-actions .btn,
  .quick-actions .btn {
    width: 100%;
    min-height: 44px;
  }

  .sticky-nav {
    display: none;
  }

  main.container {
    padding-bottom: 5.5rem;
  }

  section {
    scroll-margin-top: 1rem;
  }

  .mobile-bottom-nav {
    position: fixed;
    right: 0.55rem;
    bottom: calc(0.55rem + env(safe-area-inset-bottom));
    left: 0.55rem;
    z-index: 1000;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.2rem;
    padding: 0.42rem;
    border: 1px solid rgba(23, 32, 51, 0.13);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(16px);
  }

  .mobile-bottom-nav a {
    display: grid;
    min-height: 48px;
    place-items: center;
    align-content: center;
    gap: 0.08rem;
    border-radius: 13px;
    color: #6e7a83;
    text-decoration: none;
  }

  .mobile-bottom-nav a:hover,
  .mobile-bottom-nav a:focus-visible {
    background: #e8f7f7;
    color: var(--lab-brand-dark);
  }

  .mobile-bottom-nav span {
    font-size: 1.05rem;
    font-weight: 900;
    line-height: 1;
  }

  .mobile-bottom-nav small {
    font-size: 0.62rem;
    font-weight: 800;
  }

  .learning-path-grid {
    grid-template-columns: 1fr;
  }

  .learning-track-card {
    min-height: 0;
  }

  .learning-callout,
  .switch-result-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .learning-callout .btn {
    width: 100%;
  }

  .switch-lab-header {
    grid-template-columns: 42px minmax(0, 1fr) 36px;
    gap: 0.65rem;
    padding: 0.8rem;
  }

  .switch-lab-number {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    font-size: 0.84rem;
  }

  .lesson-toggle {
    width: 34px;
    height: 34px;
  }

  .switch-lab-body {
    padding: 0 0.8rem 0.8rem;
  }

  .switch-step {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .switch-step-index {
    width: 28px;
    height: 28px;
    border-radius: 9px;
  }

  .switch-step-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.15rem;
  }

  .switch-command-row {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .switch-command-row pre {
    grid-column: 1 / -1;
  }

  .copy-command {
    grid-column: 2;
    justify-self: end;
  }

  #commands .command-tabs {
    position: static;
  }
}

@media (max-width: 420px) {
  .hero-actions,
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .dashboard-stats {
    grid-template-columns: 1fr;
  }

  .switch-lab-title h3 {
    font-size: 0.98rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
