:root {
  --bg: #0c0a08;
  --text: #f3e6cf;
  --text-soft: #cbb89a;
  --gold: #c4a574;
  --gold-dim: rgba(196, 165, 116, 0.35);
  --line-height-base: 2.95rem;
  --story-size-base: 1.55rem;
  --story-scale: 1;
  --story-size: calc(var(--story-size-base) * var(--story-scale));
  --line-height: calc(var(--line-height-base) * var(--story-scale));
  --visible-lines: 6;
  --fade-lines: 2.75;
  --story-width: min(42rem, calc(100vw - 4rem));
  --text-col: 33.333vw;
  --image-col: 66.667vw;
  --controls-height: 5.15rem;
  --ui: "Outfit", system-ui, sans-serif;
  --story: "Cormorant Garamond", "Palatino Linotype", Palatino, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
}

body {
  overflow: hidden;
}

body.age-gate-open .app,
body.age-gate-open .controls,
body.age-gate-open .product-rail,
body.age-gate-open .library {
  filter: blur(10px) saturate(0.85);
  pointer-events: none;
}

body.library-open .app {
  filter: blur(10px) saturate(0.85);
  pointer-events: none;
}

body.library-open .controls {
  opacity: 0;
  pointer-events: none;
}

.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 45% at 50% 48%, rgba(168, 112, 52, 0.16), transparent 70%),
    radial-gradient(ellipse 90% 80% at 50% 100%, rgba(40, 22, 10, 0.7), transparent 55%);
}

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 38%, rgba(0, 0, 0, 0.72) 100%);
}

.grain {
  position: absolute;
  inset: -20%;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  animation: grain-shift 8s steps(4) infinite;
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(-1%, 2%); }
  100% { transform: translate(0, 0); }
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1.75rem 1.5rem calc(var(--controls-height) + 0.8rem);
}

.masthead {
  text-align: left;
  margin-bottom: 0.75rem;
}

.kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 400;
}

.masthead h1 {
  margin: 0;
  font-family: var(--story);
  font-weight: 600;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  letter-spacing: 0.02em;
  color: var(--text);
}

.stage {
  --stage-height: calc(var(--line-height) * (var(--visible-lines) + var(--fade-lines) * 2));
  position: relative;
  flex: 0 0 auto;
  width: var(--story-width);
  max-width: 100%;
  height: var(--stage-height);
  max-height: calc(100dvh - 8.5rem - var(--controls-height));
  margin: 0.5rem 0 0;
  overflow: hidden;
  cursor: pointer;
}

.reading-band {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 118%;
  height: calc(var(--line-height) * var(--visible-lines));
  transform: translate(-50%, -50%);
  background: radial-gradient(
    ellipse 80% 70% at 50% 50%,
    rgba(243, 230, 207, 0.055),
    transparent 72%
  );
  box-shadow:
    inset 0 18px 28px rgba(12, 10, 8, 0.18),
    inset 0 -18px 28px rgba(12, 10, 8, 0.18);
  pointer-events: none;
  z-index: 0;
}

.lines {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.line {
  position: absolute;
  left: 0;
  width: 100%;
  height: var(--line-height);
  margin: 0;
  font-family: var(--story);
  font-size: var(--story-size);
  font-weight: 500;
  line-height: var(--line-height);
  letter-spacing: 0.01em;
  text-align: left;
  will-change: transform, opacity, filter;
}

.line.is-blank {
  visibility: hidden;
}

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12%;
  margin: 0;
  text-align: left;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-soft);
  opacity: 0.7;
  transition: opacity 0.6s ease;
  pointer-events: none;
  z-index: 2;
}

.hint.is-hidden {
  opacity: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  width: 100%;
  margin: 0;
  padding: 0 0.75rem 0.7rem;
  background: linear-gradient(to top, rgba(12, 10, 8, 0.97) 62%, rgba(12, 10, 8, 0.55) 100%);
  backdrop-filter: blur(14px);
}

.timeline {
  width: min(72rem, calc(100% - 0.5rem));
  margin: 0 auto 0.45rem;
  padding: 0.35rem 0.15rem;
}

.timeline input[type="range"] {
  appearance: none;
  display: block;
  width: 100%;
  height: 1.15rem;
  margin: 0;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--gold) var(--progress, 0%),
    rgba(196, 165, 116, 0.22) var(--progress, 0%)
  );
  cursor: pointer;
}

.timeline input[type="range"]:disabled {
  cursor: default;
  opacity: 0.45;
}

.timeline input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: transparent;
}

.timeline input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(196, 165, 116, 0.18);
  cursor: grab;
}

