/* ============================================================================
   CyberReg frontend-journey — non-technical UI (ADR-1014).

   Audience: non-IT contributors (compliance, legal, procurement, board).
   Voice: calm, one task at a time, glossary always one click away.
   Surface: paper-dominant per księga znaku (ADR-1026).
   ============================================================================ */

@import url("./design-tokens.css");

* { box-sizing: border-box; }
html { color-scheme: light; }

body {
  margin: 0;
  font-family: var(--cr-font-sans);
  background: var(--cr-surface-page);
  color: var(--cr-navy);
  line-height: 1.55;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
}

/* Brand watermark anchored to the bottom-right of the main interface frame,
   in the spirit of our letterhead (paper-dominant, ADR-1026). Rendered as
   a real <aside class="brand-watermark"> in +layout.svelte, placed first
   in DOM so later siblings paint over it without any z-index gymnastics.
   Two-layer composition (independent opacity per layer):
     ::before — monochrome navy body of the mark, very subtle (≈ 5%)
     ::after  — red accent ring extracted from the full-colour mark,
                muted (≈ 35%) so the brand-red signature reads without
                competing with the content. */
.brand-watermark {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: clamp(280px, 32vw, 560px);
  /* aspect ratio of the source PNG ≈ 1845/1608 = 1.147 */
  aspect-ratio: 1845 / 1608;
  pointer-events: none;
}
.brand-watermark::before,
.brand-watermark::after {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: bottom right;
}
.brand-watermark::before {
  background-image: url("../img/cyberreg-mono-navy.png");
  opacity: 0.05;
}
.brand-watermark::after {
  background-image: url("../img/cyberreg-accent-red.png");
  opacity: 0.35;
}

/* Hide watermark on narrow viewports where it would crowd the content. */
@media (max-width: 720px) {
  .brand-watermark { display: none; }
}

/* ---------- Skip link --------------------------------------------------- */
.skip-link {
  position: absolute;
  left: -10000px;
  background: var(--cr-navy);
  color: var(--cr-paper);
  padding: 0.5rem 0.85rem;
  text-decoration: none;
  border-radius: 4px;
}
.skip-link:focus { left: 1rem; top: 1rem; z-index: 100; }

/* ---------- Top app bar — paper + hairline, never navy fill ------------- */
.jb-topbar {
  background: var(--cr-surface-page);
  border-bottom: 1px solid var(--cr-navy-12, rgba(13,41,72,0.12));
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.jb-topbar img.brand-mark {
  height: 32px;
  width: auto;
}
.jb-topbar .org-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.jb-topbar .role-pill {
  margin-left: auto;
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--cr-navy-12, rgba(13,41,72,0.12));
  font-size: 0.78rem;
  color: var(--cr-navy-72, rgba(13,41,72,0.72));
  background: var(--cr-surface-card);
}

/* ---------- Layout ------------------------------------------------------ */
.jb-shell {
  display: grid;
  /* Milestone-aside is informational nav, main column is the action area
     → main gets priority. Aside clamps between 200–280px so on a 1280
     laptop the description doesn't get squeezed into a narrow strip. */
  grid-template-columns: clamp(200px, 18vw, 280px) minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 64px);
}
@media (max-width: 1100px) {
  /* On narrower screens the milestone list becomes a horizontal strip
     above content instead of a side column, freeing the full width for
     the active-step card. */
  .jb-shell { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .jb-sidebar { display: none; }
}

.jb-sidebar {
  background: var(--cr-surface-page);
  border-right: 1px solid var(--cr-navy-12, rgba(13,41,72,0.12));
  padding: 1.25rem 1rem;
}

.jb-sidebar h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cr-navy-56, rgba(13,41,72,0.56));
  margin: 0 0 0.75rem;
}

.jb-milestone {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--cr-navy-06, rgba(13,41,72,0.06));
  font-size: 0.92rem;
}
.jb-milestone:last-child { border-bottom: none; }

