/* ==========================================================================
   Win'O'Meal — prototype d'app, habillage High-Fi V2A
   Données en dur, aucun backend. Un fichier HTML par écran.
   ========================================================================== */

:root {
  /* Palette V2A */
  --ink: #2B2424;
  --bordeaux: #7C2D3B;
  --or: #B6863C;
  --paper: #F7F1E8;
  --card: #FFFDF9;

  /* Neutres dérivés de la maquette */
  --border: #E0D5C2;
  --border-light: #E9E0D2;
  --text-mid: #574B46;
  --chip-bg: #F3E3E1;
  --star: #E8C988;

  /* Variantes assombries : les tons de la maquette échouaient WCAG AA sur
     fond paper/card. Même teinte, luminosité descendue jusqu'à 4.5:1. */
  --text-muted: #776C61;   /* maquette #9C9186 — 2.75:1 */
  --nav-idle: #786C5B;     /* maquette #A89C8C — 2.40:1 */
  --or-text: #8C672E;      /* maquette #B6863C — 3.20:1 sur carte */
  --chevron: #A09179;      /* maquette #C2B8A9 — 1.93:1 */

  /* Dégradés de robe */
  --grad-rouge: linear-gradient(160deg, #E3D4C2, #C9A97E);
  --grad-blanc: linear-gradient(160deg, #F1EAD9, #D8C6AB);
  --grad-rose: linear-gradient(160deg, #F0D9D9, #D9A8AC);
  --grad-brun: linear-gradient(160deg, #E6D8C4, #B99A6F);

  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  --nav-h: 76px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--ink);
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* Sur mobile l'app occupe l'écran ; sur desktop elle est cadrée en 390px. */
.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 390px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  overflow: hidden;
}

/* Sur desktop, châssis de téléphone. La hauteur cède si la fenêtre est
   plus courte que 844px, sinon la nav basse passe sous le pli. */
@media (min-width: 480px) {
  body { padding: 28px 0; }
  .app {
    min-height: 0;
    height: min(844px, calc(100dvh - 56px));
    border: 1px solid var(--border);
    border-radius: 44px;
    box-shadow: 0 20px 50px rgba(43, 36, 36, 0.35);
  }
}

/* Zone défilante ; la marge basse dégage la nav fixe. */
.screen {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 22px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.screen.has-nav { padding-bottom: calc(var(--nav-h) + 28px); }
/* Une fiche qui reçoit la nav de navigation.js garde la place de la barre :
   ses boutons du bas restent au-dessus. */
.app.nav-ajoutee { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }
.screen.flush { padding-left: 20px; padding-right: 20px; }

/* ============================ Typographie ============================ */

.title {
  font: 600 26px/1.2 var(--serif);
  color: var(--ink);
  margin: 0;
}

.title-lg {
  font: 700 24px/1.25 var(--serif);
  color: var(--ink);
  margin: 0;
}

.subtitle {
  font: 400 13px var(--sans);
  color: var(--text-muted);
}

.label {
  font: 700 11px var(--mono);
  color: var(--or-text);
  letter-spacing: 0.03em;
}

.label-muted {
  font: 600 11px var(--mono);
  color: var(--text-muted);
}

.head { display: flex; flex-direction: column; gap: 2px; }

.body-text {
  font: 400 13px/1.5 var(--sans);
  color: var(--text-mid);
}

/* ============================ Cartes ============================ */

.card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 3px 10px rgba(43, 36, 36, 0.05);
}

/* Vignette de robe : dégradé + pastille de couleur. */
.thumb {
  border-radius: 14px;
  flex: none;
  background: var(--grad-rouge);
  position: relative;
}

.thumb.blanc { background: var(--grad-blanc); }
.thumb.rose { background: var(--grad-rose); }
.thumb.brun { background: var(--grad-brun); }

.dot {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bordeaux);
  border: 2px solid var(--card);
}

.dot.blanc { background: #E8DFC0; }
.dot.rose { background: #D98A92; }
/* Effervescents et liquoreux (.thumb.brun) : un point dore, faute de quoi
   ils prenaient le point bordeaux d'un rouge. */
.dot.brun { background: var(--star); }

/* La vignette d'un vin dans une case qui existe déjà (vignette-vin.js) :
   l'accueil, la fiche plat et la recette ont chacun leur carré, plus petit
   que celui de la Cave. La vignette le remplit et en reprend les arrondis ;
   la pastille rapetisse avec. L'étiquette en entier, comme dans la Cave. */
.vignette-vin { width: 100%; height: 100%; border-radius: inherit; overflow: hidden; }
.vignette-vin .dot { top: 5px; left: 5px; width: 10px; height: 10px; border-width: 1.5px; }
.vignette-vin img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: none; }
.vignette-vin.avec-photo img { display: block; }

/* ============================ Contrôles ============================ */

.search {
  height: 46px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  font: 400 13px var(--sans);
  color: var(--text-muted);
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  font: 600 12px var(--sans);
  color: var(--text-mid);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 13px;
  background: transparent;
  cursor: pointer;
}

.chip.on {
  color: var(--paper);
  background: var(--bordeaux);
  border-color: var(--bordeaux);
}

/* `hidden` doit gagner sur tout `display` posé par une classe : sans ça, un
 * bloc en flex reste visible une fois masqué. Valable pour tous les écrans. */
[hidden] { display: none !important; }

/* Stickers d'une fiche (stickers.js) : ambre pour la cuisson déclarée, vert
 * pour les régimes calculés, neutre pour le pratique. Capsules à bordure
 * fine, jamais de fond plein — elles ne concurrencent pas la carte du vin. */
.stickers { display: flex; gap: 6px; flex-wrap: wrap; }
.sticker {
  display: inline-flex; align-items: center;
  font: 600 11px var(--sans); letter-spacing: .02em;
  border-radius: 999px; padding: 4px 10px;
  border: 1px solid var(--border); color: var(--text-mid); background: var(--card);
}
.sticker.cuisson { border-color: var(--or-text); color: var(--or-text); }
.sticker.regime { border-color: #4F6B4A; color: #4F6B4A; }
.sticker.mini { font-size: 8.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 6px; white-space: nowrap; }

/* Bascule à deux volets. */
.toggle {
  height: 44px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border-light);
  display: flex;
  padding: 4px;
  gap: 4px;
  flex: none;
}

.toggle button {
  flex: 1;
  border: none;
  border-radius: 11px;
  background: transparent;
  font: 600 13px var(--sans);
  color: var(--text-muted);
  cursor: pointer;
}

.toggle button.on {
  background: var(--bordeaux);
  color: var(--paper);
  font-weight: 700;
}

.btn {
  height: 52px;
  border-radius: 14px;
  background: var(--bordeaux);
  color: var(--paper);
  font: 700 15px var(--sans);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  cursor: pointer;
  text-decoration: none;
}

.btn.ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-mid);
  font-weight: 600;
  font-size: 14px;
  height: 48px;
}

.btn.outline-ink {
  background: transparent;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  height: 50px;
}

.tag {
  font: 600 12px var(--sans);
  color: var(--bordeaux);
  background: var(--chip-bg);
  border-radius: 14px;
  padding: 6px 13px;
}

.tag.sm { font-size: 10px; border-radius: 10px; padding: 3px 8px; }

.tag.or {
  color: var(--or-text);
  background: transparent;
  border: 1.5px solid #D9C091;
}

.stars { font: 600 13px var(--sans); color: var(--or-text); }
.stars.on-wine { color: var(--star); }

/* ============================ Barre d'action ============================ */

.actions {
  flex: none;
  padding: 14px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper);
}

