/* The Server Room — shared styles
   Visual idea: Vic Farrell's textbook covers and website. Deep navy from the
   site's banner, electric blue (Software Development), signal green (Visual
   Basic, Digital Technologies) and mustard (Digital Technology 7–10), with the
   cover's pixel mosaic as the one bold motif. Code lives on navy, like a real editor. */

:root {
  --paper: #f2f5fa;
  --sheet: #ffffff;
  --rule: #e0e7f1;
  --rule-strong: #c6d2e3;
  --margin: #18a957;          /* signal green: current item, success accents */
  --ink: #0b1a33;
  --graphite: #45536b;
  --pencil: #7a879c;
  --biro: #1f6fe0;            /* electric blue: links and primary actions */
  --biro-dark: #1556b8;
  --highlight: #f2b705;       /* mustard */
  --success: #13804a;
  --success-bg: #e2f5eb;
  --warn: #8f5a00;
  --warn-bg: #fff2d1;
  --danger: #c0283f;
  --danger-bg: #fde8eb;
  --slate: #0b1528;
  --slate-2: #111d35;
  --slate-3: #1e2c49;
  --slate-text: #d6e0f0;
  --slate-dim: #8394b3;
  --navy: #0b1a33;
  --glow: #3d8bff;

  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --display: "Archivo", "Arial Black", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.5625rem;
  --step-3: 1.953rem;
  --step-4: 2.441rem;
  --step-5: 3.052rem;

  --radius-s: 6px;
  --radius-m: 10px;
  --gutter: 16px;
  --line: 1.6;
  --focus: 0 0 0 3px var(--sheet), 0 0 0 5px var(--biro);
  --pixels: linear-gradient(90deg, #e94f37 0 12.5%, #f2b705 0 25%, #18a957 0 37.5%, #1f6fe0 0 50%, #7b3fe4 0 62.5%, #f2b705 0 75%, #1f6fe0 0 87.5%, #18a957 0);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0a1324; --sheet: #111d35; --rule: #1e2c49; --rule-strong: #2c3d5f;
    --ink: #e8eef9; --graphite: #b3c0d6; --pencil: #8394b3;
    --biro: #6ea8ff; --biro-dark: #9cc4ff; --highlight: #f2b705; --margin: #3fd48a;
    --success-bg: #12301f; --warn-bg: #362a0b; --danger-bg: #3d1820;
    --success: #5fd8a0; --warn: #f2c25b; --danger: #ff8597;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0a1324; --sheet: #111d35; --rule: #1e2c49; --rule-strong: #2c3d5f;
  --ink: #e8eef9; --graphite: #b3c0d6; --pencil: #8394b3;
  --biro: #6ea8ff; --biro-dark: #9cc4ff; --highlight: #f2b705; --margin: #3fd48a;
  --success-bg: #12301f; --warn-bg: #362a0b; --danger-bg: #3d1820;
  --success: #5fd8a0; --warn: #f2c25b; --danger: #ff8597;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: var(--line);
}
img, svg { max-width: 100%; }
a { color: var(--biro); text-underline-offset: 3px; }
a:hover { color: var(--biro-dark); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 2px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
h1, h2 { font-family: var(--display); font-weight: 800; letter-spacing: -0.02em; }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }
p { margin: 0 0 1em; }
code, kbd, pre { font-family: var(--mono); font-size: .9em; }
:not(pre) > code { background: color-mix(in srgb, var(--rule) 60%, transparent); padding: .1em .35em; border-radius: 3px; }
mark { background: color-mix(in srgb, var(--highlight) 45%, transparent); color: inherit; padding: 0 .15em; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- buttons and form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  font: inherit; font-weight: 700; font-size: var(--step--1);
  padding: .55em 1em; border-radius: var(--radius-s);
  border: 1.5px solid var(--ink); background: var(--sheet); color: var(--ink);
  cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap;
}
.btn:hover { background: var(--paper); color: var(--ink); }
.btn-primary { background: var(--biro); border-color: var(--biro); color: #fff; }
.btn-primary:hover { background: var(--biro-dark); border-color: var(--biro-dark); color: #fff; }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover { background: color-mix(in srgb, var(--rule) 50%, transparent); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 1.1em; height: 1.1em; flex: none; }

label { font-weight: 700; font-size: var(--step--1); }
input[type=text], input[type=email], input[type=search], input[type=password], select, textarea {
  font: inherit; color: var(--ink); background: var(--sheet);
  border: 1.5px solid var(--rule-strong); border-radius: var(--radius-s);
  padding: .5em .65em; width: 100%;
}
textarea { min-height: 7em; resize: vertical; line-height: 1.5; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--ink); }

.field { display: grid; gap: .35em; margin-bottom: 1em; }
.hint { color: var(--graphite); font-size: var(--step--1); font-weight: 400; }

/* ---------- status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: .35em;
  font-size: .8125rem; font-weight: 700; padding: .15em .6em; border-radius: 999px;
  background: color-mix(in srgb, var(--rule) 70%, transparent); color: var(--graphite); white-space: nowrap;
}
.pill::before { content: ""; width: .5em; height: .5em; border-radius: 50%; background: currentColor; }
.pill-none::before { display: none; }
.pill-ok { background: var(--success-bg); color: var(--success); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--danger-bg); color: var(--danger); }
.pill-info { background: color-mix(in srgb, var(--biro) 14%, transparent); color: var(--biro); }

/* ---------- app shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .6rem var(--gutter);
  background: var(--sheet); border-bottom: 1px solid var(--rule-strong);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; }
.topnav { display: flex; gap: .25rem; margin-left: 1rem; flex-wrap: wrap; }
.topnav a { color: var(--graphite); text-decoration: none; font-weight: 700; font-size: var(--step--1); padding: .4em .75em; border-radius: var(--radius-s); }
.topnav a:hover { color: var(--ink); background: var(--paper); }
.topnav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -3px 0 var(--biro); border-radius: 0; }
.who { margin-left: auto; display: flex; align-items: center; gap: .6rem; font-size: var(--step--1); }
.who-name { font-weight: 700; }
.who-role { color: var(--graphite); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--biro); color: #fff; font-size: .75rem; font-weight: 700;
}
.footer { padding: 1rem var(--gutter); color: var(--pencil); font-size: .8125rem; border-top: 1px solid var(--rule); }

.page {
  width: 100%; max-width: 1180px; margin: 0 auto; padding: 2rem var(--gutter) 3rem;
}
/* A reading sheet: a clean panel topped with the pixel strip from the textbook cover. */
.ruled {
  position: relative;
  background: var(--sheet);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-m);
  padding: 2.25rem 2.25rem 2rem;
  overflow: hidden;
}
.ruled::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--pixels);
}
@media (max-width: 640px) {
  .ruled { padding: 1.5rem 1rem 1.25rem; }
  h1 { font-size: var(--step-3); }
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: .35rem 0 0; color: var(--graphite); max-width: 60ch; }

