/*
 * Live Covenant Visual System v1 — Story entry bridge
 * Presentation only. Story start/hydration/action semantics stay in story-layer-v1.js.
 */

/* Story overlay frame: remove the legacy purple shell without changing runtime. */
#storyLayerV1Overlay {
  background:
    radial-gradient(circle at 74% 16%, rgba(116, 31, 49, 0.12), transparent 30%),
    rgba(7, 5, 7, 0.91);
  backdrop-filter: blur(16px) saturate(106%);
}

#storyLayerV1Overlay .story-v1-shell {
  width: min(100%, 780px);
  border: 1px solid var(--lc-border-subtle);
  border-radius: 28px;
  color: var(--lc-text-primary);
  background:
    linear-gradient(180deg, rgba(245, 239, 231, 0.028), transparent 24%),
    linear-gradient(155deg, rgba(25, 18, 22, 0.98), rgba(10, 8, 10, 0.995));
  box-shadow: var(--lc-shadow-deep);
  font-family: var(--lc-font-ui);
}

#storyLayerV1Overlay .story-v1-kicker {
  color: var(--lc-accent-decorative);
  font-family: var(--lc-font-decorative);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
}

#storyLayerV1Overlay .story-v1-title {
  margin-top: 5px;
  color: var(--lc-text-primary);
  font-family: var(--lc-font-narrative);
  font-size: clamp(1.55rem, 5vw, 2.15rem);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

#storyLayerV1Overlay .story-v1-subtitle {
  margin-top: 6px;
  color: var(--lc-text-muted);
  font: 400 0.78rem/1.55 var(--lc-font-ui);
}

#storyLayerV1Overlay [data-story-close] {
  min-width: 42px;
  min-height: 42px;
  border: 1px solid var(--lc-border-subtle);
  border-radius: var(--lc-radius-pill-token);
  color: var(--lc-text-secondary);
  background: rgba(245, 239, 231, 0.035);
}

/*
 * The unstarted Story screen is the doorway into C0. Treat its prose as a
 * physical briefing sheet, not another purple dashboard card.
 * :has() scopes this treatment to the start/wait doorway; active Story beats
 * retain their existing layout until explicitly redesigned later.
 */
#storyLayerV1Overlay .story-v1-shell:not(:has(.story-v1-objective)) .story-v1-body {
  position: relative;
  margin-top: 22px;
  padding: clamp(22px, 4vw, 34px);
  overflow: hidden;
  border: 1px solid rgba(86, 61, 43, 0.26);
  border-radius: var(--lc-radius-artifact);
  color: var(--lc-text-on-artifact);
  background:
    radial-gradient(circle at 14% 10%, rgba(255, 255, 255, 0.28), transparent 25%),
    linear-gradient(140deg, #eee2cd 0%, #e4d4bb 52%, #ccb799 100%);
  box-shadow: var(--lc-shadow-soft-lift), var(--lc-glow-artifact);
  transform: rotate(-0.18deg);
}

#storyLayerV1Overlay .story-v1-shell:not(:has(.story-v1-objective)) .story-v1-body::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background:
    repeating-linear-gradient(3deg, rgba(76, 52, 35, 0.08) 0 1px, transparent 1px 6px),
    linear-gradient(90deg, transparent 0 78%, rgba(95, 62, 39, 0.08) 80%, transparent 84%);
  mix-blend-mode: multiply;
}

#storyLayerV1Overlay .story-v1-shell:not(:has(.story-v1-objective)) .story-v1-prose {
  position: relative;
  z-index: 1;
  color: rgba(37, 25, 28, 0.86);
  font-family: var(--lc-font-narrative);
  font-size: clamp(0.93rem, 1.8vw, 1.02rem);
  line-height: 1.82;
}

#storyLayerV1Overlay .story-v1-actions {
  gap: 10px;
  margin-top: 20px;
}

#storyLayerV1Overlay .story-v1-primary {
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid rgba(194, 148, 95, 0.42);
  border-radius: var(--lc-radius-control);
  color: var(--lc-text-primary);
  background: linear-gradient(180deg, #81283c 0%, var(--lc-accent-strong) 100%);
  box-shadow: var(--lc-shadow-soft-lift), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  font: 600 0.92rem/1.35 var(--lc-font-ui);
}

