/* Mother treasure presentation: a dark-oak frame set into a stone-brick wall,
   gold-block trim, redstone-ore corners, lit lamps on the rails and redstone
   jewels for every control. Textures are procedural data URLs supplied as
   --tex-* custom properties by mother-chest-reader.js; every rule below has a
   flat-colour fallback for browsers without canvas. */

.mother-reader-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2.2vw, 30px);
  box-sizing: border-box;
  background-color: #2b2a32;
  background-image: var(--tex-wall, none);
  background-size: 48px 48px;
  image-rendering: pixelated;
  color: #f6ede4;
  font: 400 12px/1.5 'Mother Pixel', 'Courier New', Courier, monospace;
  -webkit-font-smoothing: none;
  cursor: default;
  isolation: isolate;
}
.mother-reader-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 50% 55%, rgba(255, 70, 50, 0.14), transparent 70%),
    radial-gradient(ellipse 90% 80% at 50% 50%, transparent 35%, rgba(0, 0, 0, 0.78) 100%);
}

.mother-reader-overlay *,
.mother-reader-overlay *::before,
.mother-reader-overlay *::after { box-sizing: border-box; }

/* The frame ------------------------------------------------------------- */

.mother-reader-dialog {
  position: relative;
  width: min(1480px, 100%);
  height: min(1020px, calc(100vh - 40px));
  height: min(1020px, calc(100dvh - 40px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 30px 30px 26px;
  background-color: #5c3b1e;
  background-image: var(--tex-plank, none);
  background-size: 32px 32px;
  image-rendering: pixelated;
  border: 6px solid;
  border-color: #9a6632 #2a1407 #2a1407 #9a6632;
  outline: 3px solid #110903;
  box-shadow:
    0 0 0 9px #3b2611,
    0 0 0 12px #120a04,
    0 30px 60px -10px rgba(0, 0, 0, 0.85),
    0 0 90px rgba(255, 80, 50, 0.18);
}
/* Gold-block trim ring just inside the planks. */
.mother-reader-dialog::before {
  content: '';
  position: absolute;
  inset: 12px;
  pointer-events: none;
  border: 8px solid #e1b43b;
  border-image: var(--tex-gold, none) 16 / 8px round;
  box-shadow: inset 0 0 0 2px #8a5c0f, 0 0 0 2px #8a5c0f;
}
.mother-reader-corner {
  position: absolute;
  width: 44px;
  height: 44px;
  background-color: #7b7b82;
  background-image: var(--tex-ore, none);
  background-size: 100% 100%;
  image-rendering: pixelated;
  border: 3px solid;
  border-color: #a9a9b1 #35353b #35353b #a9a9b1;
  outline: 2px solid #110903;
  box-shadow: 0 0 18px 3px rgba(255, 48, 36, 0.45);
  animation: mother-reader-ember 3.2s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}
.mother-reader-corner[data-corner="tl"] { top: -18px; left: -18px; }
.mother-reader-corner[data-corner="tr"] { top: -18px; right: -18px; animation-delay: -0.8s; }
.mother-reader-corner[data-corner="bl"] { bottom: -18px; left: -18px; animation-delay: -1.6s; }
.mother-reader-corner[data-corner="br"] { bottom: -18px; right: -18px; animation-delay: -2.4s; }
.mother-reader-rail {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(52%, 560px);
  height: 22px;
  background-color: #e59c3c;
  background-image: var(--tex-lamp, none);
  background-size: 22px 22px;
  image-rendering: pixelated;
  border: 2px solid #3d1f08;
  box-shadow: 0 0 22px 4px rgba(255, 170, 70, 0.45);
  pointer-events: none;
  z-index: 2;
}
.mother-reader-rail[data-rail="top"] { top: -14px; }
.mother-reader-rail[data-rail="bottom"] { bottom: -14px; }

/* Header plaque ---------------------------------------------------------- */

.mother-reader-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 16px 14px;
  background: rgba(22, 12, 5, 0.78);
  border: 3px solid;
  border-color: #1c0f06 #7a5027 #7a5027 #1c0f06;
}
/* A line of powered redstone dust under the title. */
.mother-reader-header::after {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 4px;
  height: 3px;
  background: linear-gradient(90deg, transparent, #ff4a3c 18%, #ff8a7a 50%, #ff4a3c 82%, transparent);
  box-shadow: 0 0 10px 1px rgba(255, 70, 50, 0.75);
  pointer-events: none;
}
.mother-reader-heading { min-width: 0; }
.mother-reader-eyebrow {
  color: #f4a6c9;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 4px;
  text-shadow: 1px 1px #000;
}
.mother-reader-title {
  margin: 0;
  font: inherit;
  font-size: clamp(13px, 1.4vw, 20px);
  line-height: 1.3;
  color: #fff6ea;
  text-shadow: 2px 2px #000, 0 0 12px rgba(255, 120, 90, 0.35);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Redstone jewel buttons -------------------------------------------------- */

.mother-reader-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  margin: 0;
  padding: 4px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #ffe9dc;
  font: inherit;
  font-size: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 1px 1px #000, 0 0 6px rgba(0, 0, 0, 0.8);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mother-reader-gem {
  display: block;
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 0 6px rgba(255, 60, 40, 0.55)) drop-shadow(0 3px 2px rgba(0, 0, 0, 0.6));
  transition: transform 0.12s ease, filter 0.12s ease;
}
.mother-reader-gem svg { display: block; width: 100%; height: 100%; }
.mother-reader-button[data-gem="left"] .mother-reader-gem,
.mother-reader-button[data-gem="right"] .mother-reader-gem {
  width: 78px;
  height: 78px;
  animation: mother-reader-twinkle 2.6s ease-in-out infinite;
}
.mother-reader-button[data-gem="right"] .mother-reader-gem { animation-delay: -1.3s; }
.mother-reader-button:hover:not(:disabled) .mother-reader-gem {
  transform: translateY(-2px) scale(1.07);
  filter: drop-shadow(0 0 14px rgba(255, 90, 70, 0.95)) drop-shadow(0 4px 3px rgba(0, 0, 0, 0.6));
  animation: none;
}
.mother-reader-button:active:not(:disabled) .mother-reader-gem {
  transform: translateY(1px) scale(0.96);
  filter: drop-shadow(0 0 8px rgba(255, 90, 70, 0.8));
}
.mother-reader-button:hover:not(:disabled) { color: #fff; }
.mother-reader-button:disabled {
  cursor: default;
  color: #9a8f88;
}
.mother-reader-button:disabled .mother-reader-gem {
  filter: grayscale(0.9) brightness(0.5) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6));
  animation: none;
}
.mother-reader-button:focus-visible,
.mother-reader-stage:focus-visible {
  outline: 3px solid #ffd66b;
  outline-offset: 3px;
}
.mother-reader-close {
  flex-direction: row;
  gap: 10px;
  flex-shrink: 0;
  padding: 4px 10px 4px 4px;
}
.mother-reader-close .mother-reader-gem { width: 44px; height: 44px; }
.mother-reader-overlay [hidden] { display: none !important; }

