/* =====================
   VARIABLES
   ===================== */
:root {
  --header-h: 70px;
  --footer-h: 190px;
  --store-size: min(90vw, 650px, calc(100vh - var(--header-h) - var(--footer-h) - 20px));
  --color-bg: #f4edd5;
  --color-primary: #e10a3a;
  --color-dark: #20150f;
}

/* =====================
   RESET
   ===================== */
*, *:before, *:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* =====================
   LAYOUT
   ===================== */
html { height: 100%; }

body {
  text-align: center;
  position: relative;
  min-height: 100%;
  font-family: geologica;
  background-color: var(--color-bg);
}

a {
  text-decoration: none;
  color: var(--color-primary);
}

/* =====================
   FONTES
   Chemin /font/ = dossier public/ d'Astro
   (avant c'était 'font/' relatif au CSS)
   ===================== */
@font-face { font-family: 'newsreader';  font-display: swap; src: url('/font/Newsreader.ttf'); }
@font-face { font-family: 'geologica';   font-display: swap; src: url('/font/Geologica.ttf'); }
@font-face { font-family: 'grenze';      font-display: swap; src: url('/font/Grenze-Regular.ttf'); }
@font-face { font-family: 'amarante';    font-display: swap; src: url('/font/Amarante-Regular.ttf'); }
@font-face { font-family: 'textmeone';   font-display: swap; src: url('/font/TextMeOne-Regular.ttf'); }
@font-face { font-family: 'ranga';       font-display: swap; src: url('/font/Ranga-Regular.ttf'); }
@font-face { font-family: 'twinklestar'; font-display: swap; src: url('/font/TwinkleStar-Regular.ttf'); }
@font-face { font-family: 'pirataone';   font-display: swap; src: url('/font/PirataOne.ttf'); }

/* =====================
   CLASSES TYPO FRANPONAIS
   ===================== */
.divA { font-family: 'twinklestar'; }
.divB { font-family: 'ranga'; }
.divC { font-family: 'pirataone'; }
.divD { font-family: 'textmeone'; }
.divE { font-family: 'amarante'; }
.divF { font-family: 'grenze'; }

/* =====================
   PAGES SECONDAIRES
   ===================== */
.center-text {
  text-align: justify;
  margin: 0 auto;
  font-family: newsreader;
  padding: 60px 20px;
  width: 80%;
}
.center-text p       { line-height: 30px; }
.center-text h1,
.center-text h3      { font-family: geologica; }
.center-text a       { text-decoration: underline; color: var(--color-primary); }

/* =====================
   HEADER
   ===================== */
.header {
  background-color: var(--color-bg);
  box-shadow: 1px 1px 4px 0 rgba(0,0,0,0.5);
  position: fixed;
  width: 100%;
  z-index: 3;
}

.header ul {
  list-style: none;
  overflow: hidden;
  background-color: var(--color-bg);
}

.header li a {
  display: block;
  padding: 20px;
  border-right: 2px solid var(--color-primary);
  text-decoration: none;
}

.header li a:hover { color: var(--color-dark); }

.header .menu {
  clear: both;
  max-height: 0;
  transition: max-height .2s ease-out;
}

.header .menu-btn { display: none; }
.header .menu-btn:checked ~ nav .menu { max-height: 240px; }
.header .menu-btn:checked ~ .menu-icon .navicon { background: transparent; }
.header .menu-btn:checked ~ .menu-icon .navicon:before { transform: rotate(-45deg); }
.header .menu-btn:checked ~ .menu-icon .navicon:after  { transform: rotate(45deg); top: 0; }
.header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:before,
.header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:after { top: 0; }

.header .menu-icon {
  cursor: pointer;
  display: inline-block;
  padding: 28px 20px;
  position: relative;
  user-select: none;
}

.header .menu-icon .navicon {
  background: #333;
  display: block;
  height: 2px;
  position: relative;
  transition: background .2s ease-out;
  width: 18px;
}

.header .menu-icon .navicon:before,
.header .menu-icon .navicon:after {
  background: #333;
  content: '';
  display: block;
  height: 100%;
  position: absolute;
  transition: all .2s ease-out;
  width: 100%;
}

.header .menu-icon .navicon:before { top: 5px; }
.header .menu-icon .navicon:after  { top: -5px; }

/* =====================
   FOOTER
   ===================== */
footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 0.4rem 0.2rem 0.2rem;
  background-color: var(--color-bg);
  text-align: center;
}

/* =====================
   FRANPOSTORE
   ===================== */
#franpostore {
  position: absolute;
  top: calc(var(--header-h) + (100vh - var(--header-h) - var(--footer-h)) / 2);
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  width: var(--store-size);
  aspect-ratio: 1 / 1;
}

