/* Shared metalwork for the RS3 log, its home plaque and the RS3 source ledger. */
body[data-game="rs3"], .door--rs3, .table-wrap[data-game="rs3"] {
  --paper: #090f1c;
  --card: #101a2e;
  --paper-2: #16233d;
  --well: #0c1426;
  --ink: #eef4ff;
  --ink-2: #c8d6ed;
  --muted: #9db0d4;
  --line: #374966;
  --gold: #f4c752;
  --gilt-ink: #ffe28a;
  --lit: #8ae0ff;
  --water: #6ad5ff;
  --water-soft: #193249;
  --red: #ff6e76;
  --red-soft: #361d2c;
  --bezel: inset 0 1px 0 rgb(138 224 255 / .16);
  --alloy: linear-gradient(118deg, var(--paper-2), var(--card) 54%, var(--well));
  --aura: linear-gradient(90deg, var(--line), var(--gold) 35%, var(--gilt-ink) 50%, var(--gold) 65%, var(--line));
  --pendant: conic-gradient(from 45deg, #bb8d36 0 25%, #ffe6a0 25% 50%, #976b20 50% 75%, #ffedbb 75%);
  --pendant-cut: polygon(50% 0, 100% 35%, 82% 70%, 50% 100%, 18% 70%, 0 35%);
  --edit: #8ae0ff;
  --edit-text: #101a2e;
  --edit-ink: #ffe9a8;
  --edit-bg: #302a1c;
  --edit-border: #f4c752;
  --edit-badge-bg: #ffe28a;
  --edit-badge-ink: #261c09;
  --edit-ring: rgb(244 199 82 / .13);
  --edit-glow: rgb(244 199 82 / .18);
}

:root[data-theme="light"] :is(body[data-game="rs3"], .door--rs3, .table-wrap[data-game="rs3"]) {
  --paper: #edf2f8;
  --card: #f8fafd;
  --paper-2: #e4ebf5;
  --well: #dfe7f2;
  --ink: #101a2e;
  --ink-2: #2d405c;
  --muted: #455874;
  --line: #a1b0c5;
  --gold: #9a6f10;
  --gilt-ink: #70500c;
  --lit: #145c8a;
  --water: #145c8a;
  --water-soft: #d4e8f4;
  --red: #a52b40;
  --red-soft: #fbe7eb;
  --bezel: inset 0 1px 0 white;
  --edit-border: #936b18;
  --edit-ink: #533c0c;
  --edit-bg: #fff4ce;
  --edit-ring: rgb(154 111 16 / .13);
  --edit-glow: rgb(154 111 16 / .15);
}

body[data-game="rs3"] {
  min-height: 100vh;
  background: radial-gradient(ellipse 80% 26rem at 0 0, var(--card), transparent) var(--paper);

  & .masthead::before {
    height: 3px;
    background: var(--aura);
  }
  & :is(.topnav a, .theme-picker select, .tool-list a, .edit-dock-hide, .edit-dock-restore) {
    min-height: 44px;
    border-radius: 4px;
  }
  & :is(.topnav a[aria-current], .tab[aria-selected="true"], .entry[aria-current="true"]) {
    background: var(--water-soft);
    color: var(--water);
    box-shadow: inset 0 -2px var(--gold);
  }
  & :is(.pane, .log-head, .guide-ca-links, .edit-dock:not(.is-collapsed)) {
    background: var(--alloy);
    box-shadow: var(--bezel);
    border-radius: 3px 13px;
    corner-shape: bevel;
  }
  & .log-head { position: relative; border-left: 3px solid var(--gold); }
  & .log-head h1 { padding-right: 38px; }
  & .log-head::after {
    content: "";
    position: absolute;
    top: 18px;
    right: 20px;
    width: 19px;
    height: 23px;
    background: var(--pendant);
    clip-path: var(--pendant-cut);
  }
  & .tabs { gap: 3px; border-bottom: 1px solid var(--line); background: var(--well); }
  & .tab { border-radius: 2px 9px 0 0; corner-shape: bevel; }
  & .tab[aria-selected="true"] { border-color: var(--lit); }
  & .tab[aria-selected="true"] .count { opacity: 1; }
  & .tab::after { height: 3px; background: var(--aura); }
  & .detail { min-width: 0; }
  & .entry { border-radius: 2px; }
  & .entry[aria-current="true"] { font-weight: 750; box-shadow: none; }
  & .entry::before { width: 3px; border-radius: 0; background: var(--gold); }
  & .pane-head { border-bottom: 1px solid var(--line); }
  & .pane-head::after { height: 1px; bottom: -1px; background: linear-gradient(90deg, var(--gold), transparent 75%); }
  & .card { background: var(--well); border-radius: 3px; }
  & .card-title { text-decoration-color: var(--muted); }
  & .card-credit { font-size: 15px; }
  & .card-by { color: var(--gilt-ink); }
  & .card-by::before { color: var(--gilt-ink); border-color: currentColor; }
  & .guide-update-age--recent { background: var(--edit); color: var(--edit-text); }
  & .guide-update-age--recent small { color: inherit; }

  /* Frame the source credit like the seal on the collection log. */
  & .billing {
    border: 1px solid var(--gold);
    border-radius: 16px 4px;
    corner-shape: bevel;
    background: var(--alloy);
    box-shadow: inset 0 0 0 3px var(--card), inset 0 0 0 4px var(--line), 0 0 16px var(--edit-ring);
    overflow-wrap: anywhere;
  }
  & .billing::before { height: 2px; background: var(--aura); }
  & .billing-kicker::before {
    content: "";
    display: block;
    margin: 0 auto 12px;
    width: 21px;
    height: 24px;
    background: var(--pendant);
    clip-path: var(--pendant-cut);
  }
  & .billing .billing-kicker, & .billing-org { color: var(--gilt-ink); }
  & .billing .billing-open-source {
    min-height: 44px;
    border-radius: 4px;
    background: var(--water-soft);
    border-color: var(--water);
    color: var(--water);
  }
  & .billing .billing-open-source:hover { text-decoration: underline; }
  & .billing-names { color: var(--ink); }
  & .suggest-edit .edit-icon { box-shadow: 0 0 10px var(--edit-glow); }
  & .guide-ca-links { border-left-color: var(--gold); }
  & .guide-ca-list a { display: inline-flex; align-items: center; min-height: 44px; }
  & .guide-content :is(.embed-rich, details, .admonition, .tabbed-set) {
    border-left: 2px solid var(--lit);
    border-radius: 3px;
  }
  & .guide-content :is(th, pre) { background: var(--well); }
  & .guide-content summary { min-height: 44px; align-content: center; }
}

body[data-game="rs3"] .guide-content img:is(.ability-icon, .d-emoji, .emoji, .twemoji) {
  background: #566b86;
  color: #eef4ff;
  border-radius: 3px;
}

.door--rs3 {
  --cut: polygon(0 0, calc(100% - 30px) 0, 100% 30px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
  color: var(--ink);
  filter: drop-shadow(0 2px 7px var(--edit-glow));

  &::before { inset: 0; clip-path: var(--cut); background: var(--aura); }
  &::after {
    inset: 2px;
    clip-path: var(--cut);
    opacity: 1;
    background: radial-gradient(ellipse at 97% 2%, var(--water-soft), transparent 48%), var(--alloy);
    box-shadow: inset 0 1px 0 var(--lit);
  }
  & .door-slate {
    inset: 16px 21px auto auto;
    width: 27px;
    height: 33px;
    border: 0;
    background: var(--pendant);
    clip-path: var(--pendant-cut);
  }
  & .door-name { margin: 0; padding-right: 32px; }
  & .door-facts { color: var(--muted); }
  & .door-meter { height: 4px; border-radius: 0; background: var(--line); }
  & .door-meter-fill { background: var(--lit); border-radius: 0; }
  & .door-by { padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line); }
  & .door-by-label { color: var(--gilt-ink); }
  & .door-community {
    font-size: 16px;
    border: 1px solid var(--line);
    border-inline-start: 2px solid var(--gold);
    border-radius: 0 4px;
    padding: 2px 8px;
    background: var(--well);
  }
  & .door-go { color: var(--water); }
}

.table-wrap[data-game="rs3"] {
  background: var(--card);
  color: var(--ink);
  border-radius: 3px 12px;
  corner-shape: bevel;
  &::before { height: 2px; background: var(--aura); }
  & th a { display: inline-flex; align-items: center; min-height: 44px; }
  & tbody tr:nth-child(even) { background: var(--well); }
  & .credit-cell { font-weight: 650; color: var(--gilt-ink); }
}

:is(body[data-game="rs3"], .door--rs3, .table-wrap[data-game="rs3"])::selection,
:is(body[data-game="rs3"], .door--rs3, .table-wrap[data-game="rs3"]) ::selection {
  background: var(--water);
  color: var(--paper);
}

@media (prefers-reduced-motion: no-preference) {
  body[data-game="rs3"] :is(.tab, .entry, .suggest-edit), .door--rs3 {
    transition: box-shadow var(--tick) ease-out, transform var(--tick) ease-out;
  }
}

@media screen and (prefers-reduced-motion: no-preference) and (forced-colors: none) {
  :root:not([data-ambient-paused]) {
    & .motion-pointer[data-world="rs3"] {
      width: 20px;
      height: 16px;
      pointer-events: none;
      filter: drop-shadow(0 1px 1px #142333);
    }
    & .motion-pointer[data-world="rs3"] :is(i, b) {
      position: absolute;
      inset: 1px auto auto 0;
      width: 10px;
      height: 13px;
      transform-origin: right 55%;
      clip-path: polygon(100% 47%, 53% 12%, 0 0, 13% 42%, 42% 56%, 15% 58%, 33% 88%, 57% 99%, 100% 62%);
      background: conic-gradient(from 250deg at 100% 54%, #e8fff4 0 23deg, #5c928a 24deg 48deg, #cfe5a1 49deg 82deg, #537b76 83deg);
      animation: rs3-companion-fold 2.4s ease-in-out infinite;
    }
    & .motion-pointer[data-world="rs3"] b { scale: -1 1; }
    & .motion-pointer[data-world="rs3"]::after {
      content: "";
      position: absolute;
      inset: 5px auto auto 9px;
      width: 2px;
      height: 8px;
      background: #e8bf68;
      border-radius: 50%;
    }
    & .door--rs3 .door-slate { z-index: 1; }
    & .door--rs3 .door-name::after {
      content: "";
      pointer-events: none;
      position: absolute;
      top: 16px;
      right: 10px;
      width: 49px;
      height: 29px;
      background: conic-gradient(from 24deg at 50% 60%, var(--water), var(--line) 23%, var(--gold) 48%, var(--line) 69%, var(--water));
      clip-path: polygon(0 0, 27% 13%, 50% 58%, 73% 13%, 100% 0, 91% 46%, 75% 57%, 86% 60%, 72% 90%, 50% 70%, 28% 90%, 14% 60%, 25% 57%, 9% 46%);
      animation: rs3-wing-pleat 8.4s ease-in-out -1.2s infinite;
    }
    & body[data-game="rs3"] .log-head::before,
    & body[data-game="rs3"] .topbar::after {
      content: "";
      position: absolute;
      width: 48px;
      height: 5px;
      pointer-events: none;
      background:
        radial-gradient(ellipse, var(--lit), transparent 70%) left center / 15px 4px no-repeat,
        radial-gradient(ellipse, var(--lit), transparent 70%) right center / 12px 3px no-repeat,
        linear-gradient(90deg, transparent, var(--gold), transparent) center / 15px 1px no-repeat;
      animation: rs3-rift-gather 7.8s ease-in-out -1.8s infinite;
    }
    & body[data-game="rs3"] .log-head::before { top: 44px; right: 5px; }
    & body[data-game="rs3"] .topbar::after { top: 3px; left: calc(50% - 24px); }
    & body[data-game="rs3"] .entry[aria-current="true"]::before {
      background: linear-gradient(to top, transparent, var(--lit) 60%, var(--ink)) center / 100% 12px no-repeat var(--gold);
      animation: rs3-lodestone-rail 8.4s ease-in-out -1.2s infinite;
    }
    & body[data-game="rs3"] .billing-kicker::before {
      --facet-flash: linear-gradient(145deg, transparent 25%, #fff6d5 50%, transparent 75%);
      background: var(--facet-flash) no-repeat 0 -25px / 34% 16px,
        var(--facet-flash) no-repeat 50% -25px / 36% 18px,
        var(--facet-flash) no-repeat 100% -25px / 34% 16px,
        var(--pendant);
      animation: rs3-crystal-chord 9.6s ease-in-out -1s infinite;
    }
  }
}
@keyframes rs3-wing-pleat {
  0%, 58%, 100% { transform: scaleX(.94); }
  26% { transform: scaleX(.49); }
}
@keyframes rs3-companion-fold {
  0%, 65%, 100% { transform: perspective(25px) rotateY(6deg); }
  30% { transform: perspective(25px) rotateY(52deg); }
}
@keyframes rs3-rift-gather {
  0%, 75%, 100% { background-position: 0 center, 100% center, center; opacity: .32; }
  22% { opacity: .9; }
  53% { background-position: 50% center, 50% center, center; opacity: .85; }
  64% { background-position: 50% center, 50% center, center; opacity: .12; }
}
@keyframes rs3-lodestone-rail {
  0%, 20%, 100% { background-position: center calc(100% + 13px); }
  34% { background-position: center 100%; }
  58%, 98% { background-position: center -13px; }
  99% { background-position: center -13px; animation-timing-function: steps(1, end); }
}
@keyframes rs3-crystal-chord {
  0%, 15%, 100% { background-position: 0 -25px, 50% -25px, 100% -25px, center; }
  30% { background-position: 0 26px, 50% -25px, 100% -25px, center; }
  45% { background-position: 0 26px, 50% 26px, 100% -25px, center; }
  60%, 98% { background-position: 0 26px, 50% 26px, 100% 26px, center; }
  99% { background-position: 0 26px, 50% 26px, 100% 26px, center; animation-timing-function: steps(1, end); }
}
@media (forced-colors: active) {
  .door--rs3, body[data-game="rs3"] .billing { border: 2px solid CanvasText; filter: none; }
  body[data-game="rs3"] :is(.tab[aria-selected="true"], .entry[aria-current="true"], .topnav a[aria-current]) {
    outline: 2px solid Highlight;
    outline-offset: -3px;
    text-decoration: underline;
  }
}
@media print {
  :root:root :is(body[data-game="rs3"], .door--rs3, .table-wrap[data-game="rs3"]) {
    --ink: #111;
    --ink-2: #222;
    --muted: #333;
    --water: #143b58;
    --lit: #143b58;
    --gilt-ink: #49360b;
    --card: white;
    --paper: white;
    --paper-2: white;
    --well: white;
    --water-soft: white;
    --alloy: white;
    background: white;
    color: #111;
  }
  .door--rs3 { border: 1px solid; filter: none; }
  .door--rs3::before, .door--rs3::after { content: none; }
  body[data-game="rs3"] .billing { box-shadow: none; }
}
