/* Case-study components for the /blog/<slug>/ pages (rendered per request by
   scripts/site-pages.js from scripts/case-study-template.html; the HTML comes
   from render.js: modalHeaderHtml, caseStudySectionsHtml). The "modal-*" class
   names date from when the homepage showed case studies in a pop-up; that pop-up
   is gone and these are just names now. Uses the color/font tokens (--paper,
   --ink, --orange, --serif...) that each page defines on :root. */

/* Case-study banner: the hero's language in miniature — a skewed color
   slab sweeps in, the label's parts drop in as tilted paper chips, and a
   hand-drawn squiggle draws itself. Slab color is per entry: an
   inline --modal-accent set by render.js (the admin's color, or a built-in
   default); orange if neither. */
.modal-header {
  --modal-accent: var(--orange);
  height: 160px;
  position: relative;
  overflow: hidden;
  background: var(--black);
  display: flex;
  align-items: flex-end;
  padding: 0 28px 26px;
}
.modal-header-slab {
  position: absolute;
  left: -4%;
  top: 22%;
  width: 74%;
  height: 110%;
  background: var(--modal-accent);
  transform: skewY(-5deg);
  animation: modalSlabIn 0.6s cubic-bezier(0.22,1,0.36,1) 0.1s both;
}
.modal-header-squiggle {
  position: absolute;
  top: 30px;
  right: 72px;
  width: 180px;
  height: 18px;
  overflow: visible;
}
.modal-header-squiggle path {
  fill: none;
  stroke: var(--paper);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0.85;
  animation: modalSquiggleDraw 0.7s cubic-bezier(0.22,1,0.36,1) 0.55s forwards;
}
.modal-header-chips {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-right: 40px;
}
.modal-header-chip {
  --r: -1.5deg;
  display: inline-block;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--black);
  background: var(--paper);
  padding: 5px 12px;
  transform: rotate(var(--r));
  animation: modalChipIn 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
  animation-delay: calc(0.3s + var(--i, 0) * 0.09s);
}
.modal-header-chip:nth-child(even) { --r: 1.2deg; }
.modal-header-chip:nth-child(3n) { --r: -0.5deg; }
/* The glasses mark on a tilted paper square, slapped on last. The mark is
   the cream PNG used as a mask, so it can be drawn in any color. */
.modal-header-sticker {
  position: absolute;
  right: 104px;
  bottom: 22px;
  width: 62px;
  height: 62px;
  background: var(--paper);
  box-shadow: 0 8px 18px rgba(0,0,0,.45);
  transform: rotate(7deg);
  animation: modalStickerIn 0.5s cubic-bezier(0.34,1.56,0.64,1) 0.8s both;
}
.modal-header-sticker-mark {
  position: absolute;
  inset: 9px;
  background: var(--black);
  -webkit-mask: url("/images/icon-mark-light.png") center / contain no-repeat;
  mask: url("/images/icon-mark-light.png") center / contain no-repeat;
}
@keyframes modalStickerIn {
  from { opacity: 0; transform: translateY(-10px) scale(1.5) rotate(-12deg); }
}
@keyframes modalSlabIn {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}
@keyframes modalSquiggleDraw {
  to { stroke-dashoffset: 0; }
}
@keyframes modalChipIn {
  from { opacity: 0; transform: translateY(-16px) rotate(calc(var(--r) * 5)); }
}
@media (prefers-reduced-motion: reduce) {
  .modal-header-slab,
  .modal-header-chip,
  .modal-header-sticker { animation: none; }
  .modal-header-squiggle path { animation: none; stroke-dashoffset: 0; }
}
.modal-body {
  padding: 28px;
}
.modal-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
}
.modal-heading-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}
.modal-title {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0;
}
.modal-logo {
  width: 92px;
  height: 70px;
  padding: 9px;
  border: none;
  border-radius: 0;
  background: none;
  object-fit: contain;
  flex: 0 0 auto;
}
.modal-logo--square {
  width: 70px;
}
.modal-logo-link {
  display: block;
  flex: 0 0 auto;
  border-radius: 0;
  transition: opacity 0.2s ease;
}
.modal-logo-link:hover,
.modal-logo-link:focus-visible {
  opacity: 0.7;
  outline: none;
}
.modal-video {
  position: relative;
  aspect-ratio: 16 / 9;
  margin-bottom: 24px;
  border-radius: 0;
  overflow: hidden;
  background: #000;
}
.modal-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.modal-section-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--orange-ink);
  margin-bottom: 8px;
  margin-top: 20px;
}
.modal-problem {
  font-family: var(--sans);
  font-size: 14px;
  color: rgba(27,24,16,.75);
  line-height: 1.7;
  margin-bottom: 4px;
}
.modal-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}
.modal-bullets li {
  font-family: var(--sans);
  font-size: 14px;
  color: rgba(27,24,16,.75);
  line-height: 1.6;
  padding-left: 16px;
  position: relative;
}
.modal-bullets li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--orange-ink);
  font-size: 12px;
}
.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}
.modal-stat-tile {
  background: rgba(27,24,16,.05);
  border: 1px solid var(--border-ink);
  border-radius: 0;
  padding: 14px;
  text-align: center;
}
.modal-stat-num {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--orange-ink);
  display: block;
  margin-bottom: 4px;
}
.modal-stat-label {
  font-family: var(--sans);
  font-size: 11px;
  color: rgba(27,24,16,.55);
  line-height: 1.3;
}
.modal-outcome {
  font-family: var(--sans);
  font-size: 14px;
  color: rgba(27,24,16,.75);
  line-height: 1.7;
}
.modal-ext-section {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-ink);
}
.modal-ext-section:first-of-type {
  margin-top: 20px;
  padding-top: 0;
  border-top: none;
}
.modal-ext-heading {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 4px 0 10px;
  line-height: 1.3;
}
.modal-ext-body {
  font-family: var(--sans);
  font-size: 14px;
  color: rgba(27,24,16,.75);
  line-height: 1.7;
  margin-bottom: 10px;
}
.modal-ext-body:last-child {
  margin-bottom: 0;
}
.modal-ext-body a {
  color: var(--orange-ink);
}
.modal-ext-body code {
  background: rgba(255,106,61,.16);
  color: var(--orange-ink);
  padding: 1px 5px;
  border-radius: 0;
  font-size: 13px;
}

@media (max-width: 900px) {
  .modal-stats { grid-template-columns: repeat(3, 1fr); }
  .modal-header { height: 132px; padding: 0 20px 20px; }
  .modal-header-slab { width: 92%; }
  .modal-header-squiggle { left: 20px; right: auto; top: 12px; width: 120px; height: 12px; }
  .modal-header-chips { gap: 8px; }
  .modal-header-chip { font-size: 11px; padding: 4px 10px; }
  .modal-header-chips { padding-right: 60px; }
  .modal-header-sticker { right: 18px; bottom: 18px; width: 46px; height: 46px; }
  .modal-header-sticker-mark { inset: 7px; }
}
