@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("lib/fonts/barlow-400.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("lib/fonts/barlow-500.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("lib/fonts/barlow-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-display: swap; src: url("lib/fonts/barlow-700.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url("lib/fonts/barlow-condensed-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url("lib/fonts/barlow-condensed-700.woff2") format("woff2"); }

:root {
    --navy: #0d083a;
    --navy-2: #171049;
    --red: #e71a38;
    --red-dark: #c4122c;
    --accent: #e71a38;
    --white: #ffffff;
    --on-navy-2: #cdcae8;
    --on-navy-3: #a29ece;
    --ink: #0d083a;
    --ink-2: #4a4670;
    --ink-3: #5c5884;
    --line: #e4e2ef;
    --paper: #f5f4fa;
    --top-h: 60px;
    --bottom-h: 84px;
    --panel-w: 340px;
    --shadow-page: 0 22px 44px -16px rgba(0, 0, 0, .6), 0 4px 12px rgba(0, 0, 0, .28);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --font: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-cond: "Barlow Condensed", "Barlow", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    background: var(--navy);
    color: var(--white);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--top-h) minmax(0, 1fr) var(--bottom-h);
    height: 100vh;
    height: 100dvh;
}
::selection { background: var(--red); color: var(--white); }
[hidden] { display: none !important; }
button, input, a { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { text-decoration: none; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 6px; }
.ico { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico.sm { width: 17px; height: 17px; }

.icon-btn {
    width: 42px; height: 42px; display: inline-grid; place-items: center;
    border-radius: 12px; color: var(--white);
    transition: background-color .2s var(--ease-out), opacity .2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .1); }
.icon-btn.ghost { background: rgba(255, 255, 255, .08); }
.icon-btn[aria-pressed="true"] { background: rgba(255, 255, 255, .16); }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }

/* ---------- Barre du haut ---------- */
.topbar {
    position: relative; z-index: 20;
    display: flex; align-items: center; gap: 16px;
    padding: 0 18px 0 22px;
    background: var(--navy);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    transition: transform .35s var(--ease-out), opacity .35s;
}
.logo { height: 28px; width: auto; max-width: 150px; object-fit: contain; flex: none; }
.sep { width: 1px; height: 26px; background: rgba(255, 255, 255, .18); flex: none; }
.title {
    min-width: 0; font-size: 15.5px; font-weight: 600; letter-spacing: .005em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; flex: none; }

.search-form {
    display: flex; align-items: center; gap: 8px;
    width: 290px; height: 40px; padding: 0 12px; margin-right: 8px;
    border-radius: 10px; background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .14);
    transition: background-color .2s, border-color .2s, width .3s var(--ease-out);
}
.search-form:focus-within { background: var(--white); color: var(--ink); border-color: var(--white); box-shadow: 0 0 0 3px rgba(231, 26, 56, .45); }
.search-form input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 15px; }
.search-form input::placeholder { color: var(--on-navy-3); }
.search-form:focus-within input::placeholder { color: var(--ink-3); }
.search-form input::-webkit-search-cancel-button { cursor: pointer; }

/* ---------- Scène ---------- */
.stage { position: relative; min-height: 0; overflow: hidden; }
.book-frame { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px 88px; transition: transform .45s var(--ease-out); }
body.panel-open:not(.compact) .book-frame { transform: translateX(calc(var(--panel-w) / -2)); }
body.panel-open:not(.compact) .arrow.next { right: calc(var(--panel-w) + 20px); }
.book-zoom { position: relative; left: 0; transform-origin: center; transition: transform .3s var(--ease-out), left .55s var(--ease-out); }
.book-zoom.panning { transition: none; }
.page { box-shadow: var(--shadow-page); }
.arrow {
    position: absolute; top: 50%; z-index: 5; transform: translateY(-50%);
    width: 50px; height: 50px; display: grid; place-items: center; border-radius: 50%;
    background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); color: var(--white);
    transition: background-color .2s, opacity .2s;
}
.arrow:hover { background: rgba(255, 255, 255, .18); }
.arrow:disabled { opacity: 0; pointer-events: none; }
.arrow.prev { left: 20px; }
.arrow.next { right: 20px; }
.pan-layer { position: absolute; inset: 0; z-index: 6; cursor: grab; touch-action: none; }
.pan-layer:active { cursor: grabbing; }

