/* Home: hero over the Fuji scene, wooden bookshelves, overview, timetable */
.home-body { background-attachment: fixed; }
.home-body main, .site-foot { position: relative; z-index: 2; }
.topnav { display: flex; gap: 4px; margin-left: auto; }
.topnav a {
  text-decoration: none; color: var(--sumi); font-size: 14px; padding: 8px 12px; border-radius: 999px;
  transition: background 0.2s;
}
.topnav a:hover { background: rgba(243, 166, 189, 0.25); }

/* ---------- hero ---------- */
.hero {
  position: relative; min-height: calc(100vh - 60px); min-height: calc(100dvh - 60px);
  display: grid; align-items: center; padding: 40px clamp(20px, 6vw, 90px) 120px;
}
.hero-copy { max-width: 640px; animation: rise 1.2s var(--ease) both; }
.hero-kicker { font-family: var(--font-mincho); letter-spacing: 0.3em; color: var(--beni); margin: 0 0 14px; font-size: 14px; }
.hero-title { margin: 0; font-family: var(--font-mincho); font-weight: 800; color: var(--sumi); line-height: 1.12; }
.ht-line { display: block; font-size: clamp(40px, 7vw, 88px); text-shadow: 0 3px 0 rgba(255, 255, 255, 0.85); }
.ht-year {
  display: inline-block; margin-top: 10px; font-size: clamp(22px, 3vw, 34px); color: #fff; background: var(--beni);
  padding: 2px 16px 4px; border-radius: 6px; letter-spacing: 0.15em; transform: rotate(-2deg);
}
.hero-sub {
  margin: 22px 0 26px; font-size: clamp(16px, 1.6vw, 19px); line-height: 1.7; color: var(--sumi);
  background: rgba(255, 255, 255, 0.72); padding: 10px 16px; border-radius: var(--radius-m); display: inline-block;
  backdrop-filter: blur(4px);
}
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-size: 17px; font-weight: 700;
  padding: 14px 26px; border-radius: 999px; transition: transform 0.25s var(--ease), box-shadow 0.25s;
}
.btn-primary { background: linear-gradient(135deg, var(--sakura-deep), var(--beni)); color: #fff; box-shadow: 0 12px 26px rgba(194, 65, 58, 0.35); }
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 16px 30px rgba(194, 65, 58, 0.42); }
.btn-ghost { background: rgba(255, 255, 255, 0.85); color: var(--fuji); border: 1px solid rgba(62, 92, 138, 0.25); }
.btn-ghost:hover { transform: translateY(-3px); }
.hero-feats { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 22px 0 0; }
.hero-feats li { background: rgba(255, 255, 255, 0.8); border-radius: 999px; padding: 6px 14px; font-size: 14px; }
.hero-seal {
  position: absolute; right: clamp(20px, 8vw, 140px); top: 18%;
  display: grid; grid-template-columns: 1fr 1fr; width: 110px; height: 110px; border: 4px solid var(--beni);
  border-radius: 10px; color: var(--beni); font-family: var(--font-mincho); font-weight: 800; font-size: 28px;
  writing-mode: vertical-rl; place-items: center; padding: 8px; transform: rotate(6deg); opacity: 0.85;
  background: rgba(255, 255, 255, 0.4); animation: stamp 0.9s 0.5s var(--ease) both;
}
.hero-vertical {
  position: absolute; right: clamp(40px, 12vw, 220px); top: 38%; writing-mode: vertical-rl;
  font-family: var(--font-mincho); font-size: clamp(18px, 2vw, 26px); letter-spacing: 0.4em; color: rgba(43, 42, 51, 0.6);
}
@keyframes rise { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: none; } }
@keyframes stamp { from { opacity: 0; transform: rotate(6deg) scale(1.8); } to { opacity: 0.85; transform: rotate(6deg) scale(1); } }

