.apps-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 35px 5vw 40px;
}

.apps-head {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 60px;
  align-items: end;
  margin-bottom: 80px;
}
.apps-head .illo { width: 100%; max-width: 340px; aspect-ratio: 1 / 1; }
.apps-head .meta {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  display: inline-flex; gap: 10px; align-items: center;
  margin-bottom: 22px;
}
.apps-head .meta .pin {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--riso-pink);
  box-shadow: 2px 2px 0 var(--riso-green);
}
.apps-head h1 {
  font-size: clamp(40px, 5vw, 72px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 600;
  max-width: 20ch;
  text-wrap: balance;
  margin-bottom: 18px;
}
.apps-head h1 em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  color: var(--riso-pink);
  text-shadow: 2px 1px 0 var(--riso-green);
}
.apps-head .lede {
  font-size: 18px;
  color: var(--ink-dim);
  max-width: 56ch;
  line-height: 1.55;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
}
.app-card {
  position: relative;
  background: var(--paper-white);
  padding: 28px 30px;
  border: 1.5px solid var(--ink);
  border-radius: 18px;
  display: grid;
  /* Preview leads so more of the embedded app is visible on landing.
     ~1.9:1 makes the preview roughly 50% wider than the old 1fr/1.3fr
     split; the info column is narrower but the blurbs are short. */
  grid-template-columns: 1.9fr 1fr;
  gap: 26px;
  /* Cards are <div> now; only the iframe + "open app" link are
     interactive. Default cursor avoids the misleading pointer. */
  cursor: default;
  transition: transform 0.18s, box-shadow 0.18s;
  min-height: 240px;
  box-shadow: 3px 3px 0 var(--riso-pink);
  overflow: hidden;
  color: var(--ink);
  /* Stretch so the preview fills the card height -- equal padding top
     and bottom -- rather than sitting short above the taller info col. */
  align-items: stretch;
}
.app-card::after {
  content: "";
  position: absolute; inset: 0;
  background-image: url("/img/grain.svg");
  background-repeat: repeat;
  mix-blend-mode: multiply;
  opacity: 0.3;
  pointer-events: none;
  border-radius: inherit;
}
.app-card > * { position: relative; z-index: 1; }
.app-card:hover {
  transform: translateY(-3px);
  box-shadow: 3px 3px 0 var(--riso-green), 0 14px 30px rgba(255, 126, 182, 0.18);
}
.app-card:nth-child(2n) { box-shadow: 3px 3px 0 var(--riso-green); }
.app-card:nth-child(2n):hover {
  box-shadow: 3px 3px 0 var(--riso-pink), 0 14px 30px rgba(45, 184, 118, 0.18);
}

.app-preview {
  /* No fixed aspect-ratio on desktop: the card grid stretches the
     preview to the full card height (see .app-card align-items).
     Mobile, where the card is a single column, restores a ratio
     below so the preview still has a height. */
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  display: grid; place-items: center;
  background: var(--paper);
}
/* Loading placeholder: visible until the iframe paints over it.
   Halftone dots + a "loading…" label, brand-flavoured. No JS needed
   -- the iframe naturally covers this once it renders. */
.app-preview::before {
  content: "loading…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background:
    radial-gradient(var(--riso-pink) 1px, transparent 1.6px) 0 0 / 8px 8px,
    var(--paper);
  z-index: 0;
  animation: app-loading-shimmer 1.4s ease-in-out infinite;
}
@keyframes app-loading-shimmer {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.85; }
}
@media (prefers-reduced-motion: reduce) {
  .app-preview::before { animation: none; opacity: 0.6; }
}
/* Iframe + corner controls sit above the loading placeholder. The
   ::before is z-index 0 and the iframe was already absolute -- just
   bumping its z-index covers the placeholder once it paints. */
.app-preview iframe { z-index: 1; }
.app-preview iframe {
  /* Render the embedded site at 1.5x logical size, then scale 0.66x via
     transform. Net: same on-screen size but 1.5x content density, so the
     preview shows more of the app's UI in a small card. */
  position: absolute;
  inset: 0;
  width: 150%;
  height: 150%;
  border: 0;
  background: var(--paper-white);
  transform: scale(0.667);
  transform-origin: top left;
}
.app-preview .frame-open,
.app-preview .frame-zoom {
  /* Small corner buttons over the preview -- the iframe captures clicks
     otherwise. frame-open launches a new tab; frame-zoom enlarges in-page. */
  position: absolute;
  top: 8px;
  z-index: 2;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--paper-white);
  border: 1.5px solid var(--ink);
  display: grid; place-items: center;
  font-size: 13px;
  color: var(--ink);
  box-shadow: 1.5px 1.5px 0 var(--riso-pink);
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.app-preview .frame-open { right: 8px; }
.app-preview .frame-zoom { right: 44px; font-size: 15px; line-height: 1; }

