/* ===== FONT DECLARATIONS ===== */
@font-face {
  font-family: "junicoderegular";
  src: url("../fonts/Junicode/junicode-regular-webfont.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "junicoderegularcondensed";
  src: url("../fonts/Junicode/junicode-regularcondensed-webfont.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "junicodeitalic";
  src: url("../fonts/Junicode/junicode-italic-webfont.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Satoshi-Black";
  src: url("../fonts/Satoshi/fonts/Satoshi-Black.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Satoshi-Medium";
  src: url("../fonts/Satoshi/fonts/Satoshi-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ===== THEME GRID (centered, fixed-size cells, laptop-first) ===== */
:root{
  --header-h: 32px;
  --header-gap: 32px;        /* gap below fixed header */
  --content-max: 1374px;     /* width of the central content area for large screens */
  --side-min: 32px;          /* min outer gutter */
  --side-max: 416px;         /* max outer gutter */
  --page-bg: #f4f6fb;
  --sa-bg: #F8F8FF;          /* Safe area background fill */

  /* Universal color palette */
  --bg-primary: #F8F8FF;     /* Primary background (was white) */
  --text-primary: #101720;   /* Primary text (was black) */
  --text-secondary: #AFBCC7; /* Dark grey text (decorative only) */
  --text-secondary-accessible: #6E707C; /* Accessible grey text (WCAG AA compliant) */
  --bg-secondary: #E5EAEE;   /* Light grey backgrounds */

  /* cell + grid sizing (fixed so flowers/text never scale) */
  --cell-w: 288px;           /* adjusted to fit 1374px max width */
  --cell-h: 198px;           /* 288 * (220/320) = 198 to keep your aspect */
  --gap:    30px;            /* slightly reduced gutter to fit within 1374px */
  --row-gap: 64px;           /* a little tighter so Shuffle stays on screen */
  --cols:   8;               /* desktop/laptop: 8 columns (each cell spans 2) */
}

/* ===== MOBILE TAP HIGHLIGHT REMOVAL ===== */
/* Remove default blue tap highlight on all elements for mobile */
*, *:before, *:after {
  -webkit-tap-highlight-color: transparent !important;
  tap-highlight-color: transparent !important;
}

/* Additional mobile tap behavior fixes */
button, a, [role="button"], [tabindex] {
  -webkit-tap-highlight-color: transparent !important;
  tap-highlight-color: transparent !important;
}

html {
  margin: 0;
  padding: 0;
  background: var(--page-bg); /* Always grey - Safari under-chrome regions stay grey */
  min-height: 100dvh; /* Extend to cover full dynamic viewport */
}

body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  width: 100%;
  overflow-x: hidden;
  display: block;
}

/* Ensure category pages have consistent background color throughout */
body.category-page {
  background: var(--page-bg);
}

/* Safe area edge fills - transparent to let page backgrounds show through */
/* Intro overlay and page backgrounds handle their own safe area coverage */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-top, 0px);
  background: transparent; /* Transparent - let page backgrounds show through */
  z-index: 2147483647; /* Above everything including intro overlay */
  pointer-events: none;
}

/* Safe area edge fills - bottom */
body::after {
  content: '';
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-bottom, 0px);
  background: transparent; /* Transparent - let page backgrounds show through */
  z-index: 2147483647; /* Above everything including intro overlay */
  pointer-events: none;
}

@media (min-width: 776px) {
  body {
    display: grid;
    place-items: center;
    grid-template-rows: 1fr;
    grid-template-columns: 1fr;
  }
}

/* Full-bleed stage for category pages - allow flowers to extend beyond bounds */
.category-page-content {
  position: fixed;
  top: 0;                     /* Start from very top */
  left: 0;
  width: 100vw;               /* true full-bleed width */
  block-size: 100dvh;         /* Dynamic viewport height adapts to Safari UI */
  background: var(--page-bg); /* Ensure background fills to edges */
  overflow: visible;          /* allow flowers to extend beyond container */
  display: flex;
  align-items: center;
  justify-content: center;
  /* Page content stays static - no animation */
  opacity: 1;
  padding-top: 32px;          /* Content padding to account for header */
  box-sizing: border-box;     /* Include padding in height calculation */
  margin: 0;                  /* Ensure no gaps */
}

/* Flower container for category pages */
#flower-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Allow clicks to pass through to underlying elements */
  z-index: 15; /* Above category overlay (z-index: 10) */
  /* Lightweight fade-in */
  opacity: 0;
  animation: flowerContainerFade 0.5s ease-out 0.05s forwards;
}

/* Flower container fade animation */
@keyframes flowerContainerFade {
  to {
    opacity: 1;
  }
}

/* Individual flower dissolve animation */
.flower {
  /* Initial state - invisible and slightly scaled down */
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.flower.flower-dissolve-in {
  /* Final state - visible and normal scale */
  opacity: 1;
  transform: scale(1);
}

/* Slower, smoother animation on mobile to avoid jagged appearance */
@media (max-width: 1160px) {
  .flower {
    transition: opacity 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .flower {
    transition: none !important;
    opacity: 1 !important;
    transform: scale(1) !important;
  }
}

#flower-container .flower,
#flower-container .flower * {
  box-sizing: border-box; /* Consistent measurements across breakpoints */
}

#flower-container .flower {
  position: absolute;
  pointer-events: auto; /* Re-enable interactions for individual flowers */
  z-index: 50 !important; /* Force above category overlay */
  /* Size is now handled dynamically by JavaScript based on viewport and emotional intensity */
  /* Remove fixed width/height as these are set by the positioning algorithm */

  /* FLIP animation target - no CSS transitions to avoid conflicts */
  will-change: transform;
  transform-origin: top left;
  backface-visibility: hidden;
  /* Ensure no clipping during size/position changes */
  overflow: visible !important;
}

/* Inner keeps centering; FLIP animates the outer */
#flower-container .flower-inner {
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
}

/* Ensure flower graphics scale with the wrapper size */
#flower-container .flower-inner > svg,
#flower-container .flower-inner > canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* Scoped guard during FLIP - kills all transitions/animations */
.category-page.is-flipping .flower,
.category-page.is-flipping .flower * {
  transition: none !important;
  animation: none !important;
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  #flower-container .flower {
    transition: none !important;
  }

  /* Disable flower entrance animation for users who prefer reduced motion */
  #flower-container {
    animation: none !important;
    opacity: 1 !important;
  }
}

/* Remove fixed scaling - flowers now position responsively using vw/vh units */
/* The golden spiral algorithm handles all responsive behavior dynamically */

/* Category page titles - absolutely centered, above flowers */
.category-title {
  font-family: "junicoderegularcondensed", serif;
  font-size: 128px;
  font-style: normal;
  font-weight: 400;
  line-height: 128px;
  letter-spacing: 12.8px;
  color: var(--text-primary);
  text-align: center;
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: none; /* Allow flower interactions to pass through */
}

/* Category title container */
.category-title-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: auto; /* Allow button clicks on both mobile and desktop */
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Desktop category title container - larger fixed size */
@media (min-width: 1161px) {
  .category-title-container {
    width: 672px;
    height: 464px;
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
  }

  .category-title {
    position: static; /* Remove absolute positioning for proper flex centering */
    transform: none; /* Remove transform since container handles centering */
  }
}

/* Category title container - hide since overlay now provides title */
.category-title-container {
  display: none;
}

/* Category pages no longer use #themes-mobile - they use .category-overlay instead */

/* Mobile category adjustments */
@media (max-width: 1160px) {
  /* raise flower layer slightly above mobile chrome */
  #flower-container { z-index: 20; }  /* was 3 */
}

/* Return to Home button uses white styling instead of blue */
.btn-return-home-white {
  background: var(--bg-primary) !important;
  color: #2259A1 !important;
  border: 1px solid #2259A1 !important;
}

.btn-return-home-white:hover {
  background: #2259A1 !important;
  color: var(--bg-primary) !important;
}

/* Full-width header bar */
.header-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 96px; /* Increased height for proper spacing */
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 32px;
  box-sizing: border-box; /* Include padding in width calculation */
  background: transparent; /* Start transparent */
  backdrop-filter: none;
  transition: background-color 0.2s ease, backdrop-filter 0.2s ease;
  pointer-events: none; /* Allow clicks through transparent header */
  will-change: background-color, backdrop-filter; /* GPU acceleration */
  transform: translateZ(0); /* Force hardware acceleration */
}


/* Make header children interactive */
.header-bar > * {
  pointer-events: auto;
}

/* Left header button - now positioned within header bar */
.header-link {
  font-family: "Satoshi-Medium", sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #2259A1;
  text-decoration: none;
  margin: 0;
  padding: 0;
  transition: color 0.2s ease-out;
  /* Prevent flicker during page loads */
  opacity: 1;
  visibility: visible;
  font-display: swap;
  will-change: auto;
  /* Ensure consistent spacing */
  flex-shrink: 0;
}

.header-link:hover {
  color: #2259A1;
  text-decoration: underline;
}

/* Right header button - now positioned within header bar */
.header-label {
  font-family: "Satoshi-Light", system-ui;
  font-size: 14px;
  font-style: normal;
  font-weight: 400;
  line-height: normal;
  color: var(--text-secondary-accessible);
  cursor: pointer;
  margin: 0;
  margin-left: auto; /* Push to the right edge for equal spacing */
  padding: 0;
  transition: color 0.2s ease-out;
  /* Prevent flicker during page loads */
  opacity: 1;
  visibility: visible;
  font-display: swap;
  will-change: auto;
  text-decoration: none;
  /* Ensure text doesn't get cut off */
  white-space: nowrap;
  overflow: visible;
}

