/* ==========================================================================
   ALTAIDE — BASE
   Reset, typography, header, page titles, buttons, inputs, bottom nav.
   Load AFTER tokens.css, BEFORE style.css.
   Everything here reads tokens. No literal colours, no literal radii.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700&family=Public+Sans:wght@400;500;600;700&family=Comfortaa:wght@400;700&display=swap');

/* --- Reset --------------------------------------------------------------- */

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-main);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* webview bounce */
}

button, input, select, textarea {
  font-family: inherit;
  font-size: var(--text-base);
  color: inherit;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-strong); }

img { max-width: 100%; }

/* --- Typography ----------------------------------------------------------
   One scale. Headings no longer share a single 17px rule that every view
   then had to override inline. */

h1, h2, h3, h4 {
  font-family: var(--font-titles);
  font-weight: var(--weight-bold);
  color: var(--text-strong);
  letter-spacing: var(--tracking-title);
  line-height: var(--leading-tight);
  margin: 0;
}

h1 { font-size: var(--text-display); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); letter-spacing: -0.02em; }

p { margin: 0; }

strong { font-weight: var(--weight-semibold); }

/* Small uppercase label above a group. Replaces the ad-hoc
   800/13px/uppercase declarations scattered through the views. */
.eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-subtle);
}

/* --- Page title ---------------------------------------------------------
   Left-aligned, one size, sub-line directly under it. The old
   .top-of-sections / .section-header / .section-subtitle trio is
   retargeted here so existing markup picks the new styling up with
   no edits. */

/* Horizontal padding comes from .app-container — adding it here too
   double-gutters the title. Vertical only. */
.page-head,
.top-of-sections {
  text-align: left;
  padding: var(--space-5) 0 0;
  margin-bottom: var(--space-5);
}

.page-title,
.section-header {
  font-family: var(--font-titles);
  font-size: var(--text-display);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-title);
  line-height: var(--leading-tight);
  color: var(--text-strong);
  margin: 0;
}

/* Greeting / context line ABOVE a page title. Quieter than the title,
   never a pill: it is orientation, not an action. */
.page-eyebrow {
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  color: var(--text-muted);
  margin: 0 0 var(--space-2);
}

.page-eyebrow strong {
  font-weight: var(--weight-semibold);
  color: var(--text-main);
}

.page-sub,
.section-subtitle {
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-muted);
  margin: var(--space-2) 0 0;
  max-width: 34em;
  text-wrap: pretty;
}

/* --- Layout -------------------------------------------------------------- */

.app-container {
  max-width: 720px;
  margin: 0 auto;
  height: 100vh;
  overflow-y: auto;
  padding: 0 var(--page-gutter);
  /* Room for the docked nav plus the iOS home indicator. One rule,
     no !important, no second declaration overriding it. */
  padding-bottom: calc(var(--nav-total) + var(--viewport-overflow) + var(--space-6));
}

/* --- Header -------------------------------------------------------------
   Transparent, sits on the app background, no white bar and no shadow.
   Logo down from 32px to 28px. The icon buttons lose their white cards. */

.menu-container,
.app-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  min-height: var(--header-height);
  padding: calc(var(--safe-top) + var(--space-3)) var(--page-gutter) var(--space-2);
  background: transparent;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.logo-wrapper span,
.logo-text {
  font-family: 'Comfortaa', sans-serif;
  font-weight: 400;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
  color: var(--color-accent); /* fallback where background-clip:text fails */
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-wrapper .demo-badge {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  -webkit-text-fill-color: var(--color-accent);
  -webkit-background-clip: initial;
  background-clip: initial;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  margin-left: var(--space-2);
  line-height: 1;
  white-space: nowrap;
  cursor: help;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* One rule for every square icon button in the app: header burger,
   back, close, side-menu close. Flat on the background, no card. */
.btn-icon,
.menu-toggle,
.close-menu {
  position: static;
  width: var(--tap-min);
  height: var(--tap-min);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-chip);
  color: var(--text-main);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.btn-icon:hover,
.menu-toggle:hover,
.close-menu:hover {
  background: var(--surface-sunken);
  transform: none;
  box-shadow: none;
}

.btn-icon .icon,
.menu-toggle .icon,
.close-menu .icon,
#menu-icon,
#notif-icon {
  font-size: 22px;
  color: var(--text-main);
  background: none;
  -webkit-text-fill-color: currentColor;
}

/* Account button: the user's initial (or photo) instead of a burger.
   36px circle with a 44px hit area, so the header stays light but the
   target is still thumb-sized. */
.avatar-btn {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1;
  color: var(--text-main);
  cursor: pointer;
  transition: background var(--transition);
}

.avatar-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--tap-min);
  height: var(--tap-min);
  transform: translate(-50%, -50%);
}

