/* ==========================================================================
   Base — reset, layout général, typographie japonaise
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ja);
  font-size: var(--fs-base);
  line-height: 1.85;              /* le japonais respire mieux large */
  color: var(--encre);
  background: var(--fond);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, var(--sakura-soft), transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 100%, var(--lavande-soft), transparent 70%);
  background-attachment: fixed;
  overflow-x: hidden;             /* aucun scroll horizontal, jamais */
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol { margin: 0; }

/* Césure japonaise aux frontières de syntagme plutôt qu'au caractère près.
   Ignoré par les navigateurs qui ne le connaissent pas — amélioration pure. */
h1, h2, h3, p, .stone__title, .bubble, .phrase__ja {
  word-break: auto-phrase;
  line-break: strict;
}
ul, ol { padding: 0; list-style: none; }
img, svg { max-width: 100%; display: block; }
button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 3px solid var(--lavande);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

/* --- En-tête ------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  padding: 0 var(--sp-4);
  padding-top: env(safe-area-inset-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 249, 243, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--sakura-soft);
}

.app-title { display: flex; align-items: center; gap: var(--sp-2); }
.app-title__mark { font-size: 1.5rem; }
.app-title__text { display: flex; flex-direction: column; line-height: 1.15; }
.app-title__text b     { font-family: var(--font-fr); font-size: var(--fs-md); font-weight: 700; letter-spacing: .01em; }
.app-title__text small { font-size: var(--fs-xs); color: var(--encre-doux); font-weight: 500; }

.streak-chip[hidden] { display: none; }   /* sinon le display:flex écrase l'attribut */
.streak-chip {
  display: flex; align-items: center; gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  background: var(--citron);
  border-radius: var(--r-full);
  font-weight: 700;
  font-size: var(--fs-sm);
  box-shadow: var(--sh-sm);
}

/* --- Zone principale ----------------------------------------------------- */
.app-main {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4);
  padding-bottom: calc(var(--tabbar-h) + var(--sp-7) + env(safe-area-inset-bottom));
}
.app-main:focus { outline: none; }

/* --- Barre d'onglets ----------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-top: 2px solid var(--sakura-soft);
}

.tab {
  flex: 1;
  min-height: var(--tap);
  padding: var(--sp-2) 0 var(--sp-3);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--encre-pale);
  transition: color .2s, transform .2s;
}
.tab__ico { font-size: 1.35rem; line-height: 1; filter: grayscale(.7); transition: filter .2s, transform .2s; }
.tab__lbl { font-size: 0.65rem; font-weight: 700; }

.tab.is-active           { color: var(--accent); }
.tab.is-active .tab__ico { filter: none; transform: translateY(-2px) scale(1.12); }
.tab:active              { transform: scale(.94); }

/* --- Titres de section --------------------------------------------------- */
.page-title {
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.4;
  margin-bottom: var(--sp-2);
}
.page-lede {
  color: var(--encre-doux);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-5);
}

/* --- Utilitaires --------------------------------------------------------- */
.stack > * + * { margin-top: var(--sp-4); }
.center { text-align: center; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Écrans larges : on garde une colonne, juste plus d'air -------------- */
@media (min-width: 700px) {
  :root { --header-h: 68px; }
  .app-main { padding: var(--sp-6) var(--sp-5); }
}
