.lore-shell{
  padding-top:calc(var(--header-h) + 4px);
}

.lore-shell .container{
  width:min(calc(100% - 28px), 1440px);
}

.lore-hero{
  position:relative;
  display:grid;
  grid-template-columns:minmax(0, 1fr) minmax(320px, 480px);
  gap:28px;
  align-items:end;
  min-height:52svh;
  padding-top:24px;
  padding-bottom:28px;
}

.lore-hero::before{
  content:"";
  position:absolute;
  inset:0;
  z-index:-1;
  border-radius:32px;
  background:
    linear-gradient(90deg, rgba(7,8,8,.94), rgba(7,8,8,.58)),
    url("../assets/logo/Fundo - Foundation.webp") center/cover;
  opacity:.86;
}

.lore-hero-copy{
  max-width:840px;
  padding:34px;
}

.lore-hero h1{
  margin:18px 0 16px;
  max-width:820px;
  font-family:"Cormorant Garamond", serif;
  font-size:clamp(3rem, 6vw, 6.1rem);
  font-weight:600;
  line-height:.92;
}

.lore-hero p{
  max-width:720px;
  margin:0;
  color:#ddd5c8;
  font-size:1.04rem;
  line-height:1.85;
}

.lore-search{
  display:grid;
  gap:12px;
  margin:34px;
  padding:18px;
  border-radius:22px;
  border:1px solid rgba(255,255,255,.1);
  background:rgba(7,8,8,.64);
  backdrop-filter:blur(14px);
  box-shadow:var(--shadow);
}

.lore-search label{
  color:var(--gold);
  font-size:.72rem;
  letter-spacing:.14em;
  text-transform:uppercase;
}

.lore-search-row{
  display:grid;
  grid-template-columns:minmax(0, 1fr) auto;
  gap:10px;
}

.lore-search input,
.lore-search button,
.reading-actions button{
  min-height:48px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.035);
  color:var(--text);
  font:inherit;
}

.lore-search input{
  width:100%;
  padding:0 16px;
}

.lore-search button,
.reading-actions button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0 18px;
  cursor:pointer;
}

.lore-section-head{
  display:flex;
  justify-content:space-between;
  align-items:end;
  gap:24px;
  margin:38px 0 18px;
}

.lore-section-head h2{
  margin:10px 0 0;
  font-family:"Cormorant Garamond", serif;
  font-size:clamp(2.2rem, 4vw, 4rem);
  font-weight:600;
}

.lore-section-head p{
  margin:0;
  color:var(--muted);
}

.book-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:18px;
}

.book-card{
  position:relative;
  min-height:360px;
  overflow:hidden;
  display:grid;
  align-content:end;
  padding:24px;
  border:1px solid rgba(255,255,255,.1);
  border-radius:24px;
  background:#101313;
  box-shadow:var(--shadow);
  color:inherit;
  cursor:pointer;
  text-align:left;
}

.book-card::before{
  content:"";
  position:absolute;
  inset:0;
  background:var(--book-bg) center/cover;
  filter:brightness(.56) saturate(.9);
  transition:transform .42s ease, filter .42s ease;
}

.book-card::after{
  content:"";
  position:absolute;
  inset:0;
  background:
    linear-gradient(90deg, rgba(240,215,159,.36) 0 9px, rgba(0,0,0,0) 9px),
    linear-gradient(180deg, rgba(0,0,0,.08), rgba(0,0,0,.82));
}

.book-card:hover::before,
.book-card.is-active::before{
  transform:scale(1.05);
  filter:brightness(.72) saturate(1);
}

.book-card.is-active{
  border-color:rgba(215,193,139,.54);
}

.book-body{
  position:relative;
  z-index:1;
  display:grid;
  gap:12px;
}

.book-card h3{
  margin:0;
  font-family:"Cormorant Garamond", serif;
  font-size:2.45rem;
  font-weight:600;
  line-height:.95;
}

