/* ==========================================================================
   Case study template — shared by every case study via the CMS.
   Per-entry accent comes from `headings_color` (violet | purple | pink |
   green | blue | amber), applied as a class on <body> by case-study.js,
   which overrides the --case-accent / --case-accent-tint tokens already
   defined (defaulting to violet) in tokens.css.
   ========================================================================== */

/* Per-entry accent now comes directly from `headings_color`, which stores
   a real hex value (e.g. "#DC2626") and is applied as an inline CSS
   variable by case-study.js — no fixed palette to keep in sync with the
   CMS anymore. See fix_accent_colors.sql for the one-time migration from
   the old named-color values. */

/* ---- Case-study nav pill: "← Projects" + section jump-links ----
   Unlike the plain site nav (which can scroll as a whole if it ever
   overflows), this one keeps "← Projects" pinned and only scrolls the
   section links — matches the reference site's mobile behavior, where
   the back arrow never moves and section names scroll under it. */
.case-nav {
  overflow: visible;
}
.case-nav-scroll {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}
.case-nav-scroll::-webkit-scrollbar { display: none; }

.case-nav-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ---- Loading / error states ---- */
.case-loading,
.case-error {
  padding: 160px 0 120px;
  text-align: center;
  color: var(--color-text-tertiary);
}
.case-error p { margin-bottom: 20px; color: var(--color-text-tertiary); }

/* ---- Hero ---- */
.case-hero {
  margin-top: 120px;
}

@media (max-width: 809px) {
  .case-hero { margin-top: 100px; }
}

.case-hero-text { max-width: none; }

.case-hero .eyebrow { margin-bottom: 16px; }

.case-hero h1 {
  font-size: var(--text-4xl);
  margin-bottom: 20px;
}

.case-description {
  font-size: var(--text-lg);
  line-height: var(--line-height-relaxed);
  color: var(--color-text-secondary);
  max-width: none;
}

.case-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-top: 48px;
  padding: 28px 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

@media (max-width: 809px) {
  .case-meta-grid { grid-template-columns: repeat(2, 1fr); row-gap: 24px; }
}

.case-meta-item h4 { margin-bottom: 8px; }
.case-meta-item p {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.4;
}

/* ---- Cover image / video ---- */
.case-cover {
  margin-top: 48px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-alt);
  aspect-ratio: 4 / 3;
}
.case-cover img,
.case-cover video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.case-cover [hidden] {
  display: none !important;
}

@media (max-width: 809px) {
  .case-cover { border-radius: var(--radius-sm); }
}

/* ---- Sections ---- */
.case-sections {
  max-width: none;
}

.case-section {
  padding: 80px 0;
}
.case-section + .case-section.has-divider {
  border-top: 1px solid var(--color-border);
}

@media (max-width: 809px) {
  .case-section { padding: 56px 0; }
}

.case-section .eyebrow { margin-bottom: 12px; }

.case-section h2 {
  font-size: var(--text-2xl);
  max-width: 22ch;
  margin-bottom: 28px;
}

/* Rich text rendered from content_section_N (HTML from the CMS editor) */
.case-section-body { display: flex; flex-direction: column; gap: 20px; }
.case-section-body h2 { font-size: var(--text-2xl); max-width: 22ch; }
.case-section-body p { font-size: var(--text-base); line-height: var(--line-height-relaxed); color: var(--color-text-secondary); }
.case-section-body strong { color: var(--color-text-primary); font-weight: 600; }
.case-section-body a:not(.btn) { color: var(--case-accent); text-decoration: underline; text-underline-offset: 2px; }
.case-section-body .btn { margin-top: 4px; }

.case-section-body ul,
.case-section-body ol {
  padding-left: 1.25em;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.case-section-body ul { list-style: disc; }
.case-section-body ol { list-style: decimal; }

.case-section-body blockquote {
  margin: 8px 0;
  padding-left: 20px;
  border-left: 3px solid var(--case-accent);
  font-size: var(--text-xl);
  font-weight: 500;
  font-style: italic;
  line-height: var(--line-height-snug);
  color: var(--color-text-primary);
}

.case-section-body figure { margin: 8px 0; }
.case-section-body figure img {
  width: 100%;
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
}
.case-section-body figcaption {
  margin-top: 10px;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.case-section-body img:not(figure img) {
  width: 100%;
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
}

/* For placing two images side by side (e.g. "Old app (left) vs New app
   (right)"). In the CMS rich-text editor, wrap the pair like:
   <div class="img-row"><figure><img ...><figcaption>...</figcaption></figure><figure>...</figure></div> */
.case-section-body .img-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.case-section-body .img-row figure { flex: 1 1 0; margin: 0; }
.case-section-body .img-row img { width: 100%; }

@media (max-width: 809px) {
  .case-section-body .img-row { flex-direction: column; }
}

/* ---- CTA ---- */
.case-cta {
  max-width: none;
  padding-bottom: 40px;
}
.case-cta-btn {
  width: 100%;
  height: auto;
  padding: 16px 20px;
  background: var(--color-bg-alt);
  color: var(--color-text-primary);
  box-shadow: none;
  font-size: 15px;
}
.case-cta-btn:hover {
  background: var(--color-border);
  transform: none;
}

/* ---- Explore more ---- */
.case-explore {
  margin-top: 40px;
  padding: 56px 0 80px;
  border-top: 1px solid var(--color-border);
}
.case-explore h4 { margin-bottom: 24px; }

.case-explore-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(50px, 1fr));
  gap: 24px;
}
@media (max-width: 1023px) {
  .case-explore-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 809px) {
  .case-explore-list { grid-template-columns: 1fr; }
}

.explore-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.explore-card:hover .explore-card-thumb img { transform: scale(1.03); }

.explore-card-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 20px;
  overflow: hidden;
  background: var(--color-bg-alt);
}
.explore-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-base) var(--ease-out-soft);
}
@media (max-width: 809px) {
  .explore-card-thumb { border-radius: 8px; }
}

.explore-card-caption { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; width: 100%; }
.explore-card h3 { flex: 1 0 0; font-size: 14px; font-weight: 600; line-height: 1.5; color: var(--color-text-primary); transition: color var(--duration-fast); }
.explore-card:hover h3 { color: var(--case-accent); }
.explore-card-meta { flex: none; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; line-height: 1.5; color: var(--color-text-tertiary); white-space: nowrap; }
.explore-card-meta span:nth-child(2) { width: 3px; height: 3px; border-radius: 50%; background: currentColor; display: inline-block; }
