/*
 * Moyako Games — Info Drawer
 * ------------------------------------------------------------------
 * Overlay drawer used on every game page (About / Rules / Tips / FAQ).
 * Independent of moyako-components.css so it loads on the 6 non-v2
 * games as well as chess. The drawer must be position:fixed + high
 * z-index so opening it doesn't push the board or render inline.
 *
 * Opened state = .is-open on .info-drawer.
 * PR-7b-era markup lives in each game's HTML; this file only styles.
 */

.info-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(400px, 85vw);
  background: var(--bg-surface, #1A1F2E);
  color: var(--text-primary, #ECEFF4);
  border-left: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 300ms ease;
  z-index: 100;
  /* Always rendered — SSR content is read by the AdSense crawler even
     while the drawer is closed. visibility toggles with .is-open. */
  visibility: hidden;
  box-sizing: border-box;
}

.info-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
}

.info-drawer .drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  flex: 0 0 auto;
}

.info-drawer .drawer-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary, #ECEFF4);
}

.info-drawer .drawer-close {
  background: transparent;
  border: 0;
  color: var(--text-primary, #ECEFF4);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 44px;
  min-height: 44px;
}

.info-drawer .drawer-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
  color: var(--text-secondary, #C5CAD5);
  font-size: 14px;
  line-height: 1.5;
}

.info-drawer .drawer-section {
  margin-bottom: 24px;
}

.info-drawer .drawer-section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #ECEFF4);
  margin: 0 0 8px 0;
}

.info-drawer .drawer-section p {
  margin: 0 0 8px 0;
}

/* Backdrop — renders only when the drawer is open. Tapping closes. */
.info-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.info-drawer.is-open + .info-drawer-backdrop,
body:has(.info-drawer.is-open) .info-drawer-backdrop {
  display: block;
}

/* Mobile — slide up from bottom, 85% height, rounded top corners. */
@media (max-width: 599px) {
  .info-drawer {
    top: auto;
    width: 100%;
    height: 85vh;
    transform: translateY(100%);
    border-left: 0;
    border-top: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    border-radius: 16px 16px 0 0;
  }
  .info-drawer.is-open {
    transform: translateY(0);
  }
}

/* Light theme adjustments */
[data-theme="light"] .info-drawer {
  background: #FFFFFF;
  color: #1F2937;
  border-color: rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .info-drawer .drawer-title,
[data-theme="light"] .info-drawer .drawer-close,
[data-theme="light"] .info-drawer .drawer-section h3 {
  color: #1F2937;
}
[data-theme="light"] .info-drawer .drawer-content {
  color: #4B5563;
}

/* Classic Wooden — parchment/brass info panel (Owner P0: the dark overlay read
   as a debug modal). The drawer had no wooden override, so --bg-surface fell back
   to the #1A1F2E dark default. Make it a proper parchment card: brass border,
   espresso headings, brown body, brass close, darker backdrop. */
[data-theme="wooden"] .info-drawer {
  background: linear-gradient(180deg, #F8EAC5 0%, #E5D2AC 100%);
  border-color: #B8893A;
  color: #4B3626;
}
[data-theme="wooden"] .info-drawer .drawer-header {
  border-bottom-color: rgba(140, 100, 40, 0.35);
}
[data-theme="wooden"] .info-drawer .drawer-title,
[data-theme="wooden"] .info-drawer .drawer-section h3 {
  color: #2A1B12;
}
[data-theme="wooden"] .info-drawer .drawer-close { color: #8C6428; }
[data-theme="wooden"] .info-drawer .drawer-content { color: #4B3626; }
[data-theme="wooden"] .info-drawer-backdrop { background: rgba(20, 10, 4, 0.72); }

/* Wooden theme — parchment surface + espresso/brown text (mirrors the light
   block). The !important on the headings is required: the title (h1) and
   section h3 would otherwise be caught by the global [data-theme="wooden"]
   h1,h2,h3 → ivory rule and vanish on the parchment drawer. */
[data-theme="wooden"] .info-drawer {
  background:
    linear-gradient(rgba(247,235,207,0.52), rgba(247,235,207,0.52)),
    radial-gradient(circle at 28% 0%, rgba(255,250,235,0.14), transparent 60%),
    url("../assets/wooden/parchment.png") repeat;
  background-size: auto, auto, 360px auto;
  color: #4B3626;
  border-color: #8C6428;
}
[data-theme="wooden"] .info-drawer .drawer-title,
[data-theme="wooden"] .info-drawer .drawer-close,
[data-theme="wooden"] .info-drawer .drawer-section h3 {
  color: #2A1B12 !important;
}
[data-theme="wooden"] .info-drawer .drawer-content,
[data-theme="wooden"] .info-drawer .drawer-section p {
  color: #4B3626;
}

/* ── ℹ "game info" FLIP back-faces (NOT the .info-drawer bottom-sheet above):
 *    the in-play left pane (.pane-left-face--back) and the picker card
 *    (.game-info-face--back) both inject the same /shared/drawer-content/
 *    <game>.html. The flipped face kept a Core dark-walnut/#241307 panel with
 *    light text + the global [data-theme="wooden"] h1-3 → ivory, so the copy
 *    read as a low-contrast dark-on-dark block (Owner maze info-drawer review
 *    — title/headings/body unreadable). Fix = make the back a PARCHMENT card
 *    (matching the front face) + espresso headings + brown body, so the flip
 *    is parchment→parchment and the text reads. Wooden-scoped; all games. ── */
[data-theme="wooden"] .pane-left-face--back,
[data-theme="wooden"] .game-info-face--back {
  background:
    linear-gradient(180deg, #F8EAC5 0%, #E5D2AC 100%) !important;
  color: #4B3626 !important;
}
[data-theme="wooden"] .pane-left-face--back :is(p, li, em, td, dd),
[data-theme="wooden"] .game-info-face--back :is(p, li, em, td, dd) {
  color: #4B3626 !important;
}
[data-theme="wooden"] .pane-left-face--back :is(h2, h3, h4, strong, dt),
[data-theme="wooden"] .pane-left-face--back .game-info-back-heading,
[data-theme="wooden"] .game-info-face--back :is(h2, h3, h4, strong, dt),
[data-theme="wooden"] .game-info-face--back .game-info-back-heading {
  color: #2A1B12 !important;
}
