/* =========================================================
   blocks.css  ·  flexible case-study block system + iPhone mockup
   Drives the per-project, fully customisable page layouts.
   ========================================================= */

/* ---------- Per-project accent (Anshika Doogar.dc palette) ---------- */
[data-accent="navy"] { --accent: #2b4bff; --accent-on: #fff; --accent-soft: #dbe2ff; --accent-text: #2b4bff; }
[data-accent="pink"] { --accent: #ff3d7f; --accent-on: #fff; --accent-soft: #ffe6fc; --accent-text: #c9215e; }
[data-accent="lime"] { --accent: #1f9d57; --accent-on: #fff; --accent-soft: #d6f2e1; --accent-text: #1f9d57; }
[data-accent="blue"] { --accent: #2b4bff; --accent-on: #fff; --accent-soft: #dbe2ff; --accent-text: #2b4bff; }
[data-accent="orange"] { --accent: #e2502b; --accent-on: #fff; --accent-soft: #ffe0d4; --accent-text: #c23c19; }
:root { --accent: #2b4bff; --accent-on: #fff; --accent-soft: #dbe2ff; --accent-text: #2b4bff; }

/* ---------- Block rhythm ---------- */
.blk { position: relative; }
.blk + .blk { margin-top: clamp(48px, 8vw, 120px); }
.blk__head { margin-bottom: clamp(22px, 3.5vw, 44px); }
.blk__eyebrow {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; font-weight: 400;
  color: var(--accent-text); display: block;
}
.blk__eyebrow::before { content: "— "; }
.blk__title { font-family: var(--display); font-style: normal; font-weight: 400; color: var(--ink); font-size: clamp(1.8rem, 4.4vw, 3.2rem); line-height: 1; letter-spacing: -1px; text-transform: uppercase; margin: 10px 0 0; overflow-wrap: break-word; }

/* ---------- richtext ---------- */
.blk-rt { display: grid; gap: clamp(20px, 4vw, 64px); align-items: start; }
/* Intro / overview: centered EB Garamond block (reference) */
.blk-rt--intro { display: block; text-align: center; max-width: 900px; margin-inline: auto; }
.blk-rt--intro .blk__eyebrow { margin-bottom: 18px; }
.blk-rt--intro .blk-rt__body { font-family: var(--serif); font-size: clamp(1.3rem, 2.6vw, 1.6rem); line-height: 1.55; color: var(--ink); max-width: 720px; margin-inline: auto; }
.blk-rt--single { grid-template-columns: 1fr; max-width: 70ch; }
.blk-rt--single.is-center { margin-inline: auto; text-align: center; }
.blk-rt__body { font-size: clamp(1.08rem, 1.7vw, 1.35rem); color: var(--ink); line-height: 1.65; overflow-wrap: break-word; }
.blk-rt__body p { margin: 0 0 1em; }
.blk-rt__body p:last-child { margin-bottom: 0; }

/* ---------- image ---------- */
.cs-image { margin-inline: auto; }
.cs-image--full { width: 100%; }
.cs-image--wide { width: 100%; }
.cs-image--inset { max-width: 820px; }
.cs-image .ph { border-radius: var(--r-xl); }
.cs-image figcaption { margin-top: 12px; font-size: .85rem; color: var(--ink-faint); font-style: italic; text-align: center; }

/* ---------- video ---------- */
.cs-video { margin-inline: auto; }
.cs-video--wide { width: 100%; }
.cs-video--inset { max-width: 820px; }
.cs-video__frame {
  position: relative; border-radius: var(--r-xl); overflow: hidden;
  background: var(--paper-2); box-shadow: var(--shadow-md); aspect-ratio: var(--ar, 16/9);
}
.cs-video__frame > video, .cs-video__frame > .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cs-video figcaption { margin-top: 12px; font-size: .85rem; color: var(--ink-faint); font-style: italic; text-align: center; }
.cs-video__empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-faint); }

/* ---------- iPhone mockup (phone block) ---------- */
.cs-phone { display: flex; justify-content: center; }
.cs-phone--left { justify-content: flex-start; }
.cs-phone--right { justify-content: flex-end; }
.cs-phone__wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 100%; }
.device {
  position: relative;
  width: clamp(232px, 30vw, 300px);
  aspect-ratio: 9 / 19.5;
  background: linear-gradient(160deg, #2b2b30, #0c0c0e);
  border-radius: 44px;
  padding: 12px;
  box-shadow: 0 2px 0 rgba(255,255,255,0.10) inset, 0 30px 70px rgba(24,23,21,0.30), 0 0 0 2px rgba(0,0,0,0.4);
}
.device::after { /* side button */
  content: ""; position: absolute; right: -3px; top: 22%; width: 3px; height: 64px; border-radius: 3px; background: #1a1a1d;
}
.device__screen {
  position: relative; width: 100%; height: 100%; border-radius: 33px; overflow: hidden;
  background: #000; display: block;
}
.device__screen > video, .device__screen > img, .device__screen > .ph {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 33px;
}
.device__notch {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 34%; height: 26px; background: #000; border-radius: 999px; z-index: 3;
}
.device__tap {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; gap: 10px; padding-bottom: 26px;
  color: #fff; text-decoration: none;
  background: linear-gradient(180deg, rgba(0,0,0,0) 45%, rgba(0,0,0,0.55));
}
.device__play {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,0.16); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.4); transition: transform .3s var(--ease), background .3s;
}
.device__tap:hover .device__play { transform: scale(1.08); background: rgba(255,255,255,0.28); }
.device__cap { font-weight: 600; font-size: .9rem; text-align: center; padding-inline: 14px; }
.cs-phone__note { font-size: .85rem; color: var(--ink-faint); font-style: italic; text-align: center; max-width: 36ch; }
/* visible focus ring on dark / gradient surfaces */
.device__tap, .cs-insta__btn { --focus-ring: var(--lime); }

/* ---------- phone feature: editorial composition (no lonely phones) ---------- */
.cs-feature {
  position: relative; overflow: clip;
  background: var(--accent-soft);
  border-radius: var(--r-xl);
  padding: clamp(20px, 3vw, 40px);
  display: grid; grid-template-columns: 260px 1fr;
  gap: clamp(24px, 4vw, 44px);
  align-items: center;
}
.cs-feature--left .cs-feature__stage { order: -1; }
.cs-feature--right { grid-template-columns: 1fr 260px; }
.cs-feature__eyebrow {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; font-weight: 400;
  color: var(--accent-text); display: block;
}
.cs-feature__eyebrow::before { content: "— "; }
.cs-feature__title {
  font-family: var(--display); font-style: normal; font-weight: 400; color: var(--ink);
  font-size: clamp(1.4rem, 2.6vw, 2rem); line-height: 1.08; letter-spacing: -.5px;
  margin: 10px 0 0; overflow-wrap: break-word;
}
.cs-feature__note { color: var(--ink-soft); line-height: 1.55; margin: 12px 0 0; max-width: 46ch; }
.cs-feature__points { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
@media (max-width: 520px) { .cs-feature__points { grid-template-columns: 1fr; } }
.cs-point { background: rgba(255,255,255,.55); border: 1px solid rgba(255,255,255,.5); border-radius: var(--r-md); padding: 12px 14px; }
.cs-point b { display: block; font-family: var(--display); font-style: normal; font-weight: 400; color: var(--accent-text); font-size: 1rem; letter-spacing: -.3px; margin-bottom: 3px; overflow-wrap: break-word; }
.cs-point span { color: var(--ink-soft); font-size: .88rem; line-height: 1.5; overflow-wrap: break-word; }
.cs-feature__chip {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 16px;
  font-weight: 600; font-size: .9rem; color: rgba(239,236,227,.82);
  background: var(--ink); border: 1px solid transparent; border-radius: 999px; padding: 10px 18px;
  transition: transform var(--t-hover) var(--ease-out), box-shadow var(--t-hover) var(--ease-out);
}
.cs-feature__chip:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -12px rgba(0,0,0,.5); }
.cs-feature__chip:active { transform: scale(0.97); }
.cs-feature__chip .ig { color: #fff; font-weight: 700; }

/* Reference: a straight phone in a tight column, box-shadow only (no halo/tilt) */
.cs-feature__stage { position: relative; display: flex; justify-content: center; align-items: center; min-width: 0; }
.cs-feature .device { width: 220px; z-index: 2; }
.cs-feature__companion {
  position: relative; z-index: 3; flex: none;
  width: clamp(104px, 11vw, 158px); aspect-ratio: 9 / 16;
  border-radius: 20px; overflow: hidden; background: #101113;
  border: 5px solid var(--paper-card); box-shadow: var(--shadow-md);
  margin-left: clamp(-34px, -2.4vw, -20px);
  transform: rotate(3.5deg) translateY(14%);
}
.cs-feature__companion video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cs-feature__companion-cap {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  background: rgba(16,17,19,0.62); color: #fff; border-radius: 999px; padding: 4px 9px;
  font-size: .62rem; font-weight: 600; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 860px) {
  .cs-feature { grid-template-columns: 1fr; }
  .cs-feature--left .cs-feature__stage { order: 0; }
  .cs-feature__stage { padding-block: 10px; }
}
@media (max-width: 400px) {
  .cs-feature__companion { width: 96px; margin-left: -18px; }
}

/* ---------- Instagram block ---------- */
.cs-insta { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.cs-insta__embed { width: 100%; max-width: 540px; margin-inline: auto; }
.cs-insta__btn {
  display: inline-flex; align-items: center; gap: 10px; font-weight: 600;
  padding: 0.85em 1.4em; border-radius: 999px; color: var(--paper);
  background: var(--ink);
  box-shadow: var(--shadow-sm); transition: transform var(--t-hover) var(--ease-out), box-shadow var(--t-hover) var(--ease-out);
}
.cs-insta__btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.cs-insta__btn:active { transform: scale(0.97); }
.cs-insta__cap { font-size: .9rem; color: var(--ink-soft); }

/* ---------- per-project CTA block ---------- */
.cs-ctablk {
  background: var(--accent); color: var(--accent-on); border-radius: var(--r-xl);
  padding: clamp(40px,7vw,84px) clamp(24px,5vw,72px); text-align: center;
}
.cs-ctablk h3 { font-family: var(--display); font-style: normal; font-weight: 400; font-size: clamp(1.8rem,4vw,3rem); margin: 0; color: var(--accent-on); letter-spacing: -1px; line-height: 1.02; overflow-wrap: break-word; }
.cs-ctablk p { margin: 16px auto 0; max-width: 46ch; opacity: .9; }
.cs-ctablk .btn { margin-top: 26px; }
.cs-ctablk--lime { color: var(--on-lime); }

/* ---------- divider ---------- */
.cs-divider { border: none; height: 1px; background: var(--line); margin: 0; }
.cs-divider--dots { height: auto; text-align: center; color: var(--accent); letter-spacing: 1em; font-size: .8rem; }
.cs-divider--space { height: clamp(20px, 5vw, 60px); background: none; }

/* ---------- reel grid (vertical autoplay videos) ---------- */
.cs-reels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cs-reels.cols-1 { grid-template-columns: minmax(0, 320px); justify-content: center; }
.cs-reels.cols-2 { grid-template-columns: repeat(2, 1fr); max-width: 680px; margin-inline: auto; }
.cs-reels.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .cs-reels, .cs-reels.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .cs-reels, .cs-reels.cols-2, .cs-reels.cols-4 { grid-template-columns: minmax(0, 1fr); } }
.cs-reel {
  position: relative; aspect-ratio: 9 / 16; border-radius: var(--r-md);
  overflow: hidden; background: #101113; box-shadow: var(--shadow-sm);
}
.cs-reel video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cs-reel__cap {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 2;
  width: fit-content; max-width: calc(100% - 20px);
  background: rgba(16,17,19,0.62); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-radius: 999px; padding: 5px 12px; font-size: .74rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- custom reel player controls ---------- */
.cs-reel, .device__screen, .cs-feature__companion, .cs-video__frame { cursor: pointer; }
.vp-sound {
  position: absolute; top: 10px; right: 10px; z-index: 6;
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer; padding: 0;
  display: grid; place-items: center; color: #fff;
  background: rgba(16,17,19,0.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; transform: translateY(-4px) scale(.92);
  transition: opacity .35s var(--ease), transform .35s var(--ease), background .2s;
}
.device__screen .vp-sound { top: 46px; }
.cs-feature__companion .vp-sound { width: 28px; height: 28px; top: 8px; right: 8px; }
.cs-reel:hover .vp-sound, .device__screen:hover .vp-sound, .cs-feature__companion:hover .vp-sound,
.cs-video__frame:hover .vp-sound, .vp-active .vp-sound, .vp-sound.is-on, .vp-sound:focus-visible { opacity: 1; transform: none; }
.vp-sound:hover { background: rgba(16,17,19,0.8); }
.vp-sound svg { width: 16px; height: 16px; display: block; }
.cs-feature__companion .vp-sound svg { width: 13px; height: 13px; }

/* control bar: play/pause, back, forward, replay */
.vp-bar {
  position: absolute; left: 10px; bottom: 22px; z-index: 6;
  display: flex; gap: 7px;
  opacity: 0; transform: translateY(6px);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.cs-reel:hover .vp-bar, .device__screen:hover .vp-bar, .cs-video__frame:hover .vp-bar,
.vp-active .vp-bar, .vp-bar:focus-within { opacity: 1; transform: none; }
.device__screen .vp-bar { left: 12px; bottom: 26px; }
.vp-btn {
  width: 28px; height: 28px; border-radius: 50%; border: none; cursor: pointer; padding: 0;
  display: grid; place-items: center; color: #fff;
  background: rgba(16,17,19,0.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background .2s, transform .25s var(--ease);
}
.vp-btn:hover { background: rgba(16,17,19,0.8); transform: translateY(-2px); }
.vp-btn svg { width: 14px; height: 14px; display: block; }

/* interactive scrubber */
.vp-scrub {
  position: absolute; left: 10px; right: 10px; bottom: 4px; height: 16px; z-index: 7;
  display: flex; align-items: center; cursor: pointer; touch-action: none;
  opacity: 0; transition: opacity .35s var(--ease);
}
.cs-reel:hover .vp-scrub, .device__screen:hover .vp-scrub, .cs-feature__companion:hover .vp-scrub,
.cs-video__frame:hover .vp-scrub, .vp-active .vp-scrub, .vp-scrub.is-on { opacity: 1; }
.device__screen .vp-scrub { left: 12px; right: 12px; bottom: 8px; }
.vp-scrub__track {
  position: relative; width: 100%; height: 3px; border-radius: 999px;
  background: rgba(255,255,255,0.25); transition: height .2s var(--ease);
}
.vp-scrub:hover .vp-scrub__track, .vp-scrubbing .vp-scrub__track { height: 5px; }
.vp-scrub__fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 999px; background: var(--pink); }
.vp-scrub__dot {
  position: absolute; top: 50%; left: 0; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px;
  border-radius: 50%; background: var(--paper-card); box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  opacity: 0; transform: scale(.6); transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.vp-scrub:hover .vp-scrub__dot, .vp-scrubbing .vp-scrub__dot { opacity: 1; transform: none; }
.vp-time {
  position: absolute; bottom: 18px; transform: translateX(-50%);
  background: rgba(16,17,19,0.75); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .64rem; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .2s var(--ease);
}
.vp-scrub:hover .vp-time, .vp-scrubbing .vp-time { opacity: 1; }
.vp-pulse__txt { font-size: .78rem; font-weight: 700; letter-spacing: .02em; }

/* caption moves up top so the bottom belongs to the controls */
.cs-reel__cap { top: 10px; bottom: auto; right: auto; max-width: calc(100% - 60px); }
.cs-feature__companion .cs-feature__companion-cap { bottom: 24px; }

.vp-pulse {
  position: absolute; top: 50%; left: 50%; z-index: 6; pointer-events: none;
  width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: rgba(16,17,19,0.5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transform: scale(.7);
}
.vp-pulse svg { width: 20px; height: 20px; }
.vp-pulse.show { animation: vp-pulse .55s var(--ease) forwards; }
@keyframes vp-pulse { 0% { opacity: .95; transform: scale(.78); } 100% { opacity: 0; transform: scale(1.18); } }

@media (hover: hover) and (pointer: fine) {
  .cs-reel { transition: transform .45s var(--ease), box-shadow .45s var(--ease); }
  .cs-reel:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
}
@media (hover: none) {
  .vp-sound, .vp-progress { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .vp-pulse.show { animation: none; opacity: 0; }
  .cs-reel:hover { transform: none; }
}

/* ---------- gallery carousel variant ---------- */
.cs-gallery.cs-gallery--carousel { grid-template-columns: none; }
.cs-gallery--carousel {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 33%);
  gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;   /* don't chain to page pan / back-swipe on Android */
  padding-bottom: 14px; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.cs-gallery--carousel > * { scroll-snap-align: start; }
.cs-gallery--carousel .ph { aspect-ratio: var(--cell-ar, 4/5); border-radius: var(--r-md); }
@media (max-width: 600px) { .cs-gallery--carousel { grid-auto-columns: 78%; } }

/* gallery cells honour the block's Instagram post ratio */
.cs-gallery .ph { aspect-ratio: var(--cell-ar, 4/5); }

/* video slides inside galleries/carousels */
.cs-gallery .ph > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cs-gallery .ph--video { background: #101113; border: none; }
.cs-gallery .ph--video .cs-reel__cap { top: 10px; bottom: auto; right: auto; max-width: calc(100% - 60px); }

/* square carousels run wider so in-image typography stays fully visible */
.cs-gallery--carousel.cs-gallery--sq { grid-auto-columns: minmax(300px, 42%); }
@media (max-width: 600px) { .cs-gallery--carousel.cs-gallery--sq { grid-auto-columns: 88%; } }
/* bias crops toward the top, where these posts carry their headlines */
.cs-gallery--sq .ph > img { object-position: center top; }

/* reel placeholder slot (striped tile in reel shape) */
.cs-reel--ph { cursor: default; box-shadow: none; }
.cs-reel--ph .ph { position: absolute; inset: 0; border-radius: 0; display: flex; align-items: center; justify-content: center; }

/* premium hover: slow zoom on gallery imagery, desktop pointers only */
.cs-gallery .ph { overflow: hidden; }
.cs-gallery .ph > img { transition: transform 1.1s var(--ease); will-change: transform; }
@media (hover: hover) and (pointer: fine) {
  .cs-gallery .ph:hover > img { transform: scale(1.045); }
}

/* editorial stagger: middle column of 3-up reel grids sits lower */
@media (min-width: 901px) {
  .cs-reels.cols-3 > :nth-child(3n+2) { margin-top: 26px; }
  .cs-reels.cols-3 > :nth-child(3n) { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-gallery .ph > img { transition: none; }
}

/* gallery column counts */
.cs-gallery.cols-2 { grid-template-columns: repeat(2,1fr); }
.cs-gallery.cols-3 { grid-template-columns: repeat(3,1fr); }
.cs-gallery.cols-4 { grid-template-columns: repeat(4,1fr); }
@media (max-width: 900px) { .cs-gallery.cols-3, .cs-gallery.cols-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 460px) { .cs-gallery.cols-2, .cs-gallery.cols-3, .cs-gallery.cols-4 { grid-template-columns: 1fr; } }

/* callouts column counts */
.cs-callouts.cols-1 { grid-template-columns: 1fr; max-width: 560px; margin-inline: auto; }
.cs-callouts.cols-2 { grid-template-columns: repeat(2,1fr); }
.cs-callouts.cols-3 { grid-template-columns: repeat(3,1fr); }
@media (max-width: 920px) { .cs-callouts.cols-3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 600px) { .cs-callouts.cols-2, .cs-callouts.cols-3 { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  .cs-gallery--carousel { scroll-snap-type: none; }
}
