/* =========================================================
   Project card → case study (hover preview + click to open)
   ========================================================= */
.media-case { background: #2f6f7a; } /* the game's river colour */
.media-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .8s var(--ease), filter .5s;
}
.media-case:hover .media-img { transform: scale(1.06); filter: brightness(.8); }
.case-cta {
  position: relative;
  padding: 10px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1.5px solid var(--ink);
  font-weight: 600;
  font-size: 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .35s, transform .5s var(--ease);
}
.case-cta span { display: inline-block; transition: transform .4s var(--ease); }
.media-case:hover .case-cta,
.media-case:focus-visible .case-cta { opacity: 1; transform: none; }
.media-case:hover .case-cta span { transform: translateX(4px); }
.peek {
  position: absolute;
  right: 6%; bottom: -40%;
  width: 22%;
  transition: bottom .6s var(--ease);
  pointer-events: none;
}
.media-case:hover .peek { bottom: -4%; }
/* touch screens have no hover: always show the call-to-action */
@media (hover: none) {
  .case-cta { opacity: 1; transform: none; }
}

.text-link {
  margin-top: 18px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-weight: 600;
  border-bottom: 2px solid var(--blue);
  transition: border-color .3s;
}
.text-link span { display: inline-block; transition: transform .4s var(--ease); }
.text-link:hover { border-color: var(--ink); }
.text-link:hover span { transform: translateX(4px); }

/* =========================================================
   Case study dialog
   ========================================================= */
html.case-open { overflow: hidden; }

.case {
  width: 100%; height: 100%;
  max-width: 100%; max-height: 100%;
  margin: 0; padding: 0; border: 0;
  background: var(--bg);
  color: var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.case::backdrop { background: rgba(10, 12, 16, .4); }
/* fallback entrance when View Transitions aren't supported */
.case[open].no-vt { animation: caseIn .55s var(--ease); }
@keyframes caseIn { from { opacity: 0; transform: translateY(40px); } }

::view-transition-group(case-hero) { animation-duration: .6s; animation-timing-function: cubic-bezier(.22, 1, .36, 1); }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: .4s; }

.case-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  height: 58px;
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.case-read {
  position: absolute; left: 0; bottom: -1px;
  height: 3px; width: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(var(--read, 0));
}
.case-nav { display: flex; gap: 20px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.case-nav button {
  flex: none;
  padding: 4px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: color .3s, border-color .3s;
}
.case-nav button:hover,
.case-nav button.active { color: var(--ink); border-bottom-color: var(--accent); }
.case-close {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--surface);
  font-size: 22px; line-height: 1;
  cursor: pointer;
  transition: transform .4s var(--ease), background .3s, color .3s;
}
.case-close:hover { transform: rotate(90deg); background: var(--ink); color: var(--bg); }

.case-body {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 72px) var(--gutter) clamp(64px, 10vw, 120px);
}

.eyebrow {
  margin: 0 0 10px;
  font-family: var(--font-hand);
  font-size: 22px;
  color: var(--accent-ink);
}
.case-title {
  margin: 0 0 18px;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: clamp(56px, 9.5vw, 112px);
  line-height: 1;
  color: var(--accent);
  text-shadow: 3px 3px 0 var(--shadow-ink, transparent);
}
.lede { margin: 0 0 32px; font-size: clamp(18px, 2vw, 22px); max-width: 46ch; color: var(--ink); }
.case-meta { margin: 16px 0 0; font-size: 14px; color: var(--muted); }
.case-hero-img {
  width: 100%;
  border-radius: var(--radius);
  border: var(--frame);
  view-transition-name: case-hero;
}
.case-sec { margin-top: clamp(64px, 10vw, 110px); scroll-margin-top: 76px; }
.case-sec > h3 {
  margin: 0 0 18px;
  font-family: var(--font-display); /* Newsreader */
  font-weight: 700;
  font-size: clamp(26px, 3.4vw, 38px);
  line-height: 1.2;
  max-width: 30ch;
  color: var(--accent-ink);
}
.case-sec > p { max-width: 65ch; }
.case h4 { margin: 0 0 8px; font-family: var(--font-display); font-size: 19px; }

