/* ========================================================================== */
/* 1. BASE & RESET                                                            */
/* ========================================================================== */

/*
 * --base-bg / overlay system
 * --------------------------
 * The site uses a layered background:
 *
 *   body::before  - the optional collection/article hero image (z=-2)
 *                   only present when <body class="has-bg"> and the
 *                   --bg-image custom property is set.
 *   body::after   - a translucent tint (white in light mode, near-black
 *                   in dark mode) sitting on top of that image (z=-1).
 *   body          - paints --base-bg as the base colour for pages with
 *                   no background image.
 *
 * Because the dark-mode tint is rgba(17,17,17,0.65) and is composited
 * over the base, the base itself stays light (#fafafa) in both themes.
 * Changing it to a darker colour would double-darken when an image is
 * present.
 */

:root {
  --base-bg: #fafafa;

  --header-offset: 0px;

  --icon-unit: 24px;
  --icon-svg-scale: 1;
  --icon-spacing-factor: 0.9;

  --icon-spacing: calc(var(--icon-unit) * var(--icon-spacing-factor));
  --list-spacing: calc(var(--icon-unit) * var(--icon-spacing-factor));
  --group-spacing: calc(var(--icon-unit) * var(--icon-spacing-factor));

  --glass-overhang-factor: 0.4;

  --glass-inset-y: calc(var(--icon-unit) * -0.4);
  --glass-inset-x: calc(var(--icon-unit) * var(--glass-overhang-factor) * -1);
  --glass-radius: calc(var(--icon-unit) * 0.9);

  /* Animation durations -- single source of truth so JS and CSS agree. */
  --anim-page-fade: 0.6s;
  --anim-glow: 0.7s;
  --anim-icon-pop: 0.7s;
  --anim-filmstrip-slide: 1s;
}

body[data-theme="dark"] {
  /* Stays light — the body::before overlay (rgba(17,17,17,0.65))
     composites over this to produce a dark-grey appearance.        */
  --base-bg: #fafafa;
}

