/* Consultas (Biblioteca home): welcome preview background image.
   Keep this isolated from the shared biblioteca-shelf.css so other pages are unaffected. */

@media (min-width: 769px) {
  /* Anchor the preview box at the bottom of the right column (matches Manage Dashboard feel). */
  .bib-shelf-wrap .bib-shelf-right {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }

  /* Keep the preview area height stable even when the selected book changes title/desc. */
  .bib-shelf-wrap .bib-preview {
    min-height: 260px;
    height: auto; /* allow to grow so content never overlaps (no interposed buttons) */
    /* Anchor the hero pseudo-element without needing position:relative on .is-empty. */
    position: relative;
  }

  .bib-shelf-wrap .bib-preview .bib-preview-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
  }

  .bib-shelf-wrap .bib-preview .bib-preview-count {
    margin-top: 0; /* override base (margin-top:auto) */
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .bib-shelf-wrap .bib-preview.is-empty {
    --bib-hero-panel-w: 46%;
    /* Defaults; JS can override per selected hero image. */
    --bib-hero-scale: 92%;
    --bib-hero-bottom-offset: 0px;
    overflow: hidden;
    border-radius: 18px;
    /* Slightly more padding than the default so the background can breathe. */
    padding: 18px 18px 18px 18px;
    /* Keep the copy from colliding with the right-side image. */
    padding-right: calc(var(--bib-hero-panel-w) + 22px);
    /* Place the entire welcome content block at the bottom of the preview. */
    justify-content: flex-end;
  }

  .bib-shelf-wrap .bib-preview .bib-preview-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  /* Make the welcome description a bit smaller on Consultas only. */
  .bib-shelf-wrap .bib-preview.is-empty .bib-preview-desc {
    font-size: 18px;
    line-height: 1.35;
  }

  /* iPad/tablet: keep hero visible but less invasive to avoid overlap. */
  @media (max-width: 1100px) {
    .bib-shelf-wrap .bib-preview.is-empty {
      --bib-hero-panel-w: 38%;
      --bib-hero-scale: 82%;
      padding-right: calc(var(--bib-hero-panel-w) + 14px);
    }
    .bib-shelf-wrap .bib-preview.is-empty .bib-preview-desc {
      font-size: 15px;
      line-height: 1.3;
    }
    .bib-shelf-wrap .bib-preview .bib-preview-desc-text {
      -webkit-line-clamp: 2;
    }
  }

  /* Hand hint (FontAwesome) */
  .bib-shelf-wrap .bib-preview .bib-preview-hand {
    display: none;
  }
  .bib-shelf-wrap .bib-preview.is-empty .bib-preview-hand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-right: 10px;
    opacity: 0.55;
    color: rgba(0, 0, 0, 0.55);
    transform-origin: 60% 50%;
    animation: bibHandWiggle 1.15s ease-in-out infinite;
    vertical-align: text-top;
    flex: 0 0 auto;
    font-size: 22px;
    margin-top: 1px;
  }
  [data-theme="dark"] .bib-shelf-wrap .bib-preview.is-empty .bib-preview-hand {
    color: rgba(255, 255, 255, 0.65);
    opacity: 0.7;
  }

  @keyframes bibHandWiggle {
    0%   { transform: translateX(2px) rotate(6deg); }
    50%  { transform: translateX(-7px) rotate(-10deg); }
    100% { transform: translateX(2px) rotate(6deg); }
  }

  @media (prefers-reduced-motion: reduce) {
    .bib-shelf-wrap .bib-preview.is-empty .bib-preview-hand {
      animation: none;
      transform: none;
    }
  }

  /* Avoid clipping the icon inside line-clamp; clamp only the text span. */
  .bib-shelf-wrap .bib-preview .bib-preview-desc {
    display: flex;
    align-items: flex-start;
    min-width: 0;
  }
  .bib-shelf-wrap .bib-preview .bib-preview-desc-text {
    min-width: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }

  .bib-shelf-wrap .bib-preview .bib-preview-go {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    background: rgba(255, 255, 255, 0.92);
    color: rgba(0, 0, 0, 0.82);
    font-weight: 900;
    font-size: 13px;
    text-decoration: none;
    transition: transform .12s ease, background .16s ease, border-color .16s ease;
  }
  /* Keep layout space reserved even when "hidden". */
  .bib-shelf-wrap .bib-preview .bib-preview-go[aria-hidden="true"] {
    visibility: hidden;
    pointer-events: none;
  }
  .bib-shelf-wrap .bib-preview .bib-preview-go:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.16);
  }
  [data-theme="dark"] .bib-shelf-wrap .bib-preview .bib-preview-go {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.22);
    color: rgba(255, 255, 255, 0.90);
  }
  [data-theme="dark"] .bib-shelf-wrap .bib-preview .bib-preview-go:hover {
    background: rgba(0, 0, 0, 0.30);
    border-color: rgba(255, 255, 255, 0.20);
  }

  .bib-shelf-wrap .bib-preview.is-empty::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--bib-hero-panel-w);
    background-repeat: no-repeat;
    /* Match dashboard behavior: size by height, crop only to the RIGHT inside the right panel. */
    background-position: left calc(100% + var(--bib-hero-bottom-offset));
    background-size: auto var(--bib-hero-scale);
    background-image: var(--bib-hero-url, url("../img/misc/arte_03.png"));
    pointer-events: none;
    z-index: 0;
  }

  .bib-shelf-wrap .bib-preview.is-empty .bib-preview-title,
  .bib-shelf-wrap .bib-preview.is-empty .bib-preview-desc,
  .bib-shelf-wrap .bib-preview.is-empty .bib-preview-count {
    position: relative;
    z-index: 1;
  }
}
