/* ==========================================================================
   CABEÇALHO DA SEÇÃO DE FILOSOFIA
   ========================================================================== */
.philosophy-page {
  align-content: end;
  display: flex;
  flex-direction: column;
  gap: 15svh;
}

.grid-philosophy {
  margin-top: 15svh;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 2vw;
  align-items: start;
}
.philosophy-groups-content {
  margin-bottom: 0;
}

/* ==========================================================================
   HERO DA FILOSOFIA
   ========================================================================== */
.philosophy-hero {
  grid-template-rows: auto auto 1fr;
  /* margin-bottom: 25svh; */
}

.img-philosophy-hero {
  grid-column: 1 / 13;
  grid-row: 1 / 1;
  width: 100%;
  height: 45svh;
  overflow: hidden;
  position: relative;
}

.img-philosophy-hero picture,
.img-philosophy-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 0% 60%;
  display: block;
  --parallax-y: 0px;
  translate: 0 var(--parallax-y);
  scale: 1.15;
  will-change: translate;
}
.philosophy-area {
  display: none;
  grid-column: 1 / 5;
  grid-row-start: 1;
  font-weight: 400;
  margin-top: -0.3rem;
}

.philosophy-intro {
  height: 100%;
  grid-column: 1 / 13;
  grid-row: 2 / 5;
  line-height: 1.2;
  text-wrap: balance;
  display: flex;
  /* flex-direction: column; */
  gap: 1rem;
  justify-content: space-between;
}

/* ==========================================================================
   A ESTANTE (SISTEMA DE PRATELEIRAS FÍSICAS)
   ========================================================================== */
.philosophy-page .bookshelf-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8svh;
  padding: 0;
}

.bookshelf-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 1vw;
  width: 100%;
  height: 65svh;
}

.book-item {
  flex: 0 0 5vw;
  height: var(--book-height, 45svh);
  background-color: var(--book-color);
  border: 1px solid #000;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: flex 0.7s cubic-bezier(0.25, 1, 0.5, 1);
}

.book-item.is-open {
  flex: 0 0 35vw;
}

/* ==========================================================================
   LOMBADA (ESTADO FECHADO)
   ========================================================================== */
.book-spine {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 5vw;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 2svh;
  transition: opacity 0.3s ease;
}

.book-title-vertical {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: var(--fs-1);
  line-height: 1.2;
}

