/* EPOK80 application chrome.
 *
 * One visual system, per docs/BRAND.md: neutral chrome around a phosphor-green
 * panel canvas. The canvas styling itself lives in the generated
 * panels/<slug>.css files, lifted from the trainers - nothing here restyles the
 * grid.
 *
 * Contrast note: every foreground/background pair below is chosen to clear
 * WCAG 2.0 AA (4.5:1 for body text, 3:1 for large text), because Section 508
 * requires it and a training tool that fails accessibility is not adoptable.
 */

:root {
  --bg:        #0e1110;
  --surface:   #161b19;
  --surface-2: #1e2523;
  --line:      #2c3532;
  --ink:       #e8efec;   /* on --bg: ~14:1 */
  --ink-dim:   #a8b5b0;   /* on --bg: ~7.5:1 */
  --accent:    #45d67f;   /* on --bg: ~9:1 */
  --warn:      #f0c674;
  --err:       #ff8a7a;
  --radius:    6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

/* !important is deliberate. This is a visibility utility and it must beat any
 * layout rule, including an ID selector. It previously lost to
 * `#view-login { display: grid }` - specificity 100 versus 20 - so hiding the
 * login view did nothing: the card stayed painted at min-height 100vh on top of
 * the active view, and a successful login looked like a failed one. */
.view.hidden { display: none !important; }

/* ------------------------------------------------------------- login card */

/* A class, not an ID. An ID selector for layout outranks every state class,
 * which is how the bug above happened. */
.view-centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 26rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
}

.brand {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 6px 0 26px;
  color: var(--ink-dim);
  font-size: 0.92rem;
}

label {
  display: block;
  margin: 16px 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  font-family: "IBM Plex Mono", Consolas, monospace;
}

