:root {
  --red: #c41b14;
  --red-edge: #b51c14;
  /* Gliding headline. Lighter alternative: #e2725f (white at ~32% over the red). */
  --glide: #9e130d;
  --cream: #fff6dc;
  --brown: #52220d;

  --display: "Dela Gothic One", "Arial Black", sans-serif;
  --body: "Figtree", system-ui, sans-serif;
  --arabic: "Almarai", system-ui, sans-serif;

  /* Shared by the 3D scene and the CSS parallax layers (-1 to 1). */
  --px: 0;
  --py: 0;

  color-scheme: light;
}

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

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

body {
  overflow: hidden;
  background: var(--red);
  color: var(--cream);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

html[lang="ar"] body {
  font-family: var(--arabic);
}

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

/* One screen: header, stage, outro. */
.screen {
  position: relative;
  height: 100vh;
  height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

/* ---------- Animated red glow ---------- */

.bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--red-edge);
}

/* Each glow is centered on its left/top point; `transform` is left free for the animation. */
.bg__glow {
  position: absolute;
  translate: -50% -50%;
  border-radius: 50%;
  will-change: transform;
}

.bg__glow--halo {
  left: 50%;
  top: 48%;
  width: 100vw;
  height: 115vh;
  background: radial-gradient(closest-side, #e3341f 0%, rgba(227, 52, 31, 0.65) 45%, rgba(181, 28, 20, 0) 100%);
  animation: breathe 14s ease-in-out infinite alternate;
}

.bg__glow--lobe {
  left: 63%;
  top: 54%;
  width: 46vw;
  height: 62vh;
  background: radial-gradient(closest-side, rgba(232, 56, 32, 0.8), rgba(232, 56, 32, 0));
  animation: sway 19s ease-in-out infinite alternate;
}

.bg__glow--core {
  left: 51%;
  top: 47%;
  width: 34vw;
  height: 40vh;
  background: radial-gradient(closest-side, rgba(251, 98, 64, 0.95) 0%, rgba(251, 98, 64, 0.45) 50%, rgba(251, 98, 64, 0) 100%);
  animation: pulse 11s ease-in-out infinite alternate;
}

@keyframes breathe {
  to {
    transform: scale(1.08) translate(1vw, 1vh);
  }
}

@keyframes sway {
  to {
    transform: translate(-14vw, -4vh) scale(1.1);
  }
}

@keyframes pulse {
  to {
    transform: translate(3vw, 3vh) scale(1.15);
  }
}

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

.header {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: center;
  padding: clamp(14px, 2.4vh, 28px) 20px 0;
}

.logo {
  margin: 0;
  line-height: 0;
}

.logo img {
  display: block;
  width: clamp(120px, 14vw, 240px);
  height: auto;
}

/* Mirrors the language switch on the opposite side of the logo. */
.handle {
  position: absolute;
  inset-inline-start: clamp(16px, 4vw, 56px);
  top: clamp(16px, 2.6vh, 30px);
  padding: 10px 0;
  border-bottom: 1.5px solid transparent;
  color: var(--cream);
  font-family: var(--display);
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
  transition: border-color 0.2s ease;
}

.handle:hover {
  border-bottom-color: currentColor;
}

.handle:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 3px;
}

.lang {
  position: absolute;
  inset-inline-end: clamp(16px, 4vw, 56px);
  top: clamp(16px, 2.6vh, 30px);
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1.5px solid rgba(255, 246, 220, 0.45);
  border-radius: 999px;
}

.lang button {
  min-width: 38px;
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--cream);
  font-family: var(--display);
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.lang button[lang="ar"] {
  font-family: var(--arabic);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.lang button:hover {
  background: rgba(255, 246, 220, 0.16);
}

.lang button[aria-pressed="true"] {
  background: var(--cream);
  color: var(--red);
}

.lang button:focus-visible,
.social a:focus-visible,
.contact a:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 3px;
}

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

.stage {
  position: relative;
  z-index: 1;
  overflow: hidden;
  isolation: isolate;
}

/* Gliding headline, sits behind the candy. */
.glide {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  overflow: hidden;
  direction: ltr;
  pointer-events: none;
}

.glide__track {
  display: flex;
  width: max-content;
  animation: glide 26s linear infinite;
}

.glide span {
  padding-inline-end: 0.45em;
  font-family: var(--display);
  font-size: clamp(64px, 10.5vw, 210px);
  line-height: 1.05;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--glide);
}

/* Each phrase reads right to left while the track itself keeps gliding left. */
html[lang="ar"] .glide span {
  direction: rtl;
  unicode-bidi: isolate;
  font-family: var(--arabic);
  font-size: clamp(64px, 10.5vw, 210px);
  font-weight: 800;
  line-height: 1.3;
}

