/* =====================================================================
   Bibliothek (Writers & Poets)
   - Bibliotheks-Regal mit Buchrücken (CSS-only)
   - Lese-Ansicht in Buch-Typografie
   - Editor + Dashboard
   ===================================================================== */

:root {
  --lib-wood:        #5a3a1f;
  --lib-wood-2:      #4a2e15;
  --lib-shelf-grain: rgba(0,0,0,.18);
  --lib-paper:       #f4ecd8;
  --lib-paper-2:     #ebe1c4;
  --lib-ink:         #2a2218;
  --lib-accent:      #7a4a1a;

  --spine-cognac:    #a05a2c;
  --spine-navy:      #1f2c5a;
  --spine-forest:    #2f5a3a;
  --spine-wine:      #6e1f2c;
  --spine-sand:      #b89860;
  --spine-linen:     #d6c89c;
}

/* ---- Hero (Landing) ---- */

.library-hero {
  background: linear-gradient(180deg, var(--lib-paper) 0%, var(--lib-paper-2) 100%);
  border-bottom: 4px solid var(--lib-wood);
}
.library-hero__door {
  width: 100%;
  max-width: 320px;
  height: auto;
  filter: drop-shadow(0 10px 22px rgba(0,0,0,.2));
}
.library-hero__title {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 600;
  color: var(--lib-wood);
  font-size: clamp(1.8rem, 2.4vw + 1rem, 2.8rem);
  margin: 0 0 .35rem;
}
.library-hero__sub {
  color: var(--lib-ink);
  font-size: clamp(1rem, .6vw + .85rem, 1.2rem);
  margin: 0 0 1.2rem;
  max-width: 720px;
}
.library-hero__cta { margin-top: .5rem; }

/* ---- Regal-Sektion ---- */

.library-shelf-section {
  background:
    repeating-linear-gradient(0deg,
      var(--lib-paper)   0 6px,
      var(--lib-paper-2) 6px 7px);
  padding: 1.5rem 0 3rem;
}

.library-shelf {
  position: relative;
  margin: 2rem auto;
}
.library-shelf__row {
  list-style: none;
  margin: 0;
  padding: 0 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  min-height: 240px;
}
/* "Bretterboden" unter den Büchern */
.library-shelf__board {
  height: 18px;
  background:
    linear-gradient(180deg, #4a2e15 0%, #3a230f 60%, #2a190a 100%);
  border-radius: 2px;
  box-shadow:
    0 6px 14px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.06);
  margin: 0 .5rem;
}

/* ---- Einzelnes Buch (Rücken) ---- */

.lib-book {
  --h: var(--rand-h, 90%);
  --w: var(--rand-w, 44px);

  display: inline-block;
  width: var(--w);
  height: 220px;
  flex: 0 0 auto;
  text-decoration: none;
  position: relative;
  cursor: pointer;
  transition: transform .25s ease, filter .25s ease;
  filter: drop-shadow(2px 4px 4px rgba(0,0,0,.4));
}
.lib-book:hover,
.lib-book:focus-visible {
  transform: translateY(-8px) rotate(-1deg);
  filter: drop-shadow(4px 10px 10px rgba(0,0,0,.45));
  z-index: 5;
}
.lib-book:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 4px;
  border-radius: 4px;
}

.lib-book__cover {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  height: var(--h);
  margin-top: auto;
  padding: 10px 4px 12px;
  border-radius: 3px 3px 1px 1px;
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(90deg,
    rgba(0,0,0,.25) 0%,
    rgba(255,255,255,.06) 12%,
    rgba(255,255,255,.04) 80%,
    rgba(0,0,0,.35) 100%);
  background-color: var(--spine, var(--spine-cognac));
  background-blend-mode: overlay;
  color: #f6efd9;
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  text-align: center;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.4);
  box-shadow: inset 1px 0 0 rgba(255,255,255,.18),
              inset -1px 0 0 rgba(0,0,0,.35);
}

/* Buchrücken-Banderolen oben & unten — wirken wie geprägte Goldlinien */
.lib-book__cover::before,
.lib-book__cover::after {
  content: "";
  position: absolute;
  left: 4px; right: 4px;
  height: 4px;
  background: linear-gradient(90deg, rgba(255,255,255,.25), rgba(0,0,0,.35));
  border-radius: 1px;
}
.lib-book__cover::before { top: 14px; }
.lib-book__cover::after  { bottom: 36px; }

