/* //books — app-specific styles. Builds on the shared design package
   (fonts.css → tokens.css → components.css). No hard-coded token values. */

html, body { height: 100%; }
body { overflow-x: hidden; }

/* ── App shell ─────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.app-sidebar { display: none; }
.app-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  padding-bottom: calc(72px + var(--safe-bottom)); /* room for fixed bottom nav */
}
.app-nav { z-index: 40; }

.view { min-width: 0; }
.hidden { display: none !important; }

/* status bar (mobile chrome) */
.app-statusbar { display: flex; }

/* section header */
.head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); padding: var(--sp-3) var(--sp-5) 0;
}
.head__title { font-size: 26px; font-weight: 800; letter-spacing: -.5px; line-height: 1.05; margin-top: 2px; }
.pad { padding: 0 var(--sp-5); }
.pad-t { padding-top: var(--sp-4); }

/* search field with leading glyph */
.searchbar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5) 0; }
.searchbar .in-field { padding-left: var(--sp-5); }
.searchfield { position: relative; flex: 1; }
.searchfield .in-glyph { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 18px; height: 18px; pointer-events: none; }
.searchfield .in-field { padding-left: 40px; }

/* ── Covers ────────────────────────────────────────────────────────────────── */
.cover {
  position: relative; overflow: hidden;
  border-radius: 3px 6px 6px 3px;
  box-shadow: var(--cover-e);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 11px; aspect-ratio: 2 / 3;
}
.cover::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: rgba(0,0,0,.22); z-index: 1; }
.cover--img { padding: 0; }
.cover--img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover__tag { font-family: var(--font-mono); font-size: 8px; letter-spacing: 1px; opacity: .7; position: relative; z-index: 2; }
.cover__title { font-size: 12px; font-weight: 700; line-height: 1.15; letter-spacing: -.2px; position: relative; z-index: 2; }
.cover--hero { width: 104px; height: 156px; aspect-ratio: auto; flex: none; }
.cover--hero .cover__title { font-size: 14px; }

/* shelf grid — 2 cols mobile, 6 desktop */
.shelf { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); padding: var(--sp-5) var(--sp-5) var(--sp-6); }
.cell { cursor: pointer; min-width: 0; }
.cell__status { display: flex; align-items: center; gap: 5px; margin-top: 6px; }
.cell__dot { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.cell__label { font-family: var(--font-mono); font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shelf-section { font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--ink-3); padding: var(--sp-4) var(--sp-5) 0; }

/* ── Book sheet ────────────────────────────────────────────────────────────── */
.sheet-head { display: flex; gap: var(--sp-4); padding: var(--sp-4) var(--sp-5) 0; }
.sheet-meta { flex: 1; min-width: 0; }
.sheet-title { font-size: 22px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }
.sheet-author { font-size: 14px; color: var(--ink-2); margin-top: 4px; }
.prog { margin: var(--sp-4) var(--sp-5) 0; border: 1px solid var(--hairline); border-radius: var(--r-3); background: var(--panel); padding: var(--sp-4); }
.prog__head { display: flex; justify-content: space-between; align-items: baseline; }
.prog__row { display: flex; align-items: flex-end; gap: var(--sp-3); margin-top: 6px; }
.prog__pct { font-family: var(--font-mono); font-size: 40px; font-weight: 600; letter-spacing: -1px; line-height: .9; font-variant-numeric: tabular-nums; }
.prog__pct span { font-size: 16px; color: var(--ink-3); }
.prog__bar { flex: 1; height: 8px; border-radius: var(--r-pill); background: var(--recess); margin-bottom: 8px; overflow: hidden; }
.prog__fill { height: 100%; border-radius: var(--r-pill); background: var(--live); transition: width var(--d-4) var(--ease-spring); }

.notes { padding: var(--sp-4) var(--sp-5) 0; }
.note { border-left: 2px solid var(--hairline-2); padding: 2px 0 2px var(--sp-3); margin-bottom: var(--sp-3); position: relative; }
.note__meta { font-family: var(--font-mono); font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--ink-3); }
.note__text { font-size: 14px; line-height: 1.4; margin-top: 3px; }
.note__del { position: absolute; right: 0; top: 0; border: none; background: transparent; color: var(--ink-3); cursor: pointer; padding: 4px; }

