/* ==========================================================================
   Java for the Robot: black & white, editor-style.
   The only color on the page lives inside code blocks, and it matches the
   VS Code Dark+ / Light+ themes that ship with WPILib.
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #000000;
  --bg-raised: #0b0b0b;
  --bg-hover: #161616;
  --fg: #f2f2f2;
  --fg-dim: #a8a8a8;
  --fg-faint: #6f6f6f;
  --line: #222222;
  --line-strong: #3b3b3b;
  --inv-bg: #f2f2f2;
  --inv-fg: #000000;

  /* syntax: VS Code Dark+ */
  --syn-plain: #d4d4d4;
  --syn-kw: #569cd6;
  --syn-ctrl: #c586c0;
  --syn-type: #4ec9b0;
  --syn-fn: #dcdcaa;
  --syn-var: #9cdcfe;
  --syn-const: #4fc1ff;
  --syn-str: #ce9178;
  --syn-num: #b5cea8;
  --syn-com: #6a9955;
  --syn-ann: #dcdcaa;

  --f-display: "Martian Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --f-body: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --f-code: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  --side: 290px;
  --bar: 44px;
  --status: 26px;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #ffffff;
  --bg-raised: #f5f5f5;
  --bg-hover: #ebebeb;
  --fg: #0a0a0a;
  --fg-dim: #4a4a4a;
  --fg-faint: #8a8a8a;
  --line: #e3e3e3;
  --line-strong: #c4c4c4;
  --inv-bg: #0a0a0a;
  --inv-fg: #ffffff;

  /* syntax: VS Code Light+ */
  --syn-plain: #1f1f1f;
  --syn-kw: #0000ff;
  --syn-ctrl: #af00db;
  --syn-type: #267f99;
  --syn-fn: #795e26;
  --syn-var: #001080;
  --syn-const: #0070c1;
  --syn-str: #a31515;
  --syn-num: #098658;
  --syn-com: #008000;
  --syn-ann: #795e26;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* show exactly what you type: no >= -> ≥ style ligatures */
  font-variant-ligatures: none;
}

a { color: inherit; }

:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

::selection { background: var(--fg); color: var(--bg); }

/* ---------- app frame ---------- */

.app {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  min-height: 100%;
}

.topbar {
  grid-column: 1 / -1;
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--bar);
  padding-inline: 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  font-family: var(--f-display);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand .slash { color: var(--fg-faint); font-weight: 400; }

.topbar .spacer { flex: 1; }