.lib-book__title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .02em;
  max-height: 130px;
  overflow: hidden;
  text-shadow: 0 1px 0 rgba(0,0,0,.5);
}
.lib-book__author {
  font-style: italic;
  font-size: 9px;
  color: rgba(246,239,217,.85);
  letter-spacing: .04em;
}

/* Spine-Farben */
.lib-book--cognac { --spine: var(--spine-cognac); }
.lib-book--navy   { --spine: var(--spine-navy); }
.lib-book--forest { --spine: var(--spine-forest); }
.lib-book--wine   { --spine: var(--spine-wine); }
.lib-book--sand   { --spine: var(--spine-sand); color: #3a2a18; }
.lib-book--sand   .lib-book__author { color: rgba(58,42,24,.85); }
.lib-book--linen  { --spine: var(--spine-linen); color: #3a2a18; }
.lib-book--linen  .lib-book__author { color: rgba(58,42,24,.85); }

/* ---- Lese-Ansicht (Buch aufgeschlagen) ---- */

.library-read {
  max-width: 760px;
  margin: 2rem auto 3rem;
  background:
    linear-gradient(180deg, var(--lib-paper) 0%, var(--lib-paper-2) 100%);
  border: 1px solid #d8caa3;
  border-radius: 4px;
  padding: 2rem 2.5rem 2.5rem;
  box-shadow:
    0 14px 34px rgba(0,0,0,.18),
    inset 0 0 0 1px rgba(255,255,255,.4);
  position: relative;
}
@media (max-width: 600px) {
  .library-read { padding: 1.25rem 1.25rem 1.5rem; margin: 1rem; }
}
/* Buchrücken-Andeutung links */
.library-read::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 8px;
  background: linear-gradient(90deg, var(--spine, var(--spine-cognac)), transparent);
  border-radius: 4px 0 0 4px;
  opacity: .55;
}
.library-read--navy   { --spine: var(--spine-navy); }
.library-read--forest { --spine: var(--spine-forest); }
.library-read--wine   { --spine: var(--spine-wine); }
.library-read--sand   { --spine: var(--spine-sand); }
.library-read--linen  { --spine: var(--spine-linen); }

.library-read__back {
  margin: 0 0 1rem;
  font-size: .9rem;
}
.library-read__back a {
  color: var(--lib-wood);
  text-decoration: none;
  font-weight: 700;
}
.library-read__back a:hover { text-decoration: underline; }

.library-read__warn {
  background: #fff8e1;
  border: 1px dashed #d6a85a;
  color: #6a4a1a;
  padding: .5rem .75rem;
  border-radius: 4px;
  font-size: .9rem;
  margin: 0 0 1rem;
}

.library-read__head { text-align: center; margin-bottom: 1.4rem; border-bottom: 1px solid #d8caa3; padding-bottom: 1.2rem; }
.library-read__title {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 600;
  color: var(--lib-ink);
  font-size: clamp(1.7rem, 2.6vw + .8rem, 2.6rem);
  line-height: 1.15;
  margin: 0 0 .35rem;
}
.library-read__sub {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  color: var(--lib-accent);
  font-size: 1.15rem;
  margin: 0 0 .5rem;
}
.library-read__byline {
  font-size: .95rem;
  color: var(--lib-ink);
  opacity: .7;
  margin: 0;
}

.library-read__body {
  font-family: 'Lato', sans-serif;
  font-size: 1.12rem;
  line-height: 1.85;
  color: var(--lib-ink);
}
.library-read__body p { margin: 0 0 1.1rem; text-indent: 1.4em; }
.library-read__body p:first-child { text-indent: 0; }
.library-read__body p:first-child::first-letter {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  float: left;
  font-size: 3.2rem;
  line-height: 1;
  padding: .15rem .5rem 0 0;
  color: var(--lib-wood);
}
.library-read__body h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-size: 1.4rem;
  color: var(--lib-wood);
  margin: 1.5rem 0 .5rem;
  text-align: center;
}
.library-read__body blockquote {
  border-left: 3px solid var(--lib-wood);
  margin: 1rem 0;
  padding: 0 1rem;
  font-style: italic;
  color: var(--lib-accent);
}
.library-read__body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1rem auto;
  display: block;
}
.library-read__body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: .95rem;
}
.library-read__body table td,
.library-read__body table th {
  border: 1px solid #d8caa3;
  padding: .4rem .6rem;
}
.library-read__edit { text-align: center; margin-top: 2rem; }

