/* Profile Timeline Stages, Decor, Vertical Camera Rail, Finale & Back-to-Top HUD */

#content-profile .timeline-canvas {
  position: relative;
  z-index: 5;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#content-profile .timeline-track {
  display: flex;
  flex-direction: row;
  height: 100%;
  width: max-content;
  transform: translate3d(0, 0, 0);
}

#content-profile.is-scrolling .timeline-track,
#content-profile.is-scrolling .vertical-track,
#content-profile.is-scrolling .global-grid {
  will-change: transform;
}

#content-profile .canvas-section {
  position: relative;
  flex-shrink: 0;
}

/* Stage Sections */
#content-profile .stage-section {
  --stage-accent: var(--ch1-accent);
  --stage-glow: var(--ch1-glow);
  position: relative;
  width: var(--stage-w, 100%);
  height: var(--stage-h, 100%);
  overflow: hidden;
}

#content-profile .stage-section[data-stage-ch="2"] {
  --stage-accent: var(--ch2-accent);
  --stage-glow: var(--ch2-glow);
}

#content-profile .stage-section[data-stage-ch="3"] {
  --stage-accent: var(--ch3-accent);
  --stage-glow: var(--ch3-glow);
}

/* Rising Tide Cascade — Outgoing Stage Recede & Incoming Decor/Titles */
#content-profile .stage-section.is-receding {
  transform-origin: right center;
  opacity: var(--recede-op, 1);
  transform: translate3d(0, var(--recede-y, 0px), 0) scale(var(--recede-scale, 1));
  will-change: transform, opacity;
}

#content-profile .stage-section.is-rising .stage-bg-decor {
  opacity: var(--rise-bg-op, 1);
  transform: translate3d(0, var(--rise-bg-y, 0px), 0) scale(var(--rise-bg-scale, 1));
  transform-origin: center top;
  will-change: transform, opacity;
}

#content-profile .stage-section.is-rising > .stage-title,
#content-profile .stage-section.is-rising-4 > .stage-sub-title {
  opacity: var(--rise-title-op, 1);
  transform: translate3d(0, var(--rise-title-y, 0px), 0) scale(var(--rise-title-scale, 1)) rotate(var(--rise-title-rot, -1.6deg));
  will-change: transform, opacity;
}

#content-profile .journey-finale.is-rising-5 .finale-inner {
  opacity: var(--rise-op, 0);
  transform: translate3d(0, var(--rise-y, 90px), 0) scale(var(--rise-scale, 0.95));
  will-change: transform, opacity;
}

#content-profile .stage-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 4;
}

/* Stage Ambient Motif (Waves, Vinyl Sonar, Ghost Num, Hairline) */
#content-profile .stage-bg-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  user-select: none;
  z-index: 1;
  overflow: hidden;
}

#content-profile .stage-sonic-wave {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: var(--wave-opacity);
}

#content-profile .stage-vinyl-sonar {
  position: absolute;
  left: var(--sonar-x, 50%);
  top: var(--sonar-y, 50%);
  width: calc(var(--sonar-r, 200px) * 2);
  height: calc(var(--sonar-r, 200px) * 2);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px dashed color-mix(in srgb, var(--stage-accent) 42%, transparent);
  box-shadow: inset 0 0 60px color-mix(in srgb, var(--stage-accent) 10%, transparent);
}

#content-profile .stage-vinyl-sonar::before,
#content-profile .stage-vinyl-sonar::after {
  content: '';
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--stage-accent) 22%, transparent);
}

#content-profile .stage-vinyl-sonar::after {
  inset: 34%;
  border-style: dashed;
  border-color: color-mix(in srgb, var(--stage-accent) 30%, transparent);
}

#content-profile .stage-ghost-num {
  position: absolute;
  right: max(24px, 3%);
  bottom: calc(var(--hud-h, 50px) + 12px);
  font-family: var(--tp-font-display);
  font-weight: 900;
  font-style: italic;
  font-size: clamp(6rem, 16cqh, 15rem);
  line-height: 0.85;
  letter-spacing: -0.04em;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--ghost-stroke);
}