html {
  background: var(--load-bg, var(--base-bg));
  overflow-y: scroll;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Set by inline <script> in <head> before first paint — prevents white flash.
   Only <html> gets the solid dark fill; <body> must keep var(--base-bg)
   (#fafafa) so the body::before overlay (rgba(17,17,17,0.65)) can composite
   over it to the intended dark-grey rather than near-black.

   --load-bg is an optional per-site override (sitedata `loadcolour`) applied
   before paint. Sites whose eventual background is dark (a game or dark image)
   set it so the page loads in that colour instead of flashing grey/white while
   the real background is still loading. Sites without it keep the grey. */
html[data-theme="dark"] {
  background: var(--load-bg, #111111);
}

/* Robust backdrop for background-LESS pages.
   The root element always paints across the whole viewport, including regions
   where the fixed body::before tint momentarily fails to cover — notably iOS
   Safari during SPA view transitions and rubber-band overscroll. There, the
   root's colour shows through, so it must match the page rather than be a bare
   #111 (which flashes black against the grey page in dark mode).

   A background-less dark page renders as the grey composite of the #fafafa base
   under the rgba(17,17,17,0.65) ::before tint — i.e. 0.65·17 + 0.35·250 ≈ 99 —
   so we match the root to that grey. Pages WITH a background (.has-bg /
   .has-game-bg) keep the #111 / loadcolour backstop, which their background
   covers. Those classes are only added once the image/game is ready, so the
   brief transition gap before they appear is still covered by this grey too.
   (If --base-bg or the tint above ever change, update the 99 to match.) */
html[data-theme="dark"]:not(:has(body.has-bg)):not(:has(body.has-game-bg)) {
  background: var(--load-bg, rgb(99, 99, 99));
}

body {
  margin: 0;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;
  /* Always fill the viewport so a short page (e.g. a collection still loading
     its data) never leaves the area below the content exposing the bare canvas
     backdrop — which flashes dark during navigation on background-less pages.
     Pages with a background are covered by their fixed image/tint layers; this
     gives background-less pages the same guarantee. box-sizing keeps the
     safe-area padding from pushing past the viewport and adding scroll. */
  box-sizing: border-box;
  min-height: 100vh;
  min-height: 100dvh;
  text-size-adjust: 100%;
  font-family: var(--body-font, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  font-size: var(--body-size, 1rem);
  overflow-x: hidden;
  position: relative;
  z-index: 0;
  background: var(--load-bg, var(--base-bg));
  color: var(--body-colour, #222);
  transition: background 0.3s ease, color 0.3s ease;
  opacity: 0;
}

body.page-loaded {
  opacity: 1;
  transition: opacity 0.4s ease;
}

body[data-theme="dark"] {
  color: var(--body-colour, #eee) !important;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* No-background tint. Scoped to :not(.has-bg) because when a background image
   is active it lives on body.has-bg::before — an unscoped dark rule here
   (html[data-theme="dark"] body::before) would out-specify the image rule and
   replace the image with a solid tint, hiding the background in dark mode. */
body:not(.has-bg)::before {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: -1;
  inset: calc(env(safe-area-inset-top) * -1) 0 calc(env(safe-area-inset-bottom) * -1) 0;
  background: rgba(255, 255, 255, 0.75);
}

html[data-theme="dark"] body:not(.has-bg)::before {
  background: rgba(17, 17, 17, 0.65);
}

body.has-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: var(--bg-image) center center / cover no-repeat;
}

body.has-bg::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.75);
  transition: background 0.3s;
}

html[data-theme="dark"] body.has-bg::after {
  background: rgba(17, 17, 17, 0.65);
}


/* ========================================================================== */
/* 2. LAYOUT CONTAINERS                                                       */
/* ========================================================================== */

header,
main,
footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1rem;
}

header {
  padding-top: 4.5rem;
  padding-bottom: 0.5rem;
}

body[data-page="reader"] header,
body[data-page="reader"] main,
body[data-page="reader"] #reader-content,
body[data-page="reader"] .pdf-glass,
body[data-page="reader"] .pdf-glass > div {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.page-section {
  margin: 5rem 0;
  scroll-margin-top: calc(4.5rem + 1rem);
}

main > .page-section:first-child {
  margin-top: 0.5rem;
  margin-bottom: 0;
}

main > .page-section:nth-child(2) {
  margin-top: calc(10vh + 1.5rem + var(--bottom-bar-offset, 0px));
}

/* ========================================================================== */


/* --- Print -------------------------------------------------------------- */

@media print {
  .top-bar-fixed,
  .bottom-bar-fixed,
  footer {
    display: none;
  }

  body::before,
  body::after,
  body.has-bg::before,
  body.has-bg::after {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }
}
/* 3. TYPOGRAPHY & LINKS                                                      */
/* ========================================================================== */

h1 {
  font-family: var(--heading-font, inherit);
  font-size: var(--heading-size, 2em);
  color: var(--heading-colour, inherit);
}

h2 {
  font-family: var(--subheading-font, inherit);
  font-size: var(--subheading-size, 1.5em);
  color: var(--subheading-colour, inherit);
}

h3, h4, h5, h6 {
  font-family: var(--subheading-font, inherit);
  color: var(--subheading-colour, inherit);
}

a,
a:visited {
  font-family: var(--link-font, inherit);
  font-size: var(--link-size, inherit);
  color: var(--link-colour, #333);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

body[data-theme="dark"] a,
body[data-theme="dark"] a:visited {
  color: var(--link-colour, #9ecbff);
}

body[data-theme="dark"] a:hover {
  color: #cfe4ff;
}

body[data-theme="dark"] a.icon-button,
body[data-theme="dark"] a.icon-button:visited,
body[data-theme="dark"] a.icon-button:hover {
  color: #eee !important;
}

/* ========================================================================== */

/* 4. TOP BAR SYSTEM                                                          */
/* ========================================================================== */

body[data-theme="light"] {
  --glass-bg: rgba(255, 255, 255, 0.50);
  --glass-border: rgba(0, 0, 0, 0.10);
  --glass-specular: rgba(255, 255, 255, 0.90);
  --glass-blur: 20px;
  --glass-saturate: 180%;
  --glass-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  --glass-fg: #111;
}

body[data-theme="dark"] {
  --glass-bg: rgba(0, 0, 0, 0.30);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-specular: rgba(255, 255, 255, 0.25);
  --glass-blur: 20px;
  --glass-saturate: 180%;
  --glass-shadow: 0 6px 20px rgba(0, 0, 0, 0.40);
  --glass-fg: #fff;
}

.top-bar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: var(--group-spacing);
  isolation: isolate;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: var(--icon-spacing);
}

.icon-list {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: var(--icon-list-justify, flex-start);
  gap: var(--list-spacing);
  width: var(--icon-list-width, auto);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  /* fade-out: opacity goes first, then visibility flips after it completes */
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

.icon-list.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  position: relative;
  isolation: isolate;
  /* fade-in: visibility flips immediately so the element is interactive
     while the opacity ramps up */
  transition: opacity 0.25s ease;
}

.icon-list.active::before {
  content: "";
  position: absolute;
  inset: var(--glass-inset-y) var(--glass-inset-x);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-top-color: var(--glass-specular, var(--glass-border));
  border-radius: var(--glass-radius);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate, 100%));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate, 100%));
  box-shadow: var(--glass-shadow);
  z-index: -1;
  pointer-events: none;
}

/* Edge-thickening lens effect: a heavier blur layer masked to the perimeter,
   simulating the increased refraction of thick glass at its edges. */
.icon-list.active::after {
  content: "";
  position: absolute;
  inset: var(--glass-inset-y) var(--glass-inset-x);
  border-radius: var(--glass-radius);
  backdrop-filter: blur(50px) saturate(220%);
  -webkit-backdrop-filter: blur(50px) saturate(220%);
  mask-image: radial-gradient(ellipse at center, transparent 55%, black 100%);
  -webkit-mask-image: radial-gradient(ellipse at center, transparent 55%, black 100%);
  z-index: -1;
  pointer-events: none;
}

/* --- Glow animation (moved into Top Bar section) -------------------------- */

.icon-list.active.glow::before {
  animation: iconGlowFlash var(--anim-glow) ease-out;
}

@keyframes iconGlowFlash {
  0% {
    box-shadow: var(--glass-shadow);
    filter: brightness(1.0);
    transform: scale(1);
  }
  10% {
    box-shadow: 0 0 28px 10px rgba(255, 255, 255, 0.35),
                0 4px 16px rgba(255, 255, 255, 0.22);
    filter: brightness(1.4);
    transform: scaleX(var(--glow-scale-peak-x,   1.25)) scaleY(var(--glow-scale-peak-y,   1.25));
  }
  45% {
    box-shadow: 0 0 6px 3px rgba(255, 255, 255, 0.10),
                0 4px 16px rgba(255, 255, 255, 0.05);
    filter: brightness(1.05);
    transform: scaleX(var(--glow-scale-bounce-x, 0.9))  scaleY(var(--glow-scale-bounce-y, 0.9));
  }
  65% {
    box-shadow: 0 0 1px 0px rgba(255, 255, 255, 0.03),
                0 4px 16px rgba(0, 0, 0, 0.08);
    filter: brightness(1.02);
    transform: scaleX(var(--glow-scale-settle-x, 1.03)) scaleY(var(--glow-scale-settle-y, 1.03));
  }
  100% {
    box-shadow: var(--glass-shadow);
    filter: brightness(1.0);
    transform: scale(1);
  }
}

/* Icon pop: scale up then bounce back to normal */
.icon-button.icon-pop .icon-svg {
  animation: iconPop var(--anim-icon-pop) ease-out;
}

@keyframes iconPop {
  0%   { transform: scale(var(--icon-svg-scale)); }
  10%  { transform: scale(calc(var(--icon-svg-scale) * 1.4)); }
  45%  { transform: scale(calc(var(--icon-svg-scale) * 0.9)); }
  65%  { transform: scale(calc(var(--icon-svg-scale) * 1.06)); }
  100% { transform: scale(var(--icon-svg-scale)); }
}

/* --- Icon swap: fade-in new button when icon changes mid-transition ------- */

.icon-button.icon-swap-in .icon-svg {
  animation: iconSwapIn 0.2s ease-out;
}

@keyframes iconSwapIn {
  from { opacity: 0; transform: scale(calc(var(--icon-svg-scale) * 0.6)); }
  to   { opacity: 1; transform: scale(var(--icon-svg-scale)); }
}

/* --- End glow animation block -------------------------------------------- */

.icon-list.inactive {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body:not(.js-ready) .icon-list {
  visibility: hidden;
}

.top-bar-fixed {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2rem);
  max-width: 960px;
  z-index: 250;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0.3rem 0.6rem;
}

.top-bar-fixed .top-bar {
  margin-bottom: 0;
}

.top-bar-fixed a,
.top-bar-fixed svg,
.top-bar-fixed span {
  color: var(--glass-fg);
  fill: var(--glass-fg);
}

.bottom-bar-fixed {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2rem);
  max-width: 960px;
  z-index: 250;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0.3rem 0.6rem;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.bottom-bar-fixed a,
.bottom-bar-fixed svg {
  color: var(--glass-fg);
  fill: var(--glass-fg);
}

/* CSS `display: flex` on .bottom-bar-fixed would otherwise beat `hidden`. */
#bottom-bar[hidden] { display: none !important; }

#bottom-bar .icon-list {
  gap: 0;
}

.bottom-bar-line {
  flex: 1;
  min-width: 0;
  height: var(--icon-unit);
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-left: calc(var(--icon-unit) * var(--glass-overhang-factor) * -1);
}

.bottom-bar-line path {
  fill: none;
}


/* ========================================================================== */
/* 5. BUTTONS & ICONS                                                         */
/* ========================================================================== */

.icon-button {
  width: var(--icon-unit);
  height: var(--icon-unit);
  flex: 0 0 var(--icon-unit);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: calc(var(--icon-unit) * 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  transition: background 0.2s ease;
}

/* Wide icons (e.g. logo): height stays at --icon-unit, width unconstrained. */
.icon-button--wide {
  width: auto;
  flex: 0 0 auto;
}
.icon-button--wide .icon-svg {
  width: auto;
  height: var(--icon-unit);
}

.icon-button:hover {
  background: rgba(0, 0, 0, 0.06);
}

body[data-theme="dark"] .icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Brief feedback after successful "copy link" */
.icon-button.copied {
  background: rgba(60, 180, 90, 0.18);
}
body[data-theme="dark"] .icon-button.copied {
  background: rgba(80, 200, 110, 0.20);
}

.icon-svg {
  width: var(--icon-unit);
  height: var(--icon-unit);
  transform: scale(var(--icon-svg-scale));
  transform-origin: var(--icon-origin, center);
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body[data-theme="dark"] a.icon-button .icon-svg,
body[data-theme="dark"] button.icon-button .icon-svg {
  stroke: #eee !important;
}

html[data-theme="light"] .icon-moon {
  display: none;
}

html[data-theme="dark"] .icon-sun {
  display: none;
}

/* ========================================================================== */

/* 6. HOMEPAGE (PAGE-SPECIFIC)                                                */
/* ========================================================================== */

.site-title {
  font-size: 1.5rem;
  font-weight: 400;
  margin: 0;
  color: inherit;
}

.site-title .site-symbol {
  height: 120px;
  width: auto;
  display: block;
}

.bio-sequence {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.section-icon-wrap {
  max-width: 65ch;
  display: flex;
  justify-content: center;
}

.section-icon {
  width: 4rem;
  height: 4rem;
  color: inherit;
}

.artist-photo {
  width: 200px;
  height: auto;
  border-radius: 0px;
  object-fit: cover;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.artist-summary {
  scroll-margin-top: calc(4.5rem + 1rem);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin: 0;
}

.artist-summary-text h1 {
  margin: 0;
  font-size: var(--heading-size, 1.8rem);
  line-height: 1.2;
}

.artist-location {
  margin: 0.25rem 0 0 0;
  font-weight: 600;
}

.bio {
  line-height: 1.7;
  max-width: 65ch;
  margin: 0;
}

.bio p + p {
  margin-top: 0.75rem;
}

/* Bullet lists in prose panes (rendered from markdown "- " items).
   Square markers in the site trim colour (falls back to the text colour when
   no trim colour is configured). */
:is(.bio, .collection-description, #image-description) ul {
  list-style: square;
  padding-left: 1.25rem;
}

:is(.bio, .collection-description, #image-description) ul li::marker {
  color: var(--trim-color, currentColor);
}

/* Frosted glass pane on biography / description text whenever a background
   (game or image) is active.  Uses the same glass variables as the top bar. */
:is(body.has-bg, body.has-game-bg) :is(.bio, .collection-description, #image-description) {
  backdrop-filter: blur(calc(0.5 * var(--glass-blur))) saturate(var(--glass-saturate, 100%));
  -webkit-backdrop-filter: blur(calc(0.5 * var(--glass-blur))) saturate(var(--glass-saturate, 100%));
  padding: 1rem;
  border-radius: 0px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-left-color: var(--trim-color, var(--glass-border));
  border-left-width: var(--trim-width, 1px);
}

:is(body.has-bg, body.has-game-bg) :is(.bio, .collection-description, #image-description) > :first-child {
  margin-top: 0;
}

:is(body.has-bg, body.has-game-bg) :is(.bio, .collection-description, #image-description) > :last-child {
  margin-bottom: 0;
}

/* A list entry's text block (title, date and comment) sits in the same
   frosted-glass pane as the bio/description when a background (game or image)
   is active, with the trim colour on the left edge. The cover image stays
   above the pane. */
:is(body.has-bg, body.has-game-bg) .collection-text {
  box-sizing: border-box;
  align-self: stretch;
  backdrop-filter: blur(calc(0.5 * var(--glass-blur))) saturate(var(--glass-saturate, 100%));
  -webkit-backdrop-filter: blur(calc(0.5 * var(--glass-blur))) saturate(var(--glass-saturate, 100%));
  padding: 0.5rem 1rem 1rem;
  border-radius: 0px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-left-color: var(--trim-color, var(--glass-border));
  border-left-width: var(--trim-width, 1px);
}

:is(body.has-bg, body.has-game-bg) .collection-text > :first-child {
  margin-top: 0;
}

:is(body.has-bg, body.has-game-bg) .collection-text > :last-child {
  margin-bottom: 0;
}

#collections-list,
#articles-list {
  --cover-max: 360px;
  padding: 0;
  list-style: none;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--cover-max)), var(--cover-max)));
  gap: 1.5rem;
  justify-content: start;
}

