/* geometric sans on the blind box's inner bag, matching the box print (box.js) */
@font-face { font-family: "Jost"; src: url("assets/fonts/jost-400.woff2") format("woff2"); font-display: block; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #e0e0e0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* blue paper texture from the Figma frame, made seamless so it repeats and pans with the photos */
#bg {
  position: fixed;
  left: 0;
  top: 0;
  width: calc(100vw + 1024px);
  height: calc(100vh + 1024px);
  background: url("assets/bg-grey.jpg") 0 0 / 1024px 1024px repeat;   /* grey paper as on hakusuku.jp/recruit */
  will-change: transform;
}

#stage {
  position: fixed;
  inset: 0;
  cursor: grab;
  touch-action: none;
}
#stage.dragging { cursor: grabbing; }

#plane { position: absolute; left: 0; top: 0; will-change: transform; }

.tile { position: absolute; left: 0; top: 0; }

/* each photo: hand-cut white backing (SVG) + photo/clip clipped to its shape (from Figma) */
.photo {
  position: absolute;
  contain: layout;
}
.photo[data-index] { cursor: zoom-in; }
#stage.dragging .photo[data-index] { cursor: grabbing; }
/* hand-cut print: white paper clipped to the cut (see cutPath in main.js), faint shadow */
.photo { filter: drop-shadow(0 0.6px 1.2px rgba(0, 0, 0, 0.22)); }
.photo .paper { position: absolute; inset: 0; background: #fafaf8; }
.photo .media { filter: contrast(0.95) saturate(0.93); }   /* a print, not a screen */
.photo .tape { position: absolute; background: rgba(214, 202, 160, 0.62); }
.photo .media {
  position: absolute;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}
/* hide iOS Safari's own play overlay on the gallery loops (shows in Low Power Mode) */
.photo video::-webkit-media-controls,
.photo video::-webkit-media-controls-panel,
.photo video::-webkit-media-controls-overlay-play-button,
.photo video::-webkit-media-controls-start-playback-button {
  display: none !important;
  -webkit-appearance: none;
  opacity: 0 !important;
}
.photo .empty {
  background: #d4d4d2;
  display: grid;
  place-items: center;
  color: #fff;
  font: 28px "Reenie Beanie", cursive;
}

/* expanded view */
#viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(24, 24, 24, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  touch-action: none;
}
body.viewing #viewer { opacity: 1; pointer-events: auto; }
#viewer figure {
  position: relative;
  background: #fff;
  padding: 7px 10px 9px 7px;      /* uneven on purpose, like the cut frames */
  transform: rotate(-0.4deg) scale(0.96);
  transition: transform 0.35s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  line-height: 0;
}
body.viewing #viewer figure { transform: rotate(-0.4deg) scale(1); }
#viewer img, #viewer video {
  display: block;
  max-width: min(88vw, 1400px);
  max-height: 78vh;
  width: auto;
  height: auto;
}
#viewer .vbtn {
  position: fixed;
  font: 32px "Reenie Beanie", cursive;
  color: #fff;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 12px 18px;
}
#viewer .close { top: 20px; right: 28px; }
#viewer .prev { left: 12px; top: 50%; transform: translateY(-50%); }
#viewer .next { right: 12px; top: 50%; transform: translateY(-50%); }
@media (max-width: 720px) {
  #viewer .prev, #viewer .next { top: auto; bottom: 24px; transform: none; }
  #viewer img, #viewer video { max-width: 92vw; max-height: 72vh; }
}

#keychain {
  position: fixed;
  left: 50%;
  top: 52%;
  /* same share of the screen as the reference, but always below the header */
  width: min(76vh, 92vw, calc((100vh - 70px) * 1.05));
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  /* shadow is baked into the layer images (animating a filter costs a repaint every frame) */
}
.kc-layer {
  position: absolute;
  transform-origin: 50% 40%;    /* the ring point */
  will-change: transform;
}
.kc-layer img { width: 100%; height: 100%; display: block; -webkit-user-drag: none; }

/* two views: gallery (default) and birthday (keychain) */
#plane, #keychain { transition: opacity 0.5s ease; }
#keychain { opacity: 0; }
body.birthday #plane { opacity: 0; }
body.birthday #keychain { opacity: 1; }
body.birthday #stage { cursor: default; }

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 64px 64px 0;
  font: 48px/1 "Reenie Beanie", cursive;
  color: #fff;
  pointer-events: none;
}
header a {
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
}
header a:hover, header a.current { opacity: 1; }

