/* ── Reset & Variables ── */
*{margin:0;padding:0;box-sizing:border-box}

:root {
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --color-bg: #000000;
  --color-accent: #FE7C56;
  --color-text: #e0d6cc;
}

html { overflow: hidden }

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  cursor: default;
  transition: background 1.2s var(--ease-out-expo);
}

/* ── Canvas ── */
#three-canvas { position: fixed; inset: 0; z-index: 10; cursor: default; transition: opacity .6s var(--ease-out-expo) }
#three-canvas.no-events { pointer-events: none; width: 50%; z-index: 20 }

/* ── Landing Header ── */
.landing-header {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 28px 40px; z-index: 30; pointer-events: none;
  transition: opacity .6s var(--ease-out-expo);
}
.landing-header.hidden { opacity: 0 }

.logo {
  display: flex; align-items: center;
  color: var(--color-accent);
}
.logo-img {
  height: 22px; width: auto;
  opacity: 0.9;
}

.landing-nav { display: flex; gap: 32px; pointer-events: all }
.landing-nav a {
  font-size: 13px; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--color-accent); text-decoration: none;
  opacity: .7; transition: opacity .3s;
}
.landing-nav a:hover { opacity: 1 }

/* ── Marquee ── */
.marquee-top {
  position: fixed; top: 72px; left: 0; right: 0; z-index: 25;
  overflow: hidden; white-space: nowrap;
  font-size: 12px; font-weight: 500;
  letter-spacing: .15em; text-transform: uppercase;
  color: var(--color-accent); opacity: .35;
  padding: 12px 0;
  border-top: 1px solid rgba(254, 124, 86, .15);
  border-bottom: 1px solid rgba(254, 124, 86, .15);
  transition: opacity .6s var(--ease-out-expo);
}
.marquee-top.hidden { opacity: 0 }
.marquee-inner { display: inline-block; animation: marquee 30s linear infinite }

@keyframes marquee {
  0%   { transform: translateX(0) }
  100% { transform: translateX(-50%) }
}

/* ── Side Text ── */
.side-text {
  position: fixed; left: 40px; top: 50%;
  transform: translateY(-50%) rotate(-90deg); transform-origin: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 72px; font-weight: 700; letter-spacing: -.02em;
  color: var(--color-accent); opacity: .12;
  white-space: nowrap; pointer-events: none; z-index: 25;
  transition: opacity .6s var(--ease-out-expo);
}
.side-text.hidden { opacity: 0 }

/* ── Landing Subtitle ── */
.landing-subtitle {
  position: fixed; bottom: 40px; left: 40px; right: 40px;
  display: flex; justify-content: space-between; align-items: flex-end;
  z-index: 25; pointer-events: none;
  transition: opacity .6s var(--ease-out-expo);
}
.landing-subtitle.hidden { opacity: 0 }
.landing-subtitle p {
  font-size: 13px; color: var(--color-accent);
  opacity: .45; max-width: 300px; line-height: 1.6;
}
.landing-subtitle .cta-hint {
  font-size: 12px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--color-accent); opacity: .6;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: .4 }
  50%      { opacity: .8 }
}

/* ── Detail View ── */
#detail-view {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity .6s var(--ease-out-expo);
  z-index: 5; overflow-y: auto; overflow-x: hidden;
  scroll-behavior: auto;
}
#detail-view::-webkit-scrollbar { width: 4px }
#detail-view::-webkit-scrollbar-track { background: transparent }
#detail-view::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px }
#detail-view.active { opacity: 1; pointer-events: all; z-index: 15 }

/* ── Detail Layout ── */
.detail-row { display: flex; width: 100%; min-height: 100vh; position: relative }
.book-panel { width: 50%; min-width: 50%; position: relative; pointer-events: none }
.book-panel-sticky {
  position: sticky; top: 0; height: 100vh; width: 100%;
  display: flex; align-items: center; justify-content: center;
}

.book-3d-wrapper { display: none }
.book-3d {
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .15s ease-out;
  cursor: grab; position: relative;
}
.book-3d:active { cursor: grabbing }

/* ── Book Cover (CSS) ── */
.book-cover-front {
  position: absolute; inset: 0; border-radius: 6px;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 36px; backface-visibility: hidden;
  box-shadow: 12px 12px 40px rgba(0,0,0,.35), 4px 4px 12px rgba(0,0,0,.2);
  overflow: hidden;
}
.book-cover-front .cover-number {
  position: absolute; top: 28px; right: 32px;
  font-family: 'Instrument Serif', serif;
  font-size: 64px; font-weight: 400; opacity: .15;
}
.book-cover-front .cover-decoration {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -60%);
  width: 120px; height: 120px;
  border: 2px solid currentColor; border-radius: 50%; opacity: .12;
}
.book-cover-front .cover-decoration::after {
  content: ''; position: absolute;
  top: 15px; left: 15px; right: 15px; bottom: 15px;
  border: 1px solid currentColor; border-radius: 50%;
}
.book-cover-front .cover-title {
  font-family: 'Instrument Serif', serif;
  font-size: 32px; line-height: 1.15; margin-bottom: 8px;
}
.book-cover-front .cover-author {
  font-size: 12px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; opacity: .6;
}

