/**
 * lesson-web.css — web-only layout additions for the GitHub Pages site.
 * Content styles live in lesson-theme.css; this file adds the two-column
 * layout, sidebar, mobile toggle, catalog cards, and terminal command blocks.
 */

/* ===== Page layout ===== */

body.tt-lesson-web {
  display: grid;
  grid-template-columns: 290px 1fr;
  grid-template-rows: auto;
  grid-template-areas: "sidebar main";
  min-height: 100vh;
  padding: 0;
  gap: 0;
}

/* ===== Sidebar ===== */

.tt-sidebar {
  grid-area: sidebar;
  background: var(--vscode-sideBar-background, #111827);
  border-right: 1px solid var(--tt-border, rgba(255,255,255,0.1));
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 0 0 32px;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--tt-border, rgba(255,255,255,0.1));
  position: sticky;
  top: 0;
  background: var(--vscode-sideBar-background, #111827);
  z-index: 10;
}

.sidebar-logo {
  color: var(--vscode-foreground);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1.3;
  display: block;
}

.sidebar-logo-text {
  display: block;
  font-weight: 300;
  letter-spacing: 0.02em;
}

.sidebar-logo-text strong {
  font-weight: 700;
  color: var(--tt-primary);
}

.sidebar-category {
  padding: 16px 0 8px;
}

/* Top pages section (Welcome, Install & Overview, Step Zero) sits above
   lesson categories with a subtle divider below it. */
.sidebar-top-pages {
  padding-top: 8px;
  border-bottom: 1px solid var(--tt-border, rgba(255,255,255,0.1));
  margin-bottom: 4px;
}

.sidebar-category-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tt-muted, rgba(226,232,240,0.5));
  padding: 0 16px 4px;
  margin: 0;
  border-bottom: none;
}

.sidebar-lesson-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-lesson-list li {
  margin: 0;
  padding: 0;
}

.sidebar-lesson-list li a {
  display: block;
  padding: 7px 16px;
  font-size: 0.82rem;
  color: var(--vscode-foreground);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.sidebar-lesson-list li a:hover {
  background: var(--tt-hover-bg);
  text-decoration: none;
}

.sidebar-lesson-list li.active a,
.sidebar-lesson-list li a[aria-current="page"] {
  border-left-color: var(--tt-primary);
  color: var(--tt-primary);
  background: var(--tt-hover-bg);
  font-weight: 600;
}

/* ===== Main content area ===== */

.tt-main-content {
  grid-area: main;
  overflow-y: auto;
  padding: 0;
}

/* Full-width layout for sidebar-less pages (e.g. /install/) */
.tt-lesson-web.no-sidebar {
  display: block;
}

.tt-full-width-content {
  width: 100%;
  overflow-y: auto;
  padding: 0;
}

.tt-full-width-content .lesson-content {
  max-width: 100%;
  padding: 0;
}

/* Override lesson-theme.css 900px cap for the install landing page.
   Body class is page-install (set by buildPages bodyClass template).
   Applies whether or not the sidebar is present. */
body.page-install .lesson-content {
  max-width: 100%;
  padding: 0;
}

.tt-lesson-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  background: var(--vscode-panel-background, #151e2b);
  border-bottom: 1px solid var(--tt-border, rgba(255,255,255,0.1));
}

.meta-time {
  font-size: 0.8rem;
  color: var(--tt-muted);
  padding: 4px 8px;
  background: var(--tt-hover-bg);
  border-radius: 4px;
}

/* ===== Mobile sidebar toggle ===== */

#sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  background: var(--tt-primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}

/* ===== Terminal command blocks ===== */

.tt-web-command {
  background: var(--tt-code-bg, #0f1923);
  border: 1px solid var(--tt-border, rgba(255,255,255,0.1));
  border-left: 4px solid var(--tt-primary);
  border-radius: 4px;
  margin: 16px 0;
  overflow: hidden;
}

.tt-web-command-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--tt-hover-bg);
  border-bottom: 1px solid var(--tt-border, rgba(255,255,255,0.06));
}

.tt-web-command-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tt-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tt-web-command-copy {
  background: var(--tt-primary);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.tt-web-command-copy:hover {
  background: var(--tt-primary-light);
}

.tt-web-command-copy.copied {
  background: var(--tt-success);
}

.tt-web-command-code {
  margin: 0;
  padding: 14px;
  background: transparent;
  border: none;
  border-radius: 0;
  font-size: 0.88em;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== Code block wrapper (for injected copy buttons) ===== */

.code-block-wrapper {
  position: relative;
}

.code-block-wrapper .copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--tt-primary);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.code-block-wrapper:hover .copy-button,
.code-block-wrapper .copy-button:focus {
  opacity: 1;
}

.code-block-wrapper .copy-button.copied {
  background: var(--tt-success);
}

/* ===== Catalog / home page ===== */

.catalog-intro {
  color: var(--tt-muted);
  margin-bottom: 24px;
  font-size: 1.05rem;
}

.hw-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
}

