/* ============================================================
   كمل — Stadium Editorial Poster
   Flat surfaces, oversized type, echo strokes, frame, ticker.
   No gradients, no glow — depth comes from layering and motion.
   ============================================================ */

:root {
  /* Color */
  --color-bg: #0a0c12;
  --color-surface: #12151d;
  --color-border: rgba(255, 255, 255, 0.14);
  --color-border-strong: rgba(255, 255, 255, 0.3);
  --color-text: #ffffff;
  --color-text-muted: rgba(255, 255, 255, 0.66);
  --color-accent: #2bc257;
  --color-echo: rgba(255, 255, 255, 0.22);

  /* Spacing (8pt) */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-6: 48px;
  --space-8: 64px;

  /* Frame */
  --frame-inset: 12px;

  /* Type */
  --font-arabic: "Tajawal", system-ui, -apple-system, sans-serif;
  --font-latin: "Inter", system-ui, -apple-system, sans-serif;
  --font-display-latin: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-sans: var(--font-arabic);

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration: 480ms;
  --duration-micro: 200ms;

  /* Shadow */
  --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-btn-hover: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ---------- Reset ---------- */

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

html {
  height: 100%;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Language-driven typography */
html[lang="en"] body {
  --font-sans: var(--font-latin);
}

html[lang="en"] .headline,
html[lang="en"] .brand__name {
  font-family: var(--font-display-latin);
  letter-spacing: -0.03em;
  /* Space Grotesk tops out at 700 — avoid faux-bold */
  font-weight: 700;
}

html[lang="en"] .headline__close {
  font-weight: 700;
}

html[lang="ar"] .headline,
html[lang="ar"] .brand__name {
  letter-spacing: 0;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

a,
button {
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- Skip link ---------- */

.skip-link {
  position: fixed;
  top: 16px;
  inset-inline-start: 16px;
  z-index: 100;
  padding: 12px 20px;
  background-color: var(--color-text);
  color: var(--color-bg);
  border-radius: 10px;
  font-weight: 700;
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* ---------- Background ---------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--color-bg);
}

.bg__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  transform: scale(1.06);
  will-change: transform;
}

.bg__scrim {
  position: absolute;
  inset: 0;
  background-color: rgba(8, 10, 16, 0.86);
}

/* Film grain — flat SVG noise, no gradients */
.bg__grain {
  position: absolute;
  inset: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* ---------- Opening curtain ---------- */

.curtain {
  display: none;
}

html.js .curtain {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.curtain__panel {
  position: absolute;
  inset-inline: 0;
  height: 50.5%;
  background-color: var(--color-bg);
  transition: transform 560ms var(--ease-out) 280ms;
}

.curtain__panel--top {
  top: 0;
}

.curtain__panel--bottom {
  bottom: 0;
}

.curtain__logo {
  position: relative;
  z-index: 1;
  width: 72px;
  height: 72px;
  transition: opacity 260ms ease, transform 260ms ease;
  transition-delay: 160ms;
}

body.is-loaded .curtain__panel--top {
  transform: translateY(-101%);
}

body.is-loaded .curtain__panel--bottom {
  transform: translateY(101%);
}

body.is-loaded .curtain__logo {
  opacity: 0;
  transform: scale(0.92);
}

body.is-loaded .curtain {
  visibility: hidden;
  transition: visibility 0s 950ms;
}

/* ---------- Poster frame ---------- */

.frame {
  position: fixed;
  inset: var(--frame-inset);
  z-index: 60;
  border: 1px solid var(--color-border);
  pointer-events: none;
}

/* ---------- Layout ---------- */

.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--space-3);
  padding-inline: max(var(--space-3), env(safe-area-inset-left), env(safe-area-inset-right));
  padding-bottom: calc(var(--frame-inset) + var(--space-1));
}

/* ---------- Header ---------- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding-top: var(--space-1);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand__logo {
  width: 40px;
  height: 40px;
}

.brand__name {
  font-size: 22px;
  font-weight: 700;
}

.lang-toggle {
  min-height: 44px;
  min-width: 64px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-text);
  background-color: transparent;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 18px;
  transition:
    border-color var(--duration-micro) var(--ease-out),
    background-color var(--duration-micro) var(--ease-out),
    transform var(--duration-micro) var(--ease-out);
}

.lang-toggle:hover {
  border-color: var(--color-border-strong);
  background-color: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.lang-toggle:active {
  transform: scale(0.97);
  transition-duration: 80ms;
}

.lang-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* ---------- Stage ---------- */

.stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding-block: var(--space-4);
}

/* ---------- Headline stack ---------- */

.headline {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-weight: 800;
}

.mask {
  display: block;
  overflow: hidden;
  /* Room for Arabic ascenders/diacritics inside the clip */
  padding-block: 0.08em;
}

.mask--word {
  padding-block: 0.1em;
}

.headline__kicker {
  display: block;
  font-size: clamp(22px, 4vw, 36px);
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: inherit;
}

.headline__word {
  display: block;
  position: relative;
  z-index: 2;
  font-size: clamp(88px, 22vw, 230px);
  line-height: 1;
  color: var(--color-accent);
  /* Lifts the word off the phone screen when they cross */
  text-shadow: 0 3px 28px rgba(0, 0, 0, 0.4);
}

/* Stroked echo repeats — pure outline, flat, decorative */
.headline__echo {
  display: block;
  font-size: clamp(88px, 22vw, 230px);
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--color-echo);
  user-select: none;
  pointer-events: none;
  margin-bottom: -0.46em;
}

