body:has(.realm-gallery) {
  animation: none;
}

body:has(.realm-gallery) .workroom-bar {
  background: #211921;
}

body:has(.realm-gallery) .workroom-bar__crumbs :is(.crumb-sep, .crumb-current) {
  color: #e1c8b5;
}

body:has(.realm-gallery) .drawer-tabs {
  background: #30232b;
  border-color: #896747;
}

body:has(.realm-gallery) .drawer-tabs__link {
  color: #e7d4c8;
}

body:has(.realm-gallery) .drawer-tabs__link.is-active {
  color: #f0c68d;
  border-bottom-color: #c79c67;
}

.realm-gallery {
  --realm-paper: #f1e6d4;
  --realm-panel: #fbf3e6;
  --realm-text: #372836;
  --realm-muted: #684f46;
  --realm-rule: #a78158;
  --realm-plum: #332531;
  --realm-cream: #fff1de;
  --realm-brass: #f0c68d;
  background: var(--realm-paper);
  color: var(--realm-text);
}

[data-theme="dark"] .realm-gallery {
  --realm-paper: #261d26;
  --realm-panel: #372932;
  --realm-text: #fff1de;
  --realm-muted: #e2c5ad;
  --realm-rule: #9d7959;
}

.realm-gallery__wrap {
  width: min(calc(100% - 2 * clamp(1rem, 4vw, 3rem)), 75rem);
  margin-inline: auto;
}

.realm-gallery__hero {
  position: relative;
  isolation: isolate;
  background: #322126;
  color: var(--realm-cream);
  border-bottom: 1px solid var(--realm-rule);
}

.realm-gallery__hero::before {
  content: "";
  position: absolute;
  inset: 0 0 0 43%;
  z-index: -1;
  background: linear-gradient(90deg, #322126, #32212613 48%, transparent),
    url("../images/library/realmwalker-split-crest.jpg") right 48% / cover no-repeat;
}

.realm-gallery__hero-inner {
  padding-block: clamp(1.75rem, 4.5vw, 4rem);
}

.realm-gallery__back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  color: var(--realm-brass);
  font-size: 0.9rem;
}

.realm-gallery__back:hover { color: var(--realm-cream); }

.realm-gallery__game {
  margin: 1rem 0 0.55rem;
  color: var(--realm-brass);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.83rem;
  font-weight: 650;
}

.realm-gallery__hero h1 {
  margin: 0;
  max-width: 18ch;
  color: inherit;
  font: 500 clamp(2.75rem, 5.85vw, 5.4rem)/0.99 var(--font-heading);
  overflow-wrap: anywhere;
}

.realm-gallery__intro {
  max-width: 29rem;
  margin: 0.85rem 0 0;
  color: #e8cdb8;
  font: italic 1.15rem/1.5 var(--font-heading);
}

.realm-gallery__links,
.realm-gallery__numbers,
.realm-gallery__raid-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.9rem;
}

.realm-gallery__links { margin-top: 1.4rem; }
.realm-gallery__links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--realm-rule);
  border-radius: 0.25rem;
  background: #2e212ad9;
  color: var(--realm-cream);
}

.realm-gallery__links a:hover { color: var(--realm-brass); }

.realm-gallery__section {
  padding-block: clamp(1.4rem, 3vw, 2.45rem);
  border-bottom: 1px solid #a7815866;
  scroll-margin-top: 1rem;
}

.realm-gallery__section h2 {
  margin: 0 0 0.7rem;
  color: var(--realm-text);
  font: 500 clamp(1.9rem, 3vw, 2.8rem)/1.13 var(--font-heading);
}

.realm-gallery__heading { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 0 1rem; }
.realm-gallery__numbers { margin: 0 0 0.7rem; color: var(--realm-muted); font-size: 0.85rem; }
.realm-gallery__numbers strong { color: var(--realm-text); }

