/* Colours from the "Stars in the Sky" deck */
:root {
  --ink: #071634;
  --navy: #18396C;
  --sky-top: #0335A3;
  --sky-mid: #0B45B6;
  --sky-low: #4F8BE6;
  --pale: #D6E2F8;
  --white: #FFFFFF;
  --rec: #E5484D;

  --glass: rgba(7, 22, 52, 0.48);
  --glass-line: rgba(255, 255, 255, 0.2);
  --text-dim: rgba(255, 255, 255, 0.72);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 140ms;
  --base: 240ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--white);
  font-family: Questrial, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button, a { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--white); outline-offset: 3px; }

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

#video {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}

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

.app {
  position: fixed;
  inset: 0;
  background: radial-gradient(120% 80% at 50% 0%, #0E2A66 0%, var(--ink) 70%);
}

.screen {
  position: absolute;
  inset: 0;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 28px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 17px;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: transform var(--fast) var(--ease-out), background-color var(--base), opacity var(--base);
}
.btn:active { transform: scale(0.97); }
.btn.loading { color: transparent; pointer-events: none; position: relative; }
.btn.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(24, 57, 108, 0.25);
  border-top-color: var(--navy);
  animation: spin 0.8s linear infinite;
}
.btn-primary { background: var(--white); color: var(--navy); box-shadow: 0 8px 24px rgba(3, 20, 70, 0.28); }
.btn-secondary { background: var(--glass); border-color: var(--glass-line); color: var(--white); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform var(--fast) var(--ease-out), background-color var(--base);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn[aria-pressed="true"] { background: var(--white); color: var(--navy); }

.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--white);
  color: var(--navy);
  font-size: 12px;
  line-height: 20px;
}

/* ---------- Welcome ---------- */

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding: calc(28px + var(--safe-top)) 24px calc(28px + var(--safe-bottom));
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-low) 100%);
  text-align: center;
}

.welcome-logo { width: 196px; position: relative; z-index: 1; }

.welcome-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}
.welcome-lettering { width: min(78vw, 380px); aspect-ratio: 1000 / 772; }

.lockup {
  position: relative;
  margin: 0;
  padding: 0.95em 0.2em 0.95em 0.6em;
  font-size: clamp(30px, 9.5vw, 42px);
  line-height: 1;
}
.lockup-word { letter-spacing: 0.01em; }
.lockup-ten, .lockup-year {
  position: absolute;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-weight: 300;
  font-size: 1.2em;
}
.lockup-ten { left: 0; top: 0.05em; }
.lockup-ten sup { font-size: 0.48em; vertical-align: 0.9em; margin-left: 0.04em; }
.lockup-year { right: 0; bottom: 0; }

.welcome-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 340px;
  margin-bottom: min(25vh, 270px);
}
.welcome-actions .btn { width: 100%; }
.welcome-error {
  margin: 0;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(7, 22, 52, 0.6);
  font-size: 15px;
  line-height: 1.4;
}

.welcome-clouds {
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: max(100%, 860px);
  height: min(24vh, 260px);
  object-fit: cover;
  object-position: center top;
  transform: translateX(-50%);
  pointer-events: none;
}
.welcome-star { position: absolute; pointer-events: none; animation: arrive 900ms var(--ease-out) both; }
.welcome-star.s1 { width: 96px; right: 3%; top: 11%; }
.welcome-star.s2 { width: 48px; left: 6%; top: 13%; animation-delay: 120ms; }
.welcome-star.s3 { width: 60px; left: 7%; bottom: 25%; animation-delay: 240ms; }
@keyframes arrive { from { opacity: 0; transform: translateY(14px) scale(0.9); } }

/* ---------- Camera ---------- */

/* Full screen on phones, like a camera app. On wide screens, a phone-shaped stage. */
.camera { display: grid; place-items: center; }

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0B1E45;
}

@media (min-aspect-ratio: 10/16) {
  .stage {
    width: auto;
    height: calc(100% - 32px);
    max-height: 100%;
    aspect-ratio: 9 / 19.5;
    border-radius: 36px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  }
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  touch-action: pan-y;
}

.flash {
  position: absolute;
  inset: 0;
  background: var(--white);
  opacity: 0;
  pointer-events: none;
}
.flash.on { animation: flash 0.4s var(--ease-out); }
@keyframes flash { from { opacity: 0.85; } to { opacity: 0; } }

.top-scrim, .bottom-scrim {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
}
.top-scrim {
  top: 0;
  height: calc(120px + var(--safe-top));
  background: linear-gradient(rgba(4, 10, 28, 0.4), rgba(4, 10, 28, 0));
}
.bottom-scrim {
  bottom: 0;
  height: calc(220px + var(--safe-bottom));
  background: linear-gradient(rgba(4, 10, 28, 0), rgba(4, 10, 28, 0.55));
}

.top-bar {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.top-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.top-bar > * { pointer-events: auto; }
.rail {
  position: absolute;
  right: -4px;
  top: -4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rail .icon-btn {
  width: 36px;
  height: 36px;
  background: rgba(7, 22, 52, 0.3);
  border-color: rgba(255, 255, 255, 0.28);
}
.rail .icon-btn svg { width: 19px; height: 19px; }
.rail .icon-btn::after { inset: -4px; }
.close-cam {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 36px;
  height: 36px;
  background: rgba(7, 22, 52, 0.3);
  border-color: rgba(255, 255, 255, 0.28);
}
.close-cam svg { width: 19px; height: 19px; }
.close-cam::after { inset: -4px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  margin-top: 4px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.pill.loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--white);
  animation: spin 0.8s linear infinite;
}
.pill.rec::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rec);
  animation: blink 1s steps(2) infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0.2; } }

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 160px;
  line-height: 1;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.countdown.tick { animation: tick 0.9s var(--ease-out); }
