/*
 * pa-ui.css — shared chrome for Prothom Alo hero games.
 * App bar, icon buttons, bottom sheets, buttons, focus ring.
 * Colour comes from pa-tokens.css; nothing here hardcodes a hex.
 */

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--pa-paper);
  color: var(--pa-ink);
  font-family: var(--pa-sans);
  font-size: var(--pa-size-body);
  line-height: var(--pa-leading-body);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: 0; margin: 0; padding: 0; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--pa-cyan);
  outline-offset: 2px;
  border-radius: var(--pa-r-sm);
}

.pa-sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- masthead --------------------------------------------------------
   A newspaper head, not an app bar: the title set at display scale on the
   left against a spot-red rule, dateline running beneath it. Shared by all
   five hero games. */

.pa-masthead {
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--pa-paper-lift);
}
.pa-masthead .pa-iconbtn { width: 2.5rem; height: 2.5rem; }
/* Three tracks, outer two equal, so the nameplate is optically centred no
   matter how many controls sit either side of it. A newspaper's nameplate
   is centred; an app bar's title is not. */
.pa-masthead__top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--pa-s-1);
  padding-inline: var(--pa-s-1);
}
.pa-masthead__lead,
.pa-masthead__tail {
  display: flex;
  align-items: center;
  gap: var(--pa-s-1);
  min-width: 0;
}
.pa-masthead__lead { justify-self: start; }
.pa-masthead__tail { justify-self: end; }
.pa-masthead__title {
  min-width: 0;
  text-align: center;
  margin: 0;
  font-family: var(--pa-serif);
  font-weight: 700;
  font-size: var(--pa-size-masthead);
  line-height: 1.1;
  letter-spacing: -0.015em;
}
.pa-masthead__timer {
  flex: none;
  padding-inline-end: var(--pa-s-1);
  font-family: var(--pa-serif);
  font-weight: 400;
  font-size: var(--pa-size-title);
  font-variant-numeric: tabular-nums;
  color: var(--pa-ink-2);
}
.pa-masthead__timer.is-done { color: var(--pa-red); font-weight: 700; }
.pa-masthead__rule {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: var(--pa-s-3);
  margin-inline: var(--pa-s-3);
  padding-block-end: 2px;
  border-block-end: 2px solid var(--pa-red);
}
.pa-masthead__date {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 2px 0.25rem 2px 0;
  font-size: var(--pa-size-meta);
  letter-spacing: 0.07em;
  color: var(--pa-cyan);
  transition: color 140ms var(--pa-ease);
}
.pa-masthead__date:hover { color: var(--pa-red); }
.pa-masthead__date svg { display: block; }

.pa-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--pa-tap);
  height: var(--pa-tap);
  border-radius: var(--pa-r-md);
  color: var(--pa-cyan);
  transition: color 140ms var(--pa-ease), background-color 140ms var(--pa-ease);
}
.pa-iconbtn:hover { color: var(--pa-red); background: var(--pa-red-08); }
.pa-iconbtn:active { background: var(--pa-red-16); }
.pa-iconbtn svg { display: block; }

/* ---- buttons --------------------------------------------------------- */

.pa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--pa-s-2);
  min-height: var(--pa-tap);
  padding: 0 var(--pa-s-5);
  border-radius: var(--pa-r-lg);
  font-weight: 600;
  transition: background-color 140ms var(--pa-ease), color 140ms var(--pa-ease), box-shadow 140ms var(--pa-ease), transform 140ms var(--pa-ease);
}
/* House rule: button labels sit in blue and go red on hover. The filled CTA
   keeps white text on a blue fill and turns the fill red on hover; the text
   buttons carry the blue on the label itself and swap it to red. */
