:root {
  --bg: #1d1b1b;
  --surface: rgb(20 18 18 / 0.85);
  --surface-solid: #262222;
  --text: #f4efe9;
  --muted: #b5aca4;
  --accent: #ff0099;
  --accent-dark: #dd0066;
  --focus: #ffd34d;
  --radius: 14px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg) url("../images/bg-wood-light.jpg");
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

main {
  min-height: 100svh;
}

[hidden] {
  display: none !important;
}

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

svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Buttons ---------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: #3a3434;
  color: var(--text);
  font: 700 1.05rem var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s;
}

.button:hover {
  filter: brightness(1.15);
}

.button:active {
  transform: scale(0.97);
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.button.primary {
  background: linear-gradient(var(--accent), var(--accent-dark));
  box-shadow: 0 4px 16px rgb(255 0 153 / 0.35);
}

.button.quiet {
  background: transparent;
  color: var(--muted);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover,
.icon-button[aria-pressed="true"] {
  background: rgb(255 255 255 / 0.12);
}

.icon-button[aria-pressed="true"] {
  color: var(--accent);
}

/* Intro ------------------------------------------------------------------ */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  /* Slightly under a full screen so the next section peeks in. svh, not dvh:
     dvh changes as the phone's address bar slides, re-laying out mid-scroll. */
  min-height: 92svh;
  padding: 32px 16px;
  text-align: center;
}

.intro .site-footer {
  padding: 32px 16px 24px;
}

.home-more {
  display: grid;
  gap: 48px;
  width: min(760px, 100% - 32px);
  margin: 0 auto;
  padding: 48px clamp(20px, 5vw, 48px);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.5);
  line-height: 1.6;
}

.home-more h2 {
  margin: 0 0 16px;
  font-size: 1.5rem;
}

.home-more p,
.home-more li {
  color: #ddd5cd;
}