.realm-gallery .wow-hero {
  background: transparent;
  padding: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.65rem, 2vw, 1.4rem);
}

.realm-gallery .wow-hero__slot {
  min-width: 0;
  min-height: 6.25rem;
  background: var(--realm-plum);
  border: 1px solid var(--realm-rule);
  border-radius: 0.35rem;
  box-shadow: 0 0.35rem 1rem #2a1a231c;
  color: var(--realm-cream);
  padding: 0.85rem 1rem;
  overflow-wrap: anywhere;
}

.realm-gallery__portrait {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--realm-plum);
  background: color-mix(in srgb, var(--realm-plum) 76%, var(--portrait-class));
  color: var(--realm-cream);
  font: 500 1.65rem/1 var(--font-heading);
}

.realm-gallery__portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.realm-gallery .wow-hero__portrait {
  flex: 0 0 auto;
  border-color: var(--realm-rule);
}

.realm-gallery .wow-hero__label { color: var(--realm-brass); }
.realm-gallery .wow-hero__name { color: var(--realm-cream); font: 500 1.35rem/1.15 var(--font-heading); }
.realm-gallery .wow-hero__meta,
.realm-gallery .wow-hero__empty { color: #e8cdb8; }
.realm-gallery .wow-hero__slot:hover .wow-hero__name { color: var(--realm-brass); }

.realm-gallery__roster .filter-pills { padding: 0.3rem 0 1.15rem; }
.realm-gallery__roster :is(.filter-pill, select, input[type="search"]),
.realm-gallery__raid-filter select {
  min-height: 2.6rem;
  max-width: 100%;
  border: 1px solid var(--realm-rule);
  border-radius: 0.3rem;
  background: var(--realm-panel);
  color: var(--realm-text);
  font: inherit;
  font-size: 0.85rem;
}

.realm-gallery__roster .filter-pill { display: inline-flex; align-items: center; }
.realm-gallery__roster :is(select, input[type="search"]),
.realm-gallery__raid-filter select { padding: 0.4rem 0.65rem; }
.realm-gallery__roster .filter-pill:is(:hover, .is-active) {
  background: var(--realm-plum);
  color: var(--realm-cream);
  transform: none;
  box-shadow: none;
}

.realm-gallery__roster .filter-pills__search { gap: 0.35rem; max-width: 100%; }
.realm-gallery__roster input[type="search"] { flex: 1 1 10rem; width: 10rem; min-width: 0; }
.realm-gallery__roster .filter-pills__search button { min-height: 2.6rem; border-radius: 0.3rem; }
.realm-gallery__roster .filter-pills__count { color: var(--realm-muted); }

.realm-gallery__roster .grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.75rem, 2vw, 1.4rem);
  animation: none;
}

.realm-gallery__roster .grid > * { animation: none; }
.realm-gallery__roster .realm-gallery__portrait {
  aspect-ratio: 4 / 3;
  font-size: 3.25rem;
}

.realm-gallery__roster .card {
  border-color: var(--realm-rule);
  border-radius: 0.4rem;
  background: var(--realm-plum);
  color: var(--realm-cream);
}