#storyLayerV1Overlay .story-v1-wait {
  margin-top: 18px;
  padding: 12px 0 12px 15px;
  border: 0;
  border-left: 1px solid rgba(168, 117, 66, 0.62);
  border-radius: 0;
  color: var(--lc-text-muted);
  background: transparent;
  font: 400 0.76rem/1.6 var(--lc-font-ui);
}

#storyLayerV1Overlay .story-v1-boundary {
  margin-top: 16px;
  color: rgba(194, 173, 178, 0.74);
  font: 400 0.68rem/1.55 var(--lc-font-ui);
}

/* C0 Waiting Echo: own mark exists, but shared progression is waiting. */
#storyLayerV1Overlay .story-v1-shell:has([data-story-c0-solo-replay]):has(.story-v1-wait) {
  background-color: var(--lc-surface-base);
  background-image:
    var(--lc-c0-waiting-art),
    radial-gradient(circle at 72% 24%, rgba(116, 31, 49, 0.10), transparent 28%),
    radial-gradient(circle at 22% 74%, rgba(168, 117, 66, 0.055), transparent 24%),
    linear-gradient(155deg, rgba(20, 14, 18, 0.98), rgba(8, 7, 8, 0.995));
  background-size: cover, auto, auto, auto;
  background-position: center, center, center, center;
}

#storyLayerV1Overlay .story-v1-shell:has([data-story-c0-solo-replay]):has(.story-v1-wait) .story-v1-body {
  padding: 18px 0 18px 18px;
  border: 0;
  border-left: 1px solid rgba(232, 220, 199, 0.15);
  border-radius: 0;
  background: linear-gradient(90deg, rgba(245, 239, 231, 0.035), transparent 72%);
  box-shadow: none;
}

#storyLayerV1Overlay .story-v1-shell:has([data-story-c0-solo-replay]):has(.story-v1-wait) .story-v1-prose,
#storyLayerV1Overlay .story-v1-shell:has([data-story-c0-solo-replay]):has(.story-v1-wait) .story-v1-objective {
  color: var(--lc-text-secondary);
  font-family: var(--lc-font-narrative);
}

#storyLayerV1Overlay .story-v1-shell:has([data-story-c0-solo-replay]):has(.story-v1-wait) .story-v1-wait {
  position: relative;
  padding: 22px 18px 22px 42px;
  border: 1px solid rgba(168, 117, 66, 0.20);
  border-radius: 18px;
  color: var(--lc-text-secondary);
  background: rgba(17, 13, 16, 0.72);
  box-shadow: var(--lc-shadow-soft-lift);
  font-family: var(--lc-font-narrative);
  font-size: 0.9rem;
  line-height: 1.75;
}

#storyLayerV1Overlay .story-v1-shell:has([data-story-c0-solo-replay]):has(.story-v1-wait) .story-v1-wait::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 27px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lc-accent-decorative);
  box-shadow: 0 0 18px rgba(168, 117, 66, 0.42);
}

/* C0 convergence: Daddy has both fragments and can explicitly compare them. */
#storyLayerV1Overlay .story-v1-shell:has([data-story-action="COMPARE_FRAGMENTS"]) {
  background-color: var(--lc-surface-base);
  background-image:
    var(--lc-c0-convergence-art),
    radial-gradient(circle at 50% 16%, rgba(168, 117, 66, 0.09), transparent 28%),
    linear-gradient(155deg, rgba(23, 15, 19, 0.99), rgba(8, 7, 8, 0.995));
  background-size: cover, auto, auto;
  background-position: center, center, center;
}

#storyLayerV1Overlay .story-v1-shell:has([data-story-action="COMPARE_FRAGMENTS"]) .story-v1-body {
  position: relative;
  overflow: hidden;
  padding: 28px;
  border: 0;
  border-radius: 20px;
  background:
    linear-gradient(102deg,
      rgba(232, 220, 199, 0.09) 0 47.8%,
      rgba(168, 117, 66, 0.36) 49.4% 50.2%,
      rgba(232, 220, 199, 0.065) 51.8% 100%);
  box-shadow: inset 0 0 0 1px rgba(232, 220, 199, 0.10), var(--lc-shadow-soft-lift);
}

