/* site.css — small extensions to victoria.css for site-shell components the
   mock doesn't define: the authenticated user's dropdown menu, the Django
   messages framework, and the stale-data banner (docs/PAGES.md §0).
   victoria.css itself is ported verbatim and never forked (AGENTS.md §6);
   new components live here instead, using the same `v-` vocabulary and the
   existing design tokens. */

/* Alpine hides x-cloak elements only once it boots; this rule hides them
   before that so the user menu never flashes open on load. */
[x-cloak] {
  display: none !important;
}

/* `.v-btn`'s own `display: inline-flex` (victoria.css) and the browser's
   default `[hidden] { display: none }` rule have equal CSS specificity,
   and an author stylesheet always beats the user-agent one — so a hidden
   `.v-btn` stayed visible regardless of source order (found via the
   no-JS screenshot check for the map panel's collapse/expand toggle,
   feedback-2026-08-18 WO-F4.1; also affects map-viewer.js's pre-existing
   fullscreen-button hide when the browser has no Fullscreen API). */
.v-btn[hidden] {
  display: none !important;
}

/* --- User chip dropdown --------------------------------------------------- */

.v-user-menu {
  position: relative;
}
.v-user-menu img.v-avatar {
  object-fit: cover;
}
.v-user-menu__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--v-2);
  background: var(--v-panel-dark-2);
  border: var(--v-border);
  border-radius: var(--v-radius);
  box-shadow: var(--v-shadow-lg);
}
.v-user-menu__panel form {
  margin: 0;
}
.v-user-menu__item {
  display: block;
  width: 100%;
  padding: var(--v-2) var(--v-3);
  font-family: var(--v-font-body);
  font-size: var(--v-fs-sm);
  color: var(--v-cream);
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--v-radius);
  cursor: pointer;
}
.v-user-menu__item:hover {
  background: rgba(194, 161, 90, 0.16);
  color: var(--v-gold-bright);
  text-decoration: none;
}

/* --- Django messages framework -------------------------------------------- */

.v-messages {
  padding-block: var(--v-4) 0;
  display: flex;
  flex-direction: column;
  gap: var(--v-2);
}
.v-message {
  padding: var(--v-3) var(--v-4);
  border: 1px solid var(--v-gold-dim);
  border-left-width: 4px;
  border-radius: var(--v-radius);
  background: var(--v-panel-dark);
  color: var(--v-cream);
  font-size: var(--v-fs-sm);
}
.v-message--success {
  border-left-color: var(--v-green);
}
.v-message--error {
  border-left-color: var(--v-red);
}
.v-message--warning {
  border-left-color: var(--v-gold);
}
.v-message--info,
.v-message--debug {
  border-left-color: var(--v-blue);
}

/* --- Footer health line (PAGES.md §0) ------------------------------------- */

.v-health {
  margin: 0 0 var(--v-2);
}
.v-health__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: baseline;
}
.v-health__dot--live {
  background: var(--v-green);
}
.v-health__dot--refreshing {
  background: var(--v-gold);
}
.v-health__dot--unavailable {
  background: var(--v-cream-2);
  opacity: 0.5;
}

/* --- Stale-data banner (PAGES.md §0) -------------------------------------- */

.v-stale-banner {
  padding: var(--v-3) var(--v-4);
  text-align: center;
  font-size: var(--v-fs-sm);
  color: var(--v-cream);
  background: var(--v-maroon-2);
  border-bottom: 1px solid var(--v-gold-dim);
}

/* --- Notice-page shell (error pages, interstitials) ------------------------ */

/* The centred framed-card layout the mock uses inline on its 404; shared by
   the error pages so the shell isn't copy-pasted per template. */
.v-notice-page {
  display: grid;
  place-items: center;
  min-height: 70vh;
}
.v-notice-page > .v-paper {
  max-width: 520px;
}

/* --- Pagination (templates/common/pagination.html) ------------------------- */

