/* Modern Ebook-Style Layout */

.dashboard-main.ebook .dashboard-page-header {
  display: none !important;
}

.ebook {
  --ebook-max-width: 90ch;
  --ebook-padding: clamp(1.5rem, 4vw, 3rem);
  
  container-type: inline-size;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.ebook__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem var(--ebook-padding);
  border-bottom: 1px solid var(--color-subtle-dark);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.ebook__header-title {
  flex: 1;
  text-align: center;
  
  strong {
    font-size: 1rem;
    font-weight: 600;
  }
}

.ebook__header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: auto;
  flex-shrink: 0;
}

.ebook__container {
  flex: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--ebook-padding);
}

.ebook__preview-banner {
  background: var(--color-subtle-dark);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 2rem;
  text-align: center;
  font-size: 0.9rem;
  
  strong {
    font-weight: 600;
  }
}

.ebook__preview-link {
  color: var(--color-link);
  text-decoration: underline;
  font-weight: 600;
  cursor: pointer;
  
  &:hover {
    text-decoration: none;
    opacity: 0.8;
  }
}

.ebook__hero-grid {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--color-subtle-dark);
}

.ebook__hero-cover {
  display: flex;
  justify-content: center;
}

.ebook__cover {
  width: 100%;
  max-width: 320px;
  height: auto;
  border-radius: 0.75rem;
  box-shadow: 0 25px 45px rgba(15, 23, 42, 0.2);
  display: block;
}

.ebook__cover-placeholder {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 2 / 3;
  border-radius: 0.75rem;
  background: var(--color-subtle-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--color-ink);
  
  .ebook__cover-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.3;
    color: inherit;
  }
}

.ebook__cover-placeholder.theme--black,
.ebook__cover-placeholder.theme--blue,
.ebook__cover-placeholder.theme--green,
.ebook__cover-placeholder.theme--magenta,
.ebook__cover-placeholder.theme--orange,
.ebook__cover-placeholder.theme--violet {
  background: url("/assets/covers/cover-blue-f33c5778.png") no-repeat center;
  background-size: cover;
  color: var(--color-always-white);
}

.ebook__cover-placeholder.theme--black {
  background-image: url("/assets/covers/cover-black-443e3258.png");
}

.ebook__cover-placeholder.theme--green {
  background-image: url("/assets/covers/cover-green-e645ae7b.png");
}

.ebook__cover-placeholder.theme--magenta {
  background-image: url("/assets/covers/cover-magenta-dcc72425.png");
}

.ebook__cover-placeholder.theme--orange {
  background-image: url("/assets/covers/cover-orange-e6f7b90d.png");
}

.ebook__cover-placeholder.theme--violet {
  background-image: url("/assets/covers/cover-violet-7a1433e8.png");
}

.ebook__cover-placeholder.theme--white {
  background: url("/assets/covers/cover-white-a033e48d.png") no-repeat center;
  background-size: cover;
  color: var(--color-ink);
}

.ebook__hero-details {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ebook__meta {
  margin-bottom: 2rem;
}

.ebook__title {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.5rem;
  color: var(--color-ink);
}

.ebook__subtitle {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  color: var(--color-ink);
  opacity: 0.8;
  margin: 0 0 0.5rem;
}

.ebook__author {
  font-size: 1.1rem;
  color: var(--color-ink);
  opacity: 0.7;
  margin: 0;
}

.ebook__start-reading-section {
  margin: 2rem 0 1.5rem;
  text-align: left;
}

.ebook__start-reading {
  min-width: 220px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 1rem 2rem;
}

.ebook__actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  
  .btn {
    min-width: 150px;
  }
}

.ebook__toc {
  margin-top: 2rem;
}

.ebook__toc-collapsible {
  border: 1px solid var(--color-subtle-dark);
  border-radius: 1.25rem;
  padding: 0;
  background: var(--color-bg);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.ebook__toc-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem 1.75rem;
  cursor: pointer;
}

.ebook__toc-summary::-webkit-details-marker {
  display: none;
}

.ebook__toc-summary-text {
  flex: 1;
  min-width: 0;
}

.ebook__toc-summary-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.ebook__toc-summary-toggle {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid var(--color-subtle-dark);
  display: grid;
  place-items: center;
  position: relative;
}

.ebook__toc-summary-toggle::before,
.ebook__toc-summary-toggle::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 2px;
  background: var(--color-ink);
  transition: transform 0.2s ease;
}

.ebook__toc-summary-toggle::after {
  transform: rotate(90deg);
}

.ebook__toc-collapsible[open] .ebook__toc-summary-toggle::after {
  transform: rotate(0deg);
}

.ebook__toc-content {
  padding: 0 1.75rem 1.75rem;
}

.ebook__toc-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.75rem;
  opacity: 0.6;
  margin: 0 0 0.2rem;
}