#hint {
  position: fixed;
  bottom: 28px;
  left: 0;
  right: 0;
  text-align: center;
  font: 28px "Reenie Beanie", cursive;
  color: #fff;
  opacity: 0.85;
  pointer-events: none;
  transition: opacity 0.6s;
}
#hint.gone { opacity: 0; }

@media (max-width: 720px) {
  header { padding: 24px 20px 0; font-size: 26px; }
}

/* ---- heart cursor (mouse only) ---- */
html.heart-cursor, html.heart-cursor * { cursor: none !important; }
#cursor {
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}
#cursor.on { opacity: 1; }
#cursor .heart {
  position: absolute;
  left: -17px; top: -16px;          /* hotspot in the middle of the heart */
  transition: transform 0.18s cubic-bezier(.3,1.6,.5,1), opacity 0.15s;
}
#cursor .heart path { transition: fill 0.15s; }
#cursor.down .heart { transform: scale(1.35, 0.6); }          /* squish while dragging */
#cursor[data-state="link"] .heart path { fill: #fff; }          /* filled over links */
#cursor[data-state="link"] .heart { transform: scale(0.85); }
#cursor[data-state="label"] .heart { opacity: 0; transform: scale(0.4); }
#cursor .label {
  position: absolute;
  left: 0; top: 0;
  transform: translate(-50%, -55%) rotate(-4deg) scale(0.6);
  font: 34px/1 "Reenie Beanie", cursive;
  color: #fff;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s, transform 0.18s cubic-bezier(.3,1.6,.5,1);
}
#cursor[data-state="label"] .label { opacity: 1; transform: translate(-50%, -55%) rotate(-4deg) scale(1); }
#cursor.down[data-state="label"] .label { transform: translate(-50%, -55%) rotate(-4deg) scale(1.3, 0.65); }

/* ---- opening (after hakusuku.jp/recruit) ---- */
body.intro #headline, body.intro #keychain { opacity: 0; transition: none; }
body.intro #plane { opacity: 0.001; transition: none; }
body.intro #hint { opacity: 0; }
#intro { position: fixed; left: 50%; top: 50%; width: 0; height: 0; z-index: 5; pointer-events: none; }
#intro .ix {
  position: absolute;
  left: 0; top: 0;
  box-sizing: border-box;
  background: #fff center / cover no-repeat;
  background-clip: content-box;
  padding: 4px 5px 5px 4px;          /* uneven white border like the cut frames */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
}
#intro .ix img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* headline: every letter on its own scrap of paper (ransom-note collage) */
#headline {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
body.birthday #headline, body.viewing #headline { opacity: 0; }
#headline .hl-line {
  display: flex;
  align-items: center;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.22));
  transform: translateY(-0.55em);
}
#headline .hl-line.down { transform: none; transition: transform 0.3s cubic-bezier(.22,1,.36,1); }
#headline span {
  display: inline-block;
  font: 66px/1 "Reenie Beanie", cursive;
  color: #1f2020;
  background: #fbfaf6;
  padding: 0.16em 0.1em 0.06em;
  margin: 0 -0.02em;
  visibility: hidden;
}
#headline span.hl-space { background: none; width: 0.3em; }
#headline span.in { visibility: visible; }
#headline span.fly { transform: translateX(2.2em); }
#headline span.fly.set { transform: none; transition: transform 0.33s cubic-bezier(.22,1,.36,1); }
#headline { transition: opacity 0.4s; }
@media (max-width: 720px) { #headline span { font-size: 44px; } }

/* short screens (phone held sideways): smaller header, keychain sits below it */
@media (max-height: 500px) {
  header { padding: 14px 24px 0; font-size: 26px; }
  #keychain { top: calc(50% + 22px); }
  #headline span { font-size: 30px; }
  #hint { bottom: 10px; font-size: 22px; }
}
body.viewing #hint { opacity: 0; }
header > * { white-space: nowrap; }
@media (max-width: 380px) { header { padding: 20px 14px 0; font-size: 21px; } }

header { z-index: 8; }


/* hover strips over the keychain (one per charm), after wildyriftian.com desktop */
#keychain { z-index: 3; }
.kc-strips { position: absolute; z-index: 10; left: 28%; top: 30%; width: 56%; height: 70%; pointer-events: none; touch-action: none; }
body.birthday .kc-strips { pointer-events: auto; }

/* header: strict 3-column grid so the date sits exactly on the centre line (over the keychain) */
header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  letter-spacing: 0.01em;
}
header > :nth-child(1) { justify-self: start; }
header > :nth-child(2) { justify-self: center; }
header > :nth-child(3) { justify-self: end; }
header a { opacity: 1; position: relative; }
/* current page: a hand-drawn ink loop draws itself around the link (no underline) */
header a .ink {
  position: absolute; left: -0.28em; top: -0.16em;
  width: calc(100% + 0.56em); height: calc(100% + 0.4em);
  overflow: visible; pointer-events: none;
}
header a .ink path {
  fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: var(--len, 400) var(--len, 400); stroke-dashoffset: var(--len, 400);
  transition: stroke-dashoffset 0.25s ease, opacity 0.25s;
}
header a.current .ink path { stroke-dashoffset: 0; transition: stroke-dashoffset 0.6s cubic-bezier(.45,.05,.3,1) 0.05s; }
@media (hover: hover) { header a:not(.current):hover .ink path { stroke-dashoffset: calc(var(--len, 400) * 0.82); opacity: 0.6; } }
@media (max-width: 720px) {
  header a .ink { left: -0.4em; top: -0.24em; width: calc(100% + 0.8em); height: calc(100% + 0.52em); }
  header a .ink path { stroke-width: 1.3; }
}
header { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); column-gap: 10px; }
@media (max-width: 720px) { header { font-size: min(26px, 5.3vw); padding-left: 16px; padding-right: 16px; } }

