/* ------------------------------------------------------------------ *
 * Portail familial — design « Mangathèque »
 * Crème + unique accent bordeaux · Space Grotesk (titres) + Manrope (UI)
 * Ombres chaudes basses et diffuses · radius moyens.
 * ------------------------------------------------------------------ */
:root {
  --bg: #faf9f6;
  --bg-desat: #eceae4;
  --card: #fff;
  --sidebar: #f0eee9;
  --titlebar: #efede8;

  --border-strong: #d3d0c8;
  --border: #e2e0da;
  --border-soft: #e8e6e0;
  --border-faint: #ecebe6;

  --ink: #1c1b19;
  --ink-2: #6f6c64;
  --ink-3: #8a877f;
  --ink-4: #a8a59d;

  --accent: #a5203f;
  --accent-grad: linear-gradient(145deg, #c23a58, #8a1730);
  --accent-veil-08: rgba(165, 32, 63, 0.08);
  --accent-veil-10: rgba(165, 32, 63, 0.1);

  --ok: #4ec98a;
  --warn: #e0a94f;

  --shadow-card: 0 8px 20px -16px rgba(60, 55, 45, 0.4);
  --shadow-logo: 0 8px 22px -10px rgba(165, 32, 63, 0.6);
  --shadow-window: 0 50px 100px -34px rgba(60, 55, 45, 0.4);

  --radius-card: 16px;
  --radius-btn: 12px;
  --radius-field: 11px;
}

/* Thème sombre : piloté par l'attribut data-theme (interrupteur manuel).
   Le choix par défaut au 1er chargement suit le système (voir le script inline
   dans server.js), mais l'utilisateur peut ensuite forcer clair ou sombre. */
:root[data-theme='dark'] {
  --bg: #1a1917;
  --bg-desat: #232120;
  --card: #232120;
  --border-strong: #3a3733;
  --border: #34322e;
  --border-soft: #302e2a;
  --border-faint: #2c2a27;
  --ink: #f2f0ea;
  --ink-2: #b6b2a8;
  --ink-3: #928e84;
  --ink-4: #726f66;
  --shadow-card: 0 8px 20px -14px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: 'Manrope', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-wrap: pretty;
}

.card {
  background: var(--card);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

/* ---------- Boutons ---------- */
.btn-primary {
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--accent-grad);
  border: none;
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-logo);
  padding: 13px 18px;
  cursor: pointer;
  width: 100%;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn-primary:hover {
  filter: brightness(1.04);
}
.btn-primary:active {
  transform: translateY(1px);
}

.btn-ghost {
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-veil-08);
  border: 1px solid var(--accent-veil-10);
  border-radius: var(--radius-btn);
  padding: 9px 14px;
  cursor: pointer;
}
.btn-ghost:hover {
  background: var(--accent-veil-10);
}

/* ============ PAGE D'ACCUEIL (launcher) ============ */
body.home {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 6vh 22px 40px;
}
.shell {
  width: 100%;
  max-width: 880px;
}
.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wordmark-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--accent-grad);
  box-shadow: var(--shadow-logo);
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 20px;
  display: grid;
  place-items: center;
}
.wordmark-text {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.logout-form {
  margin: 0;
}
.home-subtitle {
  color: var(--ink-3);
  font-size: 14px;
  margin: 2px 0 26px;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.app-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}
a.app-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -18px rgba(60, 55, 45, 0.5);
  border-color: var(--border-soft);
}
.app-card.status-empty,
.app-card.status-soon {
  cursor: default;
}
.app-card.status-empty {
  border-style: dashed;
  border-color: #d8b3bb;
  background: #f3f1ec;
  box-shadow: none;
}
:root[data-theme='dark'] .app-card.status-empty {
  background: var(--bg-desat);
  border-color: #5a3b40;
}
.app-logo {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 20px;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px -12px rgba(60, 55, 45, 0.55);
}
.status-empty .app-logo {
  color: var(--ink-4);
  box-shadow: none;
}
.app-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.app-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 16px;
}
.app-tag {
  color: var(--ink-3);
  font-size: 13px;
}
.badge {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 4px 9px;
  border-radius: 20px;
}
.badge-on {
  color: #1c7a4f;
  background: rgba(78, 201, 138, 0.16);
}
.badge-soon {
  color: #8a6516;
  background: rgba(224, 169, 79, 0.18);
}

/* ============ PAGE DE CONNEXION ============ */
body.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(165, 32, 63, 0.06), transparent 60%),
    var(--bg);
}
.login-wrap {
  width: 100%;
  max-width: 380px;
}
.login-card {
  padding: 34px 30px 30px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
}
.login-logo {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--accent-grad);
  box-shadow: var(--shadow-logo);
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 26px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
}
.login-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 24px;
  margin: 0;
}
.login-sub {
  color: var(--ink-3);
  font-size: 13px;
  margin: 4px 0 18px;
}
.login-error {
  color: #b23528;
  background: rgba(229, 72, 77, 0.12);
  border: 1px solid #e6c2c6;
  border-radius: var(--radius-field);
  font-size: 13px;
  padding: 9px 12px;
  margin: 0 0 14px;
}
.field-label {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 7px;
}
.field {
  font-family: 'Manrope', sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid #e6e4de;
  border-radius: var(--radius-field);
  padding: 13px 14px;
  width: 100%;
  margin-bottom: 18px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
:root[data-theme='dark'] .field {
  border-color: var(--border);
}
.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-veil-10);
}

/* ---------- Interrupteur clair / sombre ---------- */
.theme-switch {
  flex: 0 0 auto;
  width: 54px;
  height: 30px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--sidebar);
  position: relative;
  cursor: pointer;
  padding: 0;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.theme-switch:hover {
  border-color: var(--border-strong);
}
.theme-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--card);
  color: var(--ink-3);
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px -1px rgba(60, 55, 45, 0.35);
  transition: left 0.18s ease, color 0.16s ease;
}
:root[data-theme='dark'] .theme-knob {
  left: 28px;
  color: #e0a94f;
}
.theme-switch svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-switch .ico-moon {
  display: none;
}
:root[data-theme='dark'] .theme-switch .ico-sun {
  display: none;
}
:root[data-theme='dark'] .theme-switch .ico-moon {
  display: block;
}
/* Interrupteur flottant en haut à droite de la page de connexion */
.login-switch {
  position: absolute;
  top: 22px;
  right: 22px;
}

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
  body.home {
    padding-top: 4vh;
  }
}