.header-label:hover {
  color: #2259A1;
  text-decoration: underline;
}

/* Scrolled state - frosted glass effect for entire header bar */
.header-scrolled .header-bar {
  background: rgba(244, 246, 251, 0.85); /* Slightly more opaque for better performance */
  backdrop-filter: blur(8px) saturate(110%); /* Reduced blur for better performance */
  pointer-events: auto; /* Header becomes interactive when scrolled */

  /* Soft gradient fade at bottom edge */
  mask-image: linear-gradient(to bottom,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) 70%,
    rgba(0,0,0,0.8) 85%,
    rgba(0,0,0,0.3) 95%,
    rgba(0,0,0,0) 100%);
  -webkit-mask-image: linear-gradient(to bottom,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) 70%,
    rgba(0,0,0,0.8) 85%,
    rgba(0,0,0,0.3) 95%,
    rgba(0,0,0,0) 100%);

  /* Subtle shadow fallback for browsers without mask support */
  box-shadow: 0 4px 20px rgba(244, 246, 251, 0.3);
}

/* Remove text shadows when header bar has background */
.header-scrolled .header-link,
.header-scrolled .header-label {
  text-shadow: none;
}

/* Mobile Header Dropdown - shows on very small screens to prevent header overlap */
.mobile-header-dropdown {
  display: none;
}

.mobile-header-toggle {
  position: fixed;
  top: 32px;
  right: 32px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  z-index: 1001;
}


.mobile-header-toggle .menu-icon-inner {
  margin: auto;
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  width: 22px;
  height: 12px;
}

.mobile-header-toggle span {
  position: absolute;
  display: block;
  width: 100%;
  height: 2px;
  background-color: #2259A1;
  border-radius: 1px;
  transition: all 0.2s cubic-bezier(0.1, 0.82, 0.76, 0.965);
}

.mobile-header-toggle span:first-of-type {
  top: 0;
}

.mobile-header-toggle span:last-of-type {
  bottom: 0;
}

.mobile-header-toggle.active span:first-of-type {
  transform: rotate(45deg);
  top: 5px;
}

.mobile-header-toggle.active span:last-of-type {
  transform: rotate(-45deg);
  bottom: 5px;
}

.mobile-header-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--page-bg);
  z-index: 1000;
  padding: 80px 32px 32px;
  transform: translateY(-100%);
  transition: transform 0.2s ease, background 0.2s ease, backdrop-filter 0.2s ease;
  will-change: transform, background, backdrop-filter; /* GPU acceleration */
}

/* Mobile menu scrolled state */
.header-scrolled .mobile-header-menu {
  background: rgba(244, 246, 251, 0.92); /* More opaque for better performance */
  backdrop-filter: blur(8px) saturate(110%); /* Reduced blur for better performance */
}

/* Browser fallbacks and accessibility */

/* Mobile performance optimization - lighter blur for better performance */
@media (max-width: 775px) {
  .header-scrolled .header-bar {
    backdrop-filter: blur(4px) saturate(105%); /* Much lighter blur for mobile */
    background: rgba(244, 246, 251, 0.9); /* More opaque background to compensate */
  }
  .header-scrolled .mobile-header-menu {
    backdrop-filter: blur(4px) saturate(105%); /* Lighter blur for mobile menu */
    background: rgba(244, 246, 251, 0.95); /* More opaque background */
  }
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(8px)) {
  .header-scrolled .header-bar {
    background: rgba(244, 246, 251, 0.95) !important; /* Higher opacity fallback */

    /* Keep gradient edge diffusion */
    mask-image: linear-gradient(to bottom,
      rgba(0,0,0,1) 0%,
      rgba(0,0,0,1) 70%,
      rgba(0,0,0,0.8) 85%,
      rgba(0,0,0,0.3) 95%,
      rgba(0,0,0,0) 100%);
    -webkit-mask-image: linear-gradient(to bottom,
      rgba(0,0,0,1) 0%,
      rgba(0,0,0,1) 70%,
      rgba(0,0,0,0.8) 85%,
      rgba(0,0,0,0.3) 95%,
      rgba(0,0,0,0) 100%);

    /* Enhanced shadow for non-blur browsers */
    box-shadow: 0 6px 30px rgba(244, 246, 251, 0.4);
  }

  .header-scrolled .mobile-header-menu {
    background: rgba(244, 246, 251, 0.98); /* Near-opaque fallback */
  }
}

/* Fallback for browsers without mask-image support */
@supports not (mask-image: linear-gradient(black, transparent)) {
  .header-scrolled .header-bar::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(to bottom,
      rgba(244, 246, 251, 0.3) 0%,
      rgba(244, 246, 251, 0.1) 50%,
      transparent 100%);
    pointer-events: none;
  }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .header-bar,
  .header-link,
  .header-label,
  .mobile-header-menu {
    transition: none !important;
  }
}

/* Override for intro phase - maintain compatibility */
body.intro-active .header-bar {
  background: transparent !important;
  backdrop-filter: none !important;
}

body.intro-active .header-link,
body.intro-active .header-label {
  color: #F8F8FF !important;
}

.mobile-header-menu.active {
  transform: translateY(0);
}

.mobile-header-menu-item {
  display: block;
  font-family: "Satoshi-Light", system-ui;
  font-size: 16px;
  color: #2259A1;
  text-decoration: none;
  padding: 12px 0;
  transition: opacity 0.2s ease;
}

.mobile-header-menu-item:first-child {
  font-family: "Satoshi-Medium", sans-serif;
  font-weight: 500;
}

.mobile-header-menu-item:hover {
  opacity: 0.7;
}

.mobile-header-menu-item.secondary {
  color: #AFBCC7;
  font-weight: 400;
}

/* Hide regular headers and show dropdown on very small screens */
@media (max-width: 400px) {
  .header-link,
  .header-label {
    display: none;
  }

  .mobile-header-dropdown {
    display: block;
  }
}

/* page wrapper creates the outer gutters */
.wrapper{
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: clamp(
    var(--side-min),
    calc((100vw - var(--content-max)) / 2),
    var(--side-max)
  );
  padding-top: 112px; /* Desktop content starts 112px from top (96px header + 16px gap) */
  width: 100%; /* Ensure wrapper takes full width for proper centering */
  box-sizing: border-box; /* Include padding in width calculation */
}

/* Hide all content during intro on all screen sizes */
body.intro-active {
  overflow: hidden; /* Prevent scrolling during intro */
  position: fixed; /* Lock position to prevent scroll-behind on mobile */
  width: 100%;
  height: 100dvh;
}

body.intro-active .wrapper {
  visibility: hidden;
}


/* eyebrow */
.eyebrow{
  text-align: center;
  font-family: "Satoshi-Light", system-ui;
  font-size: 14px;
  font-style: normal;
  font-weight: 400;
  line-height: normal;
  color: var(--text-primary);
  margin: 8px 0 28px;
  z-index: 1; /* Below flowers */
}

/* --------- FLUID STAGGERED GRID (CSS-only placement) --------- */
#category-grid{
  display: grid;

  /* fixed-width tracks equal to the fixed cell width */
  grid-template-columns: repeat(4, var(--cell-w));

  /* fluid gaps control visual spacing (tune clamps to taste) */
  column-gap: clamp(40px, 6vw, 90px);

  /* center the grid and the cells */
  justify-content: center;
  justify-items: center;

  /* wrapper already provides gutters */
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: 0;
}

/* fixed-size cells so flowers/text never resize */
.category-cell{
  position: relative;
  width: var(--cell-w);
  height: var(--cell-h);
}

#category-grid,
.category-cell {
  overflow: visible;
}

/* center the label and the flower group inside the cell */
.category-label{
  position: absolute;
  left:50%; top:50%;
  transform:translate(-50%,-50%);
  width: 220px;
  text-align:center;
  font-size: 24px;
  font-weight: 400;
  line-height:1.2;
  font-family: "junicoderegularcondensed", "junicoderegular", Georgia, serif;
  letter-spacing: 0.1em;
  z-index: 2;
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Dim other category labels when hovering on desktop */
#category-grid.hovering .category-cell:not(:hover) .category-label {
  opacity: 0.3;
}
.category-cell .flower{
    position:absolute;
    pointer-events: none;/* decorations shouldn't block clicks */
  }

/* Space below themes so the Shuffle row is visible on laptops */
#themes-desktop{ margin-bottom: 28px; }

/* ===== Desktop: centered 3-on-top / 4-on-bottom (≤ 1360px total) ===== */
#category-grid{
  display: grid;

  /* 8 half-width tracks; each card spans 2 of them */
  grid-template-columns: repeat(8, calc(var(--cell-w) / 2));

  /* ONLY horizontal gap compresses; vertical gap stays fixed */
  column-gap: clamp(8px, calc((100% - (4 * var(--cell-w))) / 7), 28px);
  row-gap: var(--row-gap);      /* <- fixed vertical spacing */

  width: 100%;
  max-width: 1360px;
  margin-inline: auto;
  padding-inline: 0;

  justify-content: center;      /* center the whole grid */
  justify-items: center;        /* center each cell in its track */
}

/* fixed-size cells; each spans 2 half-tracks */
.category-cell{
  position: relative;
  width: var(--cell-w);
  height: var(--cell-h);
  grid-column: span 2;
}

