/**
 * ============================================================
 * PLATYPUS JOURNAL — Design spécifique à l'application
 * Étend design-tokens.css (charte Platypus : crème, terracotta, sauge).
 *
 * IMPORTANT : design-tokens.css doit être importé AVANT ce fichier.
 * ============================================================
 */

/* ----------------------------------------------------------
 * ALIAS ET TOKENS DU JOURNAL
 *
 * Les anciens noms (--gold, --moss, --parchment, --ink…) restent
 * valables. Les teintes utilisées comme TEXTE sont légèrement
 * assombries pour atteindre un contraste AA (4,5:1) sur le crème.
 * ---------------------------------------------------------- */
:root {
  --ink:        var(--text);
  --ink-2:      rgba(26,18,8,0.74);   /* texte secondaire : 7,3:1 */
  --ink-3:      rgba(26,18,8,0.64);   /* texte tertiaire, légendes : 5,4:1 */
  --parchment:  var(--cream);
  --aged:       var(--sand);
  --gold:       var(--terracotta);         /* surfaces, traits, ornements */
  --gold-lt:    var(--terracotta-light);
  --gold-dk:    #9A5233;                   /* terracotta en texte : 5,2:1 */
  --moss:       #4F6D54;                   /* sauge en texte : 5,2:1 */
  --moss-lt:    var(--sage);
  --rust:       #94502F;
  --fog:        var(--border-sand);

  /* Couleurs sémantiques : une par famille d'étiquette, partout dans l'appli */
  --c-emotion:      #9A5233;   --c-emotion-fill: #C4714A;
  --c-besoin:       #4F6D54;   --c-besoin-fill:  #7A9B7F;
  --c-valeur:       #6B4F3A;   --c-valeur-fill:  #B4946C;

  /* Typographie — Cinzel autorisé dans le journal (cf. STYLE-GUIDE §11) */
  --ff-display: var(--font-cinzel);
  --ff-body:    var(--font-display);   /* Cormorant Garamond */
  --ff-accent:  var(--font-display);
  --ff-ui:      var(--font-body);      /* DM Sans : petits textes d'interface */

  --label-size:     0.78rem;           /* plancher des libellés en capitales (12,5 px) */
  --label-track:    0.14em;
  --ease-out:       cubic-bezier(0.22, 1, 0.36, 1);
  --focus-ring:     0 0 0 2px var(--parchment), 0 0 0 4px var(--moss);
  --app-bar-h:      0px;
}

/* ----------------------------------------------------------
 * RESET & BASE
 * ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scrollbar-color: var(--aged) transparent; }

body {
  font-family: var(--ff-body);
  background: var(--parchment);
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1.72;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
}

::selection { background: rgba(196,113,74,0.22); color: var(--ink); }
textarea, input { caret-color: var(--gold-dk); }
a { text-underline-offset: 0.18em; text-decoration-thickness: 1px; }

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Titre de page commun (h1) */
.page-title {
  font-family: var(--ff-display);
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--moss);
  text-align: center;
  line-height: 1.4;
  text-wrap: balance;
}
.page-lede {
  font-style: italic;
  color: var(--ink-2);
  text-align: center;
  font-size: 1.1rem;
  margin-top: 0.35rem;
  text-wrap: balance;
}

/* ----------------------------------------------------------
 * EN-TÊTE DE L'APPLI (rendu côté serveur : includes/appnav.php)
 * Un seul bandeau collant : marque + onglets.
 * ---------------------------------------------------------- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  padding-top: env(safe-area-inset-top);
  background: rgba(247,242,234,0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--aged);
}
.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 52px;
  text-decoration: none;
  color: var(--brown);
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.app-brand img { width: 28px; height: 28px; }
.app-brand em { color: var(--gold-dk); font-style: italic; }
.app-tabs { display: flex; align-items: stretch; }
.app-tabs a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 0.85rem;
  font-family: var(--ff-display);
  font-size: var(--label-size);
  letter-spacing: var(--label-track);
  text-transform: uppercase;
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
}
.app-tabs a:hover { color: var(--moss); }
.app-tabs a[aria-current="page"] { color: var(--moss); border-bottom-color: var(--gold); }

@media (max-width: 640px) {
  .app-bar { flex-wrap: wrap; gap: 0; padding: 0 0.5rem; padding-top: env(safe-area-inset-top); }
  .app-brand { min-height: 46px; padding: 0 0.5rem; font-size: 1.05rem; }
  .app-tabs { width: 100%; border-top: 1px solid rgba(217,204,186,0.6); overflow-x: auto; scrollbar-width: none; }
  .app-tabs::-webkit-scrollbar { display: none; }
  .app-tabs a { flex: 1 0 auto; min-height: 46px; padding: 0 0.45rem; letter-spacing: 0.06em; }
}

/* ============================================================
   BOUTONS
   ============================================================ */
