/*
Theme Name: Fragments
Theme URI: https://fragments.beaufreton-honore.com
Description: Thème sur mesure pour le recueil Fragments — fiction adulte
Version: 1.0
Author: Samuel Beaufreton
Text Domain: fragments
*/

/* =========================================
   TYPOGRAPHIE & IMPORTS
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,700;1,400;1,500&family=EB+Garamond:ital,wght@0,400;0,500;1,400;1,500&family=Cormorant+Garamond:ital,wght@0,300;0,400;1,300;1,400&display=swap');

/* =========================================
   VARIABLES
   ========================================= */
:root {
  --bg:        #0b0b0b;
  --bg-card:   #111111;
  --bg-hover:  #161616;
  --text:      #ddd5c8;
  --text-muted:#8a7f74;
  --accent:    #9b2335;
  --accent-soft:#c4374d;
  --gold:      #b8924a;
  --gold-soft: #d4aa6a;
  --border:    rgba(255,255,255,0.07);
  --border-accent: rgba(155,35,53,0.4);

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'EB Garamond', Georgia, serif;
  --font-ui:      'Cormorant Garamond', Georgia, serif;

  --reading-width: 680px;
  --max-width:     1100px;
  --reader-font-size: 1.08rem;
  --reader-lh: 1.85;
}

/* =========================================
   PROGRESS BAR
   ========================================= */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(to right, var(--accent), var(--gold));
  z-index: 9998;
  transition: width 0.1s linear;
  pointer-events: none;
}

/* =========================================
   STORY WITH TOC — LAYOUT WRAPPER
   ========================================= */
.story-with-toc {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0;
  max-width: calc(var(--reading-width) + 280px);
  margin: 0 auto;
  align-items: start;
  padding: 0 1rem;
}

/* =========================================
   TOC SIDEBAR
   ========================================= */
.toc-sidebar {
  position: sticky;
  top: 90px;
  padding: 0 2rem 2rem 1rem;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: none;
}

.toc-sidebar::-webkit-scrollbar { display: none; }

.toc-label {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.toc-list li { position: relative; }

.toc-list li::before {
  content: '';
  position: absolute;
  left: -1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 0;
  background: var(--accent);
  transition: height 0.25s ease;
}

.toc-list li.active::before {
  height: 100%;
}

.toc-link {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 2px;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.toc-link:hover {
  background: rgba(255,255,255,0.04);
}

.toc-list li.active .toc-link {
  color: var(--text);
}

.toc-num {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.toc-name {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
  transition: color 0.15s;
}

.toc-list li.active .toc-name {
  color: var(--text);
}

.toc-link:hover .toc-name {
  color: var(--text);
}

/* =========================================
   TOC MOBILE
   ========================================= */
.toc-mobile-wrap {
  max-width: var(--reading-width);
  margin: 0 auto 2rem;
  padding: 0 2.5rem;
  position: relative;
}

.toc-mobile-btn {
  display: none;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.toc-mobile-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.07);
}

.toc-mobile {
  display: none;
  position: absolute;
  top: 100%;
  left: 2.5rem;
  right: 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  z-index: 50;
  padding: 1rem;
  max-height: 60vh;
  overflow-y: auto;
}

.toc-mobile.open {
  display: block;
}

.toc-mobile .toc-list {
  gap: 0.1rem;
}

.toc-mobile .toc-link {
  padding: 0.4rem 0.5rem;
}


/* =========================================
   RESET & BASE
   ========================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 18px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; height: auto; }

/* =========================================
   GRAIN OVERLAY
   ========================================= */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* =========================================
   ORNEMENT
   ========================================= */
.ornament {
  display: block;
  text-align: center;
  color: var(--gold);
  opacity: 0.5;
  letter-spacing: 0.3em;
  font-size: 0.7rem;
  margin: 2rem 0;
}

.divider {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border) 30%, var(--border) 70%, transparent);
  margin: 3rem 0;
}

/* =========================================
   SITE HEADER
   ========================================= */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 2rem 2.5rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  position: sticky;
  top: 0;
  background: rgba(11,11,11,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
}

