/* Joer — architecture essay. Builds on site.css and case.css; same three colors, same rules. */

/* ---------- Glossary (inside the context panel) ---------- */
.j-glossary { display: grid; gap: 0; border-top: var(--rule-hair) solid var(--border-on-panel); }
.j-glossary > div {
  display: grid;
  gap: var(--space-6);
  padding: var(--space-16) 0;
  border-bottom: var(--rule-hair) solid var(--border-on-panel);
}
.j-glossary dt { font-weight: 800; font-size: 18px; letter-spacing: -.2px; color: var(--text-display); }
.j-glossary dd { font-size: 15px; line-height: 1.5; font-weight: 500; }

/* ---------- Shelf (the books behind the method, inside the context panel) ----------
   Each cover stands on a deep plinth with an orange shelf line; the stripe offset behind it is the brand texture. */
.j-shelf { display: grid; gap: clamp(var(--space-24), 3vw, var(--space-40)); }
.j-shelf__head {
  display: grid;
  gap: var(--space-14);
  padding-top: var(--space-24);
  border-top: var(--rule-strong) solid var(--border-on-panel);
}
.j-shelf__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(32px, 3.4vw, 52px);
  line-height: .95;
  text-transform: uppercase;
  color: var(--text-display);
  text-wrap: balance;
}
.j-shelf__title span { color: var(--accent); }
.j-shelf__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: clamp(var(--space-24), 3vw, var(--space-40));
}
.j-book { display: grid; grid-template-rows: auto 1fr; gap: var(--space-20); }
.j-book__cover {
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(var(--space-28), 4vw, var(--space-56)) var(--space-24) 0;
  background: var(--surface-media);
  border-radius: 0;
  overflow: hidden;
}
/* Shelf line the book stands on */
.j-book__cover::after {
  content: "";
  justify-self: stretch;
  height: var(--space-14);
  margin: 0 calc(-1 * var(--space-24));
  background: repeating-linear-gradient(-45deg, var(--accent) 0 8px, transparent 8px 20px);
  border-top: var(--rule-strong) solid var(--accent);
}
.j-book__cover img {
  display: block;
  width: min(68%, 200px);
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 0;
  box-shadow: 10px 10px 0 var(--accent); /* printed offset in brand orange */
  transform-origin: 50% 100%;
  transition: transform .45s cubic-bezier(.2, .7, .2, 1);
}
.j-book:hover .j-book__cover img,
.j-book:focus-within .j-book__cover img { transform: translateY(-8px) rotate(-2deg); }
.j-book__info { display: grid; align-content: start; gap: var(--space-12); }
.j-book__meta {
  display: flex;
  justify-content: space-between;
  gap: var(--space-12);
  padding-bottom: var(--space-12);
  border-bottom: var(--rule-hair) solid var(--border-on-panel);
}
.j-book__title { font-weight: 800; font-size: clamp(20px, 1.7vw, 24px); line-height: 1.15; letter-spacing: -.3px; color: var(--text-display); }
.j-book__note { font-size: 15px; line-height: 1.5; font-weight: 500; }
.j-book__link {
  justify-self: start;
  margin-top: var(--space-4);
  color: var(--text-on-panel);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.j-book__link:hover { color: var(--text-hover); }
@media (prefers-reduced-motion: reduce) {
  .j-book__cover img { transition: none; }
  .j-book:hover .j-book__cover img,
  .j-book:focus-within .j-book__cover img { transform: none; }
}

/* ---------- Process steps (hero index of the chapters) ---------- */
.j-steps {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  border-top: var(--rule-strong) solid var(--border-strong);
}
.j-steps a {
  display: grid;
  gap: var(--space-6);
  height: 100%;
  padding: var(--space-16) var(--space-14) var(--space-20);
  border-bottom: var(--rule-strong) solid var(--border-strong);
  transition: background .25s ease, color .25s ease;
}
.j-steps li + li a { border-left: var(--rule-hair) solid var(--border-strong); }
.j-steps b { font-weight: 800; font-size: 17px; line-height: 1.2; letter-spacing: -.2px; }
.j-steps a:is(:hover, :focus-visible) { background: var(--ink); color: var(--accent); }
.is-dark .j-steps a:is(:hover, :focus-visible) { background: var(--accent); color: #141414; }

/* ---------- Domain event quoted inside the prose ---------- */
.j-event {
  padding: .1em .4em;
  border-radius: 0;
  background: var(--surface-panel);
  color: var(--text-on-panel);
  font-weight: 700;
  white-space: nowrap;
  box-decoration-break: clone;
}

/* ---------- Event storming strip ----------
   A timeline, the way it lands on the wall: outlined steps, orange domain events (past tense),
   a blush saga that coordinates what follows. The last lane runs right to left: each compensation
   sits under the event it undoes, in the order the saga undoes them. */
.j-storm {
  background: var(--surface-panel);
  color: var(--text-on-panel);
  border-radius: 0;
  padding: clamp(20px, 3vw, var(--space-40));
  display: grid;
  gap: var(--space-24);
}
.j-storm__head { display: flex; justify-content: space-between; gap: var(--space-12); flex-wrap: wrap; }
.j-storm__lane { margin-bottom: calc(var(--space-12) * -1); color: var(--paper); }
.j-storm__line {
  position: relative;
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-14);
}
/* the time axis behind the notes */
.j-storm__line::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: linear-gradient(to right, var(--accent) 0 calc(100% - 10px), transparent 0);
}
.j-storm__note {
  position: relative;
  display: grid;
  gap: var(--space-6);
  align-content: start;
  min-height: 132px;
  padding: var(--space-14);
  border-radius: 0;
  background: var(--accent);
  color: var(--ink);
  rotate: var(--r, 0deg);
  box-shadow: 0 10px 18px -10px rgba(0, 0, 0, .6);
  transition: rotate .35s ease;
}
.j-storm__note:nth-child(1) { --r: -1.5deg; }
.j-storm__note:nth-child(2) { --r: 1deg; }
.j-storm__note:nth-child(3) { --r: -.5deg; }
.j-storm__note:nth-child(4) { --r: 1.5deg; }
.j-storm__note:nth-child(5) { --r: -1deg; }
.j-storm__note b { font-weight: 800; font-size: 15px; line-height: 1.2; overflow-wrap: break-word; }
.j-storm__note span { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; }
.j-storm__note--step { background: var(--surface-panel); color: var(--text-on-panel); box-shadow: inset 0 0 0 2px var(--accent); }
.j-storm__line--undo { direction: rtl; }
.j-storm__line--undo::before { background: linear-gradient(to left, var(--paper) 0 calc(100% - 10px), transparent 0); }
.j-storm__line--undo > * { direction: ltr; }
.j-storm__note--saga { background: var(--paper); }
.j-storm__note--fail { background: var(--ink-deep); color: var(--paper); box-shadow: inset 0 0 0 2px var(--paper); }
.j-storm__note--undo { background: var(--surface-panel); color: var(--paper); box-shadow: none; outline: 2px dashed var(--paper); outline-offset: -2px; }
.j-storm:hover .j-storm__note { rotate: 0deg; }
.j-storm__legend { display: flex; flex-wrap: wrap; gap: var(--space-6) var(--space-24); }
.j-storm__legend span { display: inline-flex; align-items: center; gap: var(--space-12); }
.j-storm__legend i { width: 14px; height: 14px; border-radius: 0; background: var(--accent); }
.j-storm__legend i.j-storm__swatch--step { background: transparent; box-shadow: inset 0 0 0 2px var(--accent); }
.j-storm__legend i.j-storm__swatch--saga { background: var(--paper); }
.j-storm__legend i.j-storm__swatch--fail { background: var(--ink-deep); box-shadow: inset 0 0 0 2px var(--paper); }
.j-storm__legend i.j-storm__swatch--undo { background: transparent; outline: 2px dashed var(--paper); outline-offset: -2px; }
.j-storm__caption { font-size: 15px; line-height: 1.5; font-weight: 500; color: var(--paper); max-width: 720px; }