.timeline input[type="range"]:active::-webkit-slider-thumb {
  cursor: grabbing;
  transform: scale(1.12);
}

.timeline input[type="range"]::-moz-range-track {
  height: 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.timeline input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--gold);
}

.timeline input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(196, 165, 116, 0.18);
  cursor: grab;
}

.controls-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  justify-content: center;
  align-items: center;
  width: min(72rem, 100%);
  margin: 0 auto;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.controls-row button,
.controls-row .speed-label,
.controls-row .type-size-label {
  flex-shrink: 0;
}

button,
.file-btn {
  appearance: none;
  border: 1px solid rgba(196, 165, 116, 0.28);
  background: rgba(243, 230, 207, 0.04);
  color: var(--text-soft);
  font-family: var(--ui);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

button:hover,
.file-btn:hover,
button:focus-visible,
.file-btn:focus-visible {
  color: var(--text);
  border-color: rgba(196, 165, 116, 0.7);
  background: rgba(196, 165, 116, 0.12);
  outline: none;
}

button:disabled {
  opacity: 0.35;
  cursor: default;
}

button.primary {
  color: var(--bg);
  background: var(--gold);
  border-color: var(--gold);
  font-weight: 500;
  min-width: 6.5rem;
}

button.primary:hover,
button.primary:focus-visible {
  color: var(--bg);
  background: #d4b98a;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.speed-label,
.type-size-label {
  margin: 0;
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}

#btn-type-smaller,
#btn-type-larger,
#btn-slower,
#btn-faster {
  min-width: 2.45rem;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}

#btn-type-smaller {
  font-size: 0.68rem;
}

#btn-type-larger {
  font-size: 0.92rem;
}

.measure {
  position: absolute;
  left: -9999px;
  top: 0;
  font-family: var(--story);
  font-size: var(--story-size);
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  visibility: hidden;
}

.product-rail {
  position: fixed;
  top: 0;
  right: 0;
  bottom: var(--controls-height);
  z-index: 6;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: var(--image-col);
  padding: 0.55rem 0.55rem 0.7rem 0.35rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: y mandatory;
  scroll-padding-block: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(1.2rem);
  transition:
    opacity 0.5s ease,
    transform 0.75s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.5s;
}

.product-rail.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition:
    opacity 0.5s ease,
    transform 0.75s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s;
}

.product-rail::-webkit-scrollbar {
  width: 6px;
}

.product-rail::-webkit-scrollbar-thumb {
  background: rgba(196, 165, 116, 0.4);
  border-radius: 999px;
}