.category-cell .flower{
  position: absolute;
  opacity: 1; /* Always visible by default */
  transition: opacity 0.3s ease;
}

/* Hover effect: only hide other flowers when directly hovering a category cell */
.category-cell:hover ~ .category-cell .flower {
  opacity: 0 !important;
}

/* Hover effect using JavaScript class instead of expensive :has() selector */
#category-grid.hovering .category-cell:not(:hover) .flower {
  opacity: 0 !important;
}

/* Flower radiate from center animation - reusable with CSS custom properties */
@keyframes radiate-flower {
  0% {
    left: var(--start-x);
    top: var(--start-y);
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
  }
  100% {
    left: var(--end-x);
    top: var(--end-y);
    transform: translate(-50%, -50%) rotate(var(--end-rotation)) scale(var(--end-scale));
    opacity: 1;
  }
}

.category-cell .flower.animate-entrance {
  animation: radiate-flower 0.8s ease-out forwards;
}

/* --- Explicit placement: 3 on top, 4 on bottom --- */
#category-grid > .category-cell:nth-of-type(1){ grid-column: 2 / span 2; }
#category-grid > .category-cell:nth-of-type(2){ grid-column: 4 / span 2; }
#category-grid > .category-cell:nth-of-type(3){ grid-column: 6 / span 2; }

#category-grid > .category-cell:nth-of-type(4){ grid-column: 1 / span 2; }
#category-grid > .category-cell:nth-of-type(5){ grid-column: 3 / span 2; }
#category-grid > .category-cell:nth-of-type(6){ grid-column: 5 / span 2; }
#category-grid > .category-cell:nth-of-type(7){ grid-column: 7 / span 2; }

/* (Optional) at ~1260px keep vertical spacing locked; only column-gap keeps shrinking */
@media (max-width: 1260px){
  #category-grid{
    /* row-gap stays fixed */
    row-gap: var(--row-gap);
    /* column-gap continues to compress via the clamp above */
  }
}

/* ===== Guard breakpoint =====
   Below ~1160px, 4×288px won't fit even with gap=0.
   Switch to your existing 1–2–1–2–1 layout here. */
@media (max-width: 1160px){
  #category-grid{
    grid-template-columns: repeat(2, var(--cell-w));
    column-gap: clamp(12px, 2vw, 20px);  /* small breathing room */
    row-gap: clamp(40px, 5vh, 72px);
    justify-content: center;
    justify-items: center;
  }

  /* reset desktop placement */
  #category-grid > .category-cell{ grid-column: auto; }

  /* 1 */
  #category-grid > .category-cell:nth-of-type(1){ grid-column: 1 / -1; justify-self: center; }
  /* 2 */
  #category-grid > .category-cell:nth-of-type(2){ grid-column: 1; }
  #category-grid > .category-cell:nth-of-type(3){ grid-column: 2; }
  /* 1 */
  #category-grid > .category-cell:nth-of-type(4){ grid-column: 1 / -1; justify-self: center; }
  /* 2 */
  #category-grid > .category-cell:nth-of-type(5){ grid-column: 1; }
  #category-grid > .category-cell:nth-of-type(6){ grid-column: 2; }
  /* 1 */
  #category-grid > .category-cell:nth-of-type(7){ grid-column: 1 / -1; justify-self: center; }
}

/* Serpentine 1–2–1–2–1 at ≤1000px (no 3–2–2) */
@media (max-width: 1000px){
  #category-grid{
    grid-template-columns: repeat(2, var(--cell-w));
    justify-content: center;
    justify-items: center;
  }

  /* reset any desktop placements */
  #category-grid > .category-cell{ grid-column: auto; }

  /* 1 */
  #category-grid > .category-cell:nth-of-type(1){
    grid-column: 1 / -1;       /* span both columns (centered single) */
    justify-self: center;
  }
  /* 2 */
  #category-grid > .category-cell:nth-of-type(2){ grid-column: 1; }
  #category-grid > .category-cell:nth-of-type(3){ grid-column: 2; }

  /* 1 */
  #category-grid > .category-cell:nth-of-type(4){
    grid-column: 1 / -1;
    justify-self: center;
  }
  /* 2 */
  #category-grid > .category-cell:nth-of-type(5){ grid-column: 1; }
  #category-grid > .category-cell:nth-of-type(6){ grid-column: 2; }

  /* 1 */
  #category-grid > .category-cell:nth-of-type(7){
    grid-column: 1 / -1;
    justify-self: center;
  }
}


/* Mobile: hide grid, show mobile-only UI (carousel) */
#themes-desktop{ display:block; }
#themes-mobile {
  display: none;
  z-index: 10; /* Below flowers (100) */
  position: relative;
}

/* Desktop (>1160px): vertically center content */
@media (min-width: 1161px) {
  .wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
  }
}

/* Medium screens need padding for proper scroll behavior */
@media (max-width: 1160px) and (min-width: 776px) {
  .wrapper { padding-top: 136px; } /* Maintain padding for scrollable content */
}

@media (max-width: 775px){
  #themes-desktop{ display:none; }
  #themes-mobile { display:block; padding-bottom: 96px; } /* 96px space after themes section on mobile */
  .wrapper {
    padding-top: 240px; /* Mobile content starts 240px from top */
    margin: 0 auto; /* Explicit centering for mobile without grid interference */
  }

  /* Make shuffle button use mobile styling */
  #shuffle-btn {
    width: 155px;
    height: 38px;
    background: #F8F8FF;
    border: 1px solid #2259A1;
    border-radius: 5px;
    font-family: "Satoshi-Light", system-ui;
    font-size: 14px;
    font-weight: 400;
    color: #2259A1;
    transition: all 0.2s ease;
    box-sizing: border-box;
  }

  /* Only apply hover styles on devices that support hover (desktop) */
  @media (hover: hover) {
    #shuffle-btn:hover {
      background: #2259A1;
      color: #F8F8FF;
    }
  }

  /* Touch-specific active state */
  #shuffle-btn.touch-active {
    background: #2259A1;
    color: #F8F8FF;
  }

  #shuffle-btn:active {
    transform: translateY(1px);
  }

  /* Reset focus state to prevent button staying blue after tap */
  #shuffle-btn:focus {
    background: #F8F8FF;
    color: #2259A1;
    outline: none;
  }

  /* But allow focus-visible for keyboard navigation */
  #shuffle-btn:focus-visible {
    background: #2259A1;
    color: #F8F8FF;
    outline: 2px solid #2259A1;
    outline-offset: 2px;
  }
}


/* ================================
   Enhanced Mobile Carousel
   ================================ */
.mobile-carousel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin: 20px 0;
  z-index: 10; /* Above flowers */
  position: relative;
}

/* Mobile carousel positioning - natural scroll with reasonable spacing */
@media (max-width: 1160px) {
  .mobile-carousel {
    position: relative; /* Natural scroll behavior instead of fixed */
    margin-top: 80px; /* Page positioning from top */
    margin-bottom: 0;
    margin-left: 0;
    margin-right: 0;
    transform: none; /* Remove transform since we're not using fixed positioning */
    gap: 20px; /* Internal spacing between carousel elements */
  }

  /* Control spacing between EXPLORE BY THEME and carousel */
  #themes-mobile .mobile-carousel {
    margin-top: 16px; /* 16px gap between eyebrow and carousel */
  }

  .eyebrow {
    margin-bottom: 0; /* Remove default margin, use specific spacing above */
  }
}

@media (max-width: 775px) {
  .mobile-carousel {
    margin-top: 60px; /* Page positioning from top */
    gap: 20px; /* Internal spacing between carousel elements */
  }

  /* Control spacing between EXPLORE BY THEME and carousel */
  #themes-mobile .mobile-carousel {
    margin-top: 12px; /* 12px gap between eyebrow and carousel */
  }

  .eyebrow {
    margin-bottom: 0; /* Remove default margin, use specific spacing above */
  }
}

/* Category Page Overlay - Desktop and Mobile */
.category-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  block-size: 100dvh; /* Dynamic viewport height for Safari liquid glass */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  z-index: 10; /* Above flowers */
  pointer-events: none; /* Allow click-through to flowers */
  /* Navigation overlay stays static - no animation */
  opacity: 1;
  margin: 0;
  /* Force extension to absolute edges */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}


/* Category title section - just the label */
.category-title-section {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* Allow click-through to flowers */
}

/* Category navigation section - arrows and dots */
.category-nav-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px; /* Space between arrows and dots */
  pointer-events: none; /* Allow click-through to flowers */
}