.btn-ghost {
  font: inherit;
  text-decoration: none;
  font-size: 12px;
  color: var(--fg-dim);
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-ghost:hover { color: var(--fg); border-color: var(--fg); }

.menu-btn { display: none; }

/* Only when served inside AltHub (app.altf4hub.com/training/java-basics) */
.althub-back { display: block; margin: -4px 18px 14px; font-size: 12px; color: var(--fg-dim); text-decoration: none; }
.althub-back:hover { color: var(--fg); }

/* ---------- explorer (sidebar) ---------- */

.explorer {
  position: sticky;
  top: calc(var(--bar) + env(safe-area-inset-top, 0px));
  height: calc(100dvh - var(--bar) - var(--status) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  background: var(--bg-raised);
  border-right: 1px solid var(--line);
  padding-block: 14px 24px;
  font-size: 13px;
}

.explorer-label {
  padding-inline: 18px;
  margin: 0 0 10px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.tree, .tree ul { list-style: none; margin: 0; padding: 0; }

.tree .folder {
  display: block;
  padding: 3px 18px;
  color: var(--fg-dim);
  user-select: none;
}
.tree ul .folder { padding-left: 32px; }

.tree a {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: baseline;
  gap: 6px;
  padding: 4px 16px 4px 32px;
  text-decoration: none;
  color: var(--fg-dim);
  line-height: 1.45;
}
.tree ul ul a { padding-left: 46px; }
.tree a:hover { background: var(--bg-hover); color: var(--fg); }
.tree a.active { background: var(--inv-bg); color: var(--inv-fg); }
.tree a.active .num, .tree a.active .done-mark { color: var(--inv-fg); }

.tree .num { color: var(--fg-faint); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.tree .done-mark { color: var(--fg-faint); font-size: 12px; }
.tree a.is-done .done-mark { color: var(--fg); }

/* ---------- main column ---------- */

main { min-width: 0; display: flex; flex-direction: column; }

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
  overflow-x: auto;
}
.tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-family: var(--f-code);
  font-size: 12.5px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  border-top: 1px solid var(--fg);
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab .x { color: var(--fg-faint); }

.page {
  width: 100%;
  max-width: 820px;
  padding: 56px clamp(16px, 5vw, 64px) 96px;
}

/* ---------- typography ---------- */

.eyebrow {
  margin: 0 0 14px;
  font-family: var(--f-code);
  font-size: 12.5px;
  color: var(--syn-com);
}

h1 {
  margin: 0 0 18px;
  font-family: var(--f-display);
  font-size: clamp(26px, 4.4vw, 40px);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

h2 {
  margin: 56px 0 14px;
  font-family: var(--f-display);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
h2::before { content: "## "; color: var(--fg-faint); font-weight: 400; }

h3 {
  margin: 32px 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.lede {
  margin: 0 0 8px;
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--fg-dim);
  max-width: 64ch;
}

p, li { max-width: 68ch; }
p { margin: 0 0 16px; }

ul.list, ol.list { margin: 0 0 18px; padding-left: 0; list-style: none; }
ul.list li, ol.list li { position: relative; padding-left: 26px; margin-bottom: 8px; }
ul.list li::before { content: "-"; position: absolute; left: 6px; color: var(--fg-faint); }
ol.list { counter-reset: n; }
ol.list li { counter-increment: n; }
ol.list li::before { content: counter(n) "."; position: absolute; left: 0; color: var(--fg-faint); font-variant-numeric: tabular-nums; }

strong { font-weight: 600; }

/* inline code stays monochrome */
:not(pre) > code {
  font-family: var(--f-code);
  font-size: 0.88em;
  padding: 1px 5px;
  background: var(--bg-hover);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.kbd {
  font-family: var(--f-code);
  font-size: 0.85em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  padding: 0 5px;
}

/* ---------- code blocks ---------- */

.code {
  margin: 22px 0 24px;
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
}

.code figcaption {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 6px 8px 6px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--fg-dim);
}
.code .path { font-family: var(--f-code); overflow-wrap: anywhere; }

.tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  color: var(--fg-dim);
  white-space: nowrap;
}
.code.real .tag { background: var(--inv-bg); color: var(--inv-fg); border-color: var(--inv-bg); }

.copy {
  margin-left: auto;
  font: inherit;
  font-size: 11px;
  color: var(--fg-faint);
  background: transparent;
  border: 1px solid var(--line);
  padding: 1px 8px;
  cursor: pointer;
}
.copy:hover { color: var(--fg); border-color: var(--fg-dim); }

.code pre {
  margin: 0;
  padding: 14px 16px 16px;
  overflow-x: auto;
  font-family: var(--f-code);
  font-size: 13.25px;
  line-height: 1.62;
  color: var(--syn-plain);
  tab-size: 4;
  font-variant-ligatures: none;
}

.code.out pre { color: var(--fg); }

.t-kw { color: var(--syn-kw); }
.t-ctrl { color: var(--syn-ctrl); }
.t-type { color: var(--syn-type); }
.t-fn { color: var(--syn-fn); }
.t-var { color: var(--syn-var); }
.t-const { color: var(--syn-const); }
.t-str { color: var(--syn-str); }
.t-num { color: var(--syn-num); }
.t-com { color: var(--syn-com); }
.t-ann { color: var(--syn-ann); }

/* ASCII diagrams and truth tables: plain mono, no color */
.diagram {
  margin: 22px 0 24px;
  padding: 18px 20px;
  border: 1px solid var(--line-strong);
  overflow-x: auto;
  font-family: var(--f-code);
  font-size: 13px;
  line-height: 1.55;
  color: var(--fg);
  white-space: pre;
}

/* ---------- tables ---------- */

.tbl-wrap { overflow-x: auto; margin: 18px 0 24px; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  line-height: 1.5;
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: 9px 14px 9px 0;
  border-bottom: 1px solid var(--line);
}
th {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  border-bottom-color: var(--line-strong);
}
td:first-child { white-space: nowrap; }

/* ---------- notes ---------- */

.note {
  margin: 26px 0;
  padding: 16px 18px;
  border: 1px dashed var(--line-strong);
}
.note > :last-child { margin-bottom: 0; }
.note-label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--f-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* the one loud element: robot rules, inverted */
.note.rule {
  background: var(--inv-bg);
  color: var(--inv-fg);
  border: 0;
}
.note.rule :not(pre) > code {
  background: transparent;
  border-color: var(--inv-fg);
  color: var(--inv-fg);
}

/* ---------- quiz ---------- */

.quiz {
  margin-top: 64px;
  padding-top: 8px;
  border-top: 1px solid var(--line-strong);
}
.quiz h2 { margin-top: 24px; }
.quiz-sub { color: var(--fg-dim); margin-bottom: 26px; }

.q { margin: 0 0 34px; }
.q-text { margin-bottom: 12px; }
.q-text .qn { color: var(--fg-faint); margin-right: 8px; font-variant-numeric: tabular-nums; }
.q .code { margin: 10px 0 14px; }

.opts { display: grid; gap: 8px; }

.opt {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 10px 14px;
  cursor: pointer;
}
.opt:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--fg-dim); }
.opt:disabled { cursor: default; }
.opt .key { color: var(--fg-faint); }
.opt .mark { font-weight: 600; }

.opt.correct { background: var(--inv-bg); color: var(--inv-fg); border-color: var(--inv-bg); }
.opt.correct .key { color: var(--inv-fg); }
.opt.correct code { background: transparent; border-color: var(--inv-fg); color: var(--inv-fg); }
.opt.wrong { border-style: dashed; color: var(--fg-faint); }
.opt.wrong .body { text-decoration: line-through; }

.why {
  margin: 12px 0 0;
  font-family: var(--f-code);
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg-dim);
}
.why .slashes { color: var(--syn-com); }

/* ---------- lesson end ---------- */

.lesson-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 48px;
}

