/* ==========================================================================
   SAMEDAY TV – Telenovela Black Friday
   Mobile-first: every frame is a 390 × 844 "phone" column, centered on desktop.
   ========================================================================== */

:root {
  --red: #ed1c24;
  --black: #000;
  --grey-disabled: #c7ccd0;
  --frame-w: 390px;
  --frame-h: 844px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

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

html, body { margin: 0; min-height: 100%; background: #000; overflow-x: hidden; }

body {
  font-family: var(--font);
  font-weight: 400;
  color: #fff;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

img { display: block; max-width: none; }
h1, h2, p, fieldset, legend { margin: 0; padding: 0; }
fieldset { border: 0; min-width: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

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

/* ---------- App shell ---------- */
.app {
  width: var(--frame-w);
  margin: 0 auto;
  zoom: var(--ui-scale, 1); /* shrinks the 390px frame on narrower phones; set by js/main.js */
}

.screen {
  position: relative;
  width: var(--frame-w);
  height: var(--frame-h);
  overflow: hidden;
  background: var(--black);
  /* silver diagonal, tuned per screen with these variables */
  --angle: 128deg;
  --s1: 77.33%;
  --s2: 84.24%;
  --s3: 91.87%;
}

.screen > *:not(.bg):not(.quiz):not(.form) { position: absolute; }

.screen--intro   { --angle: 128.74deg; --s1: 53.04%; --s2: 62.19%; --s3: 71.96%; }
.screen--quiz    { --angle: 127.86deg; --s1: 60.32%; --s2: 69.17%; --s3: 76.49%; }
.screen--form,
.screen--error   { --angle: 128.1deg;  --s1: 77.33%; --s2: 84.24%; --s3: 91.87%; }
.screen--loading,
.screen--result  { --angle: 129.08deg; --s1: 87.58%; --s2: 92.32%; --s3: 97.56%; }
.screen--thanks  { --s1: 101%; --s2: 102%; --s3: 103%; }

/* ---------- Backgrounds ---------- */
.bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    var(--angle),
    #000 var(--s1),
    #77787a calc(var(--s1) + .01%),
    #b2b3b6 var(--s2),
    #d0d1d5 calc(var(--s2) + .01%),
    #dfe0e4 var(--s3),
    #eeeff3 calc(var(--s3) + .01%)
  );
}

.bg__petals {
  position: absolute;
  left: -103px;
  top: 0;
  width: 536px;
  height: 953px;
  object-fit: cover;
  object-position: bottom;
}

/* the petals only show over the black part of the diagonal split */
.bg__petals--small { clip-path: polygon(103px 0, 493px 0, 493px 184px, 103px 714.5px); }
.bg__petals--large { clip-path: polygon(103px 0, 493px 0, 516px 665px, 103px 1154.5px); }
.bg__petals--thanks { left: -73px; top: -8px; clip-path: none; }

.bg__corner {
  position: absolute;
  left: 187px;
  top: -95px;
  width: 404px;
  height: 393px;
  object-fit: cover;
}
.bg__corner--thanks { left: 149px; top: -141px; width: 478px; height: 465px; }

/* ---------- Brand header ---------- */
.brand { position: absolute; inset: 0 0 auto 0; height: 130px; z-index: 2; }
.brand__logo { position: absolute; top: 47px; left: 88px; width: 183px; height: auto; }
.brand__tagline {
  position: absolute; top: 104px; left: 30px;
  font-size: 14.4px; font-weight: 800; white-space: nowrap;
}

/* ---------- Shared text blocks ---------- */
.center-title { left: 0; width: 100%; padding: 0 37px; text-align: center; font-weight: 800; line-height: normal; }
.center-title--lg { top: 210px; font-size: 24px; }
.accent { color: var(--red); }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: space-between;
  border: 0; border-radius: 13px; background: var(--red); color: #fff;
  text-decoration: none; font-weight: 800; white-space: nowrap;
  box-shadow: 0 0 6px rgba(0, 0, 0, .03);
}
.btn:disabled { background: var(--grey-disabled); cursor: default; }

.btn--cta {
  position: absolute; left: 45px; top: 741px;
  width: 300px; height: 53px; padding: 0 25px 0 40px;
  font-size: 20px; z-index: 2;
}
.btn--cta img { width: 50px; height: 50px; }
.btn--xl { font-size: 24px; padding-left: 33px; }

.btn--action { width: 300px; height: 42px; padding: 0 15px; font-size: 16px; left: 45px; z-index: 2; }
.btn--action img { width: 24px; height: 24px; }

.btn--small { width: 226px; height: 42px; padding: 0 18px 0 20px; font-size: 16px; }
.btn--small img { width: 20px; height: 20px; }

/* ---------- Frame 0 · Intro ---------- */
.intro__title {
  top: 212px; left: 21px; width: 348px;
  text-align: center; font-size: 24px; font-weight: 800; line-height: normal; z-index: 2;
}
.intro__title .accent { display: block; }
.intro__text {
  top: 280px; left: 21px; width: 348px;
  text-align: center; font-size: 15px; z-index: 2;
}
.intro__poster {
  top: 335px; left: 99px; width: 192px; height: 342px; object-fit: cover; z-index: 2;
}
.intro__spoiler {
  top: 705px; left: 0; width: 100%;
  text-align: center; color: var(--red); font-size: 16px; font-weight: 800; z-index: 2;
}

/* ---------- Frame 1 · Quiz ---------- */
.quiz { position: absolute; inset: 0; z-index: 2; }
.quiz__fieldset { position: absolute; inset: 0; }
.quiz__title {
  position: absolute; top: 210px; left: 50px; width: 316px;
  font-size: 24px; font-weight: 800; line-height: normal;
}
.quiz__options {
  position: absolute; top: 348px; left: 45px; width: 300px;
  display: flex; flex-direction: column; gap: 26px;
}

.option { display: block; cursor: pointer; }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option span {
  display: flex; align-items: center; min-height: 59px; padding: 8px 22px; line-height: normal;
  border: 1px solid transparent; border-radius: 13px; background: #fff;
  color: #000; font-size: 16px; box-shadow: 0 0 6px rgba(0, 0, 0, .03);
}
.option span { justify-content: space-between; transition: background .15s, color .15s, box-shadow .15s; }
.option input:checked + span {
  border-color: #fff; background: var(--red); color: #fff; font-weight: 700; letter-spacing: -.1px;
  box-shadow: 0 0 0 3px rgba(237, 28, 36, .45), 0 6px 18px rgba(237, 28, 36, .45);
}
.option input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---------- Frame 2 / 2B · Form ---------- */
.form { position: absolute; inset: 0; z-index: 2; }

.form__title { position: absolute; top: 210px; left: 50px; font-size: 24px; font-weight: 800; }
.form__intro { position: absolute; top: 270px; left: 50px; width: 314px; font-size: 16px; }

.field {
  position: absolute; left: 45px; width: 300px; height: 42px;
  display: flex; align-items: center;
  border: 1px solid var(--red); border-radius: 13px; background: #fff;
  color: #000; font-size: 16px; box-shadow: 0 0 6px rgba(0, 0, 0, .03);
}
.field--upload { top: 349px; justify-content: space-between; padding: 0 10px 0 12px; cursor: pointer; }
.field__icons { display: flex; gap: 13px; }
.field__icons img { width: 24px; height: 24px; }

.field--text { top: 413px; }
.field--text input {
  width: 100%; height: 100%; padding: 0 12px;
  border: 0; outline: 0; border-radius: inherit; background: transparent; color: #000;
}
.field--text input::placeholder { color: #000; opacity: 1; }
.field--text input:focus ~ .field__cursor,
.field--text input:not(:placeholder-shown) ~ .field__cursor { display: none; }
.field__cursor { position: absolute; top: 13px; left: 127px; width: 14px; height: 14px; pointer-events: none; }
.field:focus-within { outline: 2px solid var(--red); outline-offset: 2px; }

.gender { position: absolute; top: 477px; left: 45px; width: 300px; }
.gender legend { margin: 0 0 9px 5px; font-size: 16px; }
.gender__options { display: flex; gap: 9px; }

.choice { cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex; align-items: center; justify-content: space-between;
  width: 144px; height: 42px; padding: 0 10px 0 12px;
  border: 1px solid #374957; border-radius: 13px; background: #fff; color: #000; font-size: 16px;
}
.choice span::after {
  content: ""; width: 24px; height: 24px;
  background: url("../assets/icons/check-off.svg") center / contain no-repeat;
}
.choice input:checked + span { width: 147px; border-color: var(--red); }
.choice input:checked + span::after { background-image: url("../assets/icons/check-on.svg"); }
.choice input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }

.consent { position: absolute; top: 584px; left: 46px; width: 303px; display: block; font-size: 13px; line-height: normal; cursor: pointer; }
.consent a { color: #0dc3db; text-decoration: underline; }
/* unchecked = empty box; check-white.svg already carried a check mark and read as "ticked" */
.consent input {
  position: absolute; top: 96px; right: 11px; width: 24px; height: 24px; margin: 0;
  appearance: none; -webkit-appearance: none;
  box-sizing: border-box; border: 2px solid #fff; border-radius: 6px; background: transparent;
}
.consent input:checked { border: 0; background: url("../assets/icons/check-on.svg") center / contain no-repeat; }
.consent input:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* "daily limit reached" message above the generate button */
.form__limit {
  position: absolute; left: 45px; top: 706px; width: 300px; padding: 7px 10px;
  border-radius: 10px; background: #fff; color: var(--red);
  font-size: 13px; font-weight: 800; text-align: center;
}
.form__limit[hidden] { display: none; }

/* ---------- Frame 3 · Loading ---------- */
.loading__note { top: 283px; left: 38px; width: 314px; text-align: center; font-size: 16px; }
.spinner { top: 422px; left: 116px; width: 158px; height: 158px; animation: spin 1.2s steps(8) infinite; }
.loading__chosen { top: 486px; left: 0; width: 100%; padding: 0 26px; text-align: center; font-size: 24px; font-weight: 800; line-height: normal; z-index: 2; }

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 4s; } }