.steps {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding-left: 48px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.steps strong,
.favourites strong {
  color: var(--text);
}

.favourites {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.favourites strong {
  display: block;
}

.more-link {
  margin: 16px 0 0;
}

.more-link a {
  color: #ff5cbc;
  text-underline-offset: 3px;
}

.home-more details {
  border-top: 1px solid rgb(255 255 255 / 0.1);
}

.home-more details:last-child {
  border-bottom: 1px solid rgb(255 255 255 / 0.1);
}

.home-more summary {
  padding: 14px 0;
  font-weight: 700;
  cursor: pointer;
}

.home-more summary:hover {
  color: #ff5cbc;
}

.home-more details p {
  margin: 0 0 16px;
}

.logo {
  width: clamp(88px, 20vw, 140px);
  height: auto;
}

/* Toast mascot ------------------------------------------------------------ */
/* Idle: floats and sways, its shadow breathes, it blinks, the butter wobbles.
   Excited (while "Ready? Smile!" is hovered or focused): hops, happy eyes, grin.
   Performance: the float, hop and shadow animate whole HTML-level boxes, which
   the compositor can run without layout. The face parts live inside the SVG and
   can't be composited, so js/toast.js pauses them while scrolling or off-screen. */

.toast {
  overflow: visible;
  /* Undo the outline-icon defaults from the generic svg rule. */
  stroke: none;
}

.toast * {
  transform-box: fill-box;
}

.toast-eyes {
  transform-origin: center;
  animation: toast-blink 5s infinite;
}

.toast-butter {
  transform-origin: 50% 100%;
  animation: toast-butter 3.6s ease-in-out infinite;
}

.toast-blush {
  animation: toast-blush 3.6s ease-in-out infinite;
}

.toast-eyes-happy,
.toast-grin {
  opacity: 0;
}

.toast-eyes,
.toast-smile,
.toast-eyes-happy,
.toast-grin {
  transition: opacity 0.15s;
}

.hero:has(#start:hover, #start:focus-visible) .toast {
  animation: toast-hop 0.55s ease-in-out infinite;
}

.hero:has(#start:hover, #start:focus-visible) .toast-button::after {
  animation: toast-hop-shadow 0.55s ease-in-out infinite;
}

.toast-button:is(.is-scrolling, .is-offscreen) .toast *,
.toast-button.is-offscreen .toast,
.toast-button.is-offscreen::after {
  animation-play-state: paused;
}

.hero:has(#start:hover, #start:focus-visible) :is(.toast-eyes, .toast-smile),
.toast.is-happy :is(.toast-eyes, .toast-smile) {
  opacity: 0;
}

.hero:has(#start:hover, #start:focus-visible) :is(.toast-eyes-happy, .toast-grin),
.toast.is-happy :is(.toast-eyes-happy, .toast-grin) {
  opacity: 1;
}

/* Easter egg (js/toast.js): the toast is a button you can poke. */
.toast-wrap {
  position: relative;
  display: grid;
  place-items: center;
}

.toast-button {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.toast-button .toast {
  display: block;
  transform-origin: 50% 85%;
  animation: toast-float 3.6s ease-in-out infinite;
}

/* Soft shadow under the toast; it shrinks and fades as the toast rises. */
.toast-button::after {
  content: "";
  position: absolute;
  bottom: 1%;
  left: 20%;
  width: 60%;
  height: 8%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(0 0 0 / 0.9) 35%, transparent);
  animation: toast-shadow 3.6s ease-in-out infinite;
  pointer-events: none;
}

.toast-bubble {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  margin: 0;
  padding: 6px 14px;
  border-radius: 16px;
  background: #fff;
  color: #3a3434;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.4);
  opacity: 0;
  translate: -50% 0;
  scale: 0.6;
  transform-origin: 50% 100%;
  transition: opacity 0.15s, scale 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
  pointer-events: none;
}

/* Little tail pointing down at the toast. */
.toast-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  border: 7px solid transparent;
  border-top-color: #fff;
  translate: -50% 0;
}

.toast-bubble:empty {
  visibility: hidden;
}

.toast-bubble.is-visible {
  opacity: 1;
  scale: 1;
}

.toast-rain {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  pointer-events: none;
}

.toast-rain img {
  position: absolute;
  top: 0;
}

@keyframes toast-float {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }

  50% {
    transform: translateY(-6px) rotate(2deg);
  }
}

@keyframes toast-shadow {
  0%,
  100% {
    transform: scaleX(1);
    opacity: 0.6;
  }

  50% {
    transform: scaleX(0.82);
    opacity: 0.38;
  }
}

@keyframes toast-blink {
  0%,
  90%,
  100% {
    transform: scaleY(1);
  }

  93% {
    transform: scaleY(0.1);
  }
}

@keyframes toast-butter {
  0%,
  100% {
    transform: rotate(0deg) translateX(0);
  }

  50% {
    transform: rotate(-5deg) translateX(-0.3px);
  }
}

@keyframes toast-blush {
  0%,
  100% {
    opacity: 0.7;
  }

  50% {
    opacity: 0.95;
  }
}

@keyframes toast-hop {
  0%,
  100% {
    transform: translateY(0) scale(1.04, 0.96);
  }

  45% {
    transform: translateY(-11px) scale(0.98, 1.02);
  }
}

@keyframes toast-hop-shadow {
  0%,
  100% {
    transform: scaleX(1.05);
    opacity: 0.65;
  }

  45% {
    transform: scaleX(0.7);
    opacity: 0.3;
  }
}

.intro h1 {
  margin: 0;
  color: var(--accent);
  font-size: clamp(2.4rem, 8vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-shadow: 0 3px 0 rgb(0 0 0 / 0.4);
}

.tagline {
  max-width: 34em;
  text-wrap: balance;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 1.1rem;
}

.promises {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 24px;
  margin: 0 0 8px;
  padding: 0;
  color: var(--text);
  font-size: 0.95rem;
  list-style: none;
}

.promises li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.promises svg {
  width: 20px;
  height: 20px;
  color: #ffe680;
}

.camera-note {
  max-width: 34em;
  text-wrap: balance;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.camera-note a {
  color: var(--muted);
  text-underline-offset: 3px;
}

.camera-note a:hover {
  color: var(--text);
}

.status {
  min-height: 1.5em;
  max-width: 34em;
  text-wrap: balance;
  margin: 0;
  color: var(--focus);
}

/* Booth ------------------------------------------------------------------ */

.booth {
  display: grid;
  grid-template-rows: 1fr auto;
  height: 100dvh;
  background: var(--bg) url("../images/bg-wood-light.jpg");
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 16px 64px;
  container-type: size;
  touch-action: pan-y;
}

.frame {
  --aspect: 4 / 3;
  position: relative;
  aspect-ratio: var(--aspect);
  /* Largest box with this aspect that fits the stage. */
  width: min(100cqw - 128px, (100cqh - 32px) * (var(--aspect)));
  max-height: calc(100cqh - 32px);
  overflow: hidden;
  border-radius: 6px;
  background: #000;
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.6);
}

.frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Still of the outgoing view, layered over the canvas while zooming. */
.frame .snapshot {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.45);
  color: #fff;
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: background 0.15s, opacity 0.2s;
}

.close svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.5;
}

.close:hover {
  background: var(--accent);
}

.capturing .close {
  opacity: 0;
  pointer-events: none;
}

.camera {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.nav {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  translate: 0 -50%;
  cursor: pointer;
}

.nav:hover {
  background: var(--accent);
}

.prev {
  left: 8px;
}

.next {
  right: 8px;
}

.capturing .nav,
.capturing .toolbar button {
  pointer-events: none;
  opacity: 0.4;
}

/* Effects grid: nine buttons laid over the nine previews. */
.grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
}

.grid-cell {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 6px;
  border: 1px solid rgb(0 0 0 / 0.6);
  background: transparent;
  color: #fff;
  font: 700 0.85rem var(--font);
  cursor: pointer;
}

.grid-cell span {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.55);
}

