/* =============================================================================
   Daggerheart SRD – Standalone Rules Compendium Overlay
   Styles scoped under .dh-srd-modal to avoid conflicts with vtt.css on VTT pages.
   Uses the same vtt-rules-* and vtt-items-corner inner class names as the VTT.
   ============================================================================= */

/* ── Loading spinner keyframe ── */
@keyframes dh-srd-spin {
  to { transform: rotate(360deg); }
}

/* ── Outer modal wrapper (full-screen fixed overlay) ── */
.dh-srd-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.dh-srd-modal--hidden {
  display: none !important;
}

/* ── Backdrop ── */
.dh-srd-modal .vtt-rules-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ── Shell / panel ── */
.dh-srd-modal .vtt-rules-shell {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  height: 100%;
  max-width: 82rem;
  max-height: 54rem;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 2.3px solid rgba(234, 179, 8, 0.85);
  background: linear-gradient(165deg, rgb(41 23 73), rgba(24, 11, 46, 0.95));
  box-shadow:
    inset 0 0 0 1px rgba(253, 224, 71, 0.28),
    0 16px 34px rgba(0, 0, 0, 0.42);
}

/* Children inside ornate panel should sit above corners */
.dh-srd-modal .vtt-env-ornate-panel > *:not(.vtt-items-corner) {
  position: relative;
  z-index: 2;
}

/* ── Corner images ── */
.dh-srd-modal .vtt-items-corner {
  position: absolute;
  top: 0.15rem;
  width: 9em;
  height: 9em;
  object-fit: contain;
  z-index: 3;
  pointer-events: none;
}

.dh-srd-modal .vtt-items-corner-left {
  left: 0.05rem;
}

.dh-srd-modal .vtt-items-corner-right {
  right: 0.05rem;
  transform: scaleX(-1);
}

.dh-srd-modal .vtt-rules-corner {
  width: 12em;
  height: 12em;
  opacity: 0.85;
  z-index: 4;
}

/* ── Sidebar ── */
.dh-srd-modal .vtt-rules-sidebar {
  display: flex;
  flex-direction: column;
  width: 18rem;
  min-width: 18rem;
  background: linear-gradient(170deg, rgba(30, 16, 56, 0.98), rgba(18, 9, 36, 0.96));
  border-right: 1px solid rgba(234, 179, 8, 0.18);
}

.dh-srd-modal .vtt-rules-sidebar-head {
  padding: 1rem 0.85rem 0.65rem;
  border-bottom: 1px solid rgba(234, 179, 8, 0.14);
}

.dh-srd-modal .vtt-rules-sidebar-title {
  font-family: 'Eveleth', serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(253, 230, 138, 0.92);
  margin-bottom: 0.6rem;
  padding-left: 3rem;
}

.dh-srd-modal .vtt-rules-search-wrap {
  position: relative;
  padding-left: 2rem;
}

.dh-srd-modal .vtt-rules-search-icon {
  position: absolute;
  left: 2.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.9rem;
  height: 0.9rem;
  color: rgba(180, 160, 220, 0.5);
  pointer-events: none;
}

.dh-srd-modal .vtt-rules-search {
  width: 100%;
  height: 2rem;
  padding: 0 0.55rem 0 2rem;
  border: 1px solid rgba(234, 179, 8, 0.22);
  border-radius: 0.3rem;
  background: rgba(0, 0, 0, 0.35);
  color: rgba(250, 240, 210, 0.92);
  font-size: 12px;
  outline: none;
  transition: border-color 140ms ease;
  -webkit-appearance: none;
}

.dh-srd-modal .vtt-rules-search::placeholder {
  color: rgba(180, 160, 220, 0.4);
}

.dh-srd-modal .vtt-rules-search:focus {
  border-color: rgba(234, 179, 8, 0.5);
}

/* Remove native search cancel button */
.dh-srd-modal .vtt-rules-search::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* ── Sidebar list ── */
.dh-srd-modal .vtt-rules-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(234, 179, 8, 0.2) transparent;
}

.dh-srd-modal .vtt-rules-category {
  margin-bottom: 0.15rem;
}

.dh-srd-modal .vtt-rules-category-head {
  display: flex;
  align-items: center;
  gap: 0.285rem;
  padding: 0.4rem 0.85rem;
  font-family: 'Eveleth', serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(200, 180, 230, 0.65);
  cursor: pointer;
  user-select: none;
  transition: color 120ms ease;
}

