/* Browser Lab. Tokens and components mirror templates/terminal.html and distro.html. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff; --bg2: #f9f9f8; --bg3: #f3f3f1;
  --text: #111111; --muted: #6b7280; --border: rgba(0,0,0,0.1);
  --green-bg: #eaf3de; --green-txt: #3b6d11; --green-mid: #97c459;
  --term-bg: #0d0f14; --term-bar: #13161e; --term-brd: #232838;
  --term-g: #00cc6a; --term-w: #c8d3f5; --term-m: #9aa3b8;
  --fail: #a03a15;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Mono', monospace;
  --radius-md: 8px;
}

html, body { height: 100%; font-family: var(--font-sans); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button { font: inherit; }
.layout { display: flex; flex-direction: column; min-height: 100vh; }

nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 24px; border-bottom: 1px solid var(--border); }
.logo-img { height: 30px; width: auto; display: block; }
.nav-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.nav-links a { font-size: 13px; color: var(--muted); text-decoration: none; padding: 5px 10px; border-radius: var(--radius-md); }
.nav-links a:hover { background: var(--bg3); color: var(--text); }
.nav-tag { font-family: var(--font-mono); font-size: 11px; color: var(--green-txt); background: var(--green-bg); padding: 5px 10px; border-radius: var(--radius-md); border: 0; cursor: help; }
/* what "browser lab" means: shown on hover, on keyboard focus, and on tap */
.tip-wrap { position: relative; display: inline-flex; }
.tip { position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; display: flex; flex-direction: column; gap: 4px; min-width: 240px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--term-bar); border: 1px solid var(--term-brd); color: var(--term-w); font-family: var(--font-mono); font-size: 11px; line-height: 1.5; text-align: left; box-shadow: 0 6px 20px rgba(0,0,0,0.25); visibility: hidden; opacity: 0; transition: opacity 0.12s; }
.tip-wrap:hover .tip, .tip-wrap:focus-within .tip { visibility: visible; opacity: 1; }

.main { flex: 1 1 auto; display: flex; flex-wrap: wrap; min-height: 0; }