input:focus-visible, button:focus-visible, select:focus-visible,
.term:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button[type="submit"] {
  width: 100%;
  margin-top: 22px;
  padding: 11px 14px;
  background: var(--accent);
  color: #06120b;
  border: 0;
  border-radius: 4px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
button[type="submit"]:hover { filter: brightness(1.08); }
button[type="submit"]:disabled { opacity: 0.55; cursor: default; }

.msg { min-height: 1.4em; margin: 12px 0 0; font-size: 0.88rem; }
.msg.err { color: var(--err); }
.msg.ok  { color: var(--accent); }

.hint, .fineprint {
  color: var(--ink-dim);
  font-size: 0.82rem;
  line-height: 1.55;
}
.hint { margin: 12px 0 0; }
.fineprint { margin-top: 24px; }

/* ----------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.spacer { flex: 1; }
.brand-sm { font-weight: 650; letter-spacing: 0.02em; }
.who { color: var(--ink-dim); font-size: 0.85rem; }

.linkish {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  border-radius: 4px;
  padding: 5px 10px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.linkish:hover { color: var(--ink); border-color: #3d4a46; }

.pill {
  font-size: 0.74rem;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--ink-dim);
  border: 1px solid var(--line);
}
.pill.warn { background: #2b2410; color: var(--warn); border-color: #4a3d18; }

/* ------------------------------------------------------------------- body */

.wrap { max-width: 1000px; margin: 0 auto; padding: 26px 18px 60px; }

h2 { margin: 0 0 6px; font-size: 1.3rem; }
.lede { margin: 0 0 22px; color: var(--ink-dim); font-size: 0.92rem; }

.modules { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.modules button {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.modules button:hover { border-color: #3d4a46; background: var(--surface-2); }
.modules .m-title { font-weight: 620; }
.modules .m-sum   { color: var(--ink-dim); font-size: 0.87rem; margin-top: 4px; }
.modules .m-count { color: var(--accent); font-size: 0.78rem; margin-top: 8px; }

.keys {
  margin: 14px 0 0;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 0.78rem;
  color: var(--ink-dim);
}
.keys b { color: var(--ink); }

.panelnav { margin-top: 18px; display: flex; align-items: center; gap: 10px; }
.panelnav label { margin: 0; }
.panelnav select {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.88rem;
}

/* ------------------------------------------------------------ progress list */

h2.mt { margin-top: 38px; }

.pill.done { background: #12301f; color: var(--accent); border-color: #235c39; }

.progress { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }

.progress li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.p-head { display: flex; align-items: baseline; gap: 12px; }
.p-name { font-weight: 620; }
.p-level {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--ink-dim);
  font-family: "IBM Plex Mono", Consolas, monospace;
}
.p-level.earned { color: var(--accent); }

.p-bar {
  margin: 10px 0 8px;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}
.p-bar span { display: block; height: 100%; background: var(--accent); }

.p-desc { color: var(--ink-dim); font-size: 0.86rem; line-height: 1.5; }

.p-cap {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--warn);
  font-size: 0.79rem;
  line-height: 1.5;
}

/* ================================================================= editor
 *
 * The ruler, the zone shading and the text must agree on where a column is, so
 * all THREE layers - .ed-ruler, .ed-zones and .ed-input - set the same font
 * stack, the same font-size and the same left origin. Omitting the font on the
 * zone layer is not cosmetic: ch resolves against the inherited font. Zone widths are in ch units, which for a monospace font is exactly
 * one character advance. Changing the font here without changing it in all
 * three places would make the editor lie about columns - the one thing it
 * exists to get right.
 */

.wrap.wide { max-width: 1180px; }

.linkish.big { padding: 9px 16px; font-size: 0.92rem; }

.ed { --ed-font: "IBM Plex Mono", "Cascadia Mono", Consolas, "DejaVu Sans Mono",
                 monospace;
      --ed-size: 14px;
      --ed-line: 21px;
      --ed-pad: 12px; }

.ed-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
}
.ed-lang { font-weight: 620; font-size: 0.88rem; }
.ed-status, .ed-pos {
  font-family: var(--ed-font); font-size: 0.78rem; color: var(--ink-dim);
}
.ed-status { margin-left: auto; }
.ed-status.has-error, .ed-pos.has-error { color: var(--err); }

.ed-btn {
  background: none; border: 1px solid var(--line); color: var(--ink-dim);
  border-radius: 4px; padding: 5px 12px; font: inherit; font-size: 0.85rem;
  cursor: pointer;
}
.ed-btn:hover { color: var(--ink); border-color: #3d4a46; }
.ed-btn.primary {
  background: var(--accent); color: #06120b; border-color: var(--accent);
  font-weight: 620;
}
.ed-btn.primary:hover { filter: brightness(1.08); }
.ed-btn:disabled { opacity: 0.5; cursor: default; }

.ed-hint {
  margin: 0; padding: 8px 12px;
  background: #2b2410; color: var(--warn);
  border: 1px solid #4a3d18; border-bottom: 0;
  font-size: 0.83rem;
}

.ed-surface {
  position: relative;
  background: #070a08;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow-x: auto;
}

.ed-ruler, .ed-input {
  font-family: var(--ed-font);
  font-size: var(--ed-size);
  line-height: var(--ed-line);
  padding: 0 var(--ed-pad);
  margin: 0;
  white-space: pre;
  letter-spacing: 0;
  tab-size: 4;
}

.ed-ruler {
  color: #4c5c52;
  border-bottom: 1px solid var(--line);
  padding-top: 6px; padding-bottom: 2px;
  user-select: none;
  position: relative; z-index: 3;
}

.ed-zones {
  position: absolute;
  top: calc(var(--ed-line) + 8px);   /* below the ruler */
  bottom: 0;
  left: var(--ed-pad);
  pointer-events: none;
  z-index: 1;

  /* CRITICAL: zone widths are expressed in ch, and ch is font-relative. Without
   * these three lines this layer inherits the body sans-serif, one ch becomes a
   * different width from one character of code, and every band drifts
   * cumulatively - Area A renders 8-12 instead of 8-11 and everything after it
   * slides. The editor then lies about columns, which is the single thing it
   * exists to get right. The editor gate measures this. */
  font-family: var(--ed-font);
  font-size: var(--ed-size);
  line-height: var(--ed-line);
}
.ed-zone { position: absolute; top: 0; bottom: 0; display: block; }
.ed-edge {
  position: absolute; top: 0; bottom: 0; width: 0;
  border-left: 1px dashed #7a5a2a;
}

/* Zone tints are deliberately low-contrast: they must not fight the text they
 * sit behind. Information is carried by the legend and the diagnostics, never by
 * colour alone - Section 508 requires that, and it is also just clearer. */
.zone-sequence   { background: rgba(120, 130, 125, 0.10); }
.zone-indicator  { background: rgba(230, 180, 80,  0.16); }
.zone-area_a     { background: rgba(80,  170, 255, 0.13); }
.zone-area_b     { background: rgba(69,  214, 127, 0.08); }
.zone-ignored    { background: rgba(255, 110, 90,  0.13); }
.zone-identifier { background: rgba(80,  170, 255, 0.13); }
.zone-name       { background: rgba(190, 150, 255, 0.12); }
.zone-content    { background: rgba(69,  214, 127, 0.08); }
.zone-continue   { background: rgba(230, 180, 80,  0.20); }

.ed-input {
  position: relative; z-index: 2;
  display: block;
  width: max-content; min-width: 100%;
  min-height: calc(var(--ed-line) * 18);
  background: transparent;
  color: #d8f0e0;
  border: 0; outline: none; resize: vertical;
  caret-color: var(--accent);
  overflow-x: hidden;
  padding-top: 4px; padding-bottom: 10px;
}

.ed-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  margin: 10px 0 0;
  font-family: var(--ed-font); font-size: 0.74rem; color: var(--ink-dim);
}
.ed-zone-key { display: inline-flex; align-items: center; gap: 6px; }
.ed-zone-key i {
  width: 22px; height: 10px; display: inline-block;
  border: 1px solid var(--line);
}

/* ----------------------------------------------------------- diagnostics */

.ed-verdict { margin-top: 16px; }
.ed-verdict.pass, .ed-verdict.fail {
  padding: 12px 14px; border-radius: var(--radius); border: 1px solid;
}
.ed-verdict.pass { background: #10291b; border-color: #245c3a; }
.ed-verdict.fail { background: #2b1512; border-color: #5c2a24; }
.v-head { font-weight: 650; margin-bottom: 4px; }
.ed-verdict.pass .v-head { color: var(--accent); }
.ed-verdict.fail .v-head { color: var(--err); }
.v-text { font-size: 0.88rem; }
.v-line {
  margin-top: 6px; font-family: var(--ed-font); font-size: 0.78rem;
  color: var(--ink-dim);
}

.ed-diags { margin-top: 16px; }
.ed-clean { color: var(--accent); font-size: 0.88rem; }

.ed-diag-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ed-diag-list li {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 4px; padding: 10px 12px;
}
.ed-diag-list li.sev-error   { border-left-color: var(--err); }
.ed-diag-list li.sev-warning { border-left-color: var(--warn); }
.ed-diag-list li.sev-info    { border-left-color: #5aa9ff; }

.d-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.d-sev {
  font-family: var(--ed-font); font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 2px 7px; border-radius: 99px;
  border: 1px solid var(--line);
}
.d-sev.sev-error   { color: var(--err);    border-color: #5c2a24; }
.d-sev.sev-warning { color: var(--warn);   border-color: #4a3d18; }
.d-sev.sev-info    { color: #5aa9ff;       border-color: #24405c; }

.d-rule { font-family: var(--ed-font); font-size: 0.76rem; color: var(--ink-dim); }
.d-jump {
  margin-left: auto; background: none; border: 1px solid var(--line);
  color: var(--ink-dim); border-radius: 4px; padding: 2px 8px;
  font-family: var(--ed-font); font-size: 0.74rem; cursor: pointer;
}
.d-jump:hover { color: var(--accent); border-color: #245c3a; }

.d-msg { margin-top: 7px; font-size: 0.9rem; }
.d-ev, .d-fix { margin-top: 6px; font-size: 0.83rem; color: var(--ink-dim); }
.d-label {
  display: inline-block; min-width: 68px;
  font-family: var(--ed-font); font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: #6b7a72;
}
.d-ev code {
  font-family: var(--ed-font); font-size: 0.8rem; color: #cfe0d6;
  background: var(--bg); padding: 1px 5px; border-radius: 3px;
}

/* ================================================================ authoring */

.au { display: grid; gap: 18px; }

.au-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
}
.au-card h3 { margin: 0 0 4px; font-size: 1.02rem; }
.au-card h4 {
  margin: 0 0 6px; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-dim);
}
.au-hint { margin: 0 0 14px; color: var(--ink-dim); font-size: 0.84rem;
           line-height: 1.55; }

.au-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.au-list { list-style: none; margin: 0; padding: 0; }
.au-list li {
  font-family: "IBM Plex Mono", Consolas, monospace; font-size: 0.76rem;
  color: var(--ink-dim); padding: 2px 0;
}
.au-mono { font-family: "IBM Plex Mono", Consolas, monospace;
           font-size: 0.78rem; color: var(--accent); margin: 0; }

.au-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.au-in {
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
  border-radius: 4px; padding: 7px 10px; font: inherit; font-size: 0.88rem;
  min-width: 9rem;
}
.au-in.short { min-width: 6.5rem; max-width: 9rem; }
.au-in.wide  { flex: 1 1 16rem; }
.au-in.mono, .mono {
  font-family: "IBM Plex Mono", Consolas, monospace;
}

.au-code {
  width: 100%; min-height: 190px; margin: 12px 0;
  background: #070a08; color: #d8f0e0;
  border: 1px solid var(--line); border-radius: 4px;
  font-family: "IBM Plex Mono", Consolas, monospace; font-size: 13px;
  line-height: 20px; padding: 10px 12px;
  white-space: pre; overflow-x: auto; resize: vertical;
}

.au-msg { font-size: 0.83rem; color: var(--ink-dim); }
.au-msg.ok   { color: var(--accent); }
.au-msg.err  { color: var(--err); }
.au-msg.warn { color: var(--warn); }

.au-langs { display: grid; gap: 6px; margin-bottom: 14px; }
.au-lang {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.85rem; padding: 6px 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
}
.au-lang code { min-width: 4.5rem; color: var(--accent); font-size: 0.8rem; }
.au-tags { margin-left: auto; display: flex; gap: 6px; }
.tag {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 7px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--ink-dim);
}
.tag.ok   { color: var(--accent); border-color: #245c3a; }
.tag.warn { color: var(--warn);   border-color: #4a3d18; }

.au-findings { display: grid; gap: 6px; margin-top: 12px; }
.au-finding {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 4px;
  font-size: 0.84rem; cursor: pointer;
}
.au-finding code { font-size: 0.76rem; color: var(--ink-dim); min-width: 10rem; }
.au-fmsg { color: var(--ink-dim); }
