/* Base : police, couleurs communes, couches de la page, navigation. */

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: dark;
  --text: #f3f1ff;
  --muted: #b9b5d6;
  --line: rgba(255, 255, 255, 0.14);
  --soft: rgba(255, 255, 255, 0.07);
  --ok: #5fe0a5;
  --warn: #ffc46b;
  --bad: #ff8a8a;
  --glass-bg: rgba(255, 255, 255, 0.07);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-blur: 20px;
  --glass-shadow: 0 10px 34px rgba(0, 0, 0, 0.28);
  --radius: 24px;
  --page-pad: 24px;
  --gap: 16px;
  --font: 'Inter Variable', Inter, system-ui, 'Segoe UI', Roboto, sans-serif;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden; /* le défilement se fait dans #scroller */
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--base-mid, #0a0620);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* Pas de sélection de texte au clic-glissé (gênant sur le bureau avec Lively) */
  user-select: none;
  -webkit-user-select: none;
}
input,
textarea,
.selectable { user-select: text; -webkit-user-select: text; }

button,
input,
select { font: inherit; color: inherit; }

a { color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.t-ok { color: var(--ok); }
.t-warn { color: var(--warn); }
.t-bad { color: var(--bad); }
.t-muted { color: var(--muted); }
.t-text { color: var(--text); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* Verre : cartes translucides floutant ce qu'il y a derrière. */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--glass-shadow);
}

/* ---------- Couches ----------
   #bg      : fond (dégradé du thème, image perso plus tard, assombrissement, halos)
   #page    : navigation + blocs (c'est cette couche qu'on floute à l'agrandissement)
   #overlay : bloc agrandi */
#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
#bg > * { position: absolute; inset: 0; }
#bg-base { background: var(--base); }
#bg-image {
  background-image: var(--bg-url, none);
  background-position: center;
  background-repeat: no-repeat;
  background-size: var(--bg-fit, cover);
}
#bg-dim { background: #000; opacity: var(--bg-dim, 0); }

#page {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 20px;
  padding: var(--page-pad);
}

#scroller {
  min-height: 0;
  height: calc(100% + 16px); /* compense la marge négative ci-dessous */
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  /* Laisse de la place à l'ombre et à l'effet de survol des cartes */
  margin: -8px;
  padding: 8px;
}
#scroller::-webkit-scrollbar { display: none; }

/* ---------- Rail de navigation (PC) ---------- */
#rail {
  border-radius: 26px;
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 0;
}
.nav-item {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}
.nav-item:hover { color: var(--text); background: var(--soft); }
.nav-item[aria-current='page'] { background: var(--accent); color: #fff; }
/* Crayon + Réglages poussés en bas du rail (Réglages seul sur la page Réglages) */
.nav-item.nav-edit { margin-top: auto; border: 0; background: transparent; cursor: pointer; }
#rail > .nav-settings:last-child { margin-top: auto; }
#rail > .nav-edit ~ .nav-settings { margin-top: 0; }

/* ---------- Barre du bas + bouton + (mobile) ---------- */
#tabbar,
#fab { display: none; }

.view-title { margin: 0 0 14px; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.view-title.pc-hidden { display: none; }

@media (max-width: 760px) {
  :root { --page-pad: 0px; --gap: 12px; --radius: 22px; }
  #page { grid-template-columns: minmax(0, 1fr); gap: 0; }
  #rail { display: none; }
  #scroller {
    margin: 0;
    height: 100%;
    padding: calc(20px + env(safe-area-inset-top)) 16px calc(130px + env(safe-area-inset-bottom));
  }
  .view-title.pc-hidden { display: block; }

  #tabbar {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    height: 68px;
    padding: 0 6px;
    border-radius: 26px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 2;
  }
  #tabbar .nav-item {
    width: auto;
    min-width: 56px;
    height: auto;
    min-height: 48px;
    padding: 4px 6px;
    flex-direction: column;
    gap: 3px;
    font-size: 10px;
    border-radius: 14px;
  }
  #tabbar .nav-item[aria-current='page'] { background: transparent; color: var(--accent); font-weight: 600; }

  #fab {
    position: absolute;
    right: 20px;
    bottom: calc(98px + env(safe-area-inset-bottom));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 0;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
  }
}

/* Boutons génériques */
.btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn-accent { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.btn-accent:hover { background: var(--accent); filter: brightness(1.1); }
.btn-danger { color: var(--bad); }

/* Bandeau d'état (hors ligne, données de démonstration…) */
.status-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 14px;
}
.status-bar:empty { display: none; }
/* PC : dans la marge du bas, pour que la grille tienne pile dans l'écran (fond d'écran) */
@media (min-width: 761px) {
  .status-bar { position: fixed; right: 32px; bottom: 4px; margin: 0; font-size: 11px; }
}
