:root {
  color-scheme: dark;

  --bg: #151413;
  --frame: #1d1c1a;
  --ink: 236 231 223;

  --screen-h: 100vh;
  --edge: 16px;

  /* 写真。16:9 を保ったまま、画面の幅か高さのどちらかいっぱいまで広げる。 */
  --frame-w: min(100vw, var(--screen-h) * 16 / 9);
  --frame-h: calc(var(--frame-w) * 9 / 16);
}

html {
  height: 100%;
  background: var(--bg);
  overscroll-behavior: none;
}

body {
  height: var(--screen-h);
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: rgb(var(--ink));
  font-family: "Avenir Next", Avenir, "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* 写真 */

.stage {
  display: grid;
  place-items: center;
  height: 100%;
}

.frame {
  position: relative;
  isolation: isolate;
  width: var(--frame-w);
  aspect-ratio: 16 / 9;
  margin: 0;
  background: var(--frame);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/*
 * 猫やホワイトボードが写真の端まで写っているため、切り抜かない。
 * 写真は 1672×941 で 16:9 との差が約 0.05% しかなく、contain では左右に 1px の隙間が出る。
 * fill で枠に合わせれば、伸縮は 1px 未満で、切り抜きも隙間も出ない。
 *
 * 2枚を重ね、新しい写真を上に載せてフェードインさせる。前の写真は下に残し、暗転させない。
 */
.photo {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: 0;
  -webkit-user-drag: none;
}

.photo.is-loaded {
  opacity: 1;
}

.photo.is-front {
  z-index: 1;
}

/* 60秒で一周するプログレスバー。写真の底辺に重ねる。 */

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  height: 3px;
  overflow: hidden;
  background: rgb(0 0 0 / 0.22);
  pointer-events: none;
}

.progress-fill {
  display: block;
  height: 100%;
  background: rgb(var(--ink) / 0.82);
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

/* 全画面切替ボタン。写真の右下隅に重ねる。 */

.fullscreen {
  position: fixed;
  right: calc((100vw - var(--frame-w)) / 2 + var(--edge));
  bottom: calc((var(--screen-h) - var(--frame-h)) / 2 + var(--edge));
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.18);
  color: rgb(var(--ink) / 0.9);
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.3));
  opacity: 0.45;
  cursor: pointer;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}

.fullscreen[hidden] {
  display: none;
}

.fullscreen svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fullscreen[aria-pressed="false"] .icon-exit,
.fullscreen[aria-pressed="true"] .icon-enter {
  display: none;
}

.fullscreen:hover {
  opacity: 1;
  background: rgb(0 0 0 / 0.42);
}

.fullscreen:focus-visible {
  opacity: 1;
  background: rgb(0 0 0 / 0.42);
  outline: 1px solid rgb(var(--ink) / 0.6);
  outline-offset: 2px;
}

/* 写真のフェードは app.js で同じ設定を見て止める。 */
@media (prefers-reduced-motion: reduce) {
  .fullscreen {
    transition: none;
  }
}