.book-item.is-open .book-spine {
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   DETALHE EDITORIAL (MARCADOR DA LOMBADA)
   ========================================================================== */
@media (min-width: 1000px) {
  /* Desenha o traço de 1px a exatos 20% do topo da lombada */
  .book-spine::after {
    content: "";
    position: absolute;
    top: 15%;
    left: 20%;
    right: 20%;
    height: 1px;
    background-color: rgba(0, 0, 0, 0.2);
    z-index: 2;
  }
}

/* ==========================================================================
   TIPOGRAFIA DA LOMBADA
   ========================================================================== */
.book-spine-main,
.book-spine-sub {
  display: block;
  white-space: nowrap;
}

.book-spine-main {
  font-weight: 500;
}

.book-spine-sub {
  font-weight: 300;
  opacity: 0.7;
  font-size: 0.85em;
}

/* ==========================================================================
   CONTEÚDO (ESTADO ABERTO)
   ========================================================================== */
.book-content {
  opacity: 0;
  width: 100%;
  height: 100%;
  padding: 2.5vw;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  pointer-events: none;
  transition: opacity 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.book-item.is-open .book-content {
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0.3s;
}

.book-item.is-open {
  cursor: default;
}

/* Força o cursor de texto ('I-beam') em todos os textos legíveis */
.book-item.is-open .book-title-expanded,
.book-item.is-open .book-subtitle-expanded,
.book-item.is-open .book-coauthors,
.book-item.is-open .book-excerpt {
  cursor: text;
  user-select: text;
}

.book-item.is-open .book-btn {
  cursor: pointer;
}

/* Metadados Superiores */
.book-meta {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  padding-bottom: 0.5rem;
  margin-bottom: 2svh;
  width: fit-content;
}

.book-publication {
  font-weight: 400;
  font-style: italic;
  opacity: 0.8;
}

.book-meta-divider {
  opacity: 0.4;
  font-size: 0.8em;
}

/* Títulos */
.book-title-expanded {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1rem;
  line-height: 1.1;
  word-break: break-word;
  text-wrap: balance;
}

.book-subtitle-expanded {
  font-size: var(--fs-1);
  font-weight: 300;
  opacity: 0.75;
}

/* Autoria e Resumo */
.book-coauthors {
  font-size: 0.9em;
  font-weight: 400;
  opacity: 0.6;
  margin-bottom: 1rem;
  margin-top: -0.5rem;
}

.book-excerpt {
  max-width: 45ch;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  text-wrap: pretty;
  margin-bottom: 1rem;
}

.book-btn {
  flex-shrink: 0;
  margin-top: auto;
  border: 1px solid #000;
  padding: 0.5rem 1.5rem;
  width: fit-content;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
  .book-btn:hover {
    background-color: rgba(0, 0, 0, 0.15);
    color: #000;
    text-decoration: none;
  }
}

/* ==========================================================================
   O LIVRO TOMBADO (ÚLTIMO ITEM DA PRATELEIRA)
   ========================================================================== */
.book-item.tilted-book {
  pointer-events: none;
  cursor: default;
  transform-origin: bottom left;
  transform: rotate(-8deg);
  margin-left: 50px;
}

/* ==========================================================================
   OVERRIDES MOBILE E TABLETS 
   ========================================================================== */
@media (max-width: 1000px), (max-width: 1368px) and (pointer: coarse), (max-aspect-ratio: 4/3) {
  .philosophy-page {
    margin-top: 0svh;
  }

  /* HERO FLUIDA PARA TOUCH */
  .philosophy-hero {
    display: flex;
    flex-direction: column;
    gap: 4svh;
    margin-bottom: 20svh;
  }
  .img-philosophy-hero {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    position: relative;
  }
  .img-philosophy-hero picture img,
  .img-philosophy-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 0% 60%;
    display: block;
    --parallax-y: 0px;
    --zoom: 1.15;
    translate: 0 var(--parallax-y);
    scale: var(--zoom);
    will-change: translate;
  }
  .philosophy-intro {
    flex-direction: column;
    hyphens: auto;
    text-wrap: pretty;
  }

  /* A ESTANTE ACORDEÃO (O design que já funcionava no celular, agora no iPad) */
  .bookshelf-wrapper {
    gap: 2svh;
  }
  .book-excerpt {
    hyphens: auto;
  }

  /* O SEGREDO: Força a fileira a virar uma coluna empilhada em qualquer tablet */
  .bookshelf-row {
    flex-direction: column;
    height: auto;
    gap: 2svh;
  }

  .book-item {
    flex: none;
    width: 100%;
    height: 12svh;
    transition: height 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  }
  .book-item.is-open {
    flex: none;
    width: 100%;
    height: 65svh;
  }

  /* LOMBADA LARGA E FÁCIL DE TOCAR */
  .book-spine {
    width: 100%;
    height: 12svh;
    bottom: auto;
    top: 0;
    left: 0;
    padding-bottom: 0;
    padding-left: 5vw;
    padding-right: 5vw;
    align-items: center;
    justify-content: flex-start;
  }
  .book-spine::after {
    display: none;
  }
  .book-title-vertical {
    writing-mode: horizontal-tb; /* Devolve a leitura normal */
    transform: none;
    display: flex;
    gap: 0.2rem;
    width: 100%;
    min-width: 0;
  }
  .book-spine-main {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
  }
  .book-spine-sub,
  .book-subtitle-expanded {
    display: none;
  }

  /* OCULTA O LIVRO TOMBADO NO TABLET */
  .book-item.tilted-book {
    display: none;
  }

  /* CONTEÚDO EXPANDIDO */
  .book-content {
    width: 100%;
    height: 100%;
    padding: 10vw 6vw;
    overflow-y: auto;
  }
}