/* Keep Stage 03 watermark anchored in Chapter 03 rather than falling to Chapter 05 */
#content-profile #stage3 .stage-ghost-num {
  top: calc(var(--vp-h, 100cqh) * 0.62);
  bottom: auto;
}

#content-profile .stage-hairline {
  position: absolute;
  left: var(--hairline-x, 50%);
  top: 16px;
  bottom: calc(var(--hud-h, 50px) + 14px);
  width: 1px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--tp-hairline-color) 18%,
    color-mix(in srgb, var(--stage-accent) 45%, var(--tp-hairline-color)) 50%,
    var(--tp-hairline-color) 82%,
    transparent 100%
  );
}

/* Neon Chalk Stage Display Titles */
#content-profile .stage-title,
#content-profile .stage-sub-title {
  position: absolute;
  z-index: 6;
  font-family: var(--tp-font-display);
  font-weight: 900;
  font-style: italic;
  line-height: 0.94;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: pre-line;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--label-stroke);
  text-shadow:
    0 0 14px color-mix(in srgb, var(--stage-accent) 75%, transparent),
    0 0 32px var(--stage-glow);
  transform: rotate(-1.6deg);
  pointer-events: none;
  user-select: none;
}

html[data-theme="light"] #content-profile .stage-title,
html[data-theme="light"] #content-profile .stage-sub-title {
  color: #0d223d;
  -webkit-text-stroke: 0;
  text-shadow: 2.5px 3px 0 color-mix(in srgb, var(--stage-accent) 28%, transparent);
}

#content-profile .stage-sub-title {
  --stage-accent: var(--ch4-accent);
  --stage-glow: var(--ch4-glow);
}

/* Vertical Viewport & Camera Rail Track (Stages 03 -> 05) */
#content-profile .vertical-viewport {
  position: relative;
  width: var(--vp-w, 100%);
  height: var(--vp-h, 100%);
  flex-shrink: 0;
  overflow: hidden;
}

#content-profile .vertical-track {
  position: relative;
  transform: translate3d(0, 0, 0);
}

/* Journey Finale Block */
#content-profile .journey-finale {
  position: relative;
  width: 100%;
  min-height: auto;
  padding: 16px 20px calc(var(--hud-h, 50px) + 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  z-index: 6;
}

#content-profile .journey-finale .finale-inner {
  width: 100%;
  max-width: min(calc(var(--vp-w, 100cqw) - 32px), 600px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: clamp(24px, 3.8cqh, 40px) clamp(18px, 3cqw, 36px);
  border-radius: 14px;
  background: color-mix(in srgb, var(--tp-bg-color) 62%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid color-mix(in srgb, var(--ch5-accent) 28%, var(--tp-border-subtle));
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.28), 0 0 36px var(--ch5-glow);
}

html[data-theme="light"] #content-profile .journey-finale .finale-inner {
  background: rgba(251, 253, 255, 0.88);
  border-color: rgba(14, 42, 74, 0.16);
  box-shadow: 0 18px 42px rgba(10, 30, 56, 0.15), 0 0 24px var(--ch5-glow);
}

#content-profile .journey-finale .finale-sign {
  font-family: var(--tp-font-display);
  font-weight: 900;
  font-style: italic;
  font-size: clamp(2.1rem, 6cqw, 4.4rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--tp-text-primary);
  text-shadow: 0 0 26px var(--ch5-glow);
}

#content-profile .journey-finale .finale-sub {
  font-family: var(--tp-font-serif);
  font-style: italic;
  font-size: clamp(0.88rem, 1.8cqw, 1.12rem);
  line-height: 1.5;
  color: var(--tp-text-muted);
  max-width: 44ch;
}

#content-profile .journey-finale .finale-back {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ch5-accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--ch5-accent) 46%, transparent);
  color: var(--tp-text-primary);
  font-family: var(--tp-font-tech);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.22s ease, background-color 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

