/* The app's own styles: screen layout and p-* classes taken from the prototype (proto.css).
   Loaded after the design system: values in tokens.css, h-* components in components.css. */

/* A reader's variables */
.lc-indigo  { --c: var(--indigo);  --on: var(--on-indigo);  --bd: var(--indigo-bord);  --tt: var(--indigo-teinte); }
.lc-abricot { --c: var(--abricot); --on: var(--on-abricot); --bd: var(--abricot-bord); --tt: var(--abricot-teinte); }
.lc-menthe  { --c: var(--menthe);  --on: var(--on-menthe);  --bd: var(--menthe-bord);  --tt: var(--menthe-teinte); }
.lc-brique  { --c: var(--brique);  --on: var(--on-brique);  --bd: var(--brique-bord);  --tt: var(--brique-teinte); }
.lc-lavande { --c: var(--lavande); --on: var(--on-lavande); --bd: var(--lavande-bord); --tt: var(--lavande-teinte); }
.lc-dragee  { --c: var(--dragee);  --on: var(--on-dragee);  --bd: var(--dragee-bord);  --tt: var(--dragee-teinte); }

body { margin: 0; background: var(--papier); color: var(--encre); font-family: var(--font-texte); -webkit-font-smoothing: antialiased; }
/* The design system's 86px bar draws the home indicator of its phone frame: the app gets it from the safe area instead */
:root { --app-nav: 58px; }
main { padding-bottom: calc(var(--app-nav) + env(safe-area-inset-bottom)); }

/* The view picker lives under the title of the screens it changes; navigation at the bottom */
main:not(:has(.p-onb)) { padding-top: env(safe-area-inset-top); }
.p-ecran > .h-selecteur { padding: 0; }
.app-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; box-sizing: border-box; height: calc(var(--app-nav) + env(safe-area-inset-bottom)); padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
.h-nav__item { text-decoration: none; }
.h-ligne, .h-jeton { text-decoration: none; }
/* A borrowing row: token and series on top, its actions (Lu, Rendre) on their own line */
.h-ligne--emprunt { flex-wrap: wrap; box-sizing: border-box; }
.h-ligne__actions a { color: inherit; text-decoration: none; }
.h-ligne--emprunt .h-ligne__corps { color: inherit; text-decoration: none; }
.h-ligne__jeton { width: var(--jeton); flex: none; }
.h-ligne__actions { flex-basis: 100%; display: flex; justify-content: flex-end; gap: var(--esp-2); padding-bottom: 4px; }
.h-ligne__actions form { display: contents; }
.h-ligne__actions .h-choix { padding: 0 14px; }
/* A token in a list row keeps its own size instead of filling the row */
.h-ligne > .h-jeton { width: 56px; min-width: 56px; flex: none; }
/* button_to forms must not break button rows */
.h-selecteur form, .h-choix-ligne form, .h-feuille__actions form { display: contents; }

.p-ecran { display: flex; flex-direction: column; gap: 16px; padding: 6px 16px 32px; animation: p-entree 220ms var(--courbe-standard) both; }
.p-titre { margin: 0; font: 800 28px/32px var(--font-texte); letter-spacing: -0.02em; }
.p-section { display: flex; flex-direction: column; gap: 8px; }
ul.h-liste { margin: 0; padding: 0; list-style: none; }
.p-texte { margin: 0; font: 500 16px/24px var(--font-texte); color: var(--encre-douce); text-wrap: pretty; }
/* Onboarding: full screen, no view selector, no bottom nav */
.p-onb { display: flex; flex-direction: column; gap: 20px; min-height: 100dvh; box-sizing: border-box; padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
.p-onb__pied { margin-top: auto; }
.p-onb__pied form { display: contents; }
.p-secondaire { margin: 0; font: 500 14px/20px var(--font-texte); color: var(--encre-douce); text-wrap: pretty; }
.p-erreur { color: var(--erreur); }
/* A confirmation screen titles its volume like a sheet does */
.h-feuille__tete h1.p-titre { font-size: 22px; line-height: 26px; }
.p-courant { background: var(--tt); }
.p-retour { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; margin-left: -6px; padding-right: 8px; font: 700 16px/20px var(--font-texte); color: var(--encre); text-decoration: none; }
.p-retour svg { width: 20px; height: 20px; }
.p-retour:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Message de confirmation : apparaît, puis s'efface seul */
.p-toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--app-nav) + 14px + env(safe-area-inset-bottom)); z-index: 30; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--rayon-m); background: var(--encre); color: var(--papier); font: 700 15px/20px var(--font-texte); box-shadow: var(--ombre-feuille); pointer-events: none; animation: p-toast 220ms var(--courbe-standard) both, p-toast-sortie 200ms 2.6s var(--courbe-sortie) forwards; }
.p-toast svg { width: 20px; height: 20px; flex: none; }

