:root {
  --text: #f8efde;
  --muted: rgba(248, 239, 222, 0.76);
  --line: rgba(255, 242, 214, 0.16);
  --paper: #f2e5c9;
  --paper-edge: #d8c29a;
  --ink: #38271a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  overflow: hidden;
  color: var(--text);
  font-family: "Manrope", system-ui, sans-serif;
  background: #120d09;
}

body.is-loading {
  overflow: hidden;
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  gap: 1rem;
  background: linear-gradient(180deg, rgba(14, 10, 8, 0.96), rgba(20, 14, 10, 0.98));
  transition: opacity 400ms ease, visibility 400ms ease;
}

.loader.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.loader-book {
  position: relative;
  width: 180px;
  height: 120px;
  transform-style: preserve-3d;
  perspective: 1200px;
}

.loader-cover,
.loader-pages {
  position: absolute;
  inset: 0;
  border-radius: 14px;
}

.loader-cover-left,
.loader-cover-right {
  background: linear-gradient(135deg, #6d4628, #b88233);
}

.loader-cover-left {
  transform-origin: left center;
  animation: coverOpen 1.7s ease-in-out infinite;
}

.loader-cover-right {
  transform-origin: right center;
  animation: coverOpenRight 1.7s ease-in-out infinite;
}

.loader-pages {
  inset: 10px 14px;
  background: linear-gradient(180deg, #fffaf1, #efe3cb);
}

.loader-text,
.book-kicker,
.book-title {
  font-family: "Cormorant Garamond", Georgia, serif;
}

.loader-text {
  margin: 0;
  font-size: 1.6rem;
}

.global-library-scene {
  position: fixed;
  inset: 0;
  z-index: -2;
}

.react-three-library,
.react-three-library canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.global-scene-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 26%, rgba(8, 6, 5, 0.26) 70%, rgba(7, 5, 4, 0.74) 100%),
    linear-gradient(180deg, rgba(8, 6, 5, 0.34), rgba(8, 6, 5, 0.02) 25%, rgba(8, 6, 5, 0.5) 100%);
}

.ui-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.top-contact,
.top-actions,
.resume-button,
.sound-toggle,
.book-viewer {
  pointer-events: auto;
}

.top-contact {
  position: absolute;
  top: 1.3rem;
  left: 50%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  max-width: min(720px, calc(100% - 2rem));
  transform: translateX(-50%);
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 14, 22, 0.62);
  color: var(--text);
  backdrop-filter: blur(14px);
}

.top-contact a,
.resume-button {
  color: var(--text);
  text-decoration: none;
}

.top-contact a {
  border-radius: 8px;
  padding: 0.38rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 800;
}

.top-contact a:hover,
.resume-button:hover,
.sound-toggle:hover {
  background: rgba(255, 250, 240, 0.16);
}

.top-actions {
  position: absolute;
  top: 1.3rem;
  right: 1.3rem;
  display: flex;
  gap: 0.6rem;
}

.resume-button,
.sound-toggle {
  min-width: 5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.1);
  color: var(--text);
  padding: 0.8rem 1rem;
  font: 600 0.9rem "Manrope", system-ui, sans-serif;
  text-align: center;
  backdrop-filter: blur(14px);
}

.sound-toggle {
  cursor: pointer;
}

.sound-toggle.is-active {
  background: rgba(188, 136, 55, 0.34);
}

.book-viewer {
  position: absolute;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  width: min(1120px, calc(100% - 4rem));
  perspective: 1400px;
}

.book-viewer.is-opening .book-shell {
  animation: recordOpen 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.book-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(190px, 0.45fr) minmax(420px, 1.55fr);
  min-height: 0;
  max-height: min(78vh, 640px);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 18%, rgba(184, 130, 62, 0.18), transparent 32%),
    linear-gradient(180deg, rgba(15, 19, 28, 0.98), rgba(8, 12, 19, 0.98));
  border: 1px solid rgba(150, 166, 186, 0.18);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.62);
  overflow: hidden;
  backdrop-filter: blur(20px);
}

.book-shell::before {
  content: "";
  position: absolute;
  inset: 1rem;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03), transparent 22%, transparent 78%, rgba(255, 255, 255, 0.03)),
    linear-gradient(180deg, rgba(22, 28, 40, 0.88), rgba(13, 18, 29, 0.9));
  box-shadow: inset 0 0 0 1px rgba(150, 166, 186, 0.12);
}

.book-shell::after {
  content: "";
  position: absolute;
  left: 1rem;
  right: 1rem;
  top: 3.4rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(184, 130, 62, 0.72), transparent);
}

.book-page {
  position: relative;
  z-index: 1;
  padding: 1.45rem 1.55rem;
  color: #e9eef6;
}

