/* public/css/styles.css
   The canvas and the tokens on it, shared by the DM and player views.
   DM chrome lives in dm.css. */

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

body {
  margin: 0;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Roboto', ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* --- Scrollbars ---
   Thin and unobtrusive everywhere, rather than per-container overrides. */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* --- Canvas --- */

#scene-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  transition: background-color 0.5s var(--ease);

  user-select: none;
  -webkit-user-select: none;
}

/* Camera anchor. Everything in the scene hangs off this one element, so pan
   and zoom cost a single composited transform. */
.world {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1; /* above the empty state, below the marquee */
  transform-origin: 0 0;

  /* One screen pixel in world units, written by SceneRenderer. Token chrome
     multiplies by it to keep its weight at any zoom. */
  --px: 1;
}

/* Pinned to the world origin: the transform carries position and rotation both.
   No transition on it, since script eases remote movement itself. */
.token {
  position: absolute;
  top: 0;
  left: 0;
  transition: opacity var(--dur) var(--ease), filter var(--dur) var(--ease);
}

/* --- Token state (DM view) ---
   Two channels that never collide: a ring says who may move a token, the fade
   says whether players can see it. A token can be both and reads as both.

   Outlines and shadows only. A border would come out of the token's declared
   size, insetting the media and leaving a dead band inside every ring. */

.token.is-selected {
  outline: calc(2px * var(--px)) solid var(--accent);
}

.token.is-interactive:hover:not(.is-selected) {
  outline: calc(1px * var(--px)) solid var(--border-strong);
}

/* Hover lifts anything you can grab. drop-shadow follows the artwork's alpha,
   haloing a cut-out rather than the rectangle it sits in. Only the hovered
   token carries a filter. */
.token.is-interactive:hover {
  filter: drop-shadow(0 0 calc(9px * var(--px)) rgba(0, 0, 0, 0.65));
}

.token.is-hidden {
  opacity: 0.4;
  filter: saturate(0.35);
}

.token.is-hidden.is-interactive:hover {
  filter: saturate(0.35) drop-shadow(0 0 calc(9px * var(--px)) rgba(0, 0, 0, 0.65));
}

/* Ring plus glow, so released tokens stand out. A shadow rather than an
   outline, so a selected token can show both. */
.token.is-movable {
  box-shadow: 0 0 0 calc(2px * var(--px)) var(--movable),
    0 0 calc(11px * var(--px)) calc(2px * var(--px)) var(--movable-glow);
}

/* Pushed out, so the selection outline keeps hugging the artwork. */
.token.is-selected.is-movable {
  box-shadow: 0 0 0 calc(4px * var(--px)) var(--movable),
    0 0 calc(11px * var(--px)) calc(4px * var(--px)) var(--movable-glow);
}

/* --- Marquee --- */

#marquee {
  position: absolute;
  z-index: 50;
  display: none;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: var(--accent-dim);
  pointer-events: none;
}

#marquee.active {
  display: block;
}

/* --- Audio gate ---
   Browsers refuse to play audio until the page has been interacted with, so
   players are asked once, up front. */

#audio-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(22, 23, 26, 0.85);
  backdrop-filter: blur(4px);
}

#enable-audio-button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 34px;
  border: none;
  border-radius: var(--radius);
  background-color: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}

#enable-audio-button:hover {
  background-color: var(--accent-hover);
}

#enable-audio-button span {
  font-size: 22px;
}

/* --- Announcements (player view) ---
   A title card, not a notification: said once in the middle of the screen and
   then gone. Fade in, hold, and fade out are one animation. */

#announcements {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;

  /* Off dead center: the middle of the screen is where the map is. */
  padding-bottom: 12vh;

  /* Never takes a click that belonged to the map. */
  pointer-events: none;
}

.announcement {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: min(680px, 84vw);

  /* The padding is room for the scrim to fade out in, so it reads as a
     darkening rather than a box. Invisible over a dark map, legibility over
     a bright one. */
  padding: 40px 80px;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.5),
    rgba(0, 0, 0, 0.26) 46%,
    transparent 72%
  );
  text-align: center;

  /* Four tenths in, a beat to read it, most of a second to dissolve. */
  animation: announce 2.4s var(--ease) both;
}

@keyframes announce {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  18% {
    opacity: 1;
    transform: none;
  }
  /* Holds until here, then dissolves: ease-in so it lingers before it goes. */
  65% {
    opacity: 1;
    transform: none;
    animation-timing-function: ease-in;
  }
  to {
    opacity: 0;
    transform: translateY(-7px) scale(1.015);
  }
}

/* The panel headers' label, tracked wider for a title. Full strength, not
   dimmed: at 11px over artwork, dim text loses to its own shadow. */
.announcement-label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-shadow: 0 1px 7px rgba(0, 0, 0, 0.6);
}

/* Takes the label's color; the two are one line. */
.announcement-icon {
  display: flex;
  flex: none;
}

.announcement-icon svg {
  display: block;
  width: 13px;
  height: 13px;
}

/* The shadow is legibility over artwork, so it is a halo, not a drop. */
.announcement-name {
  font-size: clamp(26px, 3.6vw, 40px);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.15;
  text-wrap: balance;
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.8), 0 1px 4px rgba(0, 0, 0, 0.55);
}