.v-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--v-2);
  padding-block: var(--v-4);
  flex-wrap: wrap;
}
.v-pager__pages {
  display: inline-flex;
  align-items: center;
  gap: var(--v-1);
}
.v-pager__current {
  min-width: 28px;
  text-align: center;
}
.v-pager__ellipsis {
  color: var(--v-ink-2);
  padding-inline: var(--v-1);
}

/* === Phase 2: timeline — owned by apps/timeline ========================== */

/* The whole card is the expand affordance (PAGES.md §2 "cards are
   clickable"): the title link stretches over the card; buttons and the
   title itself sit above the stretched hit area. */
.v-event__card {
  position: relative;
}
.v-event__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}
.v-event__card .v-btn,
.v-event__title a {
  position: relative;
  z-index: 1;
}
.v-event__title a::after {
  z-index: 0;
}

/* Era header — breaks out of the year gutter to span the full spine width,
   marking where the stream crosses into the era's span (PAGES.md §2). */
.v-timeline__era {
  position: relative;
  margin: var(--v-6) 0 var(--v-4) -92px;
  padding: var(--v-3) var(--v-4);
  background: rgba(43, 36, 28, 0.06);
  border-top: var(--v-border);
  border-bottom: var(--v-border);
}
.v-timeline__era:first-child {
  margin-top: 0;
}
.v-timeline__era-title {
  margin: 0;
  font-family: var(--v-font-display);
  font-size: var(--v-fs-lg);
}
.v-timeline__era-years {
  font-size: var(--v-fs-sm);
  color: var(--v-ink-3);
  font-weight: normal;
}
.v-timeline__era-desc {
  margin-top: var(--v-2);
  font-size: var(--v-fs-sm);
  color: var(--v-ink-2);
}

/* Soft-deleted events, staff view only (PAGES.md §2) — dimmed, never hidden
   from the staff who need the Restore button. */
.v-event--hidden .v-event__card {
  opacity: 0.55;
}
.v-tag--muted {
  color: var(--v-ink-3);
}

/* A real uploaded thumbnail dropped into the mock's placeholder slot. */
img.v-event__thumb {
  object-fit: cover;
  border-radius: var(--v-radius);
}

/* Expanded card: room for the full body, image, and staff actions. */
.v-event__card--expanded {
  flex-direction: column;
}
.v-event__image {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--v-radius);
  margin: var(--v-3) 0;
}
.v-event__meta {
  margin: 0 0 var(--v-2);
}
.v-event__prose :is(p, ul, ol, blockquote, table) {
  margin: 0 0 var(--v-3);
}
.v-event__prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--v-radius);
}

/* The inline add/edit form card mirrors the mock's admin panel fields
   inside a timeline card instead of a separate panel (edit replaces the
   card in place — PAGES.md §2). */
.v-event__card--form {
  flex-direction: column;
}
.v-field-error {
  color: var(--v-red);
  font-size: var(--v-fs-xs);
}

@media (max-width: 820px) {
  .v-timeline__era {
    margin-left: calc(-1 * var(--v-5));
  }
}

/* === Phase 2: world map viewer — owned by apps/world ===================== */

/* The pan/zoom container: a fixed-aspect frame that clips the zoomed/panned
   stage. panzoom (static/js/map-viewer.js) attaches to `__stage` and drives
   it with a CSS transform; the frame just clips and anchors the controls. */
.v-map-viewer__frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--v-radius);
  background: #0b0906;
  aspect-ratio: 16 / 9;
  max-height: 78vh;
}
.v-map-viewer__stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  transform-origin: 0 0;
  cursor: grab;
  touch-action: none;
}
.v-map-viewer__stage:active {
  cursor: grabbing;
}
.v-map-viewer__img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}
.v-map-viewer__controls {
  position: absolute;
  right: var(--v-3);
  bottom: var(--v-3);
  z-index: 2;
  display: flex;
  gap: var(--v-2);
}
.v-map-viewer__controls .v-btn {
  min-height: 36px;
  padding: var(--v-1) var(--v-3);
}
.v-map-panel__caption {
  margin: var(--v-2) 0 0;
}