.hw-filter-chip {
  background: var(--tt-hover-bg);
  color: var(--vscode-foreground);
  border: 1px solid var(--tt-border, rgba(255,255,255,0.15));
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.hw-filter-chip:hover {
  background: color-mix(in srgb, var(--tt-primary) 15%, var(--vscode-background));
  border-color: var(--tt-primary);
  color: var(--tt-primary);
}

.hw-filter-chip.active {
  background: var(--tt-primary);
  border-color: var(--tt-primary);
  color: white;
}

.lesson-category-section {
  margin-bottom: 48px;
}

.lesson-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.lesson-card {
  display: block;
  background: var(--vscode-editor-background);
  border: 1px solid var(--tt-border, rgba(255,255,255,0.1));
  border-radius: 8px;
  padding: 16px;
  text-decoration: none;
  color: var(--vscode-foreground);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.lesson-card:hover {
  border-color: var(--tt-primary);
  box-shadow: 0 4px 16px rgba(50, 147, 178, 0.15);
  transform: translateY(-2px);
  text-decoration: none;
}

.card-header {
  margin-bottom: 8px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 8px;
  border: none;
  padding: 0;
  color: var(--vscode-foreground);
  line-height: 1.3;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.card-time {
  font-size: 0.72rem;
  color: var(--tt-muted);
}

.card-desc {
  font-size: 0.82rem;
  color: var(--tt-muted);
  margin: 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
  body.tt-lesson-web {
    grid-template-columns: 1fr;
    grid-template-areas:
      "main";
  }

  .tt-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 260px;
    height: 100vh;
    z-index: 50;
    transition: left 0.25s ease;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.4);
  }

  .tt-sidebar.sidebar-open {
    left: 0;
  }

  #sidebar-toggle {
    display: block;
  }

  .tt-main-content {
    padding-top: 52px; /* clear the toggle button */
  }

  .tt-lesson-meta {
    padding: 10px 16px;
  }

  .lesson-content {
    padding: 16px;
  }

  .lesson-card-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== VS Code badge (on command blocks) ===== */

/* The actions row houses the copy button + VS Code badge side by side. */
.tt-web-command-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* The VS Code badge — links to the Marketplace, signals the button is
   fully interactive inside the VS Code extension. */
.tt-vsc-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #007acc;               /* VS Code blue */
  background: rgba(0, 122, 204, 0.12);
  border: 1px solid rgba(0, 122, 204, 0.35);
  border-radius: 4px;
  padding: 3px 8px;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.tt-vsc-badge:hover {
  background: rgba(0, 122, 204, 0.22);
  border-color: rgba(0, 122, 204, 0.65);
  color: #007acc;
  text-decoration: none;
}

/* Small VS Code "⧉" icon placeholder — pure CSS, no image asset needed */
.tt-vsc-badge-icon::before {
  content: "⧉";
  font-size: 0.9em;
}

/* ===== VSCode-only elements (disabled on web, tooltip on hover) ===== */

/* Elements with data-vscode-command are interactive only inside the
   VS Code extension.  On the web they're shown in a muted, disabled
   state with an explanatory tooltip on hover. */
[data-vscode-command] {
  opacity: 0.5;
  cursor: not-allowed !important;
  pointer-events: auto;          /* must stay 'auto' so ::after tooltip works */
  position: relative;
  filter: grayscale(0.3);
}

/* The tooltip that appears on hover */
[data-vscode-command]:hover::after {
  content: "Available in the VS Code extension";
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--vscode-editor-background, #1a2332);
  color: var(--vscode-foreground, #e2e8f0);
  border: 1px solid var(--tt-primary, #3293b2);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* Small VS Code branding on the tooltip */
[data-vscode-command]:hover::before {
  content: "⧉ VS Code";
  position: absolute;
  bottom: calc(100% + 32px);    /* sits above the main tooltip */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 122, 204, 0.15);
  border: 1px solid rgba(0, 122, 204, 0.4);
  color: #007acc;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
  pointer-events: none;
  z-index: 201;
}

/* ===== Inline media figures (GIFs, videos) ===== */

/*
 * GIFs and videos that were linked to GitHub in the VSCode lesson source
 * are promoted to inline figures on the web (we have the files locally).
 */
.tt-media-figure {
  margin: 28px 0;
  text-align: center;
}

.tt-media-figure img,
.tt-media-figure video {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  display: block;
  margin: 0 auto;
}

.tt-media-figure figcaption {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--tt-muted);
  font-style: italic;
}

/* "View full animation" plain-text links that follow a figure */
.tt-media-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--tt-primary);
}

