/* ============================================
   DIARY — open spread that still page-flips,
   then shuts like a leather-bound book
   ============================================ */

.diary-block {
  margin: 0 0 var(--space-lg);
}

.diary-kicker {
  font-family: var(--font-hand);
  font-size: 1.5rem;
  color: var(--ink-soft);
  transform: rotate(-1.2deg);
  margin-bottom: 1.1rem;
}

.diary {
  --page: #f7f1e3;
  --page-rule: rgba(91, 110, 82, 0.16);
  --leather: #a44402;
  --leather-lite: #c05c06;
  --leather-deep: #7a2e08;
  --leather-ink: #5c2208;
  --leather-face: linear-gradient(145deg, var(--leather-lite) 0%, var(--leather) 38%, var(--leather-deep) 72%, #8b3a0c 100%);
  width: min(736px, 100%);
  margin: 0 auto;
}

.diary-stage {
  position: relative;
  min-height: 416px;
  padding: 1.2rem 0.6rem 1.8rem;
  overflow: visible;
}

.diary-spread {
  position: relative;
  width: 100%;
  height: 416px;
  padding: 11px;
  perspective: 2800px;
  transform-style: preserve-3d;
  background: transparent;
  transform: rotate(-3.8deg);
  transform-origin: center 58%;
  transition: opacity 0.4s ease;
  filter: drop-shadow(10px 18px 20px rgba(58, 46, 34, 0.2));
}

.diary-left-board {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  border-radius: 8px 0 0 8px;
  background:
    radial-gradient(ellipse at 22% 18%, rgba(255, 248, 230, 0.28), transparent 46%),
    radial-gradient(ellipse at 78% 86%, rgba(80, 42, 16, 0.22), transparent 42%),
    var(--leather-face);
  box-shadow:
    inset 8px 0 14px rgba(58, 46, 34, 0.12),
    0 18px 24px rgba(58, 46, 34, 0.18);
  z-index: 0;
}

.diary-left-board::after {
  content: '';
  position: absolute;
  inset: 18px 16px 18px 22px;
  border: 2px solid rgba(92, 34, 8, 0.35);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 236, 200, 0.12);
}

.diary-spread::before {
  content: '';
  position: absolute;
  top: 11px;
  bottom: 11px;
  left: calc(50% - 7px);
  width: 14px;
  background: linear-gradient(
    90deg,
    rgba(58, 46, 34, 0.18),
    rgba(255, 255, 255, 0.12) 45%,
    rgba(58, 46, 34, 0.22)
  );
  z-index: 50;
  pointer-events: none;
}

.diary-left,
.diary .sheet .face {
  background:
    linear-gradient(90deg, rgba(58, 46, 34, 0.06), transparent 12px),
    repeating-linear-gradient(
      180deg,
      transparent 0 31px,
      var(--page-rule) 31px 32px
    ),
    var(--page);
}

.diary-left {
  position: absolute;
  top: 11px;
  bottom: 11px;
  left: 11px;
  width: calc(50% - 11px);
  padding: 2.3rem 1.7rem 2.4rem 1.9rem;
  box-shadow: inset -10px 0 16px rgba(58, 46, 34, 0.06);
  z-index: 2;
  font-family: var(--font-caveat);
}

.diary-prompt {
  font-family: var(--font-caveat);
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  font-weight: 400;
  font-synthesis: none;
  color: var(--rust);
  line-height: 1.15;
  margin: 0;
}

.diary-prompt-rest {
  font-family: var(--font-caveat);
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  font-weight: 400;
  font-synthesis: none;
  color: var(--ink);
  line-height: 1.25;
  margin: 0.35rem 0 0;
  max-width: 11ch;
}

.diary .sheet {
  position: absolute;
  top: 11px;
  bottom: 11px;
  left: 50%;
  width: calc(50% - 11px);
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.85s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.diary .sheet.is-flipped {
  transform: rotateY(-180deg);
}

.diary .sheet.is-turning {
  z-index: 80 !important;
}

.diary.is-closing .sheet,
.diary.is-closed .sheet {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: none;
}

.diary .face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  padding: 2.3rem 1.8rem 2.6rem 1.9rem;
  font-family: var(--font-caveat);
}

