/* Weekly memorization verses printed onto the open Bible photo in the
   home cover. Desktop: two blocks sit on the left/right pages of the
   photographed Bible, transformed to follow each page's tilt.
   Page geometry (source photo 1100x733, object-fit cover, 62% 54%):
   left page text zone centre ~ (62.3%, 45%) of the cover,
   right page text zone centre ~ (83.6%, 41%). Percentages stay stable
   across desktop widths because the photo box is width-driven.
   <=1100px: the on-photo blocks are replaced by two paper cards under
   the opening text, where the verses stay readable. */

.home-cover .home-opening { position: relative; z-index: 2; }

.memo-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.memo-page {
  position: absolute;
  padding: clamp(8px, 0.7vw, 14px) clamp(9px, 0.8vw, 16px);
  border-radius: 3px;
  background: linear-gradient(155deg, rgba(253, 249, 233, 0.7), rgba(250, 243, 220, 0.56));
  box-shadow: 0 0 22px 6px rgba(253, 249, 233, 0.35);
  color: #2e2a1e;
  transform-origin: center;
}

.memo-page--current {
  left: 62.7%;
  top: 46.3%;
  width: 17.2%;
  transform: translate(-50%, -50%) perspective(950px) rotateX(8deg) rotateY(-14deg) rotate(-4.5deg);
}

.memo-page--next {
  left: 82.6%;
  top: 42%;
  width: 21.5%;
  transform: translate(-50%, -50%) perspective(950px) rotateX(8deg) rotateY(13deg) rotate(-3deg);
}

.memo-title {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2em 0.5em;
  align-items: baseline;
  margin-bottom: 0.5em;
  font: 700 clamp(11px, 0.95vw, 15px)/1.3 "IBM Plex Sans KR", "Malgun Gothic", sans-serif;
  letter-spacing: -0.01em;
  color: #221a0d;
}

.memo-title .memo-kicker { color: #7c5c14; }

.memo-ko {
  font: 500 clamp(10.5px, 0.8vw, 13.5px)/1.55 "Noto Serif KR", "Batang", Georgia, serif;
  color: #2b2517;
  word-break: keep-all;
}

.memo-en {
  margin-top: 0.55em;
  font: clamp(8px, 0.58vw, 10px)/1.45 Georgia, "Times New Roman", serif;
  color: #4c4433;
}

/* Fallback cards (narrow screens) */
.memo-fallback { display: none; }

@media (max-width: 1100px) {
  .memo-layer { display: none; }

  .memo-fallback {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: min(calc(100% - 48px), 1280px);
    margin-inline: auto;
    padding-bottom: 26px;
  }

  .memo-card {
    padding: 16px 18px;
    border: 1px solid #d8d2ba;
    border-radius: 10px;
    background: #fdfaf0;
    color: #26302a;
    box-shadow: 0 6px 18px rgba(10, 24, 17, 0.25);
  }

  .memo-card .memo-title {
    font-size: 1rem;
    color: #253f35;
  }

  .memo-card .memo-title .memo-kicker { color: #8a6a1f; }

  .memo-card .memo-ko {
    font-size: 0.98rem;
    line-height: 1.7;
    color: #26302a;
  }

  .memo-card .memo-en {
    font-size: 0.8rem;
    line-height: 1.55;
    color: #5a665c;
  }
}

@media (max-width: 620px) {
  .memo-fallback {
    grid-template-columns: 1fr;
    width: calc(100% - 32px);
    padding-bottom: 20px;
  }
}


.memo-book[hidden], .memo-book-controls[hidden] { display: none; }

@font-face {
  font-family: "Noto Serif KR";
  src: url("/assets/memorization-noto-serif-kr.woff2") format("woff2");
  font-weight: 500 700;
  font-display: swap;
}

@font-face {
  font-family: "Noto Serif KR Controls";
  src: url("/assets/memorization-controls.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

@media (min-width: 1101px) {
  .memo-book {
    position: absolute;
    inset: 0 max(0px, calc((100vw - 1550px) / 2)) 0 auto;
    display: grid;
    place-items: center;
    width: min(61%, 960px);
    pointer-events: none;
  }
  .memo-book-spread { position: relative; width: 100%; }
  .memo-book-art { position: relative; z-index: 1; width: 100%; }
  .memo-book-art > :is(img, canvas) {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 76 / 45;
    mask-image: linear-gradient(90deg, transparent, #000 14%);
  }
  .memo-book-controls {
    position: absolute;
    left: 35.8%;
    top: 66%;
    z-index: 3;
    display: flex;
    align-items: center;
    font: 700 clamp(14px, 1.25vw, 18px)/1.25 "Noto Serif KR Controls", "Noto Serif KR", Batang, serif;
    color: #53381e;
    /* Project the controls onto the tangent of the lower left page. */
    transform-origin: left center;
    transform: translateY(-50%) matrix(.955, -.298, .562, .746, 0, 0);
  }
  .memo-book-controls button {
    min-width: 42px;
    min-height: 40px;
    padding: 0 7px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    white-space: nowrap;
    text-underline-offset: .22em;
    cursor: pointer;
    pointer-events: auto;
  }
  .memo-book-controls button:is([aria-pressed="true"], :hover) {
    text-decoration: underline;
    text-decoration-thickness: 1px;
  }
  .memo-book-controls button:focus-visible {
    outline: 2px solid #53381e;
    outline-offset: -3px;
    border-radius: 3px;
  }
  .memo-book-ready .home-opening { min-height: clamp(395px, 36.12vw, 569px); }
  .memo-book-ready .home-photo { visibility: hidden; }
  .memo-book-ready .memo-layer,
  .memo-book-text-only .memo-layer {
    inset: 0 auto auto 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .memo-book-text-only .memo-fallback {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: min(calc(100% - 48px), 1280px);
    margin-inline: auto;
    padding-bottom: 26px;
  }
  .memo-book-text-only .memo-card {
    padding: 16px 18px;
    border-radius: 10px;
    background: #fdfaf0;
  }
}

@media (min-width: 1101px) and (pointer: coarse) {
  .memo-book-controls button { min-width: 50px; min-height: 60px; }
}


.memo-next-details > summary { cursor: pointer; list-style-position: inside; }
.memo-next-details > summary .memo-title { display: inline-flex; margin-bottom: 0; }
.memo-next-details[open] > summary { margin-bottom: .65em; }
.memo-next-collapsed .memo-page--next :is(.memo-ko,.memo-en) { display: none; }
.memo-book-next-toggle[hidden] { display:none; }
.memo-book-next-toggle { position:absolute; z-index:4; left:70%; top:42%; transform:translate(-50%,-50%); border:1px solid #a48a5c; border-radius:6px; background:#fdfaf0ed; color:#53381e; padding:8px 12px; cursor:pointer; pointer-events:auto; font:700 clamp(12px,1vw,16px)/1.4 "Malgun Gothic",sans-serif; white-space:nowrap; }
.memo-book-next-toggle[aria-expanded="true"] { top:64%; }
.memo-book-next-toggle:focus-visible { outline:2px solid #53381e; }
