/* MARK BOOKS */

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

:root {
  --bg: #FAFAF8;
  --ink: #131312;
  --grey: #8F8F8A;
  --hairline: #E4E2DC;
  --sans: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --cover-h: min(63vh, 640px);
  --cover-h: min(63dvh, 640px);
  --shift: 3vh;
  --shift: 3dvh;
}

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--ink); color: var(--bg); }

:focus-visible { outline: 1px solid #B9B7B0; outline-offset: 4px; }

/* ---------- ambient glow ---------- */

.glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.6s ease;
}
.glow.on { opacity: 1; }

/* ---------- header ---------- */

.site-head {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 30px 34px;
  opacity: 0;
  animation: fadein 1s ease .1s forwards;
}

.brand {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .24em;
  text-transform: uppercase;
}

.head-nav {
  display: flex;
  gap: 32px;
  align-items: baseline;
  position: relative;
}

.head-link {
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  padding: 4px 0;
  transition: opacity .25s ease;
}
.head-link:hover { opacity: .5; }

.bag.bump { animation: bump .45s var(--ease); }
@keyframes bump {
  0% { transform: translateY(0); }
  35% { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}

.bag-panel {
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  width: 272px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  padding: 20px 22px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .3s ease, transform .3s var(--ease), visibility 0s .3s;
}
.bag-panel.open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .3s ease, transform .3s var(--ease), visibility 0s;
}
.bp-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 7px 0;
  font-size: 12px;
  letter-spacing: .02em;
}
.bp-row span:last-child { color: #55534E; white-space: nowrap; }
.bp-empty { font-size: 12px; color: var(--grey); letter-spacing: .03em; }
.bp-total {
  display: none;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
}

/* ---------- story progress ---------- */

.progress {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  gap: 4px;
  opacity: 0;
  animation: fadein 1s ease .25s forwards;
}
.tick { padding: 9px 5px; }
.tick span {
  display: block;
  width: 26px;
  height: 1px;
  background: #D8D6CF;
  transition: background .4s ease;
}
.tick.on span { background: var(--ink); }
.tick:hover span { background: #A9A7A0; }
.tick.on:hover span { background: var(--ink); }

/* ---------- stage / carousel ---------- */

.stage {
  position: fixed;
  inset: 0;
  z-index: 10;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.stage.dragging { cursor: grabbing; }

.track { position: absolute; inset: 0; }

.book {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--cover-h) * .6667);
  height: var(--cover-h);
  margin-left: calc(var(--cover-h) * -.3333);
  margin-top: calc(var(--cover-h) / -2 - var(--shift));
  will-change: transform, opacity;
  box-shadow: 0 28px 52px -28px rgba(20, 20, 18, .14);
  visibility: hidden;
}
.book svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.book.center { cursor: pointer; }

/* ---------- book meta ---------- */

.meta {
  position: absolute;
  left: 50%;
  top: calc(50% + var(--cover-h) / 2 - var(--shift) + 34px);
  transform: translateX(-50%);
  z-index: 5;
  width: min(84vw, 440px);
  text-align: center;
  opacity: 0;
  animation: fadein 1s ease .4s forwards;
}

.m-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: .01em;
}
.m-author {
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--grey);
}
.m-price { margin-top: 9px; font-size: 12px; letter-spacing: .06em; }
.m-view {
  margin-top: 15px;
  font-size: 10px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: #A9A7A0;
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
  transition: color .25s ease, border-color .25s ease;
}
.m-view:hover { color: var(--ink); border-color: var(--ink); }

.meta-line {
  transition: opacity .26s ease, transform .26s var(--ease);
}
.meta-line:nth-child(2) { transition-delay: .045s; }
.meta-line:nth-child(3) { transition-delay: .09s; }
.meta-line:nth-child(4) { transition-delay: .13s; }
.meta.swap .meta-line { opacity: 0; transform: translateY(7px); }

/* ---------- product view ---------- */

.product {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px);
  transition: opacity .5s ease, transform .5s var(--ease), visibility 0s .5s;
}
.product.open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .5s ease .06s, transform .5s var(--ease) .06s, visibility 0s;
}

.p-back {
  position: absolute;
  top: 84px;
  left: 34px;
  z-index: 2;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--grey);
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
  transition: color .25s ease, border-color .25s ease;
}
.p-back:hover { color: var(--ink); border-color: var(--ink); }

.p-grid {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  padding: 0 6vw;
}
.p-left {
  display: flex;
  justify-content: center;
  padding: 12vh 4vw 10vh;
}
.p-cover {
  width: min(30vw, 380px);
  aspect-ratio: 2 / 3;
  box-shadow: 0 28px 52px -28px rgba(20, 20, 18, .14);
}
.p-cover svg { width: 100%; height: 100%; display: block; }

