/* ============================================================
   ROS2Lab — Interactive Web Textbook
   Dark navy + ROS cyan theme
   All classes prefixed with r2l-
   ============================================================ */

:root {
  --r2l-bg: #0a1020;
  --r2l-bg2: #111a30;
  --r2l-bg3: #182547;
  --r2l-panel: #131c33;
  --r2l-border: #233358;
  --r2l-text: #e6edf7;
  --r2l-text-dim: #98a8c8;
  --r2l-text-muted: #6c7a99;
  --r2l-cyan: #00abe9;
  --r2l-cyan-dark: #0286b3;
  --r2l-cyan-soft: rgba(0, 171, 233, 0.12);
  --r2l-green: #22c55e;
  --r2l-yellow: #fbbf24;
  --r2l-red: #ef4444;
  --r2l-purple: #a78bfa;
  --r2l-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Fira Code", Consolas, monospace;
}

/* Container */
.r2l-shell {
  background: var(--r2l-bg);
  color: var(--r2l-text);
  min-height: 100vh;
  margin: -1.5rem -15px 0;  /* base.html 마진 보정 */
  padding: 2rem 1rem 4rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  line-height: 1.7;
}
.r2l-shell * { box-sizing: border-box; }
.r2l-shell a { color: var(--r2l-cyan); text-decoration: none; }
.r2l-shell a:hover { text-decoration: underline; }

/* ============================================================
   INDEX PAGE
   ============================================================ */

.r2l-hero {
  max-width: 1200px;
  margin: 0 auto 4rem;
  padding: 2.5rem 1.5rem;
  background: linear-gradient(135deg, var(--r2l-bg2), var(--r2l-bg3));
  border: 1px solid var(--r2l-border);
  border-radius: 24px;
  position: relative;
  overflow: hidden;
}
.r2l-hero::before {
  content: "";
  position: absolute;
  top: -50%; right: -20%;
  width: 60%; height: 200%;
  background: radial-gradient(circle, var(--r2l-cyan-soft), transparent 70%);
  pointer-events: none;
}
.r2l-hero-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 2rem;
  position: relative;
  align-items: center;
}
@media (max-width: 860px) {
  .r2l-hero-grid { grid-template-columns: 1fr; }
}

.r2l-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--r2l-cyan);
  border-radius: 999px;
  color: var(--r2l-cyan);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 1.2rem;
  background: var(--r2l-cyan-soft);
}
.r2l-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--r2l-cyan);
  box-shadow: 0 0 10px var(--r2l-cyan);
  animation: r2lPulse 1.6s ease-in-out infinite;
}
@keyframes r2lPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.r2l-title {
  font-size: clamp(1.7rem, 3.5vw, 2.6rem);
  font-weight: 800;
  line-height: 1.25;
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
}
.r2l-grad {
  background: linear-gradient(90deg, var(--r2l-cyan), var(--r2l-purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.r2l-subtitle {
  font-size: 1.02rem;
  color: var(--r2l-text-dim);
  margin: 0 0 1.4rem;
  max-width: 560px;
}
.r2l-hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 1.6rem; }
.r2l-chip {
  display: inline-block;
  padding: 5px 12px;
  background: var(--r2l-bg);
  border: 1px solid var(--r2l-border);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--r2l-text);
}
.r2l-cta {
  display: inline-block;
  padding: 12px 24px;
  background: var(--r2l-cyan);
  color: #04253a !important;
  font-weight: 700;
  border-radius: 12px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.r2l-cta:hover {
  text-decoration: none !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 171, 233, 0.35);
}

.r2l-hero-art {
  background: var(--r2l-bg);
  border: 1px solid var(--r2l-border);
  border-radius: 16px;
  padding: 1.2rem;
  overflow: hidden;
}
.r2l-ascii {
  font-family: var(--r2l-mono);
  font-size: 0.78rem;
  color: var(--r2l-cyan);
  margin: 0;
  white-space: pre;
  line-height: 1.3;
}

/* Chapter grid */
.r2l-chapters {
  max-width: 1200px;
  margin: 0 auto 4rem;
  padding: 0 0.5rem;
}
.r2l-section-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0 0 0.4rem;
  color: var(--r2l-text);
}
.r2l-section-sub {
  color: var(--r2l-text-muted);
  margin: 0 0 2rem;
}

