/* Copyright (C) 2026 Grigori Fursin. All rights reserved.
   cserver.cmeta.course - "cMeta: from 0 to 1".
   Self-contained: no framework, no build step, no external font. Works on the engine's
   internal cserver and on the cTuning cPlatform, in light and dark. */

.cxc {
  --cxc-bg: #fbfbfd;
  --cxc-panel: #ffffff;
  --cxc-panel-2: #f5f6f9;
  --cxc-ink: #14161c;
  --cxc-ink-2: #4a5060;
  --cxc-ink-3: #767d8e;
  --cxc-line: #e3e6ed;
  --cxc-line-2: #d2d7e2;
  --cxc-accent: #2f6df6;
  --cxc-accent-2: #10b3a6;
  --cxc-accent-3: #7a5cf0;
  --cxc-warn: #c98a12;
  --cxc-term-bg: #12141b;
  --cxc-term-ink: #e6e9f2;
  --cxc-term-dim: #8b93a7;
  --cxc-term-ok: #5fd39a;
  --cxc-radius: 12px;
  --cxc-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --cxc-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* centre the course and match the width of the sibling pages on both hosts
     (cTuning.ai centres its project pages; the Dapple Labs shell runs ~1280 wide) */
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;

  color: var(--cxc-ink);
  font-family: var(--cxc-sans);
  font-size: 15px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

/* dark: follow the host's theme (the cPlatform adds body.dark-theme; the engine's
   cserver may set data-theme), else the OS preference */
.cxc.is-dark,
body.dark .cxc:not(.is-light),
body.dark-theme .cxc:not(.is-light),
body[data-theme="dark"] .cxc:not(.is-light) {
  --cxc-bg: #0e1015;
  --cxc-panel: #161922;
  --cxc-panel-2: #1d2129;
  --cxc-ink: #e9ecf3;
  --cxc-ink-2: #b3bac9;
  --cxc-ink-3: #8a92a4;
  --cxc-line: #272c37;
  --cxc-line-2: #333a48;
  --cxc-accent: #6f9bff;
  --cxc-accent-2: #3ad0c0;
  --cxc-accent-3: #a68cff;
  --cxc-warn: #e5b23c;
  --cxc-term-bg: #0a0c11;
  --cxc-term-ink: #e6e9f2;
}
@media (prefers-color-scheme: dark) {
  .cxc:not(.is-light) {
    --cxc-bg: #0e1015;
    --cxc-panel: #161922;
    --cxc-panel-2: #1d2129;
    --cxc-ink: #e9ecf3;
    --cxc-ink-2: #b3bac9;
    --cxc-ink-3: #8a92a4;
    --cxc-line: #272c37;
    --cxc-line-2: #333a48;
    --cxc-accent: #6f9bff;
    --cxc-accent-2: #3ad0c0;
    --cxc-accent-3: #a68cff;
    --cxc-warn: #e5b23c;
    --cxc-term-bg: #0a0c11;
  }
}

.cxc * { box-sizing: border-box; }
.cxc a { color: var(--cxc-accent); text-decoration: none; }
.cxc a:hover { text-decoration: underline; }
.cxc code { font-family: var(--cxc-mono); font-size: 0.88em; background: var(--cxc-panel-2);
  border: 1px solid var(--cxc-line); border-radius: 5px; padding: 0.08em 0.36em; }

/* ---------------------------------------------------------------- header */
.cxc-top {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.7rem 0 0.9rem; border-bottom: 1px solid var(--cxc-line); margin-bottom: 1.2rem;
}
.cxc-brand { display: flex; align-items: baseline; gap: 0.5rem; color: var(--cxc-ink); font-size: 1.05rem; }
.cxc-brand:hover { text-decoration: none; }
.cxc-brand b { letter-spacing: -0.01em; }
.cxc-arrow { color: var(--cxc-accent); margin-left: 0.15rem; }
.cxc-kicker { color: var(--cxc-ink-3); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; }

.cxc-progress { display: flex; align-items: center; gap: 2px; flex: 1 1 260px; min-width: 200px; }
.cxc-progress a {
  flex: 1 1 auto; height: 7px; border-radius: 3px; background: var(--cxc-line-2);
  transition: background 0.15s, transform 0.15s;
}
.cxc-progress a:hover { transform: scaleY(1.7); background: var(--cxc-accent); }
.cxc-progress a.is-seen { background: var(--cxc-accent-2); }
.cxc-progress a.is-current { background: var(--cxc-accent); transform: scaleY(1.9); }
.cxc-progress-zero, .cxc-progress-one { color: var(--cxc-ink-3); font-size: 0.72rem; font-family: var(--cxc-mono); }
.cxc-progress-label { color: var(--cxc-ink-3); font-size: 0.75rem; white-space: nowrap; margin-left: 0.35rem; }

.cxc-links { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.cxc-tab {
  font-size: 0.82rem; padding: 0.28rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--cxc-line-2); color: var(--cxc-ink-2); background: var(--cxc-panel);
}
.cxc-tab:hover { text-decoration: none; border-color: var(--cxc-accent); color: var(--cxc-accent); }
.cxc-tab.is-active { background: var(--cxc-accent); border-color: var(--cxc-accent); color: #fff; }

/* ---------------------------------------------------------------- layout */
.cxc-main { max-width: none; }
.cxc-footer { color: var(--cxc-ink-3); font-size: 0.78rem; line-height: 1.6;
  border-top: 1px solid var(--cxc-line); padding-top: 0.9rem; margin-top: 2rem; }

.cxc-panel {
  background: var(--cxc-panel); border: 1px solid var(--cxc-line);
  border-radius: var(--cxc-radius); padding: 1.1rem 1.2rem; margin: 0 0 1rem;
}
.cxc-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 0.7rem; }
.cxc-panel-head p { margin: 0; color: var(--cxc-ink-3); font-size: 0.82rem; }
.cxc-h1 { font-size: 1.72rem; line-height: 1.22; letter-spacing: -0.02em; margin: 0.1rem 0 0.5rem; }
.cxc-h2 { font-size: 1.05rem; margin: 0; letter-spacing: -0.01em; }
.cxc-eyebrow { color: var(--cxc-accent); font-size: 0.74rem; letter-spacing: 0.09em;
  text-transform: uppercase; font-weight: 600; margin: 0 0 0.15rem; }

/* ---------------------------------------------------------------- hub */
.cxc-hero { border: 1px solid var(--cxc-line); border-radius: var(--cxc-radius);
  padding: 1.5rem 1.4rem; margin-bottom: 1.1rem;
  background: linear-gradient(135deg, var(--cxc-panel) 0%, var(--cxc-panel-2) 100%); }
.cxc-intro { color: var(--cxc-ink-2); margin: 0 0 0.9rem; max-width: none; }
.cxc-zero-one { display: flex; align-items: center; gap: 0.8rem; color: var(--cxc-ink-3);
  font-size: 0.78rem; font-family: var(--cxc-mono); }
.cxc-zero-one .bar { flex: 1 1 auto; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--cxc-accent-2), var(--cxc-accent), var(--cxc-accent-3)); }

