/* TỨ PHỦ — Digital Manuscript Reading Room */

.dr-hero {
  position: relative;
  overflow: hidden;
}

.dr-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 45% at 8% 20%, rgba(196, 154, 89, 0.12), transparent 55%),
    radial-gradient(ellipse 40% 40% at 95% 80%, rgba(116, 43, 50, 0.18), transparent 50%);
  pointer-events: none;
}

.dr-cover {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 0.5rem;
  border: 1px solid rgba(196, 154, 89, 0.4);
  background: #352326;
  margin-inline: auto;
}

@media (min-width: 768px) {
  .dr-cover {
    margin-inline: 0;
  }
}

.dr-meta-grid {
  display: grid;
  gap: 0.65rem 1.25rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .dr-meta-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.dr-meta-grid dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #d5ba99;
}

.dr-meta-grid dd {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  color: #f4e6d1;
}

.dr-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  border: 1px solid rgba(98, 68, 60, 0.55);
  padding: 0.15rem 0.55rem;
  font-size: 0.7rem;
  color: #d5ba99;
}

.dr-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.5rem;
  border-radius: 0.65rem;
  border: 1px solid rgba(98, 68, 60, 0.55);
  background: rgba(53, 35, 38, 0.9);
  color: #f4e6d1;
  padding: 0.45rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 500;
}

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

.dr-btn:disabled,
.dr-btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

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

.dr-btn.is-primary:hover,
.dr-btn.is-primary:focus-visible {
  background: #913c43;
}

.dr-btn.is-active {
  border-color: #c49a59;
  color: #e4c58c;
}

.dr-btn.is-icon {
  width: 2.5rem;
  padding: 0;
}

.dr-paper {
  border-radius: 0.85rem;
  border: 1px solid rgba(98, 68, 60, 0.28);
  background: #f5ebdd;
  color: #33241f;
  padding: 1.25rem;
}

.dr-empty {
  border-radius: 0.85rem;
  border: 1px dashed rgba(98, 68, 60, 0.55);
  background: rgba(42, 26, 28, 0.55);
  padding: 1.5rem 1.1rem;
  text-align: center;
}

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

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

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

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

.dr-card:hover,
.dr-card:focus-within {
  border-color: #c49a59;
}

.dr-card a {
  color: inherit;
  text-decoration: none;
}

/* Reader shell */
.dr-reader {
  border-radius: 0.85rem;
  border: 1px solid rgba(98, 68, 60, 0.55);
  background: rgba(42, 26, 28, 0.92);
  overflow: hidden;
}

.dr-reader.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 80;
  border-radius: 0;
  border: 0;
  background: #190f12;
}

.dr-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  border-bottom: 1px solid rgba(98, 68, 60, 0.5);
  background: rgba(53, 35, 38, 0.95);
  padding: 0.5rem 0.65rem;
}

.dr-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.dr-toolbar-sep {
  width: 1px;
  height: 1.4rem;
  background: rgba(98, 68, 60, 0.55);
  margin: 0 0.2rem;
}

.dr-page-label {
  min-width: 5.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: #d5ba99;
}

.dr-page-input {
  width: 3.2rem;
  border-radius: 0.4rem;
  border: 1px solid rgba(98, 68, 60, 0.55);
  background: #2a1a1c;
  color: #f4e6d1;
  padding: 0.25rem 0.35rem;
  text-align: center;
  font-size: 0.8rem;
}

.dr-workspace {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 420px;
}

@media (min-width: 1024px) {
  .dr-workspace {
    grid-template-columns: 220px minmax(0, 1fr) 240px;
    min-height: 560px;
  }

  .dr-workspace.is-toc-hidden {
    grid-template-columns: minmax(0, 1fr) 240px;
  }

  .dr-workspace.is-notes-hidden {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .dr-workspace.is-toc-hidden.is-notes-hidden {
    grid-template-columns: minmax(0, 1fr);
  }
}

.dr-side {
  display: none;
  border-right: 1px solid rgba(98, 68, 60, 0.45);
  background: rgba(25, 15, 18, 0.45);
  overflow: auto;
  max-height: min(70vh, 640px);
}

.dr-side-notes {
  border-right: 0;
  border-left: 1px solid rgba(98, 68, 60, 0.45);
}

@media (min-width: 1024px) {
  .dr-workspace:not(.is-toc-hidden) .dr-side-toc {
    display: block;
  }

  .dr-workspace:not(.is-notes-hidden) .dr-side-notes {
    display: block;
  }
}

.dr-side-inner {
  padding: 0.85rem;
}

.dr-stage {
  position: relative;
  min-height: 360px;
  background:
    linear-gradient(180deg, rgba(245, 235, 221, 0.04), transparent 40%),
    #241618;
  overflow: auto;
}

.dr-stage-inner {
  padding: 1rem;
  min-height: 100%;
}

.dr-nav-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-top: 1px solid rgba(98, 68, 60, 0.5);
  background: rgba(53, 35, 38, 0.95);
  padding: 0.55rem 0.75rem;
}

.dr-toc-list,
.dr-thumb-list,
.dr-note-list,
.dr-search-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dr-toc-item,
.dr-thumb-item,
.dr-note-item,
.dr-search-item {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: 0.45rem;
  border: 0;
  background: transparent;
  color: #d5ba99;
  padding: 0.45rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.dr-toc-item:hover,
.dr-thumb-item:hover,
.dr-note-item:hover,
.dr-search-item:hover,
.dr-toc-item.is-active,
.dr-thumb-item.is-active {
  background: rgba(116, 43, 50, 0.35);
  color: #f4e6d1;
}

.dr-toc-item[data-level="2"] {
  padding-left: 1rem;
}

.dr-toc-item[data-level="3"] {
  padding-left: 1.5rem;
}

.dr-thumb {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 0.35rem;
  border: 1px solid rgba(98, 68, 60, 0.45);
  background: #352326;
}

.dr-manuscript-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  overflow: auto;
  touch-action: pan-x pan-y;
}