.r2l-chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}
.r2l-card {
  display: block;
  padding: 1.3rem;
  background: var(--r2l-panel);
  border: 1px solid var(--r2l-border);
  border-radius: 16px;
  color: var(--r2l-text) !important;
  text-decoration: none !important;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.r2l-card:hover {
  transform: translateY(-3px);
  border-color: var(--r2l-cyan);
  box-shadow: 0 10px 30px rgba(0, 171, 233, 0.15);
}
.r2l-card--locked {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.r2l-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}
.r2l-card-no {
  font-family: var(--r2l-mono);
  font-size: 0.78rem;
  color: var(--r2l-cyan);
  font-weight: 700;
  letter-spacing: 0.05em;
}
.r2l-card-status {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
}
.r2l-card-status--open {
  background: rgba(34, 197, 94, 0.15);
  color: var(--r2l-green);
}
.r2l-card-status--lock {
  background: rgba(108, 122, 153, 0.15);
  color: var(--r2l-text-muted);
}
.r2l-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.2rem;
  letter-spacing: -0.01em;
}
.r2l-card-sub {
  font-size: 0.88rem;
  color: var(--r2l-cyan);
  margin-bottom: 0.7rem;
}
.r2l-card-summary {
  font-size: 0.9rem;
  color: var(--r2l-text-dim);
  margin: 0 0 1rem;
  line-height: 1.55;
}
.r2l-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--r2l-text-muted);
}
.r2l-card-tags { display: flex; gap: 4px; }
.r2l-tag {
  font-size: 0.72rem;
  padding: 2px 7px;
  background: var(--r2l-bg);
  border: 1px solid var(--r2l-border);
  border-radius: 6px;
  color: var(--r2l-text-dim);
}

/* Why section */
.r2l-why { max-width: 1200px; margin: 0 auto; padding: 0 0.5rem; }
.r2l-why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.r2l-why-card {
  background: var(--r2l-panel);
  border: 1px solid var(--r2l-border);
  border-radius: 12px;
  padding: 1.2rem;
}
.r2l-why-icon { font-size: 1.8rem; margin-bottom: 0.5rem; }
.r2l-why-card h4 { margin: 0 0 0.3rem; font-size: 1.05rem; }
.r2l-why-card p { margin: 0; color: var(--r2l-text-dim); font-size: 0.9rem; }

/* ============================================================
   CHAPTER PAGE
   ============================================================ */

.r2l-shell--chapter {
  max-width: 1300px;
  margin: -1.5rem auto 0;
  padding: 2rem 1rem 4rem;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 2rem;
}
@media (max-width: 980px) {
  .r2l-shell--chapter { grid-template-columns: 1fr; }
}

.r2l-sidebar {
  position: sticky;
  top: 1rem;
  height: fit-content;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.2rem;
  background: var(--r2l-panel);
  border: 1px solid var(--r2l-border);
  border-radius: 14px;
}
@media (max-width: 980px) {
  .r2l-sidebar { position: static; }
}
.r2l-sidebar-home {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  color: var(--r2l-text-muted) !important;
}
.r2l-sidebar-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--r2l-text-muted);
  margin-bottom: 0.6rem;
  font-weight: 700;
}
.r2l-toc { display: flex; flex-direction: column; gap: 2px; }
.r2l-toc-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--r2l-text-dim) !important;
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
}
.r2l-toc-item:hover {
  background: var(--r2l-bg);
  color: var(--r2l-text) !important;
  text-decoration: none !important;
}
.r2l-toc-item--active {
  background: var(--r2l-cyan-soft);
  color: var(--r2l-cyan) !important;
  font-weight: 600;
}
.r2l-toc-item--locked {
  color: var(--r2l-text-muted) !important;
  opacity: 0.55;
  cursor: not-allowed;
}
.r2l-toc-no {
  font-family: var(--r2l-mono);
  font-size: 0.75rem;
  background: var(--r2l-bg);
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 28px;
  text-align: center;
}

.r2l-main { min-width: 0; }

.r2l-crumb {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--r2l-text-muted);
  margin-bottom: 1.2rem;
}
.r2l-crumb a { color: var(--r2l-text-muted) !important; }

.r2l-ch-header {
  padding: 1.5rem 0 2rem;
  border-bottom: 1px solid var(--r2l-border);
  margin-bottom: 2.5rem;
}
.r2l-ch-no {
  font-family: var(--r2l-mono);
  color: var(--r2l-cyan);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}
.r2l-ch-title {
  font-size: clamp(1.7rem, 3.5vw, 2.4rem);
  font-weight: 800;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}
.r2l-ch-subtitle {
  color: var(--r2l-text-dim);
  margin: 0 0 1rem;
  font-size: 1.05rem;
}
.r2l-ch-meta { display: flex; gap: 10px; align-items: center; font-size: 0.85rem; color: var(--r2l-text-muted); }