.btn {
  font-family: var(--ff-display);
  font-size: 0.9rem;
  letter-spacing: var(--label-track);
  text-transform: uppercase;
  padding: 1rem 2rem;
  min-height: 56px;
  cursor: pointer;
  border-radius: 0;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out), background-color 0.3s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  width: 100%;
}
.btn small {
  display: block;
  font-family: var(--ff-body);
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  margin-top: 4px;
}

/* Bouton principal : terracotta profond, reflet lent qui reste sous le seuil de contraste */
.btn-gold {
  background: linear-gradient(120deg, #8F4C2F 0%, var(--gold-dk) 40%, #A85E3B 50%, var(--gold-dk) 60%, #8F4C2F 100%);
  background-size: 250% 100%;
  color: var(--parchment);
  border-color: #8F4C2F;
  animation: shimmer 6s ease-in-out infinite;
  flex-direction: column;
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(154,82,51,0.28); }
.btn-gold:disabled, .btn-gold.disabled {
  background: var(--aged);
  color: var(--ink-3);
  border-color: var(--aged);
  animation: none;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-moss { background: var(--moss); color: var(--parchment); border-color: var(--moss); }
.btn-moss:hover { background: #435E48; transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--moss); border-color: rgba(79,109,84,0.45); }
.btn-outline:hover { background: rgba(79,109,84,0.06); border-color: var(--moss); }
.btn-ghost {
  background: none; border: none; color: var(--ink-2);
  font-size: 1.05rem; letter-spacing: 0.02em; width: auto; min-height: 44px;
  padding: 0.5rem 1rem; cursor: pointer; text-decoration: underline;
  text-decoration-color: var(--aged);
  font-family: var(--ff-body); font-style: italic; text-transform: none;
}
.btn-ghost:hover { color: var(--ink); text-decoration-color: currentColor; }

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}

/* ============================================================
   CARTES
   ============================================================ */
.card {
  background: rgba(254,252,248,0.85);
  border: 1px solid var(--aged);
  padding: 2rem;
}
.card-gold { border-top: 2px solid var(--gold); }
.card-moss { border-top: 2px solid var(--moss-lt); }

/* Cadre avec coins accentués */
.frame {
  position: relative;
  border: 1px solid var(--gold);
  padding: 2.5rem;
  background: rgba(254,252,248,0.9);
}
.frame::before, .frame::after {
  content: '';
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--gold-dk);
  border-style: solid;
}
.frame::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.frame::after  { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

/* ============================================================
   FORMULAIRES
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}
.field label, .field-label {
  font-family: var(--ff-display);
  font-size: 0.85rem;
  letter-spacing: var(--label-track);
  text-transform: uppercase;
  color: var(--moss);
}
.field-hint { font-size: 0.98rem; font-style: italic; color: var(--ink-2); }
.field input,
.field textarea,
.field select {
  font-family: var(--ff-body);
  font-size: 1.15rem;
  color: var(--ink);
  background: rgba(247,242,234,0.6);
  border: none;
  border-bottom: 1px solid var(--sand);
  border-bottom-color: #BBA98F;
  padding: 0.7rem 0.4rem;
  transition: border-color 0.3s var(--ease-out), box-shadow 0.2s var(--ease-out);
  width: 100%;
  border-radius: 0;
  -webkit-appearance: none;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-bottom-color: var(--gold-dk);
  background: rgba(254,252,248,0.95);
  box-shadow: 0 2px 0 0 var(--gold-dk);
}
.field input::placeholder, .field textarea::placeholder {
  color: var(--ink-3);
  font-style: italic;
}
.field textarea {
  resize: vertical;
  min-height: 140px;
  border: 1px solid #BBA98F;
  padding: 1rem;
  line-height: 1.6;
}
.field textarea:focus { border-color: var(--gold-dk); box-shadow: 0 0 0 1px var(--gold-dk); }

/* ============================================================
   CARTES SÉLECTIONNABLES (émotion, besoin, valeur)
   Les vrais boutons radio / cases restent dans le flux (clavier,
   lecteur d'écran) : seule leur apparence est remplacée.
   ============================================================ */
fieldset.choice-group { border: none; min-width: 0; margin-top: 2.25rem; }
fieldset.choice-group > legend.section-title { margin-top: 0; float: left; }
fieldset.choice-group > legend.section-title + * { clear: both; }
.select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 0.6rem;
  margin-top: 0.75rem;
  align-items: stretch;
}
.select-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.select-label {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 56px;
  background: rgba(254,252,248,0.7);
  border: 1px solid var(--aged);
  padding: 0.85rem 0.75rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s var(--ease-out), background-color 0.2s var(--ease-out);
}
.select-label:hover { border-color: var(--gold-lt); background: rgba(196,113,74,0.05); }
.select-input:focus-visible + .select-label { box-shadow: var(--focus-ring); }
.select-input:checked + .select-label {
  background: rgba(79,109,84,0.09);
  border-color: var(--moss);
  box-shadow: inset 0 0 0 1px var(--moss);
}
.select-input:checked + .select-label::after {
  content: '';
  position: absolute;
  top: 7px; right: 7px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--moss);
}
.select-input:disabled + .select-label { opacity: 0.45; cursor: not-allowed; }
.select-title {
  font-family: var(--ff-display);
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  color: var(--moss);
  margin-bottom: 0.3rem;
  overflow-wrap: break-word;
  hyphens: auto;
}
.select-sub {
  font-family: var(--ff-body);
  font-size: 0.98rem;
  font-style: italic;
  color: var(--ink-2);
  line-height: 1.35;
  margin-top: auto;
}
/* Émotions : une simple étiquette, les familles sont des sous-titres */
.select-grid-compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.select-grid-compact .select-label { justify-content: center; padding: 0.7rem 0.5rem; }
.select-grid-compact .select-title { margin: 0; }
.choice-family {
  font-family: var(--ff-body);
  font-style: italic;
  font-size: 1.02rem;
  color: var(--ink-2);
  margin: 1rem 0 -0.3rem;
}

