:root {
  color-scheme: dark;
  font-family: "Stack Sans Headline", "Space Grotesk", "Inter", "Helvetica Neue", sans-serif;
  --bg: #050505;
  --card: rgba(5, 5, 5, 0.75);
  --glass: rgba(255, 255, 255, 0.06);
  --text: #f5f5f0;
  --accent: #f75c03;
  --muted: rgba(255, 255, 255, 0.65);
  --viewport-height: 100vh;
}

@supports (height: 100dvh) {
  :root {
    --viewport-height: 100dvh;
  }
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  min-height: 100%;
  height: var(--viewport-height);
  min-height: var(--viewport-height);
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: var(--viewport-height);
  height: 100%;
  height: var(--viewport-height);
  background: var(--bg);
  color: var(--text);
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.35;
  overflow: hidden;
  position: relative;
}

/* Canvas Vanta en arrière-plan */
body>canvas:not(#rain-canvas):not(#snow-canvas):not(#wind-canvas):not(#thunder-canvas) {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  width: 100vw;
  height: var(--viewport-height);
  min-height: var(--viewport-height);
  z-index: 0;
  pointer-events: none;
  bottom: 0;
  /* Forcer jusqu'au bord physique de l'écran */
  max-height: none;
}

/* Canvas de pluie, neige, vent et orage au-dessus des nuages mais en dessous du contenu */
#rain-canvas,
#snow-canvas,
#wind-canvas,
#thunder-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  width: 100vw;
  height: var(--viewport-height);
  min-height: var(--viewport-height);
  z-index: 1;
  pointer-events: none;
  bottom: 0;
  /* Forcer jusqu'au bord physique de l'écran */
  max-height: none;
}

