/* =============================================================
   Context Grammar — Vivid Moments Gallery
   =============================================================
   Ten moments. Each one a Without/With comparison.
   Reuses canonical site device frames (iphone15pro, samfh, etc.)
   and embeds existing UI screens via iframe with ?noframe=1.
   ============================================================= */

:root {
  --gallery-max: 1180px;
  --gallery-narrow: 880px;
  --gallery-warm: #f7f4ee;
  --gallery-ink: #08070b;
  --gallery-paper: #fafafa;
  --gallery-accent: #6889b4;
  --gallery-warm-accent: #b88a4a;
}

.gallery-page {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-top: 56px; /* nav clearance */
  font-family: var(--font-sans);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ─── HERO ─────────────────────────────────────────────────── */
.gallery-hero {
  padding: clamp(72px, 9vw, 120px) clamp(24px, 4vw, 48px) clamp(56px, 7vw, 88px);
  background: var(--gallery-ink);
  color: #f0ece4;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.gallery-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 50% 50% at 30% 20%, rgba(104, 137, 180, 0.16), transparent 65%),
    radial-gradient(ellipse 40% 40% at 75% 75%, rgba(184, 138, 74, 0.08), transparent 65%);
  pointer-events: none;
}
.gallery-hero__inner {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
}
.gallery-hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(240, 236, 228, 0.55);
  margin: 0 0 24px;
}
.gallery-hero__title {
  font-weight: 500;
  font-size: clamp(30px, 4.4vw, 56px);
  line-height: 1.1;
  letter-spacing: -1.8px;
  margin: 0 0 24px;
}
.gallery-hero__title em {
  font-style: italic;
  font-weight: 400;
  color: rgba(240, 236, 228, 0.75);
}
.gallery-hero__sub {
  font-size: clamp(15px, 1.15vw, 17px);
  line-height: 1.75;
  color: rgba(240, 236, 228, 0.75);
  margin: 0 0 32px;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
.gallery-hero__meta {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(240, 236, 228, 0.55);
}
.gallery-hero__meta a {
  color: #f0ece4;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.gallery-hero__meta a:hover { color: #fff; }

/* ─── MOMENTS GRID ─────────────────────────────────────────── */
.moments {
  background: var(--bg);
}

.moment {
  padding: clamp(56px, 7vw, 96px) clamp(20px, 4vw, 48px);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.moment:last-of-type { border-bottom: none; }

/* Feature moments get a warm sand background (the "blur fix" + "intent test") */
.moment--feature {
  background: var(--gallery-warm);
  color: var(--gallery-ink);
}

/* Moment heading — large numbered title */
.moment__head {
  max-width: var(--gallery-max);
  margin: 0 auto clamp(28px, 3.5vw, 40px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px 24px;
  align-items: baseline;
}
.moment__num {
  font-family: var(--font-mono);
  font-size: clamp(28px, 3.4vw, 44px);
  font-weight: 500;
  letter-spacing: -0.5px;
  color: var(--text-3);
}
.moment--feature .moment__num { color: var(--gallery-warm-accent); }
.moment__title-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.moment__title {
  font-weight: 500;
  font-size: clamp(22px, 2.8vw, 36px);
  line-height: 1.2;
  letter-spacing: -1px;
  margin: 0;
  color: var(--text);
}
.moment--feature .moment__title { color: var(--gallery-ink); }
.moment__title em { font-style: italic; font-weight: 400; }
.moment__where {
  font-family: var(--font-mono);
  font-size: clamp(11px, 0.85vw, 13px);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0;
}
.moment--feature .moment__where { color: rgba(8, 7, 11, 0.55); }
.moment__chip {
  align-self: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
  padding: 5px 10px;
  background: var(--gallery-warm-accent);
  color: #fff;
}
@media (max-width: 768px) {
  .moment__head {
    grid-template-columns: 1fr;
  }
  .moment__chip { justify-self: flex-start; }
}

/* Compare panel — Without / With side by side */
.moment__compare {
  max-width: var(--gallery-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: clamp(20px, 3vw, 40px);
  align-items: stretch;
}
@media (max-width: 880px) {
  .moment__compare { grid-template-columns: 1fr; }
}

/* Visual vocabulary lifted from _Brainstorming/p3-interactive-demo:
   - Without (low confidence — generic AI guessing without context) = dashed border
   - With (high confidence — context-aware AI) = solid accent border
   The border treatment carries meaning, not just decoration. */
.moment__without,
.moment__with {
  padding: clamp(20px, 2.5vw, 32px);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.moment__without {
  border: 1.5px dashed rgba(115, 115, 115, 0.4);
  background: var(--bg-2);
  position: relative;
}
.moment--feature .moment__without {
  background: rgba(255, 255, 255, 0.45);
  border-color: rgba(0, 0, 0, 0.18);
}
.moment__with {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-left-width: 3px;
  border-left-color: var(--gallery-accent);
}
.moment--feature .moment__with {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.1);
  border-left-color: var(--gallery-warm-accent);
}

.moment__panel-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0;
}
.moment__without .moment__panel-label::before {
  content: '✗ ';
  color: var(--text-3);
  margin-right: 2px;
}
.moment__with .moment__panel-label {
  color: var(--gallery-accent);
}
.moment__with .moment__panel-label::before {
  content: '✓ ';
  margin-right: 2px;
}
.moment--feature .moment__with .moment__panel-label { color: var(--gallery-warm-accent); }

.moment__panel-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-2);
  margin: 0;
}
.moment--feature .moment__panel-body { color: rgba(8, 7, 11, 0.78); }

/* Device area inside .moment__with */
.moment__device {
  margin: 8px 0 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 360px;
  padding: 16px 12px;
  background: var(--bg-2);
  border: 1px dashed var(--border);
}
.moment--feature .moment__device {
  background: rgba(255, 255, 255, 0.4);
  border-color: rgba(0, 0, 0, 0.1);
}
.moment__device > * {
  max-width: 100%;
}

/* iPhone size override for our gallery (slightly larger than the default --md) */
.moment__device .iphone15pro--md {
  --iphone-w: 240px;
}
@media (max-width: 600px) {
  .moment__device .iphone15pro--md { --iphone-w: 200px; }
}

/* Custom Nest hub frame for guest scene */
.moment__nest-frame {
  width: min(420px, 100%);
  aspect-ratio: 5 / 3;
  background: #1a1a1a;
  padding: 12px;
  border-radius: 14px;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 24px 48px -20px rgba(0,0,0,0.22);
}
.moment__nest-frame::after {
  content: '';
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 14px;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
  border-radius: 0 0 8px 8px;
}
.moment__nest-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 6px;
  background: #fafafa;
  display: block;
}

/* TV frame for family dinner */
.moment__tv-frame {
  width: min(560px, 100%);
  aspect-ratio: 16 / 9;
  background: #0a0a0a;
  padding: 8px;
  border-radius: 6px;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 24px 48px -20px rgba(0,0,0,0.22);
}
.moment__tv-frame::before {
  content: '';
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 16px;
  background: #1a1a1a;
}
.moment__tv-frame::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 4px;
  background: #1a1a1a;
  border-radius: 2px;
}
.moment__tv-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fafafa;
  display: block;
}