.panel { background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: var(--radius-m); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--rule); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: var(--step-1); }
.panel-body { padding: 1.1rem; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
table.data th, table.data td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.data th { font-weight: 700; color: var(--graphite); background: color-mix(in srgb, var(--paper) 70%, var(--sheet)); position: sticky; top: 0; }
table.data tr:hover td { background: color-mix(in srgb, var(--paper) 60%, var(--sheet)); }

/* Progress bar */
.meter { height: 8px; background: var(--rule); border-radius: 999px; overflow: hidden; min-width: 80px; }
.meter > span { display: block; height: 100%; background: var(--biro); border-radius: inherit; }

.empty { text-align: center; color: var(--graphite); padding: 2.5rem 1rem; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--ink); color: var(--sheet); padding: .65rem 1.1rem; border-radius: var(--radius-s);
  font-weight: 700; font-size: var(--step--1); z-index: 100; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}

/* Dialog */
dialog { border: 1px solid var(--rule-strong); border-radius: var(--radius-m); padding: 0; background: var(--sheet); color: var(--ink); width: min(520px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(20, 26, 40, .45); }
.dialog-body { padding: 1.25rem 1.25rem .5rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1.25rem 1.25rem; }

/* Programming fonts must show code exactly as typed: no ligatures (-> must not become an arrow). */
code, kbd, pre, samp, .cm-editor, .cm-content, .log, .db, .pv-address, .server-badge, .tree, .tab, .editor-path {
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0;
}