/* ---------- Frame 4 · Result ---------- */
.result__title { top: 203px; left: 0; width: 100%; text-align: center; font-size: 24px; font-weight: 800; z-index: 2; }
.result__poster { top: 269px; left: 68px; width: 253px; height: 432px; z-index: 2; }
.result__brackets { position: absolute; inset: 0; width: 253px; height: 432px; }
.result__image { position: absolute; top: 13px; left: 13px; width: 228px; height: 406px; object-fit: cover; }
.result__download { top: 752px; }


/* ---------- Frame 4 · Share sheet ---------- */
.sheet { inset: 0; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .65); }
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; gap: 12px;
  padding: 24px 45px 28px;
  border-radius: 22px 22px 0 0; background: #121212;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .6);
  animation: sheet-in .22s ease-out;
}
.sheet__title { margin-bottom: 4px; text-align: center; font-size: 18px; font-weight: 800; }
.sheet__option {
  display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 16px;
  border: 0; border-radius: 13px; background: #fff; color: #000; font-size: 16px; font-weight: 800;
}
.sheet__option svg { width: 24px; height: 24px; flex: none; color: var(--red); }
.sheet__option:focus-visible, .sheet__close:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.sheet__close { height: 40px; border: 0; background: none; color: #c7ccd0; font-size: 15px; }
.toast {
  left: 24px; right: 24px; bottom: 120px; z-index: 11; padding: 12px 14px;
  border-radius: 13px; background: #fff; color: #000; font-size: 14px; font-weight: 800; text-align: center;
}
.toast[hidden] { display: none; }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Frame 5 · Thanks ---------- */
.thanks__openway { top: 72px; left: 67px; width: 256px; height: 59px; object-fit: cover; z-index: 2; }
.thanks__title { top: 203px; left: 0; width: 100%; text-align: center; font-size: 24px; font-weight: 800; z-index: 2; }
.thanks__copy { top: 332px; left: 61px; width: 269px; text-align: center; font-size: 14px; line-height: normal; z-index: 2; }
.thanks__social { top: 497px; left: 0; width: 100%; text-align: center; font-size: 20px; font-weight: 800; z-index: 2; }
.thanks__tagline { top: 526px; left: 0; width: 100%; text-align: center; font-size: 14.4px; font-weight: 800; white-space: nowrap; z-index: 2; }
.thanks__back { top: 592px; left: 0; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; font-size: 14px; font-weight: 700; text-decoration: underline; text-align: center; cursor: pointer; z-index: 2; }
.thanks__share { top: 658px; }
.thanks__retry { top: 752px; }
/* text centred in the space left of the icon; the icon sits 55px from the right edge */
.thanks__share, .thanks__retry { padding: 0 55px 0 25px; }
.thanks__share span, .thanks__retry span { flex: 1; text-align: center; }
.thanks__retry img { width: 20px; height: 20px; }
.icon-rotate { transform: rotate(-90deg); }

/* ---------- Error ---------- */
.error__title { top: 269px; font-size: 20px; }
.error__label { top: 343px; left: 0; width: 100%; text-align: center; color: var(--red); font-size: 16px; font-weight: 800; }
.error__x { top: 388px; left: 107px; width: 177px; height: 178px; object-fit: cover; }
.error__retry { top: 593px; font-size: 20px; }

/* ---------- Dev frame picker (only with ?dev in the URL) ---------- */
.devbar {
  position: fixed; top: 8px; left: 8px; z-index: 99; display: flex; flex-direction: column; gap: 4px;
  padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, .92); font-size: 12px;
}
.devbar a { color: #111; text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.devbar a.is-current { background: var(--red); color: #fff; }

/* ==========================================================================
   Desktop (≥ 1024px): branded full-width stage + centered, scaled-up card.
   Everything above is the untouched mobile design.
   ========================================================================== */
@media (min-width: 1024px) {
  body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 0;
    background: linear-gradient(
      128deg,
      #000 82%,
      #77787a 82.01%,
      #b2b3b6 90%,
      #d0d1d5 90.01%,
      #dfe0e4 96%,
      #eeeff3 96.01%
    );
  }

  /* petals + red corner, same artwork as the mobile frames */
  body::before,
  body::after {
    content: "";
    position: fixed;
    pointer-events: none;
  }
  body::before {
    inset: 0;
    background: url("../assets/img/bg-petals-dim.png") center 70% / cover no-repeat;
    clip-path: polygon(0 0, 100% 0, 100% 68%, 62% 100%, 0 100%);
  }
  body::after {
    top: -6vw;
    right: -2vw;
    width: 34vw;
    height: 33vw;
    background: url("../assets/img/red-corner.png") center / cover no-repeat;
  }

  /* one background only: the page stage above replaces each frame's own backdrop */
  .screen { background: none; }
  .screen > .bg { display: none; }

  /* the 390px content column floats on the stage; --ui-scale is set by js/main.js to fit the window height */
  .app {
    position: relative;
    z-index: 1;
  }
}

/* Turnstile box over Generate */
.turnstile { position: absolute; left: 45px; top: 735px; width: 300px; z-index: 3; line-height: 0; }
.turnstile:empty, .turnstile[hidden] { display: none; }
