/* ---------------------------------------------------------------------------
   200years.cn - the photograph is the page.

   One layer only: the photo, pinned to the viewport. The segmented control at
   the bottom switches how that one frame is fitted; whatever is left over is
   filled with the page's black, never with a panel or a scrim.
--------------------------------------------------------------------------- */

:root {
  /* A 64x48, 138-byte copy of the same photo gives an instant first paint; the
     script in index.html swaps in the real file once it has decoded. */
  --hero-image: url("/assets/200years-blur.webp");

  /* How the frame meets the viewport. Rewritten by the switcher in
     index.html: `100% auto` | `auto 100%` | `contain` | `cover`. */
  --fit: 100% auto;

  --void: #000;   /* the page itself, and every leftover edge */
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
  background: var(--void);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--void);
}

/* ---- the photo --------------------------------------------------------- */

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: var(--hero-image);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: var(--fit);
  /* Out of focus until the full-size frame arrives, then eased into focus. */
  filter: blur(14px);
  transform: scale(1.06);
  will-change: filter, transform;
}

body.ready::before {
  filter: none;
  transform: none;
  transition: filter 0.6s ease, transform 0.6s ease;
}

/* ---- fit switcher ------------------------------------------------------ */

.fit {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(0.7rem, 2.4vh, 1.5rem));
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  gap: 0.1rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: rgba(8, 8, 8, 0.34);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  transition: opacity 0.55s ease;
}

/* Left alone for a while: fade all the way out and stop taking clicks. Opacity
   rather than visibility, so the buttons stay reachable by keyboard. */
.fit.is-idle {
  opacity: 0;
  pointer-events: none;
}

/* Focused from the keyboard: always visible. */
.fit:focus-within {
  opacity: 1;
  pointer-events: auto;
}

.fit button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.36rem 0.72rem;
  background: none;
  color: rgba(255, 255, 255, 0.6);
  font: inherit;
  font-size: clamp(0.68rem, 1.4vw, 0.78rem);
  letter-spacing: 0.06em;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.18s ease, background-color 0.18s ease;
}

.fit button:hover {
  color: #fff;
}

.fit button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.fit button:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.72);
  outline-offset: 1px;
}

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

  body.ready::before {
    transition: none;
  }
}