/* Tighten the gap between the list heading and the rule below it (overrides the
   default h2 bottom margin for just these list headings). */
h2:has(+ #collections-list),
h2:has(+ #articles-list) {
  margin-bottom: 0.4rem;
}

/* Trim-coloured rule between the list heading and the first row of covers.
   It occupies its own (full-width) grid row so the covers flow beneath it, but
   its visible width is --list-rule-width — set by JS (sizeListRules) to the
   exact span of the covers in the first row, so a partly-filled single row
   (e.g. one entry with room for two columns) gives a one-column-wide line.
   Falls back to the full width before JS runs / if unset. */
#collections-list::before,
#articles-list::before {
  content: "";
  grid-column: 1 / -1;
  justify-self: start;
  width: var(--list-rule-width, 100%);
  height: var(--trim-width, 1px);
  background: var(--trim-color, currentColor);
}

#collections-list li,
#articles-list li {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  /* Gap between the cover and the text/glass pane below it. */
  gap: 0.5rem;
}

/* List entry title. Adjust font-size here to resize the title (1em = the
   surrounding body size; e.g. 1.5em or 2em to enlarge). */
.collection-title {
  font-size: 1.1em;
}

.collection-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0px;
  object-fit: cover;
  display: block;
}

#articles-list .collection-thumb {
  aspect-ratio: 2 / 1;
}