@keyframes tick { from { transform: scale(1.35); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); opacity: 0.9; } }

.bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0 0 calc(6px + var(--safe-bottom));
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(7, 22, 52, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.tab {
  position: relative;
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font-size: 15px;
  transition: background-color var(--base) var(--ease-out), color var(--base);
}
.tab[aria-selected="true"] { background: var(--white); color: var(--navy); }
/* Invisible tap area: 44 px tall without changing the look. */
.tab::after, .quote-chip::after, .icon-btn::after, .modes button::before { content: ''; position: absolute; inset: -6px -2px; }

.top-center { width: calc(100% - 64px); }
.quotes {
  margin-bottom: 4px;
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 560px;
  padding: 2px 4px 4px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.quotes::-webkit-scrollbar { display: none; }
.quote-chip {
  flex: none;
  max-width: 240px;
  position: relative;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-line);
  background: rgba(7, 22, 52, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-dim);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  scroll-snap-align: center;
  transition: background-color var(--base) var(--ease-out), color var(--base), transform var(--fast) var(--ease-out);
}
.quote-chip:active { transform: scale(0.96); }
.quote-chip[aria-selected="true"] { background: var(--pale); border-color: var(--pale); color: var(--navy); }

.carousel-wrap {
  position: relative;
  width: 100%;
  max-width: 560px;
  height: 84px;
}
.carousel {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
  padding-inline: calc(50% - 28px);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}
.carousel::-webkit-scrollbar { display: none; }
.carousel.dragging { scroll-snap-type: none; }

.thumb {
  flex: none;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  background: var(--navy);
  overflow: hidden;
  scroll-snap-align: center;
  transition: transform var(--base) var(--ease-out), opacity var(--base);
  opacity: 0.85;
}
.thumb canvas { display: block; width: 100%; height: 100%; }
.thumb[aria-selected="true"] { border-color: transparent; opacity: 1; }
.thumb:active { transform: scale(0.94); transition-duration: var(--fast); }

.shutter {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 80px;
  height: 80px;
  margin: -40px 0 0 -40px;
  padding: 0;
  border-radius: 50%;
  border: 5px solid var(--white);
  background: transparent;
  box-shadow: 0 0 0 1px rgba(4, 10, 28, 0.2), inset 0 0 0 1px rgba(4, 10, 28, 0.2);
  transition: transform var(--fast) var(--ease-out), border-color var(--base);
}
.shutter:active { transform: scale(0.93); }
.shutter.video { border-color: var(--rec); }
.shutter-progress {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(var(--white) calc(var(--p, 0) * 1turn), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 5px));
  opacity: 0;
}
.shutter.recording .shutter-progress { opacity: 1; }
.shutter.recording::after {
  content: '';
  position: absolute;
  inset: 22px;
  border-radius: 8px;
  background: var(--rec);
}

.modes {
  display: flex;
  gap: 2px;
  margin-top: 2px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(7, 22, 52, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.modes button {
  position: relative;
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color var(--base);
}
.modes button[aria-selected="true"] { color: var(--white); }
.modes button[aria-selected="true"]::after {
  content: '';
  display: block;
  width: 4px;
  height: 4px;
  margin: 4px auto 0;
  border-radius: 50%;
  background: var(--white);
}

.camera.busy .tabs,
.camera.busy .carousel,
.camera.busy .modes,
.camera.busy .close-cam,
.camera.busy .rail { opacity: 0.35; pointer-events: none; transition: opacity var(--base); }

/* ---------- Result ---------- */

.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: calc(12px + var(--safe-top)) 16px calc(20px + var(--safe-bottom));
  background: rgba(4, 10, 28, 0.94);
  animation: rise var(--base) var(--ease-out);
}
.result.leaving { animation: sink 180ms cubic-bezier(0.64, 0, 0.78, 0) forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
@keyframes sink { to { opacity: 0; transform: translateY(16px) scale(0.98); } }

.result-top { width: 100%; max-width: 440px; display: flex; }
.result-media {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  justify-content: center;
}
.result-media img,
.result-media video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.result-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 400px;
}
.share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--white);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.share-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--glass-line);
  transition: transform var(--fast) var(--ease-out);
}
.share-icon svg { width: 26px; height: 26px; }
.share-btn:active .share-icon { transform: scale(0.92); }
.brand-ig { background: radial-gradient(circle farthest-corner at 28% 100%, #FEDA75 0%, #FA7E1E 22%, #D62976 48%, #962FBF 74%, #4F5BD5 100%); border-color: transparent; }
.brand-wa { background: #25D366; border-color: transparent; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + var(--safe-bottom));
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--white);
  color: var(--navy);
  font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: rise var(--base) var(--ease-out);
  z-index: 20;
}

/* Sideways phone: the camera is built for upright use. */
.rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-mid));
  font-size: 17px;
}
.rotate svg { width: 44px; height: 44px; animation: tilt 1.8s var(--ease-out) infinite; }
.rotate p { margin: 0; }
@keyframes tilt { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0); } }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .rotate { display: flex; }
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover, .btn-secondary:hover { background: rgba(7, 22, 52, 0.7); }
  .btn-primary:hover { background: #EEF3FC; }
  .tab:not([aria-selected="true"]):hover, .modes button:hover { color: var(--white); }
  .thumb:hover { opacity: 1; }
}

@media (prefers-reduced-transparency: reduce) {
  :root { --glass: rgba(7, 22, 52, 0.94); }
  .icon-btn, .tabs, .pill, .btn-secondary { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  :root { --glass: #071634; --glass-line: rgba(255, 255, 255, 0.85); --text-dim: rgba(255, 255, 255, 0.92); }
}

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