/* 5 Years（v5）の共通部分。トップと年ページが両方読む。 */

:root {
  --ink: #14213d;
  --sea: #e8f1f6;
  --paper: #fbfcfd;
  --coral: #ff6b57;
  --mute: #6b7a8c;
  --sans: "Zen Kaku Gothic New", system-ui, sans-serif;
  --min: "Shippori Mincho", serif;
  --num: "Fraunces", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.8;
  /* ヒーローの柱は傾けて画面の外まで伸ばすので、横のはみ出しだけ切る。
     overflow-x: hidden だと position: sticky が効かなくなる。 */
  overflow-x: clip;
}

a {
  color: inherit;
  text-decoration: none;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

video,
img {
  background: var(--sea);
}

/*
 * ダーク（仮。?theme=dark で html に dark が付く）。構造は変えず、色の値だけを夜に差し替える。
 * 地はヒーローと同じ紺の系統、字はクリーム。コントラストは本文 14.5:1、控えめな字 7.4:1 以上。
 */
html.dark {
  --ink: #f3ecdf;
  --paper: #111a3a;
  --sea: #1a244d;
  --mute: #aeb6cb;
}

/* 夜の地で写真が沈まないよう、細い縁と深い影を付ける。 */
html.dark :is(.cut:not(.cut--v), .cut--v video, .m, .divider__f, .yhero video, .yhero .pin > img) {
  box-shadow:
    0 0 0 1px rgba(243, 236, 223, 0.14),
    0 16px 36px rgba(0, 0, 0, 0.5);
}

/* 夏は紺の吹き出しにクリームの字、翔はクリームの吹き出しに紺の字。 */
html.dark .chat {
  background: #19234a;
  box-shadow: 0 0 0 1px rgba(243, 236, 223, 0.08);
}

html.dark .bub {
  background: #2b3769;
}

html.dark .bub--me {
  background: var(--ink);
  color: #1a2240;
}

html.dark .final b {
  text-shadow: 0 0 40px rgba(245, 200, 120, 0.3);
}

/* 前の日と帰ってからの会話 */
.chat {
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(20, 33, 61, 0.1);
}

.lbl {
  font: 300 11px var(--num);
  letter-spacing: 0.22em;
  color: var(--mute);
  margin: 8px 0 4px;
}

.lbl:first-child {
  margin-top: 0;
}

.bub {
  max-width: 90%;
  padding: 8px 13px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  margin: 5px 0;
  background: #eef3f7;
  width: fit-content;
}

.bub--me {
  background: var(--ink);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.bub--her {
  border-bottom-left-radius: 4px;
}

/* 手紙と最後 */
.letter {
  margin: 140px 0 0;
  padding: 70px 24px;
  background: var(--sea);
  border-radius: 24px;
  text-align: center;
}

.letter h2 {
  font-family: var(--min);
  font-size: 28px;
  margin: 0 0 24px;
  font-weight: 500;
}

.letter p {
  max-width: 32em;
  margin: 0 auto 1.2em;
  color: var(--mute);
  text-align: left;
  text-wrap: pretty;
}

.letter p:last-child {
  margin-bottom: 0;
}

.final {
  padding: 90px 20px 140px;
  text-align: center;
}

.final b {
  font: italic 300 clamp(64px, 14vw, 140px) / 1 var(--num);
  display: block;
  color: var(--coral);
}

.final p {
  color: var(--mute);
  margin: 14px 0 0;
}

/* 写真はダブルタップでハートを出すので、拡大の既定動作を切る。 */
[data-lb] img,
[data-lb] video {
  touch-action: manipulation;
  cursor: zoom-in;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ダブルタップのハート。タップした点に置き、粒を 8 方向へ飛ばす。 */
.pop {
  position: fixed;
  width: 0;
  height: 0;
  z-index: 80;
  pointer-events: none;
}

.pop svg {
  position: absolute;
  width: 86px;
  height: 80px;
  left: -43px;
  top: -40px;
  fill: var(--coral);
  animation: heart 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards;
}

@keyframes heart {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  18% {
    transform: scale(1.22);
    opacity: 1;
  }
  34% {
    transform: scale(0.94);
  }
  50% {
    transform: scale(1);
  }
  78% {
    transform: translateY(-8px) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-46px) scale(1.08);
    opacity: 0;
  }
}

.pop b {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f5c878;
  animation: spark 0.7s ease-out 0.08s both;
}

.pop b:nth-of-type(even) {
  background: var(--coral);
  width: 6px;
  height: 6px;
}

@keyframes spark {
  from {
    transform: rotate(var(--a)) translateY(-18px) scale(1);
    opacity: 1;
  }
  to {
    transform: rotate(var(--a)) translateY(-78px) scale(0.2);
    opacity: 0;
  }
}

/* 全画面のライトボックス。v5-touch.js が 1 つだけ差し込む。 */
.lb {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(10, 14, 26, 0.96);
  color: #fff;
  overflow: hidden;
  touch-action: none;
}

.lb::backdrop {
  background: rgba(10, 14, 26, 0.6);
}

.lb[open] {
  display: grid;
  grid-template-rows: 1fr auto;
  animation: lb-in 0.22s ease-out;
}

@keyframes lb-in {
  from {
    opacity: 0;
  }
}

.lb__stage {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: calc(56px + env(safe-area-inset-top, 0px)) 12px 8px;
}

.lb__stage > * {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  background: none;
  transition:
    transform 0.25s ease,
    opacity 0.25s ease;
}

.lb__stage > .is-drag {
  transition: none;
}

.lb__cap {
  margin: 0;
  padding: 12px 20px calc(18px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  line-height: 1.5;
}

.lb__cap b {
  display: block;
  font: 500 16px var(--min);
}

.lb__cap span {
  font: 300 13px var(--num);
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 6px;
}

.lb button {
  position: absolute;
  z-index: 2;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font: 22px/1 var(--sans);
  cursor: pointer;
}

.lb__x {
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 12px;
}

.lb__prev,
.lb__next {
  top: 50%;
  margin-top: -22px;
}

.lb__prev {
  left: 12px;
}

.lb__next {
  right: 12px;
}

/* 指でめくる手のひらでは、左右の釦は写真を隠すだけになる。 */
@media (hover: none) {
  .lb__prev,
  .lb__next {
    display: none;
  }
}

.lb[data-n="1"] .lb__prev,
.lb[data-n="1"] .lb__next {
  display: none;
}

html.has-modal {
  overflow: hidden;
}

/*
 * 動きは scroll-driven animation だけで作る。対応していないブラウザでは
 * この塊ごと無視され、全部が表示された静的なページとして読める。
 */
@supports (animation-timeline: scroll()) {
  .rise {
    animation: rise linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 70%;
  }

  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(40px) scale(0.97);
    }
    to {
      opacity: 1;
      transform: translateY(0) rotate(var(--tilt, 0deg));
    }
  }

  .bub {
    animation: pop linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 90%;
  }

  @keyframes pop {
    from {
      opacity: 0;
      transform: translateY(14px) scale(0.94);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
  }
}
