/* ==========================================================================
   csw.css — page du projet CSW (Custom Simple Waters)
   Plage : sable texturé (header plus foncé, page en fondu clair → foncé),
   marées en SVG dans le header, contenu "enfoncé" dans le sable.
   ========================================================================== */

.csw {
  /* Palette (provisoire) */
  --csw-sand-header: #e3bd88; /* sable du header, plus foncé */
  --csw-sand-top: #f0cf9c;    /* haut de page, plus foncé : côté berge (header) */
  --csw-sand-bottom: #f7e9d3; /* bas de page, plus clair */
  --csw-page-grain-fade: 35%; /* atténuation du grain sur la page (0 % = grain du header) */
  --csw-ink: #6e4a2c;         /* texte sur le sable */
  --csw-engraved: #c48f65;    /* texte gravé (titre) */
  --csw-water: #2bbfd8;

  --csw-sand-grain: url("../../ressources/csw/sand-grain.svg");
  --csw-header-h: clamp(64px, 5vw, 100px);

  min-height: 100svh;
  color: var(--csw-ink);
  /* Le voile du dessus reprend le même fondu en semi-transparent :
     il adoucit le grain sans changer les couleurs */
  background:
    linear-gradient(
      color-mix(in srgb, var(--csw-sand-top) var(--csw-page-grain-fade), transparent),
      color-mix(in srgb, var(--csw-sand-bottom) var(--csw-page-grain-fade), transparent)
    ),
    var(--csw-sand-grain),
    linear-gradient(var(--csw-sand-top), var(--csw-sand-bottom));
}

/* --------------------------------------------------------------------------
   Texte gravé dans le sable : creux ombré en haut, lèvre éclairée en bas
   -------------------------------------------------------------------------- */

.csw-engraved {
  color: var(--csw-engraved);
  text-shadow:
    0 1px 0 rgb(255 241 214 / 0.7),
    0 -1px 1px rgb(120 75 35 / 0.45),
    0 0 6px rgb(170 115 70 / 0.35);
}

/* --------------------------------------------------------------------------
   Élément enfoncé dans le sable
   L'ombre intérieure est portée par un ::after, pour rester visible
   par-dessus une image ou une vidéo.
   -------------------------------------------------------------------------- */

.csw-pressed {
  position: relative;
  border-radius: 10px;
  background: rgb(214 170 112 / 0.14);
  box-shadow:
    0 1px 0 1px rgb(255 246 228 / 0.55), /* lèvre de sable éclairée autour du creux */
    0 -1px 3px rgb(150 100 50 / 0.18);   /* léger bourrelet au-dessus */
}

.csw-pressed::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 3px 6px rgb(110 70 30 / 0.35),  /* bord haut du creux, dans l'ombre */
    inset 0 -2px 3px rgb(255 248 232 / 0.45), /* bord bas, éclairé */
    inset 0 0 0 1px rgb(140 95 50 / 0.18);
}

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

.csw-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--csw-header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--csw-sand-grain), var(--csw-sand-header);
  box-shadow: 0 2px 6px rgb(120 80 40 / 0.3);
}

.csw-header__title {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: var(--project-font-title);
  font-weight: var(--project-font-title-weight);
  font-size: min(calc(var(--csw-header-h) * 0.5), 6vw);
  line-height: 1;
  white-space: nowrap;
}

/* Marées : hautes comme le header, largeur selon leur proportion */
.csw-tide {
  position: absolute;
  top: 0;
  height: 100%;
  width: auto;
}

.csw-tide--left {
  left: 0;
  aspect-ratio: 680 / 100;
}

.csw-tide--right {
  right: 0;
  aspect-ratio: 240 / 100;
}

/* Bulles : apparaissent, gonflent légèrement puis éclatent.
   Délai (--d) et durée (--t) propres à chaque bulle, dans le HTML. */
.csw-bubbles circle {
  transform-box: fill-box;
  transform-origin: center;
  animation: csw-bubble var(--t, 3.2s) ease-in-out var(--d, 0s) infinite;
}

@keyframes csw-bubble {
  0%   { scale: 0;   opacity: 0; }
  15%  { scale: 1;   opacity: 1; }
  75%  { scale: 1.1; opacity: 1; }
  88%  { scale: 1.6; opacity: 0; }
  100% { scale: 0;   opacity: 0; }
}

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

.csw-defs {
  position: absolute;
  width: 0;
  height: 0;
}

/* Retour à l'accueil, posé sur l'eau */
.csw-header__back {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: var(--gutter);
  display: flex;
  align-items: center;
  gap: 0.5em;
  translate: 0 -50%;
  color: #fff;
  font-family: var(--project-font-title);
  font-size: clamp(1rem, calc(var(--csw-header-h) * 0.2), 1.3rem);
  font-weight: 400;
  text-decoration: none;
  text-shadow: 0 1px 3px rgb(0 70 100 / 0.55);
}