/* Category navigation arrows */
.category-nav-arrow {
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  pointer-events: auto; /* Enable arrow clicking */
  opacity: 0.7;
  /* Prevent unwanted focus states on mobile touch */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  outline: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.category-nav-arrow.prev {
  view-transition-name: nav-prev; /* Enable cross-page transitions */
}

.category-nav-arrow.next {
  view-transition-name: nav-next; /* Enable cross-page transitions */
}

.category-nav-arrow:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* Remove focus outline and prevent grey shadow on mobile */
.category-nav-arrow:focus {
  outline: none;
  opacity: 1;
  transform: scale(1.1);
}

.category-nav-arrow:active {
  outline: none;
  opacity: 0.8;
  transform: scale(1.05);
}

/* Clear focus state immediately after touch on mobile */
@media (hover: none) and (pointer: coarse) {
  .category-nav-arrow {
    transition: none !important; /* Disable transitions on mobile */
    view-transition-name: none !important; /* Disable view transitions on mobile */
  }
  
  .category-nav-arrow:focus {
    opacity: 0.7;
    transform: none;
  }
  
  .category-nav-arrow:active {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* Category name styling with responsive font sizes */
.category-overlay .category-name {
  font-family: "junicoderegularcondensed", "junicoderegular", Georgia, serif;
  font-size: 48px; /* Mobile size */
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--text-primary);
  text-align: center;
  margin: 0;
  pointer-events: none; /* Allow click-through to flowers */
  view-transition-name: category-title; /* Enable cross-page transitions */

  /* Carousel-style animation on page load */
  opacity: 0;
  animation: categoryLabelAppear 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s forwards;
}

/* Keyframe animation for category label appearance */
@keyframes categoryLabelAppear {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Category navigation dots */
.category-nav-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  pointer-events: none; /* Allow click-through to flowers */
  view-transition-name: dots-tracker; /* Enable cross-page transitions */
}

/* Disable view transitions on mobile */
@media (max-width: 1160px) {
  .category-nav-dots {
    view-transition-name: none !important;
  }
  
  .category-nav-arrow.prev,
  .category-nav-arrow.next {
    view-transition-name: none !important;
  }
  
  .category-overlay .category-name {
    view-transition-name: none !important;
  }
}

.category-nav-dot {
  width: 8px;
  height: 8px;
  background: var(--bg-secondary); /* Match home page inactive dots */
  border-radius: 50%;
  margin: 0;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); /* Smooth material design easing */
  transform: scale(1);
  pointer-events: auto; /* Enable dot clicking */
}

/* Disable transitions on mobile for dots */
@media (max-width: 1160px) {
  .category-nav-dot {
    transition: none !important;
  }
}

.category-nav-dot.active {
  background: var(--text-secondary); /* Match home page active dots */
  transform: scale(1.15); /* Slightly larger when active */
}

.category-nav-dot:hover:not(.active) {
  background: #8B98A5; /* Match home page hover color */
  transform: scale(1.05); /* Slight scale on hover */
}

/* Desktop font sizing and spacing */
@media (min-width: 1161px) {
  .category-overlay .category-name {
    font-size: 128px; /* Match desktop category title */
    line-height: 1; /* Reduce gap between lines */
  }

  .category-nav-section {
    gap: 40px; /* More space on desktop */
  }

  .category-nav-dot {
    width: 10px; /* Slightly larger dots on desktop */
    height: 10px;
  }

  /* Maintain active state scaling on desktop */
  .category-nav-dot.active {
    transform: scale(1.15);
  }
}

/* Category return button - enable clicking and use white styling */
.category-overlay .btn-return-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 320px;
  height: 38px;
  background: var(--bg-primary);
  color: #2259A1;
  border: 1px solid #2259A1;
  border-radius: 5px;
  font-family: "Satoshi-Light", system-ui;
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  pointer-events: auto; /* Enable clicking */
  transition: background 0.3s ease, color 0.3s ease; /* Only transition hover states */
  /* Prevent flicker during page loads */
  opacity: 1;
  visibility: visible;
  font-display: swap;
  will-change: auto;
}

/* Blue hover state for return button */
.category-overlay .btn-return-home:hover {
  background: #2259A1;
  color: var(--bg-primary);
  border: 1px solid #2259A1;
}


/* Responsive adjustments for smaller screens - center content */
@media (max-width: 1160px) {
  .category-overlay {
    gap: 32px; /* Tighter spacing on small screens */
    justify-content: center; /* Center vertically for all mobile screen sizes */
    padding-top: 0;
    padding-bottom: 0;
  }

  .category-overlay .category-name {
    font-size: 42px; /* Slightly smaller on very small screens */
    line-height: 1; /* Reduce gap between lines on mobile too */
  }

  .category-nav-section {
    gap: 16px; /* Tighter spacing on very small screens */
  }

  .category-overlay .btn-return-home {
    width: 155px; /* Match mobile button width */
    /* Ensure button is visible and positioned absolutely at bottom */
    position: fixed;
    bottom: 120px; /* Position above footer - footer is at bottom:0 with 16px padding, so button needs to be higher */
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999; /* Ensure button is above footer (footer z-index: 50) */
    transition: none !important; /* Disable transitions on mobile */
  }
}

/* Adjust button position for shorter viewport heights (e.g., X/Twitter embeds) */
/* Footer is ~60px tall (16px padding + text + 16px padding), so button needs to be above that */
@media (max-height: 700px) {
  .category-overlay .btn-return-home {
    bottom: 90px; /* Ensure button stays above footer with adequate spacing */
  }
}

/* Further adjustment for very short viewports */
@media (max-height: 600px) {
  .category-overlay .btn-return-home {
    bottom: 85px; /* Tighter spacing for very short viewports while still clearing footer */
  }
}

/* Ensure footer text doesn't overlap button on very short viewports */
@media (max-height: 500px) {
  .category-page .footer-copyright {
    padding: 12px 0 20px 0; /* Minimal bottom padding - text close to bottom, below button at 80px */
  }
  
  .category-overlay .btn-return-home {
    bottom: 80px; /* Minimum spacing to prevent overlap */
  }
}

/* Additional spacing adjustments for medium-height viewports */
@media (max-height: 700px) {
  .category-page .footer-copyright {
    padding: 16px 0 20px 0; /* Minimal bottom padding - text close to bottom, below button at 90px */
  }
}

@media (max-height: 600px) {
  .category-page .footer-copyright {
    padding: 16px 0 20px 0; /* Minimal bottom padding - text close to bottom, below button at 85px */
  }
}

/* Enhanced mobile positioning for very small screens */
@media (max-width: 775px) {
  .category-overlay {
    padding-top: 0; /* Keep centered on small screens */
    gap: 24px; /* Even tighter spacing for mobile */
  }

  .category-overlay .category-name {
    font-size: 36px; /* Smaller font for mobile screens */
  }

  .category-nav-section {
    gap: 12px; /* More compact navigation on mobile */
  }
}


.carousel-container {
  width: 100%;
  overflow: hidden;         /* mask neighbors */
  position: relative;
  height: 120px;
  display: flex;
  z-index: 10; /* Above flowers (5) */
  align-items: center;
  justify-content: center;  /* this is OK now; JS accounts for it */
  perspective: 1000px;
}

/* Remove specific flower overrides - flowers should be below category elements */

.carousel-track {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: 120px;
}

.mobile-category-item {
  position: absolute;
  width: 300px;
  height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
  transform-origin: center center;
  will-change: transform, opacity;
}

/* Default state - side items (20pt, blurred, behind) */
.mobile-category-item .category-label {
  font-family: "junicoderegularcondensed", "junicoderegular", Georgia, serif;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  filter: blur(4px);
  transform: scale(0.8) translateZ(-50px);
  transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  margin-bottom: 20px;
  line-height: 1.2;
  position: static;
  width: auto;
  opacity: 0.6;
}

/* Active state - center item (48pt, no blur, forward) */
.mobile-category-item.active .category-label {
  font-size: 48px;
  color: var(--text-primary);
  filter: blur(0px);
  transform: scale(1) translateZ(0px);
  opacity: 1;
  z-index: 2;
}

/* Hide buttons on non-active items */
.mobile-category-item .mobile-see-reflections-btn {
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}

.mobile-category-item.active .mobile-see-reflections-btn {
  opacity: 1;
  visibility: visible;
}

/* Mobile see reflections button now uses template class - see HTML for btn-mobile-blue class */

/* Carousel arrows */
.carousel-arrows {
  display: flex;
  gap: 20px;
  align-items: center;
  z-index: 1; /* Below flowers */
}

.carousel-arrow {
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  /* Prevent unwanted focus states on mobile touch */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  outline: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.carousel-arrow:hover:not(:disabled) {
  opacity: 0.7;
}

/* Remove focus outline and prevent grey shadow on mobile */
.carousel-arrow:focus {
  outline: none;
}

.carousel-arrow:active:not(:disabled) {
  outline: none;
  opacity: 0.8;
  transform: scale(0.95);
}

.carousel-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Clear focus state immediately after touch on mobile */
@media (hover: none) and (pointer: coarse) {
  .carousel-arrow:focus {
    opacity: 1;
    transform: none;
  }
  
  .carousel-arrow:active:not(:disabled) {
    opacity: 0.7;
    transform: scale(0.9);
  }
}

/* Dots indicator */
.carousel-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  z-index: 1; /* Below flowers */
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: none;
  box-shadow: none;
  outline: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  transition: background-color 0.1s ease, transform 0.1s ease; /* Faster transitions for better INP */
  position: relative;
  will-change: transform, background-color; /* Optimize for animations */
}

.dot.active {
  background: var(--text-secondary);
}

.dot:hover:not(.active) {
  background: #8B98A5;
}

/* MOBILE: full-bleed carousel (edge-to-edge) */
@media (max-width: 775px){
  .carousel-container{
    width: 100vw;                           /* span the viewport */
    margin-left: calc(50% - 50vw);          /* break out of wrapper padding */
    margin-right: calc(50% - 50vw);
    overflow: hidden;                       /* keep masks tight to the edges */
  }
}

/* ================================
   Reflections
   ================================ */

/* Remove opacity animations to prevent layout shifts and improve mobile performance */

/* Simple loading pulse animation for placeholder text */
@keyframes loading-pulse {
  0% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.3;
  }
  100% {
    opacity: 0.6;
  }
}