/* Fridge frame */
.moment__fridge-frame {
  width: min(380px, 100%);
  aspect-ratio: 9 / 16;
  background: #1a1a1a;
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 24px 48px -20px rgba(0,0,0,0.22);
}
.moment__fridge-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fafafa;
  display: block;
}

/* iPhone iframe styling — fill the screen area */
.iphone15pro__screen iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  display: block;
}

.moment__device-caption {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-2);
  margin: 8px 0 0;
}
.moment--feature .moment__device-caption { color: rgba(8, 7, 11, 0.8); }
.moment__device-caption strong {
  font-weight: 600;
  color: var(--text);
}
.moment--feature .moment__device-caption strong { color: var(--gallery-ink); }
.moment__device-caption em { font-style: italic; }

/* Foot — tokens + takeaway */
.moment__foot {
  max-width: var(--gallery-max);
  margin: clamp(28px, 3.5vw, 40px) auto 0;
  padding-top: clamp(20px, 2.4vw, 28px);
  border-top: 1px solid var(--border);
}
.moment--feature .moment__foot { border-top-color: rgba(0, 0, 0, 0.1); }

.moment__why-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 14px;
}
.moment--feature .moment__why-label { color: rgba(8, 7, 11, 0.55); }

.moment__tokens {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.moment__tokens li {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
  padding: 6px 12px;
  background: rgba(104, 137, 180, 0.08);
  border-left: 2px solid rgba(104, 137, 180, 0.5);
}
.moment--feature .moment__tokens li {
  color: rgba(8, 7, 11, 0.78);
  background: rgba(255, 255, 255, 0.7);
  border-left-color: rgba(184, 138, 74, 0.6);
}
.moment__tokens li span:first-child {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.8px;
  font-weight: 600;
  color: var(--gallery-accent);
  margin-right: 6px;
  text-transform: uppercase;
}
.moment--feature .moment__tokens li span:first-child { color: var(--gallery-warm-accent); }

.moment__takeaway {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  margin: 0;
  font-weight: 400;
  letter-spacing: -0.2px;
  max-width: 720px;
}
.moment--feature .moment__takeaway { color: var(--gallery-ink); }
.moment__takeaway em {
  font-style: italic;
  color: var(--text);
  font-weight: 500;
}

/* ─── SCENE-SPECIFIC MOCKUPS ───────────────────────────────── */

/* Map mockup (Moment 05 — Naka-Meguro) */
.map-mockup {
  position: relative;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(120deg, #e8e8e0 0%, #efece2 100%);
  overflow: hidden;
  font-family: var(--font-sans);
}
.map-mockup__bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.7;
}
.map-mockup__pin {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.map-mockup__pin--1 { top: 25%; left: 30%; }
.map-mockup__pin--2 { top: 48%; left: 65%; }
.map-mockup__pin--3 { top: 72%; left: 38%; }
.map-mockup__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gallery-warm-accent);
  box-shadow: 0 0 0 3px rgba(184, 138, 74, 0.25);
  position: relative;
}
.map-mockup__dot::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--gallery-warm-accent);
}
.map-mockup__label {
  background: #08070b;
  color: #f0ece4;
  font-size: 10px;
  font-weight: 500;
  padding: 4px 8px;
  text-align: center;
  white-space: nowrap;
  border-radius: 2px;
  margin-top: 6px;
  line-height: 1.35;
}
.map-mockup__label small {
  display: block;
  color: rgba(240, 236, 228, 0.55);
  font-size: 9px;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
  margin-top: 1px;
}
.map-mockup__caption {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 7, 11, 0.92);
  color: #f0ece4;
  font-size: 10px;
  padding: 6px 12px;
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.2px;
  white-space: nowrap;
  border-radius: 100px;
  width: max-content;
  max-width: 90%;
}

