/* =========================================================================
   Ubiquitous — an introduction to Domain-Driven Design
   A "dictionary entry meets system diagram" theme: ink-indigo on warm
   parchment, with a teal "boundary" accent reserved for bounded-context and
   invariant callouts — the model lives in two colors because DDD lives in
   two halves (strategic boundaries, tactical objects).
   ========================================================================= */

:root {
  --c-bg: #f5f3ee;
  --c-surface: #fdfcfa;
  --c-surface-2: #eae6db;
  --c-text: #1f2238;
  --c-text-muted: #5b5a72;
  --c-text-faint: #938fa0;
  --c-border: #ddd7c8;
  --c-border-firm: #c5bda6;
  --c-accent: #4338ca;          /* model ink — indigo */
  --c-accent-strong: #312e81;
  --c-accent-soft: rgba(67, 56, 202, 0.1);
  --c-boundary: #0f766e;        /* bounded-context teal */
  --c-boundary-soft: rgba(15, 118, 110, 0.12);
  --c-code-bg: #1e1b2e;
  --c-code-text: #e4e1f0;
  --c-shadow: rgba(31, 34, 56, 0.1);
}

html.dark {
  --c-bg: #14121f;
  --c-surface: #1c1930;
  --c-surface-2: #261f3f;
  --c-text: #ece9f5;
  --c-text-muted: #b3aec9;
  --c-text-faint: #847e9c;
  --c-border: #322b4d;
  --c-border-firm: #463c69;
  --c-accent: #9b8ffb;
  --c-accent-strong: #b8aeff;
  --c-accent-soft: rgba(155, 143, 251, 0.16);
  --c-boundary: #2dd4bf;
  --c-boundary-soft: rgba(45, 212, 191, 0.16);
  --c-code-bg: #0e0c18;
  --c-code-text: #ddd9ee;
  --c-shadow: rgba(0, 0, 0, 0.45);
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { background: var(--c-bg); color: var(--c-text); }
::selection { background: var(--c-accent-soft); }

/* ---- Navbar ---- */
.navbar-blur {
  background: color-mix(in srgb, var(--c-bg) 82%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--c-text);
  color: var(--c-accent-strong);
  flex-shrink: 0;
}
html.dark .brand-mark { background: #0c0a16; color: var(--c-accent); }
.brand-mark-sm { width: 20px; height: 20px; border-radius: 5px; }

/* ---- Small shared bits ---- */
.kicker {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-text-faint);
  font-weight: 500;
}

.module-chip {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--c-accent);
  background: var(--c-accent-soft);
  border: 1px solid color-mix(in srgb, var(--c-accent) 28%, transparent);
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
}

.badge {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--c-border-firm);
  color: var(--c-text-muted);
}
.badge-beginner { color: var(--c-boundary); border-color: color-mix(in srgb, var(--c-boundary) 40%, transparent); background: var(--c-boundary-soft); }
.badge-intermediate { color: var(--c-accent); border-color: color-mix(in srgb, var(--c-accent) 40%, transparent); background: var(--c-accent-soft); }
.badge-advanced { color: var(--c-text); border-color: var(--c-border-firm); background: var(--c-surface-2); }

/* ---- Objective box (renders the lesson summary front matter) ---- */
.objective {
  border-left: 3px solid var(--c-accent);
  background: var(--c-accent-soft);
  padding: 0.85rem 1.1rem;
  border-radius: 0 8px 8px 0;
}
.objective-label {
  display: block;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-accent);
  margin-bottom: 0.3rem;
}
.objective p { margin: 0; color: var(--c-text); font-size: 0.98rem; line-height: 1.55; }

/* =========================================================================
   Prose — the rendered markdown of each lesson / page
   ========================================================================= */
.course-prose { font-size: 1.06rem; line-height: 1.75; color: var(--c-text); }
.course-prose > *:first-child { margin-top: 0; }

.course-prose h2 {
  font-family: "Newsreader", Georgia, serif;
  font-weight: 600;
  font-size: 1.7rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 2.9rem 0 1rem;
  padding-top: 0.6rem;
  color: var(--c-text);
  scroll-margin-top: 6rem;
}
.course-prose h3 {
  font-family: "Newsreader", Georgia, serif;
  font-weight: 600;
  font-style: italic;
  font-size: 1.3rem;
  margin: 2rem 0 0.7rem;
  color: var(--c-text);
  scroll-margin-top: 6rem;
}
.course-prose p { margin: 0 0 1.15rem; }
.course-prose strong { font-weight: 650; color: var(--c-text); }
.course-prose em { font-style: italic; }

