/* TBI Immersive Home R18 */

.tbi-home *, .tbi-home-shell *, :is(.tbi-home *, .tbi-home-shell *) ::before, :is(.tbi-home *, .tbi-home-shell *) ::after {
  box-sizing: border-box;
}

:root {
  --c-ivory: #f7f2ea;
  --c-ink: #1c2d2b;
  --c-sage: #adc5b6;
  --c-coral: #c96f5b;
  --c-white: #fff;
  --c-mist: #e8e0d4;
  --sp-xs: .5rem;
  --sp-sm: 1rem;
  --sp-md: 1.5rem;
  --sp-lg: 2.5rem;
  --sp-xl: 4rem;
  --mw: 64ch;
  --tbi-p: 0;
  --tbi-shift: 0px;
  --tbi-scale: 1;
  --tbi-fade: 1;
  --tbi-tint: 0;
  --tbi-depth-x: 0px;
  --tbi-depth-y: 0px;
}

@media (prefers-reduced-motion: reduce) {
  .tbi-home *, .tbi-home-shell * {
    animation: none !important;
    transition-duration: 0s !important;
  }
}

body.tbi-home {
  margin: 0;
  padding: 0;
  line-height: 1.6;
  overflow-x: clip;
  background: var(--c-ivory);
  color: var(--c-ink);
}

.tbi-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;
}

.tbi-skip {
  position: absolute;
  left: var(--sp-md);
  bottom: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--c-ink);
  color: var(--c-white);
  text-decoration: none;
  font-weight: 700;
  z-index: 999;
  clip: rect(1px, 1px, 1px, 1px);
}

.tbi-skip:focus {
  clip: auto;
}

.tbi-home-shell {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

.tbi-hero {
  padding: var(--sp-lg) var(--sp-md);
  text-align: center;
}

.tbi-nav ul, .tbi-footer-nav ul, .tbi-nav-links ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs) var(--sp-sm);
  justify-content: center;
}

.tbi-nav a, .tbi-footer-nav a, .tbi-nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  padding: .5rem .75rem;
  color: var(--c-ink);
  text-decoration: underline;
  border-radius: 4px;
}

.tbi-nav a:focus-visible, .tbi-footer-nav a:focus-visible, .tbi-nav-links a:focus-visible {
  outline: 3px solid var(--c-coral);
  outline-offset: 2px;
}

.tbi-brand {
  margin: var(--sp-sm) 0 0;
  font-size: .875rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--c-sage);
}

.tbi-hero h1 {
  margin-top: var(--sp-md);
  font-size: clamp(1.8rem, 4.5vw + .5rem, 3rem);
  line-height: 1.2;
  font-weight: 800;
}

.tbi-hero > p, .tbi-beat p, .tbi-chapter p {
  max-width: var(--mw);
  margin-inline: auto;
}

.tbi-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  justify-content: center;
  margin-top: var(--sp-md);
}

.tbi-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: .625rem var(--sp-md);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--c-white);
  background: var(--c-coral);
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.tbi-btn:hover, .tbi-btn:focus-visible {
  background: var(--c-ink);
  color: var(--c-white);
  outline: 3px solid var(--c-ink);
  outline-offset: 3px;
}

.tbi-btn--stage {
  margin-top: var(--sp-sm);
  font-size: .9rem;
}

/* Story rail */
.tbi-story {
  position: relative;
}

.tbi-story-rail {
  position: relative;
}

.tbi-story-progress {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: var(--sp-sm) var(--sp-md);
  background: rgba(247, 242, 234, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--c-mist);
}

.tbi-story-progress__label {
  margin: 0 0 .35rem;
  font-size: .9rem;
  font-weight: 600;
}

.tbi-story-progress__track {
  height: 6px;
  background: var(--c-mist);
  border-radius: 999px;
  overflow: hidden;
}

.tbi-story-progress__fill {
  display: block;
  height: 100%;
  width: calc(var(--tbi-p) * 100%);
  background: linear-gradient(90deg, var(--c-sage), var(--c-coral));
  border-radius: inherit;
  transform-origin: left center;
}

.tbi-story-progress__steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .25rem;
  margin: .5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: .72rem;
  line-height: 1.3;
}

.tbi-story-progress__steps li {
  text-align: center;
  opacity: .55;
}

.tbi-story-progress__steps li.is-current {
  opacity: 1;
  font-weight: 700;
  color: var(--c-coral);
}

.tbi-story-stage {
  --stage-h: 42svh;
  position: sticky;
  top: 4.5rem;
  z-index: 10;
  height: var(--stage-h);
  margin: 0 var(--sp-md);
  border-radius: 20px;
  overflow: hidden;
  background: #d4ccc0;
  box-shadow: 0 16px 40px rgba(28, 45, 43, .14);
  transform: translateY(calc(var(--tbi-shift) * .5)) scale(var(--tbi-scale));
  opacity: var(--tbi-fade);
}

.tbi-story-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(28, 45, 43, calc(var(--tbi-tint) * .35)), transparent 55%);
  pointer-events: none;
}

.tbi-story-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translate3d(var(--tbi-depth-x), var(--tbi-depth-y), 0) scale(1.04);
  transition: opacity 120ms linear;
}

.tbi-story-layer.is-visible {
  opacity: 1;
}

.tbi-story-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tbi-choice-panel {
  position: absolute;
  left: var(--sp-sm);
  right: var(--sp-sm);
  bottom: var(--sp-sm);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .35rem;
  z-index: 3;
}