.grid-cell:hover span,
.grid-cell[aria-current="true"] span {
  background: var(--accent);
}

.grid-cell:focus-visible {
  outline-offset: -4px;
}

.countdown {
  --x: 50%;
  --y: 50%;
  position: absolute;
  left: var(--x);
  top: var(--y);
  translate: -50% -50%;
  color: #fff;
  font: 800 clamp(3rem, 12cqh, 6rem) / 1 var(--font);
  text-shadow: 0 4px 20px rgb(0 0 0 / 0.6);
  opacity: 0;
  pointer-events: none;
}

.countdown.big {
  font-size: clamp(5rem, 30cqh, 14rem);
}

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: var(--surface);
  backdrop-filter: blur(10px);
}

.toolbar-side {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.toolbar-side.end {
  justify-content: flex-end;
}

.effect-name {
  margin: 0 0 0 8px;
  overflow: hidden;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.shutter {
  width: 68px;
  height: 68px;
  padding: 0;
  border: 4px solid #fff;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0 58%, transparent 60%);
  cursor: pointer;
  transition: transform 0.1s;
}

.shutter:hover {
  transform: scale(1.05);
}

.shutter:active {
  transform: scale(0.94);
}

.shutter:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

/* Settings popover */
.settings {
  margin: auto 16px 104px auto;
  width: min(280px, calc(100vw - 32px));
  padding: 16px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.6);
}

.settings h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.settings label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  cursor: pointer;
}

.settings input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Review dialog ---------------------------------------------------------- */

