/* Player view (PV): pages opened by the player view (?pv=1), the GM's
   controls beside the profile menu, and the screen itself (/pv/<key>).
   Unlayered, so these rules win over the layered site styles. */

/* ---- Presentation mode: only the page's content, nothing GM-facing.
   Mark anything that should stay off the player view with .pv-hide. */

html.pv-present .top-nav,
html.pv-present .left-panel,
html.pv-present .status-bar,
html.pv-present .view-actions,
html.pv-present .pv-control,
html.pv-present .pv-hide {
  display: none !important;
}

html.pv-present .app {
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}

html.pv-present .workspace {
  grid-template-columns: minmax(0, 1fr);
  background: var(--surface);
}

html.pv-present body {
  background: var(--surface);
}

html.pv-present,
html.pv-present * {
  scrollbar-width: none;
}

/* ---- GM controls (top bar, beside the profile menu) */

.pv-control {
  display: flex;
  align-items: stretch;
}

.pv-control .tool-button {
  gap: 7px;
  padding: 0 12px;
  white-space: nowrap;
}

.pv-show:disabled {
  cursor: default;
  opacity: 0.45;
}

.pv-show:disabled:hover {
  background: transparent;
  color: var(--text-secondary);
}

.pv-show.is-live {
  background: var(--semantic-success-bg);
  box-shadow: inset 0 -3px 0 var(--semantic-success-border);
  color: var(--semantic-success-text);
}

.pv-switch {
  position: relative;
  width: 22px;
  height: 12px;
  border-radius: 6px;
  background: var(--border);
  transition: background 0.15s;
}

.pv-switch::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-raised);
  content: "";
  transition: transform 0.15s;
}

.pv-follow[aria-pressed="true"] {
  color: var(--semantic-success-text);
}

.pv-follow[aria-pressed="true"] .pv-switch {
  background: var(--semantic-success-border);
}

.pv-follow[aria-pressed="true"] .pv-switch::after {
  transform: translateX(10px);
}

.pv-menu {
  display: block;
}

.pv-menu summary {
  min-width: 30px;
}

.pv-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.5;
}

/* Connected, but no screen is open. */
.pv-dot.is-ready {
  background: var(--semantic-warning-border);
  opacity: 1;
}

/* At least one screen is watching. */
.pv-dot.is-on {
  background: var(--semantic-success-border);
  opacity: 1;
}

.pv-control.is-blackout .pv-dot {
  background: #000;
  box-shadow: 0 0 0 2px var(--semantic-danger-border);
  opacity: 1;
}

.pv-panel {
  min-width: 250px;
}

.pv-status {
  margin: 0;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.9em;
  line-height: 1.35;
  padding: 8px 12px;
}

.pv-status input {
  width: 100%;
  margin-top: 6px;
  font: inherit;
}

.pv-panel [data-pv-blackout][aria-pressed="true"] {
  background: var(--semantic-danger-bg);
  color: var(--semantic-danger-text);
}

@media (max-width: 900px) {
  .pv-control .pv-label {
    display: none;
  }
}

/* ---- The screen (/pv/<key>) */

html.pv-shell-root,
body.pv-shell {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
}

body.pv-shell {
  color: #cfd6e0;
  font-family: Cambria, Georgia, "Times New Roman", serif;
}

body.pv-shell.is-idle {
  cursor: none;
}

.pv-frame {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.pv-frame.is-shown {
  opacity: 1;
}

.pv-splash {
  position: fixed;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  text-align: center;
  transition: opacity 0.35s;
}

.pv-splash.is-hidden {
  opacity: 0;
}

.pv-splash img {
  border-radius: 50%;
  opacity: 0.8;
}

.pv-splash p {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.02em;
}

.pv-splash small {
  color: #7d8796;
}

.pv-blackout {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s;
}

.pv-blackout.is-on {
  opacity: 1;
}

.pv-offline {
  position: fixed;
  right: 12px;
  bottom: 10px;
  margin: 0;
  border-radius: 4px;
  background: rgb(0 0 0 / 65%);
  color: #d6dde8;
  font: 13px system-ui, sans-serif;
  padding: 4px 10px;
}

/* ---- Maps: the GM's cursor and pen (player-view.js pv.map) */

.pv-map-overlay {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.pv-cursor {
  fill: #ff4d2e;
  stroke: #fff;
  stroke-width: 2.5;
}

.pv-pen-halo,
.pv-pen-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 1s;
}

.pv-pen-halo {
  stroke: rgb(255 255 255 / 85%);
  stroke-width: 8;
}

.pv-pen-line {
  stroke: #ff4d2e;
  stroke-width: 4;
}

.pv-pen-halo.is-fading,
.pv-pen-line.is-fading {
  opacity: 0;
}

/* Shift over a map: drawing, not panning */
.pv-pen-ready,
.pv-pen-ready * {
  cursor: crosshair !important;
}

/* ---- Dice on the player view (routes/dice.ts): the table's rolls as they
   come in, the newest one large. The roller's controls are .pv-hide. */

html.pv-present .dice-layout {
  grid-template-columns: minmax(0, 1fr);
  width: min(100%, 980px);
  margin: 0 auto;
}

html.pv-present .dice-history-panel {
  padding: 24px;
}

html.pv-present .dice-history-panel h2 {
  font-size: 1.6rem;
}

html.pv-present .dice-history {
  gap: 10px;
}

html.pv-present .dice-history-item {
  grid-template-columns: 84px minmax(0, 1fr);
  font-size: 1.15rem;
  padding: 10px 12px;
}

html.pv-present .dice-history-total {
  width: 84px;
  height: 84px;
  font-size: 2.6rem;
}

html.pv-present .dice-history-summary span,
html.pv-present .dice-history-detail {
  font-size: 1rem;
}

html.pv-present .dice-history-item:first-child {
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 22px;
  font-size: 1.7rem;
  padding: 18px 22px;
  animation: pv-dice-in 0.35s ease-out;
}

html.pv-present .dice-history-item:first-child .dice-history-total {
  width: 150px;
  height: 150px;
  border-width: 2px;
  font-size: 5rem;
}

html.pv-present .dice-history-item:first-child .dice-history-summary span,
html.pv-present .dice-history-item:first-child .dice-history-detail {
  font-size: 1.2rem;
}

@keyframes pv-dice-in {
  from {
    opacity: 0.3;
    transform: scale(0.94);
  }
}

@media (prefers-reduced-motion: reduce) {
  html.pv-present .dice-history-item:first-child {
    animation: none;
  }
}
