/* ============================================================================
   RAC Course Elements — polished editorial components for course diagrams.

   The default look is a refined MONOCHROME design: serif display type, warm
   near-black ink, layered paper surfaces, hairline rules, soft depth, elegant
   connectors and numerals. It is meant to look finished — the quality it will
   have in a published lesson — without any brand COLOUR.

   Colour is layered on LATER by overriding the --el-* custom properties. The
   library never needs its rules edited to restyle or recolour.
   ========================================================================== */

:root {
  /* Type — titles are a serif for an editorial feel; body inherits/host sans */
  --el-font:       inherit;
  --el-font-title: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --el-font-num:   var(--el-font-title);
  --el-mono:       ui-monospace, "SFMono-Regular", Menlo, "Cascadia Mono", monospace;

  /* Ink (warm near-black greys) */
  --el-fg:     #1a1b1d;
  --el-muted:  #62666c;
  --el-faint:  #9a9ea4;

  /* Paper & surfaces (subtle monochrome layering) */
  --el-paper:  #ffffff;
  --el-fill:   #fafafa;
  --el-fill-2: #f3f4f5;
  --el-border: #e6e7ea;   /* hairline */
  --el-rule:   #d3d5d9;   /* stronger dividers / connectors */

  /* Emphasis mark (filled badges, end/start nodes) — near-black by default */
  --el-ink:    #1a1b1d;
  --el-ink-fg: #ffffff;

  /* Callout edge colours default to a neutral rule; a theme adds hue per type */
  --el-c-note: var(--el-rule); --el-c-key: var(--el-rule); --el-c-safety: var(--el-rule);
  --el-c-warning: var(--el-rule); --el-c-good: var(--el-rule); --el-c-fill: var(--el-fill);

  /* Shape, depth, rhythm */
  --el-radius:    10px;
  --el-radius-sm: 6px;
  --el-gap:       1rem;
  --el-shadow:    0 1px 1px rgba(20,22,26,.04), 0 3px 8px rgba(20,22,26,.05);
  --el-shadow-sm: 0 1px 2px rgba(20,22,26,.05);
  --el-line:      1.5px;
}

