/* ---------- Base ---------- */

:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --ink: #17161a;
  --muted: #6b6873;
  --line: #e4e0d8;
  --radius: 14px;
  --font-title: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, h3 {
  font-family: var(--font-title);
  line-height: 1.1;
  margin: 0;
}

a {
  color: inherit;
}

code, kbd {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.9em;
  background: var(--line);
  padding: 1px 6px;
  border-radius: 5px;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding-inline: 24px;
}

/* ---------- Logo & boutons ---------- */

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.35rem;
  text-decoration: none;
}

.logo-dots {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: conic-gradient(#ff6b6b, #ffd93d, #6bcb77, #4d96ff, #b06bff, #ff6b6b);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  font: 600 0.95rem var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, color 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--ink);
  color: var(--bg);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
}

.btn-ghost:hover {
  background: var(--ink);
  color: var(--bg);
}

.btn-lg {
  padding: 14px 26px;
  font-size: 1.05rem;
}

/* ---------- Page vitrine ---------- */

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-block: 24px;
}

.hero {
  padding-block: 60px 40px;
  text-align: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 16px;
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  font-weight: 800;
  max-width: 14em;
  margin: 0 auto;
}

/* « ensemble » : dégradé arc-en-ciel qui défile en boucle */
.hero h1 em {
  font-style: normal;
  background: linear-gradient(90deg, #ff6b6b, #ffb23d, #6bcb77, #4d96ff, #b06bff, #ff6b6b);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rainbow-flow 6s linear infinite;
}

@keyframes rainbow-flow {
  to {
    background-position: -200% 0;
  }
}

.lead {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 36em;
  margin: 24px auto 32px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-palette {
  display: flex;
  width: 100%;
  height: 220px;
  margin-top: 56px;
  padding: 0;
  border: 0;
  border-radius: 24px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 30px 60px -30px rgba(23, 22, 26, 0.45);
}

.hero-palette span,
.mode-card-strip span,
.cta-band span {
  flex: 1;
  transition: background 0.8s ease;
}

.hero-caption {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 14px;
}

.section {
  padding-block: 70px;
}

.section h2,
.cta h2 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
}

.section-lead {
  color: var(--muted);
  margin: 10px 0 0;
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-top: 32px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
}

.mode-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 30px -18px rgba(23, 22, 26, 0.4);
}

.mode-card-strip {
  display: flex;
  height: 70px;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
}

.mode-card h3 {
  font-size: 1.2rem;
}

.mode-card p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 6px 0 12px;
  flex: 1;
}

.mode-card-link {
  font-weight: 600;
  font-size: 0.9rem;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 32px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 32px;
}

.step-number {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-title);
  font-weight: 800;
  margin-bottom: 14px;
}

.steps h3 {
  font-size: 1.25rem;
}

.steps p,
.feature p {
  color: var(--muted);
  margin: 8px 0 0;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 32px;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.feature h3 {
  font-size: 1.1rem;
}

.cta {
  text-align: center;
  padding-block: 40px 80px;
}

.cta-band {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  max-width: 320px;
  margin: 0 auto 32px;
}

/* Titre final : chaque lettre prend une couleur au survol puis revient au noir */
.cta .cta-title {
  max-width: 12em;
  margin: 0 auto;
  font-size: clamp(2.4rem, 6.5vw, 4.8rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  cursor: default;
}

.cta-title .word {
  display: inline-block;
  white-space: nowrap;
}

.cta-title .letter {
  display: inline-block;
}

.cta-title .letter.is-lit {
  animation: letter-lit 2.4s ease-out forwards;
}

@keyframes letter-lit {
  0% {
    color: var(--c);
    transform: translateY(-0.12em) rotate(-4deg);
  }
  20% {
    color: var(--c);
    transform: none;
  }
  60% {
    color: var(--c);
  }
  100% {
    color: var(--ink);
  }
}

.cta-hint {
  margin: 14px 0 32px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Couleur du jour ---------- */

.daily {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
}

.daily-swatch {
  position: relative;
  min-height: 300px;
  height: 100%;
  border-radius: 16px;
  background: var(--daily);
  box-shadow: 0 30px 60px -30px var(--daily);
}

.daily-swatch-hex {
  position: absolute;
  left: 20px;
  bottom: 16px;
  color: var(--daily-text);
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: 0.02em;
}

.daily-info {
  padding: 10px 18px 10px 0;
}

.daily-info .eyebrow {
  margin-bottom: 10px;
}

.daily-info h2 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 800;
  color: var(--daily);
  /* le nom garde un contraste suffisant même si la couleur est claire */
  text-shadow: 0 1px 0 rgba(23, 22, 26, 0.15);
}

.daily-hsl {
  margin: 6px 0 18px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.9rem;
  color: var(--muted);
}

.daily-shades {
  display: flex;
  height: 36px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 320px;
}

.daily-shades span {
  flex: 1;
}

.daily-desc {
  margin: 18px 0 0;
  max-width: 30em;
}

.daily-text {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 10px 0 22px;
  max-width: 30em;
}

.daily-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-block: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Générateur ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20; /* le menu déroulant passe au-dessus des couleurs */
}

.topbar .logo {
  flex: none;
}

/* Les modes prennent la place disponible et défilent s'il en manque */
.modes {
  display: flex;
  flex: 0 1 auto;
  min-width: 0;
  gap: 4px;
  padding: 4px;
  background: var(--line);
  border-radius: 999px;
  overflow-x: auto;
  scrollbar-width: none; /* barre de défilement invisible */
}

.modes::-webkit-scrollbar {
  display: none;
}

/* Glisser à la souris pour faire défiler */
.modes.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.modes.is-dragging .mode {
  cursor: grabbing;
}

/* Fondu sur le bord quand des modes sont cachés de ce côté */
.modes.can-left {
  mask-image: linear-gradient(to right, transparent, #000 32px);
}

.modes.can-right {
  mask-image: linear-gradient(to left, transparent, #000 32px);
}

.modes.can-left.can-right {
  mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
}

.mode {
  flex: 1 0 auto;
  white-space: nowrap;
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 999px;
  font: 500 0.9rem var(--font-body);
  color: var(--muted);
  cursor: pointer;
}

.mode:hover {
  color: var(--ink);
}

.mode.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  margin-left: auto;
}

/* Boutons outils : contour gris, plus discrets que « Générer » */
.actions .btn-ghost {
  border-color: #d3cec4;
}

.actions .btn-ghost:hover {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--ink);
}

.toolbar {
  display: flex;
  gap: 8px;
}

.menu-toggle,
.label-long {
  display: none;
}

.ico {
  display: none;
}

#add .ico {
  display: inline; /* « + Couleur » garde son + en ligne */
}