.diary .face.front {
  box-shadow: inset 10px 0 16px rgba(58, 46, 34, 0.05);
}

.diary .face.back {
  transform: rotateY(180deg);
  box-shadow: inset -10px 0 16px rgba(58, 46, 34, 0.05);
}

.diary .face::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.16), transparent 28%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.diary .sheet.is-turning .face::after {
  opacity: 1;
}

.diary-entry {
  font-family: var(--font-caveat);
  font-size: clamp(1.45rem, 2.4vw, 1.9rem);
  font-weight: 400;
  font-synthesis: none;
  line-height: 1.4;
  margin: 0;
}

.diary-foot {
  position: absolute;
  bottom: 1.1rem;
  right: 1.4rem;
  font-family: var(--font-caveat);
  font-size: 1.05rem;
  color: var(--ink-soft);
}

.diary .flip-zone {
  position: absolute;
  top: 11px;
  bottom: 11px;
  width: calc(50% - 11px);
  z-index: 90;
  background: transparent;
  cursor: pointer;
}

.diary .flip-zone.left { left: 11px; }
.diary .flip-zone.right { right: 11px; }

.diary .flip-zone:disabled {
  cursor: default;
}

.closing-cover {
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  z-index: 3;
  pointer-events: none;
  transition: transform 1.05s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.diary.is-closing .closing-cover {
  z-index: 100;
  filter: drop-shadow(-10px 10px 16px rgba(58, 46, 34, 0.32));
}

.closing-cover.is-flipped {
  z-index: 100;
  transform: rotateY(-180deg);
}

.close-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.close-face.inside {
  background:
    radial-gradient(ellipse at 30% 18%, rgba(255, 248, 230, 0.18), transparent 48%),
    var(--leather-face);
  border-radius: 0 8px 8px 0;
  box-shadow: inset 8px 0 14px rgba(58, 46, 34, 0.18);
}

.close-face.outside {
  transform: rotateY(180deg);
  background:
    radial-gradient(ellipse at 30% 18%, rgba(255, 248, 230, 0.22), transparent 48%),
    radial-gradient(ellipse at 70% 82%, rgba(80, 42, 16, 0.2), transparent 46%),
    var(--leather-face);
  border-radius: 8px 0 0 8px;
  box-shadow: inset 0 0 0 1px rgba(90, 34, 8, 0.35);
}

.close-face.outside::after {
  content: '';
  position: absolute;
  inset: 18px 22px 18px 16px;
  border: 2px solid rgba(92, 34, 8, 0.35);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 236, 200, 0.12);
}

.diary-shut {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  transform: rotate(-6.5deg) scale(0.92) translateY(12px);
  transform-origin: center 55%;
  transition:
    opacity 0.5s ease 0.12s,
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.08s;
}

.diary-shut img {
  width: min(304px, 78%);
  height: auto;
  display: block;
  background: transparent;
  filter: drop-shadow(12px 22px 18px rgba(58, 46, 34, 0.28));
}

.diary-shut-btn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  cursor: pointer;
}

.diary.is-closing .diary-spread::before {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.diary.is-closed .diary-spread {
  opacity: 0;
  pointer-events: none;
}

.diary.is-resetting .sheet,
.diary.is-resetting .closing-cover,
.diary.is-resetting .diary-spread {
  transition: none !important;
}

.diary.is-closed .diary-shut {
  opacity: 1;
  pointer-events: auto;
  transform: rotate(-6.5deg);
  cursor: pointer;
}

.diary-hint {
  margin-top: 0.9rem;
  text-align: center;
  font-family: var(--font-hand);
  font-size: 1.25rem;
  color: var(--ink-soft);
}

@media (max-width: 720px) {
  .diary-stage,
  .diary-spread {
    height: 344px;
    min-height: 344px;
  }

  .diary-left,
  .diary .face {
    padding: 1.4rem 1.05rem 1.8rem 1.15rem;
  }

  .diary-prompt-rest {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .diary .sheet,
  .closing-cover,
  .diary-spread,
  .diary-shut {
    transition: none;
  }
}