.el, .el * { box-sizing: border-box; }
.el {
  font-family: var(--el-font);
  color: var(--el-fg);
  line-height: 1.55;
  margin: 1.75rem 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.el-title {
  font-family: var(--el-font-title);
  font-size: 1.14rem; font-weight: 700; line-height: 1.25;
  margin: 0 0 1rem; color: var(--el-fg); letter-spacing: -.01em;
}
.el-eyebrow {
  display: block; font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .13em; color: var(--el-faint); margin: 0 0 .3rem;
}
.el-note-line { font-size: .82rem; color: var(--el-muted); margin: .7rem 0 0; font-style: italic; }

/* Icons — Lucide (ISC), inlined as an SVG sprite; monochrome via currentColor,
   so they inherit whatever ink the theme sets. Icon+text pairs are laid out with
   flex align-items:center for exact vertical centring; the negative vertical-align
   only matters for the rare truly-inline case. */
.el-ico { width: 1.1em; height: 1.1em; flex: none; vertical-align: -.16em; stroke-width: 2; }
.el-ico--lg { width: 1.35em; height: 1.35em; }

/* ── 1. PROCESS FLOW — centred step cards, icon in a chip, joined by arrows ── */
.el-flow { display: flex; flex-wrap: nowrap; align-items: stretch; gap: 0; overflow-x: auto; padding-bottom: 2px; }
.el-flow__step {
  flex: 1 1 0; min-width: 118px; position: relative;
  background: var(--el-paper); border: 1px solid var(--el-border);
  border-radius: var(--el-radius); box-shadow: var(--el-shadow-sm);
  padding: 1.15rem .9rem 1.05rem;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .15rem;
}
.el-flow__badge {
  width: 2.6rem; height: 2.6rem; border-radius: 999px; margin-bottom: .7rem;
  background: var(--el-fill); border: 1px solid var(--el-border);
  display: grid; place-items: center; color: var(--el-muted);
}
.el-flow__badge .el-ico { width: 1.25rem; height: 1.25rem; }
.el-flow__step--end .el-flow__badge { background: var(--el-ink); border-color: var(--el-ink); color: var(--el-ink-fg); }
.el-flow__step + .el-flow__step { margin-left: 2rem; }
.el-flow__step + .el-flow__step::before {
  content: ""; position: absolute; left: -1.7rem; top: 50%;
  width: 1.2rem; height: var(--el-line); background: var(--el-rule); transform: translateY(-50%);
}
.el-flow__step + .el-flow__step::after {
  content: ""; position: absolute; left: -.55rem; top: 50%;
  border-left: 8px solid var(--el-rule);
  border-top: 5.5px solid transparent; border-bottom: 5.5px solid transparent; transform: translateY(-50%);
}
.el-flow__step--end { border-color: var(--el-ink); box-shadow: var(--el-shadow); }
.el-flow__step--end::after { border-left-color: var(--el-ink); }
.el-flow__k { font-weight: 650; font-size: .92rem; }
.el-flow__s { font-size: .78rem; color: var(--el-muted); line-height: 1.4; }
@media (max-width: 640px) {
  .el-flow { flex-direction: column; }
  .el-flow__step + .el-flow__step { margin-left: 0; margin-top: 1.75rem; }
  .el-flow__step + .el-flow__step::before { left: 50%; top: -1.55rem; width: var(--el-line); height: 1.1rem; transform: translateX(-50%); }
  .el-flow__step + .el-flow__step::after {
    left: 50%; top: -.45rem; transform: translateX(-50%);
    border-left: 5.5px solid transparent; border-right: 5.5px solid transparent;
    border-top: 8px solid var(--el-rule); border-bottom: 0;
  }
}

/* ── 2. LADDER / PATHWAY ─────────────────────────────────────────────────── */
.el-ladder { list-style: none; margin: 0; padding: 0; counter-reset: elstep; }
.el-ladder li { position: relative; padding: 0 0 1.4rem 3rem; counter-increment: elstep; min-height: 2rem; }
/* Badge centre sits on the first text line's centre (line-height .5 of 1.5rem
   = .75rem below the top): badge top = .75 - 1 = -.25rem, so top: -.25rem. */
.el-ladder li::before {
  content: counter(elstep); position: absolute; left: 0; top: -.25rem;
  width: 2rem; height: 2rem; border-radius: 999px;
  background: var(--el-ink); color: var(--el-ink-fg);
  font-family: var(--el-font-num); font-size: .95rem; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--el-shadow-sm);
}
.el-ladder li::after {
  content: ""; position: absolute; left: 1rem; top: 1.95rem; bottom: -.1rem;
  width: var(--el-line); background: var(--el-rule); transform: translateX(-50%);
}
.el-ladder li:last-child::after { display: none; }
.el-ladder__t { font-weight: 600; line-height: 1.5; }
.el-ladder__d { font-size: .82rem; color: var(--el-muted); margin-top: .1rem; }
.el-ladder li.el-ladder--goal::before {
  content: "\2605"; font-size: 1.05rem; box-shadow: 0 0 0 4px var(--el-fill-2), var(--el-shadow-sm);
}
.el-ladder li.el-ladder--goal .el-ladder__t { font-family: var(--el-font-title); font-size: 1.05rem; }

