:root {
  color-scheme: dark;
  /* Voice = editorial serif; utility (metadata, directions, buttons) = mono. */
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;
  font-family: var(--serif);
  background: #0d0d0c;
  color: #f0ece3;
  --edge: clamp(16px, 3vw, 34px);
  --paper: #f1ece1;
  --muted: rgba(241, 236, 225, 0.62);
  --faint: rgba(241, 236, 225, 0.4);
  --line: rgba(241, 236, 225, 0.16);
  /* Brand accents, measured from the archive's film signatures. */
  --ground: #0d0d0c;
  --surface: #1c1a18;
  --raised: #2b2826;
  --amber: #cc8f3d;       /* redscale ember — primary */
  --amber-deep: #8c3e27;  /* redscale brick */
  --teal: #4ba2a8;        /* turquoise */
  --violet: #b2627f;      /* lomochrome purple */
  --indigo: #383866;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(90, 86, 76, 0.18), transparent 46%),
    #0d0d0c;
}

body {
  min-height: 100svh;
}

button,
a {
  color: inherit;
  font: inherit;
}

.archive-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
}

/* Home / entry view: a scattered pile of featured prints that bleeds off every
   edge, with the welcome floating over a soft central veil. */
.home {
  position: fixed;
  inset: 0;
  overflow: hidden;
  /* Warm amber core behind the card, deep film-tinted corners (teal / indigo /
     brick) so the pile sits in coloured light rather than flat black. */
  background:
    radial-gradient(ellipse 52% 46% at 50% 47%, rgba(204, 143, 61, 0.16), transparent 60%),
    radial-gradient(circle at 8% 8%, rgba(75, 162, 168, 0.16), transparent 42%),
    radial-gradient(circle at 92% 14%, rgba(178, 98, 127, 0.15), transparent 44%),
    radial-gradient(circle at 84% 92%, rgba(140, 62, 39, 0.18), transparent 46%),
    radial-gradient(circle at 12% 90%, rgba(56, 56, 102, 0.18), transparent 46%),
    #0d0d0c;
}

.home[hidden] {
  display: none;
}

.home-pile {
  position: absolute;
  inset: 0;
}

.home-thumb {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  transition: transform 240ms cubic-bezier(0.2, 0.82, 0.2, 1), box-shadow 240ms ease,
    filter 240ms ease;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
  filter: saturate(1.08) contrast(1.03);
}

.home-thumb:hover {
  transform: translate(-50%, -50%) rotate(0deg) scale(1.08);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(204, 143, 61, 0.55);
  filter: saturate(1.18) brightness(1.06);
  z-index: 999;
}

.home-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: rgba(13, 13, 12, 0.4);
  animation: home-rise 560ms both;
}

@keyframes home-rise {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.home-veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(
    ellipse 56% 52% at 50% 48%,
    rgba(10, 10, 9, 0.78) 0%,
    rgba(10, 10, 9, 0.42) 40%,
    rgba(10, 10, 9, 0) 74%
  );
}

.home-welcome {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--edge);
  text-align: center;
  pointer-events: none;
}

/* Logo lockup at the top of the card: amber aperture + serif wordmark, over a
   thin amber rule. */
.home-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(204, 143, 61, 0.28);
}

.home-logo-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  color: var(--amber);
}

.home-logo-text {
  font-family: var(--serif);
  font-size: clamp(15px, 1.7vw, 18px);
  letter-spacing: 0.01em;
  color: var(--paper);
}

.home-greeting,
.home-question {
  margin: 0;
  line-height: 1.16;
}

.home-greeting {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--amber);
}

.home-question {
  margin-top: 8px;
  font-family: var(--serif);
  font-size: clamp(26px, 3.8vw, 40px);
  font-weight: 500;
  font-style: italic;
  color: var(--paper);
  text-wrap: balance;
}

/* Welcome + full rationale in one centred box over the pile — the focal point. */
.home-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: min(560px, 90vw);
  padding: clamp(26px, 3.4vw, 40px);
  border: 1px solid var(--line);
  border-top: 2px solid var(--amber);
  border-radius: 14px;
  background: linear-gradient(rgba(28, 26, 24, 0.92), rgba(16, 15, 14, 0.92));
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.62),
    0 0 80px rgba(204, 143, 61, 0.1);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

.home-rationale {
  width: 100%;            /* fill the card; flex align-items:center would otherwise let it overflow */
  margin: 18px 0 0;
  font-family: var(--serif);
  font-size: clamp(16px, 1.7vw, 17px);
  line-height: 1.66;
  color: var(--muted);
  text-align: left;
  overflow-wrap: break-word;
}

/* The fold-out control only appears on mobile; on desktop the rationale is
   always shown, so the toggle stays hidden. */
.home-toggle {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .home-thumb {
    transition: none;
  }

  .home-thumb img {
    animation: none;
  }
}