#randomImage {
  width: 100%;
  height: auto;
  border-radius: 5px;
}

#franpotexte {
  position: absolute;
  top: 36%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #333333;
  text-shadow: 3px 2px 0px rgba(0,0,0,0.15);
  font-size: clamp(12px, 4vmin, 36px);
  line-height: 1.2;
}

/* =====================
   LOADING
   ===================== */
#loadingIndicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 100;
  width: min(200px, 40vmin);
  height: min(200px, 40vmin);
}

#loadingIndicator img {
  width: 100%;
  height: 100%;
}

/* =====================
   CRÉDIT ARTISTE + TÉLÉCHARGEMENT
   ===================== */
#credit-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
  min-height: 24px;
  visibility: hidden;
}

#lienSource {
  font-family: geologica;
  font-size: 13px;
  color: var(--color-primary);
}

#lienSource:hover {
  text-decoration: underline;
}

/* Boutons téléchargement et partage — style partagé */
#downloadBtn,
#shareBtn {
  appearance: none;
  background-color: var(--color-dark);
  border: 1px solid var(--color-dark);
  border-radius: 50px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: newsreader;
  font-size: 13px;
  padding: 8px 16px;
  touch-action: manipulation;
  user-select: none;
  transition: opacity 0.2s, transform 0.1s;
  visibility: hidden;
}

#downloadBtn:hover,
#shareBtn:hover {
  opacity: 0.8;
}

#downloadBtn:active,
#shareBtn:active {
  transform: translate(1px, 1px);
}

#downloadBtn:disabled,
#shareBtn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Mobile : partage visible, téléchargement caché */
#downloadBtn { display: none; }

/* =====================
   BOUTONS
   ===================== */

/* Rangée de boutons */
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-bottom: 6px;
}

/* Boutons secondaires noirs */
.button-secondary {
  appearance: none;
  background-color: var(--color-dark);
  border: 1px solid var(--color-dark);
  border-radius: 50px;
  color: #fff;
  cursor: pointer;
  font-family: newsreader;
  font-size: 13px;
  padding: 8px 18px;
  touch-action: manipulation;
  user-select: none;
  transition: opacity 0.2s, transform 0.1s;
}

.button-secondary:hover {
  opacity: 0.8;
}

.button-secondary:active {
  transform: translate(1px, 1px);
}

.button-secondary:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Bouton principal rouge */
.button-primary {
  appearance: none;
  background-color: var(--color-primary);
  border: 1px solid var(--color-dark);
  border-radius: 50px;
  box-shadow: #fff 4px 4px 0 0, var(--color-dark) 4px 4px 0 1px;
  color: #fff;
  cursor: pointer;
  font-family: newsreader;
  font-size: 15px;
  font-weight: 400;
  padding: 12px 40px;
  touch-action: manipulation;
  user-select: none;
  width: 100%;
  max-width: 340px;
  transition: box-shadow 0.1s, transform 0.1s;
}

.button-primary:hover {
  opacity: 0.92;
}

.button-primary:active {
  box-shadow: var(--color-dark) 2px 2px 0 0, var(--color-dark) 2px 2px 0 1px;
  transform: translate(2px, 2px);
}

.button-primary:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Boutons secondaires cachés jusqu'à la première génération */
#secondary-buttons {
  visibility: hidden;
}

/* =====================
   RESPONSIVE
   ===================== */
@media (min-width: 48em) {
  :root {
    --footer-h: 170px;
  }

  .header li         { float: left; }
  .header li a       { padding: 20px 30px; }
  .header .menu      { clear: none; float: right; max-height: none; }
  .header .menu-icon { display: none; }

  #franpostore {
    top: calc(var(--header-h) + (100vh - var(--header-h) - var(--footer-h)) / 2);
  }

  /* Image carrée */
  #franpostore.is-square {
    aspect-ratio: 1 / 1;
    height: calc(100vh - var(--header-h) - var(--footer-h) - 20px);
    width: auto;
    max-width: 85vw;
  }

  /* Image wide 4/3 */
  #franpostore.is-wide {
    aspect-ratio: 4 / 3;
    height: calc(100vh - var(--header-h) - var(--footer-h) - 20px);
    width: auto;
    max-width: 85vw;
  }

  #downloadBtn { display: flex; }
  #shareBtn { display: none; }

  .button-primary {
    padding: 12px 60px;
  }
}

/* =====================
   ACCESSIBILITÉ
   ===================== */

/* Outline visible lors de la navigation au clavier (Tab) */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Supprime l'outline par défaut au clic */
*:focus:not(:focus-visible) {
  outline: none;
}

/* Réduit les animations si l'utilisateur le demande dans ses préférences OS */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