/* ========================================================================== */
/* 7. FILMSTRIP SYSTEM (HOMEPAGE-SPECIFIC)                                    */
/* ========================================================================== */

.collection-strip {
  width: 100%;
  height: calc(90vh - var(--header-offset, 0px) - var(--bottom-bar-offset, 0px));
  min-height: 200px;
  max-height: 2000px;
  position: relative;
  overflow: hidden;
  margin: 0;
}

.collection-strip-scroll {
  width: 100%;
  height: 100%;
  overflow: hidden;
  visibility: hidden;
}

.collection-strip-scroll.ready {
  visibility: visible;
}

.filmstrip-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.filmstrip-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: calc(90vh - var(--header-offset, 0px) - var(--bottom-bar-offset, 0px));
  min-height: 200px;
  max-height: 2000px;
  object-fit: cover;
  object-position: center center;
  user-select: none;
  -webkit-user-drag: none;
  transform: translateX(0);
  transition: transform var(--anim-filmstrip-slide) ease;
}

/* ========================================================================== */

/* 8. COLLECTION PAGE (PAGE-SPECIFIC)                                         */
/* ========================================================================== */

.collection-meta {
  font-size: 0.95rem;
  opacity: 0.8;
  margin-top: 0.25rem;
}

/* Optional per-item note (metadata.js `comment`), shown under the date.
   Rendered with renderParagraphs (same as bio/description), so neutralise the
   leading/trailing block margins to keep it snug under the date. */