/* Collapsible map panel (PAGES.md §3.1, feedback-2026-08-18 WO-F4.1): the
   `.is-collapsed` state map-viewer.js adds after confirming JS is running
   (server-rendered markup is always the expanded form — progressive
   enhancement). Crops the frame to a short strip rather than scaling the
   image down: the stage keeps `width:100%` (static/js/map-viewer.js
   doesn't touch it), so a shorter `overflow:hidden` frame just shows less
   of the same full-scale image — "cropped, not squashed". */
.v-map-panel--collapsible.is-collapsed .v-map-viewer__frame {
  aspect-ratio: auto;
  height: 260px;
  max-height: 260px;
}
.v-map-panel--collapsible.is-collapsed .v-map-viewer__controls {
  display: none; /* reset/fullscreen serve no purpose on a cropped preview */
}

/* Fullscreen: the frame fills the viewport; the small vendor-prefixed
   selectors cover older WebKit (map-viewer.js falls back the same way). */
.v-map-viewer__frame:fullscreen,
.v-map-viewer__frame:-webkit-full-screen {
  aspect-ratio: auto;
  max-height: none;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

/* The era-maps strip (contract with apps/timeline — templates/world/era_maps.html) */
.v-era-maps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--v-3);
}
.v-era-maps__item {
  display: flex;
  align-items: center;
  gap: var(--v-2);
  padding: var(--v-1) var(--v-2);
  border: 1px solid var(--v-gold-dim);
  border-radius: var(--v-radius);
  text-decoration: none;
  color: inherit;
  background: rgba(0, 0, 0, 0.15);
}
.v-era-maps__item:hover {
  border-color: var(--v-gold);
  text-decoration: none;
}
.v-era-maps__thumb {
  width: 64px;
  height: 40px;
  object-fit: cover;
  border-radius: 2px;
  display: block;
  flex: none;
}
.v-era-maps__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.v-era-maps__label {
  font-family: var(--v-font-display);
  font-size: var(--v-fs-sm);
}

/* --- Collapsed filter toolbar (WO-F9, feedback-2026-08-18) --------------- */
/* Wraps a page's filter form in a native <details>/<summary> so search and
   every filter start hidden behind one "Filters" control, no JS required —
   apps/common/templatetags/filter_toolbar.py's `{% filter_toolbar %}`
   block tag emits this markup for the world directory, character
   database, and timeline toolbars alike. Built on `.v-panel`/
   `.v-panel__head`/`.v-panel__body` (victoria.css) for the frame/surface;
   only the summary's disclosure triangle and the count text are new. */
details.v-filter-toggle {
  overflow: hidden;
}
.v-filter-toggle__summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.v-filter-toggle__summary::-webkit-details-marker {
  display: none;
}
.v-filter-toggle__summary::marker {
  content: "";
}
.v-filter-toggle__caret {
  display: inline-block;
  flex: none;
  width: 0.6em;
  transition: transform 0.15s ease;
  transform: rotate(0deg);
}
.v-filter-toggle__caret::before {
  content: "\25B8"; /* ▸ */
}
details.v-filter-toggle[open] > .v-filter-toggle__summary .v-filter-toggle__caret {
  transform: rotate(90deg);
}
.v-filter-toggle__summary:focus-visible {
  outline: 2px solid var(--v-gold-bright);
  outline-offset: -2px;
}
/* Decorative pill echoing the count that already sits in the summary's own
   text ("Filters (3)") — reinforcement for a sighted user skimming the
   page, never the only place the number appears. A real `aria-hidden`
   `<span>` (filter_toolbar.py), not CSS `content: attr()`: Chromium folds
   generated pseudo-element content into the accessible name, which would
   have announced the count twice ("Filters (1) 1" — caught via an
   accessibility-tree dump during WO-F9 QA). `aria-hidden` on a real node
   is the one way to keep it decoration-only. */
.v-filter-toggle__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4em;
  padding: 0 5px;
  margin-left: auto;
  border: 1px solid var(--v-gold-dim);
  border-radius: 999px;
  background: var(--v-gold-dim);
  color: var(--v-panel-dark);
  font-size: var(--v-fs-xs);
  font-weight: 700;
}
