/* 16:9 Visual Diagram Template System — Contracts Modules
   Designed for crisp 1080p/4K screen recording and live projection.
   Zero external fonts or dependencies. */

:root {
  --viewport-bg: #121211;
  --canvas-bg: #fbfaf7;
  --surface: #f2efe8;
  --surface-alt: #ffffff;
  --ink: #18181b;
  --muted: #57534e;
  --rule: #d6d3cb;
  --teal: #1d4e4f;
  --teal-soft: #e6f0f0;
  --amber: #9a4a0c;
  --amber-soft: #fdf2e6;
  --crimson: #9f1239;
  --crimson-soft: #fce8ee;
  --slate: #334155;
  --slate-soft: #eef2f6;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

body.theme-dark {
  --viewport-bg: #080808;
  --canvas-bg: #151618;
  --surface: #1e2024;
  --surface-alt: #24272c;
  --ink: #f1f0ec;
  --muted: #a8a49c;
  --rule: #34373e;
  --teal: #6cc4c6;
  --teal-soft: #1a2d2e;
  --amber: #f0a45d;
  --amber-soft: #2e2318;
  --crimson: #f27491;
  --crimson-soft: #311921;
  --slate: #94a3b8;
  --slate-soft: #202631;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--viewport-bg);
  font-family: var(--font-sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.deck-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  gap: 0.75rem;
}

/* Locked 16:9 Broadcast Stage */
.stage {
  position: relative;
  width: min(94vw, calc((100vh - 5.5rem) * 16 / 9));
  aspect-ratio: 16 / 9;
  background: var(--canvas-bg);
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 3.2% 4.2% 2.8%;
}

body.recording-mode .deck-shell {
  padding: 0;
}

body.recording-mode .stage {
  width: min(100vw, calc(100vh * 16 / 9));
  border-radius: 0;
  box-shadow: none;
}

body.recording-mode .hud {
  display: none;
}

/* Stage Header (Date-Free, LMS-Free) */
.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 1.4%;
  border-bottom: 1.5px solid var(--rule);
  margin-bottom: 2.2%;
}

.module-kicker {
  font-family: var(--font-mono);
  font-size: clamp(0.65rem, 1.05vw, 0.95rem);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--teal);
  font-weight: 600;
}

.stage-title {
  margin: 0.15em 0 0;
  font-size: clamp(1.1rem, 2.3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.stage-cite {
  font-family: var(--font-mono);
  font-size: clamp(0.65rem, 1.0vw, 0.9rem);
  color: var(--muted);
  white-space: nowrap;
}

/* Diagram Canvas Area */
.diagram-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.diagram-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Progressive Step-Reveal Animation */
[data-step] {
  opacity: 0.08;
  transition: opacity 260ms ease, filter 260ms ease;
}

[data-step].is-visible {
  opacity: 1;
}

[data-step].is-current {
  opacity: 1;
  filter: drop-shadow(0 4px 10px rgba(29, 78, 79, 0.14));
}

/* SVG Semantic Classes */
.node-rect {
  fill: var(--surface-alt);
  stroke: var(--rule);
  stroke-width: 1.75;
  rx: 8;
}

.node-primary {
  fill: var(--teal-soft);
  stroke: var(--teal);
  stroke-width: 2;
  rx: 8;
}

.node-warn {
  fill: var(--amber-soft);
  stroke: var(--amber);
  stroke-width: 2;
  rx: 8;
}

.node-alert {
  fill: var(--crimson-soft);
  stroke: var(--crimson);
  stroke-width: 2;
  rx: 8;
}

.node-neutral {
  fill: var(--slate-soft);
  stroke: var(--slate);
  stroke-width: 1.75;
  rx: 8;
}

.svg-label {
  fill: var(--ink);
  font-family: var(--font-sans);
  font-weight: 650;
  font-size: 16px;
}

.svg-sub {
  fill: var(--muted);
  font-family: var(--font-sans);
  font-size: 13px;
}

.svg-cite {
  fill: var(--teal);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
}

.svg-cite-warn {
  fill: var(--amber);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
}

.svg-cite-alert {
  fill: var(--crimson);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
}

.svg-edge {
  stroke: var(--muted);
  stroke-width: 2;
  fill: none;
}

.svg-edge-accent {
  stroke: var(--teal);
  stroke-width: 2.25;
  fill: none;
}

.svg-edge-alert {
  stroke: var(--crimson);
  stroke-width: 2;
  fill: none;
}

.svg-edge-dashed {
  stroke: var(--muted);
  stroke-width: 1.75;
  stroke-dasharray: 6 5;
  fill: none;
}

.svg-edge-label {
  fill: var(--muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
}

/* Stage Footer */
.stage-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.2%;
  border-top: 1px solid var(--rule);
  margin-top: 1.4%;
  font-family: var(--font-mono);
  font-size: clamp(0.6rem, 0.9vw, 0.8rem);
  color: var(--muted);
}

/* Recording & Presenter HUD (Hidden in Recording Mode) */
.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #d6d3cb;
}

.hud a,
.hud button {
  font-family: inherit;
  font-size: inherit;
  color: #f1f0ec;
  background: #27272a;
  border: 1px solid #3f3f46;
  border-radius: 4px;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  text-decoration: none;
}

.hud a:hover,
.hud button:hover {
  background: #3f3f46;
}

.hud .step-counter {
  min-width: 6.5rem;
  text-align: center;
  color: #a1a1aa;
}

/* Mobile / Portrait Readability (preserves locked 16:9 stage on desktop & landscape) */
@media (max-width: 720px) {
  .deck-shell {
    justify-content: flex-start;
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .stage {
    width: 100%;
    aspect-ratio: auto;
    padding: 1rem 0.95rem 0.85rem;
  }

  .stage-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding-bottom: 0.65rem;
    margin-bottom: 0.75rem;
  }

  .stage-title {
    font-size: 1.12rem;
  }

  .stage-cite {
    font-size: 0.72rem;
    white-space: normal;
  }

  .diagram-area {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }

  .diagram-svg {
    min-width: 680px;
    width: 100%;
    height: auto;
  }

  .stage-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    padding-top: 0.6rem;
    margin-top: 0.55rem;
    font-size: 0.68rem;
  }

  .stage-footer::before {
    content: "Swipe diagram sideways or rotate to landscape →";
    color: var(--teal);
    margin-bottom: 0.2rem;
  }

  .hud {
    gap: 0.4rem 0.45rem;
    font-size: 0.72rem;
  }

  .hud a,
  .hud button {
    padding: 0.38rem 0.55rem;
  }

  .hud .step-counter {
    min-width: auto;
    padding: 0 0.25rem;
  }
}