/* Sheet: a native dialog sitting at the bottom of the screen */
dialog.feuille { width: 100%; max-width: none; max-height: calc(100dvh - 48px); margin: auto 0 0; padding: 0; border: 0; background: transparent; overflow-y: auto; }
dialog.feuille::backdrop { background: rgba(10, 12, 24, 0.42); }
dialog.feuille[open] { animation: p-monte var(--duree-feuille) var(--courbe-standard) both; }
dialog.feuille .h-feuille { position: static; padding-bottom: calc(34px + env(safe-area-inset-bottom)); }

@keyframes p-entree { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes p-monte { from { transform: translateY(100%); } to { transform: none; } }
@keyframes p-toast { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes p-toast-sortie { to { opacity: 0; } }
@keyframes p-fondu { from { opacity: 0; } to { opacity: 1; } }

.p-viseur { position: relative; height: 188px; flex: none; border-radius: var(--rayon-l); background: #111; color: #fff; overflow: hidden; }
.p-viseur__video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.p-coin { position: absolute; width: 26px; height: 26px; border: 3px solid #fff; }
.p-coin--hg { top: 30px; left: 44px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.p-coin--hd { top: 30px; right: 44px; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.p-coin--bg { bottom: 46px; left: 44px; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.p-coin--bd { bottom: 46px; right: 44px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
.p-viseur__ligne { position: absolute; left: 60px; right: 60px; top: 70px; height: 2px; border-radius: 1px; background: #fff0a6; animation: p-balaye 1.6s ease-in-out infinite alternate; }
.p-viseur__texte { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); padding: 2px 12px; border-radius: 999px; background: #111; color: #fff; text-align: center; font: 600 13px/18px var(--font-texte); }

@keyframes p-balaye { from { transform: translateY(-34px); } to { transform: translateY(34px); } }

@media (prefers-reduced-motion: reduce) {
  .p-viseur__ligne { animation: none; }
  .p-ecran, dialog.feuille[open] { animation: p-fondu var(--duree-fondu) linear both; }
  .p-toast { animation: p-fondu var(--duree-fondu) linear both, p-toast-sortie var(--duree-fondu) 2.6s linear forwards; }
}

.h-entete-etagere h2 { margin: 0; flex: 1; font: 800 18px/22px var(--font-texte); letter-spacing: -.01em; }

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

.h-nav .h-scanner--nav { grid-column: 3; }
.h-scanner { text-decoration: none; }

/* Text inputs: no input component in the design system yet */
.p-saisie { box-sizing: border-box; width: 100%; min-height: 48px; padding: 10px 14px; border: 1.5px solid var(--trait-fort); border-radius: var(--rayon-m); background: var(--surface); color: var(--encre); font: 500 17px/24px var(--font-texte); }
.p-saisie:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.p-saisie:user-invalid { border-color: var(--erreur); }
.h-encart--erreur { background: var(--erreur-teinte); flex-direction: column; align-items: flex-start; }

/* Native radios and checkboxes inside .h-choix: the checked state shows on the button */
fieldset.h-champ { margin: 0; padding: 0; border: 0; min-width: 0; }
.h-choix input { position: absolute; opacity: 0; pointer-events: none; }
.h-choix:has(input:checked) { background: var(--encre); color: var(--papier); box-shadow: none; }
.h-choix:has(input:disabled) { opacity: 0.7; }
.h-choix:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Links styled as buttons: a <button> is border-box and plain by default, an <a> is not */
a.h-bouton { box-sizing: border-box; }
a.h-bouton--principal { text-decoration: none; }

/* Foyer screen */
.p-identifiant { margin: 0; font: 800 20px/24px ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .02em; color: var(--encre-douce); }
/* border-box, or .h-ligne's min-height of 64px comes on top of the padding */
.p-progression { padding-block: 12px; box-sizing: border-box; }
.h-ligne--lecteur { flex-wrap: wrap; box-sizing: border-box; }
.p-renommer { display: flex; align-items: center; gap: var(--esp-2); flex-direction: row; flex: 1 1 200px; }
.p-renommer .p-saisie { min-height: 44px; width: auto; flex: 1; min-width: 0; font-weight: 700; }
.p-renommer .h-bouton { flex: none; padding: 0 8px; font-size: 14px; }
.p-ce-telephone, .h-ligne--lecteur .h-badge { margin-left: auto; flex: none; }
.p-ce-telephone .h-bouton { font-size: 14px; padding: 0 8px; }
.p-erreurs { flex-basis: 100%; }
.p-carre-lieu { width: 32px; height: 32px; border-radius: 8px; }
.p-carre-lieu svg { width: 18px; height: 18px; }