#content-profile .journey-finale .finale-back:hover {
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--ch5-accent) 26%, transparent);
  box-shadow: 0 0 22px var(--ch5-glow);
}

#content-profile .journey-finale .finale-back:focus-visible {
  outline: 2px solid var(--ch5-accent);
  outline-offset: 3px;
}

/* Minimal Gesture Cue: "Vuốt để sang Tab Video" */
#content-profile .finale-swipe-hint {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--tp-font-tech);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tp-text-muted);
  cursor: pointer;
  transition: color 0.2s ease, transform 0.2s ease;
}

#content-profile .finale-swipe-hint:hover {
  color: #17cb8d;
  transform: translateY(1px);
}

html[data-theme="light"] #content-profile .finale-swipe-hint:hover {
  color: #0b8a5e;
}

#content-profile .finale-swipe-hint:focus-visible {
  outline: 2px solid #17cb8d;
  outline-offset: 3px;
}

#content-profile .finale-swipe-chevron {
  width: 16px;
  height: 16px;
  color: #17cb8d;
  animation: profileFinaleBob 1.75s ease-in-out infinite;
}

html[data-theme="light"] #content-profile .finale-swipe-chevron {
  color: #0b8a5e;
}

@keyframes profileFinaleBob {
  0%, 100% { transform: translateY(-2px); opacity: 0.65; }
  50% { transform: translateY(3px); opacity: 1; }
}

/* Rising Tab Videos Curtain Peek (Phương án C) */
#content-profile .profile-videos-curtain {
  position: absolute;
  left: calc(var(--rail-width, 0px) + 18px);
  right: 18px;
  bottom: 0;
  height: 98px;
  z-index: 46;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(135deg, rgba(14, 52, 46, 0.96), rgba(8, 24, 34, 0.97));
  border: 1px solid rgba(23, 203, 141, 0.56);
  border-bottom: 0;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 -16px 44px rgba(23, 203, 141, 0.24);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding-bottom: var(--sab, 0px);
  transform: translate3d(0, 105%, 0);
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity 0.16s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  will-change: transform, opacity;
}

#content-profile .profile-videos-curtain.is-peeking {
  opacity: 1;
  pointer-events: auto;
}

#content-profile .profile-videos-curtain.is-ready {
  border-color: rgba(74, 242, 186, 0.90);
  box-shadow: 0 -20px 52px rgba(23, 203, 141, 0.42);
}

#content-profile .profile-curtain-handle {
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: rgba(23, 203, 141, 0.78);
  margin-bottom: 2px;
}

#content-profile .profile-curtain-title {
  font-family: var(--tp-font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5ef2be;
  text-shadow: 0 0 14px rgba(23, 203, 141, 0.45);
}

#content-profile .profile-curtain-sub {
  font-family: var(--tp-font-tech);
  font-size: 0.72rem;
  color: rgba(234, 255, 248, 0.78);
}

html[data-theme="light"] #content-profile .profile-videos-curtain {
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.96), rgba(220, 247, 238, 0.97));
  border-color: rgba(15, 157, 108, 0.50);
  box-shadow: 0 -14px 36px rgba(15, 157, 108, 0.20);
}

html[data-theme="light"] #content-profile .profile-curtain-handle {
  background: rgba(15, 157, 108, 0.72);
}

html[data-theme="light"] #content-profile .profile-curtain-title {
  color: #047857;
  text-shadow: none;
}

html[data-theme="light"] #content-profile .profile-curtain-sub {
  color: #1f5c4e;
}

#content-profile[data-vp-mode="phone-portrait"] .profile-videos-curtain,
#content-profile[data-vp-mode="phone-land"] .profile-videos-curtain {
  left: 12px;
  right: 12px;
  height: 92px;
}

@media (prefers-reduced-motion: reduce) {
  #content-profile .finale-swipe-chevron {
    animation: none;
  }
}

#content-profile[data-vp-mode="phone-land"] .journey-finale {
  min-height: 210px;
  padding: 14px 32px calc(var(--hud-h, 34px) + 14px);
  gap: 10px;
}