/* terminal side */
.term-area { flex: 999 1 560px; min-width: 0; min-height: 480px; display: flex; flex-direction: column; background: var(--term-bg); border-right: 1px solid var(--term-brd); }
.term-topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; background: var(--term-bar); border-bottom: 1px solid var(--term-brd); }
.term-dots { display: flex; gap: 7px; }
.term-dot { width: 11px; height: 11px; border-radius: 50%; }
.term-dot.r { background: #ff5f57; } .term-dot.y { background: #febc2e; } .term-dot.g { background: #28c840; }
.term-info { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; color: var(--term-m); }
.term-info-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--term-m); }
.term-info.up .term-info-dot { background: var(--term-g); }
.term-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.term-action { font-family: var(--font-mono); font-size: 11px; min-height: 30px; padding: 0 10px; border-radius: 4px; border: 1px solid rgba(154,163,184,0.4); background: transparent; color: var(--term-w); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.term-action:hover { background: var(--term-w); color: var(--term-bg); }
.term-action.go { color: var(--term-g); border-color: rgba(0,204,106,0.4); background: rgba(0,204,106,0.08); }
.term-action.go:hover { background: var(--term-g); color: var(--term-bg); }

.term-body { position: relative; flex: 1 1 auto; min-height: 0; padding: 10px 12px; }
#term { position: absolute; inset: 10px 12px; }
#term .xterm-viewport { scrollbar-width: thin; scrollbar-color: #2a3042 transparent; }
.boot { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; background: var(--term-bg); color: var(--term-w); font-family: var(--font-mono); font-size: 13px; line-height: 1.6; }
.boot[hidden] { display: none; }
.boot-title { font-size: 15px; color: #ffffff; }
.boot-sub { color: var(--term-m); max-width: 520px; }
.boot a { color: var(--term-g); }
.boot.error .boot-title { color: #ff9b7a; }

/* lesson side */
.panel { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.panel-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: var(--radius-md); background: var(--green-bg); color: var(--green-txt); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500; }
.user-name { font-size: 13px; font-weight: 500; line-height: 1.3; }
.user-status { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.user-status.up { color: var(--green-txt); }

.course-banner { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.course-crumb { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-decoration: none; }
.course-banner-title { font-size: 15px; font-weight: 600; margin: 4px 0 0; }

/* lesson text: same rules as the server lab page (templates/distro.html) */
.tutorial-content { flex: 1 1 auto; padding: 16px 20px; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.tutorial-content h1, .tutorial-content h2 { font-size: 16px; font-weight: 600; margin: 16px 0 8px; }
.tutorial-content h2:first-of-type { margin-top: 4px; }
.tutorial-content p { margin-bottom: 10px; }
.tutorial-content ul, .tutorial-content ol { margin: 0 0 10px 22px; }
.tutorial-content a { color: #1d4f91; }
.tutorial-content code { font-family: var(--font-mono); font-size: 13px; background: var(--bg3); padding: 2px 6px; border-radius: 4px; }
.tutorial-content pre, .tutorial-content .prettyprint, .tutorial-content .well { font-family: var(--font-mono); font-size: 12px; background: var(--term-bg); color: var(--term-w); padding: 12px 14px; border-radius: var(--radius-md); overflow-x: auto; margin: 10px 0; white-space: pre; overflow-wrap: normal; }
.tutorial-content pre code { background: transparent; padding: 0; color: inherit; }
.tutorial-content mark { background: var(--green-bg); color: var(--green-txt); padding: 1px 4px; border-radius: 3px; }
.tutorial-content img { max-width: 100%; height: auto; border-radius: var(--radius-md); margin: 8px 0; }
.tutorial-content table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.tutorial-content th, .tutorial-content td { padding: 8px 10px; border: 1px solid var(--border); text-align: left; }
.tutorial-content th { background: var(--bg3); font-weight: 600; }
.tutorial-content kbd { font-family: var(--font-mono); font-size: 12px; background: var(--bg3); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border); }
.step-label { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.step-answer { margin-top: 12px; padding: 10px 14px; background: var(--green-bg); border-radius: var(--radius-md); font-size: 13px; color: var(--green-txt); }
.disk-note { margin: 0 0 12px; padding: 8px 12px; border-radius: var(--radius-md); background: var(--bg2); border: 1px solid var(--border); font-size: 12px; line-height: 1.5; color: #4b5563; }
.lesson-wait { color: var(--muted); }
.picker { list-style: none; margin: 8px 0 0 !important; display: flex; flex-direction: column; gap: 6px; }
.picker a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: var(--radius-md); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 13px; }
.picker a:hover { background: var(--green-bg); border-color: var(--green-mid); color: var(--green-txt); }

.lab-note { margin: 0 16px 10px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--bg2); border: 1px solid var(--border); font-size: 12px; line-height: 1.6; color: #374151; }
.lab-note[hidden] { display: none; }
.lab-note.pass { color: var(--green-txt); }
.lab-note.fail { color: var(--fail); }
.lab-note a { color: inherit; }

.progress-row { display: flex; align-items: center; gap: 10px; padding: 0 20px 8px; }
.progress-row[hidden] { display: none; }
.progress-bar { flex: 1; height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--green-txt); border-radius: 2px; transition: width 0.3s; }
.progress-text { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; }

.panel-footer { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); }
.panel-footer[hidden] { display: none; }
.footer-btn { flex: 1; min-height: 44px; border-radius: var(--radius-md); border: 0; font-family: var(--font-mono); font-size: 12px; font-weight: 500; cursor: pointer; }
.footer-btn[hidden] { display: none; }
.footer-btn.primary { flex: 2; background: var(--green-bg); color: var(--green-txt); }
.footer-btn.primary:hover { background: #d3e8b8; }
.footer-btn.secondary { background: var(--bg3); color: var(--text); }
.footer-btn.secondary:hover { background: #e5e5e3; }
.footer-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Wide screens: the page fills the window, the lesson scrolls inside its panel.
   Narrow screens: terminal and lesson stack and the page scrolls. */
@media (min-width: 900px) {
  .layout { height: 100vh; min-height: 0; }
  .main { flex-wrap: nowrap; overflow: hidden; }
  .term-area { flex: 1 1 auto; min-height: 0; }
  .panel { flex: 0 0 400px; min-height: 0; overflow: hidden; }
  .tutorial-content { min-height: 0; overflow-y: auto; }
}

.lab-note { margin-top: 8px; }