.collection-comment {
  font-size: 0.95rem;
  opacity: 0.8;
  margin-top: 0.15rem;
}

.collection-comment > :first-child { margin-top: 0; }
.collection-comment > :last-child { margin-bottom: 0; }

.collection-description {
  line-height: 1.8;
  margin-bottom: 1.5rem;
  max-width: 65ch;
}

.collection-description p + p {
  margin-top: 0.75rem;
}

.collection-actions {
  margin-bottom: 0.15rem;
}

.grid-toggle.icon-button {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
}

.thumb-ribbon {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.35rem 0 1.25rem 0;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  scroll-snap-type: x mandatory;
  transition: scrollbar-color 0.5s;
}
.thumb-ribbon.is-scrolling {
  scrollbar-color: rgba(128,128,128,0.45) transparent;
  transition: scrollbar-color 0.1s;
}
.thumb-ribbon::-webkit-scrollbar {
  height: 4px;
}
.thumb-ribbon::-webkit-scrollbar-track {
  background: transparent;
}
.thumb-ribbon::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 2px;
  transition: background 0.5s;
}
.thumb-ribbon.is-scrolling::-webkit-scrollbar-thumb {
  background: rgba(128,128,128,0.45);
  transition: background 0.1s;
}

.thumb-ribbon img {
  height: 300px;
  width: auto;
  object-fit: contain;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  scroll-snap-align: start;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.thumb-ribbon img:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 0.75rem 0 2rem 0;
  padding: 0;
  list-style: none;
}

