/* =========================================================================
   San Jie 17 Guardians · Continuous 6-Frame Hyperframe Cinema Engine Styles
   Shared across hyperframe.html, guardians/guardian-01..17.html, & index.html
   ========================================================================= */

:root {
  --hf-canvas: #050d0a;
  --hf-surface: rgba(8, 20, 15, 0.86);
  --hf-surface-solid: #0a1812;
  --hf-ink: #f6f2e9;
  --hf-ink-soft: #c5dad0;
  --hf-accent: #8cf0bd;
  --hf-gold: #ffd285;
  --hf-cyan: #79d8e6;
  --hf-border: rgba(140, 240, 189, 0.26);
  --hf-border-gold: rgba(255, 210, 133, 0.44);
  --hf-display: "Cormorant Garamond", "Noto Serif TC", Georgia, serif;
  --hf-text: "Inter", "Microsoft JhengHei", system-ui, sans-serif;
  --hf-mono: "JetBrains Mono", Consolas, monospace;
}

/* Full-Bleed Continuous Scroll Runway */
.hf-runway {
  position: relative;
  width: 100%;
  background: var(--hf-canvas);
}

.hf-sticky {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--hf-canvas);
}

.hf-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Directional Readability Scrims (Keep left beat copy crisp while right 55% Guardian stays luminous) */
.hf-scrim-left {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: linear-gradient(
    96deg,
    rgba(4, 11, 8, 0.84) 0%,
    rgba(4, 11, 8, 0.56) 32%,
    rgba(4, 11, 8, 0.14) 56%,
    rgba(4, 11, 8, 0.04) 76%,
    rgba(4, 11, 8, 0.16) 100%
  );
  transition: opacity 0.4s ease;
}

.hf-scrim-bottom {
  position: absolute;
  inset-x: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 170px;
  pointer-events: none;
  z-index: 4;
  background: linear-gradient(0deg, rgba(4, 11, 8, 0.94) 0%, rgba(4, 11, 8, 0.52) 52%, rgba(4, 11, 8, 0) 100%);
}

.hf-scrim-top {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 110px;
  pointer-events: none;
  z-index: 4;
  background: linear-gradient(180deg, rgba(4, 11, 8, 0.82) 0%, rgba(4, 11, 8, 0) 100%);
}

/* HD Transparent Trainer Standing Heroically on Stage Left */
.hf-trainer-dock {
  position: absolute;
  left: clamp(12px, 3vw, 48px);
  bottom: 124px;
  height: min(56vh, 465px);
  width: min(24vw, 290px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
  z-index: 6;
  transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1), transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  opacity: 0;
  transform: translateX(-28px);
}

.hf-trainer-dock.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.hf-trainer-dock img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.88)) drop-shadow(0 0 18px var(--hf-accent, #8cf0bd));
  animation: hfFloat 5.2s ease-in-out infinite;
}

.hf-trainer-tag {
  margin-top: -10px;
  font-family: var(--hf-mono);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(5, 13, 10, 0.90);
  border: 1px solid var(--hf-border-gold);
  color: var(--hf-gold);
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}

@keyframes hfFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Floating Story Beat Card (Left Safe Zone, shifts cleanly right of Trainer when Trainer ON) */
.hf-beat-wrap {
  position: absolute;
  left: clamp(16px, 4vw, 56px);
  top: 50%;
  transform: translateY(-54%);
  width: min(440px, calc(100vw - 32px));
  z-index: 12;
  transition: left 0.42s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.32s ease, transform 0.32s ease;
}

.hf-beat-wrap.has-trainer {
  left: clamp(210px, 24vw, 340px);
  width: min(400px, calc(100vw - 240px));
}

.hf-beat-card {
  border-radius: 20px;
  padding: clamp(16px, 2.2vw, 24px);
  background: linear-gradient(155deg, rgba(10, 25, 19, 0.86), rgba(5, 13, 10, 0.93));
  border: 1px solid var(--hf-border-gold);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.64), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: var(--hf-ink);
}

.hf-beat-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.hf-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--hf-mono);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(5, 15, 11, 0.88);
  border: 1px solid var(--hf-accent);
  color: var(--hf-accent);
}