.jb-milestone .node {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--cr-navy);
  background: var(--cr-surface-page);
  flex-shrink: 0;
  margin-top: 4px;
}
.jb-milestone[data-status="DONE"] .node,
.jb-milestone[data-status="SIGNED_OFF"] .node {
  background: var(--cr-navy);
}
.jb-milestone[data-status="IN_PROGRESS"] .node {
  background: var(--cr-paper);
  box-shadow: inset 0 0 0 3px var(--cr-navy);
}
.jb-milestone .title {
  font-weight: 500;
  color: var(--cr-navy);
}
.jb-milestone .meta {
  display: block;
  font-size: 0.78rem;
  color: var(--cr-navy-56, rgba(13,41,72,0.56));
  margin-top: 0.1rem;
}

/* ---------- Main column ------------------------------------------------- */
.jb-main {
  padding: 1.75rem 2rem 3rem;
  /* Take the full width offered by the parent layout (sidebar +
     milestone-aside + content); cap at 2560px on ultrawide / 5K monitors
     so absurdly long lines on giant displays don't degrade legibility,
     while leaving room for the full Word-style brand documents and the
     wide DAG/tables side-panels. */
  width: 100%;
  max-width: min(100%, 2560px);
  box-sizing: border-box;
}

.live-tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  margin-left: 0.6rem; padding: 0.08rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--cr-navy-12, rgba(13,41,72,0.12));
  font-size: 0.72rem; letter-spacing: 0.04em;
  color: var(--cr-navy-56, rgba(13,41,72,0.56));
  transition: color 0.15s ease, border-color 0.15s ease;
}
.live-tag .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cr-navy-12, rgba(13,41,72,0.12));
}
.live-tag.on { color: #2e6b4a; border-color: rgba(46,107,74,0.32); }
.live-tag.on .dot { background: #2e6b4a; box-shadow: 0 0 6px #2e6b4a; }

.jb-breadcrumbs {
  font-size: 0.82rem;
  color: var(--cr-navy-56, rgba(13,41,72,0.56));
  margin-bottom: 0.5rem;
}
.jb-breadcrumbs a {
  color: var(--cr-navy);
  text-decoration: none;
  border-bottom: 1px solid var(--cr-navy-24, rgba(13,41,72,0.24));
}

.jb-title {
  font-size: 1.85rem;
  font-weight: 600;
  margin: 0.25rem 0 0.5rem;
  letter-spacing: -0.01em;
}

.jb-subtitle {
  font-size: 1.05rem;
  color: var(--cr-navy-72, rgba(13,41,72,0.72));
  margin: 0 0 1.5rem;
}

/* ---------- Step card --------------------------------------------------- */
.step-card {
  background: var(--cr-surface-card);
  border: 1px solid var(--cr-navy-12, rgba(13,41,72,0.12));
  border-radius: 10px;
  padding: 1.5rem 1.65rem;
  margin-bottom: 1rem;
  /* Take the full main-column width — paragraphs inside should reflow to
     fit the available horizontal space, not be capped at some implicit
     reading-width default that browsers sometimes apply to articles. */
  width: 100%;
  box-sizing: border-box;
}

.step-card .step-body p,
.step-card .step-body {
  max-width: none;
}

.step-card .step-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  font-size: 0.85rem;
  color: var(--cr-navy-72, rgba(13,41,72,0.72));
  margin-bottom: 1rem;
}
.step-card .step-meta strong { color: var(--cr-navy); font-weight: 600; }

.step-card .step-body p {
  margin: 0 0 1rem;
  font-size: 1.02rem;
  line-height: 1.6;
}

/* ---------- Status pill ------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid currentColor;
  background: transparent;
}
.pill[data-status="NOT_STARTED"] { color: var(--cr-navy-56, rgba(13,41,72,0.56)); }
.pill[data-status="IN_PROGRESS"] { color: var(--cr-warning, #B26A00); }
.pill[data-status="BLOCKED"]     { color: var(--cr-red); }
.pill[data-status="REVIEW"]      { color: var(--cr-warning, #B26A00); }
.pill[data-status="DONE"]        { color: var(--cr-success, #2e6b4a); }
.pill[data-status="SIGNED_OFF"]  { color: var(--cr-success, #2e6b4a); background: var(--cr-surface-recessed, rgba(13,41,72,0.025)); }

/* ---------- Buttons ----------------------------------------------------- */
.btn {
  font: inherit;
  font-weight: 500;
  padding: 0.65rem 1.25rem;
  border-radius: 6px;
  border: 1px solid var(--cr-navy);
  cursor: pointer;
  transition: filter 120ms ease, background 120ms ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-primary {
  background: var(--cr-navy);
  color: var(--cr-paper);
}
.btn-primary:hover { filter: brightness(1.10); }
.btn-secondary {
  background: var(--cr-surface-card);
  color: var(--cr-navy);
}
.btn-secondary:hover { background: var(--cr-navy-06, rgba(13,41,72,0.06)); }
.btn-danger {
  background: var(--cr-red);
  color: var(--cr-paper);
  border-color: var(--cr-red);
}
/* Disabled state — must read as inactive regardless of the variant. A primary
   button kept its full navy fill when disabled, which looked clickable. */
.btn:disabled,
.btn[disabled] {
  background: var(--cr-navy-12, rgba(13,41,72,0.12));
  color: var(--cr-navy-56, rgba(13,41,72,0.56));
  border-color: var(--cr-navy-12, rgba(13,41,72,0.12));
  cursor: not-allowed;
  filter: none;
}
.btn:disabled:hover,
.btn[disabled]:hover {
  background: var(--cr-navy-12, rgba(13,41,72,0.12));
  filter: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

/* ---------- Evidence checklist ----------------------------------------- */
.evidence-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1rem;
}
.evidence-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--cr-navy-12, rgba(13,41,72,0.12));
  border-radius: 6px;
  margin-bottom: 0.4rem;
  background: var(--cr-surface-card);
}
.evidence-list li.collected {
  border-left: 3px solid var(--cr-success, #2e6b4a);
}
.evidence-list li.missing {
  border-left: 3px solid var(--cr-red);
}
.evidence-list .check {
  width: 18px;
  height: 18px;
  border: 2px solid var(--cr-navy-40, rgba(13,41,72,0.40));
  border-radius: 4px;
  flex-shrink: 0;
}
.evidence-list .collected .check {
  border-color: var(--cr-success, #2e6b4a);
  background: var(--cr-success, #2e6b4a);
  position: relative;
}
.evidence-list .collected .check::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 11px;
  border: solid var(--cr-paper);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  left: 4px; top: 0;
}

/* ---------- Glossary side panel ---------------------------------------- */
.glossary {
  font-size: 0.88rem;
  color: var(--cr-navy-72, rgba(13,41,72,0.72));
  border-left: 3px solid var(--cr-navy-24, rgba(13,41,72,0.24));
  padding: 0.6rem 0.9rem;
  background: var(--cr-surface-recessed, rgba(13,41,72,0.025));
  border-radius: 0 6px 6px 0;
  margin: 1rem 0;
}
.glossary dt { font-weight: 600; color: var(--cr-navy); margin-top: 0.5rem; }
.glossary dt:first-child { margin-top: 0; }
.glossary dd { margin: 0.15rem 0 0; }

/* ---------- Welcome (single column, narrow) ---------------------------- */
.jb-welcome {
  max-width: 560px;
  margin: 3rem auto;
  padding: 0 1.25rem;
  text-align: center;
}
.jb-welcome img { height: 60px; width: auto; margin-bottom: 1.5rem; }
.jb-welcome h1 {
  font-size: 2rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}
.jb-welcome p {
  font-size: 1.05rem;
  color: var(--cr-navy-72, rgba(13,41,72,0.72));
  margin: 0 0 2rem;
}
.jb-welcome .actions { justify-content: center; }

/* ---------- Footer ------------------------------------------------------ */
.jb-footer {
  border-top: 1px solid var(--cr-navy-12, rgba(13,41,72,0.12));
  padding: 1rem 1.5rem;
  font-size: 0.78rem;
  color: var(--cr-navy-56, rgba(13,41,72,0.56));
  text-align: center;
  background: var(--cr-surface-page);
}
.jb-footer .legal { margin-top: 0.25rem; }

/* ---------- Lifecycle pill + tree outline ------------------------------- */
.lifecycle-pill {
  display: inline-block;
  margin-left: 0.6rem;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  background: var(--cr-navy-06, rgba(13,41,72,0.06));
  color: var(--cr-navy);
  border: 1px solid var(--cr-navy-12, rgba(13,41,72,0.12));
}

.map-outline {
  margin-top: 2rem;
  border-top: 1px solid var(--cr-navy-12, rgba(13,41,72,0.12));
  padding-top: 1.4rem;
}
.map-outline h2 {
  font-size: 1rem;
  margin: 0 0 0.8rem;
  color: var(--cr-navy);
}
.map-outline ol.tree {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.map-outline .node {
  background: var(--cr-surface-card, #fff);
  border: 1px solid var(--cr-navy-12, rgba(13,41,72,0.12));
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
}
.map-outline .node .row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.map-outline .node .ord {
  color: var(--cr-navy-56, rgba(13,41,72,0.56));
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  min-width: 2.4rem;
}
.map-outline .node .ttl {
  flex: 1 1 240px;
  font-size: 0.93rem;
  color: var(--cr-navy);
}
.map-outline .node .ttl a {
  color: var(--cr-navy);
  text-decoration: none;
  border-bottom: 1px dotted var(--cr-navy-12);
}
.map-outline .node .ttl a:hover { border-bottom-color: var(--cr-navy); }
.map-outline .node .badge {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  background: var(--cr-navy-06, rgba(13,41,72,0.06));
  color: var(--cr-navy);
  border: 1px solid var(--cr-navy-12, rgba(13,41,72,0.12));
  white-space: nowrap;
}
.map-outline .node .badge.cycle {
  background: rgba(197,157,59,0.12);
  border-color: rgba(197,157,59,0.32);
  color: #8e6e1f;
  font-weight: 600;
}
.map-outline .node .badge.deps {
  background: rgba(20,31,61,0.08);
  color: var(--cr-navy);
}
.map-outline .node .badge.anchor {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
}
.map-outline .children {
  list-style: none;
  padding: 0.4rem 0 0 1.5rem;
  margin: 0.4rem 0 0;
  border-left: 2px solid var(--cr-gold, #c59d3b);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.map-outline .node.child {
  background: var(--cr-surface-page);
  padding: 0.45rem 0.7rem;
}

/* ---------- DAG section toggle + iteration badge ----------------------- */
.dag-section {
  margin-top: 1.5rem;
  border-top: 1px solid var(--cr-navy-12, rgba(13,41,72,0.12));
  padding-top: 1rem;
}
.dag-header { margin-bottom: 0.5rem; }
.dag-toggle {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: none;
  border: none;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
  font: inherit;
  color: var(--cr-navy, #0D2948);
  font-weight: 600;
}
.dag-toggle:hover { background: var(--cr-navy-06, rgba(13,41,72,0.06)); border-radius: 4px; }
.dag-toggle .dag-hint {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--cr-navy-56, rgba(13,41,72,0.56));
}

.map-outline .node .badge.iter {
  background: rgba(46,107,74,0.14);
  border-color: rgba(46,107,74,0.4);
  color: #1f5236;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
}

/* When the user clicks a DAG node, the matching outline row gets a brief
   gold halo so the visual link between the two views is obvious. */
.map-outline .node.flash-highlight {
  box-shadow: 0 0 0 2px var(--cr-gold, #c59d3b);
  transition: box-shadow 0.2s ease;
}