/* TV + Phone-as-Remote pattern — lifted from
   _Brainstorming/three-directions-ui-demo.html lines 502-535.
   The phone holds the controller, the TV holds the content. */
.tv-with-remote {
  display: flex;
  align-items: stretch;
  gap: clamp(12px, 2vw, 24px);
  flex-wrap: wrap;
  justify-content: center;
}
.tv-with-remote .moment__tv-frame {
  flex: 1 1 360px;
  min-width: 280px;
}
.phone-remote {
  flex: 0 0 200px;
  background: #08070b;
  padding: 18px;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  color: #f0ece4;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 12px 28px -16px rgba(0,0,0,0.35);
}
.phone-remote__label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(240, 236, 228, 0.5);
  margin: 0;
  text-align: center;
}
.phone-remote__price {
  background: rgba(240, 236, 228, 0.08);
  padding: 10px 14px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}
.phone-remote__price-amount {
  font-size: 14px;
  font-weight: 600;
  color: #f0ece4;
  font-family: var(--font-mono);
}
.phone-remote__price-meta {
  font-size: 9px;
  letter-spacing: 0.5px;
  color: rgba(240, 236, 228, 0.55);
}
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 4px;
}
.dpad__btn {
  border: 1.5px solid rgba(240, 236, 228, 0.12);
  background: rgba(240, 236, 228, 0.04);
  color: rgba(240, 236, 228, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border-radius: 8px;
}
.dpad__btn--ok {
  background: #f0ece4;
  color: #08070b;
  border: none;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.5px;
}
.dpad__btn--empty {
  background: transparent;
  border: none;
}
@media (max-width: 600px) {
  .phone-remote { flex: 1 1 100%; }
}

/* Bedtime mockup (Moment 09) */
.bedtime-mockup {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #2a1f1a 0%, #1a1410 100%);
  color: #f5e6d3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px 18px;
  font-family: var(--font-sans);
}
.bedtime-mockup__lock {
  text-align: center;
}
.bedtime-mockup__time {
  font-size: 56px;
  font-weight: 200;
  margin: 0;
  letter-spacing: -2px;
  line-height: 1;
}
.bedtime-mockup__date {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: rgba(245, 230, 211, 0.5);
  margin: 8px 0 0;
}
.bedtime-mockup__quiet {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 14px 16px;
  background: rgba(245, 230, 211, 0.06);
  border: 1px solid rgba(245, 230, 211, 0.12);
  border-radius: 4px;
}
.bedtime-mockup__moon {
  font-size: 20px;
  color: rgba(245, 230, 211, 0.7);
}
.bedtime-mockup__quiet p {
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
  color: rgba(245, 230, 211, 0.85);
}
.bedtime-mockup__break {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(245, 230, 211, 0.4);
}
.bedtime-mockup__chip {
  padding: 4px 8px;
  border: 1px solid rgba(245, 230, 211, 0.18);
  border-radius: 100px;
}

/* ─── REVEAL ON SCROLL ─────────────────────────────────────── */
.moment {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s var(--ease-out-soft), transform 0.7s var(--ease-out-soft);
}
.moment.is-visible {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .moment {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ─── CLOSE ────────────────────────────────────────────────── */
.gallery-close {
  padding: clamp(72px, 9vw, 120px) clamp(24px, 4vw, 48px);
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.gallery-close__inner {
  max-width: var(--gallery-max);
  margin: 0 auto;
  text-align: center;
}
.gallery-close__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 18px;
}
.gallery-close__title {
  font-weight: 500;
  font-size: clamp(28px, 3.6vw, 44px);
  line-height: 1.15;
  letter-spacing: -1.2px;
  margin: 0 0 22px;
  color: var(--text);
}
.gallery-close__title em {
  font-style: italic;
  font-weight: 400;
  color: var(--text-2);
}
.gallery-close__lede {
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1.7;
  color: var(--text-2);
  max-width: 720px;
  margin: 0 auto clamp(40px, 5vw, 56px);
}
.gallery-close__lede em { font-style: italic; color: var(--text); }

.gallery-close__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  text-align: left;
}
.gallery-close__card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.18s var(--ease-hover), transform 0.18s var(--ease-hover);
}
.gallery-close__card:hover {
  border-color: var(--gallery-accent);
  transform: translateY(-2px);
}
.gallery-close__card--alt {
  background: var(--gallery-ink);
  color: #f0ece4;
  border-color: var(--gallery-ink);
}
.gallery-close__card--alt:hover {
  border-color: var(--gallery-accent);
  background: #0e0d12;
}
.gallery-close__num {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--gallery-accent);
}
.gallery-close__card--alt .gallery-close__num { color: rgba(240, 236, 228, 0.85); }
.gallery-close__copy {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-2);
}
.gallery-close__card--alt .gallery-close__copy { color: rgba(240, 236, 228, 0.7); }

/* ─── FOOTER ───────────────────────────────────────────────── */
.gallery-footer {
  border-top: 1px solid var(--border);
  padding: 28px clamp(24px, 4vw, 48px);
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.7;
}
.gallery-footer__breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.gallery-footer__breadcrumb a {
  color: var(--text-3);
  text-decoration: none;
  border-bottom: 1px dashed transparent;
  transition: color 0.15s var(--ease-hover);
}
.gallery-footer__breadcrumb a:hover { color: var(--text); border-bottom-color: var(--text-2); }
.gallery-footer p { margin: 0; }
.gallery-footer a {
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.gallery-footer a:hover { color: var(--text); }
