/* ABBA Bâtisseur — habillage commun à Life, Formation et Mise en Action.
   UN SEUL endroit pour tout changer : ce fichier (et habillage.js). Chaque app l'appelle avec
   <html data-espace="life|formation|action">. L'image du bandeau est celle de l'accueil
   (fond-accueil.webp) : même adresse = déjà en mémoire de l'appareil, aucun téléchargement de plus. */

/* ---------- Couleur de chaque espace (comme sur l'accueil) ---------- */
html[data-espace="life"]      { --hab:#2e7d4f; --hab-fonce:#17472c; --hab-clair:#8fdcab; --hab-pale:#e3f2e8; }
html[data-espace="formation"] { --hab:#1a2d6b; --hab-fonce:#0f1b45; --hab-clair:#a9bdff; --hab-pale:#e5ebfb; }
html[data-espace="action"]    { --hab:#b8962e; --hab-fonce:#6b5006; --hab-clair:#f0cf6b; --hab-pale:#f8efd2; }
html[data-theme="dark"][data-espace="life"]   { --hab:#4fae74; --hab-pale:#1f3a2a; }
html[data-theme="dark"][data-espace="action"] { --hab:#d9b95a; --hab-pale:#3a3118; }
html[data-theme="dark"][data-espace="formation"] { --hab:#7c9bee; --hab-pale:#1b2650; }

/* ---------- Entête commune : image de l'accueil, voilée de la couleur de l'espace ---------- */
html[data-espace] .topbar {
  position: sticky; top: 0; z-index: 40; box-shadow: 0 3px 10px rgba(0,0,0,.18); /* l'entête reste en haut quand on fait défiler */
  isolation: isolate; overflow: hidden;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  border-bottom: 3px solid var(--hab-clair);
  border-radius: 0 0 16px 16px;
  background: var(--hab-fonce);
  min-height: 66px;
}
html[data-espace] .topbar .hab-fond {
  position: absolute; inset: 0; z-index: -2;
  background: var(--hab-fonce) url("/abba-batisseur/fond-accueil.webp") right bottom / cover no-repeat;
}
html[data-espace] .topbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, var(--hab-fonce) 0%, color-mix(in srgb, var(--hab) 80%, transparent) 55%, color-mix(in srgb, var(--hab) 35%, transparent) 100%);
}
html[data-espace] .topbar .brand { gap: 10px; min-width: 0; }
html[data-espace] .topbar a.hab-logo { display: block; flex: none; line-height: 0; border-radius: 50%; -webkit-tap-highlight-color: transparent; }
html[data-espace] .topbar .brand-logo { width: 40px; height: 40px; flex: 0 0 40px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.35)); }
html[data-espace] .topbar .brand-name { color: #fff; font-size: 19px; text-shadow: 0 1px 6px rgba(0,0,0,.4); }
html[data-espace] .topbar .brand-sub { color: var(--hab-clair); font-size: 10.5px; text-shadow: 0 1px 4px rgba(0,0,0,.4); }
html[data-espace] .topbar .topbar-right { gap: 8px; }
html[data-espace] .topbar .topbar-date { color: #fff; font-size: 11px; line-height: 1.25; white-space: nowrap; text-align: right; text-shadow: 0 1px 4px rgba(0,0,0,.45); }
html[data-espace] .topbar .theme-toggle,
html[data-espace] .topbar .hab-aa {
  background: rgba(255,255,255,.92); color: var(--hab-fonce); border: none;
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.25); font-weight: 700; font-size: 14px; font-family: inherit;
}
html[data-theme="dark"][data-espace] .topbar .theme-toggle,
html[data-theme="dark"][data-espace] .topbar .hab-aa { background: rgba(20,28,50,.88); color: #fff; }

/* Boîte « taille du texte » (Aa) */
.hab-taille { position: fixed; top: calc(60px + env(safe-area-inset-top, 0px)); right: 10px; z-index: 2147482000; display: flex; align-items: center; gap: 8px;
  background: var(--card-bg, #fff); color: var(--ink, #222); border: 1px solid var(--line, #ddd); border-radius: 14px; padding: 8px 10px; box-shadow: 0 6px 20px rgba(0,0,0,.28); }
.hab-taille[hidden] { display: none; }
.hab-taille button { border: 1px solid var(--line, #ddd); background: var(--paper, #f4f0e4); color: var(--hab); border-radius: 10px; font-weight: 700; font-size: 15px; min-width: 40px; height: 36px; cursor: pointer; }
.hab-taille .hab-t { font-size: 12px; opacity: .75; }
.hab-taille .hab-v { min-width: 44px; text-align: center; font-size: 13px; font-weight: 600; }

/* ---------- Cadre de salutation commun (le cadre bleu du Parcours) ---------- */
html[data-espace] .hab-salut {
  position: relative; overflow: hidden; margin: 0 0 11px; padding: 14px 16px 13px;
  border-radius: 14px; color: #fff;
  background: linear-gradient(135deg, #1a3260 0%, #0d1f45 60%, #1a3260 100%);
  border-left: 5px solid var(--hab-clair);
  box-shadow: 0 4px 18px rgba(31,59,87,.3), 0 0 0 1px rgba(201,162,39,.28);
}
html[data-espace] .hab-salut::after { content: ""; position: absolute; top: -40px; right: -40px; width: 150px; height: 150px; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--hab-clair) 30%, transparent) 0%, transparent 70%); }
html[data-espace] .hab-salut .hab-salut-nom { position: relative; z-index: 1; margin: 0 0 4px; font-size: 16px; font-weight: 700; color: #e6c04f; }
html[data-espace] .hab-salut .hab-salut-phrase { position: relative; z-index: 1; margin: 0; font-size: 13px; line-height: 1.45; color: var(--hab-clair); }
html[data-espace] .hab-salut .link-btn { position: relative; z-index: 1; margin-top: 7px; color: #fff; text-decoration-color: var(--hab-clair); }

/* ---------- Couleur de l'espace dans les éléments de l'app ---------- */
html[data-espace] .card,
html[data-espace] .category { border-left: 3px solid var(--hab); }
html[data-espace] .eyebrow,
html[data-espace] .category-frac,
html[data-espace] .tab-num { color: var(--hab); }
html[data-espace] .panel-head h1,
html[data-espace] .category-title,
html[data-espace] .brand-name-x { color: var(--hab); }
html[data-theme="dark"][data-espace] .panel-head h1,
html[data-theme="dark"][data-espace] .category-title { color: var(--ink); }
html[data-espace] .link-btn { text-decoration-color: var(--hab); }
html[data-espace] .btn-primary { background: var(--hab); border-color: var(--hab); color: #fff; }
html[data-espace="action"] .btn-primary { color: #1f1700; }
html[data-espace] .tab.active { border-bottom-color: var(--hab); }
html[data-espace] .bnav-btn.active { color: var(--hab); }
html[data-espace] .bnav-btn.active svg { color: var(--hab); }
html[data-espace] .seal-progress { stroke: var(--hab); }
html[data-espace] .tithe-strip { background: var(--hab-pale); }

/* ---------- Plus compact : UNE seule distance entre deux cadres (avant : marge + écart = 32 px) ---------- */
html[data-espace] { --hab-ecart: 9px; }
html[data-espace] .content { padding: 12px 14px 24px; }
/* Sur téléphone : de l'espace sous le dernier élément pour qu'il sorte entièrement au-dessus de la barre d'onglets du bas */
@media (max-width: 640px) { html[data-espace] .content { padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); } }
html[data-espace] .card { padding: 11px 14px; margin-bottom: var(--hab-ecart); }
html[data-espace] .category { padding: 11px 14px; }
html[data-espace] .categories { gap: var(--hab-ecart); }
/* Dans une grille, l'écart de la grille suffit : on retire la marge du cadre (c'était le doublon) */
html[data-espace] .dash-grid,
html[data-espace] .finance-grid { gap: var(--hab-ecart); }
html[data-espace] .dash-grid > .card,
html[data-espace] .finance-grid > .card { margin-bottom: 0; }
html[data-espace] .panel-head { margin-bottom: 10px; }
html[data-espace] .panel-head h1 { font-size: 22px; }
html[data-espace] .budget-block { margin-bottom: 10px; }
html[data-espace] .eyebrow { margin-bottom: 6px; }
html[data-espace] .ledger-row { padding: 4px 0; }
html[data-espace] .ledger-row.total { padding-top: 6px; }
html[data-espace] .tithe-strip { margin: 7px 0; padding: 6px 10px; }
html[data-espace] .week-day { gap: 4px; }
html[data-espace] .verse-card { padding: 11px 14px; }
html[data-espace] .verse-text { font-size: 15px; margin-bottom: 5px; line-height: 1.4; }
html[data-espace] .check-item { padding: 7px 0; }

/* ---------- Cadre de salutation de Parcours / Mise en Action (même cadre bleu, teinté de la couleur de l'espace) ---------- */
html[data-espace] .abba-invite-card { margin: 0 0 11px; border-left: 5px solid var(--hab-clair); border-radius: 14px; }
html[data-espace] .abba-invite-content { padding: 14px 16px 13px; }
html[data-espace] .abba-invite-glow { background: radial-gradient(circle, color-mix(in srgb, var(--hab-clair) 30%, transparent) 0%, transparent 70%); }
html[data-espace] .abba-invite-greeting { margin-bottom: 4px; color: #e6c04f; }
html[data-espace] .abba-invite-text { color: var(--hab-clair); line-height: 1.45; }

/* Petits blocs de l'accueil Parcours / Mise en Action */
html[data-espace] .dash-tools { gap: var(--hab-ecart); margin-bottom: var(--hab-ecart); }
html[data-espace] .dash-tools-title { margin: 12px 4px 6px; }
html[data-espace] .dash-tool { padding: 8px 10px; border-left: 3px solid var(--hab); }
html[data-espace] .dash-tasks { padding: 10px 14px; margin-bottom: var(--hab-ecart); }
html[data-espace] .tab.active { color: var(--hab); }
html[data-espace] .dash-card { padding: 11px 14px; }

/* Entêtes plus longues (Formation, Mise en Action) : on garde tout sur un petit écran */
@media (max-width: 420px) {
  html[data-espace="formation"] .topbar .brand-name,
  html[data-espace="action"] .topbar .brand-name { font-size: 17px; line-height: 1.1; }
  html[data-espace="formation"] .topbar .brand-sub,
  html[data-espace="action"] .topbar .brand-sub { font-size: 9.5px; letter-spacing: .03em; }
  html[data-espace="formation"] .topbar .topbar-date,
  html[data-espace="action"] .topbar .topbar-date { font-size: 10px; }
  html[data-espace="formation"] .topbar .topbar-right,
  html[data-espace="action"] .topbar .topbar-right { gap: 6px; }
}

/* Cercle à gauche, texte à droite (au lieu de tout centrer sur la largeur) */
html[data-espace] .seal-card { display: grid; grid-template-columns: 96px 1fr; column-gap: 14px; align-items: center; text-align: left; }
html[data-espace] .seal-card .seal { grid-row: 1 / span 2; }
html[data-espace] .seal-card .card-caption { grid-column: 2; align-self: end; }
html[data-espace] .seal-card .link-btn { grid-column: 2; align-self: start; justify-self: start; padding-left: 0; text-align: left; }
html[data-espace] .seal-card .seal { width: 96px; height: 96px; flex: 0 0 96px; margin: 0; }
html[data-espace] .seal-card .seal svg { width: 96px; height: 96px; }
html[data-espace] .seal-card .seal-pct { font-size: 22px; }
html[data-espace] .seal-card .card-caption { margin: 0 0 6px; font-size: 14px; color: var(--ink); font-weight: 600; }

/* Petits cadres deux par deux */
.hab-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.hab-duo > * { margin: 0 !important; min-width: 0; }

/* Image en filigrane : accueil seulement, jamais sur les formulaires ni les lectures */
html[data-espace] #panel-accueil { position: relative; isolation: isolate; }
html[data-espace] #panel-accueil::before {
  content: ""; position: absolute; inset: -6px -14px -28px; z-index: -1; pointer-events: none;
  background: url("/abba-batisseur/fond-accueil.webp") right bottom / cover no-repeat; opacity: .07;
}
html[data-theme="dark"][data-espace] #panel-accueil::before { opacity: .04; }
html[data-espace] #panel-accueil .dash-grid .card { background: color-mix(in srgb, var(--card-bg) 90%, transparent); }
html[data-espace] #panel-accueil .dash-grid .verse-card { background: var(--navy); }

@media (prefers-reduced-motion: reduce) { html[data-espace] * { transition: none !important; animation: none !important; } }