/* ── 3. HIERARCHY TREE ───────────────────────────────────────────────────── */
.el-tree, .el-tree ul { list-style: none; margin: 0; padding: 0; }
.el-tree > li + li { margin-top: .35rem; }
.el-tree ul { margin: .15rem 0 .15rem 1.15rem; border-left: var(--el-line) solid var(--el-border); padding-left: 1.1rem; }
.el-tree li { position: relative; padding: .3rem 0; }
.el-tree ul > li::before {
  content: ""; position: absolute; left: -1.1rem; top: 1.1rem; width: .8rem; height: var(--el-line);
  background: var(--el-border);
}
.el-tree__label { display: inline-flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.el-tree__code {
  font-family: var(--el-mono); font-size: .68rem; font-weight: 600; letter-spacing: .02em;
  background: var(--el-fill-2); color: var(--el-muted);
  padding: .12rem .42rem; border-radius: 999px; white-space: nowrap; line-height: 1.4;
}
.el-tree__name { font-weight: 600; }
.el-tree__aside { font-size: .8rem; color: var(--el-muted); font-style: italic; }
.el-tree__head {
  font-family: var(--el-font-title); font-weight: 700; font-size: .82rem;
  text-transform: uppercase; letter-spacing: .1em; color: var(--el-faint);
  margin: .8rem 0 .35rem; padding-bottom: .3rem; border-bottom: 1px solid var(--el-border);
}
.el-tree > li:first-child > .el-tree__head { margin-top: 0; }

/* ── 4. DECISION FLOW ────────────────────────────────────────────────────── */
.el-decision { display: flex; flex-direction: column; align-items: center; gap: 0; }
.el-decision__node {
  width: 100%; max-width: 33rem; text-align: center; position: relative;
  background: var(--el-paper); border: 1px solid var(--el-border);
  border-radius: var(--el-radius); box-shadow: var(--el-shadow-sm); padding: .75rem 1rem;
}
.el-decision__node + .el-decision__node { margin-top: 2.1rem; }
.el-decision__node + .el-decision__node::before {
  content: ""; position: absolute; left: 50%; top: -1.95rem; width: var(--el-line); height: 1.5rem; background: var(--el-rule); transform: translateX(-50%);
}
.el-decision__node + .el-decision__node::after {
  content: ""; position: absolute; left: 50%; top: -.5rem; transform: translateX(-50%);
  border-left: 5.5px solid transparent; border-right: 5.5px solid transparent; border-top: 8px solid var(--el-rule);
}
.el-decision__k { display: flex; align-items: center; justify-content: center; gap: .45rem; font-weight: 650; }
.el-decision__d { display: block; font-size: .82rem; color: var(--el-muted); margin-top: .12rem; }
.el-decision__node.is-start { background: var(--el-ink); border-color: var(--el-ink); color: var(--el-ink-fg); box-shadow: var(--el-shadow); }
.el-decision__node.is-start .el-decision__d { color: rgba(255,255,255,.72); }
.el-decision__node.is-end { border-color: var(--el-ink); border-width: 1.5px; box-shadow: var(--el-shadow); }
.el-decision__node.is-decision { border-radius: 999px; border-style: dashed; background: var(--el-fill); }
.el-decision__edge {
  display: inline-block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--el-muted); margin: .45rem 0; background: var(--el-fill-2); padding: .18rem .7rem;
  border-radius: 999px; position: relative; z-index: 1;
}