/* ---- Reaktions-Leiste (Emoji-Bar zwischen Text und Kommentaren) ---- */
.library-reactions {
  max-width: 760px;
  margin: 1.5rem auto 1rem;
  background: #fff;
  border: 1px solid #ebe1c9;
  border-radius: 12px;
  padding: 1rem 1.25rem 1.1rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.library-reactions__title {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  color: var(--lib-wood);
  font-size: 1.05rem;
  margin: 0 0 .25rem;
}
.library-reactions__hint {
  color: var(--muted);
  font-size: .9rem;
  margin: 0 0 .75rem;
}
.library-reactions__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.lib-react-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: #fdf9ef;
  border: 1px solid #ebe1c9;
  border-radius: 999px;
  padding: .35rem .9rem;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
.lib-react-btn:hover:not(:disabled),
.lib-react-btn:focus-visible {
  transform: translateY(-2px);
  border-color: var(--lib-wood);
  background: #fff8e1;
}
.lib-react-btn:focus-visible { outline: 3px solid #ffbf47; outline-offset: 2px; }
.lib-react-btn:disabled { cursor: not-allowed; opacity: .55; }
.lib-react-btn.is-on {
  background: #f7e8c8;
  border-color: var(--lib-wood);
  font-weight: 700;
}
.lib-react-btn__icon { font-size: 1.3rem; }
.lib-react-btn__count {
  font-size: .9rem;
  font-weight: 600;
  color: var(--lib-ink);
  font-variant-numeric: tabular-nums;
  min-width: 1em;
  text-align: center;
}

/* ---- Emoji-Picker im Kommentar-Formular ---- */
.library-emoji-picker {
  margin: .55rem 0 .25rem;
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}
.library-emoji-picker__label {
  font-size: .82rem;
  color: var(--muted);
  margin-right: .25rem;
}
.lib-emoji-insert {
  background: #fff;
  border: 1px solid #d8caa3;
  border-radius: 6px;
  font-size: 1.15rem;
  line-height: 1;
  padding: .15rem .45rem;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease;
}
.lib-emoji-insert:hover { background: #fdf3d4; transform: translateY(-1px); }
.lib-emoji-insert:focus-visible { outline: 3px solid #ffbf47; outline-offset: 2px; }

/* ---- Kommentare: eigene Karte, deutlich getrennt vom Buch ---- */
.library-comments {
  max-width: 760px;
  margin: 1.5rem auto 3rem;
  background: #fff;
  border: 1px solid #ebe1c9;
  border-radius: 12px;
  padding: 1.5rem 1.75rem 1.75rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
  position: relative;
}
@media (max-width: 600px) {
  .library-comments { padding: 1.1rem 1.25rem; margin: 1rem; }
}

/* Sichtbarer Übergang zwischen Buch und Diskussion */
.library-comments::before {
  content: "";
  display: block;
  width: 60px;
  height: 3px;
  background: var(--lib-wood);
  border-radius: 3px;
  margin: -.5rem auto 1.25rem;
  opacity: .55;
}
.library-comments__title {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  color: var(--lib-wood);
  font-size: 1.3rem;
  margin: 0 0 1rem;
}
.library-comments__empty {
  color: var(--lib-ink);
  opacity: .65;
  font-style: italic;
  margin: 0 0 1.25rem;
}
.library-comments__list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}
.library-comment {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: .75rem;
  padding: .85rem 0;
  border-bottom: 1px dashed #d8caa3;
}
.library-comment:last-child { border-bottom: 0; }
.library-comment__avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--lib-wood);
  color: #f6efd9;
  display: grid;
  place-items: center;
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 700;
  font-size: 1.2rem;
}
.library-comment__head {
  display: flex;
  align-items: baseline;
  gap: .65rem;
  margin-bottom: .2rem;
  flex-wrap: wrap;
}
.library-comment__author { color: var(--lib-wood); }
.library-comment__date {
  font-size: .85rem;
  color: var(--lib-ink);
  opacity: .6;
}
.library-comment__delete { margin-left: auto; }
.library-comment__delete button {
  color: var(--lib-ink);
  opacity: .4;
  font-size: 1.1rem;
}
.library-comment__delete button:hover { color: var(--red); opacity: 1; }
.library-comment__text {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--lib-ink);
}