.site-header .logo {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--text);
}

.site-header .logo span {
  color: var(--gold);
}

.site-header nav {
  display: flex;
  gap: 2rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.site-header nav a:hover {
  color: var(--text);
}

.site-header nav a[aria-current="page"] {
  color: var(--text);
}

/* =========================================
   HERO — HOMEPAGE
   ========================================= */
.hero {
  padding: 7rem 2.5rem 5rem;
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: end;
}

.hero-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hero-eyebrow::before {
  content: '';
  display: block;
  width: 2rem;
  height: 1px;
  background: var(--gold);
  opacity: 0.6;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 5vw, 4.5rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.hero h1 em {
  font-style: italic;
  color: var(--gold-soft);
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.8;
  max-width: 38ch;
}

.hero-meta {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 2rem;
  display: flex;
  gap: 2.5rem;
}

.hero-meta strong {
  display: block;
  color: var(--text);
  font-size: 1.4rem;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0;
  margin-bottom: 0.2rem;
}

/* =========================================
   STORY GRID — HOMEPAGE
   ========================================= */
.stories-section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 2.5rem 6rem;
}

.stories-section h2 {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5px;
  background: var(--border);
  border: 1px solid var(--border);
}

/* =========================================
   STORY CARD
   ========================================= */
.story-card {
  background: var(--bg-card);
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  transition: background 0.2s ease;
  position: relative;
  overflow: hidden;
}

.story-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.story-card:hover {
  background: var(--bg-hover);
}

.story-card:hover::after {
  opacity: 1;
}

.card-number {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 400;
  color: var(--border);
  line-height: 1;
  position: absolute;
  top: 1.5rem;
  right: 2rem;
  transition: color 0.3s ease;
}

.story-card:hover .card-number {
  color: rgba(155,35,53,0.15);
}

.card-location {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-location::before {
  content: '—';
  opacity: 0.5;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text);
}

.card-title em {
  font-style: italic;
  color: var(--gold-soft);
}

.card-cast {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.cast-tag {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 1px;
}

.card-excerpt {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.7;
  flex: 1;
  font-style: italic;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-soft);
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  transition: color 0.2s, gap 0.2s;
}

.card-link::after {
  content: '→';
  transition: transform 0.2s;
}

.story-card:hover .card-link {
  color: var(--gold-soft);
  gap: 0.8rem;
}

.story-card:hover .card-link::after {
  transform: translateX(3px);
}

/* =========================================
   STORY PAGE — LAYOUT
   ========================================= */
.story-page {
  min-height: 100vh;
}

.story-hero {
  padding: 5rem 2.5rem 4rem;
  max-width: var(--max-width);
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4rem;
}

.story-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.story-eyebrow a {
  color: var(--text-muted);
  transition: color 0.2s;
}

.story-eyebrow a:hover { color: var(--text); }

.story-eyebrow .sep { opacity: 0.3; }

.story-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 400;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 1rem;
}

.story-title em { font-style: italic; color: var(--gold-soft); }

.story-subtitle {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.story-meta-row {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.story-cast-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* =========================================
   STORY BODY — LECTURE
   ========================================= */
.story-body {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: 0 2.5rem 6rem;
}

.story-body h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
  font-style: italic;
  color: var(--gold-soft);
  margin: 3.5rem 0 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.01em;
}

.story-body h2::before {
  content: attr(data-chapter);
  display: block;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-style: normal;
  margin-bottom: 0.4rem;
}

.story-body p {
  font-size: var(--reader-font-size);
  line-height: var(--reader-lh);
  color: var(--text);
  margin-bottom: 1.1rem;
}

.story-body p + p {
  text-indent: 1.5em;
}

.story-body p:has(> em:first-child) {
  text-indent: 0;
}

.story-body p:first-of-type {
  text-indent: 0;
}

.story-body blockquote,
.story-body .dialogue {
  padding-left: 1.5rem;
  border-left: 2px solid var(--border-accent);
  margin: 1.5rem 0;
  color: var(--text);
  font-style: italic;
}

/* Séparateurs --- */
.story-body hr {
  border: none;
  margin: 3rem auto;
  text-align: center;
  height: auto;
  background: none;
}

.story-body hr::before {
  content: '· · ·';
  color: var(--gold);
  opacity: 0.4;
  font-size: 1rem;
  letter-spacing: 0.5em;
}

/* =========================================
   NAVIGATION ENTRE HISTOIRES
   ========================================= */
.story-nav {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: 2rem 2.5rem 5rem;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  gap: 2rem;
}

.story-nav a {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: color 0.2s;
}

.story-nav a:hover { color: var(--gold-soft); }

.story-nav .prev::before { content: '←'; }
.story-nav .next::after  { content: '→'; }

/* =========================================
   FOOTER
   ========================================= */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.site-footer .footer-logo {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--text);
}

