/* ============================================================
   Portfolio Chalet — style "dessin / Ghibli"
   ============================================================ */

:root {
  --ink: #4a3526;
  --paper: #fff8ec;
  --gold: #ffd98e;
  --gold-strong: #ffc45f;
  --hand: 'Quicksand', 'Segoe UI', system-ui, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1c2233;
  font-family: var(--hand);
  user-select: none;
}

/* ---------- Scènes ---------- */
.scene {
  position: absolute;
  inset: 0;
  display: none;
}
.scene.active { display: block; }

.scene svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Zoom vers la porte quand on entre dans le chalet */
#scene-exterieur svg {
  transition: transform 1.1s ease-in;
  transform-origin: 51% 70%;
}
#scene-exterieur.zooming svg { transform: scale(2.4); }

/* Zoom vers l'écran du bureau quand on "entre dedans" */
#scene-bureau svg {
  transition: transform 1.1s ease-in;
  transform-origin: 52.6% 53.5%;   /* centre de l'écran du PC */
}
#scene-bureau.zooming svg { transform: scale(3.2); }

/* ---------- Zones cliquables ---------- */
.hotspot {
  cursor: pointer;
  transition: filter .25s ease;
}
.hotspot:hover {
  filter: brightness(1.22)
          drop-shadow(0 0 6px var(--gold))
          drop-shadow(0 0 18px var(--gold-strong));
}

/* Zone invisible posée sur l'image, qui s'illumine au survol */
.hotzone {
  fill: var(--gold);
  opacity: 0;
  transition: opacity .25s ease;
}
.hotspot:hover .hotzone { opacity: .2; }

/* Sur tactile (pas de survol) : les zones pulsent doucement
   pour signaler ce qui est cliquable */
@media (hover: none) and (pointer: coarse) {
  .hotzone { animation: hotzonePulse 3.4s ease-in-out infinite; }
}
@keyframes hotzonePulse {
  0%, 100% { opacity: 0; }
  50%      { opacity: .14; }
}

/* ---------- Neige (canvas plein écran) ---------- */
#snow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 65;   /* au-dessus du fondu noir : la tempête ne s'interrompt jamais */
}

/* ---------- Intro : vue lointaine du chalet ---------- */
#intro {
  position: fixed;
  inset: 0;
  z-index: 30;                    /* sous la neige (40) : la tempête tombe dessus */
  background: url('images/exterieur_loin.png') center / cover no-repeat;
  cursor: pointer;
  transition: transform 3.2s ease-in;
}
#intro.walk {                     /* on avance : léger zoom pendant le fondu noir */
  transform: scale(1.18);
  pointer-events: none;
}
#intro .hint {
  position: absolute;
  bottom: 7%;
  left: 53.5%;                     /* centré sur le chemin de l'image */
  transform: translateX(-50%);
  font-family: 'Caveat', 'Segoe Print', cursive;
  font-weight: 600;
  font-size: clamp(24px, 3vw, 34px);
  color: #fff3da;
  text-shadow: 0 2px 10px rgba(30, 25, 60, .9);
  animation: hintPulse 2.6s ease-in-out 1s infinite;
  pointer-events: none;
}

/* ---------- Fondu entre scènes ---------- */
#fader {
  position: fixed;
  inset: 0;
  background: #0d1017;
  opacity: 0;
  pointer-events: none;
  transition: opacity .65s ease;
  z-index: 60;
}
#fader.on { opacity: 1; pointer-events: all; }

/* ---------- Texte de bienvenue (dans le ciel de la scène) ---------- */
.sky-title {
  font-family: 'Caveat', 'Segoe Print', cursive;  /* manuscrite, se fond dans la peinture */
  font-weight: 600;
  letter-spacing: 1px;
  text-anchor: middle;
  fill: #fff3da;
  filter: drop-shadow(0 2px 6px rgba(30, 25, 60, .75))
          drop-shadow(0 0 18px rgba(255, 190, 120, .35));
  transform-box: fill-box;
  transform-origin: 50% 50%;
  /* apparition, puis flottement continu comme porté par le vent */
  animation: welcomeIn 3.2s ease 1s both,
             skyFloat 7s ease-in-out 4.2s infinite;
}
.sky-title { font-size: 48px; }
.sky-title.tl { text-anchor: end; }   /* finit derrière le versant gauche */
.sky-title.tr {                       /* commence derrière le versant droit */
  text-anchor: start;
  animation-duration: 3.2s, 8.5s;     /* rythme décalé pour un effet naturel */
  animation-delay: 1s, 5s;
}