.tbi-choice-btn {
  min-height: 44px;
  padding: .4rem .25rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--c-ink);
  background: rgba(255, 255, 255, .88);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.tbi-choice-btn[aria-pressed="true"] {
  border-color: var(--c-coral);
  background: var(--c-white);
  color: var(--c-coral);
}

.tbi-choice-btn:focus-visible {
  outline: 3px solid var(--c-coral);
  outline-offset: 2px;
}

.tbi-stage-note {
  position: absolute;
  top: var(--sp-sm);
  left: var(--sp-sm);
  right: var(--sp-sm);
  padding: var(--sp-sm);
  background: rgba(255, 255, 255, .9);
  border-radius: 12px;
  z-index: 3;
  font-size: .85rem;
}

.tbi-stage-note p {
  margin: 0;
  max-width: none;
}

.tbi-story-scroll {
  position: relative;
  z-index: 5;
  padding: 0 var(--sp-md) var(--sp-lg);
}

.tbi-chapter {
  min-height: 72svh;
  padding: var(--sp-lg) 0;
  max-width: 38rem;
}

.tbi-chapter h3 {
  margin: 0 0 .75rem;
  font-size: clamp(1.3rem, 2.5vw + .4rem, 1.9rem);
}

.tbi-chapter-picture {
  display: none;
}

.tbi-details {
  margin-top: var(--sp-md);
  padding: var(--sp-sm);
  background: rgba(255, 255, 255, .7);
  border: 1px solid var(--c-mist);
  border-radius: 10px;
  text-align: left;
}

.tbi-details summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.tbi-details summary:focus-visible {
  outline: 3px solid var(--c-coral);
  outline-offset: 2px;
}

.tbi-beat {
  padding: var(--sp-xl) var(--sp-md);
  text-align: center;
}

.tbi-beat:nth-child(even) {
  background: #f0ebe3;
}

.tbi-beat h2 {
  font-size: clamp(1.4rem, 3vw + .5rem, 2.2rem);
}

.tbi-sources {
  max-width: var(--mw);
  margin: 1.5rem auto 0;
  font-size: .875rem;
  color: #5a6e6a;
}

.tbi-footer {
  padding: var(--sp-lg) var(--sp-md);
  text-align: center;
  font-size: .875rem;
  color: #5a6e6a;
  border-top: 1px solid #ddd8d0;
}

/* Choice tint overlays */
.tbi-home-shell[data-tbi-choice="clean"] .tbi-story-stage::after {
  background: linear-gradient(180deg, rgba(173, 197, 182, calc(.2 + var(--tbi-tint) * .3)), transparent 60%);
}

.tbi-home-shell[data-tbi-choice="inter"] .tbi-story-stage::after {
  background: linear-gradient(180deg, rgba(96, 130, 150, calc(.2 + var(--tbi-tint) * .3)), transparent 60%);
}

.tbi-home-shell[data-tbi-choice="enamel"] .tbi-story-stage::after {
  background: linear-gradient(180deg, rgba(201, 111, 91, calc(.15 + var(--tbi-tint) * .35)), transparent 60%);
}

.tbi-home-shell[data-tbi-choice="tools"] .tbi-story-stage::after {
  background: linear-gradient(180deg, rgba(92, 78, 66, calc(.2 + var(--tbi-tint) * .3)), transparent 60%);
}

/* Desktop immersive */
@media (min-width: 960px) {
  .tbi-story-rail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 44%);
    gap: var(--sp-lg);
    max-width: 1320px;
    margin-inline: auto;
    padding-inline: var(--sp-lg);
  }

  .tbi-story-progress {
    grid-column: 1 / -1;
  }

  .tbi-story-stage {
    --stage-h: min(78svh, 720px);
    top: 5.5rem;
    margin: 0;
    grid-column: 2;
    grid-row: 2 / span 4;
    align-self: start;
  }

  .tbi-story-scroll {
    grid-column: 1;
    grid-row: 2;
    padding: 0 0 var(--sp-xl);
  }

  .tbi-chapter {
    min-height: 88svh;
    padding-right: var(--sp-md);
  }

  .tbi-chapter-picture {
    display: none;
  }
}

@media (max-width: 959px) {
  .tbi-story-stage {
    margin-bottom: var(--sp-md);
  }

  .tbi-chapter-picture {
    display: block;
    margin-top: var(--sp-md);
  }

  .tbi-chapter-picture img {
    width: 100%;
    border-radius: 12px;
    aspect-ratio: 900 / 1124;
    object-fit: cover;
  }

  .tbi-chapter {
    min-height: auto;
  }

  .tbi-choice-panel {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .tbi-hero {
    padding-inline: var(--sp-lg);
  }
}

@media (max-width: 767px) {
  .tbi-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .tbi-btn {
    width: 100%;
  }

  .tbi-story-progress__steps {
    font-size: .65rem;
  }
}

/* Static / reduced motion */
.tbi-story-static .tbi-story-layer {
  opacity: 0;
  transform: none;
}

.tbi-story-static .tbi-story-layer.is-visible {
  opacity: 1;
}

.tbi-story-static .tbi-story-stage {
  transform: none;
  opacity: 1;
}

@media print {
  .tbi-story-stage, .tbi-choice-panel, .tbi-stage-note {
    display: none;
  }

  .tbi-chapter-picture {
    display: block;
  }
}