/* Transparent overlay so clicking anywhere on the preview enlarges it.
   The corner buttons (z-index: 2) sit above this and stay clickable.
   Inside the lightbox the iframe is interactive -- no overlay there. */
.app-preview .frame-click {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: zoom-in;
}
.app-preview .frame-open:hover,
.app-preview .frame-zoom:hover {
  transform: translateY(-1px);
  box-shadow: 1.5px 1.5px 0 var(--riso-green);
}

/* In-place expansion: the card itself jumps to position: fixed and
   grows to fill most of the viewport. The iframe gets large and stays
   interactive (the .frame-click overlay is hidden in this state). */
.app-card-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(20, 30, 25, 0.72);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
body.app-card-open .app-card-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.app-card.is-expanded {
  position: fixed;
  /* Top offset clears the sticky .topbar (z:150, ~60px tall) so the
     header stays visible above the expanded card. */
  top: 76px;
  bottom: 4vh;
  left: 4vw;
  right: 4vw;
  width: auto;
  max-width: 1200px;
  max-height: calc(100vh - 100px);
  margin: 0 auto;
  z-index: 100;
  grid-template-columns: 1.6fr 1fr;
  gap: 32px;
  padding: 32px 36px;
  box-shadow: 6px 6px 0 var(--riso-pink), 0 30px 60px rgba(0, 0, 0, 0.35);
  overflow: auto;
}
@media (max-width: 540px) {
  .app-card.is-expanded { top: 60px; padding: 18px 20px; }
}
/* Drop the riso grain on the expanded card -- multiply blend at full
   size washes the embedded app out. Small cards keep their texture. */
.app-card.is-expanded::after { display: none; }
.app-card.is-expanded:hover { transform: none; }
.app-card.is-expanded .app-preview {
  aspect-ratio: auto;
  height: 100%;
  min-height: 60vh;
}
.app-card.is-expanded .app-preview iframe {
  /* In the expanded view show the embedded app at 1:1 -- we have the
     room and the user wants to actually use it. */
  width: 100%;
  height: 100%;
  transform: none;
}
.app-card.is-expanded .frame-click {
  display: none;
}
.app-card .card-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--paper-white);
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: none;
  place-items: center;
  box-shadow: 2px 2px 0 var(--riso-green);
  z-index: 3;
  padding: 0;
  font-family: inherit;
}
.app-card.is-expanded .card-close { display: grid; }
.app-card .card-close:hover { box-shadow: 2px 2px 0 var(--riso-pink); }
body.app-card-open { overflow: hidden; }
/* Suppress the page-wide riso grain (main::after) while a card is
   expanded -- it's a multiply-blend overlay that washes the embed. */
body.app-card-open main::after { display: none; }

.app-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}
.app-info .stack {
  display: flex; gap: 6px; flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
}
.app-info .stack span {
  padding: 3px 9px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  color: var(--ink-dim);
  background: var(--paper);
}
.app-info h3 {
  font-size: 24px; font-weight: 600; letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
}
.app-info p {
  color: var(--ink-dim);
  font-size: 14.5px;
  line-height: 1.55;
  flex: 1;
}
.app-info .open {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--riso-pink);
  text-shadow: 1px 0.5px 0 var(--riso-green);
  font-weight: 500;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  align-self: flex-start;
}
.app-card:hover .open .arr { transform: translateX(3px); }
.open .arr { transition: transform 0.2s; }

@media (max-width: 900px) {
  .apps-head { grid-template-columns: 1fr; gap: 32px; margin-bottom: 60px; }
  .apps-head .illo { max-width: 240px; }
  .app-grid { grid-template-columns: 1fr; }
  .app-card { grid-template-columns: 1fr; gap: 20px; }
  /* Single-column card: the preview no longer stretches to a sibling,
     so give it back an explicit ratio. */
  .app-preview { aspect-ratio: 4 / 3; }
}

@media (max-width: 540px) {
  .apps-page { padding: 36px 5vw 30px; }
  .apps-head { gap: 20px; margin-bottom: 40px; }
  .apps-head .illo { max-width: 180px; }
  .apps-head h1 { font-size: clamp(28px, 8vw, 40px); }
  .apps-head .lede { font-size: 15px; }
  .app-card { padding: 20px 22px; gap: 16px; min-height: 0; }
  .app-info h3 { font-size: 20px; }
  .app-info p { font-size: 14px; }
  .app-preview { aspect-ratio: 16 / 9; }
  .app-grid { gap: 14px; }
}