/* Contenu au-dessus des canvas */
body>*:not(canvas) {
  position: relative;
  z-index: 2;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  width: 100vw;
  height: calc(var(--viewport-height) + env(safe-area-inset-bottom));
  /* Inclure la safe area iOS */
  min-height: 100%;
  min-height: var(--viewport-height);
  background: #000;
  z-index: 10000;
  opacity: 1;
  transition: opacity 0.6s ease-out;
  pointer-events: none;
  bottom: 0;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

main {
  height: var(--viewport-height);
  min-height: var(--viewport-height);
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scroll-padding: 0;
  position: relative;
  z-index: 2;
}

.hero,
.hourly,
.daily {
  min-height: var(--viewport-height);
  height: auto;
  width: min(900px, 100%);
  margin: 0 auto;
  padding: clamp(1.5rem, 6vw, 5rem) clamp(1.5rem, 6vw, 4rem);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  flex-shrink: 0;
}

/* Plus d'espace en haut sur mobile */
@media (max-width: 767px) {
  .hero {
    padding-top: clamp(2rem, 8vw, 4rem) !important;
  }
}

.hero {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  position: relative;
  opacity: 0;
  transform: translateY(60px) scale(0.92);
  transition: opacity 1s ease-out, transform 1s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center center;
}

.hero.loaded {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Compenser la transformation du parent pour que le header reste fixe */
.hero:not(.loaded) header {
  /* Inverse de translateY(60px) scale(0.92) pour annuler la transformation du parent */
  /* L'ordre est important : d'abord scale inverse, puis translate inverse */
  transform: scale(1.087) translateY(-65.22px);
  /* 1/0.92 = 1.087, 60/0.92 = 65.22 */
}

.hero.loaded header {
  transform: translateY(0) scale(1);
  transition: opacity 0.3s ease-in, transform 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  backdrop-filter: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
}

header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: clamp(1rem, 4vw, 2rem);
  width: 100%;
  align-self: flex-start;
  opacity: 0;
  transition: opacity 0.3s ease-in;
  transform: translateY(0) scale(1);
  /* Compenser la transformation du parent pour que le header reste fixe */
  transform-origin: top left;
}

.hero.loaded header {
  opacity: 1;
}

.brand {
  font-size: 1rem;
  letter-spacing: 0.2rem;
  color: var(--muted);
  font-weight: 700;
}

.date {
  font-size: clamp(1.3rem, 3.2vw, 1.8rem);
  color: var(--accent);
  font-weight: 700;
}

h1 {
  margin: 0 0 1rem 0;
  font-size: clamp(2rem, 8vw, 2.8rem);
  line-height: 1.1;
  text-transform: uppercase;
}

.subtitle {
  margin: 0 0 1.75rem 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.weather-text {
  font-size: clamp(1.8rem, 7vw, 2.4rem);
  font-weight: 700;
  line-height: 1.45;
  white-space: pre-line;
  margin: 0 0 2rem 0;
  opacity: 1;
  min-height: 1.45em;
  /* Préserver la hauteur minimale pour éviter le saut */
  font-variant-emoji: emoji;
  /* Forcer le rendu emoji sur Safari */
  /* Réactiver les ligatures standard pour un meilleur rendu, mais désactiver les contextuelles */
  -webkit-font-feature-settings: "liga" 1, "calt" 0;
  font-feature-settings: "liga" 1, "calt" 0;
  /* Utiliser des chiffres à chasse fixe pour un rendu cohérent */
  font-variant-numeric: tabular-nums;
  /* Forcer un rendu cohérent des caractères */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Forcer un espacement des lettres cohérent */
  letter-spacing: 0;
  width: 100%;
  align-self: flex-start;
}

.weather-text .char-fade-in {
  display: inline;
  opacity: 0;
  animation: charFadeIn 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  vertical-align: baseline;
  letter-spacing: 0 !important;
  word-spacing: 0;
  margin: 0;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
  font-weight: inherit;
  /* S'assurer que tous les caractères ont le même rendu */
  font-feature-settings: "liga" 1, "calt" 0;
  -webkit-font-feature-settings: "liga" 1, "calt" 0;
  font-variant-numeric: tabular-nums;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Forcer un rendu cohérent sans transformation */
  transform: none;
  will-change: opacity, filter;
  filter: blur(3px);
}

@keyframes charFadeIn {
  0% {
    opacity: 0;
    filter: blur(5px);
  }

  25% {
    opacity: 0.25;
    filter: blur(3.5px);
  }

  50% {
    opacity: 0.5;
    filter: blur(2px);
  }

  70% {
    opacity: 0.7;
    filter: blur(1px);
  }

  85% {
    opacity: 0.85;
    filter: blur(0.5px);
  }

  100% {
    opacity: 1;
    filter: blur(0);
  }
}

.hourly-content {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  height: auto;
  min-height: 100%;
  padding-top: 60px;
  padding-bottom: 2rem;
  width: 100%;
  gap: 0;
  position: relative;
  min-height: 0;
}

.hourly-message-container {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  padding: 1.5rem 1rem;
  min-height: auto;
  max-height: none;
  flex-shrink: 0;
  position: relative;
  overflow-y: visible;
}

.hourly-section {
  width: 100%;
  position: relative;
  bottom: auto;
  left: auto;
  right: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: auto;
  max-height: none;
  overflow-x: hidden;
  overflow-y: visible;
  margin-top: 2rem;
}

.hourly-zones {
  position: relative;
  height: 24px;
  margin-bottom: 0.5rem;
  display: block;
  overflow: visible;
  will-change: transform;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  /* Permettre au conteneur de dépasser la largeur max si nécessaire */
  min-width: 100%;
  /* S'assurer que le conteneur est aligné de la même manière que la liste */
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .hourly-zones {
    /* Utiliser la même largeur max que la liste horaire */
    max-width: 600px;
  }
}


.hourly-zone-label {
  position: absolute;
  font-size: 0.6rem;
  letter-spacing: 0.1rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
  top: 2px;
  transform: translateX(-50%);
  opacity: 1;
}

.hourly-zone-separator {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.15);
  pointer-events: none;
  z-index: 4;
}

.hourly-message-label {
  font-size: 0.75rem;
  letter-spacing: 0.15rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.hourly-message {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.daily-message {
  font-size: clamp(1.2rem, 3.5vw, 1.6rem);
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
  text-align: center;
  max-width: 700px;
  margin: 0 auto 2rem auto;
  padding: 0 1rem;
}

.daily-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: auto;
  min-height: 100%;
  padding-top: 60px;
  padding-bottom: 2rem;
}

.hourly,
.daily {
  position: relative;
}

.hourly-head,
.daily-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding-top: clamp(1.5rem, 6vw, 3rem);
  z-index: 10;
}

.chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease, background 0.2s ease, transform 0.1s ease;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(10px);
}

.chevron:hover {
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.06);
}

.chevron:active {
  transform: scale(0.95);
}

.chevron-down {
  position: absolute;
  bottom: clamp(1.5rem, 6vw, 3rem);
  left: 50%;
  margin-left: -20px;
  z-index: 10;
}

.chevron-down:active {
  transform: scale(0.95);
}

.hourly-list {
  margin: 0 auto;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: row;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 2rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
  position: relative;
}

@media (min-width: 768px) {
  .hourly-list {
    max-width: 600px;
  }
}

.hourly-list::-webkit-scrollbar {
  height: 4px;
}

.hourly-list::-webkit-scrollbar-track {
  background: transparent;
}

.hourly-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.hourly-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.scroll-indicator {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.3);
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.2s ease;
  animation: none;
}