.book-page-left {
  border-right: 1px solid rgba(150, 166, 186, 0.12);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.book-kicker {
  margin: 0;
  color: #9ca9bb;
  text-transform: uppercase;
  letter-spacing: 0;
  font: 800 0.68rem "Manrope", system-ui, sans-serif;
}

.book-title {
  margin: 0.55rem 0 0;
  color: #f4f7fb;
  font-family: "Manrope", system-ui, sans-serif;
  font-size: clamp(1.7rem, 2.6rem, 2.6rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.08;
}

.panel-body {
  display: grid;
  gap: 0.75rem;
  max-height: calc(min(78vh, 640px) - 3rem);
  overflow: auto;
  padding-right: 0.4rem;
}

.panel-body p {
  margin: 0;
  color: #aab5c4;
  font-size: 0.88rem;
  line-height: 1.58;
}

.panel-lead {
  color: #f0f4fb !important;
  font-size: 1rem !important;
  font-weight: 700;
  line-height: 1.35 !important;
}

.panel-copy {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.record-sections {
  display: grid;
  gap: 1rem;
}

.record-section {
  display: grid;
  gap: 1rem;
  border: 1px solid rgba(150, 166, 186, 0.14);
  border-radius: 8px;
  background: rgba(8, 12, 19, 0.42);
  padding: 1rem;
}

.record-section-head {
  display: grid;
  grid-template-columns: minmax(220px, 0.78fr) minmax(260px, 1fr);
  gap: 0.7rem 1.3rem;
  align-items: start;
}

.record-section-head span {
  grid-column: 1 / -1;
  color: #a7b2c2;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.record-section-head strong {
  color: #f4f7fb;
  font-size: clamp(1.55rem, 2vw, 2.35rem);
  line-height: 1.2;
}

.record-section-head p {
  color: #aab5c4;
  font-size: 1.05rem;
  line-height: 1.72;
}

.record-card {
  min-height: 0;
  border: 1px solid rgba(150, 166, 186, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(31, 38, 52, 0.78), rgba(19, 24, 35, 0.88));
  padding: 0.82rem;
}

.record-card span {
  display: block;
  margin-bottom: 0.45rem;
  color: #a7b2c2;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.record-card strong {
  display: block;
  margin-bottom: 0.5rem;
  color: #eef3fa;
  font-size: 1rem;
  line-height: 1.3;
}

.record-card p {
  color: #a8b3c1;
  font-size: 0.84rem;
  line-height: 1.5;
}

.record-card a {
  display: inline-flex;
  margin-top: 0.7rem;
  border: 1px solid rgba(184, 130, 62, 0.34);
  border-radius: 8px;
  padding: 0.5rem 0.62rem;
  color: #f0d299;
  font-size: 0.72rem;
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
}

.project-preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  margin-bottom: 0.65rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  padding: 0.4rem;
}

.chip-group {
  display: none;
}

.chip-group span {
  padding: 0.55rem 0.82rem;
  border-radius: 8px;
  border: 1px solid rgba(184, 130, 62, 0.24);
  background: rgba(184, 130, 62, 0.12);
  color: #e8c98d;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.book-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  z-index: 2;
  min-width: 4.2rem;
  height: 2rem;
  border: 1px solid rgba(150, 166, 186, 0.2);
  border-radius: 8px;
  background: rgba(31, 38, 52, 0.86);
  color: #f4f7fb;
  font: 800 0.76rem "Manrope", system-ui, sans-serif;
  cursor: pointer;
}

.book-close:hover {
  background: rgba(184, 130, 62, 0.34);
}

@keyframes coverOpen {
  0%, 100% { transform: perspective(1200px) rotateY(0deg); }
  50% { transform: perspective(1200px) rotateY(-58deg); }
}

@keyframes coverOpenRight {
  0%, 100% { transform: perspective(1200px) rotateY(0deg); }
  50% { transform: perspective(1200px) rotateY(58deg); }
}

@keyframes recordOpen {
  0% {
    opacity: 0;
    transform: rotateX(10deg) scale(0.92) translateY(32px);
  }

  100% {
    opacity: 1;
    transform: rotateX(0deg) scale(1) translateY(0);
  }
}

@media (max-width: 860px) {
  .top-contact {
    top: 0.7rem;
    left: 0.5rem;
    right: 0.5rem;
    max-width: none;
    transform: none;
    padding: 0.4rem;
    gap: 0.3rem;
  }

  .top-contact a {
    padding: 0.3rem 0.4rem;
    font-size: 0.75rem;
  }

  .top-actions {
    top: auto;
    right: 0.5rem;
    bottom: 0.5rem;
    z-index: 4;
    gap: 0.4rem;
  }

  .resume-button,
  .sound-toggle {
    min-width: 4rem;
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
  }

  .book-viewer {
    width: min(100% - 1rem, 960px);
    bottom: 4rem;
  }

  .book-shell {
    grid-template-columns: 1fr;
    min-height: 0;
    max-height: 85vh;
  }

  .book-shell::after {
    display: none;
  }

  .book-page {
    padding: 1rem;
  }

  .book-page-left {
    border-right: 0;
    border-bottom: 1px solid rgba(113, 86, 47, 0.12);
    padding-bottom: 0.8rem;
  }

  .book-page-right {
    padding-top: 0.8rem;
  }

  .book-title {
    font-size: 1.5rem;
  }

  .panel-body {
    max-height: 50vh;
  }

  .panel-copy,
  .record-grid,
  .record-section-head {
    grid-template-columns: 1fr;
  }

  .record-card {
    min-height: 0;
  }

  .record-section-head strong {
    font-size: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
