/* ==========================================================================
   TapBrain Prototype Template - Tutorial Website Stylesheet
   Modern, responsive documentation theme with Light / Dark support
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, monospace;

  /* Light Theme Variables */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-sidebar: #f1f5f9;
  --bg-code: #f1f5f9;
  --bg-code-block: #0f172a;
  --border-color: #e2e8f0;
  --border-subtle: #edf2f7;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-link: #2563eb;
  --text-link-hover: #1d4ed8;

  --accent-primary: #3b82f6;
  --accent-secondary: #06b6d4;
  --accent-badge: #e0f2fe;
  --accent-badge-text: #0369a1;

  /* Callout colors */
  --callout-note-bg: #eff6ff;
  --callout-note-border: #3b82f6;
  --callout-note-title: #1e40af;

  --callout-warn-bg: #fffbeb;
  --callout-warn-border: #f59e0b;
  --callout-warn-title: #b45309;

  --callout-exercise-bg: #f0fdf4;
  --callout-exercise-border: #10b981;
  --callout-exercise-title: #047857;

  /* Spacing & Sizes */
  --sidebar-width: 290px;
  --toc-width: 240px;
  --header-height: 60px;
  --content-max-width: 880px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
  /* Dark Theme Variables */
  --bg-body: #090d16;
  --bg-surface: #0f172a;
  --bg-sidebar: #0b1120;
  --bg-code: #1e293b;
  --bg-code-block: #020617;
  --border-color: #1e293b;
  --border-subtle: #172033;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --text-link: #60a5fa;
  --text-link-hover: #93c5fd;

  --accent-primary: #3b82f6;
  --accent-secondary: #38bdf8;
  --accent-badge: #1e293b;
  --accent-badge-text: #38bdf8;

  --callout-note-bg: rgba(30, 58, 138, 0.2);
  --callout-note-border: #3b82f6;
  --callout-note-title: #93c5fd;

  --callout-warn-bg: rgba(180, 83, 9, 0.2);
  --callout-warn-border: #f59e0b;
  --callout-warn-title: #fcd34d;

  --callout-exercise-bg: rgba(4, 120, 87, 0.2);
  --callout-exercise-border: #10b981;
  --callout-exercise-title: #6ee7b7;
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-main);
  background-color: var(--bg-body);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--text-link-hover);
  text-decoration: underline;
}

p, ul, ol, table, blockquote, .callout {
  margin-bottom: 1.25rem;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 0.85rem;
  scroll-margin-top: calc(var(--header-height) + 1.5rem);
}

h1 {
  font-size: 2.1rem;
  letter-spacing: -0.025em;
  margin-top: 0;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-color);
}

h2 {
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
}

h3 {
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

h4 {
  font-size: 1.05rem;
}

ul, ol {
  padding-left: 1.6rem;
}

li {
  margin-bottom: 0.4rem;
}

strong {
  font-weight: 600;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background-color: var(--bg-code);
  padding: 0.18em 0.42em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

pre {
  position: relative;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-md);
  background-color: var(--bg-code-block);
  border: 1px solid var(--border-color);
  overflow-x: auto;
}

pre code {
  display: block;
  padding: 1.2rem;
  background: transparent;
  border: none;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #e2e8f0;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 1rem;
  background-color: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  color: #94a3b8;
  font-family: var(--font-mono);
}

.copy-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Mobile Top Header */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 50;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none !important;
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.15rem;
}

.brand-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 1.1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.theme-toggle-btn, .menu-toggle-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover, .menu-toggle-btn:hover {
  background-color: var(--bg-code);
  border-color: var(--accent-primary);
}

.menu-toggle-btn {
  display: none;
}

/* Sidebar Navigation */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  z-index: 40;
  padding: 1.25rem 0.85rem 2rem 1rem;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding-bottom: 1.2rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.nav-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  padding: 0.5rem 0.6rem 0.3rem;
  margin-top: 0.75rem;
}

.nav-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-link-item {
  margin-bottom: 0.2rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s ease;
  text-decoration: none !important;
}

.nav-link:hover {
  color: var(--text-main);
  background-color: var(--bg-surface);
}