/* Menu déroulant quand la barre n'a plus la place d'afficher les outils */
@media (max-width: 1100px) {
  .menu {
    position: relative;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .toolbar {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 260px;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 20px 40px -12px rgba(23, 22, 26, 0.35);
  }

  .menu.is-open .toolbar {
    display: flex;
  }

  .menu.is-open .menu-toggle {
    border-color: var(--ink);
  }

  .actions .toolbar .btn {
    justify-content: flex-start;
    gap: 12px;
    border: 0;
    border-radius: 10px;
    padding: 11px 12px;
    font-weight: 500;
  }

  .actions .toolbar .btn:hover {
    background: var(--bg);
    transform: none;
  }

  .toolbar .btn:disabled {
    background: transparent;
  }

  .ico {
    display: inline-block;
    width: 22px;
    text-align: center;
  }

  .label-short {
    display: none;
  }

  .label-long {
    display: inline;
  }
}

/* Double écart pour séparer l'action principale des outils */
.btn-generate {
  margin-left: 8px;
}

.btn-generate span {
  font-size: 1.1em;
  line-height: 1;
}

.palette {
  flex: 1;
  display: flex;
  min-height: 0;
}

.swatch {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 24px 12px 40px;
  cursor: pointer;
  transition: flex 0.25s ease;
}

.swatch:hover {
  flex: 1.15;
}

/* Glisser-déposer */
.palette {
  position: relative; /* repère pour offsetLeft / offsetTop des couleurs */
}

.swatch {
  cursor: grab;
  touch-action: none; /* sur mobile, le doigt déplace la couleur au lieu de faire défiler */
  user-select: none;
}

.palette.is-sorting .swatch {
  flex: 1;
  transition: none;
  cursor: grabbing;
}

.swatch.is-dragging {
  z-index: 5;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
  outline: 3px solid rgba(255, 255, 255, 0.7);
  outline-offset: -3px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Outils d'une couleur : cadenas, modifier, supprimer */
.tools {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  color: inherit;
  font-size: 1.15rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
}

.swatch:hover .tool,
.tool.is-on {
  opacity: 1;
}

.tool:hover {
  background: rgba(255, 255, 255, 0.45);
}

.tool:disabled {
  display: none;
}

/* Le sélecteur de couleur est invisible, posé sur le bouton ✎ */
.tool-picker input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.swatch-name {
  width: 100%;
  max-width: 200px;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: 600 1rem var(--font-body);
  text-align: center;
}

.swatch-name:hover,
.swatch-name:focus {
  border-color: currentColor;
  outline: none;
}

.swatch-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

.swatch-hex {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
}

.swatch-hsl {
  font-size: 0.8rem;
  opacity: 0.75;
}

.hint {
  padding: 12px 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 60px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Moins d'animations si le système le demande */
@media (prefers-reduced-motion: reduce) {
  .hero h1 em,
  .cta-title .letter.is-lit {
    animation: none;
  }
}

/* ---------- Mobile ---------- */

@media (max-width: 700px) {
  .daily {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .daily-swatch {
    min-height: 200px;
  }

  .daily-info {
    padding: 0 6px 10px;
  }

  .cta-hint {
    display: none; /* pas de survol sur téléphone */
  }

  /* Place pour le bouton « Générer » fixé en bas */
  .app {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  /* Ligne 1 : logo + menu. Ligne 2 : modes sur toute la largeur */
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
  }

  .modes {
    order: 2;
    flex: 1 1 100%;
  }

  /* « Générer » : pleine largeur, fixé en bas de l'écran */
  .btn-generate {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 10;
    margin: 0;
    padding: 16px;
    font-size: 1.05rem;
    box-shadow: 0 10px 30px -10px rgba(23, 22, 26, 0.6);
  }

  .btn-generate:hover {
    transform: none;
  }

  /* Pas de touche Espace sur téléphone : l'aide ne sert plus */
  .hint {
    display: none;
  }

  .toast {
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }

  /* Les couleurs s'empilent en lignes */
  .palette {
    flex-direction: column;
  }

  .swatch {
    flex-direction: row;
    justify-content: space-between;
    padding: 0 20px;
  }

  .swatch:hover {
    flex: 1;
  }

  .tools {
    position: static;
    transform: none;
    flex-direction: row;
    order: 2;
  }

  .tool {
    opacity: 1;
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .swatch-info {
    align-items: flex-start;
    text-align: left;
  }

  .swatch-name {
    text-align: left;
    padding-left: 0;
  }

  .swatch-hex {
    font-size: 1.3rem;
  }

  .swatch-hsl {
    display: none;
  }

  .hero-palette {
    height: 140px;
  }
}