.book-spine-3d {
  position: absolute; left: -20px; top: 0;
  width: 20px; height: 100%;
  transform: rotateY(-90deg); transform-origin: right center;
  border-radius: 2px 0 0 2px;
}
.book-pages-edge {
  position: absolute; right: -6px; top: 4px;
  width: 6px; height: calc(100% - 8px);
  background: linear-gradient(90deg, #e8e0d4 0%, #f5f0e8 30%, #e8e0d4 60%, #f5f0e8 100%);
  border-radius: 0 2px 2px 0; transform: translateZ(-1px);
}
.book-bottom-edge {
  position: absolute; bottom: -6px; left: 4px;
  width: calc(100% - 8px); height: 6px;
  background: linear-gradient(180deg, #e8e0d4 0%, #f5f0e8 50%, #e8e0d4 100%);
  border-radius: 0 0 2px 2px;
}

/* ── Content Panel ── */
.content-panel { width: 50%; position: relative }
.content-section {
  padding: 100px 60px 140px;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.content-section .section-number {
  font-family: 'Instrument Serif', serif;
  font-size: 14px; opacity: .4; margin-bottom: 40px;
}
.content-section h1 {
  font-family: 'Instrument Serif', serif;
  font-size: 52px; font-weight: 400; line-height: 1.1;
  margin-bottom: 8px; letter-spacing: -.02em;
}
.content-section .subtitle {
  font-family: 'Instrument Serif', serif;
  font-size: 22px; font-style: italic; font-weight: 400;
  line-height: 1.4; opacity: .6; margin-bottom: 16px;
}
.content-section .author {
  font-size: 14px; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase;
  opacity: .5; margin-bottom: 32px;
}
.buy-btn {
  display: inline-flex; align-items: center; gap: 10px;
  width: fit-content;
  padding: 14px 32px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px; font-weight: 600;
  letter-spacing: .04em;
  color: var(--btn-accent, #ffffff);
  border: 1.5px solid var(--btn-accent, #ffffff);
  border-radius: 40px;
  text-decoration: none;
  margin-bottom: 56px;
  transition: all .35s var(--ease-out-expo);
  cursor: pointer;
  backdrop-filter: blur(4px);
  background: rgba(255,255,255,0.04);
}
.buy-btn:hover {
  background: var(--btn-accent, #ffffff);
  color: #0a0a0a;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.buy-btn:active { transform: translateY(0); }
.buy-arrow {
  transition: transform .35s var(--ease-out-expo);
  font-size: 16px;
}
.buy-btn:hover .buy-arrow { transform: translateX(4px); }
.content-section .description {
  font-family: 'Inter', sans-serif;
  font-size: 17px; line-height: 1.8; opacity: .8;
  max-width: 500px; margin-bottom: 32px; font-weight: 300;
}
.content-section .section-heading {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  opacity: .45; margin-top: 48px; margin-bottom: 20px;
}
.content-section .pull-quote {
  font-family: 'Instrument Serif', serif;
  font-size: 28px; font-style: italic; line-height: 1.45;
  max-width: 420px; margin: 48px 0; padding-left: 24px;
  border-left: 2px solid currentColor; opacity: .7;
}
.content-section .body-text {
  font-family: 'Inter', sans-serif;
  font-size: 16px; line-height: 1.85; opacity: .75;
  max-width: 500px; margin-bottom: 28px; font-weight: 300;
}
.content-section .meta-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 24px; margin-top: 48px; max-width: 480px;
}
.meta-item label {
  font-size: 10px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  opacity: .4; display: block; margin-bottom: 6px;
}
.meta-item span {
  font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 400; opacity: .8;
}
.content-section .chapter-list {
  list-style: none; padding: 0; margin: 32px 0; max-width: 480px;
}
.content-section .chapter-list li {
  font-family: 'Inter', sans-serif;
  font-size: 14px; line-height: 1.6; opacity: .6;
  padding: 10px 0; border-bottom: 1px solid currentColor;
  display: flex; justify-content: space-between;
}
.content-section .chapter-list li .ch-num {
  font-family: 'Instrument Serif', serif;
  font-size: 13px; opacity: .5;
}
.scroll-indicator {
  margin-top: 60px; font-size: 11px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  opacity: .3; display: flex; align-items: center; gap: 12px;
}
.scroll-indicator .arrow {
  display: inline-block;
  animation: bobDown 1.5s ease-in-out infinite;
}

@keyframes bobDown {
  0%, 100% { transform: translateY(0) }
  50%      { transform: translateY(4px) }
}

/* ── UI Controls ── */
.back-btn {
  position: fixed; top: 32px; left: 32px; z-index: 30;
  background: rgba(0,0,0,.2); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.1);
  color: #fff; width: 48px; height: 48px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 18px; opacity: 0; pointer-events: none;
  transition: all .5s var(--ease-out-expo);
}
.back-btn.visible { opacity: 1; pointer-events: all }
.back-btn:hover { background: rgba(0,0,0,.4); transform: scale(1.08) }

.progress-bar {
  position: fixed; bottom: 0; left: 0; height: 3px;
  background: rgba(255,255,255,.5); z-index: 30;
  transition: width .3s ease-out; opacity: 0; pointer-events: none;
}
.progress-bar.visible { opacity: 1 }

.book-counter {
  position: fixed; bottom: 32px; right: 32px; z-index: 30;
  font-family: 'Instrument Serif', serif; font-size: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity .5s var(--ease-out-expo);
}
.book-counter.visible { opacity: .4 }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .book-3d-wrapper { width: 200px; height: 300px }
  .content-section { padding: 60px 36px }
  .content-section h1 { font-size: 38px }
}

@media (max-width: 768px) {
  .detail-row { flex-direction: row }
  .book-panel { width: 50%; min-width: 50% }
  .book-panel-sticky { height: 100vh }
  .content-panel { width: 50% }
  .book-3d-wrapper { width: 160px; height: 220px }
  .content-section { padding: 40px 24px }
  .content-section h1 { font-size: 30px }
  .side-text { display: none }
}
