/*
 * Old Dudes D&D — Roll Initiative Entrance
 * Isolated from the rest of the site with odx- prefixed classes.
 */

html.odx-entrance-pending {
  background: #050608;
}

html.odx-entrance-pending body {
  opacity: 0;
}

.odx-entrance {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 24px;
  color: #f7f3e8;
  background:
    radial-gradient(circle at 50% 28%, rgba(104, 25, 21, 0.38), transparent 34%),
    radial-gradient(circle at 50% 75%, rgba(177, 105, 26, 0.13), transparent 42%),
    linear-gradient(180deg, #0d0e11 0%, #050608 100%);
  font-family: inherit;
  isolation: isolate;
}

.odx-entrance *,
.odx-entrance *::before,
.odx-entrance *::after {
  box-sizing: border-box;
}

.odx-panel {
  width: min(760px, 100%);
  margin: auto;
  text-align: center;
}

.odx-kicker {
  margin: 0 0 10px;
  font-size: clamp(0.72rem, 1.6vw, 0.9rem);
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #cfaa66;
}

.odx-title {
  margin: 0;
  font-size: clamp(2.3rem, 7vw, 5rem);
  line-height: 0.98;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  text-shadow:
    0 3px 0 #000,
    0 12px 35px rgba(0, 0, 0, 0.8);
}

.odx-subtitle {
  max-width: 600px;
  margin: 15px auto 26px;
  color: rgba(247, 243, 232, 0.76);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.55;
}

.odx-die-stage {
  position: relative;
  width: min(330px, 72vw);
  aspect-ratio: 1;
  margin: 8px auto 22px;
  display: grid;
  place-items: center;
  perspective: 900px;
}

.odx-d20 {
  position: relative;
  width: 78%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  clip-path: polygon(
    50% 0%,
    82% 10%,
    100% 38%,
    94% 74%,
    72% 100%,
    28% 100%,
    6% 74%,
    0% 38%,
    18% 10%
  );
  background:
    linear-gradient(145deg, rgba(255,255,255,0.22), transparent 26%),
    linear-gradient(35deg, #8c1717 0%, #3d0909 48%, #ad2d1c 100%);
  border: 0;
  filter:
    drop-shadow(0 18px 22px rgba(0,0,0,0.7))
    drop-shadow(0 0 24px rgba(171,45,30,0.22));
  transform-style: preserve-3d;
}

.odx-d20::before,
.odx-d20::after {
  content: "";
  position: absolute;
  inset: 13%;
  pointer-events: none;
  opacity: 0.52;
}

.odx-d20::before {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  border: 2px solid rgba(237, 201, 126, 0.52);
}

.odx-d20::after {
  inset: 27% 18%;
  border-left: 2px solid rgba(237, 201, 126, 0.35);
  border-right: 2px solid rgba(237, 201, 126, 0.35);
  transform: rotate(60deg);
}

.odx-number {
  position: relative;
  z-index: 3;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(4.5rem, 17vw, 8.5rem);
  font-weight: 900;
  line-height: 1;
  color: #f0d390;
  text-shadow:
    0 3px 0 #5e210c,
    0 7px 12px rgba(0,0,0,0.75);
}

.odx-d20.odx-rolled {
  animation: odx-roll 720ms cubic-bezier(.2,.8,.2,1) both;
}

.odx-d20.odx-nat20 {
  filter:
    drop-shadow(0 18px 22px rgba(0,0,0,0.65))
    drop-shadow(0 0 34px rgba(255,188,62,0.8));
}

@keyframes odx-roll {
  0% {
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(1);
  }
  28% {
    transform: rotateX(190deg) rotateY(270deg) rotateZ(110deg) scale(0.82);
  }
  62% {
    transform: rotateX(430deg) rotateY(540deg) rotateZ(260deg) scale(1.12);
  }
  82% {
    transform: rotateX(690deg) rotateY(735deg) rotateZ(380deg) scale(0.96);
  }
  100% {
    transform: rotateX(720deg) rotateY(720deg) rotateZ(360deg) scale(1);
  }
}

.odx-roll-button {
  appearance: none;
  border: 2px solid #d6ad5d;
  border-radius: 999px;
  padding: 15px 30px;
  min-width: min(320px, 86vw);
  font: inherit;
  font-size: clamp(1rem, 2vw, 1.15rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  color: #18110a;
  background: linear-gradient(180deg, #f4d98d 0%, #c99b45 100%);
  box-shadow:
    0 8px 24px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.6);
  transition:
    transform 140ms ease,
    filter 140ms ease,
    box-shadow 140ms ease;
}

.odx-roll-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.07);
  box-shadow:
    0 11px 28px rgba(0,0,0,0.52),
    inset 0 1px 0 rgba(255,255,255,0.65);
}

.odx-roll-button:active {
  transform: translateY(1px);
}

.odx-roll-button:focus-visible,
.odx-alt a:focus-visible,
.odx-enter-button:focus-visible,
.odx-skip:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

.odx-alt-label {
  margin: 28px 0 10px;
  font-size: 0.78rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: rgba(247,243,232,0.48);
}

.odx-alt {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 15px;
  font-size: 0.92rem;
}

.odx-alt a,
.odx-enter-button {
  appearance: none;
  border: 0;
  padding: 7px 3px;
  color: rgba(247,243,232,0.77);
  background: transparent;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  border-bottom: 1px solid rgba(207,170,102,0.28);
}

.odx-alt a:hover,
.odx-enter-button:hover {
  color: #fff;
  border-bottom-color: #d6ad5d;
}

.odx-video-wrap {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  background: #000;
}

.odx-entrance.odx-is-blasting .odx-panel {
  visibility: hidden;
}

.odx-entrance.odx-is-blasting .odx-video-wrap {
  display: grid;
  place-items: center;
}

.odx-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.odx-skip {
  position: absolute;
  z-index: 22;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  appearance: none;
  border: 1px solid rgba(255,255,255,0.48);
  border-radius: 999px;
  padding: 9px 15px;
  color: #fff;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

.odx-entering {
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease;
}

@media (max-width: 620px) {
  .odx-entrance {
    padding: 18px 16px;
  }

  .odx-subtitle {
    margin-bottom: 14px;
  }

  .odx-die-stage {
    width: min(250px, 66vw);
    margin-bottom: 12px;
  }

  .odx-alt-label {
    margin-top: 20px;
  }

  .odx-alt {
    gap: 5px 13px;
    font-size: 0.86rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .odx-d20.odx-rolled {
    animation: none;
  }

  .odx-roll-button,
  .odx-entering {
    transition: none;
  }
}

/* ==========================================================
   Old Dudes branded Natural 20 entrance die
   ========================================================== */

.odx-d20 {
  width: 96%;
  aspect-ratio: 1;
  clip-path: none;

  background:
    url("/assets/media/old-dude-dice.png")
    center / contain
    no-repeat;

  border: 0;

  filter:
    drop-shadow(0 22px 24px rgba(0,0,0,0.72))
    drop-shadow(0 0 24px rgba(213,161,58,0.18));

  transform-style: preserve-3d;
}

.odx-d20::before,
.odx-d20::after {
  display: none;
}

.odx-number {
  display: none;
}

.odx-d20.odx-nat20 {
  filter:
    drop-shadow(0 22px 25px rgba(0,0,0,0.68))
    drop-shadow(0 0 38px rgba(239,190,79,0.65));
}

@media (max-width: 620px) {
  .odx-die-stage {
    width: min(285px, 72vw);
  }
}

/* Big entrance d20 is also a Roll Initiative button */
.odx-die-button {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.odx-die-button:hover .odx-d20 {
  filter:
    drop-shadow(0 22px 25px rgba(0,0,0,0.68))
    drop-shadow(0 0 34px rgba(239,190,79,0.48));
}

.odx-die-button:focus-visible {
  outline: 3px solid #f4d98d;
  outline-offset: 7px;
  border-radius: 24px;
}

.odx-die-button:disabled {
  cursor: default;
}