.topbar {
  position: absolute;
  z-index: 40;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: var(--edge);
  pointer-events: none;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: rgba(240, 236, 227, 0.88);
  text-decoration: none;
  font-size: clamp(15px, 1.6vw, 19px);
  line-height: 1;
  letter-spacing: 0;
  pointer-events: auto;
}

.wordmark:hover {
  color: #fffaf0;
}

.wordmark-icon {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  color: var(--amber);
  opacity: 0.95;
}

.wordmark:hover .wordmark-icon {
  opacity: 1;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.nav-button,
.close-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(13, 13, 12, 0.54);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 8px 15px;
  min-height: 34px;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.nav-button:hover,
.close-button:hover {
  border-color: rgba(204, 143, 61, 0.55);
  color: var(--amber);
}

/* The help button is a single glyph (✥) — size it up and center it so it reads
   as a mark rather than tiny body text. */
#helpButton {
  font-size: 15px;
  line-height: 1;
  padding: 7px 12px;
  color: var(--amber);
  border-color: rgba(204, 143, 61, 0.4);
}

.nav-button:disabled {
  opacity: 0.34;
  cursor: default;
}

.nav-button:disabled:hover {
  border-color: var(--line);
  color: rgba(240, 236, 227, 0.82);
}

.stage {
  position: absolute;
  inset: 0;
  touch-action: none;
  user-select: none;
}

.current-photo {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  pointer-events: none;
}

.current-photo img {
  display: block;
  max-width: min(76vw, 1640px);
  max-height: min(78svh, 1180px);
  width: auto;
  height: auto;
  object-fit: contain;
  background: transparent;
}

.stage.is-transitioning .current-photo img {
  opacity: 1;
}

.stage.is-transitioning .peek {
  pointer-events: none;
}

.transition-layer {
  position: absolute;
  inset: 0;
  z-index: 24;
  pointer-events: none;
}

.transition-image {
  position: absolute;
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  object-fit: contain;
  background: transparent;
  will-change: transform, width, height, opacity;
}

.peek {
  position: absolute;
  z-index: 6;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0.42;
  filter: saturate(0.92) brightness(0.86);
  transition: opacity 180ms ease, filter 180ms ease, transform 240ms ease;
}

.peek:hover {
  opacity: 0.76;
  filter: saturate(1) brightness(0.96);
}

.peek img {
  display: block;
  max-width: min(52vw, 940px);
  max-height: min(52svh, 760px);
  width: auto;
  height: auto;
  object-fit: contain;
  background: transparent;
}

.peek-up {
  top: 0;
  left: 50%;
  transform: translate(-50%, -64%);
}

.peek-right {
  top: 50%;
  right: 0;
  transform: translate(64%, -50%);
}

.peek-down {
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 64%);
}

.peek-left {
  top: 50%;
  left: 0;
  transform: translate(-64%, -50%);
}

.peek-up:hover {
  transform: translate(-50%, -58%);
}

.peek-right:hover {
  transform: translate(58%, -50%);
}

.peek-down:hover {
  transform: translate(-50%, 58%);
}

.peek-left:hover {
  transform: translate(-58%, -50%);
}

.direction-label {
  display: none;
}

.direction-labels {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

.viewport-label {
  position: absolute;
  z-index: 1;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: rgba(13, 13, 12, 0.58);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  backdrop-filter: blur(10px);
  pointer-events: none;
}

/* One film accent per direction (Random stays neutral). */
.label-up { color: var(--teal); border-color: rgba(75, 162, 168, 0.4); }
.label-right { color: var(--amber); border-color: rgba(204, 143, 61, 0.4); }
.label-down { color: var(--violet); border-color: rgba(178, 98, 127, 0.4); }

.label-up {
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
}

.label-right {
  top: 50%;
  right: var(--edge);
  transform: translateY(-50%);
}

.label-down {
  bottom: 58px;
  left: 50%;
  transform: translateX(-50%);
}

.label-left {
  top: 50%;
  left: var(--edge);
  transform: translateY(-50%);
}

.history {
  position: absolute;
  z-index: 36;
  left: var(--edge);
  bottom: calc(var(--edge) + 4px);
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: auto;
}

.history[hidden] {
  display: none;
}

.history-label {
  align-self: flex-start;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 2px 4px 2px 2px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

.history-label:hover {
  color: var(--amber);
}

.history-label::after {
  content: " \25BE"; /* ▾ open */
}

.history.is-collapsed .history-label::after {
  content: " \25B8"; /* ▸ collapsed */
}

.history.is-collapsed .history-rail {
  display: none;
}

.history-rail {
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-nav {
  flex: 0 0 auto;
  width: 20px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(240, 236, 227, 0.18);
  border-radius: 6px;
  background: rgba(13, 13, 12, 0.48);
  color: rgba(240, 236, 227, 0.82);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.history-nav:hover:not(:disabled) {
  border-color: rgba(240, 236, 227, 0.42);
  color: #fffaf0;
}

.history-nav:disabled {
  opacity: 0.26;
  cursor: default;
}

.history-window {
  width: 274px;
  max-width: 44vw;
  overflow: hidden;
}

.history-track {
  display: flex;
  gap: 6px;
  width: max-content;
  transition: transform 200ms cubic-bezier(0.2, 0.82, 0.2, 1);
  will-change: transform;
}

.history-item {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid rgba(240, 236, 227, 0.18);
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
  background: rgba(13, 13, 12, 0.48);
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 160ms ease, border-color 160ms ease;
}

.history-item:hover {
  opacity: 0.92;
  border-color: rgba(240, 236, 227, 0.42);
}

.history-item.is-current {
  opacity: 1;
  border-color: rgba(240, 236, 227, 0.88);
  box-shadow: 0 0 0 1px rgba(240, 236, 227, 0.5);
}

.history-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (prefers-reduced-motion: reduce) {
  .history-track {
    transition: none;
  }
}

.about-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
}

.about-panel.is-open {
  display: block;
}

.about-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 4, 0.72);
}

.about-content {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100svh - 32px);
  overflow: auto;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-top: 2px solid var(--amber);
  border-radius: 14px;
  background: linear-gradient(rgba(28, 26, 24, 0.97), rgba(16, 15, 14, 0.97));
  padding: clamp(24px, 4vw, 42px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), 0 0 80px rgba(204, 143, 61, 0.08);
}

