/* =========================================================
   Our diary: closed book on the diary page
   ========================================================= */
.diary-card {
  width: 100%;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 16px;
  padding: 18px;
  background: #fff;
  border: 3px solid var(--pink-100);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.diary-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.diary-actions .btn-small { padding: 10px 18px; font-size: 1rem; }

.closed-book {
  position: relative;
  width: 86px; height: 110px;
  padding: 0; border: none; background: none; cursor: pointer;
  perspective: 500px;
  animation: bob 3.6s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
.closed-book:focus-visible { outline: 3px dashed var(--pink-400); outline-offset: 6px; border-radius: 8px; }
.cb-pages {
  position: absolute; inset: 4px 0 4px 6px;
  border-radius: 3px 8px 8px 3px;
  background: repeating-linear-gradient(90deg, #fffaf4 0 2px, #f1e2d8 2px 3px);
  box-shadow: 0 8px 14px -6px rgba(194, 54, 107, .5);
}
.cb-cover, .jcover {
  position: absolute; inset: 0; z-index: 1;
  border-radius: 4px 10px 10px 4px;
  background: linear-gradient(140deg, #ffb0cb, #ef4f86);
  box-shadow: inset 7px 0 0 rgba(0, 0, 0, .08);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transform-origin: left center;
  transition: transform .5s cubic-bezier(.5, 0, .3, 1.2);
}
.cb-cover::before, .jcover::before {
  content: ""; position: absolute; inset: 7px 7px 7px 12px;
  border: 2px dashed rgba(255, 255, 255, .75);
  border-radius: 3px 7px 7px 3px;
}
.closed-book:hover .cb-cover { transform: rotateY(-28deg); }
.cb-title { font-family: "Caveat", "Nanum Pen Script", cursive; font-size: 1.25rem; line-height: .95; color: #fff; text-align: center; }
.cb-heart { color: #fff; font-size: .9rem; }
.cb-ribbon {
  position: absolute; top: 0; right: 16px;
  width: 9px; height: 60%;
  background: #ffd76a;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 85%, 0 100%);
}

/* =========================================================
   The open book
   ========================================================= */
.jbook-overlay { flex-direction: column; gap: 14px; }
.jbook {
  position: relative;
  width: min(100%, 460px);
  height: min(calc(100vh - 120px), 660px);
  min-height: 420px;
  margin-top: auto;
  perspective: 1800px;
  animation: bookIn .55s cubic-bezier(.3, 1.3, .5, 1);
}
@keyframes bookIn { from { opacity: 0; transform: translateY(40px) scale(.85) rotate(-3deg); } }
.jbook-back {
  position: absolute; inset: -8px -10px -10px -8px;
  border-radius: 10px 20px 20px 10px;
  background: linear-gradient(140deg, #ff9ec0, #d6457a);
  box-shadow: 0 30px 60px -20px rgba(90, 42, 61, .6);
}
.jbook-back::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 14px;
  border-radius: 10px 0 0 10px;
  background: rgba(0, 0, 0, .12);
}
.jpage-wrap {
  position: absolute; inset: 0;
  perspective: 1800px;
  border-radius: 4px 14px 14px 4px;
}
.jpage {
  position: absolute; inset: 0;
  overflow-y: auto;
  padding: 26px 22px 46px 38px;
  border-radius: 4px 14px 14px 4px;
  background:
    linear-gradient(90deg, rgba(150, 90, 110, .22), transparent 22px),
    linear-gradient(90deg, transparent 28px, #ffc2d3 28px, #ffc2d3 30px, transparent 30px),
    repeating-linear-gradient(#fffdf7 0 31px, #d9e7f5 31px 32px);
  box-shadow: inset 0 0 0 1px #f1e2d8, 2px 2px 0 #f3e6dc, 4px 4px 0 #ecdccf;
  outline: none;
  overscroll-behavior: contain;
}
.jpage::-webkit-scrollbar { width: 6px; }
.jpage::-webkit-scrollbar-thumb { background: var(--pink-200); border-radius: 6px; }

.jcover {
  border-radius: 4px 14px 14px 4px;
  transition: transform 1.1s cubic-bezier(.6, .05, .3, 1), opacity .3s .9s;
  backface-visibility: hidden;
  z-index: 5;
}
.jcover .cb-ribbon { right: 34px; height: 45%; }
.jcover.opened { transform: rotateY(-172deg); opacity: 0; pointer-events: none; }
.jcover-title { font-family: "Caveat", "Nanum Pen Script", cursive; font-size: 3rem; color: #fff; text-shadow: 0 3px 0 rgba(194, 54, 107, .5); }
.jcover-heart { color: #fff; font-size: 1.6rem; letter-spacing: 6px; }

.jbook .x-btn { top: -18px; right: -14px; z-index: 6; }

/* page turning */
.jleaf {
  position: absolute; inset: 0; z-index: 3;
  transform-origin: left center;
  transform-style: preserve-3d;
  pointer-events: none;
}
.jface { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 4px 14px 14px 4px; }
.jfront { overflow: hidden; }
.jback {
  transform: rotateY(180deg);
  background:
    linear-gradient(270deg, rgba(150, 90, 110, .25), transparent 30px),
    repeating-linear-gradient(#fbf4ec 0 31px, #e5ddd5 31px 32px);
}
.jshade {
  position: absolute; inset: 0; z-index: 2;
  border-radius: 4px 14px 14px 4px;
  background: linear-gradient(90deg, rgba(90, 42, 61, .55), transparent 70%);
  pointer-events: none;
}

/* page contents */
.jtape {
  display: table;
  margin: 0 auto;
  padding: 2px 18px;
  transform: rotate(-2deg);
  background: repeating-linear-gradient(45deg, rgba(255, 163, 196, .7) 0 7px, rgba(255, 214, 229, .7) 7px 14px);
  font-family: "Caveat", "Nanum Pen Script", cursive; font-weight: 700; font-size: 1.5rem; line-height: 30px;
  color: var(--ink);
}
.jday { margin: 2px 0 0; text-align: center; font-family: "Caveat", "Nanum Pen Script", cursive; font-size: 1.25rem; line-height: 32px; color: var(--ink-soft); }

.jentry {
  position: relative;
  display: block; width: 100%;
  margin: 16px 0 0;
  padding: 0;
  background: none; border: none; text-align: left; font: inherit; color: inherit;
}
.jhead { display: flex; align-items: center; gap: 8px; height: 32px; }
.jsticker {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(194, 54, 107, .3);
  font-size: 1.05rem;
  flex-shrink: 0;
}
.jname { font: 800 .95rem "Nunito", "Gowun Dodum", sans-serif; color: var(--berry); }
.jmood { font-size: 1.2rem; margin-left: auto; }
.jtext {
  margin: 0;
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: "Caveat", "Nanum Pen Script", cursive; font-size: 1.5rem; line-height: 32px;
}
.jentry-her .jtext { color: #3d3399; }   /* her pen: blue-violet ink */
.jentry-duk .jtext { color: #a8285a; }   /* Duk's pen: berry ink */
.jentry-duk .jname { color: #a8285a; }
.jentry-her .jname { color: #3d3399; }
.jedit {
  margin-top: 2px;
  padding: 0; border: none; background: none; cursor: pointer;
  font: 800 .82rem "Nunito", "Gowun Dodum", sans-serif; color: var(--ink-soft); text-decoration: underline;
}
.jentry-blank, .jentry-none {
  display: flex; align-items: center; gap: 10px;
  min-height: 64px;
  padding: 10px 12px;
  border: 2px dashed var(--pink-200);
  border-radius: 14px;
  font-family: "Caveat", "Nanum Pen Script", cursive; font-size: 1.3rem; line-height: 1.15;
  color: var(--ink-soft);
}
.jentry-blank { cursor: pointer; background: rgba(255, 228, 238, .5); color: var(--berry); animation: blankGlow 2s ease-in-out infinite; }
.jentry-blank:hover { background: rgba(255, 201, 220, .6); }
@keyframes blankGlow { 50% { border-color: var(--pink-400); } }
.jdoodle { display: block; margin: 14px 4px 0 auto; width: max-content; font-size: 1.7rem; opacity: .8; transform: rotate(12deg); }
.jpageno { margin-top: 4px; text-align: center; font-family: "Caveat", "Nanum Pen Script", cursive; font-size: 1.15rem; color: var(--ink-soft); }

/* nav */
.jnav { display: flex; align-items: center; gap: 12px; margin-bottom: auto; }
.jnav-btn {
  width: 50px; height: 50px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: linear-gradient(180deg, #ff94b9, #ef4f86);
  color: #fff; font: 600 1.8rem/1 "Fredoka", "Jua", sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--berry), 0 10px 18px -8px rgba(194, 54, 107, .7);
  transition: transform .15s, opacity .2s;
}
.jnav-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--berry); }
.jnav-btn:disabled { opacity: .35; cursor: default; }
.jnav-mid {
  padding: 10px 16px;
  border-radius: 999px;
  border: 2px solid var(--pink-200);
  background: #fff;
  color: var(--berry); font: 800 .85rem "Nunito", "Gowun Dodum", sans-serif;
  cursor: pointer;
}
.jnav-mid:disabled { opacity: .5; cursor: default; }

/* page tucked into the book after saving */
.fly-book {
  position: fixed; left: 50%; top: 50%; z-index: 55;
  font-size: 3.2rem;
  margin: -30px 0 0 -30px;
  filter: drop-shadow(0 10px 14px rgba(194, 54, 107, .4));
  pointer-events: none;
}
.fly-book.go { animation: bookHug 1.25s cubic-bezier(.3, 1.3, .5, 1) forwards; }
@keyframes bookHug {
  0% { transform: scale(.2); opacity: 0; }
  30% { transform: scale(1.3) rotate(-8deg); opacity: 1; }
  45% { transform: scale(1) rotate(6deg); }
  60% { transform: scale(1.1) rotate(-3deg); }
  100% { transform: translateY(40vh) scale(.4); opacity: 0; }
}

/* =========================================================
   Her photos
   ========================================================= */

/* scrapbook photo taped on each page */
.jphoto {
  position: relative;
  display: block;
  width: min(72%, 240px);
  margin: 18px auto 6px;
  padding: 8px 8px 6px;
  border: none; border-radius: 3px;
  background: #fff;
  box-shadow: 0 12px 20px -12px rgba(90, 42, 61, .55);
  transform: rotate(var(--r));
  cursor: zoom-in;
}
.jphoto img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--pink-50); border-radius: 2px; }
.jphoto-tape {
  position: absolute; top: -11px; left: 50%; z-index: 1;
  width: 74px; height: 22px;
  transform: translateX(-50%) rotate(-4deg);
  background: repeating-linear-gradient(45deg, rgba(255, 215, 106, .8) 0 6px, rgba(255, 236, 170, .8) 6px 12px);
}
.jphoto-cap { display: block; margin-top: 4px; text-align: center; font-family: "Caveat", "Nanum Pen Script", cursive; font-size: 1.25rem; line-height: 1.1; color: var(--ink); }

/* her photo on the book covers */
.jcover-photo {
  position: relative; z-index: 1;
  width: 52%; aspect-ratio: 1;
  object-fit: cover;
  padding: 8px 8px 26px;
  background: #fff;
  border-radius: 3px;
  transform: rotate(-4deg);
  box-shadow: 0 12px 22px -10px rgba(90, 42, 61, .6);
}
.jcover.has-photo .jcover-title { font-size: 2.3rem; margin-top: 6px; }
.jcover.has-photo .jcover-heart { display: none; }
.cb-photo {
  position: relative; z-index: 1;
  width: 54px; height: 54px;
  object-fit: cover;
  padding: 3px 3px 8px;
  background: #fff;
  border-radius: 2px;
  transform: rotate(-5deg);
  box-shadow: 0 4px 8px -3px rgba(90, 42, 61, .5);
}
.closed-book.has-photo .cb-title { font-size: .95rem; line-height: .9; }
.closed-book.has-photo .cb-heart { display: none; }

/* polaroids hanging on a string */
.clothesline { width: 100%; }
.cl-label { margin: 0 0 -8px 6px; font-family: "Caveat", "Nanum Pen Script", cursive; font-size: 1.45rem; color: var(--berry); }
.cl-scroll {
  overflow-x: auto; overflow-y: hidden;
  padding: 2px 0 22px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
}
.cl-scroll::-webkit-scrollbar { display: none; }
.cl-row { position: relative; display: inline-flex; gap: 16px; min-width: 100%; padding: 22px 16px 6px; }
.cl-row::before {
  content: ""; position: absolute; left: 0; right: 0; top: 18px;
  height: 2px; border-radius: 2px;
  background: #c79a86;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .7);
}
.cl-photo, .margin-polaroid {
  position: relative; flex-shrink: 0;
  padding: 7px 7px 6px;
  border: none; border-radius: 3px;
  background: #fff;
  box-shadow: 0 12px 18px -12px rgba(90, 42, 61, .6);
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}
.cl-photo {
  width: 120px;
  transform-origin: 50% -10px;
  transform: rotate(var(--r));
  animation: sway var(--d) ease-in-out var(--delay) infinite alternate;
}
.cl-photo:hover, .cl-photo:focus-visible { animation-play-state: paused; }
.cl-photo:focus-visible, .margin-polaroid:focus-visible { outline: 3px dashed var(--pink-400); outline-offset: 4px; }
@keyframes sway { from { transform: rotate(calc(var(--r) - 3deg)); } to { transform: rotate(calc(var(--r) + 3deg)); } }
.cl-photo img { display: block; width: 106px; height: 106px; object-fit: cover; background: var(--pink-50); border-radius: 2px; }
.cl-cap { display: block; margin-top: 3px; max-width: 106px; text-align: center; font-family: "Caveat", "Nanum Pen Script", cursive; font-size: 1.05rem; line-height: 1.1; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin {
  position: absolute; top: -13px; left: 50%;
  width: 10px; height: 22px; margin-left: -5px;
  border-radius: 3px;
  background: linear-gradient(#ffd0e1, #ef4f86);
  box-shadow: 0 2px 2px rgba(0, 0, 0, .15);
}
.pin::after { content: ""; position: absolute; left: 4px; top: 4px; width: 2px; height: 14px; background: rgba(255, 255, 255, .6); }

/* side-margin polaroids on wide screens */
.photo-margins { display: none; }
@media (min-width: 1100px) { body.in-diary .photo-margins { display: block; } }
.margin-polaroid {
  position: fixed; z-index: 2;
  width: 160px;
  transform: rotate(var(--r));
  transition: transform .25s;
  animation: fadeUp .6s ease both;
}
.margin-polaroid:hover { transform: rotate(0) scale(1.07); z-index: 3; }
.margin-polaroid img { display: block; width: 146px; height: 146px; object-fit: cover; background: var(--pink-50); }
.margin-polaroid .pin { display: none; }
.margin-polaroid::before {
  content: ""; position: absolute; top: -10px; left: 50%;
  width: 70px; height: 22px;
  transform: translateX(-50%) rotate(4deg);
  background: repeating-linear-gradient(45deg, rgba(255, 163, 196, .75) 0 7px, rgba(255, 214, 229, .75) 7px 14px);
}
.margin-polaroid .cl-cap { max-width: 146px; font-size: 1.2rem; }

/* the photo viewer opens on top of the book */
.viewer { z-index: 45; }

/* Korean lines inside the book (her view) */
.jentry-blank .ko, .jentry-none .ko { display: block; font-size: .85em; margin-top: 2px; }
.jedit .ko { opacity: .8; }
.jnav-mid .ko { opacity: .8; }
#nbSave .ko::before { content: "· "; opacity: .7; }