#storyLayerV1Overlay .story-v1-shell:has([data-story-action="COMPARE_FRAGMENTS"]) .story-v1-body::before,
#storyLayerV1Overlay .story-v1-shell:has([data-story-action="COMPARE_FRAGMENTS"]) .story-v1-body::after {
  content: '';
  position: absolute;
  top: 18px;
  bottom: 18px;
  width: 44%;
  pointer-events: none;
  opacity: 0.10;
  background:
    repeating-linear-gradient(4deg, rgba(232, 220, 199, 0.34) 0 1px, transparent 1px 7px),
    linear-gradient(135deg, rgba(232, 220, 199, 0.18), transparent 56%);
}

#storyLayerV1Overlay .story-v1-shell:has([data-story-action="COMPARE_FRAGMENTS"]) .story-v1-body::before {
  left: 16px;
  transform: rotate(-1deg);
}

#storyLayerV1Overlay .story-v1-shell:has([data-story-action="COMPARE_FRAGMENTS"]) .story-v1-body::after {
  right: 16px;
  transform: rotate(0.8deg);
}

#storyLayerV1Overlay .story-v1-shell:has([data-story-action="COMPARE_FRAGMENTS"]) .story-v1-prose,
#storyLayerV1Overlay .story-v1-shell:has([data-story-action="COMPARE_FRAGMENTS"]) .story-v1-objective,
#storyLayerV1Overlay .story-v1-shell:has([data-story-action="COMPARE_FRAGMENTS"]) .story-v1-hooks {
  position: relative;
  z-index: 1;
}

#storyLayerV1Overlay .story-v1-shell:has([data-story-action="COMPARE_FRAGMENTS"]) [data-story-action="COMPARE_FRAGMENTS"] {
  flex: 0 1 320px;
  min-height: 52px;
  margin-inline: auto;
  border-color: rgba(194, 148, 95, 0.58);
  background: linear-gradient(180deg, #8b2e44 0%, #5e1828 100%);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.32), 0 0 28px rgba(168, 117, 66, 0.08);
}

/* Games Hub Story entry: one invitation object, not a purple product card. */
.story-hub-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(168, 117, 66, 0.30) !important;
  border-radius: 16px 16px 24px 16px !important;
  color: var(--lc-text-on-artifact) !important;
  background:
    radial-gradient(circle at 14% 8%, rgba(255, 255, 255, 0.24), transparent 26%),
    linear-gradient(145deg, #e9dcc5 0%, #dcc8aa 56%, #c5ad8a 100%) !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24), var(--lc-glow-artifact) !important;
  transform: rotate(-0.16deg);
}

.story-hub-card .story-hub-kicker {
  color: var(--lc-accent-strong) !important;
  font: 600 0.72rem/1.4 var(--lc-font-code) !important;
  letter-spacing: 0.07em !important;
}

.story-hub-card .story-hub-title {
  color: #281b1f !important;
  font-family: var(--lc-font-narrative) !important;
  font-size: 1.08rem !important;
  font-weight: 600 !important;
}

.story-hub-card .story-hub-copy {
  color: rgba(40, 27, 31, 0.67) !important;
  font: 400 0.74rem/1.55 var(--lc-font-ui) !important;
}

@media (max-width: 599px) {
  #storyLayerV1Overlay {
    padding: 8px;
  }

  #storyLayerV1Overlay .story-v1-shell {
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 14px 14px;
  }

  #storyLayerV1Overlay .story-v1-shell:not(:has(.story-v1-objective)) .story-v1-body {
    padding: 22px 18px;
    transform: none;
  }

  #storyLayerV1Overlay .story-v1-shell:has([data-story-c0-solo-replay]):has(.story-v1-wait) .story-v1-body {
    padding: 14px 0 14px 14px;
  }

  #storyLayerV1Overlay .story-v1-shell:has([data-story-action="COMPARE_FRAGMENTS"]) .story-v1-body {
    padding: 22px 16px;
  }

  #storyLayerV1Overlay .story-v1-primary {
    width: 100%;
  }

  .story-hub-card {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-hub-card {
    transform: none;
  }
}