.pa-btn--primary { background: var(--pa-cyan); color: #fff; }
.pa-btn--primary:focus-visible { outline-color: var(--pa-ink); outline-offset: 3px; }
.pa-btn--primary:hover { background: var(--pa-red); }
.pa-btn--primary:active { transform: translateY(1px); }
.pa-btn--ghost { color: var(--pa-cyan); }
.pa-btn--ghost:hover { color: var(--pa-red); background: var(--pa-red-08); }
/* Same footprint as --primary (the ring is an inset shadow, so it adds no
   height): a secondary action that sits beside শুরু করুন without outweighing it. */
.pa-btn--secondary { color: var(--pa-cyan); box-shadow: inset 0 0 0 1.5px var(--pa-cyan); }
.pa-btn--secondary:hover { color: var(--pa-red); box-shadow: inset 0 0 0 1.5px var(--pa-red); background: var(--pa-red-08); }
.pa-btn--secondary:active { transform: translateY(1px); }

/* ── House rule: EVERY button label is blue and turns red on hover ─────────
   Applies to all buttons everywhere — .pa-btn, icon buttons, menu rows, the
   on-screen keyboard, clue navigation, grid cells, in-game controls. Filled
   buttons keep white text (their fill carries the blue→red instead); disabled
   buttons keep their muted colour. */
button:not(:disabled) { color: var(--pa-cyan); }
button:not(:disabled):hover { color: var(--pa-red); }
/* Filled buttons: white label stays white, the fill carries the colour. */
.pa-btn--primary:not(:disabled), .pa-btn--primary:not(:disabled):hover,
.pa-strip__use:not(:disabled), .pa-strip__use:not(:disabled):hover { color: #fff; }

/* Peer actions share a row two-up; a third wraps to a full-width line below. */
.fp-actions { display: flex; flex-wrap: wrap; gap: var(--pa-s-3); align-items: stretch; }
.fp-actions > .pa-btn { flex: 1 0 40%; width: auto; min-width: 0; margin: 0; padding-inline: var(--pa-s-4); white-space: nowrap; }

/* Leaderboard sheet — a scrolling top-10 list above a pinned "you" row.
   The body itself does not scroll (overrides pa-sheet__body); the list does. */
.pa-sheet__body.lb { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.lb-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; list-style: none; margin: 0; padding: var(--pa-s-2) var(--pa-s-4); }
.lb-row { display: flex; align-items: center; gap: var(--pa-s-3); padding: var(--pa-s-3) 0; border-block-end: 1px solid var(--pa-rule); }
.lb-row:last-child { border-block-end: 0; }
.lb-row__rank { flex: none; width: 1.75rem; text-align: center; font-family: var(--pa-serif); font-weight: 700; color: var(--pa-ink-2); }
.lb-row__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row__pts { flex: none; font-family: var(--pa-serif); font-weight: 700; color: var(--pa-cyan); }
/* The reader's own standing, pinned to the foot so it never scrolls away. */
.lb-me { flex: none; display: flex; align-items: center; gap: var(--pa-s-3); padding: var(--pa-s-4); border-block-start: 1px solid var(--pa-rule-strong); background: var(--pa-cyan-08); }
.lb-me .lb-row__rank { color: var(--pa-cyan); }
.lb-me .lb-row__name { font-weight: 700; color: var(--pa-ink); }

/* ---- bottom sheet ---------------------------------------------------- */

.pa-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: end;
  pointer-events: none;
}
.pa-sheet[hidden] { display: none; }

.pa-sheet__scrim {
  position: absolute;
  inset: 0;
  background: rgba(22, 23, 26, 0.44);
  opacity: 0;
  transition: opacity 240ms var(--pa-ease);
}

.pa-sheet__panel:focus { outline: none; }
.pa-sheet__panel {
  position: relative;
  width: min(34rem, 100%);
  justify-self: center;
  max-height: 78dvh;
  display: flex;
  flex-direction: column;
  background: var(--pa-paper-lift);
  border-radius: var(--pa-r-xl) var(--pa-r-xl) 0 0;
  box-shadow: var(--pa-lift-2);
  transform: translateY(101%);
  transition: transform 320ms var(--pa-ease);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.pa-sheet.is-open { pointer-events: auto; }
.pa-sheet.is-open .pa-sheet__scrim { opacity: 1; }
.pa-sheet.is-open .pa-sheet__panel { transform: translateY(0); }

/* On a spread the same sheet is a dialog: centred, all four corners, and it
   arrives by settling rather than sliding — a bottom sheet on a 1280px page
   is a phone habit showing through. Same markup, same focus trap, same
   Escape; only where it sits. The width is the reading measure the games
   already use for a sheet, not the page. */
@media (min-width: 60rem) and (min-height: 40rem) {
  .pa-sheet { align-items: center; }
  .pa-sheet__panel {
    width: min(36rem, calc(100% - 2 * var(--pa-s-6)));
    max-height: min(85dvh, 52rem);
    border-radius: var(--pa-r-xl);
    padding-bottom: 0;
    opacity: 0;
    transform: translateY(1.25rem) scale(0.985);
    transition: transform 280ms var(--pa-ease), opacity 200ms var(--pa-ease);
  }
  .pa-sheet.is-open .pa-sheet__panel { opacity: 1; transform: translateY(0) scale(1); }
}

.pa-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pa-s-3);
  padding: var(--pa-s-3) var(--pa-s-3) var(--pa-s-2) var(--pa-s-4);
  border-bottom: 1px solid var(--pa-rule);
}
.pa-sheet__title {
  margin: 0;
  font-family: var(--pa-serif);
  font-weight: 700;
  font-size: var(--pa-size-title);
  line-height: 1.2;
}
.pa-sheet__body { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* ---- scrollbars ------------------------------------------------------
   A default scrollbar is a grey plastic gutter from another design system,
   and on Windows and Android it is wide enough to be the loudest object on
   a three-ink page. Every scrolling region in the system wears this instead:
   a hairline-coloured thumb on no track, inked darker on hover. Overlay
   scrollbars (macOS, iOS) ignore it and stay invisible, which is correct. */

.pa-scroll { scrollbar-width: thin; scrollbar-color: var(--pa-rule) transparent; }
.pa-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.pa-scroll::-webkit-scrollbar-track { background: transparent; }
.pa-scroll::-webkit-scrollbar-thumb {
  background: var(--pa-rule);
  background-clip: content-box;
  border: 3px solid transparent;
  border-radius: 999px;
}
.pa-scroll:hover::-webkit-scrollbar-thumb { background: var(--pa-ink-3); background-clip: content-box; }

/* ---- menu rows ------------------------------------------------------- */

.pa-menu { padding: var(--pa-s-2) 0 var(--pa-s-3); }
.pa-menu__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pa-s-3);
  width: 100%;
  min-height: var(--pa-tap);
  padding: var(--pa-s-2) var(--pa-s-4);
  text-align: start;
  color: var(--pa-cyan);
  transition: color 140ms var(--pa-ease), background-color 140ms var(--pa-ease);
}
.pa-menu__row:hover { color: var(--pa-red); background: var(--pa-red-08); }
.pa-menu__label { font-weight: 500; }
.pa-menu__hint { color: var(--pa-ink-3); font-size: var(--pa-size-meta); }
.pa-menu__sep { height: 1px; margin: var(--pa-s-2) var(--pa-s-4); background: var(--pa-rule); }