.csw-header__back-arrow {
  font-size: 1.3em;
  line-height: 1;
  transition: translate 0.2s ease;
}

.csw-header__back:hover .csw-header__back-arrow,
.csw-header__back:focus-visible .csw-header__back-arrow {
  translate: -4px 0;
}

.csw-header__back:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
  border-radius: 4px;
}

/* Écran étroit : marées en partie hors champ, flèche seule */
@media (max-width: 760px) {
  .csw-tide--left {
    translate: -55% 0;
  }

  .csw-tide--right {
    translate: 35% 0;
  }

  .csw-header__back-text {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Contenu
   -------------------------------------------------------------------------- */

.csw-content {
  max-width: 1100px;
  margin-inline: auto;
  padding: clamp(2rem, 6vh, 4rem) var(--gutter) 7rem;
}

.csw-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* la colonne ne s'élargit pas selon son contenu (carrousel) */
  gap: 1.5rem;
}

.csw-section + .csw-section {
  margin-top: clamp(2.5rem, 6vh, 4rem);
}

.csw-heading {
  margin: 0;
  font-family: var(--project-font-title);
  font-weight: var(--project-font-title-weight);
  font-size: clamp(1.75rem, 2.5vw, 2.5rem);
}

.csw-card {
  padding: 1.5rem 1.75rem;
  font-size: 1.1rem;
  line-height: 1.6;
}

.csw-card p {
  margin: 0;
}

.csw-media {
  margin: 0;
  overflow: hidden;
}

/* Une image, l'écran de démo ou une vidéo sont plus chargés qu'un bloc
   de texte : creux plus marqué */
.csw-media.csw-pressed,
.csw-screen.csw-pressed,
.csw-video.csw-pressed {
  box-shadow:
    0 2px 0 1px rgb(255 246 228 / 0.75), /* lèvre éclairée, plus épaisse */
    0 -2px 6px rgb(150 100 50 / 0.3);    /* bourrelet au-dessus */
}

.csw-media.csw-pressed::after,
.csw-screen.csw-pressed::after,
.csw-video.csw-pressed::after {
  box-shadow:
    inset 0 8px 16px rgb(70 40 15 / 0.55),   /* bord haut, dans l'ombre */
    inset 0 0 14px rgb(70 40 15 / 0.35),     /* profondeur sur tout le pourtour */
    inset 0 -3px 5px rgb(255 248 232 / 0.5), /* bord bas, éclairé */
    inset 0 0 0 2px rgb(110 70 30 / 0.3);
}

.csw-media img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 6;
  object-fit: cover;
}

/* --------------------------------------------------------------------------
   Écran de démo Unity (structure : unity-screen.css)
   -------------------------------------------------------------------------- */