#content-profile[data-vp-mode="phone-land"] .journey-finale .finale-inner {
  gap: 8px;
  padding: 14px 20px;
}

/* Back-to-Top Corner Button (Merged from hud.css) */
#content-profile .back-to-top-btn {
  position: absolute;
  left: calc(var(--rail-width, 0px) + max(18px, calc(var(--sal) + 14px)));
  bottom: max(10px, calc((var(--hud-h, 50px) - 38px) * 0.5 + var(--sab)));
  z-index: 40;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--hud-pill-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: var(--hud-pill-border);
  box-shadow: var(--hud-pill-shadow);
  color: var(--hud-pill-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px) scale(0.9);
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
    background-color 0.3s ease,
    border-color 0.22s ease,
    color 0.22s ease,
    opacity 0.25s ease,
    visibility 0.25s ease;
}

#content-profile .back-to-top-btn.visible {
  opacity: 0.96;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

#content-profile .back-to-top-btn:hover {
  transform: translateY(-2px);
  border-color: var(--tp-active-accent);
  color: var(--tp-active-accent);
}

#content-profile .back-to-top-btn:active {
  transform: scale(0.92);
}

#content-profile .back-to-top-btn svg {
  width: 16px;
  height: 16px;
}

#content-profile .back-to-top-btn:focus-visible {
  outline: 2px solid var(--tp-active-accent);
  outline-offset: 3px;
}

/* Minimal Chapter Progress Pill */
#content-profile .profile-chapter-rail {
  position: absolute;
  left: calc(50% + var(--rail-width, 0px) * 0.5);
  bottom: max(12px, calc((var(--hud-h, 50px) - 28px) * 0.5 + var(--sab)));
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--hud-pill-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: var(--hud-pill-border);
  box-shadow: var(--hud-pill-shadow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(-50%, 8px, 0) scale(0.94);
  transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

#content-profile .profile-chapter-rail.visible {
  opacity: 0.96;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(-50%, 0, 0) scale(1);
}

#content-profile .profile-chapter-dot {
  appearance: none;
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--hud-pill-text) 34%, transparent);
  cursor: pointer;
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.22s ease, box-shadow 0.22s ease;
}

#content-profile .profile-chapter-dot:hover {
  background: color-mix(in srgb, var(--hud-pill-text) 72%, transparent);
}

#content-profile .profile-chapter-dot.is-active {
  width: 22px;
  background: var(--tp-active-accent);
  box-shadow: 0 0 10px var(--tp-glow-color);
}

#content-profile .profile-chapter-dot:focus-visible {
  outline: 2px solid var(--tp-active-accent);
  outline-offset: 2px;
}

#content-profile[data-vp-mode="phone-portrait"] .profile-chapter-rail {
  left: 50%;
  height: 26px;
  gap: 6px;
  padding: 0 10px;
}

#content-profile[data-vp-mode="phone-land"] .profile-chapter-rail {
  left: 50%;
  height: 24px;
  bottom: max(5px, calc((var(--hud-h, 34px) - 24px) * 0.5 + var(--sab)));
}

#content-profile[data-vp-mode="phone-portrait"] .back-to-top-btn {
  width: 34px;
  height: 34px;
  left: max(12px, var(--sal));
  bottom: max(8px, calc((var(--hud-h, 42px) - 34px) * 0.5 + var(--sab)));
}

#content-profile[data-vp-mode="phone-portrait"] .back-to-top-btn svg {
  width: 15px;
  height: 15px;
}

#content-profile[data-vp-mode="phone-land"] .back-to-top-btn {
  width: 30px;
  height: 30px;
  left: max(20px, calc(var(--sal) + 10px));
  bottom: max(6px, calc((var(--hud-h, 34px) - 30px) * 0.5 + var(--sab)));
}

#content-profile[data-vp-mode="phone-land"] .back-to-top-btn svg {
  width: 14px;
  height: 14px;
}