.cards3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 28px 0;
}
.pcard { padding-top: 14px; border-top: 2px solid var(--accent); }
.pcard p { margin: 0; color: var(--muted); font-size: .95em; }

.goal {
  margin: 0;
  padding: 24px 28px;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
  font-size: clamp(17px, 1.8vw, 20px);
}
.goal span { display: block; font-family: var(--font-hand); font-size: 22px; color: var(--accent-ink); }

/* CPT → game mapping */
.map {
  margin: 28px 0 40px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.map-row {
  display: grid;
  grid-template-columns: 1fr 40px 1.3fr;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
.map-head {
  border-top: 0;
  background: var(--deep);
  color: #fff;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.map-row > span:first-child { color: var(--muted); }
.map-head > span:first-child { color: #fff; }
.map-row:not(.map-head) > span:last-child { font-weight: 500; }
.map-row i { font-style: normal; color: var(--accent-ink); text-align: center; font-weight: 700; }
.map-row img { display: inline-block; height: 28px; width: auto; vertical-align: middle; margin: 0 2px; }
@media (max-width: 600px) {
  .map-row { grid-template-columns: 1fr; gap: 2px; }
  .map-row i { display: none; }
  .map-head span:last-child { display: none; }
}

.split {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
}
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }

.ticks { list-style: none; padding: 0; margin: 0; }
.ticks li { position: relative; padding-left: 28px; margin-bottom: 12px; }
.ticks li::before {
  content: "";
  position: absolute; left: 4px; top: .55em;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
kbd {
  display: inline-block;
  padding: 1px 7px;
  border: 1.5px solid var(--ink);
  border-bottom-width: 3px;
  border-radius: 6px;
  font: 600 12px var(--font-body);
  background: var(--surface);
}

.shot { margin: 0; }
.shot img {
  width: 100%;
  border-radius: var(--radius);
  border: var(--frame);
}
.shot figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); }

.gallery .shot img { aspect-ratio: 769 / 434; object-fit: cover; }
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 32px;
}

/* ---------- Real game (Unity WebGL in an iframe), at the top of the case study ---------- */
.game {
  border: var(--frame);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.game-cover,
.game-frame {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9; /* the game's UI is laid out for 16:9 */
  border: 0;
}
.game-frame { background: var(--river); }
.game-cover {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 16px;
  text-align: center;
  color: #fff;
}
.game-cover[hidden], .game-bar[hidden] { display: none; }
/* the screenshot fills the cover; it is also the hero image the project card morphs into */
.game .game-poster {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  border: 0;
  border-radius: 0;
  filter: brightness(.62);
  z-index: 0;
}
.game-cover > :not(.game-poster) { position: relative; z-index: 1; }
.game-play { padding: 0; border: 0; background: none; cursor: pointer; }
.game-play .play { width: 76px; height: 76px; }
.game-play:hover .play { transform: scale(1.1); background: var(--ink); }
.game-play:hover .play::before { border-left-color: var(--bg); }
.game-label { margin: 0; font-weight: 700; font-size: 18px; text-shadow: 0 1px 8px rgba(0, 0, 0, .4); }
.game-note { margin: 0; font-size: 13px; opacity: .9; }
.game-note.game-warn { max-width: 52ch; opacity: 1; line-height: 1.5; }
.game-touch { display: none; margin: 0; max-width: 40ch; }
/* phones and tablets: no keyboard, so point to the demo instead */
@media (hover: none) and (pointer: coarse) {
  .game-play, .game-note { display: none; }
  .game-touch { display: block; }
}
.game-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 10px 14px;
  border-top: var(--frame);
  font-size: 13px;
  color: var(--muted);
}
.game-actions { display: flex; gap: 8px; }
.game-btn {
  padding: 6px 14px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .3s, color .3s;
}
.game-btn:hover { background: var(--ink); color: var(--bg); }

/* ---------- Correlation tabs ---------- */
.corr {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 28px 0 16px;
}
@media (max-width: 600px) { .corr { grid-template-columns: 1fr; } }
.corr-tab {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 8px;
  padding: 16px 18px;
  text-align: left;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .3s, transform .4s var(--ease), box-shadow .4s;
}
.corr-tab:hover { transform: translateY(-3px); }
.corr-tab[aria-selected="true"] { border-color: var(--ink); box-shadow: 0 4px 0 var(--ink); }
.corr-tab span { font-weight: 600; }
.corr-tab b { font-family: var(--font-display); font-size: 26px; grid-row: span 2; align-self: center; }
.corr-tab em { font-style: normal; font-size: 13px; color: var(--muted); }
/* −1 … 0 … +1 meter */
.meter {
  grid-column: 1 / -1;
  position: relative;
  height: 6px;
  margin-top: 10px;
  border-radius: 6px;
  background: var(--line);
}
.meter::before {
  content: "";
  position: absolute; left: 50%; top: -3px; bottom: -3px;
  width: 1.5px; background: var(--muted);
}
.meter::after {
  content: "";
  position: absolute; top: 0; bottom: 0;
  border-radius: 6px;
  background: var(--accent);
  left: calc(50% + min(var(--r), 0) * 50%);
  width: calc(max(var(--r), var(--r) * -1) * 50%);
  transform-origin: var(--origin, left);
  transform: scaleX(0);
  transition: transform 1s var(--ease);
}
.corr.in .meter::after { transform: scaleX(1); }
.corr-tab:nth-child(3) .meter { --origin: right; }

.corr-panel {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  align-items: center;
}
@media (max-width: 760px) { .corr-panel { grid-template-columns: 1fr; } }
.corr-img { width: 100%; border: var(--frame); border-radius: var(--radius); background: #fff; transition: opacity .3s; }
.corr-text { margin: 0; transition: opacity .3s; }
.corr-panel.swap .corr-img,
.corr-panel.swap .corr-text { opacity: 0; }

.takeaway { margin: 24px 0 0; max-width: 65ch; }

.tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}
.tools figure { margin: 0; }
.tools img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  border: var(--frame);
}
.tools figcaption { margin-top: 10px; font-size: 14px; color: var(--muted); }
.tools figcaption b { display: block; color: var(--ink); font-size: 15px; }