.dh-srd-modal .vtt-rules-category-head:hover {
  color: rgba(253, 224, 71, 0.9);
}

.dh-srd-modal .vtt-rules-category-chevron {
  width: 0.85rem;
  height: 0.85rem;
  transition: transform 180ms ease;
  flex-shrink: 0;
}

.dh-srd-modal .vtt-rules-category.is-collapsed .vtt-rules-category-chevron {
  transform: rotate(-90deg);
}

.dh-srd-modal .vtt-rules-category-entries {
  overflow: hidden;
}

.dh-srd-modal .vtt-rules-category.is-collapsed .vtt-rules-category-entries {
  display: none;
}

.dh-srd-modal .vtt-rules-entry {
  display: block;
  width: 100%;
  padding: 0.3rem 0.85rem 0.3rem 1.5rem;
  background: none;
  border: none;
  text-align: left;
  font-size: 13px;
  color: rgba(210, 200, 230, 0.68);
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dh-srd-modal .vtt-rules-entry:hover {
  background: rgba(234, 179, 8, 0.08);
  color: rgba(253, 224, 71, 0.95);
}

.dh-srd-modal .vtt-rules-entry.is-active {
  background: rgba(234, 179, 8, 0.14);
  color: rgba(253, 224, 71, 1);
  font-weight: 600;
}

/* ── Content area ── */
.dh-srd-modal .vtt-rules-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: linear-gradient(170deg, rgba(36, 20, 64, 0.97), rgba(22, 10, 42, 0.95));
}

.dh-srd-modal .vtt-rules-content-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  padding-right: 4.2rem;
  border-bottom: 1px solid rgba(234, 179, 8, 0.14);
  min-height: 2.75rem;
}

.dh-srd-modal .vtt-rules-breadcrumb {
  font-size: 11px;
  color: rgba(180, 160, 220, 0.55);
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dh-srd-modal .vtt-rules-breadcrumb span {
  color: rgba(253, 224, 71, 0.85);
}

.dh-srd-modal .vtt-rules-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.25rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
  color: rgba(220, 200, 160, 0.7);
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
  flex-shrink: 0;
}

.dh-srd-modal .vtt-rules-close svg {
  width: 0.85rem;
  height: 0.85rem;
}

.dh-srd-modal .vtt-rules-close:hover {
  border-color: rgba(234, 179, 8, 0.5);
  color: rgba(253, 224, 71, 0.95);
  background: rgba(234, 179, 8, 0.1);
}

/* ── Content body ── */
.dh-srd-modal .vtt-rules-body {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem 2.25rem 3rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(234, 179, 8, 0.18) transparent;
}

/* Welcome state */
.dh-srd-modal .vtt-rules-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: rgba(180, 160, 220, 0.45);
}

.dh-srd-modal .vtt-rules-welcome p {
  font-size: 12px;
  max-width: 24rem;
  line-height: 1.6;
}

/* Loading state */
.dh-srd-modal .vtt-rules-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: rgba(180, 160, 220, 0.45);
  font-size: 12px;
  gap: 0.5rem;
}

.dh-srd-modal .vtt-rules-loading::before {
  content: '';
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(234, 179, 8, 0.2);
  border-top-color: rgba(234, 179, 8, 0.7);
  border-radius: 50%;
  animation: dh-srd-spin 0.7s linear infinite;
}

/* ── Article (rendered markdown) ── */
.dh-srd-modal .vtt-rules-article {
  color: rgba(235, 225, 200, 0.88);
  font-size: 13.5px;
  line-height: 1.72;
  padding-right: 5rem;
}

.dh-srd-modal .vtt-rules-article h1 {
  font-family: 'Eveleth', serif;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(253, 224, 71, 0.95);
  margin: 0 0 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 2px solid rgba(234, 179, 8, 0.25);
}

.dh-srd-modal .vtt-rules-article h2 {
  font-family: 'Eveleth', serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(253, 224, 71, 0.88);
  margin: 1.8rem 0 0.55rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(234, 179, 8, 0.16);
}

.dh-srd-modal .vtt-rules-article h3 {
  font-family: 'Eveleth', serif;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: rgba(253, 224, 71, 0.8);
  margin: 1.4rem 0 0.4rem;
}

.dh-srd-modal .vtt-rules-article h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: rgba(253, 224, 71, 0.72);
  margin: 1.1rem 0 0.3rem;
}

.dh-srd-modal .vtt-rules-article p {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
}