/* don't paint the gallery at all while it's hidden behind the birthday page */
body.birthday #plane { visibility: hidden; }

#headline { will-change: transform; }
#headline .hl-space { width: 0.38em; background: transparent; box-shadow: none; padding: 0; }

/* ---- minimap + zoom (after tokyo-haneda.com/haneda-nice-day) ---- */
#plane { transform-origin: 0 0; }
#minimap {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 220px;
  z-index: 5;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.5s ease;
}
#minimap .mm-map { position: relative; width: 100%; }
#minimap .mm-map svg { display: block; width: 100%; height: 100%; overflow: visible; }
#minimap .mm-frame {
  position: absolute;
  left: 0; top: 0;
  border: 2px solid #fff;
  box-sizing: border-box;
  transform-origin: 0 0;
  will-change: transform;
}
#zoom {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 28px; height: 28px;
  margin: 0; padding: 0;
  border: 2px solid #fff;
  border-radius: 4px;
  background: #1f2020;
  z-index: 6;
  transition: opacity 0.5s ease;
}
#zoom::before, #zoom::after { content: ""; position: absolute; width: 6px; height: 6px; transition: transform 0.4s ease; }
#zoom::before { top: 4px; right: 4px; border-top: 2px solid #fff; border-right: 2px solid #fff; border-top-right-radius: 2px; }
#zoom::after  { bottom: 4px; left: 4px; border-bottom: 2px solid #fff; border-left: 2px solid #fff; border-bottom-left-radius: 2px; }
#zoom[data-zoom="out"]::before, #zoom[data-zoom="out"]::after { transform: rotate(180deg); }
/* the map sits up and left of the button, like the reference */
#minimap { right: 64px; bottom: 56px; }
body.birthday #minimap, body.birthday #zoom, body.intro #minimap, body.intro #zoom, body.viewing #minimap, body.viewing #zoom { opacity: 0; pointer-events: none; }
body.zoomed-out #hint { opacity: 0; }
@media (max-width: 720px) {
  #minimap { width: 150px; right: 16px; bottom: 16px; }
}
/* touch screens: no zoom button (as on the reference) */
@media not all and (hover: hover) and (pointer: fine) {
  #zoom { display: none; }
  #minimap { right: 16px; bottom: 16px; }
}

/* ---- phones: audit fixes ---- */
/* header stays readable over bright photos */
header { text-shadow: 0 1px 6px rgba(0, 0, 0, 0.42); }
header a .ink { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.38)); }
/* the photo viewer has its own close button: hide the header under it */
body.viewing header { opacity: 0; pointer-events: none; }
header { transition: opacity 0.25s; }
@media (max-width: 720px) {
  /* headline never runs edge to edge on narrow phones */
  #headline span { font-size: min(44px, 10.6vw); }
  /* hint bottom-left so it never runs into the minimap (bottom-right) */
  #hint { text-align: left; left: 16px; right: auto; bottom: 18px; }
}
@media (max-height: 500px) {
  #hint { text-align: left; left: 24px; right: auto; }
  #headline span { font-size: 30px; }
}

