/* ============================================================
   CASES
   Three layouts share the same markup:
   - default (no JS / reduced motion): stacked cards, a static quarter in every notch
   - html.cases-pin:   sticky stage, wheel scroll drives a horizontal track
   - html.cases-swipe: horizontal scroll-snap track (touch / narrow screens)
   ============================================================ */

.cases {
  --r: 48px;          /* notch radius = quarter size (same radius as the logo bite) */
  --card-w: min(84vw, 560px);
  --card-h: min(560px, calc(100svh - 200px));
  position: relative;
  background: var(--carbon);
  padding: clamp(72px, 12vh, 140px) var(--gutter);
}

.cases__head {
  margin-bottom: clamp(28px, 5vh, 56px);
}

.cases__lead {
  max-width: 36rem;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: var(--fs-lead);
}

.cases__title {
  margin: 0;
  max-width: 16em;
  font-size: clamp(1.9rem, 4.2vw, 3.6rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.ruler,
.cases__cross {
  display: none;
}

.cases__track {
  display: grid;
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------- Card ---------- */
.case {
  --accent: var(--vermilion);
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto auto 1fr auto;
  width: 100%;
  max-width: var(--card-w);
  min-height: var(--card-h);
  padding: 26px 30px 0;
  border-radius: 22px;
  /* Circular notch in the bottom-left corner: the quarter circle is the piece that fits in it.
     Drawn as a transparent hole in the background so children (the quarter) are not clipped. */
  background: radial-gradient(circle at 0 100%, transparent calc(var(--r) - 0.5px), var(--card-bg) var(--r));
}

.case--carbon { --card-bg: var(--carbon-2); color: var(--marfil); }
.case--marfil { --card-bg: var(--marfil); color: var(--carbon); --accent-text: var(--carbon); }
.case--vermilion { --card-bg: var(--vermilion); color: var(--carbon); --accent: var(--carbon); }

.case__num {
  grid-row: 1;
  font-size: var(--fs-small);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--accent-text, var(--accent));
}

.case__client {
  grid-row: 1;
  justify-self: end;
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.62;
}

.case__name {
  grid-row: 2;
  grid-column: 1 / -1;
  margin: 10px 0 0;
  font-size: clamp(1.6rem, 2.6vw, 2.15rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.case > .ui {
  grid-row: 3;
  grid-column: 1 / -1;
  margin: 18px 0 20px;
}

.case__ba {
  grid-row: 4;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 0;
  align-content: start;
}

.case__ba > div { margin: 0; }

.case__ba dt {
  margin-bottom: 4px;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.55;
}

.case__ba dd {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.case__before dd {
  opacity: 0.55;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: currentColor;
  transition: text-decoration-color 0.5s var(--ease) 0.4s;
}

.case__after dd { font-weight: 600; }

.case__how {
  grid-row: 5;
  grid-column: 1 / -1;
  align-self: start;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, currentColor 16%, transparent);
  font-size: 0.8125rem;
  line-height: 1.45;
  opacity: 0.82;
}

.case__how strong {
  font-weight: 800;
}

.case__tag {
  grid-row: 6;
  grid-column: 1 / -1;
  justify-self: end;
  align-self: center;
  padding: 14px 0 18px;
  font-size: var(--fs-small);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-text, var(--accent));
}

/* The notch itself: the quarter flies here when the card becomes active. */
.case__slot {
  position: absolute;
  left: 0;
  bottom: 0;
  width: var(--r);
  height: var(--r);
}

/* Default layout: every notch shows a static quarter. */
html:not(.cases-live) .case__slot::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--vermilion);
  border-top-right-radius: 100%;
}

/* ---------- Mini UIs (fictional data, drawn in CSS) ---------- */
.ui {
  --ui-line: color-mix(in srgb, currentColor 16%, transparent);
  min-height: 118px;
  font-size: 0.8125rem;
}

.ui span,
.ui em { font-style: normal; }

.ui b { display: block; position: relative; height: 8px; border-radius: 99px; background: var(--ui-line); font-weight: 400; }
.ui b > i { position: absolute; top: 0; bottom: 0; left: var(--x, 0); width: var(--w, 50%); border-radius: 99px; background: var(--accent); transform-origin: 0 50%; }

.ui--planner,
.ui--pay { display: grid; gap: 11px; align-content: center; }
.ui__row { display: grid; grid-template-columns: 7.6em 1fr; align-items: center; gap: 12px; }

.ui--invoice { display: grid; gap: 7px; align-content: center; }
.ui__line,
.ui__total { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--ui-line); }
.ui__total { align-items: center; border-bottom: 0; font-weight: 800; }
.ui__total em { margin-left: auto; }