/* Formular bzw. Login-Hinweis */
.library-comments__form,
.library-comments__login-cta {
  background: #fdf9ef;
  border: 1px solid #ebe1c9;
  border-radius: 8px;
  padding: 1rem 1.15rem;
  margin-top: .5rem;
}
.library-comments__form textarea { font-size: 1rem; }
.library-comments__login-cta {
  text-align: center;
}

/* ---- Dashboard ---- */

.library-dash__title {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 600;
  color: var(--lib-wood);
  font-size: clamp(1.5rem, 2vw + .8rem, 2rem);
  margin: 0 0 .25rem;
}
.library-dash__list {
  list-style: none;
  padding: 0;
  margin: .5rem 0 0;
}
.library-dash__list li {
  padding: .5rem .75rem;
  border-bottom: 1px solid #ebe1c9;
}
.library-dash__list a { color: var(--lib-wood); text-decoration: none; }
.library-dash__list a:hover { text-decoration: underline; }

/* ---- Editor ---- */

.library-editor { min-height: 320px; }
.library-editor__meta {
  margin-top: .5rem;
  font-size: .9rem;
}
.library-auto { font-style: italic; }

.library-side {
  background: #fdf9ef;
  border: 1px solid #ebe1c9;
  border-radius: 8px;
  padding: 1rem;
  position: sticky;
  top: 1rem;
}

.spine-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .35rem;
  margin-top: .35rem;
}
.spine-picker__opt {
  cursor: pointer;
  text-align: center;
  font-size: .8rem;
}
.spine-picker__opt input { display: none; }
.spine-picker__swatch {
  display: block;
  height: 36px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.3);
  margin-bottom: .15rem;
  box-shadow: inset 1px 0 0 rgba(255,255,255,.25);
}
.spine-picker__opt--cognac .spine-picker__swatch { background: var(--spine-cognac); }
.spine-picker__opt--navy   .spine-picker__swatch { background: var(--spine-navy); }
.spine-picker__opt--forest .spine-picker__swatch { background: var(--spine-forest); }
.spine-picker__opt--wine   .spine-picker__swatch { background: var(--spine-wine); }
.spine-picker__opt--sand   .spine-picker__swatch { background: var(--spine-sand); }
.spine-picker__opt--linen  .spine-picker__swatch { background: var(--spine-linen); }
.spine-picker__opt input:checked + .spine-picker__swatch {
  outline: 2px solid var(--lib-wood);
  outline-offset: 2px;
}