.dh-srd-modal .vtt-rules-article strong {
  color: rgba(253, 224, 71, 0.95);
  font-weight: 700;
}

.dh-srd-modal .vtt-rules-article em {
  color: rgb(205, 156, 35);
  font-style: italic;
}

.dh-srd-modal .vtt-rules-article blockquote {
  margin: 0.85rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid rgba(234, 179, 8, 0.35);
  background: rgba(234, 179, 8, 0.04);
  border-radius: 0 0.3rem 0.3rem 0;
  color: rgba(230, 220, 245, 0.85);
  font-size: 13px;
}

.dh-srd-modal .vtt-rules-article blockquote p:last-child {
  margin-bottom: 0;
}

.dh-srd-modal .vtt-rules-article ul,
.dh-srd-modal .vtt-rules-article ol {
  margin: 0.5rem 0 0.85rem 1.2rem;
  padding: 0;
  list-style: disc;
}

.dh-srd-modal .vtt-rules-article li {
  margin-bottom: 0.3rem;
}

.dh-srd-modal .vtt-rules-article li::marker {
  color: rgba(234, 179, 8, 0.45);
}

.dh-srd-modal .vtt-rules-article a {
  color: rgba(147, 197, 253, 0.92);
  text-decoration: underline;
  text-decoration-color: rgba(147, 197, 253, 0.3);
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color 120ms ease, text-decoration-color 120ms ease;
}

.dh-srd-modal .vtt-rules-article a:hover {
  color: rgba(191, 219, 254, 1);
  text-decoration-color: rgba(147, 197, 253, 0.65);
}

.dh-srd-modal .vtt-rules-article hr {
  border: none;
  border-top: 1px solid rgba(234, 179, 8, 0.15);
  margin: 1.5rem 0;
}

.dh-srd-modal .vtt-rules-article code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  padding: 0.15em 0.35em;
  border-radius: 0.2rem;
  background: rgba(0, 0, 0, 0.3);
  color: rgba(253, 224, 71, 0.85);
}

.dh-srd-modal .vtt-rules-article pre {
  margin: 0.85rem 0;
  padding: 0.85rem 1rem;
  border-radius: 0.35rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow-x: auto;
}

.dh-srd-modal .vtt-rules-article pre code {
  padding: 0;
  background: none;
}

/* Tables */
.dh-srd-modal .vtt-rules-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.85rem 0;
  font-size: 12.5px;
}

.dh-srd-modal .vtt-rules-article thead th {
  padding: 0.45rem 0.65rem;
  font-family: 'Eveleth', serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  color: rgba(253, 224, 71, 0.8);
  border-bottom: 2px solid rgba(234, 179, 8, 0.22);
  background: rgba(0, 0, 0, 0.2);
}

.dh-srd-modal .vtt-rules-article tbody td {
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: top;
}

.dh-srd-modal .vtt-rules-article tbody tr:hover {
  background: rgba(234, 179, 8, 0.04);
}

/* ── Article icon (weapon/adversary/etc.) ── */
.dh-srd-modal .vtt-rules-article-icon-wrap {
  float: right;
  width: 7rem;
  height: 7rem;
  margin: 0 0 0.75rem 1rem;
  border-radius: 1rem;
  overflow: hidden;
  flex-shrink: 0;
}

.dh-srd-modal .vtt-rules-article-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ── Domain banner ── */
.dh-srd-modal .vtt-rules-domain-banner-wrap {
  position: absolute;
  top: -0.1rem;
  right: 1rem;
  width: 6rem;
  height: auto;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

.dh-srd-modal .vtt-rules-domain-banner {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Inline feature icons (class/subclass pages) ── */
.dh-srd-modal .vtt-rules-feature-icon {
  display: inline-block;
  width: 2.4rem;
  height: 2.4rem;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 0.3rem;
  border-radius: 111rem;
  flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .dh-srd-modal {
    padding: 0.75rem;
  }

  .dh-srd-modal .vtt-rules-shell {
    flex-direction: column;
    max-height: 95dvh;
  }

  .dh-srd-modal .vtt-rules-sidebar {
    width: 100%;
    min-width: 0;
    max-height: 14rem;
    border-right: none;
    border-bottom: 1px solid rgba(234, 179, 8, 0.18);
  }

  .dh-srd-modal .vtt-rules-body {
    padding: 1.25rem 1rem 2rem;
  }

  .dh-srd-modal .vtt-rules-corner {
    display: none;
  }
}