.page { background: var(--white); overflow: hidden; }
.page img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; opacity: 0; transition: opacity .35s; }
.page img.ready { opacity: 1; }
.page .lk { position: absolute; z-index: 5; border-radius: 2px; transition: background-color .2s; }
.page .lk:hover { background: rgba(33, 22, 128, .12); outline: 1px solid rgba(33, 22, 128, .35); }
.page .hit { position: absolute; z-index: 4; pointer-events: none; background: rgba(231, 26, 56, .24); outline: 2px solid var(--red); border-radius: 2px; animation: hit-in .6s var(--ease-out); }
@keyframes hit-in { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.loader {
    position: absolute; z-index: 8; display: flex; flex-direction: column; align-items: center; gap: 14px;
    font-size: 14px; font-weight: 600; color: var(--on-navy-2);
}
.loader span { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .15); border-top-color: var(--red); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-pill {
    position: absolute; left: 50%; bottom: 18px; z-index: 7; transform: translateX(-50%);
    padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
    background: rgba(13, 8, 58, .82); border: 1px solid rgba(255, 255, 255, .12);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    opacity: 0; pointer-events: none; transition: opacity .3s;
}

/* ---------- Barre du bas ---------- */
.bottombar {
    position: relative; z-index: 20;
    display: flex; align-items: center; gap: 18px; padding: 0 18px;
    background: var(--navy); border-top: 1px solid rgba(255, 255, 255, .08);
    transition: transform .35s var(--ease-out), opacity .35s;
}
.nav { display: flex; align-items: center; gap: 2px; flex: none; }
.count { min-width: 132px; text-align: center; font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.strip, .strip-spacer { flex: 1; min-width: 0; }
.strip {
    display: flex; gap: 8px; align-items: center; height: 100%; padding: 0 4px;
    overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none;
    mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent);
}
.strip::-webkit-scrollbar { display: none; }
.strip button { flex: none; display: flex; gap: 1px; padding: 3px; border-radius: 4px; opacity: .55; transition: opacity .2s, background-color .2s; }
.strip button:hover { opacity: .9; }
.strip button.on { opacity: 1; outline: 2px solid var(--red); outline-offset: 1px; }
.strip button.has-hit { position: relative; opacity: .9; }
.strip button.has-hit::after { content: ""; position: absolute; top: -4px; left: 50%; width: 7px; height: 7px; border-radius: 50%; background: var(--red); transform: translateX(-50%); }
.strip img { width: 36px; height: 51px; object-fit: cover; background: rgba(255, 255, 255, .08); }
.tools { display: flex; align-items: center; gap: 2px; flex: none; }
.only-compact { display: none !important; }

/* ---------- Panneau de recherche ---------- */
.panel {
    position: fixed; z-index: 30; top: var(--top-h); right: 0; bottom: var(--bottom-h); width: var(--panel-w);
    background: var(--white); color: var(--ink);
    box-shadow: -22px 0 44px -26px rgba(0, 0, 0, .7);
    display: flex; flex-direction: column;
    animation: panel-in .35s var(--ease-out);
}
@keyframes panel-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 6px 16px; }
.panel-head .icon-btn { color: var(--ink-2); }
.panel-head .icon-btn:hover { background: var(--paper); }
.search-form.in-panel { flex: 1; width: auto; margin: 0; background: var(--paper); border-color: var(--line); color: var(--ink); }
.search-form.in-panel input::placeholder { color: var(--ink-3); }
body:not(.compact) .search-form.in-panel { display: none; }
body:not(.compact) .panel-head { padding-top: 10px; }
.results-meta { padding: 6px 18px 10px; font-family: var(--font-cond); font-weight: 700; font-size: 20px; line-height: 1.15; }
.results-meta.muted { font-family: var(--font); font-weight: 500; font-size: 14.5px; color: var(--ink-3); }
.results { list-style: none; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.results li button {
    width: 100%; text-align: left; display: grid; grid-template-columns: 46px 1fr; gap: 12px;
    padding: 12px 18px; border-top: 1px solid var(--line); transition: background-color .15s;
}
.results li button:hover, .results li button.on { background: #fdf0f2; }
.results img { width: 46px; height: 65px; object-fit: cover; border-radius: 2px; box-shadow: 0 2px 6px rgba(13, 8, 58, .2); background: var(--paper); }
.results b { display: block; font-size: 13px; font-weight: 700; color: var(--red-dark); margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.results p { font-size: 13.5px; line-height: 1.4; color: var(--ink-2); }
.results mark { background: #ffe1e6; color: var(--ink); font-weight: 600; padding: 0 2px; border-radius: 2px; }

/* ---------- Toutes les pages ---------- */
.pages-overlay {
    position: fixed; inset: 0; z-index: 40; background: rgba(9, 6, 40, .97);
    display: flex; flex-direction: column; animation: fade-in .25s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }
.pages-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px 28px; }
.pages-head h2 { font-family: var(--font-cond); font-weight: 700; font-size: 26px; }
.pages-grid {
    flex: 1; overflow-y: auto; padding: 12px 28px 40px;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 22px 18px; align-content: start;
}
.pages-grid button { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--on-navy-2); font-variant-numeric: tabular-nums; }
.pages-grid img { width: 100%; aspect-ratio: 1 / 1.414; object-fit: cover; border-radius: 2px; background: rgba(255, 255, 255, .06); box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .8); transition: transform .2s var(--ease-out); }
.pages-grid button:hover img { transform: translateY(-3px); }
.pages-grid button.on img { outline: 2px solid var(--red); outline-offset: 3px; }
.pages-grid button.on { color: var(--white); }

/* ---------- Accueil (téléphone) ---------- */
.cover-screen {
    position: fixed; inset: 0; z-index: 50; background: var(--navy);
    display: flex; flex-direction: column; overflow-y: auto;
    padding: env(safe-area-inset-top) 0 calc(24px + env(safe-area-inset-bottom));
}
.cover-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; }
.cover-art { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 15% 0; }
.cover-art img { max-width: 100%; max-height: 46vh; height: auto; border-radius: 3px; box-shadow: var(--shadow-page); animation: cover-in .7s var(--ease-out); }
@keyframes cover-in { from { transform: translateY(14px) scale(.97); opacity: 0; } }
.cover-meta { text-align: center; padding: 22px 24px 0; }
.cover-meta h1 { font-family: var(--font-cond); font-weight: 700; font-size: 26px; line-height: 1.08; text-wrap: balance; }
.cover-meta p { color: var(--on-navy-2); font-size: 14.5px; margin-top: 6px; }
.cover-actions { display: grid; gap: 10px; padding: 20px 22px 0; width: 100%; max-width: 420px; margin: 0 auto; }
.btn-read {
    display: flex; align-items: center; justify-content: center; gap: 10px; height: 54px;
    border-radius: 14px; background: var(--accent); color: var(--white); font-weight: 700; font-size: 17px;
    box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .55); transition: filter .2s;
}
.btn-read:hover { filter: brightness(.9); }
.cover-row { display: flex; gap: 10px; }
.btn-soft {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; height: 48px;
    border-radius: 14px; background: rgba(255, 255, 255, .09); font-weight: 600; font-size: 15px;
}