/* ---------- Context map ----------
   Three bounded contexts stacked, joined by the messages that cross the border.
   The same person is a client at the front desk and a patient in the office. */
.j-ctx {
  container: ctx / inline-size;
  background: var(--surface-panel);
  color: var(--text-on-panel);
  border-radius: 0;
  padding: clamp(20px, 3vw, var(--space-40));
  display: grid;
  gap: clamp(var(--space-28), 3vw, var(--space-40));
}
.j-ctx__head { display: grid; gap: var(--space-14); }
.j-ctx__kicker { display: flex; justify-content: space-between; gap: var(--space-12); }
.j-ctx__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(32px, 3.4vw, 52px);
  line-height: .95;
  text-transform: uppercase;
  color: var(--text-display);
}
.j-ctx__title span { color: var(--accent); }
.j-ctx__legend {
  list-style: none;
  padding: var(--space-14) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6) var(--space-24);
  border-top: var(--rule-hair) solid var(--border-on-panel);
}
.j-ctx__legend li { display: inline-flex; align-items: center; gap: var(--space-12); }
.j-ctx__swatch { display: inline-block; width: 14px; height: 14px; border-radius: 0; border: 2px solid var(--accent); }
.j-ctx__swatch--core { background: var(--paper); border-color: var(--paper); }
.j-ctx__swatch--generic { border-style: dashed; }