.sky-hint {
  font-family: 'Caveat', 'Segoe Print', cursive;
  font-weight: 600;
  font-size: 32px;
  text-anchor: middle;
  fill: #fff6e6;
  filter: drop-shadow(0 2px 6px rgba(30, 25, 60, .9));
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: welcomeIn 3.2s ease 1s both,
             hintPulse 2.6s ease-in-out 4.5s infinite,
             skyFloat 6s ease-in-out 5s infinite;
}

@keyframes welcomeIn { from { opacity: 0; transform: translateY(-18px); }
                       to   { opacity: 1; transform: translateY(0); } }
@keyframes hintPulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes skyFloat {
  0%, 100% { transform: translateY(0)    rotate(0deg); }
  35%      { transform: translateY(-6px) rotate(.45deg); }
  70%      { transform: translateY(3px)  rotate(-.35deg); }
}

/* ---------- Étiquette qui suit la souris ---------- */
#tooltip {
  position: fixed;
  padding: 7px 16px 8px;
  background: var(--paper);
  color: var(--ink);
  border: 2.5px solid #6b4e36;
  border-radius: 18px 22px 20px 24px / 22px 18px 24px 20px;
  font-size: 15px;
  box-shadow: 0 4px 14px rgba(30, 20, 10, .35);
  pointer-events: none;
  opacity: 0;
  transform: translate(14px, 18px) scale(.9);
  transition: opacity .18s ease, transform .18s ease;
  z-index: 70;
  white-space: nowrap;
}
#tooltip.show { opacity: 1; transform: translate(14px, 18px) scale(1); }

/* ---------- Bulle de texte ---------- */
#bubble-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 12, 25, .35);
  z-index: 80;
  display: none;
  cursor: pointer;
}
#bubble-backdrop.show { display: block; }

#bubble {
  position: absolute;          /* positionnée en JS près du point cliqué */
  width: min(88vw, 520px);
  background: var(--paper);
  color: var(--ink);
  border: 3.5px solid #6b4e36;
  border-radius: 42px 58px 46px 62px / 56px 44px 60px 48px;
  padding: 30px 34px 26px;
  box-shadow: 0 14px 44px rgba(20, 12, 5, .5);
  cursor: default;
  transform-origin: 20% 100%;  /* le pop part de la queue */
  animation: bubblePop .32s cubic-bezier(.34, 1.56, .64, 1);
}
#bubble::after {              /* petite queue de bulle, vers le bas */
  content: '';
  position: absolute;
  bottom: -26px;
  left: 18%;
  width: 34px;
  height: 34px;
  background: var(--paper);
  border: 3.5px solid #6b4e36;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) skew(12deg, 12deg);
  border-radius: 0 0 12px 0;
}
#bubble.below { transform-origin: 20% 0%; }
#bubble.below::after {        /* bulle sous le clic : queue vers le haut */
  bottom: auto;
  top: -26px;
  border: 3.5px solid #6b4e36;
  border-bottom: none;
  border-right: none;
  border-radius: 12px 0 0 0;
}
@keyframes bubblePop {
  from { transform: scale(.6); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
#bubble h2 {
  font-size: clamp(19px, 2.4vw, 25px);
  margin-bottom: 12px;
  color: #7a4a1f;
}
#bubble .body {
  font-size: clamp(14px, 1.7vw, 17px);
  line-height: 1.55;
}
#bubble .body p + p { margin-top: 9px; }
#bubble .body a {
  color: #7a4a1f;
  text-decoration: underline;
  text-underline-offset: 3px;
}
#bubble .body a:hover { color: #b26b3a; }
#bubble .body ul { margin: 8px 0 0 20px; }
#bubble .body li { margin-bottom: 4px; }
#bubble .close-hint {
  margin-top: 16px;
  font-size: 12.5px;
  opacity: .55;
  text-align: right;
}

/* ---------- Panneau "tournez votre téléphone" (mobile portrait) ---------- */
#rotate-overlay {
  position: fixed;
  inset: 0;
  background: #1c2233;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
}
#rotate-overlay .card {
  background: var(--paper);
  color: var(--ink);
  border: 3.5px solid #6b4e36;
  border-radius: 42px 58px 46px 62px / 56px 44px 60px 48px;
  padding: 34px 38px 30px;
  box-shadow: 0 14px 44px rgba(20, 12, 5, .5);
  font-family: var(--hand);
}
#rotate-overlay .phone {
  display: inline-block;
  font-size: 56px;
  margin-bottom: 14px;
  animation: phoneTilt 2.2s ease-in-out infinite;
}
#rotate-overlay p {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.5;
}
@keyframes phoneTilt {
  0%, 15%  { transform: rotate(0deg); }
  50%, 80% { transform: rotate(90deg); }
  100%     { transform: rotate(0deg); }
}
@media (orientation: portrait) and (pointer: coarse) {
  #rotate-overlay { display: flex; }
}

