/* ── Fonts ── */
@font-face {
  font-family: 'RoadRadioBlack';
  src: url('../fonts/RoadRadioBlack/font.woff2') format('woff2'),
       url('../fonts/RoadRadioBlack/font.woff')  format('woff');
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Theme tokens (set via <html data-theme="light|dark">) ── */
:root {
  --accent:       #ce0100;
  --accent-hover: #a01000;
  --bg-page:      #f0ede8;
  --text-muted:   #666;
  --shadow:       0 8px 32px rgba(0,0,0,0.18);
  --img-bg:       url('../img/light/Futique-bg.jpg');
  --img-monogram: url('../img/light/loader.png');
}
[data-theme="dark"] {
  --accent:       #ce0100;   /* option to change red for dark */
  --accent-hover: #a01000;
  --bg-page:      #0e0e0e;
  --text-muted:   #c7c7c7;
  --shadow:       0 0 40px rgba(206,1,0,0.18);   /* red glow */
  --img-bg:       url('../img/dark/Futique-bg.jpg');
  --img-monogram: url('../img/dark/loader.png');
}

html, body {
  height: 100%;
  background-color: var(--bg-page);
  background-image: var(--img-bg);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  background-attachment: fixed;
  color: var(--accent);
  font-family: 'RoadRadioBlack', sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

a { color: var(--accent); }

/* Prevent scroll + touch propagation while cropping */
body.is-cropping { overflow: hidden; touch-action: none; }

/* ── Loading overlay ── */
#loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
  background-color: var(--bg-page);
  background-image: var(--img-bg);
  background-size: cover;
  background-position: center;
  z-index: 200;
}

.loading-track {
  width: 100%; max-width: 500px;
  height: 6px; background: rgba(206,1,0,0.18);
  border-radius: 3px; overflow: hidden;
  margin-top: 30px;
}
.loading-fill {
  height: 100%; background: var(--accent);
  width: 0%;
  animation: loadingProgress 2s ease-in-out forwards;
}
@keyframes loadingProgress {
  0%   { width: 0%; }
  100% { width: 100%; }
}

/* ── Screens ── */
.screen {
  display: none;
  position: relative;
  min-height: 100svh;
  flex-direction: column;
  align-items: center;
}
.screen.active { display: flex; }

/* ── Top-left restart ── */
.restart-btn {
  position: absolute;
  top: 15px; left: 15px;
  z-index: 5;
  font-family: 'RoadRadioBlack', sans-serif;
  font-size: 0.72em; letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: none; border: none;
  cursor: pointer; padding: 4px 2px;
}

@media (max-width: 600px) {
  .restart-btn {
    top: 5px; left: 50%;
    transform: translateX(-50%);
  }
}

/* ── Global horizontal padding for all major steps ── */
.page-pad { padding-left: 15px; padding-right: 15px; }

/* ── Shared UI ── */
.f-icon {
  height: 40px;
  width: 100%;
  background-image: var(--img-monogram);
  background-size: auto 60%;
  background-repeat: no-repeat;
  background-position: center;
  margin-bottom: 5px;
}

.f-rotate {
  transform: rotate(180deg);
}

.page-title {
  font-size: clamp(1em, 5vw, 1.4em);
  line-height: 1em;
  text-align: center;
  letter-spacing: 0.04em;
  padding: 28px 20px 0;
}

.btn {
  display: block; width: 100%;
  padding: 15px 16px;
  font-family: 'RoadRadioBlack', sans-serif;
  font-size: 0.88em; letter-spacing: 0.1em; text-transform: uppercase;
  border: 2px solid var(--accent); background: transparent; color: var(--accent);
  cursor: pointer; line-height: 1; text-align: center;
  transition: background 0.15s, color 0.15s;
  -webkit-appearance: none; appearance: none;
}
.btn:hover, .btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover        { background: var(--accent-hover); }
.btn:disabled             { opacity: 0.45; cursor: default; }

input[type="email"] {
  display: block; width: 100%;
  padding: 12px; margin-bottom: 14px;
  border: 2px solid var(--accent); background: transparent;
  font-family: 'RoadRadioBlack', sans-serif; font-size: 0.9em;
  color: #000; text-align: center; outline: none;
}
input[type="email"]::placeholder { color: #aaa; }

.small-text {
  font-size: 0.7em; line-height: 1.5;
  text-align: center; color: var(--text-muted);
  margin-top: -14px;
}
.small-text a { color: var(--text-muted); }

.upload-cta {
  font-size: 0.95em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  color: var(--accent);
}

/* ── Pulse loader ── */
.pulse {
  width: 52px; height: 52px;
  background: var(--img-monogram) center / contain no-repeat;
  animation: pulse-anim 1.2s ease-in-out infinite;
}
@keyframes pulse-anim {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.3); opacity: 0.5; }
}