/* Body content */
.r2l-body {
  max-width: 760px;
  font-size: 1rem;
}
.r2l-sec { margin-bottom: 2.5rem; }
.r2l-h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
  color: var(--r2l-text);
}
.r2l-h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 1.5rem 0 0.7rem;
  color: var(--r2l-text);
}
.r2l-body p { margin: 0 0 1rem; color: var(--r2l-text); }
.r2l-body b, .r2l-body strong { color: var(--r2l-text); }
.r2l-body code {
  font-family: var(--r2l-mono);
  font-size: 0.88em;
  background: var(--r2l-bg3);
  color: var(--r2l-cyan);
  padding: 2px 6px;
  border-radius: 4px;
}
.r2l-body kbd {
  font-family: var(--r2l-mono);
  font-size: 0.8em;
  background: var(--r2l-bg3);
  border: 1px solid var(--r2l-border);
  border-bottom-width: 2px;
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--r2l-text);
}

/* Bullets */
.r2l-bullet { padding-left: 1.4rem; margin: 0 0 1rem; color: var(--r2l-text); }
.r2l-bullet li { margin: 0.4rem 0; }
.r2l-bullet--num { list-style: decimal; }
.r2l-bullet:not(.r2l-bullet--num) { list-style: disc; }

/* Acronym box */
.r2l-acronym {
  display: flex;
  gap: 12px;
  background: var(--r2l-cyan-soft);
  border-left: 3px solid var(--r2l-cyan);
  padding: 12px 16px;
  border-radius: 8px;
  margin: 1.2rem 0;
}
.r2l-acronym-tag {
  font-family: var(--r2l-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--r2l-cyan);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-top: 4px;
  white-space: nowrap;
}
.r2l-acronym-body { font-size: 0.92rem; color: var(--r2l-text); }
.r2l-acronym-body b { color: var(--r2l-cyan); }

/* Quote / Tip */
.r2l-quote {
  background: var(--r2l-bg2);
  border-left: 3px solid var(--r2l-purple);
  padding: 14px 18px;
  border-radius: 8px;
  margin: 1.2rem 0;
  color: var(--r2l-text);
  font-size: 0.95rem;
}
.r2l-tip {
  background: rgba(251, 191, 36, 0.08);
  border-left: 3px solid var(--r2l-yellow);
  padding: 12px 16px;
  border-radius: 8px;
  margin: 1.2rem 0;
  color: var(--r2l-text);
  font-size: 0.92rem;
}

/* Code blocks */
.r2l-code, .r2l-output {
  background: #050810;
  border: 1px solid var(--r2l-border);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 1rem 0;
  overflow-x: auto;
  font-family: var(--r2l-mono);
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--r2l-text);
}
.r2l-code code, .r2l-output code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.r2l-output {
  border-color: #2d4a2d;
  color: #b8e6b8;
}
.r2l-ascii {
  background: #050810;
  border: 1px solid var(--r2l-border);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 1rem 0;
  overflow-x: auto;
  font-family: var(--r2l-mono);
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--r2l-cyan);
}

/* Examples grid */
.r2l-examples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  margin: 1.2rem 0;
}
.r2l-ex {
  background: var(--r2l-panel);
  border: 1px solid var(--r2l-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
  color: var(--r2l-text);
  text-align: center;
}

/* Three cards */
.r2l-three {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 1.2rem 0;
}
.r2l-three-card {
  background: var(--r2l-panel);
  border: 1px solid var(--r2l-border);
  border-radius: 12px;
  padding: 1.2rem;
  text-align: center;
}
.r2l-three-emoji { font-size: 2rem; margin-bottom: 0.4rem; }
.r2l-three-name {
  font-weight: 700;
  color: var(--r2l-cyan);
  margin-bottom: 0.4rem;
  font-size: 1rem;
}
.r2l-three-desc { font-size: 0.85rem; color: var(--r2l-text-dim); }

/* Comparison */
.r2l-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.2rem 0;
}
@media (max-width: 660px) {
  .r2l-compare { grid-template-columns: 1fr; }
}
.r2l-compare-col {
  background: var(--r2l-panel);
  border: 1px solid var(--r2l-border);
  border-radius: 12px;
  padding: 1.2rem;
}
.r2l-compare-col--new { border-color: var(--r2l-cyan); }
.r2l-compare-title {
  font-weight: 700;
  margin-bottom: 0.8rem;
  font-size: 1rem;
}
.r2l-compare-title--old { color: var(--r2l-text-muted); }
.r2l-compare-title--new { color: var(--r2l-cyan); }