.ebook__toc-subtitle {
  margin: 0.2rem 0 0;
  color: var(--color-ink);
  opacity: 0.7;
  font-size: 0.95rem;
}

.ebook__toc-list {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.ebook__toc-item {
  height: 100%;
}

.ebook__toc-link {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1.25rem 1.35rem;
  border-radius: 1rem;
  border: 1px solid var(--color-subtle-dark);
  background: var(--color-bg);
  text-decoration: none;
  color: var(--color-ink);
  height: 100%;
  position: relative;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.ebook__toc-link:hover {
  border-color: var(--color-link);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.07);
}

.ebook__toc-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ebook__toc-pill {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--color-subtle-dark);
}

.ebook__toc-page {
  opacity: 0.6;
}

.ebook__toc-item-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.ebook__toc-item-desc {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.75;
  line-height: 1.5;
}

.ebook__toc-item-arrow {
  position: absolute;
  right: 1.35rem;
  bottom: 1.25rem;
  opacity: 0.5;
}

.ebook__empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-ink);
  opacity: 0.6;
  
  img {
    margin-bottom: 1rem;
    opacity: 0.5;
  }
  
  p {
    font-size: 1.1rem;
    margin: 0;
  }
}

.ebook__footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem var(--ebook-padding);
  border-top: 1px solid var(--color-subtle-dark);
  background: var(--color-bg);
}

.ebook__footer-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.875rem;
  color: color-mix(in srgb, var(--color-ink) 70%, transparent);
}

.ebook__footer-text {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.ebook__footer-text strong {
  font-weight: 600;
  color: var(--color-ink);
}

.ebook__footer-link {
  color: var(--color-link);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 200ms ease;
}

.ebook__footer-link:hover {
  opacity: 0.7;
  text-decoration: underline;
}

.ebook__footer-divider {
  color: color-mix(in srgb, var(--color-ink) 40%, transparent);
}

.ebook__start-reading {
  min-width: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

/* Footer Navigation for Reading Pages */
.ebook__footer-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem var(--ebook-padding);
  border-top: 1px solid var(--color-subtle-dark);
  background: var(--color-bg);
  gap: 1rem;
}

.ebook__footer-nav-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.ebook__footer-nav-group:first-child {
  justify-content: flex-start;
}

.ebook__footer-nav-group:last-child {
  justify-content: flex-end;
}

.ebook__footer-nav-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ebook__footer-nav .btn {
  max-width: 100%;
  min-width: 0;
  justify-content: space-between;
}

.ebook__footer-nav .btn .overflow-ellipsis {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
}

/* TOC Styles for Ebook Layout */
.ebook .toc {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.ebook .toc__container:where(:has(#toc-list:checked)) .toc {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ebook .toc__leaf {
  border: 1px solid var(--color-subtle-dark);
  border-radius: 0.5rem;
  padding: 1rem;
  transition: all 0.2s ease;
  background: var(--color-bg);
  
  &:hover {
    border-color: var(--color-link);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  }
}

.ebook .toc__title {
  font-weight: 500;
  color: var(--color-ink);
  text-decoration: none;
  display: block;
  margin-top: 0.5rem;
}

.ebook .toc__thumbnail {
  aspect-ratio: 2 / 3;
  border-radius: 0.25rem;
  overflow: hidden;
  margin-bottom: 0.75rem;
  background: var(--color-subtle-dark);
}

/* Responsive */
@media (max-width: 768px) {
  .ebook {
    --ebook-padding: 1rem;
  }
  
  .ebook__header {
    padding: 0.75rem 1rem;
  }
  
  .ebook__header-title {
    font-size: 0.9rem;
  }
  
  .ebook__hero-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }
  
  .ebook__hero-details {
    text-align: center;
    align-items: center;
  }
  
  .ebook__actions {
    justify-content: center;
  }
  
  .ebook__start-reading {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .ebook__footer-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .ebook__footer-nav-group,
  .ebook__footer-nav-center {
    width: 100%;
    justify-content: stretch;
  }

  .ebook__footer-nav-center {
    order: -1;
    margin-bottom: 0.5rem;
    justify-content: center;
  }

  .ebook__footer-nav .btn {
    width: 100%;
  }

  .ebook__footer-nav-group:first-child,
  .ebook__footer-nav-group:last-child {
    justify-content: stretch;
  }
}

/* Hash highlight for ebook layout */
.ebook .hash-highlight {
  animation: hash-highlight 2s ease-out;
  outline: 2px solid var(--color-link);
  outline-offset: 0.5em;
  border-radius: 0.5rem;
  background-color: rgba(var(--color-link-rgb, 0, 0, 0), 0.1);
}

@keyframes hash-highlight {
  0% {
    outline-color: var(--color-link);
    outline-width: 3px;
    background-color: color-mix(in srgb, var(--color-link) 20%, transparent);
  }
  100% {
    outline-color: transparent;
    outline-width: 0;
    background-color: transparent;
  }
}
