/* Lecteur Serein - base.css */
/* Fond, noise microfiche, projection lumineuse, vignette, landing, toolbar */

:root {
  --bg: #121212;
  --text: #e0ddd8;
  --text-dim: rgba(224, 221, 216, 0.55);
  --accent: #c9a24b;
  --glow: rgba(255, 243, 230, 0.05);
  --border-soft: rgba(255, 255, 255, 0.08);
  --transition: 0.25s ease;
  --reader-font: 'EB Garamond', Georgia, serif;
  --reader-letter-spacing: 0;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--reader-font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.font-fraunces {
  font-optical-sizing: auto;
}

/* ================= NOISE + PROJECTION ================= */

.page {
  position: relative;
  min-height: 100vh;
}

/* Projection glow : halo central, bords assombris */
.page::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(
    ellipse 120% 90% at center,
    transparent 20%,
    rgba(0, 0, 0, 0.35) 60%,
    rgba(0, 0, 0, 0.65) 100%
  );
  pointer-events: none;
  z-index: 100;
}

/* Grain microfiche */
.page::after {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0.55 0 0 0 0.45 0 0.45 0 0 0.4 0 0 0.35 0 0.35 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.045;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 101;
}

/* ================= LANDING ================= */

#landing {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  background: var(--bg);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#landing.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.landing-inner {
  text-align: center;
  max-width: 480px;
  width: 100%;
  padding: 40px 24px;
}

.brand {
  font-size: 2.4rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.tagline {
  font-style: italic;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-bottom: 3rem;
}

.paste-zone {
  border: 1px dashed rgba(224, 221, 216, 0.25);
  border-radius: 10px;
  padding: 44px 28px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: rgba(255, 255, 255, 0.015);
  outline: none;
}

.paste-zone:hover,
.paste-zone:focus-visible,
.paste-zone.dragover {
  border-color: var(--accent);
  background: rgba(201, 162, 75, 0.04);
}

.paste-zone svg {
  stroke: var(--text-dim);
  margin-bottom: 16px;
}

.paste-label {
  font-size: 1.15rem;
  margin-bottom: 6px;
}

.paste-hint,
.paste-formats {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.paste-formats {
  margin-top: 4px;
  letter-spacing: 0.04em;
}

.btn-file {
  margin-top: 20px;
  background: transparent;
  border: 1px solid rgba(224, 221, 216, 0.25);
  color: var(--text);
  padding: 10px 26px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.btn-file:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.landing-status {
  margin-top: 18px;
  font-size: 0.9rem;
  color: var(--text-dim);
  min-height: 1.4em;
}

.landing-status.error {
  color: #c96a5a;
}

/* ================= URL ZONE ================= */

.url-zone {
  margin-top: 24px;
}

.url-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(224, 221, 216, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color var(--transition);
}

.url-input-row:focus-within {
  border-color: var(--accent);
}

.url-input-row svg {
  stroke: var(--text-dim);
  flex-shrink: 0;
}

#urlInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 4px 0;
}

#urlInput::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.btn-fetch {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 6px 18px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.btn-fetch:hover {
  background: var(--accent);
  color: #121212;
}

.btn-fetch:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ================= FILE ROW ================= */

.file-row {
  margin-top: 20px;
}

/* ================= READER LAYOUT ================= */

#reader[hidden] {
  display: none;
}

.reader-container {
  max-width: var(--canvas-width, 720px);
  margin: 0 auto;
  padding: 64px 40px 120px;
  position: relative;
  z-index: 10;
  transition: max-width var(--transition);
}

.doc-header {
  margin-bottom: 2.2em;
  padding-bottom: 1.4em;
  border-bottom: 1px solid var(--border-soft);
}

.doc-header h1 {
  font-size: 1.9rem;
  font-weight: 500;
  line-height: 1.25;
}

.doc-header.sticky {
  position: sticky;
  top: 0;
  background: rgba(18, 18, 18, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 18px 0;
  margin: 0 -40px 2em;
  padding-left: 40px;
  padding-right: 40px;
  z-index: 40;
  border-bottom: 1px solid var(--border-soft);
}

/* ================= TOOLBAR ================= */

.toolbar {
  position: fixed;
  bottom: 26px;
  right: 26px;
  display: flex;
  gap: 10px;
  z-index: 200;
}

.tool-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(224, 221, 216, 0.2);
  background: rgba(18, 18, 18, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

/* ================= PREFACE / POSTFACE ================= */
/* Hors flux de colonnes : métadonnées, épigraphe, notes de fin */

.preface,
.postface {
  letter-spacing: var(--reader-letter-spacing);
}

.preface:empty,
.postface:empty {
  display: none;
}

.preface {
  margin-bottom: 2em;
  padding-bottom: 1.2em;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.88em;
  color: var(--text-dim);
}

.preface p {
  text-align: left;
  margin-bottom: 0.3em;
}

.preface blockquote {
  margin: 0.5em 0 0;
  font-size: 1.05em;
}

.postface {
  margin-top: 2.4em;
  padding-top: 1.2em;
  border-top: 1px solid var(--border-soft);
  font-size: 0.85em;
  color: var(--text-dim);
}

.postface p {
  text-align: left;
  margin-bottom: 0.4em;
}

/* ================= MODE ÉDITION ================= */

#reader.editing .doc-header h1,
#reader.editing .preface,
#reader.editing article,
#reader.editing .postface {
  outline: 1px dashed rgba(201, 162, 75, 0.35);
  outline-offset: 6px;
  border-radius: 3px;
  cursor: text;
  transition: outline-color var(--transition);
}

#reader.editing .doc-header h1:hover,
#reader.editing .preface:hover,
#reader.editing article:hover,
#reader.editing .postface:hover,
#reader.editing .doc-header h1:focus,
#reader.editing .preface:focus,
#reader.editing article:focus,
#reader.editing .postface:focus {
  outline-color: var(--accent);
}

#reader.editing .preface:empty,
#reader.editing .postface:empty {
  display: block;
  min-height: 2.5em;
}

#reader.editing .preface:empty::before {
  content: 'Préface : métadonnées, épigraphe...';
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.85rem;
}

#reader.editing .postface:empty::before {
  content: 'Postface : notes, sources...';
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.85rem;
}

.tool-btn[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(201, 162, 75, 0.12);
}

/* ================= SHARE TOAST ================= */

.share-toast {
  position: fixed;
  bottom: 90px;
  right: 26px;
  background: rgba(18, 18, 18, 0.95);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 0.9rem;
  z-index: 300;
  animation: toast-in 0.3s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= RESPONSIVE ================= */

@media (max-width: 768px) {
  .reader-container {
    padding: 32px 20px 110px;
  }

  .doc-header.sticky {
    margin: 0 -20px 1.6em;
    padding-left: 20px;
    padding-right: 20px;
  }

  .brand {
    font-size: 1.8rem;
  }

  .toolbar {
    bottom: 18px;
    right: 18px;
  }
}