/* ---- switch ---------------------------------------------------------- */

.pa-switch {
  position: relative;
  flex: none;
  width: 2.75rem;
  height: 1.625rem;
  border-radius: 999px;
  background: var(--pa-rule);
  transition: background-color 180ms var(--pa-ease);
}
.pa-switch::after {
  content: '';
  position: absolute;
  inset-inline-start: 3px;
  top: 3px;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--pa-lift-1);
  transition: transform 180ms var(--pa-ease);
}
.pa-menu__row[aria-checked='true'] .pa-switch { background: var(--pa-cyan); }
.pa-menu__row[aria-checked='true'] .pa-switch::after { transform: translateX(1.125rem); }

/* ---- ad slot ---------------------------------------------------------
   An ad is commercial and the page must say so. The slot is a lifted block
   bounded by a rule above and below, with বিজ্ঞাপন set in the meta voice
   over a hairline before the creative begins — the marker a newspaper prints
   over paid space, and the one thing that must hold on the day no ad is
   sold: the box stays, labelled, at full height. It must never read as the
   paper's own column, so it is never on --pa-paper and never borderless.

   Height is reserved structurally, not measured: pa-ads.js sizes the frame
   inline at mount from the declared slot size, before any request is made.
   Nothing in this block may depend on the creative's own height. */