/* Page stage -------------------------------------------------------------- */

.mother-reader-stage {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  border: 5px solid;
  border-color: #1a1008 #6b4725 #6b4725 #1a1008;
  background: #15110f;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.9);
  overscroll-behavior: contain;
  scrollbar-color: #e3261f #15110f;
  scrollbar-width: thin;
  touch-action: pan-x pan-y;
}
.mother-reader-canvas {
  display: grid;
  place-items: center;
  min-width: 100%;
  min-height: 100%;
}
.mother-reader-paper {
  flex: none;
  margin: 12px;
  background: #fff;
  border: 2px solid #e1b43b;
  outline: 2px solid #5a3a0c;
  box-shadow: 0 0 0 1px #000, 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 40px rgba(255, 90, 60, 0.12);
  transition: opacity 0.15s ease;
}
.mother-reader-overlay[data-loading="true"] .mother-reader-paper { opacity: 0.55; }
.mother-reader-page {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
  user-select: none;
  -webkit-user-drag: none;
}
.mother-reader-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: #fff;
  background: rgba(21, 17, 15, 0.92);
}
.mother-reader-status p { max-width: 42ch; margin: 0; text-shadow: 1px 1px #000; }

/* Footer: navigation jewels, page plaque, zoom jewels, media links --------- */

.mother-reader-footer,
.mother-reader-navigation,
.mother-reader-sizing {
  display: flex;
  align-items: center;
  gap: 12px;
}
.mother-reader-footer {
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 2px 6px 0;
}
.mother-reader-navigation { gap: 18px; }
.mother-reader-counter {
  min-width: 15ch;
  font-size: 10px;
  padding: 9px 14px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: #ffe08a;
  background: rgba(22, 12, 5, 0.82);
  border: 3px solid;
  border-color: #1c0f06 #7a5027 #7a5027 #1c0f06;
  box-shadow: inset 0 0 0 1px #c9962c;
  text-shadow: 1px 1px #000;
}
.mother-reader-sizing .mother-reader-button { padding-left: 4px; padding-right: 4px; }
.mother-reader-sizing .mother-reader-gem { width: 44px; height: 44px; }
.mother-reader-sizing .mother-reader-button[data-gem="fit"] { min-width: 12ch; }
.mother-reader-links {
  flex: 0 0 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding-top: 10px;
  border-top: 2px solid rgba(201, 150, 44, 0.55);
}
.mother-reader-media-link {
  flex-direction: row;
  max-width: 100%;
  padding: 9px 16px;
  border: 3px solid;
  border-color: #9a6632 #2a1407 #2a1407 #9a6632;
  border-radius: 0;
  background: rgba(22, 12, 5, 0.85);
  color: #ffe08a;
  font-size: 9px;
  letter-spacing: 0.02em;
  text-align: center;
  text-decoration: none;
  box-shadow: inset 0 0 0 1px #c9962c;
}
.mother-reader-media-link:hover {
  background: rgba(60, 24, 10, 0.95);
  color: #fff3c4;
  box-shadow: inset 0 0 0 1px #ffd66b, 0 0 14px rgba(255, 90, 60, 0.45);
}
.mother-reader-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: pre-line;
}