@keyframes glide {
  to {
    transform: translateX(-50%);
  }
}

/* Blurred chocolate pieces with cursor parallax (depth set per piece). */
.piece {
  --depth: 0;
  position: absolute;
  z-index: 2;
  pointer-events: none;
  transform: translate(calc(var(--px) * var(--depth) * 1px), calc(var(--py) * var(--depth) * -1px)) rotate(var(--rotate, 0deg));
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.piece--back {
  --depth: -14;
  --rotate: -8deg;
  width: clamp(110px, 12vw, 220px);
  left: 26%;
  top: 30%;
  filter: blur(9px);
}

.piece--top {
  --depth: -24;
  --rotate: -30deg;
  width: clamp(60px, 6vw, 120px);
  left: 42%;
  top: 4%;
  filter: blur(14px);
  opacity: 0.85;
}

.piece--front {
  --depth: 32;
  --rotate: 160deg;
  z-index: 4;
  width: clamp(150px, 17vw, 320px);
  right: 22%;
  bottom: 10%;
  filter: blur(12px);
}

.candy-shadow {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 78%;
  width: min(38vw, 520px);
  height: min(7vw, 90px);
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(90, 6, 4, 0.45), rgba(90, 6, 4, 0));
  pointer-events: none;
}

/* Still image of the candy, shown until the 3D model is ready. */
.candy-poster {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  width: min(66vh, 86vw);
  height: auto;
  transform: translate(-50%, -50%);
  transition: opacity 0.6s ease;
}

#candy {
  position: absolute;
  z-index: 3;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.is-3d-ready .candy-poster {
  opacity: 0;
}

.is-3d-ready #candy {
  opacity: 1;
}

/* ---------- Message and social icons ---------- */

.outro {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 2.4vh, 26px);
  padding: 0 20px clamp(16px, 3vh, 36px);
  padding-bottom: max(clamp(16px, 3vh, 36px), env(safe-area-inset-bottom));
  text-align: center;
}

.message {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(18px, 1.9vw, 30px);
  line-height: 1.2;
  text-transform: uppercase;
}

/* French words inside the Arabic message keep the Latin display font of the FR version. */
html[lang="ar"] .message .latin {
  font-family: var(--display);
  font-size: 0.86em;
  text-transform: uppercase;
}

/* "En attendant, كول كبريسة" mixes French and Arabic: let the first word set the reading direction. */
html[lang="ar"] .message {
  unicode-bidi: plaintext;
  font-family: var(--arabic);
  font-size: clamp(22px, 2.2vw, 34px);
  font-weight: 800;
  text-transform: none;
}

.follow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.follow__label {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.follow__label strong {
  margin-inline-start: 6px;
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.02em;
}

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

/* Large round icons, like the "Caprice se partage aussi en ligne" section. */
.social {
  display: flex;
  justify-content: center;
  gap: clamp(12px, 1.6vw, 26px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.social a {
  display: grid;
  place-items: center;
  width: clamp(54px, 4.8vw, 86px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 246, 220, 0.16);
  color: var(--cream);
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.social a:hover {
  background: var(--cream);
  color: var(--red);
  transform: translateY(-3px);
}

.social svg {
  display: block;
  width: auto;
  height: 46%;
  fill: currentColor;
}

.contact {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 20px;
  margin: 2px 0 0;
  font-size: 48px;
  font-weight: 500;
}

.contact a {
  color: var(--cream);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.contact a:hover {
  border-bottom-color: currentColor;
}

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

@media (max-width: 760px) {
  .header {
    justify-content: flex-start;
    padding-inline: 16px;
  }

  .lang {
    top: 18px;
  }

  /* The logo takes this corner on phones; the handle still shows above the icons. */
  .handle {
    display: none;
  }

  .glide span {
    font-size: clamp(56px, 19vw, 120px);
  }

  html[lang="ar"] .glide span {
    font-size: clamp(56px, 19vw, 120px);
  }

  .piece--back {
    left: 4%;
    top: 22%;
  }

  .piece--top {
    left: 60%;
    top: 6%;
  }

  .piece--front {
    right: -6%;
    bottom: 14%;
  }

  .candy-shadow {
    width: 70vw;
    height: 14vw;
    top: 76%;
  }

  .candy-poster {
    width: 92vw;
  }

  .message {
    max-width: 20ch;
  }

  .contact {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg__glow {
    animation: none;
  }

  .glide__track {
    animation-duration: 90s;
  }

  .piece {
    transition: none;
  }
}