.headline__echo--below {
  margin-bottom: 0;
  margin-top: -0.46em;
}

.headline__close {
  display: block;
  position: relative;
  z-index: 2;
  margin-top: 0.2em;
  font-size: clamp(30px, 6vw, 56px);
  font-weight: 800;
}

/* ---------- Actions ---------- */

.actions {
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

.store-btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 200px;
  min-height: 56px;
  padding: 14px 24px;
  background-color: var(--color-text);
  color: var(--color-bg);
  border-radius: 14px;
  box-shadow: var(--shadow-btn);
  /* Magnetic drift rides the translate property; hover/press ride transform */
  translate: var(--mx, 0px) var(--my, 0px);
  transition:
    translate 300ms var(--ease-out),
    transform var(--duration-micro) var(--ease-out),
    box-shadow var(--duration-micro) var(--ease-out),
    background-color var(--duration-micro) var(--ease-out),
    border-color var(--duration-micro) var(--ease-out);
}

.store-btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-btn-hover);
}

.store-btn:active {
  transform: scale(0.97);
  transition-duration: 80ms;
}

.store-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.store-btn--secondary {
  background-color: rgba(18, 21, 29, 0.85);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  box-shadow: none;
}

.store-btn--secondary:hover {
  background-color: var(--color-surface);
  border-color: var(--color-border-strong);
  box-shadow: none;
}

.store-btn__icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.store-btn__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: start;
  line-height: 1.25;
}

.store-btn__text small {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.62;
}

.store-btn--secondary .store-btn__text small {
  opacity: 0.78;
}

.store-btn__text strong {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
  direction: ltr;
}

/* ---------- Phone ---------- */

.phone {
  position: relative;
  z-index: 1;
  width: min(280px, 64vw);
  margin-top: var(--space-6);
}

/* Tilt lives on its own layer so the JS transform never fights
   the reveal transition on the wrapper above */
.phone__tilt {
  rotate: -6deg;
  will-change: transform;
}

.phone__image {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 30px 50px rgba(0, 0, 0, 0.55));
  animation: phone-float 7s ease-in-out infinite;
}

@keyframes phone-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}

/* ---------- Reveal motion ---------- */

html.js [data-reveal] {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity var(--duration) var(--ease-out),
    transform var(--duration) var(--ease-out);
  transition-delay: var(--d, 0ms);
}

body.is-loaded [data-reveal] {
  opacity: 1;
  transform: translateY(0);
}

/* Headline lines rise out of their masks */
html.js .mask .line {
  display: block;
  transform: translateY(115%);
  transition: transform 680ms var(--ease-out);
  transition-delay: var(--d, 0ms);
}

body.is-loaded .mask .line {
  transform: translateY(0);
}

/* Language switch crossfade */
.page {
  transition: opacity 220ms var(--ease-out);
}

body.is-switching .page {
  opacity: 0;
}

/* ---------- Desktop: poster composition ---------- */

@media (min-width: 1024px) {
  .page {
    padding: var(--space-4) var(--space-6);
    padding-bottom: calc(var(--frame-inset) + var(--space-1));
  }

  .stage {
    align-items: flex-start;
    text-align: start;
    justify-content: center;
  }

  .headline {
    align-items: flex-start;
  }

  .actions {
    justify-content: flex-start;
  }

  /* Echo strokes stretch across and settle under the phone */
  .headline__echo {
    align-self: stretch;
    text-align: end;
  }

  /* The phone leaves the flow and leans over the echo strokes */
  .phone {
    position: absolute;
    inset-inline-end: 4%;
    top: 50%;
    translate: 0 -50%;
    width: clamp(300px, 28vw, 400px);
    margin-top: 0;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html.js [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }

  html.js .mask .line {
    transform: none;
    transition: none;
  }

  html.js .curtain {
    display: none;
  }

  .phone__image {
    animation: none;
  }

  .store-btn,
  .store-btn:hover,
  .store-btn:active,
  .lang-toggle:hover,
  .lang-toggle:active {
    transform: none;
    translate: 0 0;
    transition: none;
  }
}
