:root {
  --forest-950: #050d09;
  --forest-900: #08150f;
  --forest-850: #0b1d15;
  --forest-800: #10291e;
  --forest-700: #163a2a;
  --forest-600: #1f4d38;
  --forest-500: #2f6b4f;
  --moss: #6fa889;
  --sage: #9cc5a8;
  --mist: #e4eee7;

  --bg-gradient:
    radial-gradient(120% 80% at 15% 0%, rgba(47, 107, 79, 0.28) 0%, transparent 60%),
    radial-gradient(90% 70% at 100% 100%, rgba(31, 77, 56, 0.35) 0%, transparent 60%),
    linear-gradient(165deg, var(--forest-850) 0%, var(--forest-900) 50%, var(--forest-950) 100%);

  --ease-smooth: cubic-bezier(0.87, 0, 0.13, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --gutter: 24px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* The page itself never scrolls: every view is a fixed, full-screen layer.
   That's what keeps mobile browsers from rubber-banding / resizing the background. */
html,
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: var(--forest-900);
}

body {
  background: var(--bg-gradient);
  color: var(--mist);
  font-family: "DM Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

/* ---------- Shared bits ---------- */

.year {
  position: absolute;
  left: var(--gutter);
  bottom: calc(22px + var(--safe-b));
  font-size: clamp(12px, 0.35vw + 9px, 16px);
  letter-spacing: 0.24em;
  color: rgba(228, 238, 231, 0.82);
  pointer-events: none;
  opacity: 0;
}

.ui-btn {
  position: relative;
  touch-action: manipulation;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--mist);
  background: linear-gradient(145deg, rgba(47, 107, 79, 0.5), rgba(8, 21, 15, 0.7));
  border: 1px solid rgba(156, 197, 168, 0.16);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: border-color 0.3s ease, background 0.3s ease, transform 0.3s ease;
}

.ui-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .ui-btn:hover {
    border-color: rgba(156, 197, 168, 0.45);
    background: linear-gradient(145deg, rgba(63, 133, 99, 0.6), rgba(11, 29, 21, 0.75));
  }
}

.ui-btn:active {
  transform: scale(0.94);
}

.ui-btn:focus-visible,
.hero-arrow:focus-visible,
.site-footer a:focus-visible {
  outline: 1px solid var(--sage);
  outline-offset: 3px;
}

/* ---------- Preloader ---------- */

.preloader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg-gradient), var(--forest-900);
}

/* Progress bar (design assets/progress-bar), recoloured forest green */
.progress {
  position: relative;
  width: min(400px, calc(100vw - 48px));
  height: 30px;
  border-radius: 20px;
  background: linear-gradient(to right, rgba(156, 197, 168, 0.16), rgba(228, 238, 231, 0.24));
}

.progress-done {
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  font-weight: bolder;
  font-size: 14px;
  color: #fff;
  height: 100%;
  width: 0;
  min-width: 46px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  overflow: hidden;
  white-space: nowrap;
  background: linear-gradient(to left, rgb(47, 107, 79), rgb(156, 197, 168));
  box-shadow: 0 3px 60px -6px rgb(47, 107, 79);
}

/* ---------- Hero ---------- */

.hero {
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  background: var(--bg-gradient), var(--forest-900);
  touch-action: none;
  will-change: transform;
}

.hero-track {
  position: absolute;
  inset: 0;
}

/* Columns are laid out by JS in whole pixels and overlap by 1px, so no seam can show between them. */
.hero-col {
  position: absolute;
  top: 0;
  height: 100%;
  overflow: hidden;
}

/* One strip per column; holds the current slide (plus the incoming one during a transition). */
.hero-strip {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.hero-slide {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.hero-slide img {
  position: absolute;
  top: 0;
  left: var(--img-left, 0);
  width: var(--hw, 100vw);
  max-width: none;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.hero-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to top, rgba(5, 13, 9, 0.72) 0%, rgba(8, 21, 15, 0.25) 22%, transparent 42%),
    linear-gradient(to bottom, rgba(5, 13, 9, 0.35) 0%, transparent 18%),
    radial-gradient(120% 100% at 50% 50%, transparent 60%, rgba(16, 41, 30, 0.45) 100%);
}

.hero-nav {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.hero-arrow {
  width: 40px;
  height: 44px;
  background: url("data:image/svg+xml,%3Csvg width='10' height='29' viewBox='0 0 10 29' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9 0V27L1 17.4857' stroke='%23e4eee7' stroke-width='2' /%3E%3C/svg%3E") no-repeat center / 10px 29px;
  transition: transform 0.6s ease, opacity 0.4s ease;
}

.hero-prev {
  transform: scaleY(-1);
}

.hero-prev:active {
  transform: scaleY(-1) translateY(6px);
}

.hero-next:active {
  transform: translateY(6px);
}

.hero-prev[disabled] {
  opacity: 0.25;
  cursor: default;
}

.hero.at-start .hero-next {
  animation: nudge 2.4s ease-in-out 1.5s infinite;
}

@keyframes nudge {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(7px); }
}

.hero-ticks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hero-ticks span {
  display: block;
  width: 2px;
  height: 18px;
  border-radius: 2px;
  background: rgba(228, 238, 231, 0.22);
  transition: background 0.6s ease, height 0.6s var(--ease-smooth);
}

.hero-ticks span.active {
  height: 30px;
  background: linear-gradient(to bottom, var(--mist), var(--moss));
}

/* ---------- Gallery ---------- */

.gallery {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: var(--bg-gradient), var(--forest-900);
  visibility: hidden;
}

.viewport {
  position: absolute;
  inset: 0;
  z-index: 0;
  isolation: isolate; /* keep the moving grid in its own layer, under the buttons */
  overflow: hidden;
  touch-action: none;
}

.view-gallery .viewport {
  cursor: grab;
}

.dragging .viewport {
  cursor: grabbing;
}

.canvas-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.grid-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.grid-item {
  position: absolute;
  width: 320px;
  height: 320px;
  overflow: hidden;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--forest-700), var(--forest-850));
  cursor: pointer;
  will-change: transform, opacity;
}