/* ============================================================
   ÉTIQUETTES (couleur = famille)
   ============================================================ */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0.75rem; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--ff-display);
  font-size: var(--label-size);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border: 1px solid var(--aged);
  color: var(--ink-2);
  background: rgba(254,252,248,0.6);
}
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.tag-emotion { color: var(--c-emotion); border-color: rgba(196,113,74,0.35); }
.tag-besoin  { color: var(--c-besoin);  border-color: rgba(122,155,127,0.45); }
.tag-valeur  { color: var(--c-valeur);  border-color: rgba(180,148,108,0.5); }

/* ============================================================
   BARRE D'ÉTAPES
   ============================================================ */
.steps-bar {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 0.75rem;
}
.step-dot {
  width: 38px;
  height: 4px;
  background: var(--aged);
  transition: background 0.3s var(--ease-out);
}
.step-dot.active { background: var(--gold); }
.steps-label {
  text-align: center;
  font-family: var(--ff-ui);
  font-size: 0.8rem;
  color: var(--ink-2);
  margin-bottom: 1.75rem;
}

/* ============================================================
   ORNEMENTS ET TITRES DE SECTION
   ============================================================ */
.ornament {
  text-align: center;
  color: var(--gold);
  letter-spacing: 0.5em;
  font-size: 1rem;
  margin: 1rem 0;
}
.section-title {
  display: block;
  width: 100%;
  font-family: var(--ff-display);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: var(--label-track);
  text-transform: uppercase;
  color: var(--moss);
  border-bottom: 1px solid var(--aged);
  padding-bottom: 0.6rem;
  margin-bottom: 0.25rem;
  margin-top: 2.25rem;
}
.section-title small {
  font-family: var(--ff-body);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  font-size: 1rem;
  color: var(--ink-2);
}