/* ---------- section scaffolding ---------- */
.shelf-section, .overview, .timetable {
  background: rgba(251, 247, 240, 0.94) var(--paper-grain);
  padding: 64px clamp(16px, 5vw, 70px);
}
.shelf-section { border-top: 6px double rgba(217, 102, 138, 0.4); }
.section-head { display: flex; flex-wrap: wrap; align-items: end; gap: 6px 20px; margin-bottom: 30px; }
.section-kicker { width: 100%; font-family: var(--font-jp); color: var(--sakura-deep); letter-spacing: 0.3em; font-size: 14px; }
.section-head h2 { margin: 0; font-family: var(--font-mincho); font-size: clamp(28px, 4vw, 44px); color: var(--fuji); }
.progress-wrap { margin-left: auto; font-size: 14px; min-width: 220px; }
.progress-bar { height: 8px; background: #efe3d6; border-radius: 99px; margin-top: 6px; overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--sakura), var(--sakura-deep)); transition: width 1s var(--ease); }

/* ---------- shelves ---------- */
.shelf { margin-bottom: 30px; }
.shelf-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 14px; }
.shelf-label .jp { font-family: var(--font-mincho); font-size: 22px; font-weight: 700; }
.shelf-label .tr { display: inline; font-size: 15px; }
.shelf-books {
  --w: 148px; --h: 208px; --row-gap: 46px;
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--row-gap) 26px; padding: 0 18px var(--row-gap);
  perspective: 1200px;
  /* one wooden plank under every row of books, however many rows wrap */
  background-image: linear-gradient(180deg,
    transparent 0 var(--h),
    color-mix(in srgb, var(--wood) 85%, #fff) var(--h),
    var(--wood) calc(var(--h) + 8px),
    color-mix(in srgb, var(--wood) 70%, #000) calc(var(--h) + 20px),
    rgba(80, 50, 30, 0.22) calc(var(--h) + 20px),
    transparent calc(var(--h) + 34px));
  background-size: 100% calc(var(--h) + var(--row-gap));
  background-repeat: repeat-y;
}
.book3d {
  position: relative; display: block; width: var(--w); height: var(--h); text-decoration: none; color: var(--sumi);
  transform-style: preserve-3d; transform: rotateY(-14deg);
  transition: transform 0.5s var(--ease), filter 0.3s;
  filter: drop-shadow(6px 10px 10px rgba(60, 40, 30, 0.28));
}
.book3d:hover, .book3d:focus-visible { transform: rotateY(-4deg) translateY(-12px) scale(1.04); }
.book3d.opening { transform: rotateY(-70deg) translateZ(40px) scale(1.25); transition-duration: 0.5s; }
.b-spine {
  position: absolute; top: 0; left: 0; width: 22px; height: 100%;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 60%, #000), var(--c));
  transform-origin: left; transform: rotateY(90deg) translateX(-22px);
}
.b-cover {
  position: absolute; inset: 0; border-radius: 3px 8px 8px 3px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 10px 10px 18px; text-align: center;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0 10px, rgba(255, 255, 255, 0.25) 10px 12px, transparent 12px),
    linear-gradient(170deg, color-mix(in srgb, var(--c) 30%, #fff) 0%, #fffaf5 58%, color-mix(in srgb, var(--c) 18%, #fff) 100%);
  border: 1px solid color-mix(in srgb, var(--c) 40%, #fff);
}
.b-cover::after { /* mini Fuji at the foot of each cover */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 34%;
  background: url("../img/fuji.svg") center 82% / 330% auto no-repeat; opacity: 0.55; pointer-events: none;
}
.b-day {
  position: relative; z-index: 1; font-family: var(--font-mincho); font-weight: 800; font-size: 15px; color: #fff;
  background: var(--c); padding: 2px 10px; border-radius: 4px; letter-spacing: 0.08em;
}
.b-icon { position: relative; z-index: 1; font-size: 30px; margin-top: 2px; }
.b-title { position: relative; z-index: 1; font-family: var(--font-mincho); font-weight: 700; font-size: 14px; line-height: 1.45; }
.b-title rt { font-size: 0.55em; }
.b-tr { position: relative; z-index: 1; font-size: 11px; line-height: 1.3; }
.b-tr .tr { font-size: 11px; color: var(--sumi-soft); }
.b-life {
  position: relative; z-index: 1; margin-top: auto; font-size: 10px; color: var(--matcha); font-weight: 700;
  background: rgba(255, 255, 255, 0.85); border-radius: 99px; padding: 2px 8px;
}
.b-life rt { display: none; }
.b-foot { position: relative; z-index: 1; font-size: 9px; letter-spacing: 0.2em; color: var(--sumi-soft); text-transform: uppercase; }
.b-ribbon {
  position: absolute; top: -6px; right: 14px; z-index: 2; min-width: 28px; padding: 6px 4px 10px; text-align: center;
  background: var(--beni); color: #fff; font-size: 11px; font-weight: 700;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
}
.book3d.is-done .b-ribbon { background: var(--matcha); }
.book3d.is-soon { filter: grayscale(0.6) opacity(0.6); cursor: default; }

/* ---------- overview ---------- */
.ov-grid { display: grid; grid-template-columns: 1.3fr repeat(2, 1fr); gap: 18px; }
.ov-stat {
  grid-row: span 2; background: var(--fuji) url("../img/fuji.svg") center bottom / cover no-repeat; color: #fff;
  border-radius: var(--radius-l); padding: 30px; position: relative; overflow: hidden; min-height: 300px;
  display: flex; flex-direction: column;
}
.ov-stat::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(43, 52, 90, 0.88), rgba(62, 92, 138, 0.35)); }
.ov-stat > * { position: relative; }
.ov-big { font-family: var(--font-mincho); font-size: 92px; font-weight: 800; line-height: 1; }
.ov-unit { font-size: 22px; margin-left: 6px; }
.ov-label { display: block; margin-top: 6px; font-size: 16px; opacity: 0.9; }
.ov-bars { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.ov-bars span {
  display: block; width: calc(var(--w) / 176 * 100% + 120px); max-width: 100%; background: var(--c); border-radius: 6px;
  padding: 6px 10px; font-size: 14px; font-weight: 600; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}
.ov-card {
  background: #fff; border-radius: var(--radius-l); padding: 22px; border: 1px solid #f0e2d6;
  box-shadow: var(--shadow-soft); transition: transform 0.3s var(--ease);
}
.ov-card:hover { transform: translateY(-4px) rotate(-0.4deg); }
.ov-icon { font-size: 34px; }
.ov-card h3 { margin: 6px 0; font-family: var(--font-mincho); font-size: 22px; color: var(--fuji); }
.ov-card p { margin: 0; }
.ov-card .tr { font-size: 15px; color: var(--sumi); }

/* ---------- timetable ---------- */
.tt-scroll { overflow-x: auto; }
.tt { border-collapse: separate; border-spacing: 0 8px; min-width: 420px; width: 100%; max-width: 760px; caption-side: bottom; }
.tt caption { text-align: left; font-size: 14px; color: var(--sumi-soft); padding-top: 10px; }
.tt th, .tt td { background: #fff; padding: 12px 16px; text-align: left; }
.tt th { font-family: var(--font-mincho); border-radius: 10px 0 0 10px; width: 150px; }
.tt td:last-child { border-radius: 0 10px 10px 0; }
.tt-chip { display: inline-block; border-radius: 999px; padding: 4px 12px; font-size: 14px; color: #fff; }
.tt-japanese .tt-chip { background: var(--fuji); }
.tt-life .tt-chip { background: var(--matcha); }
.tt-lunch th, .tt-lunch td { background: #fff4f7; }
.tt-lunch .tt-chip { background: var(--sakura-deep); }

.site-foot { text-align: center; padding: 30px 16px 40px; background: rgba(43, 42, 51, 0.88); color: #f3e9e3; font-size: 13px; }
.foot-note { opacity: 0.8; }

@media (max-width: 900px) {
  .ov-grid { grid-template-columns: 1fr; }
  .ov-stat { grid-row: auto; }
  .hero-seal { width: 80px; height: 80px; font-size: 20px; top: 12%; }
  .hero-vertical { display: none; }
  .topnav { display: none; }
}
@media (max-width: 560px) {
  .shelf-books { --w: 128px; --h: 182px; --row-gap: 40px; column-gap: 16px; justify-content: center; padding: 0 6px var(--row-gap); }
  .b-title { font-size: 12px; }
  .hero { padding-bottom: 80px; }
}

/* =====================================================================
   Motion layer: parallax Fuji scene, smooth snapping, scroll reveals
   ===================================================================== */
html:has(.home-body) { scroll-behavior: smooth; scroll-snap-type: y proximity; }
.home-body { background: var(--washi); }
.hero, .snap { scroll-snap-align: start; }
.hero { overflow: hidden; isolation: isolate; min-height: 100vh; min-height: 100dvh; margin-top: -60px; padding-top: 100px; }
.hero-scene { position: absolute; inset: 0; z-index: -1; }
.layer { position: absolute; inset: -2% 0 0; will-change: transform; }
.layer svg { width: 100%; height: 100%; display: block; }
.layer-branch-l, .layer-branch-r { z-index: 3; pointer-events: none; }
.layer-town { z-index: 2; }

/* clouds drift, mist breathes, branches sway, lanterns swing, cranes fly */
.cloud { animation: drift 38s linear infinite alternate; }
.cloud.c2 { animation-duration: 52s; animation-direction: alternate-reverse; }
.cloud.c3 { animation-duration: 30s; }
@keyframes drift { from { transform: translateX(-60px); } to { transform: translateX(90px); } }
.mist { animation: mist 14s ease-in-out infinite alternate; }
@keyframes mist { from { transform: translateX(-80px); opacity: 0.7; } to { transform: translateX(80px); opacity: 1; } }
.sway { transform-origin: 0 40px; animation: sway 6s ease-in-out infinite alternate; }
@keyframes sway { from { transform: rotate(-1.2deg); } to { transform: rotate(1.4deg); } }
.lantern { animation: swing 3.2s ease-in-out var(--d, 0s) infinite alternate; transform-box: view-box; }
@keyframes swing { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
.flock { animation: fly 26s linear infinite; }
@keyframes fly {
  from { transform: translate(-120px, 260px) scale(0.9); }
  to { transform: translate(1720px, 120px) scale(1.1); }
}
.bird { animation: flap 0.9s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.bird.b2 { animation-delay: 0.3s; } .bird.b3 { animation-delay: 0.55s; }
@keyframes flap { from { transform: scaleY(1); } to { transform: scaleY(0.45); } }

.hero-copy { position: relative; z-index: 4; will-change: transform, opacity; }
.hero-seal, .hero-vertical { z-index: 4; }
.scroll-cue {
  position: absolute; left: 50%; bottom: 26px; z-index: 5; width: 30px; height: 50px; margin-left: -15px;
  border: 2px solid rgba(255, 255, 255, 0.9); border-radius: 20px; background: rgba(43, 42, 51, 0.18);
}
.scroll-cue span { position: absolute; left: 50%; top: 9px; width: 6px; height: 10px; margin-left: -3px; border-radius: 3px; background: #fff; animation: cue 1.8s ease-in-out infinite; }
@keyframes cue { 0% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(16px); opacity: 0; } 100% { opacity: 0; } }

/* seigaiha (blue ocean wave) band crowning each section */
.shelf-section, .overview, .timetable { position: relative; }
.shelf-section::before, .overview::before, .timetable::before {
  content: ""; position: absolute; left: 0; right: 0; top: -28px; height: 28px; pointer-events: none;
  --wave: rgba(62, 92, 138, 0.22);
  background:
    radial-gradient(circle at 50% 100%, transparent 6px, var(--wave) 7px 8px, transparent 9px 13px, var(--wave) 14px 15px, transparent 16px 20px, var(--wave) 21px 22px, transparent 23px) 0 0 / 56px 28px,
    radial-gradient(circle at 50% 100%, var(--washi) 22px, transparent 23px) 28px 14px / 56px 28px;
}
.shelf-section { border-top: none; }
.overview { background: linear-gradient(180deg, #fbf3ee, #f7eee7) var(--paper-grain); }
.timetable { background: linear-gradient(180deg, #f6f1ea, #fbf7f0); }

/* torii gate silhouette watching over the overview */
.torii {
  position: absolute; right: 4%; top: 40px; width: 160px; height: 130px; opacity: 0.16; pointer-events: none;
  background:
    linear-gradient(var(--beni), var(--beni)) 0 0 / 100% 14px no-repeat,
    linear-gradient(var(--beni), var(--beni)) 12px 30px / calc(100% - 24px) 10px no-repeat,
    linear-gradient(var(--beni), var(--beni)) 28px 0 / 14px 100% no-repeat,
    linear-gradient(var(--beni), var(--beni)) calc(100% - 28px) 0 / 14px 100% no-repeat;
  border-radius: 40% 40% 0 0 / 14px 14px 0 0;
}

/* reveal on scroll */
[data-reveal] { opacity: 0; transform: translateY(36px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
[data-reveal].in-view { opacity: 1; transform: none; }
.ov-card[data-reveal] { transition-delay: calc(var(--i, 0) * 0.12s); }
.shelf[data-reveal] .book3d { opacity: 0; transform: rotateY(-14deg) translateY(50px); }
.shelf[data-reveal].in-view .book3d {
  opacity: 1; transform: rotateY(-14deg);
  transition: transform 0.8s var(--ease) calc(var(--order, 0) * 0.08s), opacity 0.8s var(--ease) calc(var(--order, 0) * 0.08s), filter 0.3s;
}
.shelf[data-reveal].in-view .book3d:hover, .shelf[data-reveal].in-view .book3d:focus-visible {
  transform: rotateY(-4deg) translateY(-12px) scale(1.04); transition-delay: 0s;
}
.shelf[data-reveal].in-view .book3d.opening { transform: rotateY(-70deg) translateZ(40px) scale(1.25); transition-delay: 0s; }

@media (max-width: 760px) {
  .layer-branch-r { display: none; }
  .hero { padding-top: 90px; }
}
@media (prefers-reduced-motion: reduce) {
  html:has(.home-body) { scroll-behavior: auto; }
  [data-reveal], .shelf[data-reveal] .book3d { opacity: 1; transform: none; }
}
.home-body .sakura-canvas { z-index: 6; }