body.library-open .product-rail {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.product-list {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.7rem;
  min-height: 100%;
}

.product-card {
  scroll-snap-align: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 0.7rem;
  border: 1px solid rgba(196, 165, 116, 0.22);
  background: #120e0b;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(196, 165, 116, 0.08);
  opacity: 0;
  transform: translateY(2.4rem);
  transition:
    opacity 0.55s ease,
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.product-card.is-in {
  opacity: 1;
  transform: translateY(0);
}

.product-figure {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #16110d;
}

.product-card.is-image .product-figure {
  height: calc(100dvh - var(--controls-height) - 1.4rem);
}

.product-card.is-buyable .product-figure {
  height: min(52vh, 28rem);
}

.product-figure img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  transform-origin: center center;
  will-change: transform;
}

.product-card.is-in .product-figure img {
  animation: kenburns-a 28s ease-in-out infinite alternate;
}

.product-card.is-in:nth-child(2n) .product-figure img {
  animation-name: kenburns-b;
}

.product-card.is-in:nth-child(3n) .product-figure img {
  animation-name: kenburns-c;
}

@keyframes kenburns-a {
  from {
    transform: scale(0.94);
  }
  to {
    transform: scale(1);
  }
}

@keyframes kenburns-b {
  from {
    transform: scale(0.93);
  }
  to {
    transform: scale(1);
  }
}

@keyframes kenburns-c {
  from {
    transform: scale(0.95);
  }
  to {
    transform: scale(1);
  }
}

.product-figure.is-missing {
  display: none;
}

.product-price {
  margin: 0.75rem 1rem 0;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-align: center;
}

.product-buy {
  display: block;
  margin: 0.85rem 1rem 1rem;
  padding: 0.72rem 1rem;
  border-radius: 999px;
  background: var(--gold);
  color: var(--bg);
  text-align: center;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: background 0.2s ease, transform 0.2s ease;
}

.product-buy:hover,
.product-buy:focus-visible {
  background: #d4b98a;
  outline: none;
}

@media (min-width: 980px) {
  body.has-product .app {
    width: var(--text-col);
    max-width: var(--text-col);
    padding-left: 1.1rem;
    padding-right: 0.55rem;
    transform: none;
  }

  body.has-product .stage {
    width: 100%;
    max-width: 100%;
  }

  body.has-product .masthead h1 {
    font-size: clamp(1.15rem, 2.2vw, 1.7rem);
  }
}

@media (max-width: 640px) {
  :root {
    --story-size-base: 1.35rem;
    --line-height-base: 2.55rem;
  }

  .app {
    padding: 1.1rem 0.9rem calc(var(--controls-height) + 0.6rem);
  }

  .controls-row {
    gap: 0.4rem;
  }

  button,
  .file-btn {
    font-size: 0.68rem;
    padding: 0.48rem 0.7rem;
  }
}

@media (max-width: 979px) {
  .product-rail {
    top: auto;
    bottom: calc(var(--controls-height) + 0.35rem);
    height: 58vh;
    width: min(var(--image-col), calc(100vw - 0.8rem));
    right: 0.35rem;
    padding: 0.35rem;
    border-radius: 0.85rem;
    background: linear-gradient(to left, rgba(12, 10, 8, 0.55), transparent 90%);
  }

  .product-card.is-image .product-figure {
    height: calc(58vh - 0.7rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .grain,
  .product-card.is-in .product-figure img {
    animation: none;
  }
}

.age-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(8, 6, 5, 0.72);
}

.age-gate[hidden] {
  display: none;
}

.age-gate-card {
  width: min(28rem, 100%);
  padding: 2rem 1.8rem 1.7rem;
  border: 1px solid rgba(196, 165, 116, 0.28);
  border-radius: 1.2rem;
  background:
    linear-gradient(180deg, rgba(243, 230, 207, 0.06), rgba(12, 10, 8, 0.35)),
    rgba(22, 17, 13, 0.96);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.age-gate-card h2 {
  margin: 0 0 0.7rem;
  font-family: var(--story);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 600;
}

.age-gate-card p {
  margin: 0 0 1.4rem;
  color: var(--text-soft);
  line-height: 1.5;
}

.age-gate-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.age-gate-actions button {
  width: 100%;
}

.library {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: rgba(8, 6, 5, 0.42);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.45s ease,
    visibility 0.45s;
}

.library.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.library-panel {
  width: min(74rem, 100%);
  max-height: calc(100dvh - 2.5rem);
  overflow: auto;
  padding: 0.5rem 0.25rem 1rem;
}

.library-head {
  text-align: center;
  margin-bottom: 2rem;
}

.library-head h2 {
  margin: 0;
  font-family: var(--story);
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.library-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
}

.story-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex: 1 1 22rem;
  width: min(100%, 28rem);
  max-width: 28rem;
  min-height: 20rem;
  padding: 0;
  border: 1px solid rgba(196, 165, 116, 0.28);
  border-radius: 1.4rem;
  overflow: hidden;
  background: #14100c;
  color: var(--text);
  text-align: left;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.35s ease;
}

.story-tile:hover {
  transform: translateY(-6px);
  border-color: rgba(196, 165, 116, 0.8);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.45);
}

.story-tile.is-current {
  border-color: var(--gold);
  box-shadow:
    0 26px 60px rgba(0, 0, 0, 0.45),
    0 0 0 1px var(--gold);
}

.story-tile-cover {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(196, 165, 116, 0.22), transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(80, 42, 18, 0.45), transparent 50%),
    #1a1510;
  background-size: cover;
  background-position: center;
  transform: scale(1.04);
  transition: transform 0.7s ease;
}

.story-tile:hover .story-tile-cover {
  transform: scale(1.1);
}

.story-tile-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-height: 16rem;
  padding: 1.7rem 1.55rem 1.1rem;
  background: linear-gradient(
    to top,
    rgba(12, 10, 8, 0.94) 0%,
    rgba(12, 10, 8, 0.55) 42%,
    rgba(12, 10, 8, 0.08) 100%
  );
}

.story-tile-kicker {
  margin-bottom: 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
}

.story-tile-title {
  font-family: var(--story);
  font-size: clamp(1.7rem, 2.6vw, 2.35rem);
  font-weight: 600;
  line-height: 1.15;
}

.story-tile-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 0.7rem;
  font-family: var(--story);
  font-size: 1.05rem;
  line-height: 1.4;
  color: var(--text-soft);
}

.story-tile-actions {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0 1.2rem 1.15rem;
}

.story-tile-actions button {
  flex: 1 1 auto;
}

.library-status {
  margin: 1.5rem 0 0;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-soft);
}

.library-status:empty {
  display: none;
}

.library-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: center;
  margin-top: 2rem;
}
