/* ============================== Webfont ================================== */
/* FK Grotesk — drop the font files in  fonts/  (see README). Until they're
   present the browser falls back to a neutral grotesk so nothing breaks. */
/* Light covers the lighter end (300–400); Medium covers everything heavier
   (500–800) so headings/captions stay crisp without faux-bold. */
@font-face {
  font-family: "FK Grotesk";
  src: url("fonts/FKGrotesk-Light.woff2") format("woff2");
  font-weight: 300 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "FK Grotesk";
  src: url("fonts/FKGrotesk-Medium.woff2") format("woff2");
  font-weight: 500 800;
  font-style: normal;
  font-display: swap;
}
/* Kern — used for titles/headings */
@font-face {
  font-family: "Kern";
  src: url("fonts/Kern Extended Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ============================ Base / mobile-first ========================= */
:root {
  --font: "FK Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-title: "Kern", "FK Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --bg: #0b0b0f;
  --surface: #16161d;
  --text: #f4f4f6;
  --muted: #9a9aa6;
  --radius: 16px;
  --gap: 10px;
  --maxw: 520px;            /* phone-width cap on larger screens */
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
}
html, body {
  margin: 0;
  color: var(--text);
  min-height: 100%;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;          /* fill the viewport so the footer can sit at the bottom */
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

/* Home backdrop: fixed full-screen image behind the content */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg) url("images/home-bg.png") center / cover no-repeat;
}

/* ============================== Home header ============================== */
.app-header {
  width: 100%;             /* fill the viewport (capped at --maxw); without this the
                              auto margins shrink-wrap it to the title and it overflows
                              narrow phones, so the heading never wraps */
  max-width: var(--maxw);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 22px) 18px 6px;
  text-align: center;
}
.brand {
  display: inline-block;
  line-height: 0;
}
.brand__logo {
  height: 21px;          /* 25% smaller than 28px */
  width: auto;
  filter: brightness(0) invert(1);   /* dark wordmark → white on dark bg */
}
.app-header h1 {
  font-family: var(--font-title);
  font-size: clamp(22px, 6vw, 26px);  /* scale down on narrow phones so it never clips */
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 48px 0 0;                   /* 48px below the logo */
  text-wrap: balance;                 /* tidy, even line breaks instead of a forced <br> */
  overflow-wrap: break-word;
}

/* ============================== Reel list =============================== */
.list {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 0 8px;
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;          /* grow to fill, pushing the footer to the bottom */
  width: 100%;
}

/* ============================== Footer ================================== */
.app-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 18px calc(env(safe-area-inset-bottom) + 32px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.foot-social {
  display: flex;
  align-items: center;
  gap: 16px;
}
.foot-social a {
  color: var(--text);
  opacity: .8;
  display: inline-flex;
  -webkit-tap-highlight-color: transparent;
}
.foot-social a:hover { opacity: 1; }

/* back row shown above a category's reel list */
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 4px 16px 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.back:hover { color: var(--text); }
.back__chev { font-size: 20px; line-height: 1; }

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 10px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s ease;
}
.row:active { background: var(--surface); }
.row + .row { border-top: 1px solid rgba(255,255,255,.07); }

.row__thumb {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface);
}

/* icon variant: a tinted tile with a Phosphor glyph */
.row__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .08);
  color: #E4FF83;
}
.row__icon svg {
  width: 28px;
  height: 28px;
}

.row__body {
  flex: 1 1 auto;
  min-width: 0;
}
.row__title {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row__meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.row__chev {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

/* =============================== Viewer ================================== */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: none;
  justify-content: center;
  align-items: center;
}
.viewer.is-open { display: flex; }

.viewer__stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: var(--maxw);
  background: #000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* progress segments */
.progress {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  gap: 4px;
}
.progress__seg {
  flex: 1;
  height: 3px;
  border-radius: 3px;
  background: rgba(255,255,255,.3);
  overflow: hidden;
}
.progress__seg > i {
  display: block;
  height: 100%;
  width: 0;
  background: #fff;
  border-radius: 3px;
}
.progress__seg.is-done > i { width: 100%; }
.progress__seg.is-active > i { width: 100%; }

/* top bar */
.viewer__top {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 22px);
  left: 14px;
  right: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.viewer__title {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 500;
  text-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.viewer__actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
.icon-btn {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 30px;
  line-height: 1;
  width: 40px;
  height: 40px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn svg { display: block; }

/* media: full-bleed background filling the whole stage */
.viewer__media {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.viewer__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;       /* fill the screen, crop overflow */
}

/* optional foreground image (app screenshot over the background)
   Flows in the stage's flex column so it sits ABOVE the caption rather than
   full-bleed: centered, with side gaps, and a fixed gap before the text. */
.viewer__fgwrap {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;          /* fills the space above the caption (which flows below) */
  min-height: 0;           /* allow shrink so object-fit: contain works */
  display: flex;
  align-items: center;     /* center the shot vertically in the space above the caption */
  justify-content: center;
  /* 16px of side breathing room; centering in the flow above the caption keeps the
     image off the text, and the caption's 24px top-pad guarantees ≥24px below it */
  padding: 0 16px;
  pointer-events: none;
  /* one square box every shot is fit into, so they read at a consistent size
     regardless of their (wildly varying) source aspect ratios. ~50% larger than
     before: more width (smaller side gaps) and a taller height cap. */
  --shot: min(calc(min(100vw, var(--maxw)) - 32px), 66dvh);
}
.viewer__fg {
  width: var(--shot);
  height: var(--shot);
  object-fit: contain;     /* shown whole, never cropped */
  object-position: center; /* centered within its square box */
}
.viewer__fg[hidden] { display: none; }

/* caption: overlaid at the bottom over a gradient scrim */
.viewer__caption {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;          /* flows below the image, so text never overlaps it */
  margin: 0;
  /* 24px gap above the text (also fades the scrim), 60px gap from the edge */
  padding: 24px 24px calc(env(safe-area-inset-bottom) + 60px);
  text-align: center;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.3;
  background: linear-gradient(to top, rgba(0,0,0,.8) 0%, rgba(0,0,0,.5) 48%, rgba(0,0,0,0) 100%);
  pointer-events: none;    /* let taps pass through to the nav zones */
}

/* tap zones — left third / right two-thirds */
.tapzone {
  position: absolute;
  top: 60px;            /* leave the close button tappable */
  bottom: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 4;
  -webkit-tap-highlight-color: transparent;
}
.tapzone--left  { left: 0;  width: 33%; }
.tapzone--right { right: 0; width: 67%; }

/* background cross-fade when changing step */
.viewer__media img.swap {
  animation: fade .25s ease;
}
@keyframes fade {
  from { opacity: 0; transform: scale(1.02); }
  to   { opacity: 1; transform: scale(1); }
}

/* foreground: dynamic entrance — rises up, overshoots, settles */
.viewer__fg.anim {
  animation: fgIn .66s cubic-bezier(.18,.7,.2,1) both;
}
@keyframes fgIn {
  0%   { opacity: 0; transform: translateY(41px) scale(.83); }
  55%  { opacity: 1; }
  72%  { transform: translateY(-7px) scale(1.05); }   /* overshoot for punch */
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .row, .viewer__media img.swap, .viewer__fg.anim { transition: none; animation: none; }
}