.cxc-path { display: grid; gap: 0.8rem; margin-bottom: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.cxc-chapter { background: var(--cxc-panel); border: 1px solid var(--cxc-line);
  border-radius: var(--cxc-radius); padding: 0.95rem 1rem; }
.cxc-chapter h3 { margin: 0.2rem 0 0.3rem; font-size: 1rem; }
.cxc-chapter p { margin: 0 0 0.55rem; color: var(--cxc-ink-3); font-size: 0.83rem; line-height: 1.5; }
.cxc-chapter-num { color: var(--cxc-accent); font-size: 0.7rem; letter-spacing: 0.09em;
  text-transform: uppercase; font-weight: 600; }
.cxc-chapter ol { margin: 0; padding-left: 1.25rem; font-size: 0.9rem; }
.cxc-chapter ol li { margin: 0.18rem 0; }
.cxc-chapter ol li.is-seen::marker { color: var(--cxc-accent-2); }
.cxc-chapter ol li.is-current { font-weight: 600; }
.cxc-chapter ol li.is-current a { color: var(--cxc-ink); }

/* note the a.btn selectors: ".cxc a" above would otherwise out-specify a bare ".btn-*" */
.cxc .btn, .cxc a.btn { display: inline-block; font-size: 0.88rem; padding: 0.46rem 0.95rem;
  border-radius: 8px; border: 1px solid var(--cxc-line-2); cursor: pointer; font-family: inherit; }
.cxc .btn:hover, .cxc a.btn:hover { text-decoration: none; }
.cxc .btn-primary, .cxc a.btn-primary { background: var(--cxc-accent); border-color: var(--cxc-accent); color: #fff; }
.cxc .btn-primary:hover, .cxc a.btn-primary:hover { filter: brightness(1.07); color: #fff; }
.cxc .btn-secondary, .cxc a.btn-secondary { background: var(--cxc-panel); color: var(--cxc-ink-2); }
.cxc .btn-secondary:hover, .cxc a.btn-secondary:hover { border-color: var(--cxc-accent); color: var(--cxc-accent); }
.cxc .btn-ghost, .cxc a.btn-ghost { background: transparent; color: var(--cxc-ink-2); }
.cxc .btn-sm, .cxc a.btn-sm { font-size: 0.78rem; padding: 0.26rem 0.6rem; }

/* ---------------------------------------------------------------- lesson */
.cxc-lesson-head { display: grid; grid-template-columns: 1fr 300px; gap: 1.2rem; margin-bottom: 1.1rem; }
@media (max-width: 820px) { .cxc-lesson-head { grid-template-columns: 1fr; } }
.cxc-question { font-size: 1.02rem; margin: 0.3rem 0 0.5rem; }
.cxc-chapter-card { background: var(--cxc-panel-2); border: 1px solid var(--cxc-line);
  border-radius: var(--cxc-radius); padding: 0.85rem 0.95rem; font-size: 0.84rem; color: var(--cxc-ink-2); }
.cxc-chapter-card ol { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.cxc-chapter-card ol li { margin: 0.15rem 0; }
.cxc-chapter-card ol li.is-current { font-weight: 600; color: var(--cxc-ink); }

/* prose runs the full column width; a 76-78ch reading measure was the original choice - restore it here if preferred */
.cxc-plain { margin: 0 0 0.7rem; max-width: none; }
.cxc-takeaway { border-left: 3px solid var(--cxc-accent-2); background: var(--cxc-panel-2);
  border-radius: 0 8px 8px 0; padding: 0.6rem 0.85rem; margin-top: 0.8rem; }

/* the live terminal - the signature element of this course */
.cxc-demo { border: 1px solid var(--cxc-line); border-radius: 10px; overflow: hidden; margin: 0 0 0.85rem; }
.cxc-demo-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
  flex-wrap: wrap; padding: 0.5rem 0.8rem; background: var(--cxc-panel-2); border-bottom: 1px solid var(--cxc-line); }
.cxc-demo-title { font-size: 0.86rem; font-weight: 600; }
.cxc-demo-note { color: var(--cxc-ink-3); font-size: 0.78rem; }
.cxc-term { background: var(--cxc-term-bg); color: var(--cxc-term-ink); font-family: var(--cxc-mono);
  font-size: 0.8rem; line-height: 1.55; padding: 0.8rem 0.9rem; margin: 0; overflow-x: auto;
  white-space: pre; tab-size: 4; }
.cxc-term .p { color: var(--cxc-term-ok); user-select: none; }
.cxc-term .c { color: #ffd479; }
.cxc-term.is-running { opacity: 0.55; }
.cxc-term-empty { color: var(--cxc-term-dim); font-style: italic; }
.cxc-demo-foot { padding: 0.45rem 0.8rem; background: var(--cxc-panel-2);
  border-top: 1px solid var(--cxc-line); color: var(--cxc-ink-3); font-size: 0.78rem; }
.cxc-live { display: inline-flex; align-items: center; gap: 0.32rem; font-size: 0.72rem;
  color: var(--cxc-accent-2); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.cxc-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--cxc-accent-2); box-shadow: 0 0 0 0 currentColor; animation: cxcPulse 2s infinite; }
@keyframes cxcPulse { 0% { opacity: 0.45; } 50% { opacity: 1; } 100% { opacity: 0.45; } }

/* visuals */
.cxc-viz-wrap { width: 100%; overflow-x: auto; }
.cxc-viz-wrap svg { display: block; max-width: 100%; height: auto; }
.cxc-viz-caption { color: var(--cxc-ink-3); font-size: 0.8rem; margin: 0.5rem 0 0; }
.viz-box { fill: var(--cxc-panel-2); stroke: var(--cxc-line-2); }
.viz-box-a { fill: none; stroke: var(--cxc-accent); }
.viz-label { fill: var(--cxc-ink); font-family: var(--cxc-sans); font-size: 12px; }
.viz-label-sm { fill: var(--cxc-ink-3); font-family: var(--cxc-sans); font-size: 10.5px; }
.viz-mono { fill: var(--cxc-ink-2); font-family: var(--cxc-mono); font-size: 11px; }
.viz-link { fill: none; stroke: var(--cxc-line-2); }
.viz-link-a { fill: none; stroke: var(--cxc-accent); }

/* check yourself / notes */
.cxc-check summary { cursor: pointer; font-weight: 600; }
.cxc-check details { margin-top: 0.3rem; }
.cxc-check details p { margin: 0.5rem 0 0; color: var(--cxc-ink-2); }
.cxc-note { background: var(--cxc-panel-2); border: 1px dashed var(--cxc-line-2);
  border-radius: 8px; padding: 0.6rem 0.8rem; font-size: 0.85rem; color: var(--cxc-ink-2); }
.cxc-trap { border-left: 3px solid var(--cxc-warn); background: var(--cxc-panel-2);
  border-radius: 0 8px 8px 0; padding: 0.6rem 0.85rem; margin-top: 0.7rem; }
.cxc-trap b { color: var(--cxc-warn); }

/* navigation */
.cxc-nav { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 1.2rem; }
.cxc-nav a { font-size: 0.9rem; }
.cxc-nav .cxc-next { text-align: right; margin-left: auto; }
.cxc-next-words { color: var(--cxc-ink-3); font-size: 0.84rem; margin: 0 0 0.3rem; }

.cxc-banner { background: var(--cxc-panel-2); border: 1px solid var(--cxc-warn);
  border-radius: 8px; padding: 0.6rem 0.85rem; margin-bottom: 1rem; font-size: 0.86rem; }
.cxc-status { color: var(--cxc-ink-3); font-size: 0.78rem; margin: 0; }

.cxc-kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 0.8rem; font-size: 0.86rem; }
.cxc-kv dt { color: var(--cxc-ink-3); font-family: var(--cxc-mono); font-size: 0.8rem; }
.cxc-kv dd { margin: 0; }

.cxc-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.cxc-table th, .cxc-table td { text-align: left; padding: 0.38rem 0.6rem; border-bottom: 1px solid var(--cxc-line); vertical-align: top; }
.cxc-table th { color: var(--cxc-ink-3); font-weight: 600; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.05em; }
.cxc-table-wrap { overflow-x: auto; }

@media (max-width: 560px) {
  .cxc-h1 { font-size: 1.42rem; }
  .cxc-panel { padding: 0.9rem; }
  .cxc-progress { order: 3; flex-basis: 100%; }
}