/* ---- header: two links grouped top-left on paper scraps; navy ink loop marks the
   current page. No date here (it's a stamp under the headline). ---- */
header { display: flex !important; justify-content: flex-start !important; align-items: baseline; gap: 0.45em; text-shadow: none; }
header > * { justify-self: auto !important; margin: 0 !important; }
header a, header a:hover { opacity: 1; }
header a {
  position: relative; padding: 0.12em 0.32em 0.02em; color: #1f2020; isolation: isolate;
  transform: rotate(-2deg);
}
header a[data-view="birthday"] { transform: rotate(1.5deg); }
header a::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: #fbfaf6;
  clip-path: polygon(2% 9%, 48% 0, 98% 6%, 100% 93%, 55% 100%, 1% 95%);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}
header a[data-view="birthday"]::before { clip-path: polygon(1% 4%, 52% 7%, 99% 0, 97% 96%, 46% 92%, 3% 100%); }
header a .ink { left: -0.45em; top: -0.32em; width: calc(100% + 0.9em); height: calc(100% + 0.64em); filter: none; }
header a .ink path { stroke: #1f2020; }
@media (max-width: 720px) {
  header a .ink { left: -0.45em; top: -0.32em; width: calc(100% + 0.9em); height: calc(100% + 0.64em); }
}

/* date stamp under the headline */
#headline .hl-date {
  margin-top: 12px;
  font: 32px/1 "Reenie Beanie", cursive;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
#headline .hl-date.in { opacity: 1; transform: none; }
@media (max-width: 720px) { #headline .hl-date { font-size: 24px; margin-top: 8px; } }
@media (max-height: 500px) { #headline .hl-date { font-size: 20px; margin-top: 4px; } }

/* ---- blind-box opening (box.js) ---- */
#blindbox { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; z-index: 6; display: none; touch-action: none; transition: opacity 0.45s ease 0.12s; }
#blindbox.gone { opacity: 0; pointer-events: none; transition: none; }   /* hard cut, like hakusuku */
body.boxing header, body.boxing #minimap, body.boxing #zoom, body.boxing #hint { opacity: 0 !important; pointer-events: none; }
#bb-hint {
  position: fixed; left: 50%; bottom: max(9vh, 64px); z-index: 7; margin: 0;
  transform: translateX(-50%) rotate(-1.5deg) translateY(6px);
  font: 30px/1 "Reenie Beanie", cursive; color: #1f2020;
  background: #fbfaf6; padding: 0.16em 0.4em 0.04em;
  clip-path: polygon(2% 9%, 48% 0, 98% 6%, 100% 93%, 55% 100%, 1% 95%);
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease, transform 0.3s ease; white-space: nowrap;
}
#bb-hint.on { opacity: 1; transform: translateX(-50%) rotate(-1.5deg); }
#bb-skip {
  position: fixed; right: 20px; bottom: 18px; z-index: 7; border: 0; background: none; padding: 6px 8px;
  font: 22px/1 "Reenie Beanie", cursive; color: rgba(255,255,255,0.85); text-shadow: 0 1px 4px rgba(22,44,96,.4);
  opacity: 0; pointer-events: none; transition: opacity 0.4s;
}
body.boxing #bb-skip { opacity: 1; pointer-events: auto; }
@media (max-width: 720px) { #bb-hint { font-size: 24px; } }

/* keychain page: plain black, like wildyriftian.com */
html:has(body.birthday), body.birthday { background: #000; }
body.birthday #bg { opacity: 0; }
body.birthday header a .ink path { stroke: #f4f1e8; }   /* the hand-drawn loop shows on black */

/* ---- title, after hakusuku.jp/recruit: glyphs on white hand-cut scraps, on one cream strip.
   Their glyph is ~110 px in a 2560 px cover-fitted video: 4.5% of the viewport's longer side */
@font-face { font-family: "WenKai Title"; src: url("assets/fonts/wenkai-title.woff2") format("woff2"); font-display: block; }
#headline .hl-line { position: relative; display: flex; align-items: flex-start; gap: 0; padding: 0 0.22em 0.24em 0; margin: 0;
  font-size: min(5.5vmax, 9.5vw); }        /* their glyphs: ~71 px tall at 1440 wide */
#headline .hl-strip {
  position: absolute; left: 0.62em; right: 0; top: 0.1em; bottom: 0;
  background: rgb(244, 239, 231);
}
#headline .hl-line span, #headline .hl-line span.in {
  position: relative;
  font: 700 1em/1 "WenKai Title", serif;
  color: rgb(31, 32, 32);
  -webkit-text-stroke: 0.03em rgb(31, 32, 32);
  background: rgb(250, 250, 250);
  margin: 0;
  box-shadow: none;
  letter-spacing: 0;
}
/* punctuation: a small tight scrap of its own (their "、"), cropped round the mark. Ink boxes
   measured in the browser (WenKai Bold, line-height 1): "，" x .09-.24em y .725-.945em;
   "！" x .16-.29em y .115-.855em. */
#headline .hl-line span.hl-p { width: 0.36em; height: 0.38em; padding: 0; margin-left: -0.22em; overflow: hidden; }
#headline .hl-line span.hl-p b { position: absolute; font: inherit; line-height: 1; left: 0.015em; top: -0.645em; }
#headline .hl-line span.hl-p[data-g="！"] { width: 0.3em; height: 0.9em; margin-left: 0.04em; }
#headline .hl-line span.hl-p[data-g="！"] b { left: -0.075em; top: -0.035em; }
#headline .hl-date { display: none; }

/* ---- "click me!" (under the title) and "back" (keychain page): same cut-paper build as the
   title at 42% size; a pen loop is drawn round one when it's clicked ---- */
@font-face { font-family: "WenKai Title"; src: url("assets/fonts/wenkai-btn.woff2") format("woff2");
  unicode-range: U+0020-007E; font-display: block; }
#headline .hl-line.hl-btn { font-size: max(18px, calc(min(5.5vmax, 9.5vw) * 0.42)); margin-top: 0.9em; }
.hl-btn::after { content: ""; position: absolute; inset: -10px -8px; }   /* ~44px tap target on phones */
.hl-btn { position: relative; display: flex; align-items: flex-start; padding: 0 0.22em 0.24em 0;
  text-decoration: none; pointer-events: auto; cursor: pointer; -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.22)); outline: none; }