/* ────────────────────────────────────────────────────────── */
/* SCREEN: UPLOAD                                             */
/* ────────────────────────────────────────────────────────── */
#screen-upload {
  justify-content: center;
  gap: 20px;
  padding-bottom: 40px;
}

#upload-area {
  position: relative;
  width: 100%; max-width: 500px;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ── Upload area intro animations ── */
@keyframes frameSlideTop {
  from { transform: translateY(-110%); }
  to   { transform: translateY(0); }
}
@keyframes frameSlideBottom {
  from { transform: translateY(110%) rotate(180deg); }
  to   { transform: translateY(0)    rotate(180deg); }
}
@keyframes frameSlideBiffy {
  from { transform: translateY(-50%) translateX(-150%); }
  to   { transform: translateY(-50%) translateX(0); }
}
@keyframes frameSlideClyro {
  from { transform: translateY(-50%) translateX(150%); }
  to   { transform: translateY(-50%) translateX(0); }
}
@keyframes frameFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#upload-area .frame-top    { animation: frameSlideTop    0.7s cubic-bezier(0.4,0,0.2,1) 0s    both; }
#upload-area .frame-bottom { animation: frameSlideBottom 0.7s cubic-bezier(0.4,0,0.2,1) 0.3s  both; }
#upload-area .frame-biffy  { animation: frameSlideBiffy  0.6s cubic-bezier(0.4,0,0.2,1) 0.55s both; }
#upload-area .frame-clyro  { animation: frameSlideClyro  0.6s cubic-bezier(0.4,0,0.2,1) 0.65s both; }
#upload-area #upload-hint  { animation: frameFadeIn      0.8s ease                       0.8s  both; }

/* Frame layer images sit on top of each other */
.frame-layer {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: fill; pointer-events: none;
}

/* Dark theme only: frame background sits ~10% darker (image at 0.9 over black) */
[data-theme="dark"] #upload-area { background: #000; }
[data-theme="dark"] .frame-layer { opacity: 0.8; }

/* Upload prompt in the photo zone */
#upload-hint {
  position: absolute;
  /* matches square ZONE: { x:216, y:245, w:288, h:231 } on 720×720 */
  top:    34%;    /* 245/720 */
  left:   30%;    /* 216/720 */
  right:  30%;
  bottom: 33.9%;  /* 244/720 */
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
}

.upload-icon-img {
  width: 160px; height: 120px;
  object-fit: contain;
}

#upload-hint p {
  font-size: 0.72em; line-height: 1.4;
  text-align: center; color: rgba(206,1,0,0.55);
  max-width: 140px;
}

/* Dashed border when bg PNG not loaded */
#upload-area.no-bg {
  border: 2px dashed rgba(206,1,0,0.35);
  background: rgba(206,1,0,0.03);
}

/* ────────────────────────────────────────────────────────── */
/* SCREEN: CROP                                               */
/* ────────────────────────────────────────────────────────── */
#screen-crop {
  padding-top: 28px;
  justify-content: space-between;
  overflow: hidden;
  max-height: 100svh;
}

#crop-wrap {
  flex: 1;
  width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
  touch-action: none;
}

#crop-canvas {
  display: block;
  max-width: min(500px, 100%);
  max-height: calc(100vh - 130px);
  width: auto;
  height: auto;
  touch-action: none;
  box-shadow: var(--shadow);
}

#crop-bar {
  width: 100%; flex-shrink: 0;
  padding: 10px 0;
  display: flex; gap: 8px;
}

#crop-bar .btn.primary {
  flex: 1 1 0;
  min-width: 0;
  padding-left: 8px; padding-right: 8px;
  font-size: 0.78em; letter-spacing: 0.03em;
  white-space: nowrap;
}

#crop-switch {
  width: 100%; flex-shrink: 0;
  padding: 8px 0;
  text-align: center;
}

/* ────────────────────────────────────────────────────────── */
/* SCREEN: GENERATING                                         */
/* ────────────────────────────────────────────────────────── */
#screen-generating {
  justify-content: center; align-items: center;
  gap: 16px; padding-top: 40px; padding-bottom: 40px; text-align: center;
}

.loader-img {
  width: 140px; height: 140px;
  object-fit: contain;
  animation: pulse-anim 1.2s ease-in-out infinite;
}