.review {
  max-width: min(720px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  overflow: visible;
}

.review::backdrop {
  background: rgb(0 0 0 / 0.75);
  backdrop-filter: blur(4px);
}

.photo {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 160px);
  object-fit: contain;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 16px 40px rgb(0 0 0 / 0.6);
  rotate: -2deg;
  animation: drop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.photo[data-frame="white-thick"] {
  border: 16px solid #fff;
  border-bottom-width: 48px;
}

.photo[data-frame="white-thin"] {
  border: 8px solid #fff;
}

.photo[data-frame="black-thin"] {
  border: 8px solid #111;
}

@keyframes drop {
  from {
    opacity: 0;
    translate: 0 -60px;
    rotate: 4deg;
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

/* Site links and content pages -------------------------------------------- */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer nav,
.settings-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.site-footer p {
  margin: 0;
}

.site-footer a,
.settings-links a {
  color: var(--muted);
  text-underline-offset: 3px;
}

.site-footer a:hover,
.settings-links a:hover,
.site-footer a[aria-current="page"] {
  color: var(--text);
}

.settings-links {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgb(255 255 255 / 0.1);
  font-size: 0.9rem;
}

.button.small {
  min-height: 40px;
  padding: 0 18px;
  font-size: 0.95rem;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 760px;
  min-height: 100svh;
  margin: 0 auto;
  padding: 16px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.page-header .button {
  white-space: nowrap;
}

.page-body {
  flex: 1;
  padding: clamp(24px, 5vw, 48px);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.5);
  line-height: 1.65;
}

.page-body h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 6vw, 2.75rem);
  line-height: 1.1;
}

.page-body h2 {
  margin: 2em 0 0.5em;
  font-size: 1.25rem;
}

.page-body p,
.page-body li {
  color: #ddd5cd;
}

.page-body a {
  color: #ff5cbc;
  text-underline-offset: 3px;
}

.page-body a:hover {
  color: var(--text);
}

.page-body ul {
  padding-left: 1.25em;
}

.page-body li + li {
  margin-top: 0.4em;
}

.lede {
  font-size: 1.2rem;
}

.updated {
  margin-top: 0;
  color: var(--muted) !important;
  font-size: 0.9rem;
}

.summary {
  margin: 24px 0;
  padding: 4px 20px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: rgb(255 0 153 / 0.08);
}

.effect-list {
  color: var(--muted) !important;
}

kbd {
  padding: 1px 6px;
  border: 1px solid rgb(255 255 255 / 0.25);
  border-radius: 5px;
  background: rgb(255 255 255 / 0.06);
  font: 0.85em ui-monospace, monospace;
}

.page .site-footer {
  padding-bottom: 8px;
}

.not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 100svh;
  padding: 32px 16px;
  text-align: center;
}

.not-found img {
  rotate: 180deg;
  filter: drop-shadow(0 -8px 20px rgb(0 0 0 / 0.5));
}

.not-found h1 {
  margin: 0;
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  line-height: 1.15;
  text-wrap: balance;
}

.not-found p {
  max-width: 30em;
  margin: 0;
  color: var(--muted);
}

.not-found .site-footer {
  margin-top: 32px;
}

/* Small screens ---------------------------------------------------------- */

@media (max-width: 600px) {
  .stage {
    padding: 8px;
  }

  .frame {
    width: min(100cqw - 16px, (100cqh - 16px) * (var(--aspect)));
    max-height: calc(100cqh - 16px);
  }

  .nav {
    background: rgb(0 0 0 / 0.4);
  }

  .prev {
    left: 12px;
  }

  .next {
    right: 12px;
  }

  .toolbar {
    gap: 8px;
    padding-inline: 8px;
  }

  .effect-name {
    margin-left: 4px;
    font-size: 0.9rem;
  }

  .grid-cell {
    font-size: 0.7rem;
    padding: 3px;
  }

  .settings {
    margin: auto 8px 96px auto;
  }

  .page-brand {
    gap: 8px;
    font-size: 1.05rem;
  }

  .page-brand img {
    width: 28px;
    height: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