.loading-text {
  color: #AFBCC7;
  animation: loading-pulse 1.5s ease-in-out infinite;
}
#reflections {
  margin: 64px auto 100px;
  text-align: center;
  max-width: var(--content-max);
  width: 100%; /* Ensure full width for proper card spacing */
  min-height: 150px; /* Minimum height to prevent layout shifts */
}

#reflections h2 {
  font-family: "Satoshi-Light", system-ui;
  font-size: 14px;
  font-weight: 400;
}
#shuffle-cards {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin: 20px 0 32px 0;
  width: 100%; /* Ensure cards container takes full width */
  height: 52px; /* Fixed height to prevent layout shifts */
  min-height: 52px; /* Minimum height guarantee */
  flex-shrink: 0; /* Prevent cards from shrinking */
  /* Always shows 3 cards - CSS media queries handle responsive visibility */
}
#shuffle-cards .card {
  padding: 0px;
  width: 320px;
  height: 52px; /* Increased from 44px to allow 2 lines of text */
  text-align: left;
  box-sizing: border-box;
  flex-shrink: 0; /* Prevent cards from shrinking */
  flex-grow: 0; /* Prevent cards from growing */
  min-width: 320px; /* Enforce minimum width */
  max-width: 320px; /* Enforce maximum width */
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  font-family: "Satoshi-Light", system-ui;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.3; /* Explicit line-height for consistent spacing */
}

/* Style metaphor text within shuffle cards */
.metaphor-text {
  font-family: "Satoshi-Italic", system-ui;
  font-style: italic;
  font-weight: 400;
}

/* Style links within shuffle cards */
#shuffle-cards .card a {
  color: inherit; /* Keep the black text color */
  text-decoration: underline; /* Add underline */
}

/* Hover and active states for shuffle cards */
#shuffle-cards .card {
  cursor: pointer;
  transition: opacity 0.3s ease;
  color: #101720; /* Default state - dark grey */
  opacity: 1;
}

/* When any card is hovered, dim other cards to 30% opacity */
#shuffle-cards:hover .card {
  opacity: 0.3; /* All cards become 30% opacity on container hover */
}

#shuffle-cards:hover .card:hover {
  opacity: 1; /* But the hovered card stays at full opacity */
}

#shuffle-cards .card:active {
  opacity: 1; /* Full opacity on tap/click */
}

/* Responsive card visibility: 3→2→1 cards */
/* Hide 3rd card when screen is too narrow for 3 cards */
@media (max-width: 1141px) {
  #shuffle-cards .card[data-card-index="2"] {
    display: none;
  }
}

/* Hide 2nd card when screen is too narrow for 2 cards */
@media (max-width: 775px) {
  #shuffle-cards .card[data-card-index="1"] {
    display: none;
  }
}

/* ================================
   Reusable Button Templates
   ================================ */

/* Primary Button Template (White with Blue Border) */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 320px;
  height: 38px;
  background: #F8F8FF;
  border: 1px solid #2259A1;
  border-radius: 5px;
  font-family: "Satoshi-Light", system-ui;
  font-size: 14px;
  font-weight: 400;
  color: #2259A1;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

/* Only apply hover styles on devices that support hover (desktop) */
@media (hover: hover) {
  .btn-primary:hover {
    background: #2259A1;
    color: #F8F8FF;
  }
}

/* Touch-specific active state for btn-primary */
.btn-primary.touch-active {
  background: #2259A1;
  color: #F8F8FF;
}

.btn-primary:active {
  transform: translateY(1px);
}

/* Mobile Blue Button Template */
.btn-mobile-blue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 155px;
  height: 38px;
  background: #2259A1;
  border: 1px solid #2259A1;
  border-radius: 5px;
  font-family: "Satoshi-Light", system-ui;
  font-size: 14px;
  font-weight: 400;
  color: #F8F8FF;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.btn-mobile-blue:hover {
  background: #004080;
  border-color: #004080;
}

.btn-mobile-blue:active {
  transform: translateY(1px);
}

/* Mobile White Button Template */
.btn-mobile-white {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 155px;
  height: 38px;
  background: #F8F8FF;
  border: 1px solid #2259A1;
  border-radius: 5px;
  font-family: "Satoshi-Light", system-ui;
  font-size: 14px;
  font-weight: 400;
  color: #2259A1;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.btn-mobile-white:hover {
  background: #2259A1;
  color: #F8F8FF;
}

.btn-mobile-white:active {
  transform: translateY(1px);
}

/* Back Button Template */
.btn-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 38px;
  background: #F8F8FF;
  border: 1px solid var(--text-primary);
  border-radius: 5px;
  font-family: "Satoshi-Light", system-ui;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.btn-back:hover {
  background: var(--text-primary);
  color: #F8F8FF;
}

.btn-back:active {
  transform: translateY(1px);
}

/* Return to Home Button Template */
.btn-return-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 155px;
  height: 38px;
  pointer-events: auto; /* Override parent pointer-events: none */
  background: var(--bg-primary);
  border: 1px solid #2259A1;
  border-radius: 5px;
  font-family: "Satoshi-Light", system-ui;
  font-size: 14px;
  font-weight: 400;
  color: #2259A1;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
  z-index: 9999; /* Top-most layer */
  pointer-events: auto; /* Explicitly enable pointer events */

  /* Desktop positioning - fixed at bottom center */
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
}

/* Disable transitions on mobile for return home button */
@media (max-width: 1160px) {
  .btn-return-home {
    transition: none !important;
  }
}


.btn-return-home:hover {
  background: #2259A1;
  color: var(--bg-primary);
}


/* Apply button template to shuffle button */
#shuffle-btn {
  padding: 0; /* Reset default padding */
}

/* ================================
   Modal (unchanged)
   ================================ */
#mg-modal-overlay{
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
  background: rgba(248, 248, 255, 0.95); /* 95% white overlay - stronger visual barrier */
  z-index: 10000; /* Higher than tooltips (9999) to block all background interactions */
  pointer-events: auto; /* Ensure overlay captures all pointer events */
}

#mg-modal-overlay.open{ display: block; }

#mg-modal-overlay.closing {
  opacity: 0;
  pointer-events: auto;
  transition: opacity .25s ease;
}

#mg-modal{
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 1200px; /* Smaller container = more click-outside area */
  height: 900px; /* Smaller container = more click-outside area */
  /* Remove responsive constraints for desktop - use fixed size for stability */
  /* max-width and max-height will be added back in mobile media query */
  background: transparent;
  overflow: visible;
  /* Fine-tune centering - desktop only */
  margin-top: 0; /* Properly centered */
}

/* Desktop modal background */
#mg-modal::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('data:image/svg+xml,<svg width="1534" height="1190" viewBox="0 0 1534 1190" fill="none" xmlns="http://www.w3.org/2000/svg"><foreignObject x="0.521744" y="0.521744" width="1532.96" height="1188.67"><div xmlns="http://www.w3.org/1999/xhtml" style="backdrop-filter:blur(43.98px);clip-path:url(%23bgblur_0_405_2790_clip_path);height:100%25;width:100%25"></div></foreignObject><g filter="url(%23filter0_f_405_2790)" data-figma-bg-blur-radius="87.9565"><ellipse cx="767" cy="594.857" rx="578" ry="405.857" fill="%23F8F8FF"/></g><defs><filter id="filter0_f_405_2790" x="0.521744" y="0.521744" width="1532.96" height="1188.67" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="94.2391" result="effect1_foregroundBlur_405_2790"/></filter><clipPath id="bgblur_0_405_2790_clip_path" transform="translate(-0.521744 -0.521744)"><ellipse cx="767" cy="594.857" rx="578" ry="405.857"/></clipPath></defs></svg>') center/contain no-repeat;
  z-index: -1;
}
#mg-modal-close{
  display: none; /* Hide the X button */
}
.mg-modal-inner{
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 64px; /* Exact gap between left and right */
  /* Position content at ellipse center - desktop ellipse cx="767" cy="594.857" */
  padding: 8px 0; /* Minimal vertical padding to prevent clipping */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); /* Center consistently */
  width: 656px; /* Exact content width */
}
.mg-left{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 296px; /* Exact width for left side */
  flex-shrink: 0;
  padding: 4px 0; /* Minimal vertical padding to prevent clipping */
}
#mg-flower-host{ width: 100%; max-width: 296px; display: grid; place-items: center; overflow: visible; }
.mg-right{
  width: 296px; /* Exact width for right side (text) */
  flex-shrink: 0;
  overflow: visible;
  padding: 4px 0; /* Minimal vertical padding to prevent clipping */
}

.mg-category{ font: 400 24px/1.2 "junicoderegularcondensed", serif; letter-spacing: 2.4px; text-align: justify; color: var(--text-primary); opacity: .8; margin-bottom: 8px; white-space: nowrap; transition: opacity 0.2s ease-out; }
.mg-quote{ font: italic 36px/1.2 "Satoshi-Italic", system-ui; margin: 10px 0 22px; color: var(--text-primary); transition: opacity 0.2s ease-out; }
.mg-stats{ list-style: none; padding: 0; margin: 8px 0 18px; }
.mg-stats .label{ display: block; font: 400 12px/1.2 "junicoderegularcondensed", serif; letter-spacing: .1em; color: var(--text-primary); }
.mg-stats .value{ font: 400 16px/1.4 "Satoshi-Light", system-ui; color: var(--text-primary); }
/* Desktop Modal Right Side Layout */
.mg-meta {
  display: flex;
  flex-direction: column;
}