.image-grid[hidden] {
  display: none;
}

.image-grid .grid-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.image-grid .grid-item img:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

/* ========================================================================== */

/* 9. IMAGE PAGE (PAGE-SPECIFIC)                                              */
/* ========================================================================== */

.image-viewer {
  /* Use the page content width (not the full viewport). This keeps the
     image area aligned with the site's centered content column. */
  width: 100%;
  margin: 0 auto 1.25rem;
  display: flex;
  justify-content: center;
}

.image-frame {
  /* Box that is 100% wide and 80% of the viewport height (subtracting the topbar) */
  width: 100%;
  height: calc(80vh - var(--header-offset));
  min-height: 350px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.full-image {
  /* Image scales to fit the box with preserved aspect ratio */
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.4s ease 0.1s, transform 0.4s ease 0.1s;
}

.full-image.loaded {
  opacity: 1;
  transform: translateY(0);
}

.image-meta {
  max-width: 65ch;
}

#image-description {
  max-width: 65ch;
  line-height: 1.8;
}

#image-description p + p {
  margin-top: 0.75rem;
}

/* ========================================================================== */

/* 10. SLIDESHOW OVERLAY (PAGE-SPECIFIC)                                      */
/* ========================================================================== */

.slideshow-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.slideshow-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
}

.slideshow-overlay[aria-hidden="false"] {
  visibility: visible;
  opacity: 1;
}