.toast {
    position: fixed; left: 50%; bottom: calc(var(--bottom-h) + 18px); z-index: 60; transform: translateX(-50%);
    padding: 10px 16px; border-radius: 10px; background: var(--white); color: var(--ink);
    font-size: 14.5px; font-weight: 600; box-shadow: 0 12px 28px -12px rgba(0, 0, 0, .7);
    animation: toast-in .3s var(--ease-out);
}
@keyframes toast-in { from { transform: translate(-50%, 10px); opacity: 0; } }
.noscript { position: fixed; inset: auto 0 0; padding: 16px; background: var(--white); color: var(--ink); text-align: center; }
.noscript a { color: var(--blue, #211680); text-decoration: underline; }

/* ---------- Téléphone : la page prend tout l'écran ---------- */
body.compact { --top-h: 56px; --bottom-h: 0px; grid-template-rows: minmax(0, 1fr); }
body.compact .topbar, body.compact .bottombar { position: fixed; left: 0; right: 0; }
body.compact .topbar { top: 0; height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0 16px; gap: 12px; background: rgba(13, 8, 58, .94); }
body.compact .sep { display: none; }
body.compact .logo { height: 24px; }
body.compact .title { font-size: 14px; color: var(--on-navy-2); }
body.compact .bottombar {
    bottom: 0; flex-direction: column; align-items: stretch; gap: 10px;
    padding: 10px 0 calc(12px + env(safe-area-inset-bottom)); background: rgba(13, 8, 58, .96);
}
body.compact .nav { justify-content: center; }
body.compact .count { min-width: 110px; font-size: 13.5px; color: var(--on-navy-2); }
body.compact .strip { flex: none; height: 64px; padding: 0 16px; }
body.compact .tools { justify-content: space-around; padding: 0 6px; }
body.compact .tool { display: flex !important; flex-direction: column; align-items: center; gap: 4px; padding: 4px 10px; font-size: 11.5px; font-weight: 600; color: var(--on-navy-2); }
body.compact .tool .ico { color: var(--white); }
body.compact .hide-compact { display: none !important; }
body.compact .book-frame { padding: 0; }
body.compact .arrow { display: none; }
body.compact .panel { top: 0; bottom: 0; width: 100%; z-index: 45; padding-top: env(safe-area-inset-top); }
body.compact .toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
body.compact:not(.chrome-visible) .topbar { transform: translateY(-100%); opacity: 0; pointer-events: none; }
body.compact:not(.chrome-visible) .bottombar { transform: translateY(100%); opacity: 0; pointer-events: none; }
body.compact:not(.chrome-visible) .page-pill { opacity: 1; }

@media (max-width: 1100px) {
    .search-form { width: 220px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