.sheet-cta { padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.sheet-cta .in-btn { display: flex; width: 100%; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; }

/* ── Session (REC) ─────────────────────────────────────────────────────────── */
.session-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-5); padding: var(--sp-5); }
.session-status { text-align: center; min-height: 56px; }
.session-status__title { font-size: 17px; font-weight: 700; }
.session-status__sub { font-size: 14px; color: var(--ink-2); font-style: italic; margin-top: 4px; max-width: 30ch; }
.recwell-lg { width: 220px; height: 220px; }
.recwell-lg::before { width: 200px; height: 200px; }
.recwell-lg .in-rec { width: 156px; height: 156px; }
.result-card { margin: 0 var(--sp-5) var(--sp-4); border: 1px solid var(--sig-green); border-radius: var(--r-4); background: var(--panel); padding: var(--sp-4); box-shadow: var(--e-2); }
.result-card--edit { border-color: var(--hairline-2); }
.result-card__actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }
.result-card__actions .in-btn { flex: 1; height: 44px; }

/* ── Reader DNA ────────────────────────────────────────────────────────────── */
.dna-tiles { display: flex; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5) 0; }
.dna-tile { flex: 1; border-radius: var(--r-3); padding: var(--sp-3); min-width: 0; }
.dna-tile--ink { background: var(--ink); }
.dna-tile--ink .in-lbl, .dna-tile--ink .cap { color: rgba(255,255,255,.5); }
.dna-tile--panel { border: 1px solid var(--hairline); background: var(--panel); }
.dna-tile__cap { font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--ink-3); }
.dna-tile__val { font-family: var(--font-mono); font-size: 30px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.dna-tile--ink .dna-tile__val { color: #fff; }
.dna-tile__val small { font-size: 12px; color: var(--ink-3); }
.dna-section { padding: var(--sp-5) var(--sp-5) 0; }
.genre-row { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.genre-row__label { width: 84px; font-size: 13px; font-weight: 600; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.genre-row__track { flex: 1; height: 10px; border-radius: var(--r-pill); background: var(--recess); overflow: hidden; }
.genre-row__fill { height: 100%; border-radius: var(--r-pill); }
.genre-row__pct { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.traits { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.trait { padding: 7px var(--sp-3); border-radius: var(--r-pill); border: 1px solid var(--hairline-2); background: var(--panel); font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--ink-2); }

/* ── Knowledge Graph — instrument encre plein écran (façon Obsidian) ────────── */
/* Surface encre pleine : remplit sous la status bar et déborde SOUS la barre
   de navigation fixe (marge négative qui annule le padding-bottom de .app-main)
   → aucun bord/liseré blanc, aucun conteneur qui dépasse. */
.graph-screen {
  position: relative;
  background: var(--ink);
  overflow: hidden;
  touch-action: none;
  min-height: calc(100vh - 44px - var(--safe-top));
  min-height: calc(100svh - 44px - var(--safe-top));
  margin-bottom: calc(-1 * (72px + var(--safe-bottom)));
}
.graph-canvas {
  position: absolute; inset: 0;
  display: block; width: 100%; height: 100%;
  touch-action: none;
}

/* overlays au-dessus du canvas */
.graph-overlay { position: absolute; left: 0; right: 0; z-index: 2; pointer-events: none; }
.graph-overlay--top {
  top: 0; padding: var(--sp-4) var(--sp-5) var(--sp-6);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--ink) 82%, transparent), transparent);
}
.graph-kicker {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px;
  text-transform: uppercase; color: color-mix(in srgb, var(--sig-violet) 50%, var(--ink-inv));
}
.graph-title { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin: 2px 0 0; color: var(--ink-inv); }

/* légende sobre, dégagée de la bottom nav */
.graph-legend {
  position: absolute; left: 0; z-index: 2; pointer-events: none;
  bottom: calc(72px + var(--safe-bottom) + var(--sp-3));
  padding: 0 var(--sp-5); display: flex; gap: var(--sp-4); flex-wrap: wrap; align-items: center;
}
.graph-legend span {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--ink-inv); opacity: .6;
}
.graph-legend__dot { width: 10px; height: 10px; border-radius: 50%; }
.graph-legend__dot--book { background: var(--live); }
.graph-legend__dot--concept { background: var(--sig-violet); }
.graph-legend__hint { opacity: .38; }

/* contrôles de zoom (tactiles) */
.graph-zoom {
  position: absolute; right: var(--sp-4); z-index: 3;
  bottom: calc(72px + var(--safe-bottom) + var(--sp-3));
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.graph-zoom__btn {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-2); cursor: pointer; color: var(--ink-inv);
  border: 1px solid color-mix(in srgb, var(--ink-inv) 16%, transparent);
  background: color-mix(in srgb, var(--ink-inv) 8%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: background var(--d-2) var(--ease-out), transform var(--d-1) var(--ease-out);
}
.graph-zoom__btn:hover { background: color-mix(in srgb, var(--ink-inv) 16%, transparent); }
.graph-zoom__btn:active { transform: translateY(1px); }

/* état vide */
.graph-empty {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: var(--sp-6); color: var(--ink-inv);
}
.graph-empty__glyph { font-family: var(--font-mono); font-weight: 600; font-size: 40px; color: var(--sig-violet); }
.graph-empty__txt { margin-top: var(--sp-3); opacity: .7; font-size: 14px; line-height: 1.5; }

/* ── Add / search results ──────────────────────────────────────────────────── */
.result-list { padding: var(--sp-4) var(--sp-5) var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); }
.result-row { display: flex; gap: var(--sp-3); align-items: center; border: 1px solid var(--hairline); border-radius: var(--r-3); background: var(--panel); padding: var(--sp-3); box-shadow: var(--e-1); }
.result-row .cover { width: 44px; height: 66px; aspect-ratio: auto; flex: none; }
.result-row__meta { flex: 1; min-width: 0; }
.result-row__title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.result-row__author { font-size: 13px; color: var(--ink-2); margin-top: 2px; }

/* scan sheet video */
.scan-video { width: 100%; border-radius: var(--r-3); background: var(--ink); aspect-ratio: 4 / 3; overflow: hidden; }
.scan-video video { width: 100%; height: 100%; object-fit: cover; }
.scan-hint { text-align: center; font-size: 13px; color: var(--ink-2); margin-top: var(--sp-3); }

/* ── Login v6 ──────────────────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--sp-5); }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--hairline); border-radius: var(--r-4); box-shadow: var(--e-2); padding: var(--sp-6); }
.auth-brand { font-family: var(--font-mono); font-weight: 600; font-size: 34px; letter-spacing: -1.5px; }
.auth-kicker { font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--sp-2); }
.auth-copy { color: var(--ink-2); font-size: 14px; margin: var(--sp-3) 0 var(--sp-5); }
.auth-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.auth-form label { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--sp-2); }
.auth-note { margin-top: var(--sp-4); font-size: 13px; min-height: 18px; }

/* Tablet portrait — 3-col shelf (still bottom-nav layout). */
@media (min-width: 560px) and (max-width: 899px) {
  .shelf { grid-template-columns: repeat(3, 1fr); }
}

/* ── Desktop (≥ 900px) — 216px sidebar, 6-col shelf, hide bottom nav ────────── */
@media (min-width: 900px) {
  .app-nav { display: none; }
  .app-statusbar { display: none; }
  .app-sidebar { display: flex; }
  .app-main { padding-bottom: 0; }
  .app-content { max-width: 1100px; }
  .shelf { grid-template-columns: repeat(6, 1fr); }
  .head, .searchbar, .pad, .shelf-section { padding-left: var(--sp-6); padding-right: var(--sp-6); }
  .head__title { font-size: 30px; }
  .session-body { min-height: 70vh; }
  /* Desktop : pas de status bar ni de bottom nav → l'encre remplit la zone. */
  .graph-screen { min-height: 100vh; min-height: 100svh; margin-bottom: 0; }
  .graph-legend { bottom: var(--sp-5); }
  .graph-zoom { bottom: var(--sp-5); }
}