/* ---------- Bouton son ---------- */
#audio-toggle {
  position: fixed;
  top: 16px;
  right: 18px;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(255, 248, 236, .18);
  border: 2px solid rgba(255, 248, 236, .45);
  border-radius: 40% 46% 42% 48%;
  cursor: pointer;
  z-index: 90;
  transition: background .2s ease, transform .2s ease;
}
#audio-toggle:hover { background: rgba(255, 248, 236, .38); transform: scale(1.08); }

/* ============================================================
   Animations des éléments SVG
   ============================================================ */

/* Fumée de cheminée — suit le panache peint, vers le haut-droite */
.smoke-puff {
  transform-box: fill-box;          /* le scale se fait autour de la bouffée, */
  transform-origin: 50% 50%;        /* pas autour du centre de la scène        */
  animation: smokeRise 6s linear infinite;
  opacity: 0;
}
.smoke-puff.p2 { animation-delay: 1.5s; }
.smoke-puff.p3 { animation-delay: 3s; }
.smoke-puff.p4 { animation-delay: 4.5s; }
@keyframes smokeRise {
  0%   { opacity: 0;   transform: translate(0, 0) scale(.45); }
  12%  { opacity: .5; }
  60%  { opacity: .32; transform: translate(26px, -96px) scale(1.4); }
  100% { opacity: 0;   transform: translate(58px, -180px) scale(2.2); }
}

/* Petit paquet de neige qui se décroche, tombe et s'écrase */
.snow-drop {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  opacity: 0;
  animation: snowDrop var(--cycle, 11s) linear infinite;
  animation-delay: var(--wait, 0s);
}
@keyframes snowDrop {
  0%, 80% { opacity: 0;   transform: translateY(0) scale(1); }
  80.5%   { opacity: .95; transform: translateY(0) scale(1);
            animation-timing-function: cubic-bezier(.5, 0, .9, .6); }  /* gravité */
  88%     { opacity: .95; transform: translateY(var(--fall, 250px)) scale(1); }
  91%     { opacity: 0;   transform: translateY(var(--fall, 250px)) scale(1.7, .3); }
  100%    { opacity: 0;   transform: translateY(var(--fall, 250px)) scale(1.7, .3); }
}

/* Étoiles */
.star { animation: twinkle 3.4s ease-in-out infinite; }
.star.s2 { animation-delay: 1.1s; }
.star.s3 { animation-delay: 2.2s; }
@keyframes twinkle { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

/* Nuages qui dérivent */
.cloud   { animation: drift 60s linear infinite alternate; }
.cloud.c2 { animation-duration: 85s; animation-direction: alternate-reverse; }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(90px); } }

/* Halo des fenêtres / lampes qui respire */
.glow { animation: breathe 3.8s ease-in-out infinite; }
@keyframes breathe { 0%,100% { opacity: .75; } 50% { opacity: 1; } }

/* Flammes du feu de cheminée */
.flame { transform-origin: center bottom; transform-box: fill-box; }
.flame.f1 { animation: flick 1.15s ease-in-out infinite; }
.flame.f2 { animation: flick 0.85s ease-in-out .25s infinite; }
.flame.f3 { animation: flick 0.65s ease-in-out .45s infinite; }
@keyframes flick {
  0%,100% { transform: scaleY(1)    scaleX(1);    opacity: .95; }
  35%     { transform: scaleY(1.14) scaleX(.94);  opacity: 1; }
  70%     { transform: scaleY(.88)  scaleX(1.06); opacity: .85; }
}
.fire-glow { animation: fireBreathe 1.7s ease-in-out infinite; }
@keyframes fireBreathe { 0%,100% { opacity: .55; } 50% { opacity: .85; } }

/* Étincelles du feu */
.spark { animation: sparkUp 2.4s linear infinite; opacity: 0; }
.spark.k2 { animation-delay: .9s; }
.spark.k3 { animation-delay: 1.7s; }
@keyframes sparkUp {
  0%  { opacity: 0; transform: translateY(0); }
  12% { opacity: 1; }
  100%{ opacity: 0; transform: translateY(-95px); }
}

/* Flammes bleues du gaz */
.gas-flame { transform-origin: center bottom; transform-box: fill-box;
             animation: gasFlick .5s ease-in-out infinite alternate; }
@keyframes gasFlick { from { transform: scaleY(1); opacity: .9; }
                      to   { transform: scaleY(1.35); opacity: 1; } }

/* Vapeur de cuisson */
.steam {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: steamRise 3.2s linear infinite;
  opacity: 0;
}
.steam.v2 { animation-delay: 1.1s; }
.steam.v3 { animation-delay: 2.1s; }
@keyframes steamRise {
  0%   { opacity: 0;  transform: translateY(0) scale(.6); }
  20%  { opacity: .5; }
  100% { opacity: 0;  transform: translateY(-70px) scale(1.5); }
}

