/* ========================================================================== */
/* 1. BASE & RESET                                                            */
/* ========================================================================== */

: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);
}

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(--base-bg);
  overflow-y: scroll;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;
  text-size-adjust: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
  position: relative;
  z-index: 0;
  background: var(--base-bg);
  color: #222;
  transition: background 0.3s ease, color 0.3s ease;
}

body[data-theme="dark"] {
  color: #eee !important;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

body::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);
}

body[data-theme="dark"]::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;
}

body[data-theme="dark"].has-bg::after {
  background: rgba(17, 17, 17, 0.65);
}

#page-content {
  opacity: 0;
  transition: opacity 0.6s ease;
}

body.page-loaded #page-content {
  opacity: 1;
}

/* --- Cross-document View Transitions (Chrome 126+, Safari 18+) ------------ */

@view-transition {
  navigation: auto;
}

#page-content {
  view-transition-name: page-content;
}

/* Outgoing page content fades out */
::view-transition-old(page-content) {
  animation: viewFadeOut 0.3s ease-out both;
}

/* Incoming page content fades in */
::view-transition-new(page-content) {
  animation: viewFadeIn 0.4s ease-in 0.1s both;
}

@keyframes viewFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes viewFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* --- End View Transitions ------------------------------------------------- */

/* ========================================================================== */
/* 2. LAYOUT CONTAINERS                                                       */
/* ========================================================================== */

header,
main,
footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.5rem 0.5rem;
}

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;
}

main > .page-section:first-child {
  margin-top: 0.5rem;
  margin-bottom: 16vh;
}

/* ========================================================================== */
/* 3. TYPOGRAPHY & LINKS                                                      */
/* ========================================================================== */

a,
a:visited {
  color: #333;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

body[data-theme="dark"] a,
body[data-theme="dark"] a:visited {
  color: #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.40);
  --glass-border: rgba(0, 0, 0, 0.12);
  --glass-blur: 10px;
  --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.40);
  --glass-border: rgba(255, 255, 255, 0.18);
  --glass-blur: 14px;
  --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;
  gap: var(--list-spacing);
}

.icon-list.active {
  visibility: visible;
  pointer-events: auto;
  position: relative;
  isolation: isolate;
}

.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-radius: var(--glass-radius);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--glass-shadow);
  z-index: -1;
  pointer-events: none;
}

/* --- Glow animation (moved into Top Bar section) -------------------------- */

.icon-list.active.glow::before {
  animation: iconGlowFlash 0.7s 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: scale(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: scale(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: scale(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 0.7s ease-out;
}

@keyframes iconPop {
  0%   { transform: scale(var(--icon-svg-scale)); }
  10%  { transform: scale(calc(var(--icon-svg-scale) * 1.7)); }
  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)); }
}

/* --- End glow animation block -------------------------------------------- */

.icon-list.inactive {
  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);
}

/* ========================================================================== */
/* 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;
}

.icon-button:hover {
  background: rgba(0, 0, 0, 0.06);
}

body[data-theme="dark"] .icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.icon-svg {
  width: var(--icon-unit);
  height: var(--icon-unit);
  transform: scale(var(--icon-svg-scale));
  transform-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;
}

body[data-theme="light"] .icon-moon {
  display: none;
}

body[data-theme="dark"] .icon-sun {
  display: none;
}

/* ========================================================================== */
/* 6. HOMEPAGE (PAGE-SPECIFIC)                                                */
/* ========================================================================== */

.site-title {
  font-size: 1.5rem;
  font-weight: 400;
  margin: 0;
  color: inherit;
}

.artist-photo {
  width: 200px;
  height: auto;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.artist-summary {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin: 0;
}

.artist-summary-text h1 {
  margin: 0;
  font-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;
}

#collections-list,
#articles-list {
  padding: 0;
  list-style: none;
  margin: 0;
}

#collections-list li,
#articles-list li {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
  width: min(100vw - 1rem, 420px);
  margin-right: 1rem;
}

.collection-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  object-fit: cover;
  display: block;
}

/* ========================================================================== */
/* 7. FILMSTRIP SYSTEM (HOMEPAGE-SPECIFIC)                                    */
/* ========================================================================== */

.collection-strip {
  width: 100%;
  height: calc(90vh - var(--header-offset));
  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));
  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 1s ease;
}

/* ========================================================================== */
/* 8. COLLECTION PAGE (PAGE-SPECIFIC)                                         */
/* ========================================================================== */

.collection-meta {
  font-size: 0.95rem;
  opacity: 0.8;
  margin-top: 0.25rem;
}

.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;
  scroll-snap-type: x mandatory;
}

.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));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  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;
  }

  /* Homepage collections and articles lists: stack title under thumbnail */
  #collections-list li,
  #articles-list li {
    flex-direction: column;
    align-items: flex-start;
  }

  #collections-list li > div,
  #articles-list li > div {
    margin-top: 0.5rem;
  }
}

/* ========================================================================== */
/* 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;
}