.hf-badge--gold {
  border-color: var(--hf-border-gold);
  color: var(--hf-gold);
}

.hf-badge--solid {
  background: var(--hf-gold);
  color: #0b140e;
  border-color: #fff3da;
}

.hf-beat-title {
  margin: 0;
  font-family: var(--hf-display);
  font-size: clamp(1.55rem, 2.8vw, 2.35rem);
  font-weight: 700;
  line-height: 1.08;
  color: #fcf9f2;
}

.hf-beat-sub {
  margin: 6px 0 0;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--hf-accent);
}

.hf-beat-desc {
  margin: 10px 0 0;
  font-size: 0.85rem;
  line-height: 1.56;
  color: #dcebe3;
}

.hf-beat-code {
  margin-top: 10px;
  padding: 8px 11px;
  border-radius: 10px;
  background: rgba(3, 9, 7, 0.90);
  border: 1px solid rgba(140, 240, 189, 0.28);
  font-family: var(--hf-mono);
  font-size: 11px;
  color: #8cf0bd;
  overflow-x: auto;
  white-space: pre-wrap;
}

.hf-beat-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Squad Chips inside Beat Card */
.hf-squad-chips {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hf-sq-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: rgba(8, 22, 16, 0.92);
  border: 1px solid rgba(255, 210, 133, 0.35);
  color: #f4efe4;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.hf-sq-chip:hover {
  border-color: var(--hf-gold);
  transform: translateY(-1px);
}

.hf-sq-chip img {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  object-fit: cover;
  object-position: top;
  background: #06120d;
}

/* Bottom Cinema Control Dock */
.hf-dock-wrap {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.hf-dock {
  pointer-events: auto;
  width: 100%;
  max-width: 980px;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(6, 16, 12, 0.88);
  border: 1px solid rgba(140, 240, 189, 0.28);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hf-dock-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hf-dock-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.hf-btn {
  cursor: pointer;
  border: 1px solid rgba(140, 240, 189, 0.28);
  background: rgba(11, 26, 20, 0.92);
  color: var(--hf-ink-soft);
  border-radius: 999px;
  padding: 5px 11px;
  font-family: var(--hf-text);
  font-size: 11.5px;
  font-weight: 700;
  transition: all 0.16s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hf-btn:hover {
  border-color: var(--hf-gold);
  color: #fcf9f2;
}

.hf-btn.is-active,
.hf-btn[aria-pressed="true"] {
  background: var(--hf-gold);
  color: #0e140e;
  border-color: #fff3da;
}

.hf-btn--accent {
  border-color: var(--hf-accent);
  color: var(--hf-accent);
}

.hf-btn--accent.is-active {
  background: var(--hf-accent);
  color: #06130e;
  border-color: #d1fae5;
}

.hf-scrubber-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hf-scrubber-label {
  font-family: var(--hf-mono);
  font-size: 10.5px;
  font-weight: 800;
  color: var(--hf-accent);
  white-space: nowrap;
}

.hf-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--hf-accent) 0%, var(--hf-gold) 100%);
  outline: none;
  cursor: pointer;
}

.hf-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 999px;
  background: var(--hf-gold);
  border: 2px solid #06120d;
  box-shadow: 0 0 12px rgba(255, 210, 133, 0.9);
  cursor: pointer;
}

.hf-pct {
  font-family: var(--hf-mono);
  font-size: 11.5px;
  font-weight: 800;
  color: var(--hf-gold);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
}

/* Right-Edge Constellation Timeline Spine (for multi-sequence Odyssey) */
.hf-spine {
  position: fixed;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-height: 76vh;
  overflow-y: auto;
  padding: 6px 4px;
  scrollbar-width: none;
}

.hf-spine::-webkit-scrollbar { display: none; }

.hf-spine-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(6, 16, 12, 0.78);
  border: 1px solid rgba(140, 240, 189, 0.22);
  border-radius: 999px;
  padding: 3px 8px;
  cursor: pointer;
  color: #a9c4b7;
  font-family: var(--hf-mono);
  font-size: 10px;
  font-weight: 700;
  transition: all 0.18s ease;
}