/* ── 5. TABLE ────────────────────────────────────────────────────────────── */
.el-table {
  overflow-x: auto; border: 1px solid var(--el-border);
  border-radius: var(--el-radius); box-shadow: var(--el-shadow-sm); background: var(--el-paper);
}
.el-table table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.el-table th, .el-table td { text-align: left; padding: .68rem .95rem; border-bottom: 1px solid var(--el-border); vertical-align: top; }
.el-table thead th {
  background: var(--el-fill-2); font-family: var(--el-font-title); font-weight: 700;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--el-muted);
  border-bottom: 1.5px solid var(--el-rule); white-space: nowrap;
}
.el-table tbody tr:nth-child(even) td { background: #fcfcfc; }
.el-table tbody tr:last-child td { border-bottom: 0; }
.el-table tbody tr:hover td { background: var(--el-fill); }
.el-table--kv td:first-child { font-weight: 600; width: 32%; white-space: nowrap; color: var(--el-fg); }

/* ── 6. COMPARE (card: full-width divided header + padded body) ───────────── */
.el-compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; }
.el-compare__col {
  background: var(--el-paper); border: 1px solid var(--el-border);
  border-radius: var(--el-radius); box-shadow: var(--el-shadow-sm); overflow: hidden;
}
.el-compare__head {
  display: flex; align-items: center; gap: .55rem; margin: 0;
  padding: .8rem 1.15rem; border-bottom: 1px solid var(--el-border);  /* full-bleed divider */
  background: var(--el-fill);
  font-family: var(--el-font-title); font-weight: 700; font-size: 1rem;
}
.el-compare__head .el-ico { color: var(--el-faint); }
.el-compare__col.is-good .el-compare__head .el-ico { color: var(--el-c-good); }
.el-compare__col.is-bad  .el-compare__head .el-ico { color: var(--el-c-safety); }
.el-compare__body { padding: 1rem 1.15rem 1.1rem; }
.el-compare__body ul { margin: 0; padding: 0; list-style: none; font-size: .89rem; }
.el-compare__body li { margin: .55rem 0; padding-left: 1.2rem; position: relative; color: var(--el-fg); line-height: 1.5; }
.el-compare__body li:first-child { margin-top: 0; }
.el-compare__body li::before { content: ""; position: absolute; left: .15rem; top: .62em; width: .34rem; height: .34rem; border-radius: 999px; background: var(--el-rule); }

/* ── 7. CALLOUT ──────────────────────────────────────────────────────────── */
.el-callout {
  border: 1px solid var(--el-border); border-left: 4px solid var(--el-c-note);
  background: var(--el-c-fill); border-radius: var(--el-radius-sm);
  box-shadow: var(--el-shadow-sm); padding: .85rem 1.05rem; font-size: .92rem;
}
.el-callout__label {
  display: flex; align-items: center; gap: .4rem;
  font-family: var(--el-font-title); font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: var(--el-muted); margin-bottom: .3rem;
}
.el-callout__label .el-ico { color: var(--el-c-note); }
.el-callout--key     .el-callout__label .el-ico { color: var(--el-c-key); }
.el-callout--safety  .el-callout__label .el-ico { color: var(--el-c-safety); }
.el-callout--warning .el-callout__label .el-ico { color: var(--el-c-warning); }
.el-callout--good    .el-callout__label .el-ico { color: var(--el-c-good); }
.el-callout p { margin: 0; }
.el-callout p + p { margin-top: .5rem; }
.el-callout--key     { border-left-color: var(--el-c-key); }
.el-callout--note    { border-left-color: var(--el-c-note); }
.el-callout--safety  { border-left-color: var(--el-c-safety); }
.el-callout--warning { border-left-color: var(--el-c-warning); }
.el-callout--good    { border-left-color: var(--el-c-good); }

/* ── 8. STAT ROW ─────────────────────────────────────────────────────────── */
.el-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--el-gap); }
.el-stat {
  background: var(--el-paper); border: 1px solid var(--el-border);
  border-radius: var(--el-radius); box-shadow: var(--el-shadow-sm); padding: 1rem .9rem; text-align: center;
}
.el-stat__ico { color: var(--el-faint); display: block; margin: 0 auto .5rem; }
.el-stat__v { font-family: var(--el-font-title); font-size: 1.9rem; font-weight: 700; line-height: 1; letter-spacing: -.01em; }
.el-stat__l { font-size: .72rem; color: var(--el-muted); margin-top: .5rem; text-transform: uppercase; letter-spacing: .1em; }


@media print {
  .el, .el-flow, .el-compare, .el-stats, .el-decision__node, .el-table { break-inside: avoid; }
  .el-flow__step, .el-stat, .el-compare__col, .el-decision__node, .el-table { box-shadow: none; }
}