.hourly-section.scrollable .scroll-indicator {
  opacity: 1;
  animation: pulse 2s ease-in-out infinite;
}

.hourly-section:not(.scrollable) .scroll-indicator {
  opacity: 0 !important;
  animation: none !important;
}

@keyframes pulse {

  0%,
  100% {
    transform: translateY(-50%) translateX(0);
    opacity: 0.3;
  }

  50% {
    transform: translateY(-50%) translateX(-5px);
    opacity: 0.6;
  }
}

.hourly-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0 1rem;
  min-width: 65px;
  flex-shrink: 0;
  gap: 0.5rem;
  transition: opacity 0.2s ease;
}

.hourly-item:hover {
  opacity: 0.8;
}

.hourly-time {
  font-size: 0.65rem;
  letter-spacing: 0.15rem;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin-bottom: 0.15rem;
}

.hourly-icon {
  font-size: 1.5rem;
  opacity: 0.75;
  line-height: 1;
  text-align: center;
}

.hourly-temp {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  text-align: center;
}

.hourly-rain {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.35);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
  font-weight: 700;
  text-align: center;
}


.daily-list {
  margin: 0 auto;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.daily-item {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  padding: 1.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: opacity 0.2s ease;
}

.daily-item:last-child {
  border-bottom: none;
}

.daily-item:hover {
  opacity: 0.8;
}

.daily-date {
  font-size: 0.8rem;
  letter-spacing: 0.15rem;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.daily-detail {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  justify-self: start;
}

.daily-icon {
  font-size: 1.3rem;
  opacity: 0.75;
  line-height: 1;
}

.daily-temp {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.daily-rain {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.35);
  font-variant-numeric: tabular-nums;
  justify-self: end;
  letter-spacing: 0.1rem;
  text-transform: uppercase;
  font-weight: 700;
}

@media (min-width: 768px) {
  header {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }

  .date {
    font-size: 1.2rem;
  }

  .weather-text {
    font-size: 1.8rem;
  }
}

/* Icône de notification */
.notification-bell {
  position: fixed;
  top: clamp(1.5rem, 6vw, 3rem);
  right: clamp(1.5rem, 6vw, 3rem);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  z-index: 1000;
  padding: 0;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1;
}

.notification-bell:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  transform: scale(1.05);
}

.notification-bell:active {
  transform: scale(0.95);
}

.notification-bell.active {
  color: var(--accent);
  background: rgba(247, 92, 3, 0.15);
  border-color: rgba(247, 92, 3, 0.3);
}

.notification-bell.active:hover {
  background: rgba(247, 92, 3, 0.2);
  border-color: rgba(247, 92, 3, 0.4);
}

.notification-bell.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.notification-bell.disabled:hover {
  transform: none;
}

/* Optimisations pour très petits écrans (iPhone SE, etc.) */
@media (max-width: 400px) {
  :root {
    --viewport-height: 100vh;
    /* Fallback */
  }

  @supports (height: 100dvh) {
    :root {
      --viewport-height: 100dvh;
    }
  }

  body {
    font-size: 1rem;
    /* Réduction de la taille de base */
  }

  .hero,
  .hourly,
  .daily {
    padding: 1.5rem 1rem !important;
    /* Réduction drastique du padding */
  }

  .hero {
    padding-top: 2rem !important;
  }

  h1 {
    font-size: 1.8rem;
    /* Plus petit titre */
    margin-bottom: 0.5rem;
  }

  .subtitle {
    margin-bottom: 1rem;
    font-size: 0.85rem;
  }

  .weather-text {
    font-size: 1.4rem;
    /* Texte météo plus petit */
    margin-bottom: 1rem;
    line-height: 1.3;
  }

  .date {
    font-size: 1.1rem;
  }

  /* Hourly section specific */
  .hourly-content {
    padding-top: 40px;
    /* Moins d'espace sous la flèche du haut */
    padding-bottom: 1rem;
  }

  .hourly-message-container {
    padding: 0.5rem 0.5rem;
    min-height: auto;
  }

  .hourly-message {
    font-size: 1.3rem;
  }

  .hourly-section {
    margin-top: 1rem;
  }

  .hourly-item {
    padding: 0 0.75rem;
    min-width: 55px;
  }

  .hourly-icon {
    font-size: 1.2rem;
  }

  /* Daily section specific */
  .daily-content {
    padding-top: 40px;
  }

  .daily-message {
    font-size: 1.1rem;
    margin-bottom: 1rem;
  }

  .daily-item {
    padding: 0.75rem 0;
  }

  .daily-icon {
    font-size: 1.1rem;
  }

  .daily-temp {
    font-size: 0.9rem;
  }
}