/* Container 1: Category and Metaphor */
.mg-text-container {
  margin-bottom: 56px; /* 56px space to stats container */
}

/* Desktop: Override the text-left to be full width (not just for mobile) */
.mg-text-left {
  width: 100%;
}

/* Desktop: Hide the text-right stats on desktop (they'll be repositioned) */
.mg-text-right {
  display: none;
}

/* Desktop: Show desktop stats, hide mobile stats */
.mg-stats-desktop {
  display: block;
}

.mg-stats-mobile {
  display: none;
}

/* Container 2: Stats - Add direct styling to the mg-stats list */
.mg-stats {
  list-style: none;
  padding: 0;
  margin: 0 0 36px 0; /* 36px space to back button */
}

.mg-stats li {
  margin-bottom: 24px; /* 24px space between stat items */
}

.mg-stats li:last-child {
  margin-bottom: 0; /* Remove margin from last item */
}

/* Back button now uses universal .btn-back class */

@media (max-width: 1160px){
  .mg-modal-inner{
    flex-direction: column;
    gap: 20px;
    /* Position content at mobile ellipse center - mobile ellipse cx="293" cy="467" */
    transform: translate(-50%, -50%); /* Mobile ellipse is properly centered */
    width: 338px; /* Exact mobile width */
    align-items: center;
  }

  /* Mobile: flower takes full width, centered */
  .mg-left{
    width: 100%;
    justify-content: center;
  }

  /* Mobile: text area becomes 2-column layout */
  .mg-right{
    width: 100%;
  }

  .mg-meta{
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .mg-text-container{ /* The container holding both text columns */
    display: flex;
    gap: 16px; /* 16px spacing between columns */
    align-items: baseline; /* Use baseline alignment for text elements */
    margin-bottom: 36px; /* 36px space to back button - same as desktop */
  }

  /* Mobile: left text column (quote + category) */
  .mg-text-left {
    width: 200px;
    flex-shrink: 0;
  }

  /* Mobile: right text column (stats) */
  .mg-text-right {
    width: 120px;
    flex-shrink: 0;
    display: block; /* Show on mobile */
  }

  /* Mobile: Show mobile stats, hide desktop stats */
  .mg-stats-mobile {
    display: block;
  }

  .mg-stats-desktop {
    display: none;
  }

  /* Mobile: Override stats margin to match desktop spacing */
  .mg-stats {
    margin: 0; /* Remove all margins to align with category */
  }

  /* Mobile: back button centered below with consistent spacing */
  .btn-back {
    align-self: center;
    margin-top: 0; /* Spacing comes from text-container margin-bottom */
  }
  /* Mobile: Category styling */
  .mg-category{
    color: var(--Black, #101720);
    font-family: "junicoderegularcondensed", serif;
    font-size: 12px;
    font-style: normal;
    font-weight: 400;
    margin: 0; /* Remove all margins */
    padding: 0; /* Remove all padding */
    line-height: 1.2; /* Match stats label line-height */
    letter-spacing: 1.2px;
    text-transform: capitalize;
    white-space: nowrap;
    vertical-align: baseline; /* Ensure baseline alignment */
  }

  /* Mobile: Stats labels styling */
  .mg-stats .label {
    color: var(--Black, #101720);
    font-family: "junicoderegularcondensed", serif;
    font-size: 12px;
    font-style: normal;
    font-weight: 400;
    margin: 0; /* Remove all margins */
    padding: 0; /* Remove all padding */
    line-height: 1.2; /* Match category line-height */
    letter-spacing: 1.2px;
    text-transform: capitalize;
    white-space: nowrap;
    vertical-align: baseline; /* Ensure baseline alignment */
    display: block; /* Label on its own line, value below */
  }

  .mg-quote{ font: italic 24px/1.2 "Satoshi-Italic", system-ui; }

  /* Mobile modal shape */
  #mg-modal {
    width: 450px; /* Smaller container = more click-outside area */
    height: 700px; /* Smaller container = more click-outside area */
    max-width: 80vw;
    max-height: 80vh;
  }

  /* Mobile modal background */
  #mg-modal::before {
    background: url('data:image/svg+xml,<svg width="586" height="934" viewBox="0 0 586 934" fill="none" xmlns="http://www.w3.org/2000/svg"><foreignObject x="0.713665" y="0.713665" width="584.573" height="932.573"><div xmlns="http://www.w3.org/1999/xhtml" style="backdrop-filter:blur(12.43px);clip-path:url(%23bgblur_0_690_9692_clip_path);height:100%25;width:100%25"></div></foreignObject><g filter="url(%23filter0_f_690_9692)" data-figma-bg-blur-radius="24.867"><ellipse cx="293" cy="467" rx="239" ry="413" fill="%23F8F8FF"/></g><defs><filter id="filter0_f_690_9692" x="0.713665" y="0.713665" width="584.573" height="932.573" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur stdDeviation="26.6432" result="effect1_foregroundBlur_690_9692"/></filter><clipPath id="bgblur_0_690_9692_clip_path" transform="translate(-0.713665 -0.713665)"><ellipse cx="293" cy="467" rx="239" ry="413"/></clipPath></defs></svg>') center/contain no-repeat;
  }

  /* Ensure flower has enough space on mobile */
  #mg-flower-host {
    max-width: calc(100vw - 80px);
    max-height: 40vh;
  }

  .mg-left {
    padding: 15px;
  }

  .mg-stage {
    max-width: 100%;
    max-height: 100%;
  }

  /* Close button hidden on mobile too */

  /* Reset desktop margin adjustment for mobile */
  #mg-modal {
    margin-top: 0; /* Mobile positioning is fine as-is */
  }
}

/* === Modal: flower stage with centered base rings === */
#mg-flower-host { width: 100%; max-width: 480px; display: grid; place-items: center; }

.mg-stage {
  position: relative;
  width: 247px;
  height: 247px;   /* fixed size for consistent experience */
}

.mg-base,
.mg-flower-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.mg-base {
  pointer-events: auto;
  z-index: 0;
}

.mg-base > svg {
  width: 100%;
  height: 100%;
  /* no transform here; base stays fixed */
}

.mg-flower-wrap {
  z-index: 1;
  --flower-tx: 0px;
  --flower-ty: 0px;
  transform: translate(var(--flower-tx), var(--flower-ty));
}

/* Hide every tooltip while suppression flag is set (modal transitions) */
.mg-suppress-tooltips .mg-tooltip,
.mg-suppress-tooltips .flower-tooltip,
.mg-suppress-tooltips [data-tooltip],
.mg-suppress-tooltips .tippy-box {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* Hover tooltip for flower sections */
.mg-tooltip {
  position: absolute;
  z-index: 15;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.6); /* Even whiter background */
  backdrop-filter: blur(20px); /* Stronger frosted glass blur effect */
  -webkit-backdrop-filter: blur(20px); /* Safari support */
  will-change: backdrop-filter; /* GPU acceleration */
  isolation: isolate; /* Create stacking context for backdrop-filter */
  border: 0.5px solid #F8F8FF; /* Border matching SVG */
  border-radius: 5px; /* Rounded corners */
  padding: 8px 16px; /* 8px top/bottom, 16px left/right */
  font: 500 14px/1.4 "Satoshi-Medium", sans-serif; /* Medium weight */
  color: var(--text-primary); /* Black text */
  white-space: nowrap;
  user-select: none;
}

/* ================================
   View Transitions API - Cross-Page Navigation
   ================================ */

/* Smooth cross-page animations for category navigation */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 300ms;
  animation-timing-function: ease;
}

/* Specific transitions for category elements */
::view-transition-old(category-title),
::view-transition-new(category-title) {
  animation-duration: 400ms;
  animation-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1);
}

::view-transition-old(dots-tracker),
::view-transition-new(dots-tracker) {
  animation-duration: 350ms;
  animation-timing-function: ease-out;
}

/* Disable View Transitions on mobile for instant navigation */
@media (max-width: 1160px) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

/* Accessibility support - respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root),
  ::view-transition-old(category-title),
  ::view-transition-new(category-title),
  ::view-transition-old(dots-tracker),
  ::view-transition-new(dots-tracker),
  ::view-transition-old(nav-prev),
  ::view-transition-new(nav-prev),
  ::view-transition-old(nav-next),
  ::view-transition-new(nav-next),
  ::view-transition-old(return-btn),
  ::view-transition-new(return-btn) {
    animation: none;
  }
}

/* sectors should sit under the petals while still being visible */
.mg-flower-wrap svg .mg-sector {
  /* no z-index in SVG; order handles it. This rule is here just as a hook if you later add filters */
  opacity: 1; /* Placeholder to avoid empty ruleset */
}

/* Ensure the flower area container participates in layout */
.modal-visual, .modal-left, .modal-top, #mg-flower-host { position: relative; }

/* Valence chips sit near the flower graphic; layout follows your modal columns naturally */
.modal-valence {
  display: none; /* Hide the container since we're using curved text */
}

/* Row of three chips */
.modal-valence__row {
  display: flex; gap: 8px; flex-wrap: wrap;
  align-items: center; justify-content: center;
}