.course-prose a {
  color: var(--c-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--c-accent) 45%, transparent);
}
.course-prose a:hover { text-decoration-color: var(--c-accent); }

.course-prose ul, .course-prose ol { margin: 0 0 1.25rem; padding-left: 1.3rem; }
.course-prose li { margin: 0.4rem 0; padding-left: 0.2rem; }
.course-prose ul li::marker { color: var(--c-accent); }
.course-prose ol li::marker { color: var(--c-text-faint); font-family: "IBM Plex Mono", monospace; font-size: 0.85em; }
.course-prose li > ul, .course-prose li > ol { margin: 0.4rem 0; }

.course-prose hr { border: 0; border-top: 1px solid var(--c-border); margin: 2.5rem 0; }

/* Inline code */
.course-prose code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.86em;
  background: var(--c-surface-2);
  color: var(--c-accent-strong);
  padding: 0.12em 0.38em;
  border-radius: 4px;
  border: 1px solid var(--c-border);
}

/* Blockquotes — used as callouts (Tip / Note), teal "boundary" border distinguishes
   them from the indigo accent used for the main thread of the prose. */
.course-prose blockquote {
  position: relative;
  margin: 1.6rem 0;
  padding: 1rem 1.2rem 1rem 1.25rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-boundary);
  border-radius: 0 8px 8px 0;
  color: var(--c-text-muted);
}
.course-prose blockquote p { margin: 0; }
.course-prose blockquote p + p { margin-top: 0.6rem; }
.course-prose blockquote strong { color: var(--c-boundary); }
html.dark .course-prose blockquote { background: var(--c-surface-2); }

/* Pull quote */
.course-prose .pull {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.45rem;
  line-height: 1.45;
  font-weight: 500;
  font-style: italic;
  color: var(--c-text);
  border: 0;
  background: none;
  padding: 1.4rem 0 1.4rem 1.4rem;
  margin: 2rem 0;
  border-left: 3px solid var(--c-accent);
}

/* Code blocks (Rouge output) */
.course-prose div.highlight,
.course-prose pre {
  position: relative;
  background: var(--c-code-bg);
  border: 1px solid var(--c-border-firm);
  border-radius: 10px;
  margin: 1.5rem 0;
  overflow: hidden;
}
.course-prose div.highlight pre, .course-prose pre {
  margin: 0;
  border: 0;
  background: transparent;
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
}
.course-prose pre code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.84rem;
  line-height: 1.7;
  background: none;
  border: 0;
  padding: 0;
  color: var(--c-code-text);
}