.book-meta{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.book-meta span,
.chapter-chip{
  display:inline-flex;
  min-height:30px;
  align-items:center;
  padding:0 11px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.1);
  background:rgba(255,255,255,.045);
  color:#efe6d2;
  font-size:.78rem;
}

.book-card p{
  margin:0;
  color:#d8d0c3;
  line-height:1.7;
  max-height:0;
  opacity:0;
  overflow:hidden;
  transform:translateY(8px);
  transition:max-height .26s ease, opacity .22s ease, transform .22s ease;
}

.book-card:hover p,
.book-card:focus-visible p{
  max-height:170px;
  opacity:1;
  transform:translateY(0);
}

body.lore-drawer-open{
  overflow:hidden;
}

.lore-drawer{
  position:fixed;
  inset:0;
  z-index:120;
  display:grid;
  place-items:center;
  padding:18px;
  pointer-events:none;
  opacity:0;
  transition:opacity .22s ease;
}

.lore-drawer.is-open{
  pointer-events:auto;
  opacity:1;
}

.drawer-backdrop{
  position:absolute;
  inset:0;
  border:0;
  background:rgba(0,0,0,.72);
  cursor:pointer;
}

.lore-drawer .drawer-panel{
  position:relative;
  width:min(1480px, 100%);
  height:min(900px, calc(100svh - 36px));
  overflow:hidden;
  border-radius:28px;
  border:1px solid rgba(255,255,255,.12);
  background:
    radial-gradient(circle at top left, rgba(215,193,139,.1), transparent 34%),
    rgba(10,12,12,.94);
  box-shadow:0 32px 120px rgba(0,0,0,.72);
  transform:translateY(14px) scale(.985);
  transition:transform .22s ease;
}

.lore-drawer.is-open .drawer-panel{
  transform:translateY(0) scale(1);
}

.drawer-close{
  position:absolute;
  top:14px;
  right:14px;
  z-index:50;
  width:50px;
  height:50px;
  border-radius:999px;
  border:1px solid rgba(240,215,159,.72);
  background:rgba(8,9,9,.88);
  color:#fff4d0;
  font-size:1.95rem;
  line-height:1;
  cursor:pointer;
  backdrop-filter:blur(12px);
  box-shadow:0 10px 30px rgba(0,0,0,.52), 0 0 0 3px rgba(240,215,159,.12);
}

.reading-background{
  position:absolute;
  inset:0;
  background-position:center top 18%;
  background-size:cover;
  background-repeat:no-repeat;
  opacity:.62;
  filter:saturate(.9) contrast(1.05);
  pointer-events:none;
}

.reading-background::after{
  content:"";
  position:absolute;
  inset:0;
  background:
    linear-gradient(90deg, rgba(7,8,8,.88), rgba(7,8,8,.52) 42%, rgba(7,8,8,.26)),
    linear-gradient(180deg, rgba(7,8,8,.26), rgba(7,8,8,.78));
}

.reading-room{
  position:relative;
  z-index:1;
  display:grid;
  grid-template-columns:minmax(260px, 340px) minmax(0, 1fr);
  gap:18px;
  height:100%;
  padding:28px;
}

.reading-side,
.reading-main{
  min-height:0;
  border:1px solid var(--line);
  border-radius:24px;
  background:rgba(7,8,8,.3);
  box-shadow:var(--shadow);
  backdrop-filter:blur(3px);
}

.reading-side{
  display:grid;
  align-content:start;
  padding:18px;
}

.chapter-list-panel{
  display:grid;
  gap:12px;
}

.chapter-list-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.chapter-list-head > span:last-child{
  color:var(--muted);
  font-size:.86rem;
}

.chapter-list{
  display:grid;
  gap:8px;
  max-height:none;
  overflow:auto;
  height:calc(100svh - 190px);
  padding-right:4px;
}

.chapter-button{
  display:grid;
  grid-template-columns:38px minmax(0, 1fr);
  align-items:center;
  gap:10px;
  width:100%;
  padding:9px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:14px;
  background:rgba(255,255,255,.025);
  color:inherit;
  cursor:pointer;
  text-align:left;
}