.pa-ad {
  display: grid;
  /* minmax(0, 1fr), not auto: an auto track grows to the frame's intrinsic
     320px and overflows a 319px column; this track lets the frame's
     max-width: 100% bite instead. No inline padding for the same reason —
     a 320 creative in a 330 phone column has ten pixels to spare, not
     thirty. */
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  margin-block: var(--pa-s-4);
  padding: var(--pa-s-2) 0 var(--pa-s-3);
  background: var(--pa-paper-lift);
  border-block: 1px solid var(--pa-rule);
  overflow: hidden;
}
.pa-ad[hidden] { display: none; }
.pa-ad__label {
  width: 100%;
  padding-block-end: 2px;
  margin-block-end: var(--pa-s-2);
  border-block-end: 1px solid var(--pa-rule);
  text-align: center;
  font-size: var(--pa-size-meta);
  letter-spacing: 0.07em;
  line-height: var(--pa-leading-tight);
  color: var(--pa-ink-3);
  user-select: none;
  -webkit-user-select: none;
}
.pa-ad__frame {
  position: relative;
  overflow: hidden;
  /* The vendor's iframe or the placeholder fills this; nothing else does. */
}
.pa-ad__frame > * { display: block; }

/* ---- the সাহায্য strip ------------------------------------------------
   Built by pa-ads.js into a host the game reserves above its board, the way
   a game shows lives: four tokens, spent one at a time, and one action that
   works on whatever the game says is in front of the reader. Tokens are a
   bulb in the system's stroke: filled chrome = the reader's (free), outlined
   chrome = a view each, hollow ink-3 = spent — three shapes, never hue
   alone. Spending one is the strip's one motion: the token pops and goes
   out. The count beside the tokens is for assistive tech on a phone — the
   tokens are the count — and printed on a spread. */