/* The chips (kept for compatibility but hidden) */
.valence-chip {
  border: 1px solid #d1d3d4;
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font: 600 12px/1 system-ui, sans-serif;
  letter-spacing: .04em;
  cursor: default;
  user-select: none;
  display: none; /* Hide the chips since we're using curved text */
}
.valence-chip[data-zone="pos"] { color: #5EA748; }
.valence-chip[data-zone="neu"] { color: #9A8F3B; }
.valence-chip[data-zone="neg"] { color: #2259A1; }

/* curved valence text on the ring */
#mg-flower-host svg .valence-labels text {
  font-weight: 400;
  font-family: "Satoshi-Light", system-ui, -apple-system, Segoe UI, Roboto, Inter, sans-serif;
  line-height: 1;
  letter-spacing: .08em;
  text-transform: uppercase;
  fill: #6E707C;
  opacity: .9;
  cursor: pointer;
  /* font-size set dynamically in JS using pxToSvg() */
}

/* optional tints per zone (only affect CSS 'color', not 'fill') */
#mg-flower-host svg .valence-labels .valence-pos { color: #5EA748; }
#mg-flower-host svg .valence-labels .valence-neu { color: #9A8F3B; }
#mg-flower-host svg .valence-labels .valence-neg { color: #2259A1; }

/* Valence label hover - Satoshi-Medium with universal text color */
#mg-flower-host svg .valence-labels text:hover {
  fill: var(--text-primary); /* #101720 - universal black */
  font-family: "Satoshi-Medium", sans-serif;
  font-weight: 500;
}

/* ensure you can hover the label group */
#mg-flower-host svg .valence-labels,
#mg-flower-host svg .valence-labels * { pointer-events: auto; }
#mg-flower-host svg .valence-labels text { cursor: pointer; }

/* Hard override to ensure mg-base allows pointer events */
#mg-modal .mg-base { pointer-events: auto !important; }

/* The overlay only lets the text itself get events */
.valence-overlay { pointer-events: none; }
.valence-overlay .valence-labels,
.valence-overlay .valence-labels text,
.valence-overlay .valence-labels textPath {
  pointer-events: auto;
  cursor: pointer;
}

/* Ensure overlay labels use correct font */
.valence-overlay .valence-labels {
  font-family: "Satoshi-Light", system-ui;
}

/* Centered tooltip matching existing emotion hover style */
.valence-center-tip {
  position: absolute;
  z-index: 50; /* Above valence overlay (zIndex 20) */
  pointer-events: none;
  background: rgba(255, 255, 255, 0.6); /* Even whiter background */
  backdrop-filter: blur(20px); /* Stronger frosted glass blur effect */
  -webkit-backdrop-filter: blur(20px); /* Safari support */
  will-change: backdrop-filter; /* GPU acceleration */
  isolation: isolate; /* Create stacking context for backdrop-filter */
  border: 0.5px solid #F8F8FF; /* Match mg-tooltip border */
  border-radius: 5px; /* Match mg-tooltip radius */
  padding: 8px 16px; /* Match mg-tooltip padding */
  font: 500 14px/1.4 "Satoshi-Medium", sans-serif; /* Consistent font size and line-height */
  color: var(--text-primary); /* Match mg-tooltip text color */
  text-align: center;
  width: max-content; /* Hug the text content */
  /* Position relative to the stage center, not the valence container */
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateY(-4px);
  /* Smooth animations matching information tooltip */
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease-out, visibility 120ms ease-out, transform 120ms ease-out;
}

/* Visible state for smooth animation */
.valence-center-tip--visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) translateY(0);
}

/* Smooth transitions for emotion slice overlays and fading */
.mg-overlay-sector {
  transition: opacity 120ms ease-out, fill 120ms ease-out;
}

.mg-fade-sector {
  transition: opacity 120ms ease-out;
}

/* Responsive nicety: let JS handle font sizing for curved labels */
@media (min-width: 1160px) {
  svg .valence-labels text { font-size: inherit; }
}

/* Respect reduced motion for all flower modal animations */
@media (prefers-reduced-motion: reduce) {
  .valence-center-tip,
  .mg-overlay-sector,
  .mg-fade-sector {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }

  .valence-center-tip {
    transform: translate(-50%, -50%) !important;
  }
}

/* ================================
   Intro Animation Overlay System
   ================================ */