.chapter-button img{
  width:38px;
  height:52px;
  border-radius:6px;
  object-fit:cover;
}

.chapter-button strong{
  display:block;
  overflow:hidden;
  color:#fff7df;
  font-size:.92rem;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.chapter-button span{
  display:block;
  margin-top:3px;
  color:var(--muted);
  font-size:.76rem;
}

.chapter-button.is-active{
  border-color:rgba(215,193,139,.48);
  background:rgba(215,193,139,.1);
}

.reading-main{
  position:relative;
  overflow:hidden;
  isolation:isolate;
  display:grid;
  grid-template-columns:minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:"header chapter";
  gap:0;
  align-content:start;
  height:100%;
  padding:0;
  border-color:rgba(94,68,31,.58);
  background:
    linear-gradient(90deg, rgba(211,189,143,.92) 0 49.6%, rgba(111,82,42,.82) 49.6% 50.4%, rgba(234,219,184,.92) 50.4% 100%),
    var(--chapter-art, none) center/cover no-repeat;
  color:#2c2114;
  box-shadow:
    inset 0 0 52px rgba(74,43,15,.22),
    0 28px 80px rgba(0,0,0,.56);
}

.reading-main::before{
  content:"";
  position:absolute;
  top:0;
  bottom:0;
  left:50%;
  z-index:2;
  width:32px;
  transform:translateX(-50%);
  background:
    linear-gradient(90deg, rgba(33,19,8,.34), rgba(255,255,255,.18), rgba(33,19,8,.42));
  box-shadow:
    -18px 0 32px rgba(65,37,12,.18),
    18px 0 32px rgba(65,37,12,.2);
  pointer-events:none;
}

.reading-main::after{
  content:"";
  position:absolute;
  inset-block:0;
  z-index:3;
  width:50%;
  opacity:0;
  pointer-events:none;
  background:
    linear-gradient(90deg, rgba(255,255,255,.18), rgba(104,67,27,.2)),
    repeating-linear-gradient(0deg, rgba(75,50,24,.08) 0 1px, transparent 1px 32px),
    #eadbb8;
  box-shadow:0 22px 52px rgba(0,0,0,.32);
}

.reading-room.is-turning-next .reading-main::after{
  left:50%;
  transform-origin:left center;
  animation:lorePageTurnNext .42s ease both;
}

.reading-room.is-turning-prev .reading-main::after{
  left:0;
  transform-origin:right center;
  animation:lorePageTurnPrev .42s ease both;
}

.reading-header{
  grid-area:header;
  position:relative;
  z-index:1;
  display:grid;
  gap:12px;
  align-content:start;
  min-width:0;
  min-height:520px;
  height:100%;
  padding:46px 62px 46px 44px;
  overflow:auto;
  border:0;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.28), transparent 30%),
    linear-gradient(90deg, rgba(127,83,32,.16), transparent 28%),
    repeating-linear-gradient(0deg, rgba(75,50,24,.07) 0 1px, transparent 1px 33px);
}

.reading-header h2{
  margin:0;
  font-family:"Cormorant Garamond", serif;
  font-size:clamp(2.4rem, 5vw, 4.8rem);
  font-weight:600;
  line-height:.92;
  color:#2f2111;
}

.reading-header p{
  margin:0;
  color:#6c4a24;
  font-size:1.05rem;
}

.reading-card-art{
  width:min(360px, 92%);
  justify-self:center;
  margin-top:12px;
  border-radius:18px;
  object-fit:cover;
  aspect-ratio:1;
  border:1px solid rgba(99,63,25,.28);
  box-shadow:0 18px 42px rgba(77,49,20,.22);
}

.reading-header .section-kicker{
  color:#7f5b25;
}

.chapter-panel{
  grid-area:chapter;
  position:relative;
  z-index:1;
  overflow:auto;
  display:grid;
  gap:12px;
  align-content:start;
  min-width:0;
  min-height:520px;
  height:100%;
  padding:46px 48px 46px 62px;
  border:0;
  border-radius:0;
  background:
    radial-gradient(circle at top right, rgba(255,255,255,.28), transparent 30%),
    linear-gradient(270deg, rgba(127,83,32,.12), transparent 28%),
    repeating-linear-gradient(0deg, rgba(75,50,24,.07) 0 1px, transparent 1px 33px);
}