.progress-track {
  width: 100%; max-width: 500px;
  height: 6px; background: rgba(206,1,0,0.18);
  border-radius: 3px; overflow: hidden;
  margin-top: 30px;
}
#progress-fill {
  height: 100%; background: var(--accent); width: 0%;
  transition: width 0.4s ease;
}

#status-msg {
  font-size: 0.75em; letter-spacing: 0.06em;
  color: var(--text-muted); min-height: 1.4em;
}

.gen-note {
  font-size: 0.65em; color: #999; max-width: 260px; line-height: 1.5;
}

/* ────────────────────────────────────────────────────────── */
/* SCREEN: RESULT                                             */
/* ────────────────────────────────────────────────────────── */
#screen-result {
  padding-top: 28px;
  justify-content: space-between;
  overflow: hidden;
  max-height: 100svh;
}

#result-wrap {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  overflow: hidden;
}

#video-wrap {
  position: relative;
  flex-shrink: 1;
  min-height: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* Story (9:16): tall — fill the height, cap the width */
#video-wrap.story {
  aspect-ratio: 9 / 16;
  height: 100%;
  max-height: 100%;
  width: auto;
  max-width: min(340px, 100%);
}

/* Square (1:1): wide — drive by width up to 500px */
#video-wrap.square {
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: min(500px, 100%);
  height: auto;
  max-height: 100%;
}

#result-bar {
  width: 100%; flex-shrink: 0;
  padding: 10px 0;
  display: flex; gap: 8px;
}
#result-bar .btn { flex: 1 1 0; min-width: 0; }

.media-overlay-btn {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  padding: 16px 22px;
  background: var(--accent);
  color: #fff;
  font-family: 'RoadRadioBlack', sans-serif;
  font-size: 0.8em; letter-spacing: 0.12em;
  border: none; cursor: pointer;
}
.media-overlay-btn.show { display: flex; }

#mute-btn {
  position: absolute;
  bottom: 10px; right: 10px;
  z-index: 4;
  display: none;
  align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: var(--accent);
  color: #fff;
  border: none; border-radius: 50%;
  cursor: pointer;
}
#mute-btn.show { display: flex; }

#video-player,
#image-player { width: 100%; height: 100%; display: block; object-fit: cover; }
#image-player { display: none; }

#compat-note {
  display: none;
  font-size: 0.68em; color: var(--text-muted);
  text-align: center; max-width: 320px;
  line-height: 1.5;
}

/* ── Format picker screen ── */
#screen-format {
  justify-content: center; align-items: center;
  gap: 24px; padding-top: 32px; padding-bottom: 32px;
}

.format-buttons {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; max-width: 340px;
}

/* ── Sign-up screen ── */
#screen-signup {
  justify-content: center; align-items: center;
  padding-top: 40px; padding-bottom: 48px; gap: 0;
}

#signup-inner {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px;
}

#signup-inner > p {
  font-size: 0.72em; line-height: 1.5; color: #333;
}

#signup-inner > .signup-intro {
  font-size: 1em;
  line-height: 1.4;
  text-align: center;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.checkbox-row {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 0.68em; line-height: 1.5; color: var(--text-muted);
}
.checkbox-row a { color: var(--text-muted); }
.checkbox-row input[type="checkbox"] {
  margin-top: 3px; flex-shrink: 0;
  width: 16px; height: 16px; cursor: pointer;
  accent-color: var(--accent);
}

#signup-error {
  font-size: 0.8em; font-weight: bold; color: #000;
  text-align: center;
  padding: 10px 0;
}
#signup-error:empty { padding: 0; }

#signup-submit { margin-top: 20px; }

.reset-link {
  font-size: 0.75em; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
  text-align: center;
}

/* ── Frame overlay system ── */
.frame-top,
.frame-bottom {
  position: absolute;
  left: 0; right: 0;
  z-index: 2; pointer-events: none;
  padding: 3%;
}
.frame-top    { top: 0; }
.frame-bottom { bottom: 0; transform: rotate(180deg); }

.frame-venue   { width: 100%; height: auto; display: block; margin-bottom: 3%; }
.frame-futique { width: 100%; height: auto; display: block; }

.frame-biffy,
.frame-clyro {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  height: auto; max-width: 12%;
  z-index: 3; pointer-events: none;
}
.frame-biffy { left: 3%; }
.frame-clyro { right: 3%; }

/* ── Footer ── */
footer {
  width: 100%; text-align: center;
  font-size: 0.62em; padding: 5px 0;
  color: var(--text-muted); line-height: 1.2em;
}
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { text-decoration: underline; }
.fsep { margin: 0 5px; }