.ui__chip {
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--carbon);
  font-style: normal;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.case--vermilion .ui__chip { color: var(--marfil); }

.ui--shots {
  position: relative;
  height: 150px;
  min-height: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #0b0e14;
  box-shadow: inset 0 0 0 1px var(--ui-line);
}

.ui--shots img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left top;
  opacity: 0;
  transform: scale(1.14);
  will-change: transform;
}

.ui--shots img:first-of-type { opacity: 1; }

.ui--shots-center img { object-position: center top; }

.ui__demo {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgb(17 19 24 / 0.78);
  color: var(--marfil);
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

html.cases-live .case.is-active .ui--shots img { animation: shot-cycle 12s linear infinite; }
html.cases-live .case.is-active .ui--shots img:nth-of-type(2) { animation-delay: 3s; }
html.cases-live .case.is-active .ui--shots img:nth-of-type(3) { animation-delay: 6s; }
html.cases-live .case.is-active .ui--shots img:nth-of-type(4) { animation-delay: 9s; }

@keyframes shot-cycle {
  0% { opacity: 0; }
  4% { opacity: 1; }
  24% { opacity: 1; }
  28% { opacity: 0; }
  100% { opacity: 0; }
}

.case__link {
  grid-row: 6;
  grid-column: 1;
  justify-self: start;
  align-self: center;
  margin-left: calc(var(--r) + 10px);
  padding: 14px 0 18px;
  color: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}

.case__link:hover { color: var(--accent-text, var(--accent)); }

.ui--store { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ui__tile { display: grid; grid-template-rows: 1fr auto; gap: 6px; min-height: 96px; }
.ui__tile s { border-radius: 10px; background: color-mix(in srgb, currentColor 14%, transparent); }
.ui__tile span { height: 8px; width: 60%; border-radius: 99px; background: var(--accent); }

.ui--recon { display: grid; gap: 9px; align-content: center; }
.ui__rec { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 10px; }
.ui__dot { display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 3px var(--marfil); }
.ui__rec--flag .ui__dot { background: transparent; box-shadow: inset 0 0 0 2px var(--accent); }
.ui__rec--flag em { color: inherit; font-weight: 800; }

.ui__payhead { display: flex; justify-content: space-between; font-weight: 800; }
.ui__pay { display: grid; grid-template-columns: 6.6em 1fr auto; align-items: center; gap: 12px; }
.ui__pay b > i { left: 0; }

.ui--chart { display: flex; align-items: flex-end; gap: 10px; height: 118px; }
.ui--chart > i { flex: 1; height: var(--h); border-radius: 6px 6px 0 0; background: var(--accent); transform-origin: 50% 100%; }

.ui--chat { display: flex; flex-direction: column; justify-content: center; gap: 5px; min-height: 124px; font-size: 0.75rem; }
.ui__bubble { max-width: 80%; padding: 6px 11px; border-radius: 14px 14px 14px 4px; background: color-mix(in srgb, currentColor 10%, transparent); line-height: 1.3; }
.ui__bubble--out { align-self: flex-end; display: flex; align-items: center; gap: 3px; border-radius: 14px 14px 4px 14px; background: var(--accent); color: var(--carbon); font-weight: 600; }
.ui__bubble .ui__chip { margin-left: 6px; }
.ui__wave { display: block; width: 3px; height: 10px; border-radius: 2px; background: currentColor; }
.ui__wave:nth-child(2n) { height: 15px; }
.ui__wave:nth-child(3n) { height: 6px; }
.ui__wave:nth-child(5n) { height: 18px; }
.ui__bubble--out > span { margin-left: 6px; font-weight: 800; }

/* Initial "not yet done" state, only in live layouts; final state is the default. */
html.cases-live .case:not(.is-active) .u-fade { opacity: 0; transform: translateY(8px); }
html.cases-live .case:not(.is-active) .u-x { transform: scaleX(0); }
html.cases-live .case:not(.is-active) .u-y { transform: scaleY(0); }
html.cases-live .case:not(.is-active) .u-pop { opacity: 0; transform: scale(0.6); }
html.cases-live .case:not(.is-active) .case__before dd { text-decoration-color: transparent; }

html.cases-live .case.is-active .u-fade { animation: u-fade 0.55s var(--ease) var(--d, 0s) both; }
html.cases-live .case.is-active .u-x { animation: u-x 0.9s var(--ease) calc(var(--d, 0s) + 0.15s) both; }
html.cases-live .case.is-active .u-y { animation: u-y 0.9s var(--ease) var(--d, 0s) both; }
html.cases-live .case.is-active .u-pop { animation: u-pop 0.45s var(--ease) calc(var(--d, 0s) + 0.5s) both; }

.ui > :nth-child(1) { --d: 0.05s; }
.ui > :nth-child(2) { --d: 0.17s; }
.ui > :nth-child(3) { --d: 0.29s; }
.ui > :nth-child(4) { --d: 0.41s; }
.ui > :nth-child(5) { --d: 0.53s; }
.ui > :nth-child(6) { --d: 0.65s; }

@keyframes u-fade { from { opacity: 0; transform: translateY(8px); } }
@keyframes u-x { from { transform: scaleX(0); } }
@keyframes u-y { from { transform: scaleY(0); } }
@keyframes u-pop { from { opacity: 0; transform: scale(0.6); } }

.case.is-pulse { animation: case-pulse 1.1s var(--ease); }
@keyframes case-pulse { 40% { translate: 0 -10px; } }

/* ---------- Pin layout (desktop, fine pointer, motion allowed) ---------- */
html.cases-pin .cases {
  padding: 0;
  /* height is set from JS: travel distance + one viewport + a short dwell */
}

html.cases-pin .cases__pin {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto 1fr;
  padding: clamp(28px, 6vh, 64px) 0 clamp(20px, 4vh, 40px);
}

html.cases-pin .cases__head {
  margin: 0;
  padding-inline: var(--gutter);
}

html.cases-pin .cases__title { font-size: clamp(1.5rem, 2.6vw, 2.4rem); }

html.cases-pin .cases__lead { display: none; font-size: 0.95rem; margin-top: 8px; }

@media (min-height: 800px) {
  html.cases-pin .cases__lead { display: block; }
}

/* Short viewports: keep the card readable by dropping the longest line. */
@media (max-height: 800px) {
  html.cases-pin .case__how { display: none; }
}

html.cases-pin .ruler {
  display: block;
  position: relative;
  width: min(520px, 60vw);
  height: 30px;
  margin: 18px 0 0 var(--gutter);
}

.ruler__ticks {
  position: absolute;
  inset: 8px 0 8px 0;
  background: repeating-linear-gradient(90deg, var(--muted) 0 1px, transparent 1px 10px);
  opacity: 0.55;
}

.ruler__win {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: calc(var(--p, 0) * (100% - 52px));
  width: 52px;
  border: 1.5px solid var(--vermilion);
  border-radius: 4px;
}

html.cases-pin .cases__viewport {
  position: relative;
  display: flex;
  align-items: center;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

html.cases-pin .cases__viewport.is-dragging {
  cursor: grabbing;
}

html.cases-pin .cases__viewport.is-dragging .case {
  pointer-events: none;
}

html.cases-pin .cases__track {
  display: flex;
  gap: 40px;
  padding-inline: calc(50vw - var(--card-w) / 2);
  will-change: transform;
}

html.cases-pin .case {
  flex: none;
  width: var(--card-w);
  contain: layout style;
}

html.cases-pin .cases__cross {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  pointer-events: none;
  z-index: 3;
  mix-blend-mode: difference;
}

.cases__cross::before,
.cases__cross::after {
  content: "";
  position: absolute;
  background: #fff;
}
.cases__cross::before { left: 10px; top: 0; width: 2px; height: 22px; }
.cases__cross::after { top: 10px; left: 0; height: 2px; width: 22px; }

/* ---------- Swipe layout ---------- */
html.cases-swipe .cases { padding-inline: 0; }
html.cases-swipe .cases__head { padding-inline: var(--gutter); }

html.cases-swipe .ruler {
  display: block;
  position: relative;
  height: 30px;
  margin: 0 var(--gutter) 18px;
}

html.cases-swipe .cases__track {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 4px var(--gutter) 24px;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
}

html.cases-swipe .cases__track::-webkit-scrollbar { display: none; }

html.cases-swipe .case {
  flex: none;
  width: var(--card-w);
  scroll-snap-align: center;
  transition: opacity 0.4s var(--ease), scale 0.4s var(--ease);
}

html.cases-swipe .case:not(.is-active) { opacity: 0.55; scale: 0.96; }

/* The quarter, once it lives in a slot, fills it exactly. */
.case__slot .quarter {
  width: 100%;
  height: 100%;
  margin: 0;
  translate: none;
}

@media (max-width: 560px) {
  .cases { --r: 40px; }
  .case { padding: 22px 22px 0; }
  .case__ba { grid-template-columns: 1fr; gap: 12px; }
  .ui--store .ui__tile { min-height: 72px; }
}
