/* The Tavern Arcade — sticky ad chrome (A-ADS only).
   A-ADS units must never use display:none or visibility:hidden. */

:root {
  --ta-ad-top: 98px;       /* 90px unit + 8px padding */
  --ta-ad-side: 0px;
  --ta-ad-z: 100050;
  --ta-ad-bg: #0c0806;
  --ta-ad-line: rgba(232, 178, 74, 0.28);
}

@media (max-width: 727px) {
  :root {
    /* 90/728 of the viewport width, plus 8px of padding.
       (Must multiply a number by 100vw — two lengths cannot be multiplied.) */
    --ta-ad-top: calc(90 * 100vw / 728 + 8px);
  }
}

/* When a game is opened inside the homepage iframe, the parent already
   shows the sticky A-ADS bars. Zero out this document's reservations. */
html.ta-ad-in-iframe {
  --ta-ad-top: 0px;
  --ta-ad-side: 0px;
}

/* -------- top bar (A-ADS 728x90) -------- */
.ta-ad-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--ta-ad-z);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--ta-ad-top);
  background: var(--ta-ad-bg);
  border-bottom: 1px solid var(--ta-ad-line);
  pointer-events: auto;
}

html.ta-ad-in-iframe .ta-ad-top,
html.ta-ad-in-iframe .ta-ad-rail {
  /* Nested in #game-frame: parent page already has the A-ADS units. */
  display: none !important;
}

/* Header A-ADS 728x90: scale down on narrow viewports, never clip the iframe. */
.ta-ad-aads-728 {
  width: 728px;
  height: 90px;
  flex: 0 0 auto;
}
@media (max-width: 727px) {
  /* Flex-start so the unscaled 90px box is not vertically centered
     in the shorter bar (that would put its top at a negative y). */
  .ta-ad-top { align-items: flex-start; padding-top: 4px; box-sizing: border-box; }
  .ta-ad-aads-728 {
    /* 100vw/728px is unitless (length/length), which scale() requires */
    transform: scale(calc(100vw / 728px));
    transform-origin: top center;
  }
}

/* -------- left A-ADS rail (160x600) --------
   Desktop (>=1360px): fixed left, always visible (A-ADS crawler is desktop).
   Narrower: stays in normal flow at the end of the page
   (never display:none / visibility:hidden). */
.ta-ad-rail,
.ta-ad-rail-left {
  box-sizing: border-box;
  width: 160px;
  height: 600px;
  margin: 16px auto;
  background: var(--ta-ad-bg);
}

@media (min-width: 1360px) {
  html.ta-ads-sides {
    --ta-ad-side: 168px;
  }
  html.ta-ads-sides .ta-ad-rail-left {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    z-index: var(--ta-ad-z);
    left: 4px;
  }
}

/* At 1360–1479 the left rail leaves less room for the sticky site nav. */
@media (min-width: 1360px) and (max-width: 1479px) {
  html.ta-ads-sides header.top .wrap,
  html.ta-ads-sides .top .wrap { gap: 8px !important; }
  html.ta-ads-sides .brand { letter-spacing: 0.08em !important; }
  html.ta-ads-sides .nav { gap: 10px !important; }
}

/* -------- reserve space so the top bar never covers page content -------- */
html.ta-ads-content body {
  padding-top: var(--ta-ad-top) !important;
  box-sizing: border-box;
}
@media (min-width: 1360px) {
  html.ta-ads-sides body {
    padding-left: var(--ta-ad-side) !important;
  }
}

/* Existing sticky site header sits below the top ad bar */
html.ta-ads-content header.top,
html.ta-ads-content .top {
  top: var(--ta-ad-top) !important;
}

/* Homepage in-page game player: sit below the top bar (and inside the left rail) */
html.ta-ads-content #play-modal {
  top: var(--ta-ad-top) !important;
  left: var(--ta-ad-side) !important;
}

html.ta-ads-content dialog {
  max-height: calc(88vh - var(--ta-ad-top)) !important;
}

/* -------- fullscreen / canvas / VR game pages (top bar only) --------
   Shrink common fullscreen shells so the canvas sits below the top bar.
   Game JavaScript is not modified. */
html.ta-ads-game,
html.ta-ads-vr {
  height: 100%;
}
html.ta-ads-game body,
html.ta-ads-vr body {
  box-sizing: border-box;
  padding-top: var(--ta-ad-top) !important;
}

html.ta-ads-game #canvaswrap,
html.ta-ads-game body > #game,
html.ta-ads-vr #canvaswrap,
html.ta-ads-vr body > #game,
html.ta-ads-game .screen,
html.ta-ads-vr .screen,
html.ta-ads-game #game-container,
html.ta-ads-game #gameCanvas,
html.ta-ads-game canvas#gameCanvas,
html.ta-ads-game #fx-canvas,
html.ta-ads-game body > canvas,
html.ta-ads-vr #game-container,
html.ta-ads-vr body > canvas {
  top: var(--ta-ad-top) !important;
  bottom: 0 !important;
  height: auto !important;
}

html.ta-ads-game #game-container,
html.ta-ads-vr #game-container {
  max-height: 100%;
}

/* Simple HUD overlays that were pinned to the raw viewport */
html.ta-ads-game #ui {
  top: calc(var(--ta-ad-top) + 8px) !important;
}
