/* ハタチたち ブースの受け取りページ。白地に黒の文字、強い色はコーラル1色 (主な操作だけ)。 */

:root {
  --bg: #ffffff;
  --text: #111111;
  --sub: #6b6b6b;
  --fill: #f3f3f3;
  --fill-press: #e7e7e7;
  --accent: #ff5757;
  --accent-press: #e84e4e;
  --gutter: 20px;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  line-break: strict;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + 16px)
    calc(env(safe-area-inset-right) + var(--gutter))
    calc(env(safe-area-inset-bottom) + 40px)
    calc(env(safe-area-inset-left) + var(--gutter));
}

.masthead {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 20px;
}

.status {
  margin-top: 28px;
}

.headline {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.lead {
  margin: 6px 0 0;
  font-size: 15px;
  color: var(--sub);
}

.note,
.inapp {
  margin: 16px 0 0;
  font-size: 14px;
}

.inapp p {
  margin: 0 0 12px;
}

/* ---------- 写真 ---------- */

.photo-body {
  margin-top: 24px;
}

/* 左右にスワイプ。次の1枚の端を少しだけ見せる */
.slider {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 calc(-1 * var(--gutter));
  padding: 0 0 0 var(--gutter);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.slider::-webkit-scrollbar {
  display: none;
}

.slider::after {
  content: "";
  flex: 0 0 calc(var(--gutter) - 8px);
  height: 1px;
}

.slide {
  flex: 0 0 calc(100% - var(--gutter));
  margin: 0;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.frame {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--fill);
  border-radius: 10px;
  overflow: hidden;
}

.frame img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  visibility: hidden;
}

.frame.is-ready img {
  visibility: visible;
}

.ph {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--sub);
}

.frame.is-ready .ph,
.vframe.has-video .ph {
  display: none;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #dadada;
  border-top-color: #8c8c8c;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 12px;
}

.thumb {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin: 0;
  padding: 6px 0 4px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--sub);
  font: inherit;
  font-size: 12px;
  line-height: 1.3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.timg {
  display: block;
  width: 48px;
  aspect-ratio: 4 / 5;
  border-radius: 6px;
  background: var(--fill);
  overflow: hidden;
  outline: 2px solid transparent;
  outline-offset: 2px;
}

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

.timg img:not([src]) {
  display: none;
}

.thumb[aria-selected="true"] {
  color: var(--text);
  font-weight: 600;
}

.thumb[aria-selected="true"] .timg {
  outline-color: var(--text);
}

.thumb:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.controls {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  font-size: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 31px;
  background: #d9d9d9;
  cursor: pointer;
  transition: background-color 0.2s;
}

.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s;
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::before {
  transform: translateX(20px);
}

.switch:disabled {
  opacity: 0.4;
  cursor: default;
}

.switch:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ---------- ボタンと案内 ---------- */

.btn {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 12px 16px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn.primary {
  background: var(--accent);
  color: #ffffff;
}

.btn.primary:active {
  background: var(--accent-press);
}

.btn.secondary {
  background: var(--fill);
  color: var(--text);
}

.btn.secondary:active {
  background: var(--fill-press);
}

.btn:disabled,
.btn.primary:disabled {
  background: var(--fill);
  color: #a3a3a3;
  cursor: default;
}

.btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.retry {
  margin-top: 24px;
}

.help {
  font-size: 14px;
}

.help-text {
  margin: 4px 0 0;
}

.dl-note {
  margin: 0;
  font-size: 14px;
  color: var(--sub);
}

.filelink,
.textbtn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.textbtn {
  -webkit-appearance: none;
  appearance: none;
  padding: 0 8px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.expiry {
  margin: 40px 0 0;
  font-size: 13px;
  color: var(--sub);
}

/* ---------- 動画 ---------- */

.videos {
  display: grid;
  gap: 40px;
  margin-top: 28px;
}

.vname {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}

/* 縦長の動画でも画面に収まるように、高さの上限から幅を決める */
.vframe {
  --arw: 9;
  --arh: 16;
  position: relative;
  width: min(100%, calc(72vh * var(--arw) / var(--arh)));
  width: min(100%, calc(72svh * var(--arw) / var(--arh)));
  aspect-ratio: var(--arw) / var(--arh);
  margin: 0 auto;
  background: var(--fill);
  border-radius: 10px;
  overflow: hidden;
}

.vframe video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000000;
  visibility: hidden;
}

.vframe.has-video video {
  visibility: visible;
}

.vitem .btn {
  margin-top: 12px;
}

.vitem .help {
  margin-top: 8px;
}

@media (hover: hover) {
  .btn.primary:not(:disabled):hover {
    background: #f75050;
  }

  .btn.secondary:not(:disabled):hover {
    background: #ececec;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }

  .switch,
  .switch::before {
    transition: none;
  }
}
