/* ==========================================
   NKDevSpace — Tutorial Pages CSS
   Uses same color system as style.css
   ========================================== */

:root {
  --navy: #1e3a8a;
  --blue: #2563eb;
  --blue-light: #3b82f6;
  --blue-pale: #dbeafe;
  --white: #ffffff;
  --off-white: #f8faff;
  --text-dark: #0f172a;
  --text-mid: #334155;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 2px 8px rgba(30,58,138,0.08);
  --shadow-md: 0 8px 30px rgba(30,58,138,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.3s cubic-bezier(0.4,0,0.2,1);
  --font: 'Poppins', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--off-white);
  color: var(--text-dark);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

body.dark {
  --white: #0f172a;
  --off-white: #1e293b;
  --text-dark: #f1f5f9;
  --text-mid: #cbd5e1;
  --text-light: #94a3b8;
  --border: #334155;
  --blue-pale: rgba(37,99,235,0.18);
}

body.dark .tut-step,
body.dark .overview-card,
body.dark .tut-nav-back,
body.dark .tut-nav-next {
  background: #1e293b;
  border-color: #334155;
}

body.dark .explain-block { background: #1e293b; border-color: #334155; }
body.dark .explain-code { background: rgba(37,99,235,0.15); border-bottom-color: #334155; }
body.dark .explain-code code { color: #7dd3fc; }
body.dark .explain-text { color: var(--text-mid); }
body.dark .explain-text strong { color: #e2e8f0; }
body.dark .tut-step code { background: rgba(37,99,235,0.18); color: #7dd3fc; }
body.dark .tut-tip { background: rgba(37,99,235,0.12); border-left-color: var(--blue-light); }
body.dark .tut-tip span { color: var(--text-mid); }
body.dark .tut-tip span strong { color: #e2e8f0; }
body.dark .tut-page-footer { background: #0f172a; border-top-color: #334155; }
body.dark .wiring-diagram { border-color: #334155; }

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* ====== TOP BAR ====== */
.top-bar {
  background: linear-gradient(135deg, var(--navy), var(--blue));
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Dark toggle inside tutorial top-bar */
.top-bar .dark-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  border: 1.5px solid rgba(255,255,255,0.25);
  border-radius: 100px;
  padding: 6px 14px 6px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: var(--font);
}

.top-bar .dark-toggle:hover {
  background: rgba(255,255,255,0.28);
  color: white;
}

.top-bar .dark-toggle i { font-size: 0.9rem; }

@media (max-width: 480px) {
  .top-bar .dark-toggle-label { display: none; }
  .top-bar .dark-toggle { padding: 6px 10px; }
}

.back-btn {
  color: rgba(255,255,255,0.8);
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color var(--transition);
}

.back-btn:hover { color: white; }

.top-bar-logo {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.logo-nk {
  font-family: 'Space Mono', monospace;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -3px;
  color: white;
  line-height: 1;
}

.logo-dev {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.6);
  line-height: 1;
}

/* ====== HERO ====== */
.tut-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
  padding: 56px 24px 48px;
  text-align: center;
  color: white;
}

.tut-hero-inner {
  max-width: 720px;
  margin: 0 auto;
}

.tut-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 100px;
  margin-bottom: 20px;
  border: 1px solid rgba(255,255,255,0.25);
  backdrop-filter: blur(10px);
}

.tut-hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 900;
  margin-bottom: 14px;
  line-height: 1.2;
}

.tut-hero p {
  color: rgba(255,255,255,0.78);
  font-size: 1rem;
  margin-bottom: 24px;
  line-height: 1.7;
}

.tut-meta {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.tut-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.1);
  padding: 6px 14px;
  border-radius: 100px;
}

/* ====== MAIN CONTAINER ====== */
.tut-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* ====== OVERVIEW CARDS ====== */
.tut-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

.overview-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.overview-card > i {
  font-size: 1.4rem;
  color: var(--blue);
  margin-top: 2px;
  flex-shrink: 0;
}

.overview-card h5 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.overview-card ul li {
  font-size: 0.88rem;
  color: var(--text-mid);
  padding: 3px 0 3px 14px;
  position: relative;
  word-break: break-word;
  overflow-wrap: break-word;
}

.overview-card ul li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--blue);
  font-weight: 700;
}

/* ====== STEP BLOCKS ====== */
.tut-step {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  margin-bottom: 20px;
  position: relative;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 14px;
  border-radius: 100px;
  margin-bottom: 14px;
}

.tut-step h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 12px;
}

.tut-step p {
  font-size: 0.92rem;
  color: var(--text-mid);
  margin-bottom: 14px;
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: break-word;
}

.tut-step ol {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tut-step ol li {
  font-size: 0.92rem;
  color: var(--text-mid);
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: break-word;
}

.tut-step ol li strong { color: var(--text-dark); }

.tut-step code {
  background: var(--blue-pale);
  color: var(--navy);
  font-family: 'Space Mono', monospace;
  font-size: 0.82rem;
  padding: 2px 8px;
  border-radius: 6px;
}

/* ====== TIP BOX ====== */
.tut-tip {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--blue-pale);
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 16px;
  margin-top: 16px;
}

.tut-tip i {
  color: var(--blue);
  font-size: 1rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.tut-tip span {
  font-size: 0.88rem;
  color: var(--text-mid);
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: break-word;
}

.tut-tip span strong { color: var(--navy); }

/* ====== CODE BLOCK ====== */
.code-block {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid var(--border);
  margin-top: 14px;
}

.code-header {
  background: var(--navy);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.code-header span {
  color: rgba(255,255,255,0.7);
  font-size: 0.82rem;
  font-family: 'Space Mono', monospace;
  display: flex;
  align-items: center;
  gap: 8px;
}

.copy-btn {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.copy-btn:hover {
  background: rgba(255,255,255,0.22);
  color: white;
}

.code-block pre {
  background: #0f172a;
  padding: 20px;
  overflow-x: auto;
  margin: 0;
}

.code-block pre code {
  background: none;
  color: #e2e8f0;
  font-family: 'Space Mono', monospace;
  font-size: 0.84rem;
  line-height: 1.7;
  padding: 0;
  border-radius: 0;
  white-space: pre;
}

/* ====== WIRING DIAGRAM ====== */
.wiring-diagram {
  margin-top: 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.wiring-label {
  background: var(--navy);
  color: rgba(255,255,255,0.85);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wiring-diagram img {
  width: 100%;
  display: block;
  background: var(--off-white);
}

/* ====== CODE EXPLANATION ====== */
.code-explain {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.explain-block {
  background: var(--off-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.explain-code {
  background: var(--blue-pale);
  padding: 10px 14px;
  border-bottom: 1.5px solid var(--border);
}

.explain-code code {
  background: none;
  color: var(--navy);
  font-family: 'Space Mono', monospace;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0;
  word-break: break-all;
}

.explain-text {
  padding: 12px 14px;
  font-size: 0.88rem;
  color: var(--text-mid);
  line-height: 1.65;
  word-break: break-word;
  overflow-wrap: break-word;
}

.explain-text strong { color: var(--navy); }

/* ====== CHALLENGE LIST ====== */
.challenge-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.challenge-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--text-mid);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
}

.challenge-list li i {
  color: var(--blue);
  font-size: 0.9rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.challenge-list li strong { color: var(--text-dark); }

/* ====== FOOTER CTA ====== */
.tut-footer-cta {
  background: linear-gradient(135deg, var(--navy), var(--blue));
  border-radius: var(--radius);
  padding: 32px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 32px 0 24px;
  flex-wrap: wrap;
}

.tut-footer-cta h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: white;
  margin-bottom: 6px;
}

.tut-footer-cta p {
  font-size: 0.88rem;
  color: rgba(255,255,255,0.72);
}

.tut-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  color: var(--navy);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 100px;
  white-space: nowrap;
  transition: var(--transition);
  flex-shrink: 0;
}

.tut-cta-btn:hover {
  background: var(--blue-pale);
  transform: translateY(-2px);
}

/* ====== NAV BUTTONS ====== */
.tut-nav-btns {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.tut-nav-back,
.tut-nav-next {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1.5px solid var(--border);
  color: var(--text-mid);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.tut-nav-back:hover,
.tut-nav-next:hover {
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: var(--shadow-sm);
}

/* ====== PAGE FOOTER ====== */
.tut-page-footer {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-light);
  padding: 24px;
  border-top: 1px solid var(--border);
  background: var(--white);
}

.tut-page-footer a {
  color: var(--blue);
  font-weight: 500;
}

/* ====== EXTRA CLASSES (Student Management & Tic Tac Toe) ====== */
.section-sep {
  border: none;
  border-top: 1.5px solid var(--border);
  margin: 24px 0;
}

.tut-step h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--blue);
  margin: 20px 0 10px;
}

code.inline {
  background: var(--blue-pale);
  color: var(--navy);
  font-family: 'Space Mono', monospace;
  font-size: 0.82rem;
  padding: 2px 8px;
  border-radius: 6px;
}

.output-block {
  background: #0f172a;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  color: #7dd3fc;
  line-height: 1.9;
  margin: 14px 0;
  white-space: pre;
  overflow-x: auto;
}

.tut-info {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--blue-pale);
  border-left: 3px solid var(--blue-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 16px;
  margin-top: 16px;
}

.tut-info i {
  color: var(--blue);
  font-size: 1rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.tut-info span {
  font-size: 0.88rem;
  color: var(--text-mid);
  line-height: 1.6;
  word-break: break-word;
}

.tut-info span strong { color: var(--navy); }

.func-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.86rem;
  overflow-x: auto;
  display: block;
}

.func-table th {
  background: var(--blue-pale);
  color: var(--navy);
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.func-table td {
  padding: 10px 14px;
  border-bottom: 1.5px solid var(--border);
  color: var(--text-mid);
  vertical-align: top;
  line-height: 1.6;
}

.func-table td:first-child {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  color: var(--blue);
  white-space: nowrap;
  font-weight: 700;
}

.func-table tr:last-child td { border-bottom: none; }

.swing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 14px 0;
}

.swing-card {
  background: var(--off-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}

.swing-card .swing-icon {
  font-size: 1.4rem;
  color: var(--blue);
  margin-bottom: 8px;
}

.swing-card h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 6px;
  font-family: 'Space Mono', monospace;
}

.swing-card p {
  font-size: 0.84rem;
  color: var(--text-light);
  margin: 0;
  line-height: 1.6;
}

/* Dark mode extras */
body.dark .output-block { background: #020817; border-color: #334155; }
body.dark code.inline { background: rgba(37,99,235,0.18); color: #7dd3fc; }
body.dark .tut-info { background: rgba(37,99,235,0.1); border-left-color: var(--blue); }
body.dark .tut-info span { color: var(--text-mid); }
body.dark .tut-info span strong { color: #7dd3fc; }
body.dark .func-table th { background: rgba(37,99,235,0.15); color: #7dd3fc; }
body.dark .func-table td { color: var(--text-mid); border-bottom-color: #334155; }
body.dark .func-table td:first-child { color: #7dd3fc; }
body.dark .swing-card { background: #1e293b; border-color: #334155; }
body.dark .swing-card h4 { color: var(--text-dark); }
body.dark .swing-card p { color: var(--text-light); }
body.dark .section-sep { border-top-color: #334155; }
body.dark .tut-step h3 { color: var(--blue-light); }

@media (max-width: 768px) {
  .swing-grid { grid-template-columns: 1fr; }
  .func-table { font-size: 0.78rem; }
  .func-table th, .func-table td { padding: 8px 10px; }
  .output-block { font-size: 0.72rem; padding: 12px 12px; }
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
  .top-bar { padding: 12px 16px; }
  .tut-hero { padding: 40px 16px 36px; }
  .tut-hero h1 { font-size: clamp(1.4rem, 6vw, 2rem); }
  .tut-hero p { font-size: 0.92rem; }
  .tut-meta { gap: 8px; }
  .tut-meta span { font-size: 0.78rem; padding: 5px 10px; }

  .tut-container { padding: 24px 16px 60px; }

  .tut-overview { grid-template-columns: 1fr; }
  .overview-card { padding: 18px; }

  .tut-step { padding: 20px 16px 18px; }
  .tut-step h2 { font-size: 1.05rem; }
  .tut-step ol { padding-left: 16px; }

  .code-block pre { padding: 14px 12px; overflow-x: auto; }
  .code-block pre code { font-size: 0.75rem; }
  .code-header { padding: 8px 12px; }
  .code-header span { font-size: 0.75rem; }
  .copy-btn { padding: 4px 10px; font-size: 0.72rem; }

  .tut-tip { padding: 12px 14px; }
  .tut-tip span { font-size: 0.84rem; }

  .tut-footer-cta { flex-direction: column; text-align: center; padding: 24px 18px; }
  .tut-cta-btn { width: 100%; justify-content: center; }

  .tut-nav-btns { flex-direction: column; gap: 10px; }
  .tut-nav-back, .tut-nav-next { justify-content: center; width: 100%; }
}

@media (max-width: 400px) {
  .tut-container { padding: 20px 12px 48px; }
  .tut-step { padding: 16px 14px; }
  .overview-card { padding: 14px; flex-direction: column; gap: 10px; }
  .tut-footer-cta { padding: 20px 14px; }
}