.hl-btn .hl-strip { position: absolute; left: 0.62em; right: 0; top: 0.1em; bottom: 0; background: rgb(244, 239, 231); }
.hl-btn span { position: relative; font: 700 1em/1 "WenKai Title", serif; color: rgb(31, 32, 32);
  -webkit-text-stroke: 0.03em rgb(31, 32, 32); background: rgb(250, 250, 250);
  transition: transform 0.17s cubic-bezier(.22,1,.36,1); }
.hl-btn:active { transform: scale(0.97); }
.hl-btn .ink { position: absolute; left: -0.55em; top: -0.5em; width: calc(100% + 1.1em); height: calc(100% + 0.95em);
  overflow: visible; pointer-events: none; }
.hl-btn .ink path { fill: none; stroke: #1f2020; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  vector-effect: non-scaling-stroke; stroke-dasharray: var(--len, 400) var(--len, 400); stroke-dashoffset: var(--len, 400);
  transition: stroke-dashoffset 0.25s ease, opacity 0.25s; }
@media (hover: hover) { .hl-btn:not(.drawn):hover .ink path { stroke-dashoffset: calc(var(--len, 400) * 0.84); opacity: 0.55; } }
.hl-btn.drawn .ink path { stroke-dashoffset: 0; opacity: 1; transition: stroke-dashoffset 0.5s cubic-bezier(.45,.05,.3,1); }
.hl-btn:focus-visible .ink path { stroke-dashoffset: calc(var(--len, 400) * 0.84); opacity: 0.55; }
/* back: top-left on the black keychain page, light pen */
.hl-back { position: fixed; z-index: 8; left: 28px; top: 26px; font-size: min(30px, 6.4vw);
  opacity: 0; pointer-events: none; transition: opacity 0.35s; }
body.birthday .hl-back { opacity: 1; pointer-events: auto; }
body.birthday.intro .hl-back, body.boxing .hl-back { opacity: 0; pointer-events: none; }
.hl-back .ink path { stroke: #f4f1e8; }
@media (max-width: 720px) { .hl-back { left: 16px; top: 18px; } }
