/* Demos / videos gallery — /library/demos/ */

/* Page type: use the same serif as "The Invisible Climate of a Street".
   This stylesheet loads only on this page, and the nav/footer set their own
   (Helvetica) font-family, so this stays scoped to the demos content —
   which otherwise falls back to the browser's default serif. */
body {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

/* View switcher (2d gallery / 3d wheel / 3d stack) — restrained Apple-style liquid glass.
   Fixed as a vertical control pinned to the right edge of the viewport. */
.demos-viewswitch {
  position: fixed;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  z-index: 50;
  display: inline-grid;
  grid-auto-flow: row;
  gap: 2px;
  margin-top: 0;
  padding: 4px;
}

/* container background removed — only the sliding lens marks the active view */

/* sliding glass lens that glides to the active segment (soft, low-contrast edge) */
.demos-viewswitch-thumb {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 4px;
  height: 0; /* set by JS to the active button's height */
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.55),
    rgba(255, 255, 255, 0.28)
  );
  border: 1px solid rgba(255, 255, 255, 0.5);
  -webkit-backdrop-filter: blur(14px) saturate(135%);
  backdrop-filter: blur(14px) saturate(135%);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transform: translateY(0);
  transition: transform 380ms cubic-bezier(0.22, 1, 0.36, 1),
    height 380ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  z-index: 0;
}

/* Reduce-transparency: swap the glass lens for a solid, legible chip. */
@media (prefers-reduced-transparency: reduce) {
  .demos-viewswitch-thumb {
    background: rgb(238, 238, 238);
    border-color: rgba(0, 0, 0, 0.15);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.demos-viewbtn {
  position: relative;
  z-index: 1;
  min-width: 120px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(20, 20, 20, 0.68);
  font: inherit;
  font-size: 0.95em;
  padding: 9px 22px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: none;
  transition: color 220ms ease;
}

.demos-viewbtn:hover {
  color: rgba(15, 15, 15, 0.9);
}

/* Instant press feedback — respond on pointer-down, not release (§1). */
.demos-viewbtn:active {
  transform: scale(0.96);
  transition: transform 90ms ease-out;
}

/* active segment: text weight/color changes only */
.demos-viewbtn.is-active {
  color: rgba(15, 15, 15, 0.94);
}

/* Views share the page; toggled via [hidden] */
.demos-view[hidden] {
  display: none;
}

.demos-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 40px 60px;
  color: #333;
}

.demos-section {
  margin-bottom: 60px;
}

.demos-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}

@media (min-width: 600px) {
  .demos-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 960px) {
  .demos-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.demo-card {
  margin: 0;
}

/* Entrance animation — cards settle into place when a view is shown */
@keyframes demoCardIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.965);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .demo-card,
  .wheel-view {
    animation: none !important;
  }
}

.demo-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

/* Thumbnail: fixed 16:9 frame, image cropped to fill */
.demo-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 6px;
  background: #eee;
}

.demo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
  /* Sits above .demo-thumb-fallback, which stays behind as the graceful
     fallback for cards whose image is missing (or gitignored). An <img> that
     fails to load removes itself, revealing the glyph. */
  position: relative;
  z-index: 1;
}

.demo-thumb-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2em;
  color: #bbb;
}

/* Play badge, fades in on hover */
.demo-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.1em;
  padding-left: 4px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.demo-link:hover .demo-thumb img {
  transform: scale(1.05);
}

.demo-link:hover .demo-play {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Press feedback: the whole card gives slightly under a tap (§1). */
.demo-link:active .demo-thumb {
  transform: scale(0.985);
  transition: transform 90ms ease-out;
}

/* Category tag badge, pinned to the thumbnail corner */
.demo-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.72em;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  padding: 3px 9px;
  border-radius: 999px;
}

.demo-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 10px;
}

.demo-title {
  font-weight: 500;
  color: #000;
  line-height: 1.3;
}

.demo-link:hover .demo-title {
  text-decoration: underline;
}

.demo-person {
  color: #666;
  font-size: 0.95em;
}

.demo-note {
  color: #999;
  font-size: 0.9em;
}

/* Marks a card whose project is gitignored: it works when the site is served
   locally but 404s on the deployed site. */
.demo-flag {
  display: inline-block;
  margin-left: 0.45em;
  padding: 1px 5px;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 0.68em;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #999;
  vertical-align: 0.12em;
}

.demo-link:hover .demo-flag {
  text-decoration: none;
}

/* 3d views (shared canvas container for "3d wheel" / "3d stack") — renders
   directly into the page, transparent canvas floating on the white
   background (no card/panel). */
.demos-motion {
  width: 100%; /* flex item with auto side-margins would otherwise shrink to content */
  max-width: none; /* 3D views span the full width so edge cards aren't cropped */
  margin: 0 auto;
  padding: 10px 40px 20px;
}

/* Demos page: pull the title closer to the nav so the 3D views + caption fit
   in one viewport (the reading-list pages keep the larger 130px offset). */
.demos-header {
  position: relative;
  margin-top: 72px;
}

/* ← library sits in the viewport's top-left corner (below the nav) instead of
   stacking above the centered title */
.demos-header .readlist-crumb {
  position: fixed;
  top: 90px;
  left: 40px;
  margin: 0;
  z-index: 10;
}

.wheel-view {
  position: relative;
  width: 100%;
  /* fill the viewport left below the title + caption so nothing overflows */
  height: clamp(280px, calc(100vh - 270px), 660px);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  cursor: grab;
  touch-action: pan-y;
}

.wheel-view:active {
  cursor: grabbing;
}

.wheel-view canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
}

/* Minimal caption outside the canvas */
.wheel-caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 0 2px;
  color: #333;
}

.wheel-caption-title {
  font-size: 1.05em;
  font-weight: 500;
  color: #000;
}

.wheel-caption-count {
  color: #999;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* iPhone / small phones. The view-switcher is a floating glass control by
   design, so it stays pinned to the right edge — but its 120px buttons cover
   a third of a phone screen, so shrink it. Tighten gutters and pull the title
   up under the (now sticky, in-flow) nav so the 3D views fit the viewport. */
@media (max-width: 600px) {
  .demos-viewswitch {
    right: 8px;
    padding: 3px;
    gap: 1px;
  }

  .demos-viewbtn {
    min-width: 0;
    padding: 7px 12px;
    font-size: 0.8em;
  }

  .demos-wrap {
    padding: 10px 20px 48px;
  }

  .demos-motion {
    padding: 10px 16px 20px;
  }

  .demos-header {
    margin-top: 64px;
  }

  /* flow the crumb inline above the title instead of fixed-positioning it
     over the taller stacked mobile nav */
  .demos-header .readlist-crumb {
    position: static;
    padding: 0;
    margin-bottom: 10px;
  }

  .demos-section {
    margin-bottom: 40px;
  }

  /* leave room for the sticky nav + caption so the 3D canvas doesn't overflow */
  .wheel-view {
    height: clamp(240px, calc(100vh - 320px), 480px);
  }

  .wheel-caption {
    margin-top: 12px;
  }
}