.j-ctx__map {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.j-ctx__box {
  display: grid;
  gap: var(--space-6);
  align-content: start;
  padding: var(--space-16) var(--space-18) var(--space-18);
  border: var(--rule-strong) solid var(--border-on-panel);
  border-radius: 0;
}
.j-ctx__box > * { min-width: 0; }
.j-ctx__box--generic { border-style: dashed; }
.j-ctx__box--core { background: var(--paper); border-color: var(--paper); color: var(--ink); }
.j-ctx__meta { font-family: var(--font-mono); font-size: 11px; line-height: 1.4; text-transform: uppercase; }
.j-ctx__name {
  font-family: var(--font-display);
  font-size: clamp(28px, 2.6vw, 40px);
  line-height: 1;
  text-transform: uppercase;
  color: var(--text-display);
}
.j-ctx__box--core .j-ctx__name { color: var(--ink); }
.j-ctx__word {
  margin-top: var(--space-12);
  padding-top: var(--space-12);
  border-top: var(--rule-hair) solid currentColor;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 500;
}
.j-ctx__word b { display: block; font-family: var(--font-mono); font-weight: 400; font-size: 11px; text-transform: uppercase; margin-bottom: var(--space-4); }
/* what this context deliberately never sees */
.j-ctx__word i {
  display: block;
  margin-top: var(--space-12);
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  text-transform: uppercase;
}
.j-ctx__word i::before { content: "⊘ " / ""; }

/* Connector between two contexts: a label over a line with an arrowhead */
.j-ctx__edge {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 72px;
}
.j-ctx__edge > span {
  position: relative;
  z-index: 1;
  padding: var(--space-4) var(--space-6);
  background: var(--surface-panel);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.3;
  text-transform: uppercase;
  text-align: center;
  color: var(--paper);
}
.j-ctx__edge::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 12px;
  translate: -50% 0;
  background:
    radial-gradient(circle, var(--paper) 2.5px, transparent 3.5px) center -12px / 12px 12px no-repeat,
    linear-gradient(var(--accent), var(--accent)) center top / 2px calc(100% - 7px) no-repeat,
    linear-gradient(to top right, transparent 50%, var(--accent) 0) left bottom / 6px 7px no-repeat,
    linear-gradient(to bottom right, var(--accent) 50%, transparent 0) right bottom / 6px 7px no-repeat;
  animation: j-ctx-pulse 2.8s cubic-bezier(.5, 0, .5, 1) infinite;
  animation-delay: var(--d, 0s);
}
.j-ctx__edge + .j-ctx__box + .j-ctx__edge { --d: 1.4s; }
@keyframes j-ctx-pulse {
  0%, 15% { background-position: center -12px, center top, left bottom, right bottom; }
  60%, 100% { background-position: center calc(100% + 12px), center top, left bottom, right bottom; }
}
/* Wide enough: name on the left, what the word means here on the right */
@container ctx (min-width: 560px) {
  .j-ctx__box { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); column-gap: var(--space-24); }
  .j-ctx__meta, .j-ctx__name { grid-column: 1; }
  .j-ctx__word { grid-column: 2; grid-row: 1 / span 2; margin: 0; padding: 0 0 0 var(--space-24); border-top: 0; border-left: var(--rule-hair) solid currentColor; }
}
.is-motion-paused .j-ctx__edge::before { animation: none; }
@media (prefers-reduced-motion: reduce) { .j-ctx__edge::before { animation: none; } }