/* ============================================================
   ALERTES
   ============================================================ */
.alert {
  padding: 0.9rem 1.2rem;
  font-family: var(--ff-body);
  font-size: 1.05rem;
  margin-bottom: 1.25rem;
  border: 1px solid;
}
.alert-error  { background: rgba(148,80,47,0.06);  border-color: rgba(148,80,47,0.45); color: var(--rust); }
.alert-success{ background: rgba(79,109,84,0.07);  border-color: rgba(79,109,84,0.4);  color: var(--moss); }
.alert-gold   { background: rgba(196,113,74,0.08); border-color: rgba(196,113,74,0.4); color: var(--gold-dk); }

/* ============================================================
   BARRES DE STATS (constellation)
   ============================================================ */
.stat-row { margin-bottom: 1rem; }
.stat-info {
  display: flex;
  justify-content: space-between;
  font-size: 1.1rem;
  margin-bottom: 4px;
  color: var(--ink);
}
.stat-count {
  font-family: var(--ff-ui);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.stat-bar-bg {
  height: 5px;
  background: var(--aged);
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transition: transform 1.2s var(--ease-out);
}

/* ============================================================
   POLAROID
   ============================================================ */
.polaroid {
  background: var(--white);
  padding: 8px 8px 28px;
  border: 1px solid var(--aged);
  box-shadow: var(--shadow-md);
  text-align: center;
  transform: rotate(-1deg);
}
.polaroid img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  display: block;
}
.polaroid-caption {
  font-family: var(--ff-accent);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink);
  margin-top: 8px;
}

/* ============================================================
   ÉTAT VIDE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 1px dashed var(--aged);
  background: rgba(254,252,248,0.5);
}
.empty-state p { font-style: italic; color: var(--ink-2); font-size: 1.15rem; text-wrap: balance; }
.empty-state .btn { margin-top: 1.5rem; width: auto; display: inline-flex; padding: 0.9rem 2rem; }

/* ============================================================
   UTILITAIRES
   ============================================================ */
.container      { max-width: 480px; margin: 0 auto; padding: 1.5rem; }
.container-wide { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

/* Écran centré (connexion, inscription, bravo) : on centre un <main>, jamais le body */
.screen-center {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fade-up {
  from { opacity: 0.001; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fade-up 0.6s var(--ease-out) both; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .btn-gold { animation: none; background-position: 50% 50%; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
  .select-grid { grid-template-columns: 1fr 1fr; }
  .container { padding: 1rem; }
}
@media (max-width: 300px) {
  .select-grid, .select-grid-compact { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------
 * INSTALLATION DE L'APPLI (PWA)
 * ---------------------------------------------------------- */
.install-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1rem;
  margin-bottom: 1.5rem;
  background: rgba(254,252,248,0.9);
  border: 1px solid rgba(122,155,127,0.5);
}
.install-card[hidden] { display: none; }
.install-card img { width: 44px; height: 44px; flex-shrink: 0; border-radius: 10px; }
.install-text { flex: 1; font-size: 1.02rem; line-height: 1.4; color: var(--ink); }
.install-text strong {
  display: block;
  font-family: var(--ff-display);
  font-size: var(--label-size);
  letter-spacing: var(--label-track);
  text-transform: uppercase;
  font-weight: 400;
  color: var(--moss);
  margin-bottom: 0.15rem;
}
.install-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 0.15rem; }
.install-btn {
  font-family: var(--ff-display);
  font-size: var(--label-size);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--moss);
  color: var(--parchment);
  border: none;
  padding: 0.6rem 0.9rem;
  min-height: 44px;
  cursor: pointer;
}
.install-btn:hover { background: #435E48; }
.install-later {
  background: none;
  border: none;
  font-family: var(--ff-body);
  font-style: italic;
  font-size: 1rem;
  color: var(--ink-2);
  cursor: pointer;
  min-height: 36px;
  padding: 0.25rem 0.5rem;
}