/* Anhang-Block im Editor */
.library-attach {
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  background: #fdf9ef;
  border: 1px dashed #d8caa3;
  border-radius: 8px;
}
.library-attach__title {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 600;
  color: var(--lib-wood);
  font-size: 1.05rem;
  margin: 0 0 .25rem;
}
.library-attach__hint {
  color: #6a4a1a;
  background: #fff8e1;
  border: 1px dashed #d6a85a;
  border-radius: 4px;
  padding: .5rem .75rem;
  font-size: .9rem;
  margin: 0 0 .5rem;
}
.library-attach__current {
  background: #fff;
  border: 1px solid #ebe1c9;
  border-radius: 6px;
  padding: .55rem .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.library-attach__chip {
  display: inline-block;
  background: var(--lib-wood);
  color: #fff;
  font-weight: 700;
  font-size: .75rem;
  letter-spacing: .04em;
  padding: .15rem .5rem;
  border-radius: 3px;
}
.library-attach__file {
  color: var(--lib-wood);
  text-decoration: none;
  font-weight: 700;
}
.library-attach__file:hover { text-decoration: underline; }

/* Datei-Upload-Zone im Editor (DOCX/ODT/RTF/TXT/PDF → HTML) */
.library-upload-zone {
  margin-top: .5rem;
  padding: 1.1rem 1.25rem;
  background: #fdf9ef;
  border: 2px dashed #d8caa3;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.library-upload-zone:hover,
.library-upload-zone.is-drag {
  border-color: var(--lib-wood);
  background: #fff8e1;
}
.library-upload-zone__text {
  margin: 0 0 .2rem;
  font-weight: 700;
  color: var(--lib-wood);
}
.library-upload-zone__hint {
  margin: 0;
  font-size: .85rem;
  color: var(--muted);
}
.library-upload-zone__input {
  display: block;
  margin: .6rem auto 0;
  max-width: 320px;
}
.library-upload-zone__status {
  margin: .5rem 0 0;
  font-size: .85rem;
  font-style: italic;
  min-height: 1.2em;
}
.library-upload-zone__status.is-error { color: var(--red, #b3261e); }

/* Anhang-Karte in der Leseansicht */
.library-attach-card {
  max-width: 760px;
  margin: 1.5rem auto;
  background: #fbf3dd;
  border: 1px solid #d8caa3;
  border-radius: 8px;
  padding: .85rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .9rem;
}
.library-attach-card__body { flex: 1; }
.library-attach-card__head { margin: 0 0 .35rem; font-size: 1rem; }

/* PDF-Inline-Frame */
.library-pdf-frame {
  max-width: 920px;
  margin: 2rem auto;
  border: 1px solid #d8caa3;
  border-radius: 8px;
  overflow: hidden;
  background: #2a2218;
}
.library-pdf-frame object { display: block; }

/* ---- Writers-Intro-Akkordeon (klickbare Zeilen) ----------------- */
.writers-intro {
  max-width: 920px;
  margin: 0 auto 1.5rem;
}
.writers-intro .accordion-item {
  background: #fdf9ef;
  border: 1px solid #ebe1c9;
  border-radius: 10px;
  margin-bottom: .5rem;
  overflow: hidden;
}
.writers-intro .accordion-button {
  background: transparent;
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-size: 1.15rem;
  color: #6a4a14;
  padding: .85rem 1.1rem;
}
.writers-intro .accordion-button:not(.collapsed) {
  background: #f5ebd2;
  color: #4a3208;
  box-shadow: none;
}
.writers-intro .accordion-button:focus {
  box-shadow: 0 0 0 .2rem rgba(184, 138, 59, .25);
  border-color: transparent;
}
.writers-intro .accordion-body {
  font-size: 1rem;
  line-height: 1.55;
  padding: .25rem 1.1rem 1rem;
  color: var(--ink);
}
.writers-intro .accordion-body p:last-child { margin-bottom: 0; }
@media (max-width: 575.98px) {
  .writers-intro .accordion-button { font-size: 1rem; padding: .7rem .85rem; }
  .writers-intro .accordion-body { padding: .25rem .85rem .85rem; }
}

/* ---- Buch-Index unter dem Regal --------------------------------- */
.library-index {
  max-width: 920px;
  margin: 1rem auto 2rem;
}
.library-index .accordion-item {
  background: #fdf9ef;
  border: 1px solid #ebe1c9;
  border-radius: 10px;
  overflow: hidden;
}
.library-index .accordion-button {
  background: transparent;
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-size: 1.1rem;
  color: #6a4a14;
  padding: .75rem 1.1rem;
  gap: .5rem;
}
.library-index .accordion-button:not(.collapsed) {
  background: #f5ebd2;
  color: #4a3208;
  box-shadow: none;
}
.library-index .accordion-button:focus {
  box-shadow: 0 0 0 .2rem rgba(184, 138, 59, .25);
}
.library-index__count {
  color: var(--muted);
  font-style: normal;
  font-family: 'Lato', sans-serif;
  font-size: .9rem;
}
.library-index__table th {
  background: #f5ebd2;
  color: #6a4a14;
  font-weight: 700;
  font-size: .9rem;
  border-bottom: 1px solid #ebe1c9;
}
.library-index__table td {
  vertical-align: middle;
  border-bottom: 1px solid #f1e8d2;
}
.library-index__link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.library-index__link:hover { color: var(--accent); text-decoration: underline; }
@media (max-width: 575.98px) {
  .library-index .accordion-button { font-size: 1rem; padding: .65rem .85rem; }
  .library-index__table th, .library-index__table td { padding: .45rem .6rem; }
}