.slideshow-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1;
}

.slideshow-inner {
  position: relative;
  z-index: 2;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Constrain slideshow content to the page column width and keep
     the inner box sized to most of the viewport height. */
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  height: 95vh;
}

#slideshow-image {
  pointer-events: auto;
  /* Make the slideshow image 95% of the page column width, keep a
     sensible cap at 960px, and preserve aspect ratio via max-height. */
  width: 95%;
  max-width: 960px;
  box-sizing: border-box;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.4s ease;
  margin: 0 auto;
}

/* Ensure the slideshow image sits above the dark backdrop */
#slideshow-image {
  position: relative;
  z-index: 3;
}

#slideshow-image.loaded {
  opacity: 1;
}

.slideshow-icon {
  position: absolute;
  width: 90px;
  height: 90px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: auto;
  z-index: 5;
  background-size: contain;
  background-repeat: no-repeat;
  transition: opacity 0.4s ease;
}

.slideshow-icon.show {
  opacity: 1;
}

/* ========================================================================== */

/* 11. FOOTER                                                                 */
/* ========================================================================== */

footer {
  font-size: 0.85rem;
  opacity: 0.8;
  padding-bottom: 3rem;
  margin-bottom: 1rem;
}

/* ========================================================================== */

/* 12. MENU (GLASS SYSTEM)                                                    */
/* ========================================================================== */

.dropdown-menu {
  background: var(--glass-bg);
  color: var(--glass-fg);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate, 100%));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate, 100%));
  box-shadow: var(--glass-shadow);

  position: fixed;
  padding: 6px 0;
  min-width: 160px;
  width: max-content;

  display: flex;
  flex-direction: column;
  text-align: right;

  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 500ms ease, transform 500ms ease;

  z-index: 1001;
}

.dropdown-menu.open {
  opacity: 1;
  transform: translateY(0);
}

.dropdown-item {
  padding: 8px 18px;
  text-decoration: none;
  color: var(--glass-fg);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
  border-radius: 4px;
  max-width: 90vw;
  box-sizing: border-box;
}

.dropdown-item:hover {
  background: rgba(0, 0, 0, 0.06);
}

body[data-theme="dark"] .dropdown-item:hover {
  background: rgba(255, 255, 255, 0.10);
}

.dropdown-menu .dropdown-item {
  color: var(--glass-fg) !important;
}

.dropdown-divider {
  height: 1px;
  margin: 4px 18px;
  background: var(--glass-border);
  opacity: 0.6;
}

/* ========================================================================== */

/* 13. RESPONSIVE ADJUSTMENTS                                                 */
/* ========================================================================== */

@media (max-width: 750px) {

  /* Homepage artist summary: stack text under image */
  .artist-summary {
    flex-direction: column;
    align-items: flex-start;
  }

  .artist-summary-text {
    text-align: left;
  }

}