/* =========================================
   PROSE INLINE
   ========================================= */
.story-body em  { font-style: italic; }
.story-body strong { font-weight: 500; color: var(--text); }

/* =========================================
   READING WIDGET
   ========================================= */
.reader-widget {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 200;
}

.reader-widget-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.reader-widget-btn:hover,
.reader-widget.open .reader-widget-btn {
  color: var(--gold);
  border-color: var(--gold);
  background: var(--bg-hover);
}

.reader-panel {
  position: absolute;
  bottom: 54px;
  right: 0;
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0;
  display: none;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

.reader-widget.open .reader-panel {
  display: flex;
}

.reader-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.reader-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}
.reader-close:hover { color: var(--text); }

.reader-section {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.reader-section-label {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.reader-options {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.reader-opt {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-ui);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.reader-opt:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

.reader-opt.active {
  background: rgba(155,35,53,0.15);
  border-color: var(--accent);
  color: var(--text);
}

.reader-size-opts .reader-opt:nth-child(1) { font-size: 0.7rem; }
.reader-size-opts .reader-opt:nth-child(2) { font-size: 0.85rem; }
.reader-size-opts .reader-opt:nth-child(3) { font-size: 1rem; }
.reader-size-opts .reader-opt:nth-child(4) { font-size: 1.15rem; }

.theme-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.reader-reset {
  margin: 1rem 1.2rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  width: calc(100% - 2.4rem);
}
.reader-reset:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 900px) {
  .story-with-toc {
    grid-template-columns: 1fr;
    padding: 0;
  }
  .toc-sidebar { display: none; }
  .toc-mobile-btn { display: flex; }
}

@media (max-width: 768px) {
  .hero { grid-template-columns: 1fr; gap: 2.5rem; padding: 4rem 1.5rem 3rem; }
  .hero h1 { font-size: 2.4rem; }
  .hero-meta { gap: 1.5rem; }
  .stories-section { padding: 1rem 1.5rem 4rem; }
  .stories-grid { grid-template-columns: 1fr; }
  .story-card { padding: 2rem; }
  .story-hero { padding: 3rem 1.5rem 3rem; }
  .story-body { padding: 0 1.5rem 4rem; }
  .site-header { padding: 1.5rem; }
  .site-header nav { display: none; }
  .story-nav { padding: 2rem 1.5rem 4rem; flex-direction: column; gap: 1rem; }
  .reader-widget { bottom: 1.5rem; right: 1.5rem; }
  .reader-panel { width: 260px; right: 0; }
}

/* =========================================
   ANIMATIONS
   ========================================= */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-text > * {
  animation: fadeUp 0.6s ease both;
}
.hero-eyebrow { animation-delay: 0.1s; }
.hero h1      { animation-delay: 0.2s; }
.hero-desc    { animation-delay: 0.3s; }

.story-card {
  animation: fadeUp 0.5s ease both;
}
.story-card:nth-child(1) { animation-delay: 0.15s; }
.story-card:nth-child(2) { animation-delay: 0.25s; }
.story-card:nth-child(3) { animation-delay: 0.35s; }
.story-card:nth-child(4) { animation-delay: 0.45s; }
