/*
 * The page a shared moment opens (functions/m/[clipId].js) — the one most
 * people see before they have heard of Whimzi. Its own small sheet rather
 * than the site's: dark always, because it frames video (CLAUDE.md, "Anything
 * that frames video is dark"), and nothing on it that is not the moment, where
 * it is, going there, or what Whimzi is in one line.
 *
 * Phone first: the clip is the screen. On a wide screen the clip sits beside
 * its words. The life bar drains with CSS alone; the one script
 * (share-feed.js) only adds the full-screen feed at the end of this sheet.
 */

@font-face {
  font-family: 'Space Grotesk';
  src: url('fonts/space-grotesk-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: 'Space Grotesk';
  src: url('fonts/space-grotesk-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --surface: #17171a;
  --surface-high: #222227;
  --ink: #f7f7f8;
  --ink-muted: #9a9aa3;
  --hairline: #2a2a2f;
  --accent: #c6f432;
  --on-accent: #111114;
  --display: 'Space Grotesk', Futura, 'Trebuchet MS', sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body.share {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

.s-page {
  max-width: 64rem;
  margin: 0 auto;
  padding-block: 0 2.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
}

/* A grid item's minimum is its content's, and the row of tiles is wide by design. */
.s-page > *,
.s-moment > * {
  min-width: 0;
}

/* ---- Top bar: the mark, the name, the one call to action --------------- */

.s-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: max(14px, env(safe-area-inset-top, 0px)) 0;
}

.s-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  font: 700 1.3rem/1 var(--display);
  letter-spacing: -0.02em;
}

/* The app icon's tile, as on every page of the site. */
.s-brand img {
  width: 28px;
  height: 28px;
  border-radius: 0.42rem;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.s-get {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 1rem;
  border-radius: 999px;
  background: var(--surface-high);
  font: 600 0.9rem/1 var(--body);
  text-decoration: none;
  white-space: nowrap;
}

/* ---- The moment ----------------------------------------------------------- */

.s-moment {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 52rem) {
  .s-moment {
    grid-template-columns: minmax(0, 24rem) minmax(0, 1fr);
    gap: 2.5rem;
    align-items: center;
  }
}

.s-frame {
  position: relative;
  width: 100%;
  max-width: 26rem;
  margin: 0.75rem auto 0;
  aspect-ratio: 9 / 16;
  /* Short enough that the place and Take me there are on the first screen of a phone. */
  max-height: 60vh;
  max-height: 60svh;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.s-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--surface);
}

/* The stamp and the video, kept together whatever the page's layout does. */
.s-media {
  display: grid;
  gap: 0.5rem;
  justify-items: start;
  width: 100%;
  max-width: 26rem;
  margin: 0.75rem auto 0;
}

.s-media .s-frame {
  margin: 0;
}

/* Above the main video rather than on it: Safari's controls hold every corner. */
.s-stamp.above {
  position: static;
}

.s-words {
  display: grid;
  gap: 1rem;
  max-width: 30rem;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 52rem) {
  .s-words {
    margin: 0;
  }
}

.s-from {
  margin: 0;
  font: 700 0.75rem/1 var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.s-place {
  margin: 0;
  font: 700 clamp(1.8rem, 6vw, 2.6rem) / 1.05 var(--display);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.s-area {
  margin: 0.35rem 0 0;
  color: var(--ink-muted);
}

/* The name and Go on one line, as the app's place page has them. */
.s-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.s-head-words {
  min-width: 0;
}

.s-note {
  margin: 0;
  color: var(--ink-muted);
}

/* How long it has left, draining with CSS alone (the page's own nonce'd style sets the start). */
.s-life {
  display: grid;
  gap: 0.45rem;
}

.s-life-label {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.s-life-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-high);
  overflow: hidden;
}

.life-fill {
  height: 100%;
  background: var(--ink-muted);
  animation-name: drain;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.life-fill.current {
  background: var(--accent);
}

/* ---- More right now ------------------------------------------------------- */

.s-more h2,
.s-app h2 {
  margin: 0 0 0.9rem;
  font: 700 1.25rem/1.2 var(--display);
  letter-spacing: -0.01em;
}

.s-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 9.5rem;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: max(16px, env(safe-area-inset-left, 0px));
  padding-bottom: 0.5rem;
  margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  padding-inline: max(16px, env(safe-area-inset-left, 0px));
  scrollbar-width: none;
}

.s-row::-webkit-scrollbar {
  display: none;
}

.s-tile {
  position: relative;
  display: block;
  aspect-ratio: 9 / 16;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  scroll-snap-align: start;
  text-decoration: none;
}

/*
 * A video rather than its poster image: a clip whose poster never landed (it is
 * optional, rule 2) still shows its first frame instead of a broken image.
 */
.s-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* The play mark, centred, so a tile reads as a clip to watch. */
.s-play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.6rem;
  height: 2.6rem;
  margin: -1.3rem 0 0 -1.3rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
}

.s-play svg {
  width: 1.25rem;
  height: 1.25rem;
  margin-left: 2px;
}

.s-tile .s-stamp {
  top: 8px;
  left: 8px;
  font-size: 0.68rem;
  padding: 0.3rem 0.55rem;
}

.s-tile-where {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  font: 700 0.85rem/1.2 var(--display);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

/* ---- What Whimzi is, in one breath ---------------------------------------- */

/* What Whimzi is: the mark, one line, three small steps in the app's own colours. */
.s-app {
  display: grid;
  justify-items: center;
  gap: 1.1rem;
  padding: 1.8rem 1.4rem;
  border-radius: 26px;
  background: var(--surface);
  text-align: center;
}

.s-app h2 {
  margin: 0;
  font-size: 1.6rem;
}

.s-film-too {
  margin: 0;
  max-width: 30ch;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

.s-film-too strong {
  color: var(--ink);
}

.s-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  width: 100%;
  font-size: 0.82rem;
  line-height: 1.3;
  color: var(--ink-muted);
}

.s-steps li {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
}

.s-step {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
}

.s-step svg {
  width: 22px;
  height: 22px;
}

.s-step.ask {
  background: #8b5cf6;
  color: #fff;
}

.s-step.film {
  border: 3px solid var(--ink);
}

.s-step.film i {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: #ff3b30;
}

.s-step.go {
  background: var(--accent);
  color: var(--on-accent);
}

/* The step after watching: ask the place, right now. */
.s-ask {
  margin-top: 0.9rem;
}

/* ---- The way in, kept at the foot of a phone's screen -------------------- */

.s-dock {
  position: fixed;
  left: max(12px, env(safe-area-inset-left, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.6rem 0.6rem 0.7rem;
  border-radius: 22px;
  background: rgba(23, 23, 26, 0.92);
  border: 1px solid var(--hairline);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 10;
}

.s-dock img {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  flex: none;
}

.s-dock-words {
  display: grid;
  min-width: 0;
  flex: 1;
  line-height: 1.2;
}

.s-dock-words strong {
  font: 700 0.95rem/1.2 var(--display);
}

.s-dock-words span {
  font-size: 0.75rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Room under the last thing on the page, so the dock never covers it. */
body.share:has(.s-dock) .s-page {
  padding-bottom: 6.5rem;
}

@media (min-width: 52rem) {
  .s-dock {
    left: auto;
    max-width: 26rem;
  }
}

/* ---- Gone, and not found -------------------------------------------------- */

.s-passed {
  display: grid;
  place-items: center;
  gap: 0.6rem;
  padding: 3rem 1.5rem;
  text-align: center;
  border-radius: var(--radius);
  background: var(--surface);
}

.s-passed h1 {
  margin: 0;
  font: 700 clamp(1.8rem, 6vw, 2.4rem) / 1.05 var(--display);
}

.s-passed p {
  margin: 0;
  color: var(--ink-muted);
  max-width: 26rem;
}

.s-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
  padding-bottom: max(0px, env(safe-area-inset-bottom, 0px));
}

.s-foot a {
  color: var(--ink-muted);
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