.dr-manuscript-img {
  max-width: 100%;
  height: auto;
  transform-origin: center center;
  transition: transform 0.15s ease;
  user-select: none;
}

.dr-pdf-frame {
  width: 100%;
  min-height: 480px;
  border: 0;
  background: #1a1214;
}

.dr-pdf-canvas-wrap {
  display: flex;
  justify-content: center;
  padding: 0.75rem;
  overflow: auto;
}

.dr-pdf-canvas-wrap canvas {
  max-width: 100%;
  height: auto;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.dr-text-shell {
  margin: 0 auto;
  border-radius: 0.5rem;
  padding: 1.25rem 1.1rem;
  line-height: 1.75;
}

.dr-text-shell[data-reader-theme="paper"] {
  background: #f5ebdd;
  color: #33241f;
}

.dr-text-shell[data-reader-theme="light"] {
  background: #faf7f2;
  color: #2a211c;
}

.dr-text-shell[data-reader-theme="dark"] {
  background: #1f1517;
  color: #f4e6d1;
}

.dr-text-shell[data-reader-font="sm"] {
  font-size: 0.95rem;
}

.dr-text-shell[data-reader-font="md"] {
  font-size: 1.05rem;
}

.dr-text-shell[data-reader-font="lg"] {
  font-size: 1.18rem;
}

.dr-text-shell[data-reader-font="xl"] {
  font-size: 1.32rem;
}

.dr-text-shell[data-reader-width="narrow"] {
  max-width: 36rem;
}

.dr-text-shell[data-reader-width="standard"] {
  max-width: 42rem;
}

.dr-text-shell[data-reader-width="wide"] {
  max-width: 54rem;
}

.dr-mark {
  background: rgba(196, 154, 89, 0.45);
  color: inherit;
  border-radius: 0.15rem;
  padding: 0 0.1rem;
}

.dr-parallel {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
  .dr-parallel.is-split {
    grid-template-columns: 1fr 1fr;
  }

  .dr-parallel.is-triple {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.dr-parallel-pane {
  border-radius: 0.65rem;
  border: 1px solid rgba(98, 68, 60, 0.4);
  background: rgba(245, 235, 221, 0.96);
  color: #33241f;
  min-height: 240px;
  overflow: auto;
}

.dr-parallel-pane-head {
  border-bottom: 1px solid rgba(98, 68, 60, 0.28);
  padding: 0.55rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(51, 36, 31, 0.7);
}

.dr-parallel-pane-body {
  padding: 0.85rem 0.75rem;
  font-size: 0.92rem;
  line-height: 1.7;
}

.dr-tabs {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.dr-cite-box {
  border-radius: 0.65rem;
  border: 1px solid rgba(98, 68, 60, 0.28);
  background: rgba(255, 255, 255, 0.45);
  padding: 0.85rem;
  font-size: 0.9rem;
  color: #33241f;
  white-space: pre-wrap;
}

.dr-cite-warn {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: rgba(116, 43, 50, 0.95);
}

.dr-drawer {
  position: fixed;
  inset: 0;
  z-index: 75;
  pointer-events: none;
}

.dr-drawer.is-open {
  pointer-events: auto;
}

.dr-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(25, 15, 18, 0.72);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.dr-drawer.is-open .dr-drawer-overlay {
  opacity: 1;
}

.dr-drawer-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(100%, 320px);
  transform: translateX(-105%);
  background: #2a1a1c;
  border-right: 1px solid rgba(98, 68, 60, 0.55);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}

.dr-drawer.is-notes .dr-drawer-panel {
  left: auto;
  right: 0;
  transform: translateX(105%);
  border-right: 0;
  border-left: 1px solid rgba(98, 68, 60, 0.55);
}

.dr-drawer.is-open .dr-drawer-panel {
  transform: translateX(0);
}

.dr-drawer.is-sheet .dr-drawer-panel {
  top: auto;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-height: min(70vh, 520px);
  transform: translateY(105%);
  border-radius: 1rem 1rem 0 0;
  border: 1px solid rgba(98, 68, 60, 0.55);
}

.dr-drawer.is-sheet.is-open .dr-drawer-panel {
  transform: translateY(0);
}

.dr-drawer-body {
  overflow: auto;
  flex: 1;
  padding: 0.85rem;
}

.dr-search-panel {
  border-bottom: 1px solid rgba(98, 68, 60, 0.45);
  padding: 0.65rem 0.75rem;
  display: none;
}

.dr-search-panel.is-open {
  display: block;
}

.dr-search-input {
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid rgba(98, 68, 60, 0.55);
  background: #190f12;
  color: #f4e6d1;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
}

.dr-search-input:focus {
  outline: none;
  border-color: #c49a59;
}

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

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

.dr-not-found {
  min-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (prefers-reduced-motion: reduce) {
  .dr-manuscript-img,
  .dr-drawer-overlay,
  .dr-drawer-panel,
  .dr-toast {
    transition: none;
  }
}

@media (max-width: 1023px) {
  .dr-toolbar .dr-toolbar-sep {
    display: none;
  }

  .dr-btn.is-desktop-only {
    display: none;
  }
}