.avatar-btn:hover { background: var(--border); }

.avatar-btn img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.notification-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
}

/* Unread marker: a dot, not a number crammed into 18px.
   Add the count back as text only where there is room for it. */
.badge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 9px;
  height: 9px;
  padding: 0;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  border: 2px solid var(--bg);
  color: transparent;
  font-size: 0;
  overflow: hidden;
}

/* --- Buttons ------------------------------------------------------------
   Three: primary (flat accent), secondary (outlined), quiet (text).
   One height, one radius, no gradients. */

.app-btn,
.btn-primary,
.btn-modal-primary,
.request-btn {
  width: 100%;
  min-height: var(--control-height);
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: var(--text-on-accent);
  box-shadow: none;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.app-btn:active,
.btn-primary:active,
.btn-modal-primary:active,
.request-btn:active {
  background: var(--color-accent-strong);
  transform: scale(0.99);
}

.btn-secondary,
.btn-modal-secondary,
.btn-back,
.btn-outline-edit {
  width: 100%;
  min-height: var(--control-height);
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-main);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-secondary:active,
.btn-modal-secondary:active,
.btn-back:active {
  background: var(--surface-sunken);
}

.btn-quiet {
  min-height: var(--tap-min);
  padding: 0 var(--space-3);
  background: none;
  border: none;
  color: var(--color-accent);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}

.app-btn.danger,
.btn-danger {
  background: var(--surface);
  color: var(--color-danger);
  border: 1px solid var(--border);
}

.app-btn.danger:active {
  background: var(--color-danger-soft);
}
/* Le bandeau d'attente devient cliquable, sans changer d'apparence. */
.req-btn-track {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface-sunken);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: var(--text-sm); font-weight: var(--weight-semibold);
  color: var(--text-muted);
  min-height: var(--tap-min);
  cursor: pointer;
}
.req-btn-track:hover { border-color: var(--border-strong); color: var(--text-main); }
/* Full-width action docked to the bottom of a screen. Replaces the
   floating white action card with its own shadow and gutters. */
.action-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--page-gutter)
           calc(var(--space-4) + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* --- Inputs -------------------------------------------------------------
   One pattern: persistent label above, field below, hint under.
   Same height and radius as buttons. */

.field {
  display: block;
  margin-bottom: var(--space-4);
}

.field-label,
.control-item label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-main);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: var(--space-2);
}

.field-hint {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-subtle);
  margin-top: var(--space-2);
}

.app-input,
.app-select,
textarea.app-input {
  width: 100%;
  min-height: var(--control-height);
  padding: 0 var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--text-strong);
  transition: border-color var(--transition), box-shadow var(--transition);
}

textarea.app-input {
  min-height: 96px;
  padding: var(--space-3) var(--space-4);
  line-height: var(--leading-normal);
  resize: vertical;
}

.app-input::placeholder { color: var(--text-subtle); }

.app-input:focus,
.app-select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.app-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: none;
  cursor: pointer;
}

.select-wrapper { position: relative; }

.select-wrapper::after {
  content: "";
  position: absolute;
  right: var(--space-4);
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid var(--text-subtle);
  border-bottom: 2px solid var(--text-subtle);
  transform: rotate(45deg);
  pointer-events: none;
}

/* --- Selected state -----------------------------------------------------
   ONE way to show "chosen", everywhere: tinted fill, accent border,
   and a check mark in the markup. Replaces the coral-border,
   navy-border and blue-fill variants. */

.is-selected,
.selected,
.active-card {
  background: var(--color-accent-soft);
  border-color: var(--color-accent);
  box-shadow: none;
  transform: none;
  color: var(--text-strong);
}

/* --- Bottom nav ---------------------------------------------------------
   Docked, not floating. The safe-area inset is respected once, and
   not overridden on the next line. */

/* --- Bottom nav ---------------------------------------------------------
   Ancrée au bord bas. Le safe-area est respecté une seule fois. */

.bottom-nav,
.bottom-menu {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: var(--space-1);
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding: 0 var(--space-2) var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}

.bottom-nav.nav-hidden { display: none; }

.nav-item {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
}

.nav-item .icon {
  font-size: 24px;
  transition: transform var(--transition);
}

/* Minuscules : « CHERCHER » en 10px capitales est le libellé le moins
   lisible de l'app, et les capitales suppriment les ascendantes qui
   aident à reconnaître un mot d'un coup d'œil. */