/* Logo lockup — mirrors the home card masthead. */
.about-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(204, 143, 61, 0.28);
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(19px, 2.6vw, 24px);
  line-height: 1;
  letter-spacing: 0.01em;
}

.about-logo-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  color: var(--amber);
}

/* Plain analogue note + Instagram (also the contact). */
.about-note {
  margin: 22px 0 0 !important;
  font-family: var(--mono);
  font-size: 11px !important;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint) !important;
}

.ig-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 20px;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--amber);
  color: #1a1206;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.ig-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(204, 143, 61, 0.34);
}

.ig-icon {
  width: 18px;
  height: 18px;
}

.about-content p {
  margin: 0 0 16px;
  color: rgba(240, 236, 227, 0.78);
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.55;
}

/* Help panel — "Ways to move" legend. */
.help-intro {
  font-size: clamp(15px, 1.8vw, 17px) !important;
}

.help-legend {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.help-legend li {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.5;
  color: var(--muted);
}

.leg {
  display: inline-block;
  margin-right: 10px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.leg-up { color: var(--teal); border-color: rgba(75, 162, 168, 0.4); }
.leg-right { color: var(--amber); border-color: rgba(204, 143, 61, 0.4); }
.leg-down { color: var(--violet); border-color: rgba(178, 98, 127, 0.4); }

.close-button {
  position: sticky;
  top: 0;
  float: right;
  margin: -10px -10px 14px 16px;
}

@media (max-width: 760px) {
  :root {
    --edge: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .nav-button {
    min-height: 34px;
    padding: 7px 11px;
  }

  /* Home: shrink the card and fold the rationale so the pile shows through. */
  .home-pile {
    cursor: grab;
    touch-action: none; /* let us drag-to-pan instead of scrolling the page */
  }

  .home-pile:active {
    cursor: grabbing;
  }

  .home-card {
    max-width: min(380px, 88vw);
    padding: 22px 24px;
    border-radius: 12px;
  }

  .home-logo-icon { width: 22px; height: 22px; }
  .home-logo-text { font-size: 15px; }

  .home-greeting { margin-top: 14px; }

  .home-question {
    margin-top: 6px;
    font-size: clamp(24px, 6.6vw, 30px);
  }

  .home-rationale {
    display: none; /* folded by default; .is-expanded reveals it */
    font-size: 15px;
  }

  .home-card.is-expanded .home-rationale {
    display: block;
  }

  .home-toggle {
    display: inline-flex;
    align-items: center;
    margin-top: 16px;
    padding: 8px 15px;
    border: 1px solid rgba(204, 143, 61, 0.4);
    border-radius: 999px;
    background: transparent;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--amber);
    cursor: pointer;
  }

  /* Explore: the floating edge labels overlap the photo on a phone — the "?"
     panel carries the instructions instead. */
  .viewport-label {
    display: none;
  }

  .current-photo img {
    max-width: 80vw;
    max-height: 72svh;
  }

  .peek img {
    max-width: 68vw;
    max-height: 42svh;
  }

  .peek-up {
    transform: translate(-50%, -70%);
  }

  .peek-right {
    transform: translate(72%, -50%);
  }

  .peek-down {
    transform: translate(-50%, 70%);
  }

  .peek-left {
    transform: translate(-72%, -50%);
  }

  .direction-label {
    font-size: 11px;
    padding: 6px 7px;
  }

  .history-window {
    width: 246px;
    max-width: 58vw;
  }

  .history-nav {
    height: 30px;
  }

  .history-item {
    width: 30px;
    height: 30px;
  }
}