/* ========================================================================== */

/* 14. EARTH CONTAINER (COLLECTION PAGE)                                      */
/* ========================================================================== */

.earth-container {
  width: 100%;
  min-width: 0;
  height: 60vh;
  min-height: 0;
  margin: 0 0 2rem;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: var(--panel-bg, rgba(0, 0, 0, 0.1));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Optional subtle dark‑mode adjustment */
body[data-theme="dark"] .earth-container {
  background: rgba(255, 255, 255, 0.05);
}

/* ========================================================================== */

/* 15. PDF VIEWER (ARTICLE & READER PAGES)                                    */
/* ========================================================================== */

.pdf-canvas {
  width: 100%;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;   /* smooth momentum scroll on iOS      */
  scrollbar-width: none;               /* Firefox                            */
  -ms-overflow-style: none;            /* IE / Edge                          */
}
.pdf-canvas::-webkit-scrollbar {
  display: none;                       /* Chrome / Safari                    */
}

/* Each rendered canvas = one PDF page, stacked vertically */
.pdf-canvas canvas {
  display: block;
  width: 100%;
  margin-bottom: 12px;
}
.pdf-canvas canvas:last-child {
  margin-bottom: 0;
}

/* Article page: compact scrollable preview */
.pdf-canvas-article {
  margin: 2rem auto;
  max-width: 95vw;
  height: 400px;
  max-height: 60vh;
}

/* Reader page: full-viewport immersive view */
.pdf-canvas-reader {
  margin: 0 auto;
  padding-top: 70px;
  max-width: 960px;
  height: 100vh;
  box-sizing: border-box;
}


/* ========================================================================== */

/* 16. LOGIN PAGE                                                             */
/* ========================================================================== */

/* Full-viewport overlay centres the login panel */
.login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--base-bg);
  z-index: 9999;
}

/* When a background image is active, make the overlay transparent
   so the body::before (image) and body::after (tint) show through. */
body.has-bg .login-overlay {
  background: transparent;
}

/* Glassmorphic login panel */
.login-panel {
  width: 100%;
  max-width: 340px;
  padding: 2.5rem 2rem 2rem;
  border-radius: 16px;
  background: var(--glass-bg, rgba(255, 255, 255, 0.40));
  border: 1px solid var(--glass-border, rgba(0, 0, 0, 0.12));
  backdrop-filter: blur(var(--glass-blur, 20px)) saturate(var(--glass-saturate, 100%));
  -webkit-backdrop-filter: blur(var(--glass-blur, 20px)) saturate(var(--glass-saturate, 100%));
  box-shadow: var(--glass-shadow, 0 4px 16px rgba(0, 0, 0, 0.12));
  color: var(--glass-fg, #111);
  text-align: center;
}

.login-title {
  margin: 0 0 1.6rem;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.login-label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  text-align: left;
  opacity: 0.7;
}

.login-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--glass-border, rgba(0, 0, 0, 0.12));
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.25);
  color: inherit;
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s ease;
}
.login-input:focus {
  border-color: rgba(0, 0, 0, 0.35);
}
body[data-theme="dark"] .login-input {
  background: rgba(255, 255, 255, 0.08);
}
body[data-theme="dark"] .login-input:focus {
  border-color: rgba(255, 255, 255, 0.45);
}

.login-button {
  width: 100%;
  padding: 0.65rem;
  margin-top: 0.5rem;
  border: none;
  border-radius: 8px;
  background: #222;
  color: #fff;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}
.login-button:hover {
  background: #444;
}
body[data-theme="dark"] .login-button {
  background: #eee;
  color: #111;
}
body[data-theme="dark"] .login-button:hover {
  background: #ccc;
}

.login-error {
  min-height: 1.2em;
  margin: 0.8rem 0 0;
  font-size: 0.85rem;
  color: #c0392b;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.login-error-visible {
  opacity: 1;
}