/* Motion ------------------------------------------------------------------ */

@keyframes mother-reader-ember {
  0%, 100% { box-shadow: 0 0 14px 2px rgba(255, 48, 36, 0.35); }
  50% { box-shadow: 0 0 24px 5px rgba(255, 70, 50, 0.7); }
}
@keyframes mother-reader-twinkle {
  0%, 100% { filter: drop-shadow(0 0 5px rgba(255, 60, 40, 0.45)) drop-shadow(0 3px 2px rgba(0, 0, 0, 0.6)); }
  50% { filter: drop-shadow(0 0 13px rgba(255, 90, 70, 0.9)) drop-shadow(0 3px 2px rgba(0, 0, 0, 0.6)); }
}
@media (prefers-reduced-motion: reduce) {
  .mother-reader-corner,
  .mother-reader-button .mother-reader-gem { animation: none; }
  .mother-reader-gem { transition: none; }
  .mother-reader-stage { scroll-behavior: auto; }
}

/* Small screens ------------------------------------------------------------ */

@media (max-width: 760px) {
  .mother-reader-overlay { padding: 8px; font-size: 10px; }
  .mother-reader-dialog {
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
    padding: 18px 14px 14px;
    gap: 8px;
    border-width: 4px;
    box-shadow: 0 0 0 6px #3b2611, 0 0 0 8px #120a04, 0 20px 40px -10px rgba(0, 0, 0, 0.85);
  }
  .mother-reader-dialog::before { inset: 7px; border-width: 5px; border-image-width: 5px; }
  .mother-reader-corner { width: 30px; height: 30px; }
  .mother-reader-corner[data-corner="tl"], .mother-reader-corner[data-corner="bl"] { left: -12px; }
  .mother-reader-corner[data-corner="tr"], .mother-reader-corner[data-corner="br"] { right: -12px; }
  .mother-reader-corner[data-corner="tl"], .mother-reader-corner[data-corner="tr"] { top: -12px; }
  .mother-reader-corner[data-corner="bl"], .mother-reader-corner[data-corner="br"] { bottom: -12px; }
  .mother-reader-rail { height: 14px; background-size: 14px 14px; width: 44%; }
  .mother-reader-rail[data-rail="top"] { top: -9px; }
  .mother-reader-rail[data-rail="bottom"] { bottom: -9px; }
  .mother-reader-header { gap: 8px; padding: 8px 10px 12px; }
  .mother-reader-close { padding: 2px 6px 2px 2px; }
  .mother-reader-close .mother-reader-gem { width: 36px; height: 36px; }
  .mother-reader-close .mother-reader-label { max-width: 9ch; line-height: 1.15; }
  .mother-reader-button { font-size: 7px; padding: 2px 4px; }
  .mother-reader-button[data-gem="left"] .mother-reader-gem,
  .mother-reader-button[data-gem="right"] .mother-reader-gem { width: 56px; height: 56px; }
  .mother-reader-sizing .mother-reader-gem { width: 36px; height: 36px; }
  .mother-reader-footer { justify-content: center; gap: 8px; }
  .mother-reader-navigation { width: 100%; justify-content: space-between; gap: 8px; }
  .mother-reader-counter { min-width: 10ch; padding: 7px 10px; }
  .mother-reader-sizing .mother-reader-button[data-gem="fit"] { min-width: 0; }
}

@media (max-height: 470px) and (min-width: 761px) {
  .mother-reader-overlay { padding: 8px; }
  .mother-reader-dialog { height: calc(100dvh - 16px); padding: 14px 16px 10px; gap: 6px; }
  .mother-reader-dialog::before { inset: 6px; border-width: 5px; border-image-width: 5px; }
  .mother-reader-eyebrow { display: none; }
  .mother-reader-header { padding: 4px 12px 8px; }
  .mother-reader-corner { width: 28px; height: 28px; }
  .mother-reader-rail { display: none; }
  .mother-reader-button .mother-reader-label { display: none; }
  .mother-reader-button[data-gem="left"] .mother-reader-gem,
  .mother-reader-button[data-gem="right"] .mother-reader-gem { width: 46px; height: 46px; }
  .mother-reader-sizing .mother-reader-gem, .mother-reader-close .mother-reader-gem { width: 34px; height: 34px; }
  .mother-reader-counter { padding: 5px 10px; }
}