.j-ctx__note { font-size: 15px; line-height: 1.5; font-weight: 500; color: var(--paper); max-width: 720px; }

/* ---------- Domain model ----------
   The four tactical pieces inside one bounded context. Colors follow the rest of the page:
   blush for what matters most (the aggregate), orange fill for a domain event, dashed for a value. */
.j-model {
  container: model / inline-size;
  background: var(--surface-panel);
  color: var(--text-on-panel);
  border-radius: 0;
  padding: clamp(20px, 3vw, var(--space-40));
  display: grid;
  gap: clamp(var(--space-28), 3vw, var(--space-40));
}
.j-model__head { display: grid; gap: var(--space-14); }
.j-model__kicker { display: flex; justify-content: space-between; gap: var(--space-12); flex-wrap: wrap; }
.j-model__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(32px, 3.4vw, 52px);
  line-height: .95;
  text-transform: uppercase;
  color: var(--text-display);
}
.j-model__title span { color: var(--accent); }

.j-model__grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-14);
}
@container model (min-width: 560px) {
  .j-model__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .j-model__card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.j-model__card {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: var(--space-6);
  padding: var(--space-16) var(--space-18) var(--space-18);
  border: var(--rule-strong) solid var(--accent);
  border-radius: 0;
}
.j-model__card > * { min-width: 0; }
.j-model__card--root { background: var(--paper); border-color: var(--paper); color: var(--ink); }
.j-model__card--value { border-style: dashed; }
.j-model__card--event { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.j-model__type { font-family: var(--font-mono); font-size: 11px; line-height: 1.4; text-transform: uppercase; }
.j-model__name {
  font-family: var(--font-display);
  font-size: clamp(28px, 2.6vw, 40px);
  line-height: 1;
  text-transform: uppercase;
  color: var(--text-display);
  overflow-wrap: break-word;
}
.j-model__card--root .j-model__name,
.j-model__card--event .j-model__name { color: var(--ink); }
.j-model__ask { font-size: 15px; line-height: 1.35; font-weight: 800; letter-spacing: -.2px; }
.j-model__detail {
  display: grid;
  gap: var(--space-6);
  align-content: start;
  margin-top: var(--space-6);
  padding-top: var(--space-12);
  border-top: var(--rule-hair) solid currentColor;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 500;
}
.j-model__detail b { font-family: var(--font-mono); font-weight: 400; font-size: 11px; text-transform: uppercase; }
.j-model__note { font-size: 15px; line-height: 1.5; font-weight: 500; color: var(--paper); max-width: 720px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .j-storm__line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .j-storm__line::before { display: none; }
  .j-storm__line--undo { direction: ltr; }
  .j-storm__note:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .j-steps li + li a { border-left: 0; }
}
@media (max-width: 480px) {
  .j-storm__line { grid-template-columns: minmax(0, 1fr); }
  .j-storm__note { min-height: 0; }
}

/* ---------- Toolkit ----------
   Nine techniques in three fronts. Each card points back to the chapter where the technique is used;
   the whole card is the link (stretched ::after), hover inverts like the hero steps. */
.j-tools-section { display: grid; gap: clamp(var(--space-24), 3vw, var(--space-40)); }
.j-tools-section .j-section-header { padding-bottom: 0; }
.j-tools__lead {
  margin: 0;
  max-width: 760px;
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -.02em;
  text-wrap: balance;
}
.j-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: var(--rule-strong) solid var(--border-strong);
  border-bottom: var(--rule-strong) solid var(--border-strong);
}
.j-tools__group { display: grid; grid-template-rows: auto 1fr; min-width: 0; }
.j-tools__group + .j-tools__group { border-left: var(--rule-hair) solid var(--border-strong); }
.j-tools__head > * { margin: 0; }
.j-tools__head {
  display: grid;
  gap: var(--space-6);
  align-content: start;
  padding: var(--space-20) var(--space-18) var(--space-24);
  border-bottom: var(--rule-strong) solid var(--border-strong);
}
.j-tools__head > .j-tools__kicker { display: flex; justify-content: space-between; gap: var(--space-12); margin-bottom: var(--space-12); }
.j-tools__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(34px, 3.4vw, 54px);
  line-height: .92;
  text-transform: uppercase;
}
.j-tools__sub { font-size: 15px; line-height: 1.4; font-weight: 500; }
.j-tools__list { list-style: none; padding: 0; margin: 0; display: grid; align-content: start; }
.j-tools__item {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-6) var(--space-16);
  padding: var(--space-20) var(--space-18) var(--space-24);
  transition: background .25s ease, color .25s ease;
}
.j-tools__item + .j-tools__item { border-top: var(--rule-hair) solid var(--border-strong); }
.j-tools__item > * { margin: 0; }
.j-tools__item > :not(.j-tools__num) { grid-column: 2; }
.j-tools__num {
  grid-row: 1 / span 3;
  font-family: var(--font-display);
  font-size: 40px;
  line-height: .85;
  min-width: 2ch;
  margin-top: -2px;
}
.j-tools__name { font-weight: 800; font-size: clamp(18px, 1.5vw, 21px); line-height: 1.2; letter-spacing: -.3px; text-wrap: balance; }
.j-tools__desc { font-size: 15px; line-height: 1.45; font-weight: 500; }
.j-tools__link { margin-top: var(--space-6); justify-self: start; }
.j-tools__link::after { content: ""; position: absolute; inset: 0; }
.j-tools__link:focus-visible { outline: none; }
.j-tools__item:has(.j-tools__link:focus-visible) { outline: var(--rule-strong) solid var(--ink); outline-offset: -4px; }
.j-tools__item:has(.j-tools__link:is(:hover, :focus-visible)) { background: var(--ink); color: var(--accent); }
.is-dark .j-tools__item:has(.j-tools__link:is(:hover, :focus-visible)) { background: var(--accent); color: #141414; }
.is-dark .j-tools__item:has(.j-tools__link:focus-visible) { outline-color: var(--accent); }

@media (max-width: 900px) {
  .j-tools { grid-template-columns: minmax(0, 1fr); border-bottom: 0; }
  .j-tools__group + .j-tools__group { border-left: 0; border-top: var(--rule-strong) solid var(--border-strong); margin-top: var(--space-40); }
  .j-tools__list { border-bottom: var(--rule-strong) solid var(--border-strong); }
  .j-tools__head, .j-tools__item { padding-inline: 0; }
  .j-tools__item:has(.j-tools__link:is(:hover, :focus-visible)) { padding-inline: var(--space-14); }
}
