/* iPad Garden アドベントカレンダー2026 試作（ローカル確認用） */

:root {
  color-scheme: light;
  --cream: #f8ecdc;
  --paper: #fffaf3;
  --ink: #3b2f2a;
  --ink-soft: #66564d;
  --red: #a64b42;
  --red-deep: #8f4139;
  --coral: #e0785e;
  --green: #3d6652;
  --green-deep: #2f5241;
  --gold: #c39331;
  --gold-light: #ffd978;
  --line: #eadfcd;
  --font: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--cream);
  background-image: url("images/paper-texture-cream-v1-1254.jpg");
  background-image: image-set(url("images/paper-texture-cream-v1-1254.webp") type("image/webp"), url("images/paper-texture-cream-v1-1254.jpg") type("image/jpeg"));
  background-size: 627px 627px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.8;
  letter-spacing: .03em;
  line-break: strict;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }
.nb { display: inline-block; }
[hidden] { display: none !important; }

/* ---------- 試作用パネル ---------- */
.proto-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  padding: 8px 16px;
  background: repeating-linear-gradient(-45deg, #fff4cc 0 12px, #fbeab0 12px 24px);
  border-bottom: 2px dashed #c9a640;
  font-size: 13.5px; line-height: 1.5;
}
.proto-bar[hidden] { display: none; }
.proto-bar__tag { background: #5a4a10; color: #fff; font-weight: 700; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.proto-bar__label { font-weight: 500; }
.proto-bar__select { font: inherit; padding: 4px 6px; border-radius: 6px; border: 1px solid #b89a3e; background: #fff; max-width: 100%; }
.proto-bar__now { color: var(--ink-soft); }

/* ---------- 飾りの星 ----------
   ・読み上げ対象外（aria-hidden）、タップを遮らない（pointer-events: none）。
   ・一部の星だけが時々ふっときらめく（少し明るく・少し大きく）。動きを減らす設定では静止。 */
.stars { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.star { position: absolute; width: var(--s, 24px); height: auto; transform: rotate(var(--r, 0deg)); opacity: calc(var(--o, 1) * .8); }
/* 4〜5秒ごとに、星ごとにずらして、ふわっと明るくなって戻る（約1.2秒）。
   光の強さは明るさ（opacity）と大きさだけで表す。filter の動きは iPhone でちらつくため使わない */
.star {
  animation: twinkle var(--dur, 4.6s) ease-in-out var(--delay, 0s) infinite;
  transform-origin: 50% 50%; will-change: transform, opacity;
}
.star--h1 { --dur: 4.4s; --delay: .2s; }
.star--h2 { --dur: 4.9s; --delay: 2.6s; }
.star--h3 { --dur: 4.6s; --delay: 1.3s; }
.star--h4 { --dur: 5s;   --delay: 3.5s; }
.star--s1 { --dur: 4.8s; --delay: .9s; }
.star--s2 { --dur: 4.3s; --delay: 2.9s; }
.star--s3 { --dur: 5s;   --delay: 1.9s; }
.star--s4 { --dur: 4.5s; --delay: 3.8s; }
@keyframes twinkle {
  0%, 70%, 100% { opacity: calc(var(--o, 1) * .8); transform: rotate(var(--r, 0deg)) scale(1); }
  82% { opacity: 1; transform: rotate(var(--r, 0deg)) scale(1.08); }
  94% { opacity: calc(var(--o, 1) * .8); transform: rotate(var(--r, 0deg)) scale(1); }
}
/* 作品画面そのもの（フォーカス先）には枠を出さない */
.viewer:focus, .viewer:focus-visible { outline: none; }

/* 見出しまわり（スマホ基準） */
/* スマホ：ロゴの左右と「2026」の左右（タイトル文字とは重ねない） */
.star--h1 { --s: 26px; --r: -8deg; left: 14%; top: 22px; }
.star--h2 { --s: 15px; --r: 12deg; left: 24%; top: 112px; --o: .85; }
/* スマホ：右上は音楽ボタンがあるので、この星はロゴの左下・タイトルの左外側へ */
.star--h3 { --s: 16px; --r: 6deg;  left: 5%; top: 58px; }
.star--h4 { --s: 17px; --r: -10deg; right: 23%; top: 108px; --o: .9; }

/* おうちの左右（パソコン幅で表示） */
.stars--side .star { display: none; }

/* ---------- 見出し ---------- */
.head { position: relative; text-align: center; padding: 22px 16px 4px; max-width: 760px; margin: 0 auto; }
.head > :not(.stars) { position: relative; z-index: 1; }
.head__logo { margin: 0 0 10px; }
/* 音楽ボタン：ロゴの右側の余白（見出しの段は増やさない）。文字は小さめ、押せる範囲は余白で確保 */
.head > .music-btn {
  position: absolute; z-index: 2; right: 8px; top: 18px;
  display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 1.5px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .85);
  color: var(--ink); line-height: 1; cursor: pointer;
}
.music-btn__icon { position: relative; font-size: 18px; color: var(--ink-soft); }
.music-btn[aria-pressed="false"] .music-btn__icon::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 18px; height: 1.5px; border-radius: 999px;
  background: currentColor; box-shadow: 0 0 0 1px #fff;
  transform: translate(-50%, -50%) rotate(-45deg);
}
.music-btn[aria-pressed="true"] { border-color: var(--green); background: #fff; }
.music-btn[aria-pressed="true"] .music-btn__icon { color: var(--green-deep); }
/* @Gardenロゴ（横長・透過余白は詰め済み）。スマホは小さめにして、おうちまでの距離を伸ばさない */
.head__logo { line-height: 0; }
.head__logo img { height: 32px; width: auto; margin: 0 auto; }
.head__title { margin: 0; color: var(--red); font-weight: 700; line-height: 1.3; font-size: clamp(24px, 7.4vw, 40px); letter-spacing: .04em; }
.head__year { display: block; color: var(--green); font-size: .62em; letter-spacing: .12em; }

/* ---------- 短い案内（説明・状況・凡例を1つにまとめたもの） ---------- */
.stage { padding: 6px 16px 24px; position: relative; }
.guide {
  margin: 0 auto 4px; text-align: center;
  font-size: 14.5px; font-weight: 500; line-height: 1.5; color: var(--ink);
}
.guide__dot {
  display: inline-block; width: .95em; height: .95em; margin-right: .4em; vertical-align: -.1em;
  border-radius: 50%; background: var(--green-deep); box-shadow: 0 0 0 1.5px #fff8e8, 0 0 0 2.5px rgba(47, 82, 65, .35);
}
.guide[data-phase="before"], .guide[data-phase="after"] { color: var(--green-deep); font-weight: 700; }

/* ---------- おうち ---------- */
.house-wrap { position: relative; max-width: 600px; margin: 0 auto; }
.house { position: relative; width: 100%; container-type: inline-size; z-index: 1; }
.house__img { width: 100%; }

/* 狭い画面：外側の余白を詰めて窓を大きくする（透過画像の左右にも少し余白がある） */
@media (max-width: 420px) {
  .stage { padding-left: 0; padding-right: 0; }
  .guide { margin-left: 12px; margin-right: 12px; }
}

/* 押せる範囲（ボタン）：見た目の窓より少し広い。隣の窓とは重ならない */
.spot {
  position: absolute;
  margin: 0; padding: 0; border: 0; background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.spot:focus { outline: none; }
.spot[data-state="future"] { cursor: default; }

/* 見た目の窓（元画像の窓の位置） */
.spot__win {
  position: absolute;
  border-radius: 48% 48% 6% 6% / 36% 36% 4% 4%;
}
.spot--door .spot__win { border-radius: 48% 48% 4% 4% / 30% 30% 3% 3%; }
.spot:focus-visible .spot__win { outline: 3px solid #fff; box-shadow: 0 0 0 6px var(--coral); }

/* 窓の下側だけを照らし、扉の色と紙の質感を見せる。 */
.spot__glow {
  position: absolute; inset: 4% 7% 9%;
  border-radius: 46% 46% 4% 4% / 34% 34% 3% 3%;
  background: radial-gradient(ellipse 54% 48% at 50% 82%, rgba(255, 232, 170, .81) 0%, rgba(255, 196, 104, .37) 50%, transparent 100%);
  opacity: 0;
  transition: opacity .3s ease;
}
/* 玄関：光の切れ目がドア板の途中に来て横線に見えるため、枠の中で透明まで消えきる形にする。
   楕円は上下左右の端（中心57%±38%、50%±46%）に届く前に透明になる大きさ。
   中心を数字の丸の少し下に置き、明るい芯を広めに取って、丸に隠れても他の窓と同じくらい明るく見せる。色と濃さは他の窓と同じ */
.spot--door .spot__glow {
  inset: 4% 10% 12%;
  background: radial-gradient(ellipse 46% 38% at 50% 57%, rgba(255, 232, 170, .81) 0%, rgba(255, 232, 170, .81) 40%, rgba(255, 196, 104, .37) 85%, transparent 100%);
}
.spot[data-state="open"] .spot__glow,
.spot[data-state="today"] .spot__glow { opacity: 1; }

/* 番号のプレート：塗りつぶし＝見られる／輪郭だけ＝まだ。ホバーなしで常に見分けられる */
.spot__num {
  position: absolute; left: 50%; top: 46%;
  transform: translate(-50%, -50%);
  display: grid; place-items: center;
  width: max(26px, 7.4cqw); height: max(26px, 7.4cqw);
  border-radius: 50%;
  font-weight: 700; line-height: 1; letter-spacing: 0;
  font-size: max(14px, 3.9cqw);
  font-variant-numeric: tabular-nums;
  transition: transform .2s ease;
  /* 未来：塗りなし、細めの輪郭と読める濃さの数字 */
  background: transparent;
  color: #4a3b33;
  border: 1.5px solid rgba(74, 59, 51, .75);
  text-shadow: 0 0 3px rgba(255, 250, 243, .95), 0 0 1px #fff;
}
.spot--door .spot__num { top: 40%; }
/* 玄関の扉は濃い緑。未来の数字を明るい色にすると「色つきの数字（開いている日）」に見えるため、
   丸を窓のガラスに近いベージュで少し透けさせて塗り、文字と枠は他の未来の窓と同じ濃い茶色にする。
   最終日なので少しだけ特別、ただし下の段で24だけが浮かない明るさにとどめる */
.spot--door[data-state="future"] .spot__num {
  background: rgba(240, 226, 198, .8); color: #4a3b33;
  border-color: rgba(74, 59, 51, .75);
  text-shadow: none;
}

/* 公開済み：濃い緑の塗りつぶし＋白い数字 */
.spot[data-state="open"] .spot__num {
  background: var(--green-deep); color: #fff; text-shadow: none;
  border: 2px solid #fff8e8;
  box-shadow: 0 1px 3px rgba(30, 40, 30, .35);
}
/* 玄関の公開済み：濃い緑の扉に埋もれないよう、クリーム色の枠を太くする */
.spot--door[data-state="open"] .spot__num {
  border-width: 3px;
  box-shadow: 0 0 0 1px rgba(30, 40, 30, .35), 0 1px 4px rgba(30, 40, 30, .45);
}
/* 当日：赤の塗りつぶし＋白い数字（＋小さな「今日」の札） */
.spot[data-state="today"] .spot__num {
  background: var(--red); color: #fff; text-shadow: none;
  border: 2px solid #fff8e8;
  box-shadow: 0 1px 3px rgba(60, 20, 10, .35);
}

/* 「今日」の札：当日の1か所だけ */
.spot__tag:empty { display: none; }
.spot__tag {
  position: absolute; left: 50%; bottom: 13%;
  transform: translateX(-50%);
  background: var(--red); color: #fff;
  font-size: max(10px, 2.2cqw); font-weight: 700; line-height: 1; letter-spacing: .02em;
  padding: .3em .55em; border-radius: 999px; white-space: nowrap;
  border: 1.5px solid #fff8e8;
}
.spot--door .spot__tag { bottom: 22%; }
/* おうちの幅が狭いとき：番号を少し上げ、札を窓の下端へ下ろして重ならないようにする */
@container (max-width: 420px) {
  .spot__num { top: 36%; }
  .spot__tag { bottom: 2%; }
  .spot--door .spot__num { top: 35%; }
  .spot--door .spot__tag { bottom: 16%; }
}

/* 押したときの反応 */
.spot.is-press .spot__num { animation: press .22s ease; }
@keyframes press { 50% { transform: translate(-50%, -50%) scale(1.18); } }
.spot.is-nope .spot__num { animation: nope .35s ease; }
@keyframes nope { 25% { transform: translate(-58%, -50%); } 75% { transform: translate(-42%, -50%); } }
@media (hover: hover) {
  .spot:not([data-state="future"]):hover .spot__num { transform: translate(-50%, -50%) scale(1.1); }
}

/* 未来の日を押したときのお知らせ */
.toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 5;
  transform: translate(-50%, 12px);
  width: max-content; max-width: calc(100% - 32px);
  margin: 0; padding: 10px 18px;
  background: rgba(59, 47, 42, .92); color: #fff;
  border-radius: 12px; font-size: 14px; line-height: 1.6; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

.foot { text-align: center; padding: 8px 16px 32px; font-size: 13px; color: var(--ink-soft); line-height: 1.7; }
.foot p { margin: 0; }

/* ---------- 作品の表示画面 ----------
   作品が主役。順番は「× 閉じる → 作品 → 日付｜作者名（＋音の操作）→ リンク」。
   鑑賞中は枠・文字を動かさない（開くときの約0.25秒の切り替えだけ）。 */
.viewer {
  --gap: 24px;
  width: min(calc(100% - var(--gap)), 720px);
  max-height: calc(100% - var(--gap));
  padding: 0; border: 0; border-radius: 16px;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 16px 48px rgba(40, 20, 10, .35);
  overflow: auto;
  overscroll-behavior: contain;
}
.viewer::backdrop { background: rgba(40, 24, 16, .68); }
.viewer[open] { animation: viewerIn .25s ease-out; }
.viewer[open]::backdrop { animation: fadeIn .25s ease-out; }
@keyframes viewerIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes fadeIn { from { opacity: 0; } }

/* 閉じる：作品とは別の細い帯に1つだけ。スクロールしても上に残る */
.viewer__bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: flex-end;
  padding: 6px 6px 4px;
  background: var(--paper);
}
.viewer__close {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: 999px; background: #fff;
  cursor: pointer; font-size: 14px; font-weight: 700; color: var(--ink);
}
.viewer__close-x { font-size: 20px; line-height: 1; }

.viewer__body { padding: 0 12px 16px; }

/* 作品：縦横比を保ち、画面に収まる最大の大きさ（切らない・重ねない）
   --maxh = 画面の高さ − 外側の余白・閉じる帯・下の文字欄 */
.viewer__media {
  --maxh: max(220px, calc(100dvh - var(--gap) - 54px - 112px));
  width: min(100%, calc(var(--maxh) * var(--ar, 1.5)));
  aspect-ratio: var(--ar, 1.5);
  margin: 0 auto;
  background: #efe4d3; border-radius: 10px; overflow: hidden;
}
.viewer__media img, .viewer__media video { width: 100%; height: 100%; object-fit: contain; display: block; }
/* 動画：端末の操作バーの代わりに、作品全体が「一時停止／再生」のボタン。▶ は止まっているときだけ */
.viewer__media { position: relative; }
.viewer__play {
  position: absolute; inset: 0; z-index: 1; padding: 0; border: 0; border-radius: inherit;
  background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.viewer__play:focus-visible { outline: 3px solid var(--coral); outline-offset: -5px; }
.viewer__play-icon {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%; background: rgba(40, 32, 28, .55);
  opacity: 0; transition: opacity .2s ease;
}
.viewer__play-icon::before {
  content: ""; position: absolute; left: 22px; top: 17px;
  border-style: solid; border-width: 11px 0 11px 18px; border-color: transparent transparent transparent #fff;
}
.viewer__play.is-paused .viewer__play-icon { opacity: 1; }
.viewer__thumb { display: block; width: 100%; height: 100%; }
/* 作品の長押しメニュー（iPhoneの「写真に保存」など）・選択・ドラッグを出さない */
.viewer__media, .viewer__media img, .viewer__media video {
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none;
}

/* 文字は作品のすぐ下に一か所。日付と作者名は同じ強さ */
.viewer__info {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 4px 12px; margin-top: 10px; text-align: center;
}
.viewer__caption {
  margin: 0; min-width: 0;
  font-size: 15px; font-weight: 500; line-height: 1.6; color: var(--ink);
  overflow-wrap: anywhere;
}
.viewer__sep { margin: 0 .35em; color: var(--ink-soft); }

/* 音の操作：動画の近く（作品のすぐ下）にまとめる */
.viewer__sound {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 44px; padding: 0 14px;   /* 文字は13.5pxのまま、押せる高さは余白で確保 */
  border: 1.5px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.viewer__sound[aria-pressed="true"] { border-color: var(--green); color: var(--green-deep); }
.viewer__note { margin: 4px 0 0; font-size: 13px; color: var(--red-deep); line-height: 1.6; text-align: center; }

/* リンク：あるときだけ、作者情報の下に控えめに1つ */
.viewer__linkrow { margin: 6px 0 0; text-align: center; }
.viewer__link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  color: var(--green-deep); font-size: 15px; font-weight: 700;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1.5px;
}
@media (hover: hover) { .viewer__link:hover { color: var(--green); } }

/* 狭い画面では、押せる高さ44pxの内側に小さな枠を描く。 */
@media (max-width: 599px) {
  .viewer__close, .viewer__sound {
    position: relative; isolation: isolate;
    padding-inline: 9px; border: 0; background: transparent;
  }
  .viewer__close::before, .viewer__sound::before {
    content: ""; position: absolute; inset: 6px 0; z-index: -1;
    border: 1px solid var(--line); border-radius: 999px;
    background: rgba(255, 255, 255, .55); pointer-events: none;
  }
  .viewer__close { font-weight: 500; }
  .viewer__close-x { font-size: 16px; }
}

/* ---------- 広い画面 ---------- */
@media (min-width: 600px) {
  .head { padding-top: 30px; }
  .head__logo img { height: 44px; }
  .star--h1 { --s: 34px; left: 10%; top: 80px; }
  .star--h2 { --s: 20px; left: 19%; top: 150px; }
  .star--h3 { --s: 28px; left: auto; right: 11%; top: 86px; }
  .star--h4 { --s: 22px; right: 20%; top: 156px; }
  .viewer__body { padding: 0 20px 20px; }
}
@media (min-width: 900px) {
  .stars--side .star { display: block; }
  .star--s1 { --s: 40px; --r: 8deg;   left: -110px; top: 18%; }
  .star--s2 { --s: 30px; --r: -12deg; left: -70px;  top: 52%; --o: .9; }
  .star--s3 { --s: 24px; --r: 10deg;  right: -80px; top: 30%; --o: .85; }
  .star--s4 { --s: 36px; --r: -6deg;  right: -120px; top: 64%; }
}

/* 動きを減らす設定：星のきらめき・窓の反応・画面の切り替えをすべて静止表示にする */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .star { opacity: var(--o, 1); }
}