.hf-spine-dot:hover {
  border-color: var(--hf-gold);
  color: #fff;
}

.hf-spine-dot.is-active {
  background: var(--hf-gold);
  color: #0b140e;
  border-color: #fff4dc;
  box-shadow: 0 0 14px rgba(255, 210, 133, 0.65);
}

.hf-spine-dot::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

/* Embedded Theater Variant (for index.html Act III · Living Restoration Scroll) */
.hf-theater {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  overflow: hidden;
  border: 1.5px solid var(--hf-border-gold);
  background: #040b08;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.62);
}

.hf-theater canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hf-theater .hf-trainer-dock {
  bottom: 10px;
  height: 74%;
  width: 23%;
  left: 2.5%;
}

.hf-theater-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}

.hf-theater-hud > * { pointer-events: auto; }

.hf-theater-caption {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  z-index: 11;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(95deg, rgba(5, 14, 10, 0.92), rgba(8, 22, 16, 0.84));
  border: 1px solid rgba(255, 210, 133, 0.36);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hf-compare-tags {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 11;
  display: none;
  justify-content: space-between;
  pointer-events: none;
}

.hf-compare-tags.is-visible {
  display: flex;
}

.hf-portal-dim {
  opacity: 0.14 !important;
  transform: translateY(-50%) scale(0.985);
}

.hf-cast-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border-radius: 999px;
  border: 1.5px solid #fff3d6;
  background: linear-gradient(135deg, #ffd285 0%, #8cf0bd 100%);
  color: #09150f;
  font-family: var(--hf-text);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 0 22px rgba(140, 240, 189, 0.42), 0 8px 20px rgba(0, 0, 0, 0.5);
  transition: transform 0.16s ease, filter 0.16s ease;
}

.hf-cast-btn:hover {
  transform: translateY(-1px) scale(1.02);
  filter: brightness(1.06);
}

/* Responsive Adjustments */
@media (max-width: 960px) {
  .hf-trainer-dock {
    height: 36vh;
    width: 30vw;
    left: 6px;
    bottom: 108px;
  }
  .hf-beat-wrap,
  .hf-beat-wrap.has-trainer {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 102px;
    transform: none;
    width: auto;
    max-width: none;
    max-height: 44vh;
    overflow-y: auto;
  }
  .hf-beat-card {
    padding: 11px 13px;
  }
  .hf-beat-desc {
    font-size: 0.77rem;
    line-height: 1.44;
  }
  .hf-beat-code {
    display: none !important;
  }
  .hf-spine {
    display: none;
  }
  .hf-scrim-left {
    background: linear-gradient(0deg, rgba(4, 11, 8, 0.94) 0%, rgba(4, 11, 8, 0.62) 45%, rgba(4, 11, 8, 0.14) 76%, rgba(4, 11, 8, 0.35) 100%);
  }
}

@media (max-width: 640px) {
  .hf-trainer-dock {
    display: none;
  }
  .hf-theater-hud {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 4px;
    align-items: center;
  }
  .hf-theater-hud #th-badge-name {
    display: none;
  }
  .hf-theater-hud .hf-badge {
    font-size: 9px;
    padding: 3px 7px;
  }
  .hf-cast-btn {
    padding: 4px 10px;
    font-size: 10.5px;
    gap: 4px;
  }
  .hf-compare-tags .hf-badge {
    font-size: 8.5px;
    padding: 2px 6px;
  }
  .hf-dock-wrap {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }
  .hf-dock {
    padding: 8px 10px;
    gap: 6px;
  }
  .hf-dock-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .hf-dock-row::-webkit-scrollbar { display: none; }
  .hf-dock-group {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }
  .hf-btn {
    padding: 4px 8px;
    font-size: 10.5px;
    white-space: nowrap;
  }
  .hf-beat-wrap,
  .hf-beat-wrap.has-trainer {
    bottom: 92px;
    max-height: 42vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hf-trainer-dock img {
    animation: none !important;
  }
  .hf-trainer-dock,
  .hf-beat-wrap,
  .hf-scrim-left {
    transition: none !important;
  }
}