/* LEDs de la tour PC : rouge <-> bleu */
.led  { animation: ledPulse 2.4s ease-in-out infinite; }
.led.l2 { animation-delay: 1.2s; }
@keyframes ledPulse {
  0%, 100% { fill: #ff4d5a; filter: drop-shadow(0 0 5px #ff4d5a); }
  50%      { fill: #3b82f6; filter: drop-shadow(0 0 5px #3b82f6); }
}

/* Lignes de code qui défilent sur l'écran */
.code-scroll { animation: codeScroll 7s linear infinite; }
@keyframes codeScroll { from { transform: translateY(0); } to { transform: translateY(-120px); } }

/* Curseur qui clignote sur l'écran */
.cursor-blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* Jeux de lumière de la sono */
.dj-beam { transform-origin: center bottom; transform-box: fill-box;
           animation: beamSway 3.6s ease-in-out infinite alternate; }
.dj-beam.b2 { animation-duration: 2.8s; animation-direction: alternate-reverse; }
@keyframes beamSway { from { transform: rotate(-14deg); opacity: .35; }
                      to   { transform: rotate(14deg);  opacity: .7; } }
.dj-led {
  animation: djColor 2s linear infinite;
  filter: drop-shadow(0 0 6px rgba(255, 235, 200, .8));
}

/* Guirlande du salon : chaque ampoule pulse dans sa couleur */
.gled {
  fill: currentColor;
  transform-box: fill-box;
  transform-origin: 50% 50%;
  filter: drop-shadow(0 0 8px currentColor);
  animation: gledPulse 1.3s ease-in-out infinite;
}
@keyframes gledPulse {
  0%, 100% { opacity: .2; transform: scale(.75); }
  50%      { opacity: .95; transform: scale(1.15); }
}
.dj-led.d2 { animation-delay: .66s; }
.dj-led.d3 { animation-delay: 1.33s; }
@keyframes djColor {
  0%   { fill: #ff5470; } 33% { fill: #4dd4ff; }
  66%  { fill: #b96bff; } 100% { fill: #ff5470; }
}

/* Ondes sonores des enceintes (quand la musique joue) */
.wave {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: waveOut 1.5s ease-out infinite;
  opacity: 0;
}
.wave.w2 { animation-delay: .75s; }
.wave.w3 { animation-delay: .4s; }
.wave.w4 { animation-delay: 1.15s; }
@keyframes waveOut {
  0%   { transform: scale(.55); opacity: .55; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* LED bleues de la table de mixage */
.mix-led {
  animation: mixBlink .9s ease-in-out infinite;
  filter: drop-shadow(0 0 4px #4dd4ff);
}
.mix-led.l2 { animation-delay: .2s;  animation-duration: .7s; }
.mix-led.l3 { animation-delay: .45s; animation-duration: 1.1s; }
.mix-led.l4 { animation-delay: .1s;  animation-duration: .8s; }
.mix-led.l5 { animation-delay: .3s; }
@keyframes mixBlink { 0%, 100% { opacity: .1; } 50% { opacity: 1; } }

/* Queue du chat */
.cat-tail { transform-origin: left center; transform-box: fill-box;
            animation: tailWag 4.5s ease-in-out infinite; }
@keyframes tailWag { 0%,100% { transform: rotate(0deg); }
                     50%     { transform: rotate(-14deg); } }

/* Ronflement du chat */
.cat-zzz { animation: zzzFloat 3.6s linear infinite; opacity: 0; }
.cat-zzz.z2 { animation-delay: 1.8s; }
@keyframes zzzFloat {
  0%   { opacity: 0; transform: translate(0, 0); }
  25%  { opacity: .8; }
  100% { opacity: 0; transform: translate(18px, -42px); }
}

/* Neige derrière les fenêtres */
.win-flake { animation: winFall 5s linear infinite; }
.win-flake.w2 { animation-delay: 1.7s; animation-duration: 6s; }
.win-flake.w3 { animation-delay: 3.4s; animation-duration: 4.4s; }
@keyframes winFall {
  from { transform: translate(0, -110px); opacity: 0; }
  10%  { opacity: .9; }
  90%  { opacity: .9; }
  to   { transform: translate(22px, 130px); opacity: 0; }
}

/* Flamme de lanterne / bougie */
.candle { transform-origin: center bottom; transform-box: fill-box;
          animation: candleFlick 1.4s ease-in-out infinite; }
@keyframes candleFlick {
  0%,100% { transform: scale(1) rotate(0deg); }
  30%     { transform: scale(1.12, .94) rotate(-3deg); }
  65%     { transform: scale(.92, 1.1) rotate(3deg); }
}