/* Rouge syntax highlighting (Java-leaning token set), tuned to the code-block palette */
.highlight .k, .highlight .kd, .highlight .kt, .highlight .kn { color: #9b8ffb; } /* keywords */
.highlight .nc, .highlight .nn { color: #5bc8b8; } /* class / type names */
.highlight .nf, .highlight .nb { color: #f0a85a; } /* method / builtin names */
.highlight .n, .highlight .py { color: var(--c-code-text); } /* identifiers */
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sr { color: #8fd6c4; } /* strings */
.highlight .c, .highlight .c1, .highlight .cm { color: #877fa3; font-style: italic; } /* comments */
.highlight .o, .highlight .p { color: #b8a8d9; } /* operators / punctuation */
.highlight .mi, .highlight .mf, .highlight .il { color: #f0a85a; } /* numbers */
.highlight .ow { color: #9b8ffb; } /* word operators (and/or/not) */

/* Copy button */
.copy-btn {
  position: absolute;
  top: 0.55rem; right: 0.55rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #b3aec9;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  padding: 0.22rem 0.5rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.course-prose div.highlight:hover .copy-btn,
.course-prose pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: #fff; }
.copy-btn.copied { color: var(--c-boundary); border-color: var(--c-boundary); opacity: 1; }

/* Tables (used in the Glossary) */
.course-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}
.course-prose thead th {
  text-align: left;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--c-text-faint);
  border-bottom: 2px solid var(--c-border-firm);
  padding: 0.55rem 0.7rem;
}
.course-prose tbody td {
  border-bottom: 1px solid var(--c-border);
  padding: 0.55rem 0.7rem;
  vertical-align: top;
}
.course-prose tbody tr:hover { background: var(--c-surface); }

/* =========================================================================
   Table of contents
   ========================================================================= */
.toc-sidebar { position: sticky; top: 6rem; }
#toc-list { display: flex; flex-direction: column; gap: 0.1rem; border-left: 1px solid var(--c-border); }
.toc-link {
  display: block;
  font-size: 0.83rem;
  line-height: 1.35;
  color: var(--c-text-muted);
  text-decoration: none;
  padding: 0.32rem 0 0.32rem 0.85rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.toc-h3 { padding-left: 1.6rem; font-size: 0.79rem; color: var(--c-text-faint); }
.toc-link:hover { color: var(--c-accent); }
.toc-link.active { color: var(--c-accent); border-left-color: var(--c-accent); font-weight: 500; }

.progress-track { height: 5px; background: var(--c-surface-2); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--c-accent); border-radius: 999px; }

/* =========================================================================
   Cards (home + curriculum)
   ========================================================================= */
.course-card,
.nav-card {
  display: block;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 1.5rem;
  text-decoration: none;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.course-card:hover,
.nav-card:hover {
  border-color: var(--c-border-firm);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -16px var(--c-shadow);
}
.nav-card-right { text-align: right; }

.card-index {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  color: var(--c-accent);
  opacity: 0.85;
}

/* =========================================================================
   Hero (home)
   ========================================================================= */
.hero-grid {
  background-image:
    linear-gradient(var(--c-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--c-border) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 35%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 35%, transparent 75%);
  opacity: 0.5;
}

/* Slow drifting gradient mesh behind the hero, for motion without distraction */
.hero-mesh {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(38% 32% at 18% 22%, color-mix(in srgb, var(--c-accent) 22%, transparent), transparent 70%),
    radial-gradient(32% 30% at 82% 12%, color-mix(in srgb, var(--c-boundary) 18%, transparent), transparent 70%),
    radial-gradient(40% 36% at 60% 78%, color-mix(in srgb, var(--c-accent) 14%, transparent), transparent 70%);
  filter: blur(40px);
  animation: mesh-drift 22s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes mesh-drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-3%, 2%) scale(1.06); }
}

/* ---- Context map (hero diagram) ---- */
.context-map { position: relative; width: 100%; }
.cmap-box {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.7rem 0.95rem;
  border-radius: 10px;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border-firm);
  box-shadow: 0 14px 30px -18px var(--c-shadow);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  opacity: 0;
  animation: cmap-in 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
.cmap-box .cmap-name { font-size: 0.86rem; font-weight: 600; color: var(--c-text); }
.cmap-box .cmap-tag { font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-text-faint); }
.cmap-box.cmap-core { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft), 0 14px 30px -18px var(--c-shadow); }
.cmap-box.cmap-core .cmap-tag { color: var(--c-accent); }
@keyframes cmap-in { to { opacity: 1; } }

.cmap-line {
  stroke: var(--c-boundary);
  stroke-width: 1.6;
  fill: none;
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  animation: cmap-draw 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
@keyframes cmap-draw { to { stroke-dashoffset: 0; } }

.cmap-dot {
  fill: var(--c-accent);
  opacity: 0;
  animation: cmap-pulse 2.4s ease-in-out 1.6s infinite;
}
@keyframes cmap-pulse {
  0%, 100% { opacity: 0; r: 2.5; }
  50% { opacity: 0.9; r: 4; }
}

/* Cycling term label under the hero headline */
.term-cycle { position: relative; display: inline-block; height: 1.3em; min-width: 11ch; vertical-align: bottom; }
.term-cycle-item {
  position: absolute; left: 0; top: 0;
  white-space: nowrap;
  color: var(--c-accent);
  font-style: italic;
  opacity: 0;
  animation: term-fade 9s ease-in-out infinite;
}
@keyframes term-fade {
  0%, 4% { opacity: 0; transform: translateY(6px); }
  8%, 22% { opacity: 1; transform: translateY(0); }
  26%, 100% { opacity: 0; transform: translateY(-6px); }
}

.foot-link { transition: color 0.15s ease; }

/* =========================================================================
   Reveal animation
   ========================================================================= */
.reveal { opacity: 0; transform: translateY(10px); animation: reveal-in 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) forwards; }
@keyframes reveal-in { to { opacity: 1; transform: none; } }

/* Progressive enhancement: visible by default; only hidden (to animate in)
   once JS adds .js-reveal, so no-JS and observer failures still show content. */
html.js-reveal [data-reveal] { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s ease; }
html.js-reveal [data-reveal].revealed { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal, [data-reveal] { animation: none; opacity: 1; transform: none; transition: none; }
  .hero-mesh { animation: none; }
  .cmap-line { animation: none; stroke-dashoffset: 0; }
  .cmap-dot { animation: none; opacity: 0.9; }
  .cmap-box { animation: none; opacity: 1; }
  .term-cycle-item { animation: none; opacity: 0; }
  .term-cycle-item:first-child { opacity: 1; }
  html { scroll-behavior: auto; }
}