/* Table */
.r2l-table {
  background: var(--r2l-panel);
  border: 1px solid var(--r2l-border);
  border-radius: 12px;
  margin: 1.2rem 0;
  overflow: hidden;
  font-size: 0.9rem;
}
.r2l-table-head {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  background: var(--r2l-bg3);
  font-weight: 700;
  padding: 10px 14px;
  color: var(--r2l-cyan);
  font-size: 0.85rem;
}
.r2l-table-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  padding: 12px 14px;
  border-top: 1px solid var(--r2l-border);
}
.r2l-table-row > div { padding-right: 8px; }

/* Quiz */
.r2l-quiz {
  background: var(--r2l-panel);
  border: 1px solid var(--r2l-border);
  border-left: 4px solid var(--r2l-cyan);
  border-radius: 12px;
  padding: 1.4rem;
  margin: 1.5rem 0;
}
.r2l-quiz-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--r2l-cyan);
  background: var(--r2l-cyan-soft);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 0.6rem;
}
.r2l-quiz-q {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 1rem;
  color: var(--r2l-text);
}
.r2l-quiz-opts { display: flex; flex-direction: column; gap: 8px; }
.r2l-opt {
  text-align: left;
  padding: 12px 16px;
  background: var(--r2l-bg);
  border: 1px solid var(--r2l-border);
  border-radius: 8px;
  color: var(--r2l-text);
  font-size: 0.93rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
}
.r2l-opt:hover:not(:disabled) {
  border-color: var(--r2l-cyan);
  background: var(--r2l-cyan-soft);
}
.r2l-opt:disabled { cursor: default; }
.r2l-opt--correct {
  border-color: var(--r2l-green) !important;
  background: rgba(34, 197, 94, 0.12) !important;
  color: #c9f3d6 !important;
}
.r2l-opt--wrong {
  border-color: var(--r2l-red) !important;
  background: rgba(239, 68, 68, 0.12) !important;
  color: #f5c7c7 !important;
}
.r2l-quiz-result {
  margin-top: 0.8rem;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 1.2em;
}
.r2l-quiz-result--correct { color: var(--r2l-green); }
.r2l-quiz-result--wrong { color: var(--r2l-red); }

/* Summary */
.r2l-summary {
  background: linear-gradient(135deg, var(--r2l-bg2), var(--r2l-bg3));
  border: 1px solid var(--r2l-cyan);
  border-radius: 16px;
  padding: 1.5rem;
}
.r2l-summary .r2l-h2 { color: var(--r2l-cyan); }

/* Complete button */
.r2l-complete {
  text-align: center;
  margin: 3rem 0 2rem;
}
.r2l-complete-btn {
  padding: 12px 24px;
  background: transparent;
  border: 2px solid var(--r2l-cyan);
  color: var(--r2l-cyan);
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.15s;
  font-family: inherit;
}
.r2l-complete-btn:hover { background: var(--r2l-cyan-soft); }
.r2l-complete-btn--done {
  background: var(--r2l-cyan);
  color: #04253a;
}

/* Pager */
.r2l-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
}
.r2l-pager-link {
  display: block;
  padding: 1rem 1.2rem;
  background: var(--r2l-panel);
  border: 1px solid var(--r2l-border);
  border-radius: 12px;
  color: var(--r2l-text) !important;
  transition: border-color 0.15s, transform 0.15s;
}
.r2l-pager-link:hover {
  border-color: var(--r2l-cyan);
  text-decoration: none !important;
  transform: translateY(-2px);
}
.r2l-pager-link--next { text-align: right; }
.r2l-pager-label {
  display: block;
  font-size: 0.8rem;
  color: var(--r2l-cyan);
  margin-bottom: 3px;
}
.r2l-pager-title {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
}

/* Coming Soon */
.r2l-coming {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.r2l-coming-inner {
  text-align: center;
  max-width: 500px;
  padding: 3rem 1.5rem;
}
.r2l-coming-lock { font-size: 4rem; margin-bottom: 1rem; }
.r2l-coming-no {
  font-family: var(--r2l-mono);
  color: var(--r2l-cyan);
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.r2l-coming-title { font-size: 1.8rem; margin: 0 0 0.5rem; }
.r2l-coming-sub { color: var(--r2l-cyan); margin-bottom: 1rem; }
.r2l-coming-summary { color: var(--r2l-text-dim); margin-bottom: 1.5rem; }
.r2l-coming-status {
  display: inline-block;
  padding: 8px 16px;
  background: var(--r2l-cyan-soft);
  border: 1px solid var(--r2l-cyan);
  border-radius: 999px;
  color: var(--r2l-cyan);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}