.chapter-panel .section-kicker{
  color:#7f5b25;
}

.chapter-panel p{
  margin:0;
  color:#342413;
  font-family:"Cormorant Garamond", serif;
  font-size:1.34rem;
  line-height:1.72;
}

.chapter-panel p + p{
  margin-top:12px;
}

.reading-actions{
  position:absolute;
  inset:0;
  z-index:5;
  display:block;
  padding:0;
  border:0;
  background:transparent;
  pointer-events:none;
  backdrop-filter:none;
}

.reading-actions button{
  position:absolute;
  top:50%;
  display:grid;
  place-items:center;
  width:42px;
  height:42px;
  min-height:42px;
  padding:0;
  border-radius:999px;
  border:1px solid rgba(72,48,20,.28);
  background:rgba(255,247,223,.74);
  color:#392816;
  font-size:0;
  line-height:1;
  box-shadow:0 12px 28px rgba(0,0,0,.2);
  pointer-events:auto;
  transform:translateY(-50%);
}

.reading-actions button::before{
  font-size:1.7rem;
  line-height:1;
}

#prevChapter{
  left:14px;
}

#nextChapter{
  right:14px;
}

#prevChapter::before{
  content:"‹";
}

#nextChapter::before{
  content:"›";
}

.reading-actions button:disabled{
  opacity:.38;
  cursor:not-allowed;
}

@keyframes lorePageTurnNext{
  0%{opacity:0; transform:perspective(900px) rotateY(0deg)}
  15%{opacity:1}
  100%{opacity:0; transform:perspective(900px) rotateY(-102deg)}
}

@keyframes lorePageTurnPrev{
  0%{opacity:0; transform:perspective(900px) rotateY(0deg)}
  15%{opacity:1}
  100%{opacity:0; transform:perspective(900px) rotateY(102deg)}
}

.lore-empty,
.lore-loading{
  grid-column:1 / -1;
  min-height:220px;
  display:grid;
  place-items:center;
  text-align:center;
  padding:24px;
  border-radius:24px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
}

.lore-empty h3,
.lore-loading h3{
  margin:0 0 10px;
  font-family:"Cormorant Garamond", serif;
  font-size:2rem;
  font-weight:600;
}

.lore-empty p,
.lore-loading p{
  margin:0;
  color:var(--muted);
}

@media (max-width: 1080px){
  .lore-hero{
    grid-template-columns:1fr;
  }

  .book-grid{
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }

  .reading-room{
    grid-template-columns:1fr;
    overflow:auto;
  }

  .reading-side{
    order:2;
  }

  .chapter-list{
    height:auto;
    max-height:260px;
  }

  .reading-main{
    grid-template-columns:1fr;
    grid-template-areas:
      "header"
      "chapter";
    height:auto;
    min-height:520px;
    overflow:visible;
  }

  .reading-main::before{
    display:none;
  }

  .reading-main::after{
    width:100%;
  }

  .reading-header,
  .chapter-panel{
    height:auto;
    min-height:auto;
    padding:34px 30px 62px;
    overflow:visible;
  }
}

@media (max-width: 760px){
  .lore-shell{
    padding-top:var(--header-h);
  }

  .lore-hero-copy,
  .lore-search{
    margin:0;
    padding:22px;
  }

  .lore-hero{
    gap:16px;
  }

  .lore-search-row{
    grid-template-columns:1fr;
  }

  .book-grid{
    grid-template-columns:1fr;
  }

  .lore-section-head{
    display:grid;
  }

  .lore-drawer{
    padding:0;
  }

  .lore-drawer .drawer-panel{
    height:100svh;
    border-radius:0;
  }

  .reading-room{
    padding:18px;
  }

  .reading-header,
  .chapter-panel{
    padding:28px 22px 54px;
  }
}