.csw-screen {
  /* Aperçu : ressources/csw/poster.webp (converti depuis poster.png) ; s'il manque, de l'eau */
  background:
    url("../../ressources/csw/poster.webp") center / cover no-repeat,
    radial-gradient(ellipse at 30% 20%, #8ee6f0 0%, transparent 55%),
    linear-gradient(160deg, #3ccde6, #0f86b0);
}

.csw-screen .unity-screen__overlay {
  background: linear-gradient(rgb(40 25 10 / 0.1), rgb(40 25 10 / 0.45));
  color: #fff;
  text-shadow: 0 1px 3px rgb(0 50 70 / 0.6);
}

/* Bouton « Lancer » : une goutte d'eau tropicale bordée d'écume */
.csw-screen .unity-screen__launch {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.6em 1.6em;
  border: 2px solid rgb(255 255 255 / 0.85);
  border-radius: 999px;
  background: linear-gradient(#3ccde6, #149fcc);
  box-shadow:
    0 4px 14px rgb(0 70 100 / 0.35),
    inset 0 1px 0 rgb(255 255 255 / 0.5);
  color: #fff;
  font-family: var(--project-font-title);
  font-size: clamp(1.1rem, 1.6vw, 1.5rem);
  font-weight: var(--project-font-title-weight);
  text-shadow: 0 1px 2px rgb(0 60 90 / 0.5);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.csw-screen .unity-screen__launch:hover,
.csw-screen .unity-screen__launch:focus-visible {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow:
    0 6px 20px rgb(0 70 100 / 0.45),
    inset 0 1px 0 rgb(255 255 255 / 0.6);
  outline: none;
}

.csw-screen .unity-screen__hint,
.csw-screen .unity-screen__status,
.csw-screen .unity-screen__error {
  margin: 0;
  font-size: 0.95rem;
}

.csw-screen .unity-screen__error {
  max-width: 32rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgb(60 30 10 / 0.6);
}

/* Barre de chargement : un sillon dans le sable qui se remplit d'eau */
.csw-screen .unity-screen__bar {
  height: 0.75rem;
  border-radius: 999px;
  background: rgb(214 170 112 / 0.85);
  box-shadow:
    inset 0 2px 4px rgb(90 55 20 / 0.55),
    0 1px 0 rgb(255 246 228 / 0.6);
}

.csw-screen .unity-screen__bar span {
  border-radius: inherit;
  background:
    linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 0.55) 50%, transparent 70%) 0 0 / 200% 100%,
    linear-gradient(#5fdcec, #149fcc);
  animation: csw-shimmer 1.6s linear infinite;
}

@keyframes csw-shimmer {
  to { background-position: -200% 0, 0 0; }
}

/* Plein écran : discret, en haut à droite */
.csw-screen .unity-screen__fullscreen {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 0.6);
  border-radius: 8px;
  background: rgb(0 40 60 / 0.45);
  color: #fff;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}

.csw-screen .unity-screen__fullscreen:hover,
.csw-screen .unity-screen__fullscreen:focus-visible {
  opacity: 1;
  background: rgb(0 40 60 / 0.7);
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .csw-screen .unity-screen__bar span {
    animation: none;
  }
}

/* --------------------------------------------------------------------------
   Carrousel de vidéos (structure : carousel.css)
   -------------------------------------------------------------------------- */

/* Marge intérieure : les ombres des creux ne sont pas rognées par le carrousel */
.csw-carousel .carousel__slide {
  padding: 0.5rem 0.5rem 0.75rem;
}

.csw-carousel {
  --carousel-arrow-size: clamp(2.75rem, 3.5vw, 3.5rem);
  --carousel-gap: 1.25rem;
}

.csw-carousel__title {
  margin: 0 0 1.1rem;
  font-family: var(--project-font-title);
  font-weight: var(--project-font-title-weight);
  font-size: clamp(1.75rem, 2.8vw, 2.75rem);
  line-height: 1.15;
  text-align: center;
}

.csw-carousel__text {
  margin: 1.25rem 0 0;
}

/* Bouton lecture : une goutte d'eau, comme « Lancer la démo » */
.csw-video .youtube-lite__icon {
  width: clamp(3.5rem, 6vw, 4.75rem);
  aspect-ratio: 1;
  border: 2px solid rgb(255 255 255 / 0.85);
  border-radius: 50%;
  background: linear-gradient(#3ccde6, #149fcc);
  box-shadow:
    0 4px 14px rgb(0 70 100 / 0.4),
    inset 0 1px 0 rgb(255 255 255 / 0.5);
  color: #fff;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.csw-video .youtube-lite__icon svg {
  width: 42%;
  translate: 8% 0; /* centrage optique du triangle */
}

.csw-video .youtube-lite__play:hover .youtube-lite__icon,
.csw-video .youtube-lite__play:focus-visible .youtube-lite__icon {
  transform: scale(1.08);
  filter: brightness(1.08);
}

.csw-video .youtube-lite__play:focus-visible {
  outline: none;
}

/* Contrôles : flèches en gouttes d'eau, pastilles en petits sillons dans le sable */
.csw-carousel .carousel__prev,
.csw-carousel .carousel__next {
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid rgb(255 255 255 / 0.85);
  border-radius: 50%;
  background: linear-gradient(#3ccde6, #149fcc);
  box-shadow: 0 3px 10px rgb(0 70 100 / 0.3);
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.csw-carousel .carousel__prev:hover,
.csw-carousel .carousel__next:hover,
.csw-carousel .carousel__prev:focus-visible,
.csw-carousel .carousel__next:focus-visible {
  transform: translateY(-2px);
  filter: brightness(1.08);
  outline: none;
}

.csw-carousel .carousel__dot {
  width: 2.25rem;
  height: 0.7rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgb(214 170 112 / 0.5);
  box-shadow:
    inset 0 2px 3px rgb(90 55 20 / 0.5),
    0 1px 0 rgb(255 246 228 / 0.7);
  cursor: pointer;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Pastille active : le sillon se remplit d'eau */
.csw-carousel .carousel__dot[aria-current="true"] {
  background: linear-gradient(#8ee6f0, #149fcc);
  box-shadow:
    inset 0 1px 2px rgb(0 60 90 / 0.4),
    0 0 6px rgb(60 205 230 / 0.6);
}

.csw-carousel .carousel__dot:focus-visible {
  outline: 2px solid #149fcc;
  outline-offset: 3px;
}