/* ===== Mermaid diagram overrides ===== */

/* Mermaid renders SVG inline; give it a bit of breathing room and
   constrain its max-width so it doesn't overflow on narrow viewports. */
.mermaid {
  max-width: 100%;
  overflow-x: auto;
  margin: 16px 0;
  padding: 0;
  background: transparent;
  border: none;
}

.mermaid svg {
  max-width: 100%;
  height: auto;
}

/* ===== Reference page overrides ===== */

.reference-page .lesson-content {
  max-width: 860px;
}

/* ===== Welcome page component styles ===== */
/*
 * These replicate welcome.html's inline styles, scoped to .page-welcome so
 * they cannot bleed into the sidebar or other layout regions.
 * Colors use our CSS variable system to stay theme-consistent.
 */

/* ASCII logo banner */
.page-welcome .ascii-logo pre {
  font-family: 'Courier New', Courier, monospace;
  font-size: 10px;
  line-height: 1.1;
  color: var(--tt-primary);
  background: var(--vscode-editor-background);
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0 0 24px;
  border: 2px solid var(--tt-primary);
}

/* Hero callout panel */
.page-welcome .hero {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--tt-primary) 15%, transparent) 0%,
    color-mix(in srgb, var(--tt-primary)  5%, transparent) 100%);
  border-left: 4px solid var(--tt-primary);
  padding: 20px;
  margin: 20px 0;
  border-radius: 4px;
}

/* Section spacing */
.page-welcome .section {
  margin: 30px 0;
}

/* Directory / code info panel */
.page-welcome .directory-info {
  background: var(--vscode-editor-background);
  border-radius: 4px;
  padding: 12px;
  font-size: 13px;
  margin: 15px 0;
  border: 1px solid color-mix(in srgb, var(--tt-primary) 30%, transparent);
}

.page-welcome .directory-info code {
  color: var(--tt-primary-light, var(--tt-primary));
}

/* Lesson walkthrough list */
.page-welcome .walkthrough-list {
  list-style: none;
  padding: 0;
  margin: 20px 0;
}