.btn {
  font: inherit;
  font-size: 13.5px;
  padding: 10px 16px;
  cursor: pointer;
  border: 1px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
  display: inline-flex;
  gap: 10px;
  align-items: center;
}
.btn:hover { background: transparent; color: var(--fg); }
.btn.outline { background: transparent; color: var(--fg); }
.btn.outline:hover { background: var(--fg); color: var(--bg); }

.end-hint { font-size: 12.5px; color: var(--fg-faint); }

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 40px;
}
.pager a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  text-decoration: none;
  min-width: 0;
}
.pager a:hover { border-color: var(--fg); background: var(--bg-hover); }
.pager .dir { font-size: 11.5px; color: var(--fg-faint); }
.pager .ttl { font-family: var(--f-display); font-size: 13px; font-weight: 500; letter-spacing: -0.01em; }
.pager .next { text-align: right; grid-column: 2; }

/* ---------- details (solutions) ---------- */

details.reveal {
  margin: 20px 0 26px;
  border: 1px solid var(--line-strong);
}
details.reveal > summary {
  cursor: pointer;
  padding: 12px 16px;
  font-family: var(--f-display);
  font-size: 12.5px;
  font-weight: 500;
  list-style: none;
}
details.reveal > summary::-webkit-details-marker { display: none; }
details.reveal > summary::before { content: "+ "; color: var(--fg-faint); }
details.reveal[open] > summary::before { content: "- "; }
details.reveal[open] > summary { border-bottom: 1px solid var(--line); }
details.reveal > .inner { padding: 4px 16px 4px; }

.checklist { list-style: none; padding: 0; margin: 0 0 18px; }
.checklist li { padding-left: 34px; position: relative; margin-bottom: 8px; }
.checklist li::before { content: "[ ]"; position: absolute; left: 0; color: var(--fg-faint); }

/* ---------- home ---------- */

.prompt {
  margin: 0 0 22px;
  font-family: var(--f-code);
  font-size: 13px;
  color: var(--fg-dim);
}
.prompt .user { color: var(--fg); }

.hero h1 {
  font-size: clamp(34px, 7vw, 64px);
  letter-spacing: -0.05em;
  line-height: 1.02;
  margin-bottom: 22px;
}
.cursor {
  display: inline-block;
  width: 0.5em;
  height: 0.9em;
  margin-left: 0.08em;
  background: var(--fg);
  vertical-align: -0.06em;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.hero .lede { font-size: 17px; max-width: 58ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.index { margin-top: 12px; border-top: 1px solid var(--line-strong); }
.index a {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto 28px;
  gap: 12px;
  align-items: baseline;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.index a:hover { background: var(--bg-hover); }
.index .num { color: var(--fg-faint); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.index .ttl { font-family: var(--f-display); font-size: 14px; font-weight: 500; letter-spacing: -0.015em; }
.index .sum { display: block; margin-top: 3px; font-size: 13px; color: var(--fg-dim); line-height: 1.5; }
.index .min { font-size: 12px; color: var(--fg-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.index .done-mark { color: var(--fg-faint); text-align: right; }
.index a.is-done .done-mark { color: var(--fg); }

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 40px;
}

/* ---------- status bar ---------- */

.statusbar {
  grid-column: 1 / -1;
  position: sticky;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: var(--status);
  padding: 0 16px env(safe-area-inset-bottom, 0px);
  background: var(--inv-bg);
  color: var(--inv-fg);
  font-family: var(--f-code);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
}
.statusbar .right { margin-left: auto; display: flex; gap: 18px; }

/* ---------- responsive ---------- */

@media (max-width: 880px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-block; }
  .explorer {
    position: fixed;
    z-index: 25;
    top: calc(var(--bar) + env(safe-area-inset-top, 0px));
    left: 0;
    bottom: calc(var(--status) + env(safe-area-inset-bottom, 0px));
    height: auto;
    width: min(320px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    border-right: 1px solid var(--line-strong);
  }
  .app.nav-open .explorer { transform: none; }
  .scrim {
    position: fixed;
    inset: 0;
    z-index: 24;
    background: var(--bg);
    opacity: 0.6;
  }
  .page { padding-top: 36px; }
  .statusbar .hide-sm { display: none; }
}

@media (max-width: 520px) {
  .brand .long { display: none; }
  .topbar .althub-top { display: none; }
  .index a { grid-template-columns: 28px minmax(0, 1fr) 22px; }
  .index .min { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  .explorer { transition: none; }
}