.grid-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  transition: transform 1s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (hover: hover) {
  .grid-item:hover img {
    transform: scale(1.06);
  }
}

.gallery-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(5, 13, 9, 0.45) 0%, transparent 8%),
    linear-gradient(to top, rgba(5, 13, 9, 0.8) 0%, transparent 20%),
    radial-gradient(130% 110% at 50% 50%, transparent 55%, rgba(8, 21, 15, 0.7) 100%);
}

.gallery-controls {
  position: absolute;
  z-index: 5;
  transform: translateZ(0); /* own layer, so Safari can't hit-test the 3D-moved grid above it */
  right: var(--gutter);
  bottom: calc(72px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
}

.gallery-controls {
  transition: opacity 0.5s ease;
}

.gallery.ui-visible .gallery-controls {
  opacity: 1;
}

.gallery:not(.ui-visible) .gallery-controls {
  pointer-events: none;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  visibility: hidden;
  touch-action: none;
}

.lightbox.open {
  visibility: visible;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  background:
    radial-gradient(90% 80% at 50% 45%, rgba(22, 58, 42, 0.82) 0%, rgba(8, 21, 15, 0.93) 60%, rgba(5, 13, 9, 0.97) 100%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.lightbox-frame {
  position: fixed;
  z-index: 1;
  top: 0;
  left: 0;
  overflow: hidden;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--forest-700), var(--forest-850));
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
  will-change: transform;
}

.lightbox-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.lightbox-close {
  position: absolute;
  z-index: 5;
  transform: translateZ(0);
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: var(--gutter);
  opacity: 0;
}

.lightbox-step {
  position: absolute;
  z-index: 5;
  top: 50%;
  margin-top: -21px;
  opacity: 0;
  display: none;
}

/* Arrows for mouse users on roomy screens; touch screens swipe instead (matches arrowsMQ in main.js). */
@media (hover: hover) and (min-width: 701px) and (min-height: 501px) {
  .lightbox-step {
    display: grid;
  }
}

.lightbox-prev { left: var(--gutter); }
.lightbox-next { right: var(--gutter); }

/* ---------- Footer ---------- */

.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(18px + var(--safe-b));
  z-index: 30;
  display: flex;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
}

.site-footer a {
  pointer-events: auto;
  position: relative;
  padding: 4px 2px;
  font-size: clamp(12px, 0.35vw + 9px, 16px);
  letter-spacing: 0.22em;
  text-decoration: none;
  color: transparent;
  background: linear-gradient(90deg, var(--sage) 0%, var(--mist) 45%, var(--moss) 100%);
  background-size: 200% 100%;
  background-position: 0% 0;
  -webkit-background-clip: text;
  background-clip: text;
  transition: background-position 0.8s ease;
}

.site-footer a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0.22em;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--sage), transparent);
  transform: scaleX(0);
  transition: transform 0.6s var(--ease-smooth);
}

@media (hover: hover) {
  .site-footer a:hover {
    background-position: 100% 0;
  }

  .site-footer a:hover::after {
    transform: scaleX(1);
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 700px), (max-height: 500px) {
  :root {
    --gutter: 16px;
  }

  .year,
  .site-footer a {
    font-size: 12px;
  }

  .hero-nav {
    right: 6px;
    gap: 14px;
  }

  .ui-btn {
    width: 40px;
    height: 40px;
  }

  .gallery-controls {
    bottom: calc(64px + var(--safe-b));
    gap: 8px;
  }
}

/* Phones held sideways: very little height, so tighten everything vertically. */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-nav {
    gap: 8px;
  }

  .hero-arrow {
    height: 34px;
  }

  .hero-ticks span {
    height: 12px;
  }

  .hero-ticks span.active {
    height: 20px;
  }

  .gallery-controls {
    bottom: calc(14px + var(--safe-b));
  }

  .year,
  .site-footer {
    bottom: calc(12px + var(--safe-b));
  }
}

/* Big screens: give the little UI a bit more presence. */
@media (min-width: 1800px) and (min-height: 900px) {
  :root {
    --gutter: 36px;
  }

  .ui-btn {
    width: 48px;
    height: 48px;
  }

  .ui-btn svg {
    width: 20px;
    height: 20px;
  }

  .hero-nav {
    right: 24px;
  }
}