.nav-item span:not(.nav-badge) {
  width: 100%;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item.active {
  color: var(--color-accent);
}

.nav-item.active span:not(.nav-badge) {
  font-weight: var(--weight-semibold);
}

.nav-item.active .icon {
  transform: none;
}

/* --- Badge messages non lus --------------------------------------------- */

.nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 22px);
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent);
  color: var(--text-on-accent);
  border: 2px solid var(--surface);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: var(--weight-bold);
  box-sizing: border-box;
}

/* --- Indicateur timer en cours ------------------------------------------ */

.nav-item#nav-timer.running .icon { color: var(--color-accent); }

.nav-item#nav-timer .timer-running-dot {
  display: none;
  position: absolute;
  top: 8px;
  right: calc(50% - 22px);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 2px var(--surface);
}

.nav-item#nav-timer.running .timer-running-dot {
  display: block;
  animation: timer-dot-pulse 1.6s ease-in-out infinite;
}

@keyframes timer-dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.7); opacity: 0.55; }
}

.nav-item.active .icon { color: var(--color-accent); }

/* --- Cards --------------------------------------------------------------- */

.card,
.choice-card,
.req-card,
.caregiver-card,
.request-card,
.proposal-card,
.service-config-card,
.success-ready-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* --- Chips --------------------------------------------------------------- */

.chip,
.mini-badge,
.tiny-badge,
.req-info-chip,
.req-service-tag,
.interest-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--surface-sunken);
  border: none;
  border-radius: var(--radius-chip);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  color: var(--text-main);
  white-space: nowrap;
}
#view-cg-services { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mini-badge.hw {
  display: inline-flex; align-items: center; gap: 8px;
  height: auto; padding: 6px 12px; white-space: normal;
}
.mini-badge.hw .icon { font-size: 16px; color: var(--color-accent-ink); flex-shrink: 0; }
.chip.is-selected,
.interest-chip.selected {
  background: var(--color-accent-soft);
  color: var(--color-accent-strong);
  border: 1px solid var(--color-accent);
}

/* --- Status pills -------------------------------------------------------- */

.status-badge,
.cg-status-mini {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-chip);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  background: var(--surface-sunken);
  color: var(--text-main);
}

.status-badge.badge-pending,
.cg-status-mini.badge-pending { background: var(--color-warning-soft); color: var(--color-warning); }

.status-badge.badge-accepted,
.cg-status-mini.badge-accepted { background: var(--color-success-soft); color: var(--color-success); }

.status-badge.badge-refused,
.cg-status-mini.badge-refused { background: var(--color-danger-soft); color: var(--color-danger); }

/* --- Utilities ---------------------------------------------------------- */

.hidden, .d-none, .nav-hidden { display: none !important; }
.w-100 { width: 100%; }
.mt-2 { margin-top: var(--space-2); }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-accent { color: var(--color-accent); }
.tabular { font-variant-numeric: tabular-nums; }

@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
/* --- HOME HEADLINE + CTA -------------------------------------------------
   Le CTA "discret" (variant secondary : ajouter des heures) tient sur la même
   ligne que le titre, en petit bouton carré. Le CTA principal (états 1 et 2,
   aucun abonnement) reste un .app-btn pleine largeur sous le header. */

.home-headline-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.home-headline-row .page-title { flex: 1; min-width: 0; margin: 0; }

.home-cta-round {
  position: relative;
  align-self: flex-end;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 14px -8px rgba(226, 96, 76, 0.9);
  transition: background var(--transition);
}

.home-cta-round:hover,
.home-cta-round:active { background: var(--color-accent-strong); }

/* Les quatre couches se relaient dans le même cercle : l'icône, puis +1h,
   +2h, +3h. Une seule est visible à la fois. */
.home-cta-round > * {
  position: absolute;
  animation: topupCycle 12s infinite;
}

.home-cta-round > *:nth-child(1) { animation-delay: 0s; }
.home-cta-round > *:nth-child(2) { animation-delay: 3s; opacity: 0; }
.home-cta-round > *:nth-child(3) { animation-delay: 6s; opacity: 0; }
.home-cta-round > *:nth-child(4) { animation-delay: 9s; opacity: 0; }

.home-cta-round .home-cta-plus {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
}

.home-cta-round .home-cta-plus .icon { font-size: 1.7rem; }

.home-cta-round .home-cta-hint {
  font-family: var(--font-titles);
  font-size: 0.9375rem;
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-title);
}

@keyframes topupCycle {
  0%, 3%    { opacity: 0; transform: translateY(4px); }
  6%, 22%   { opacity: 1; transform: none; }
  25%, 100% { opacity: 0; transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .home-cta-round > * { animation: none; }
  .home-cta-round > *:not(:first-child) { display: none; }
}