.p-right { max-width: 400px; padding: 14vh 4vw 10vh 0; }
.p-over {
  font-size: 10px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--grey);
}
.p-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(30px, 3.4vw, 42px);
  line-height: 1.08;
  margin-top: 18px;
}
.p-author {
  margin-top: 13px;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--grey);
}
.p-rule { height: 1px; background: var(--hairline); margin: 30px 0; }
.p-price { font-size: 15px; letter-spacing: .04em; }
.p-format { margin-top: 8px; font-size: 12px; color: var(--grey); letter-spacing: .03em; }
.p-blurb { margin-top: 26px; font-size: 14px; line-height: 1.75; color: #4C4C48; }
.p-add {
  margin-top: 34px;
  width: 100%;
  height: 54px;
  background: #141413;
  color: #FAFAF8;
  font-size: 11px;
  letter-spacing: .26em;
  text-transform: uppercase;
  transition: opacity .25s ease;
}
.p-add:hover { opacity: .8; }
.p-add:disabled { opacity: 1; }

.p-specs { margin-top: 46px; }
.p-specs div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding: 11px 0;
  border-top: 1px solid var(--hairline);
}
.p-specs dt {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--grey);
}
.p-specs dd { font-size: 12px; letter-spacing: .03em; }

.p-art { margin: 8vh 0 0; }
.p-art-img { height: 76vh; }
.p-art-img svg { width: 100%; height: 100%; display: block; }
.p-art figcaption {
  padding: 16px 34px 0;
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--grey);
}

.p-quote {
  max-width: 860px;
  margin: 0 auto;
  padding: 17vh 34px;
  text-align: center;
}
.p-quote p {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(24px, 3vw, 35px);
  line-height: 1.35;
  color: #2B2B28;
}
.p-quote cite {
  display: block;
  margin-top: 28px;
  font-family: var(--sans);
  font-style: normal;
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--grey);
}

.p-foot {
  margin: 0 34px;
  padding: 26px 0 36px;
  border-top: 1px solid var(--hairline);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--grey);
}

/* ---------- search overlay ---------- */

.search {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s ease, visibility 0s .35s;
}
.search.open {
  opacity: 1;
  visibility: visible;
  transition: opacity .35s ease, visibility 0s;
}
.search-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 30px 34px;
  font-size: 11px;
  letter-spacing: .24em;
  text-transform: uppercase;
}
.search-head button { letter-spacing: .22em; text-transform: uppercase; font-size: 11px; transition: opacity .25s; }
.search-head button:hover { opacity: .5; }

.search-body {
  max-width: 620px;
  margin: 13vh auto 0;
  padding: 0 34px;
}
#searchInput {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  font-family: var(--serif);
  font-size: clamp(30px, 5vw, 42px);
  padding: 4px 0 14px;
  outline: none;
  color: var(--ink);
  border-radius: 0;
}
#searchInput::placeholder { color: #C9C7C0; }

.search-results { list-style: none; margin-top: 10px; }
.search-results li button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding: 20px 0;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  transition: opacity .2s ease;
}
.search-results li button:hover { opacity: .5; }
.sr-main { display: flex; flex-direction: column; gap: 7px; }
.sr-title { font-family: var(--serif); font-size: 21px; }
.sr-author {
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--grey);
}
.sr-price { font-size: 12px; color: #55534E; white-space: nowrap; }
.search-empty { padding: 32px 0; font-size: 12px; letter-spacing: .06em; color: var(--grey); }

/* ---------- flip clone ---------- */

.flip-clone {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  transform-origin: 0 0;
  box-shadow: 0 28px 52px -28px rgba(20, 20, 18, .14);
}
.flip-clone svg { width: 100%; height: 100%; display: block; }

@keyframes fadein { to { opacity: 1; } }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .p-grid {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 0 7vw;
  }
  .p-left { padding: 15vh 0 5vh; }
  .p-cover { width: min(58vw, 300px); }
  .p-right { max-width: none; padding: 3vh 0 9vh; }
  .p-art-img { height: 52vh; }
}

@media (max-width: 720px) {
  :root {
    --cover-h: 52vh;
    --cover-h: 52dvh;
    --shift: 1.5vh;
    --shift: 1.5dvh;
  }
  .site-head { padding: 22px 20px; }
  .head-nav { gap: 24px; }
  .progress { top: 62px; }
  .tick { padding: 9px 4px; }
  .tick span { width: 18px; }
  .meta { top: calc(50% + var(--cover-h) / 2 - var(--shift) + 24px); }
  .m-title { font-size: 20px; }
  .p-back { top: 70px; left: 20px; }
  .p-art figcaption { padding: 14px 20px 0; }
  .p-foot { margin: 0 20px; flex-direction: column; gap: 8px; }
  .search-head { padding: 22px 20px; }
  .search-body { padding: 0 20px; margin-top: 9vh; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
}