.topbar {
  flex: none;
  padding: 10px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--card);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
}

/* ============================ Navigation basse ============================ */

.nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-h);
  background: var(--paper);
  border-top: 1px solid var(--border-light);
  padding: 12px 18px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 56px;
  text-decoration: none;
  color: var(--nav-idle);
  font: 600 10px var(--sans);
}

.nav a.on { color: var(--bordeaux); font-weight: 700; }

/* Le libellé du bouton central se cale sous le disque en saillie. */
.nav .slot { width: 64px; }

/* Surclasse `.nav a`, qui sinon impose le gris inactif au verre. */
.nav a.fab {
  position: absolute;
  left: 50%;
  top: -26px;
  transform: translateX(-50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bordeaux);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 22px rgba(124, 45, 59, 0.45);
  border: 4px solid var(--paper);
  color: var(--paper);
  text-decoration: none;
  width: 64px;
  height: 64px;
  gap: 0;
}

.fab-label {
  position: absolute;
  left: 50%;
  top: 44px;
  transform: translateX(-50%);
  font: 700 10px var(--sans);
  color: var(--bordeaux);
  text-decoration: none;
}

/* Bouton d'ajout flottant. */
.fab-add {
  position: absolute;
  right: 22px;
  bottom: calc(var(--nav-h) + 18px);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--bordeaux);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 20px rgba(124, 45, 59, 0.4);
  border: none;
  color: var(--paper);
  cursor: pointer;
  z-index: 2;
}

/* Sur téléphone, la barre et le bouton d'ajout restent à l'écran.
 *
 * `.app` n'y a qu'une hauteur minimale : une longue page la fait grandir, et
 * c'est la page entière qui défile. En `absolute`, la barre suivait le bas de
 * `.app`, donc le bas de la page — sur repas.html, 7 500 px plus bas, hors de
 * vue tant qu'on n'avait pas tout parcouru. En `fixed`, elle reste collée au
 * bas de l'écran, et la page garde son défilement naturel (barre d'adresse
 * qui se replie, retour en haut d'un toucher sur l'heure).
 *
 * Même largeur que `.app` (390 px au plus), centrée. La marge du bas suit la
 * zone de l'indicateur d'accueil des iPhone, que viewport-fit=cover laisse
 * sous le contenu. Au-delà de 480 px, le châssis a une hauteur fixe : la
 * barre y reste en `absolute`, au bas du châssis. */
@media (max-width: 479px) {
  .nav {
    position: fixed;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 100%;
    max-width: 390px;
    z-index: 5;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .fab-add {
    position: fixed;
    right: max(22px, calc((100% - 390px) / 2 + 22px));
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 18px);
  }
  .screen.has-nav {
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 28px);
  }
}

/* ============================ Accessibilité ============================ */

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--bordeaux);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