.page-welcome .walkthrough-item {
  background: var(--vscode-editor-background);
  border: 1px solid color-mix(in srgb, var(--tt-primary) 30%, transparent);
  border-radius: 6px;
  padding: 16px;
  margin: 10px 0;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.page-welcome .walkthrough-item:hover {
  background: color-mix(in srgb, var(--tt-primary) 10%, var(--vscode-editor-background));
  border-color: var(--tt-primary);
  transform: translateX(4px);
}

.page-welcome .walkthrough-item h3 {
  margin: 0 0 8px;
  color: var(--tt-primary);
  font-size: 1rem;
  border: none;
  padding: 0;
}

.page-welcome .walkthrough-item p {
  margin: 0;
  color: var(--tt-muted);
  font-size: 0.875rem;
}

/* Quick-action button grid */
.page-welcome .quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.page-welcome .quick-link {
  display: block;
  background: var(--tt-primary);
  color: white;
  padding: 12px 16px;
  border-radius: 4px;
  text-align: center;
  cursor: pointer;
  border: 1px solid var(--tt-primary);
  transition: background 0.2s, transform 0.15s;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}

.page-welcome .quick-link:hover {
  background: var(--tt-primary-light, var(--tt-primary));
  filter: brightness(1.15);
  transform: scale(1.03);
  text-decoration: none;
  color: white;
}

/* Disabled quick-link (data-vscode-command) overrides the hover transform */
.page-welcome [data-vscode-command].quick-link {
  transform: none !important;
}

/* Walkthrough badge pill */
.page-welcome .walkthrough-badge {
  display: inline-block;
  background: var(--tt-primary);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  margin-left: 8px;
}

/* Section headings inside the welcome page use the site accent */
.page-welcome .lesson-content h3[style] {
  color: var(--tt-primary) !important;
}

/* ===== Syntax highlighting — Tenstorrent theme ===== */
/*
 * Token colors derived from themes/tenstorrent-theme.json semanticTokenColors.
 * We keep the pre/code background transparent so lesson-theme.css's
 * --vscode-textCodeBlock-background (#0F2A35) shows through.
 */

.hljs {
  color: #E8F0F2;        /* base foreground */
  background: transparent;
}

/* Keywords, control flow, operators */
.hljs-keyword,
.hljs-operator,
.hljs-selector-tag,
.hljs-built_in,
.hljs-builtin-name {
  color: #4FD1C5;        /* teal */
  font-weight: bold;
}

/* Strings and string template literals */
.hljs-string,
.hljs-template-variable,
.hljs-doctag,
.hljs-regexp {
  color: #F5A7C0;        /* light pink */
}

/* Numbers, boolean literals */
.hljs-number,
.hljs-literal {
  color: #E6B55E;        /* orange-yellow */
}

/* Function names, method calls */
.hljs-title,
.hljs-title.function_,
.hljs-title.function_.invoke__ {
  color: #F4C471;        /* golden yellow */
}

/* Class, type, and interface names */
.hljs-title.class_,
.hljs-type,
.hljs-symbol {
  color: #EC96B8;        /* pink */
}

/* Variables, properties, parameters */
.hljs-variable,
.hljs-variable.language_,
.hljs-params,
.hljs-attr {
  color: #81E6D9;        /* light teal */
}

/* Comments */
.hljs-comment,
.hljs-quote {
  color: #607D8B;        /* gray-blue */
  font-style: italic;
}

/* Tag names in HTML/JSX/XML */
.hljs-tag,
.hljs-name {
  color: #4FD1C5;        /* teal */
}

/* Attribute names */
.hljs-attribute {
  color: #81E6D9;        /* light teal */
}

/* Meta-directives: #include, @decorator, etc. */
.hljs-meta,
.hljs-meta .hljs-keyword {
  color: #B8E6D9;        /* pale teal */
}

/* Shell/bash command names and env-var substitutions */
.hljs-section {
  color: #F4C471;        /* golden yellow */
  font-weight: bold;
}

/* Diff add/remove lines */
.hljs-addition {
  color: #27AE60;
  background: rgba(39, 174, 96, 0.12);
}

.hljs-deletion {
  color: #FF6B6B;
  background: rgba(255, 107, 107, 0.12);
}

/* Link text */
.hljs-link {
  color: #4FD1C5;
  text-decoration: underline;
}

/* ===== Syntax highlighting — light mode overrides ===== */
/*
 * Replaces the dark palette with VS Code Light+ / docs.tenstorrent.com colours
 * so code blocks are readable when the OS/browser is in light mode.
 */
@media (prefers-color-scheme: light) {
  .hljs {
    color: #1e1e1e;          /* near-black base */
  }

  .hljs-keyword,
  .hljs-operator,
  .hljs-selector-tag,
  .hljs-built_in,
  .hljs-builtin-name {
    color: #0000ff;          /* blue — VS Code Light+ keyword */
    font-weight: bold;
  }

  .hljs-string,
  .hljs-template-variable,
  .hljs-doctag,
  .hljs-regexp {
    color: #a31515;          /* burgundy — VS Code Light+ string */
  }

  .hljs-number,
  .hljs-literal {
    color: #098658;          /* green — numeric literals */
  }

  .hljs-title,
  .hljs-title.function_,
  .hljs-title.function_.invoke__ {
    color: #795e26;          /* brown — function names */
  }

  .hljs-title.class_,
  .hljs-type,
  .hljs-symbol {
    color: #267f99;          /* teal-blue — types */
  }

  .hljs-variable,
  .hljs-variable.language_,
  .hljs-params,
  .hljs-attr {
    color: #001080;          /* dark navy — variables */
  }

  .hljs-comment,
  .hljs-quote {
    color: #008000;          /* green — comments */
    font-style: italic;
  }

  .hljs-tag,
  .hljs-name {
    color: #800000;          /* maroon — HTML/XML tags */
  }

  .hljs-attribute {
    color: #e50000;          /* red — attribute names */
  }

  .hljs-meta,
  .hljs-meta .hljs-keyword {
    color: #0000ff;          /* blue — decorators, directives */
  }

  .hljs-section {
    color: #795e26;
    font-weight: bold;
  }

  .hljs-addition {
    color: #1a8737;
    background: rgba(26, 135, 55, 0.12);
  }

  .hljs-deletion {
    color: #c41a16;
    background: rgba(196, 26, 22, 0.12);
  }

  .hljs-link {
    color: #0070c1;
    text-decoration: underline;
  }
}