.nav-link.active {
  color: var(--accent-primary);
  background-color: var(--bg-surface);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.nav-link-badge {
  font-size: 0.75rem;
  padding: 1px 6px;
  background-color: var(--accent-badge);
  color: var(--accent-badge-text);
  border-radius: 999px;
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: center;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 2.5rem 2rem 4rem 2.5rem;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.content-article {
  width: 100%;
  max-width: var(--content-max-width);
  min-width: 0;
}

/* Table of Contents (Right Sticky Bar) */
.toc-wrapper {
  width: var(--toc-width);
  margin-left: 2.5rem;
  position: sticky;
  top: calc(var(--header-height) + 2rem);
  height: fit-content;
  max-height: calc(100vh - var(--header-height) - 4rem);
  overflow-y: auto;
  font-size: 0.82rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border-color);
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.toc-list {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.toc-item {
  margin-bottom: 0.4rem;
}

.toc-link {
  color: var(--text-muted);
  display: block;
  text-decoration: none !important;
  transition: color 0.15s ease;
  line-height: 1.4;
}

.toc-link:hover, .toc-link.active {
  color: var(--accent-primary);
  font-weight: 600;
}

.toc-h3 {
  padding-left: 0.85rem;
}

/* Callout Boxes */
.callout {
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius-md);
  margin: 1.5rem 0;
  border-left: 4px solid;
  font-size: 0.95rem;
  line-height: 1.6;
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.callout-note {
  background-color: var(--callout-note-bg);
  border-color: var(--callout-note-border);
}
.callout-note .callout-title {
  color: var(--callout-note-title);
}

.callout-warning {
  background-color: var(--callout-warn-bg);
  border-color: var(--callout-warn-border);
}
.callout-warning .callout-title {
  color: var(--callout-warn-title);
}

.callout-exercise {
  background-color: var(--callout-exercise-bg);
  border-color: var(--callout-exercise-border);
}
.callout-exercise .callout-title {
  color: var(--callout-exercise-title);
}

.callout p:last-child {
  margin-bottom: 0;
}

/* Responsive Tables */
.table-container {
  width: 100%;
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

th, td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: var(--bg-sidebar);
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: rgba(0, 0, 0, 0.015);
}

[data-theme="dark"] tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Page Navigation Footer (Previous / Next) */
.page-nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border-color);
  gap: 1rem;
}

.page-nav-link {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  text-decoration: none !important;
  transition: all 0.2s ease;
  min-width: 160px;
}

.page-nav-link:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.page-nav-prev {
  align-items: flex-start;
}

.page-nav-next {
  align-items: flex-end;
  margin-left: auto;
}

.page-nav-sub {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  font-weight: 600;
}

.page-nav-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-top: 0.2rem;
}

/* Mermaid Diagrams Container */
.mermaid-wrapper {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin: 1.5rem 0;
  overflow-x: auto; /* wide diagrams scroll on phones instead of shrinking the text */
}

.mermaid-wrapper pre.mermaid {
  background: transparent;
  border: 0;
  margin: 0;
  padding: 0;
  text-align: center;
  /* Labels inherit from <pre>: reset so mermaid's text measurement matches what is drawn */
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  white-space: normal;
  color: var(--text-main);
}

/* Natural size (useMaxWidth: false), centered; never smaller than readable */
.mermaid-wrapper pre.mermaid svg {
  max-width: none;
  height: auto;
  display: inline-block;
}

/* Badges & Pills */
.badge {
  display: inline-block;
  padding: 0.15em 0.5em;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background-color: var(--bg-code);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.badge-primary {
  background-color: var(--accent-badge);
  color: var(--accent-badge-text);
  border-color: transparent;
}

/* Back to top button */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 30;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background: var(--text-link-hover);
  transform: translateY(-2px);
}

/* Mobile backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 35;
  backdrop-filter: blur(2px);
}

/* Responsive Media Queries */
@media (max-width: 1200px) {
  .toc-wrapper {
    display: none;
  }
  .main-wrapper {
    padding-right: 2.5rem;
  }
}

@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .main-wrapper {
    margin-left: 0;
    padding: 1.75rem 1.25rem 3rem 1.25rem;
  }

  .menu-toggle-btn {
    display: flex;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.65rem;
  }
  h2 {
    font-size: 1.3rem;
  }
  h3 {
    font-size: 1.1rem;
  }
  .page-nav-footer {
    flex-direction: column;
  }
  .page-nav-link {
    width: 100%;
  }
  .page-nav-next {
    margin-left: 0;
    align-items: flex-start;
  }
}

/* 375px mobile minimum screen protection */
@media (max-width: 375px) {
  body {
    overflow-x: hidden;
  }
  .main-wrapper {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
  pre code {
    padding: 0.85rem;
    font-size: 0.82rem;
  }
}

/* Learning roadmap (index.html §4): two week cards, stacked on narrow screens */
.roadmap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.roadmap-week {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-top: 4px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.2rem 1.2rem;
  box-shadow: var(--shadow-sm);
}

.roadmap-week + .roadmap-week {
  border-top-color: var(--callout-exercise-border);
}

.roadmap-week-header {
  margin-bottom: 0.9rem;
}

.roadmap-week-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.roadmap-week-title {
  margin: 0.15rem 0 0;
  font-size: 1.15rem;
  color: var(--text-main);
}

.roadmap-days {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

/* Vertical timeline line behind the badges */
.roadmap-days::before {
  content: "";
  position: absolute;
  left: 2.6rem;
  top: 0.6rem;
  bottom: 0.6rem;
  width: 2px;
  background-color: var(--border-color);
}

.roadmap-day {
  position: relative;
  display: grid;
  grid-template-columns: 5.2rem minmax(0, 1fr);
  align-items: start;
  gap: 0.75rem;
  padding: 0.55rem 0;
  margin: 0;
}

.roadmap-badge {
  position: relative;
  justify-self: center;
  min-width: 4.6rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.6;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background-color: var(--accent-badge);
  color: var(--accent-badge-text);
  border: 1px solid var(--border-color);
}

.roadmap-task {
  font-size: 0.97rem;
  line-height: 1.55;
  color: var(--text-main);
}

@media (max-width: 760px) {
  .roadmap {
    grid-template-columns: minmax(0, 1fr);
  }
}