.learned {
  margin-top: 40px;
  padding: 24px 28px;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
}
.learned .ticks { margin-top: 12px; }
.learned .ticks li:last-child { margin-bottom: 0; }

/* note above preliminary results */
.case-sec > .note-prelim {
  max-width: none; /* spans the full width, like the charts under it */
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 14px;
}

/* charts and diagrams: show the whole image, never crop */
.gallery.charts { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); } /* two columns, so charts stay readable */
/* every chart gets the same 3:2 box; each one is fitted inside on white, never cropped or stretched */
.gallery.charts .shot img { aspect-ratio: 3 / 2; object-fit: contain; padding: 10px; background: #fff; }
.shot-wide { margin: 28px 0; }
.shot-wide img { background: #fff; }

/* project card with a wide figure: keeps the figure's own shape */
.media-wide { aspect-ratio: auto; background: #fff; }
.media-wide .media-img { position: static; width: 100%; height: auto; }
.media-wide .case-cta { position: absolute; left: 50%; top: 50%; translate: -50% -50%; }

.case-back {
  margin-top: 48px;
  padding: 12px 24px;
  border-radius: var(--radius);
  border: 1.5px solid var(--ink);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
  transition: background .3s, color .3s;
}
.case-back:hover { background: var(--ink); color: var(--bg); }