.realm-gallery__roster .card__body { background: var(--realm-plum); }
.realm-gallery__roster .card__title { color: var(--realm-cream); font: 500 1.3rem/1.18 var(--font-heading); }
.realm-gallery__roster .card:hover .card__title { color: var(--realm-brass); }
.realm-gallery__roster .card__meta { color: #e8cdb8; }
.realm-gallery__roster .tag { background: #261c25; border: 1px solid #88654b; color: #efd1a9; }

.realm-gallery .stat-charts { gap: 0.9rem; padding: 0; }
.realm-gallery .stat-card { border: 1px solid var(--realm-rule); border-radius: 0.35rem; background: var(--realm-panel); }
.realm-gallery :is(.stat-card__title, .donut-chart__number, .role-bar__count) { color: var(--realm-text); }
.realm-gallery :is(.donut-chart__label, .role-bar__label) { color: var(--realm-muted); }
.realm-gallery .donut-chart__hole { background: var(--realm-panel); }

.realm-gallery .raid-progress { margin: 0; }
.realm-gallery .raid-progress__header { gap: 0.65rem 1rem; margin-bottom: 1.15rem; }
.realm-gallery .raid-progress__header h2 { margin: 0; }
.realm-gallery .raid-progress__header .card__meta { color: var(--realm-muted); }
.realm-gallery__raid-filter { justify-content: start; }
.realm-gallery .raid-card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(0.75rem, 2vw, 1.4rem); }
.realm-gallery .raid-card { border: 1px solid var(--realm-rule); border-radius: 0.35rem; background: #2a2028; }
.realm-gallery .raid-card__title { color: var(--realm-cream); font: 500 1.25rem/1.15 var(--font-heading); }
.realm-gallery .raid-card__level { color: #e8cdb8; }
.realm-gallery .raid-card__banner {
  position: relative;
  border-bottom: 1px solid #8b6549;
  background-image: linear-gradient(140deg, #624139, #34242e 70%, #271b22);
}

.realm-gallery .raid-card__banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 40%, #33202784);
}

.realm-gallery .raid-card__row {
  display: grid;
  grid-template-columns: 3.55rem minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  min-height: 1.2rem;
}

.realm-gallery .raid-card__label {
  margin: 0;
  color: var(--realm-brass);
}

.realm-gallery .raid-card__track {
  height: 0.48rem;
  margin-right: 2.4rem;
  border-radius: 1rem;
  outline: 1px solid #786051;
  background: #1b141b;
  overflow: visible;
}

.realm-gallery .raid-card__fill { border-radius: inherit; }
.realm-gallery .raid-card__fill--is-complete { background: linear-gradient(90deg, #ad814e, #efc58a); }
.realm-gallery .raid-card__fill--is-progress { background: linear-gradient(90deg, #854f60, #c88278); }

.realm-gallery .raid-card__count {
  inset: 50% auto auto calc(100% + 0.45rem);
  transform: translateY(-50%);
  padding: 0;
  color: var(--realm-cream);
  font-variant-numeric: tabular-nums;
  text-shadow: none;
  white-space: nowrap;
}

.realm-gallery :is(a, button, select, input):focus-visible { outline: 2px solid #b67635; outline-offset: 3px; }
.realm-gallery__links a:focus-visible,
.realm-gallery .wow-hero__slot:focus-visible { outline-color: var(--realm-brass); }

@media (max-width: 64rem) {
  .realm-gallery__roster .grid,
  .realm-gallery .raid-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 48rem) {
  body:has(.realm-gallery) .drawer-tabs { flex-wrap: nowrap; overflow-x: auto; padding-inline: 0.5rem; }
  body:has(.realm-gallery) .drawer-tabs__link { flex-shrink: 0; white-space: nowrap; }

  .realm-gallery__hero::before {
    inset: 0;
    background: linear-gradient(90deg, #322126f5 5%, #322126ac 65%, #32212678),
      url("../images/library/realmwalker-split-crest.jpg") center 47% / cover no-repeat;
  }

  .realm-gallery .wow-hero { grid-template-columns: 1fr; }
  .realm-gallery .wow-hero__slot { min-height: 5.1rem; }
  .realm-gallery__roster .grid,
  .realm-gallery .raid-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 32rem) {
  .realm-gallery__roster .grid,
  .realm-gallery .raid-card-grid { grid-template-columns: minmax(0, 1fr); }
  .realm-gallery__roster .filter-pills__count { margin-left: 0; }
  .realm-gallery__roster .filter-pills__search { width: min(100%, 19rem); }
}

@media (prefers-reduced-motion: reduce) {
  .realm-gallery :is(.wow-hero__slot, .card, .card__image, .role-bar__fill, .raid-card__fill) { transition: none; }
}
