/* TỨ PHỦ — Excerpt detail / manuscript reading room */

.ed-layout {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 1100px) {
  .ed-layout {
    grid-template-columns: 210px minmax(0, 1fr);
    align-items: start;
  }
}

.ed-toc {
  display: none;
}

@media (min-width: 1100px) {
  .ed-toc {
    display: block;
    position: sticky;
    top: calc(var(--header-h, 64px) + 1rem);
    border-radius: 0.85rem;
    border: 1px solid rgba(98, 68, 60, 0.55);
    background: rgba(42, 26, 28, 0.9);
    padding: 1rem;
  }
}

.ed-toc a {
  display: block;
  border-radius: 0.4rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  color: #d5ba99;
  text-decoration: none;
}

.ed-toc a:hover,
.ed-toc a:focus-visible,
.ed-toc a.is-active {
  color: #f4e6d1;
  background: rgba(116, 43, 50, 0.35);
  outline: none;
}

.ed-chip {
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid rgba(196, 154, 89, 0.45);
  padding: 0.12rem 0.55rem;
  font-size: 0.7rem;
  color: #e4c58c;
}

.ed-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.ed-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 2.35rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(98, 68, 60, 0.55);
  background: rgba(53, 35, 38, 0.95);
  color: #f4e6d1;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  text-decoration: none;
}

.ed-btn:hover,
.ed-btn:focus-visible,
.ed-btn.is-active {
  border-color: #c49a59;
  outline: none;
}

.ed-btn.is-primary {
  background: #742b32;
  border-color: transparent;
}

.ed-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.ed-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ed-manuscript-wrap {
  border-radius: 1rem;
  border: 1px solid rgba(98, 68, 60, 0.45);
  background: rgba(42, 26, 28, 0.55);
  padding: 0.85rem;
}

.ed-manuscript {
  border-radius: 0.75rem;
  background: #f5ebdd;
  color: #33241f;
  padding: 1.35rem 1.15rem;
  margin: 0 auto;
  max-width: 48rem;
  box-shadow: inset 0 0 0 1px rgba(98, 68, 60, 0.18);
  transition: max-width 0.2s ease, font-size 0.2s ease;
}

.ed-manuscript.is-narrow {
  max-width: 36rem;
}

.ed-manuscript.is-wide {
  max-width: 56rem;
}

.ed-manuscript.is-dark {
  background: #2a1a1c;
  color: #f4e6d1;
  box-shadow: inset 0 0 0 1px rgba(98, 68, 60, 0.55);
}

body.ed-focus-mode .site-header,
body.ed-focus-mode footer,
body.ed-focus-mode .ed-toc,
body.ed-focus-mode [data-ed-side-panels] {
  display: none !important;
}

body.ed-focus-mode .ed-layout {
  grid-template-columns: 1fr;
}

.ed-quote-mark {
  font-family: "Noto Serif", Georgia, serif;
  font-size: 2rem;
  line-height: 1;
  color: #c49a59;
}

.ed-text {
  font-family: "Noto Serif", Georgia, serif;
  line-height: 1.85;
  white-space: pre-wrap;
}

.ed-layer {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(98, 68, 60, 0.25);
}

.ed-layer-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(51, 36, 31, 0.65);
  margin-bottom: 0.35rem;
}

.ed-manuscript.is-dark .ed-layer-label {
  color: #d5ba99;
}

.ed-anno {
  border: 0;
  background: rgba(196, 154, 89, 0.22);
  color: inherit;
  font: inherit;
  border-radius: 0.2rem;
  padding: 0 0.15rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 0.15em;
}

.ed-card {
  border-radius: 0.85rem;
  border: 1px solid rgba(98, 68, 60, 0.55);
  background: rgba(42, 26, 28, 0.88);
  padding: 1rem;
}

.ed-card-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .ed-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .ed-card-grid.is-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.ed-meta-table {
  width: 100%;
  border-collapse: collapse;
}

.ed-meta-table th,
.ed-meta-table td {
  border-bottom: 1px solid rgba(98, 68, 60, 0.4);
  padding: 0.6rem 0.3rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.875rem;
}

.ed-meta-table th {
  width: 36%;
  color: #e4c58c;
  font-weight: 500;
}

.ed-meta-table td {
  color: #d5ba99;
}

.ed-empty {
  border-radius: 0.85rem;
  border: 1px dashed rgba(98, 68, 60, 0.7);
  background: rgba(42, 26, 28, 0.4);
  padding: 1.25rem;
  text-align: center;
}

.ed-cite {
  white-space: pre-wrap;
  font-size: 0.85rem;
  color: #d5ba99;
  border-radius: 0.65rem;
  border: 1px solid rgba(98, 68, 60, 0.55);
  background: rgba(53, 35, 38, 0.7);
  padding: 0.85rem;
}

.ed-compare {
  display: grid;
  gap: 0.85rem;
}

@media (min-width: 900px) {
  .ed-compare.is-split {
    grid-template-columns: 1fr 1fr;
  }
}

.ed-compare-panel {
  border-radius: 0.75rem;
  border: 1px solid rgba(98, 68, 60, 0.45);
  background: #f5ebdd;
  color: #33241f;
  padding: 0.9rem;
  min-height: 8rem;
}

.ed-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.ed-popover {
  position: absolute;
  z-index: 40;
  max-width: min(92vw, 320px);
  border-radius: 0.65rem;
  border: 1px solid rgba(98, 68, 60, 0.6);
  background: #2a1a1c;
  color: #f4e6d1;
  padding: 0.75rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.ed-toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  z-index: 90;
  transform: translateX(-50%) translateY(120%);
  border-radius: 0.65rem;
  border: 1px solid rgba(98, 68, 60, 0.55);
  background: #2a1a1c;
  color: #f4e6d1;
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.ed-toast.is-open {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.ed-not-found {
  min-height: 50vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem 1rem;
}

.ed-toc-mobile {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: none;
}

.ed-toc-mobile.is-open {
  display: block;
}

.ed-toc-overlay {
  position: absolute;
  inset: 0;
  background: rgba(25, 15, 18, 0.7);
}

.ed-toc-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(100%, 320px);
  overflow: auto;
  border-left: 1px solid rgba(98, 68, 60, 0.6);
  background: #2a1a1c;
  padding: 1rem;
}

@media print {
  .site-header,
  footer,
  .ed-toc,
  .ed-toolbar,
  .ed-actions,
  .ed-toast,
  [data-scroll-top],
  [data-ed-toc-open],
  [data-search-open],
  [data-mobile-toggle] {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  .ed-manuscript {
    box-shadow: none;
    max-width: none !important;
  }

  .ed-layout {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ed-manuscript,
  .ed-toast {
    transition: none;
  }
}