.pa-strip {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--pa-s-3);
  padding: var(--pa-s-2) var(--pa-s-4);
  background: var(--pa-paper-lift);
  border-bottom: 1px solid var(--pa-rule);
}
.pa-strip[hidden] { display: none; }
.pa-strip__lives { display: flex; align-items: center; gap: var(--pa-s-3); min-width: 0; }
.pa-strip__k {
  font: 400 var(--pa-size-meta)/1 var(--pa-sans);
  letter-spacing: 0.07em;
  color: var(--pa-ink-2);
}
.pa-strip__tokens { display: inline-flex; gap: var(--pa-s-1); }
.pa-token {
  display: inline-flex; width: 1.5rem; height: 1.5rem;
  color: var(--pa-cyan);
  transition: color 200ms var(--pa-ease), opacity 200ms var(--pa-ease);
}
.pa-token svg { width: 100%; height: 100%; display: block; }
.pa-token .pa-token__fill { fill: currentColor; }
.pa-token.is-ad .pa-token__fill { fill: transparent; }
.pa-token.is-spent { color: var(--pa-ink-3); opacity: 0.55; }
.pa-token.is-spent .pa-token__fill { fill: transparent; }
.pa-token.is-going { animation: pa-token-out 420ms var(--pa-ease) both; }
@keyframes pa-token-out {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.pa-strip__n {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  font: 400 var(--pa-size-meta)/1 var(--pa-sans);
  letter-spacing: 0.07em;
  color: var(--pa-ink-2);
  font-variant-numeric: tabular-nums;
}
.pa-strip__use {
  flex: none;
  display: inline-flex; align-items: center; gap: var(--pa-s-2);
  min-height: max(var(--pa-tap), 44px);
  padding: 0 var(--pa-s-4);
  border-radius: var(--pa-r-lg);
  background: var(--pa-cyan);
  color: #fff;
  font: 600 var(--pa-size-body)/1 var(--pa-sans);
  white-space: nowrap;
  transition: background-color 140ms var(--pa-ease), opacity 140ms var(--pa-ease);
}
.pa-strip__use:hover:not(:disabled) { background: var(--pa-red); }
.pa-strip__use:disabled { cursor: default; background: var(--pa-rule); color: var(--pa-ink-2); }
.pa-strip__use[aria-busy='true'] { opacity: 0.6; }
.pa-strip__ad { flex: none; }
/* At the ceiling the action is a statement, not a disabled button. */
.pa-strip__use.is-out { background: transparent; color: var(--pa-ink-3); padding-inline: 0; font-weight: 400; }

@media (min-width: 60rem) and (min-height: 40rem) {
  .pa-strip { padding-block: var(--pa-s-3); }
  .pa-token { width: 1.75rem; height: 1.75rem; }
  .pa-strip__n { position: static; width: auto; height: auto; clip: auto; overflow: visible; }
  .pa-strip__use { padding-inline: var(--pa-s-5); }
}
@media (prefers-reduced-motion: reduce) {
  .pa-token.is-going { animation: none; }
}

/* ---- rewarded sheet --------------------------------------------------
   Built by pa-ads.js, never written into a page. A pa-sheet with two states:
   the offer and the spot. The offer is set as a receipt — what you get at
   the title step, then the price and the balance as two ruled rows with
   their labels in the meta voice — so the trade is read before it is made,
   the way a paper prints an offer: terms first, coupon under. The spot then
   plays in the sheet's own host. No display ad ever sits in here. */

.pa-reward { padding: var(--pa-s-4) var(--pa-s-4) var(--pa-s-5); }
.pa-reward__what {
  margin: 0;
  font: 700 var(--pa-size-title)/1.25 var(--pa-serif);
  color: var(--pa-ink);
  text-wrap: balance;
}
.pa-reward__terms {
  display: grid;
  grid-template-columns: auto 1fr;
  margin: var(--pa-s-4) 0 0;
  border-top: 1px solid var(--pa-rule);
}
.pa-reward__terms > div {
  display: contents;
}
.pa-reward__terms dt,
.pa-reward__terms dd {
  margin: 0;
  padding: var(--pa-s-2) 0;
  border-bottom: 1px solid var(--pa-rule);
  line-height: 1.5;
}
.pa-reward__terms dt {
  font: 400 var(--pa-size-meta)/1.5 var(--pa-sans);
  letter-spacing: 0.07em;
  color: var(--pa-ink-2);
  padding-top: calc(var(--pa-s-2) + 0.15em);
}
.pa-reward__terms dd {
  padding-inline-start: var(--pa-s-5);
  font: 400 var(--pa-size-body)/1.5 var(--pa-sans);
  color: var(--pa-ink);
}
.pa-reward__terms dd .pa-reward__last { color: var(--pa-red-deep); }
.pa-reward__actions {
  display: flex;
  gap: var(--pa-s-2);
  flex-wrap: wrap;
  margin-top: var(--pa-s-5);
}
.pa-reward__actions .pa-btn--primary { flex: 1 1 12rem; }
.pa-reward__host { width: 100%; }
.pa-reward__host[hidden], .pa-reward__offer[hidden] { display: none; }