/* Main overlay container */
.intro-overlay {
  position: fixed;
  inset: 0; /* Use inset shorthand for perfect edge coverage */
  width: 100vw;
  height: 100dvh; /* Dynamic viewport height to cover full screen */
  background: transparent; /* Transparent to let html grey show in under-chrome regions */
  z-index: 999; /* Below headers (1000) during text phase */
  display: flex; /* Use flex instead of grid for better padding control */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
  /* Ensure no gaps at edges - extend to absolute viewport edges */
  margin: 0;
  overflow: hidden; /* Prevent any overflow that might create gaps */
  /* Block all interactions with content below */
  pointer-events: auto;
  /* Force background to extend under Safari chrome on macOS */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Blue content wrapper that extends to full edges including safe areas */
.intro-overlay::before {
  content: '';
  position: absolute;
  top: 0; /* Extend to very top including safe area */
  bottom: 0; /* Extend to very bottom including safe area */
  left: 0;
  right: 0;
  background: #2564AA; /* Blue background for intro text */
  z-index: -1;
  transition: background-color 0.3s ease-out;
}

/* Change blue layer to transparent during video, completion, and hidden states */
.intro-overlay.video-phase::before,
.intro-overlay.completing::before,
.intro-overlay.hidden::before {
  background: transparent;
}

/* Increase z-index during video phase to hide headers on mobile */
.intro-overlay.video-phase {
  z-index: 2147483647; /* Above everything during video phase to hide headers on mobile */
}

/* Hidden state for completed/skipped intro */
.intro-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Content container */
.intro-content {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  /* Remove height constraint to allow natural centering */
  /* Padding to keep content out of safe areas (notch, home indicator) */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Phase 1: Text and SVG Container */
.intro-text-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0;
  animation: fadeInText 1s ease-out 0.5s forwards;
}

/* Text styling - Desktop and Mobile */
.intro-text {
  font-family: "junicodeitalic", "junicoderegular", Georgia, serif;
  font-style: italic;
  font-size: 120px; /* Desktop size */
  font-weight: 400;
  line-height: 1.2;
  color: #F8F8FF; /* White text on blue background */
  margin: 0;
  max-width: none; /* Remove constraint to allow natural 3-line layout */
  letter-spacing: 0.02em;
  text-align: center; /* Center the actual lines */
}

/* Last line container for SVG positioning */
.last-line {
  position: relative; /* Anchor for the SVG */
  display: inline-block; /* Shrink-wrap to the last line's width */
}


/* Position the ripple right after the "?" and vertically centered on that line */
.last-line .intro-touch-svg {
  position: absolute;
  left: 100%; /* Immediately after the text */
  top: 50%; /* Middle of the line's cap-height box */
  transform: translate(0, -50%);
  margin-left: 0.35em; /* Breathing room from the "?" */
  width: 136px;
  height: 133px;
  cursor: pointer;
  pointer-events: auto; /* Ensure clicks are captured */
  z-index: 10; /* Ensure it's above other elements */
}

/* Auto-expand animation - same as click animation but happens on fade-in */
.intro-touch-svg .ripple-outer {
  opacity: 0.25;
  animation: rippleAutoExpand 1.2s ease-out 0.1s forwards, rippleOuterPulse 3s ease-in-out 1.4s infinite;
}

.intro-touch-svg .ripple-inner {
  opacity: 0.5;
  animation: rippleAutoExpandInner 1.2s ease-out 0.1s forwards, rippleInnerPulse 3s ease-in-out 1.4s infinite;
}

.intro-touch-svg .center-dot {
  opacity: 1;
  animation: centerDotPulse 3s ease-in-out 1.4s infinite;
}

/* Ripple effect on click - overrides the looping animations */
.intro-touch-svg.clicked .ripple-outer {
  animation: rippleExpand 0.8s ease-out forwards !important;
}

.intro-touch-svg.clicked .ripple-inner {
  animation: rippleExpandInner 0.8s ease-out forwards !important;
}

.intro-touch-svg.clicked .center-dot {
  animation: centerStable 0.8s ease-out forwards !important;
}

/* Phase 2: Video */
.intro-video {
  position: fixed; /* Fixed to viewport instead of absolute */
  top: 50%;
  left: 50%;
  /* Scale video larger than viewport to ensure complete coverage */
  width: 110vw;
  height: 110vh;
  height: 110dvh;
  /* Force minimum dimensions to guarantee no gaps */
  min-width: 110vw;
  min-height: 110vh;
  min-height: 110dvh;
  object-fit: cover;
  object-position: center center; /* Ensure center of video stays centered */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
  z-index: 600; /* Above intro overlay (500) to cover everything */
  /* Center video and force edge-to-edge coverage */
  transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
}

.intro-video.playing {
  opacity: 1;
  visibility: visible;
}

/* Hide all video controls and browser-added buttons */
.intro-video::-webkit-media-controls {
  display: none !important;
}

.intro-video::-webkit-media-controls-enclosure {
  display: none !important;
}

.intro-video::-webkit-media-controls-panel {
  display: none !important;
}

.intro-video::-webkit-media-controls-play-button {
  display: none !important;
}

.intro-video::-webkit-media-controls-start-playback-button {
  display: none !important;
}

/* Hide mobile-specific video controls */
.intro-video::-webkit-media-controls-overlay-play-button {
  display: none !important;
}

.intro-video::-webkit-media-controls-current-time-display {
  display: none !important;
}

.intro-video::-webkit-media-controls-time-remaining-display {
  display: none !important;
}

.intro-video::-webkit-media-controls-timeline {
  display: none !important;
}

.intro-video::-webkit-media-controls-volume-slider {
  display: none !important;
}

.intro-video::-webkit-media-controls-fullscreen-button {
  display: none !important;
}

/* iOS Safari specific controls */
.intro-video::-webkit-media-controls-wireless-playback-picker-button {
  display: none !important;
}

/* Additional mobile browser controls */
.intro-video::--webkit-media-controls-panel {
  display: none !important;
}

/* Force video to be non-interactive on mobile */
@media (max-width: 775px) {
  .intro-video {
    pointer-events: none !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -khtml-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;

    /* Additional mobile control hiding */
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;

    /* Enhanced mobile edge-to-edge coverage - scale larger than viewport */
    width: 110vw;
    height: 110vh;
    height: 110dvh;
    /* Force minimum dimensions to ensure full coverage */
    min-width: 110vw;
    min-height: 110vh;
    min-height: 110dvh;
    /* No max constraints - allow scaling as large as needed */
    max-width: none;
    max-height: none;

    /* Keep centering for proper object-fit: cover behavior */
    top: 50%;
    left: 50%;
    /* Maintain center positioning with hardware acceleration */
    -webkit-transform: translate(-50%, -50%) translateZ(0);
    transform: translate(-50%, -50%) translateZ(0);
  }

  /* Mobile-specific WebKit control selectors */
  .intro-video::-webkit-media-controls-overlay-enclosure {
    display: none !important;
  }

  .intro-video::-webkit-media-controls-overlay-play-button {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }

  /* iOS specific controls */
  .intro-video::-webkit-media-controls-start-playback-button {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }
}


/* Header styling during intro phase - highest specificity override */
body.intro-active .header-link,
body.intro-active .header-label {
  color: #F8F8FF !important;
  background: none !important;
  background-color: transparent !important;
}

body.intro-active .header-link:hover,
body.intro-active .header-label:hover {
  color: #F8F8FF !important;
  text-decoration: underline !important;
  background: none !important;
  background-color: transparent !important;
}

/* Mobile header during intro */
body.intro-active .mobile-header-toggle span {
  background-color: #F8F8FF !important;
}

body.intro-active .mobile-header-menu-item {
  color: #F8F8FF !important;
}

body.intro-active .mobile-header-menu-item.secondary {
  color: #F8F8FF !important;
  opacity: 0.8;
}

body.intro-active .mobile-header-menu {
  background: var(--page-bg) !important;
}

/* Header fade-out during video */
.headers-faded .header-link,
.headers-faded .header-label,
.headers-faded .mobile-header-dropdown {
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

/* Mobile responsive design */
@media (max-width: 775px) {
  .intro-overlay {
    /* Use 100dvh for full coverage including under-chrome regions */
    height: 100dvh;
    /* Force full coverage on mobile to block underlying content */
    width: 100vw;

    /* Enhanced mobile centering - override grid with flex */
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .intro-content {
    /* Keep the original structure but ensure it's centered */
    display: grid;
    place-items: center;
    width: 100%;
    height: auto;
  }

  .intro-text-container {
    /* Keep original flex column structure */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: 0;
    padding: 0;
  }

  .intro-text {
    font-size: clamp(4rem, 9vw, 7.5rem); /* Responsive font sizing - 4rem = 64px */
    max-width: none; /* Remove max-width constraint */
    margin: 0;
    text-align: center; /* Ensure lines are centered */
  }

  /* Mobile SVG sizing and positioning */
  .last-line .intro-touch-svg {
    width: 88px;
    height: 88px; /* Mobile sizing */
    margin-left: 0.2em; /* Tighter spacing on mobile */
  }

}

/* Animations */
@keyframes fadeInText {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInTouch {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Auto-expand animations - same as click but for automatic appearance */
@keyframes rippleAutoExpand {
  0% {
    r: 18.4442;
    opacity: 0;
    stroke-width: 0.423519;
  }
  30% {
    r: 142.538;
    opacity: 0.25;
    stroke-width: 3.27298;
  }
  100% {
    r: 18.4442;
    opacity: 0.25;
    stroke-width: 0.423519;
  }
}

@keyframes rippleAutoExpandInner {
  0% {
    r: 12.642;
    opacity: 0;
    stroke-width: 0.847038;
  }
  30% {
    r: 84.7143;
    opacity: 0.5;
    stroke-width: 5.676;
  }
  100% {
    r: 12.642;
    opacity: 0.5;
    stroke-width: 0.847038;
  }
}

/* Subtle idle pulse animations */
@keyframes rippleOuterPulse {
  0%, 100% {
    r: 18.4442;
    opacity: 0.25;
  }
  50% {
    r: 22;
    opacity: 0.15;
  }
}

@keyframes rippleInnerPulse {
  0%, 100% {
    r: 12.642;
    opacity: 0.5;
  }
  50% {
    r: 15;
    opacity: 0.3;
  }
}

@keyframes centerDotPulse {
  0%, 100% {
    r: 21.1107;
    opacity: 1;
  }
  50% {
    r: 19;
    opacity: 0.9;
  }
}

/* Click ripple expansion animations */
@keyframes rippleExpand {
  0% {
    r: 18.4442;
    opacity: 0.25;
    stroke-width: 0.423519;
  }
  70% {
    r: 142.538;
    opacity: 0.25;
    stroke-width: 3.27298;
  }
  100% {
    r: 142.538;
    opacity: 0;
    stroke-width: 3.27298;
  }
}

@keyframes rippleExpandInner {
  0% {
    r: 12.642;
    opacity: 0.5;
    stroke-width: 0.847038;
  }
  70% {
    r: 84.7143;
    opacity: 0.5;
    stroke-width: 5.676;
  }
  100% {
    r: 84.7143;
    opacity: 0;
    stroke-width: 5.676;
  }
}

@keyframes centerStable {
  0%, 100% {
    r: 21.1107;
    opacity: 1;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .intro-text-container,
  .intro-touch-svg {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .intro-overlay,
  .intro-video,
  .header-link,
  .header-label {
    transition: none !important;
  }
}

/* ================================
   Zine Page Styles
   ================================ */

/* Zine page - natural stacking layout */
.zine-page .wrapper {
  padding-top: 128px; /* 96px header + 32px spacing */
  padding-bottom: 0;
  display: block;
  width: 100%;
}

/* Center container for title + reader */
.zine-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px; /* 32px spacing between title and PDF */
  width: 100%;
  max-width: 100%;
  padding-bottom: 40px; /* Space before footer */
}

/* Zine Title */
.zine-title {
  font-family: "junicoderegularcondensed", "junicoderegular", Georgia, serif;
  font-size: 48px;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--text-primary);
  text-align: center;
  margin: 0;
  line-height: 1.2;
  flex-shrink: 0;
}

/* Zine Description */
.zine-description {
  font-family: "Satoshi-Light", system-ui;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  text-align: left;
  margin: 0;
  max-width: 800px; /* Match PDF controls max-width */
  padding: 0 20px;
}

/* PDF reader */
.pdf-reader {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* PDF canvas container */
.pdf-canvas-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  padding: 0;
  margin-bottom: 32px; /* 32px spacing between PDF and controls */
}

#pdf-canvas {
  max-width: 100%;
  width: auto !important;
  height: auto !important;
  display: block;
  object-fit: contain;
}

/* Desktop and tablet - limit PDF width to 50% of viewport */
@media (min-width: 776px) {
  #pdf-canvas {
    max-width: 50vw;
  }

  /* Cover pages (first and last) should be half the width of spreads */
  #pdf-canvas.cover-page {
    max-width: 25vw;
  }
}

/* Copyright Footer */
.footer-bar {
  width: 100%;
  padding: 0 32px;
  box-sizing: border-box;
  background: transparent;
  /* Prevent layout shift */
  min-height: 0;
}

.footer-copyright {
  font-family: "Satoshi-Light", system-ui;
  font-size: 14px;
  font-weight: 400;
  line-height: normal;
  color: var(--text-secondary-accessible);
  padding: 32px 0;
  margin: 0;
  /* Prevent layout shift */
  min-height: 0;
  box-sizing: border-box;
}

.footer-copyright a {
  color: inherit;
  text-decoration: underline;
}

/* Sticky footer for category pages */
.category-page .footer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 50;
  /* Prevent layout shift - ensure footer is positioned correctly from start */
  transform: translateZ(0);
  will-change: auto;
}

.category-page .footer-copyright {
  padding: 16px 0;
  /* Prevent layout shift */
  min-height: 0;
  box-sizing: border-box;
}

/* Disable transitions on mobile for footer */
@media (max-width: 1160px) {
  .category-page .footer-bar,
  .category-page .footer-copyright {
    transition: none !important;
  }
}

/* Mobile footer adjustments */
@media (max-width: 775px) {
  .footer-copyright {
    font-size: 12px;
    text-align: center;
    padding: 32px 0 128px 0; /* Extra bottom padding for mobile browser UI (128px to clear Chrome UI) */
  }

  .category-page .footer-copyright {
    font-size: 12px;
    text-align: center;
    padding: 16px 0 20px 0; /* Minimal bottom padding - text should be close to bottom, well below button at 120px */
    /* Prevent layout shift - ensure consistent height */
    min-height: 0;
    box-sizing: border-box;
    /* Force layout calculation from start */
    transform: translateZ(0);
  }
}


