/* The opening, story and invitations share the illustrated card's edges. */
main:has(.topic-opening) {
  --scene-gutter: clamp(1rem, 5vw, 4.5rem);
  --topic-tone: #102b38;
}
main:has(.mini-example) {--topic-tone: #153437}
main:has(.phobia-pattern), main:has(.relationship-pattern) {--topic-tone: #103539}
body main .topic-opening,
body main.compact-topic > .topic-opening-actions {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding-inline: var(--scene-left, var(--scene-gutter)) var(--scene-right, var(--scene-gutter));
}
body main .topic-opening {
  padding-block: clamp(1.9rem, 4vw, 3.65rem) clamp(.85rem, 1.7vw, 1.4rem);
  overflow: clip;
  background: linear-gradient(160deg, #0c1e30, transparent 80%), var(--topic-tone);
  color: #ecf1ed;
  text-align: left;
  scroll-margin-top: 4.5rem;
}
body main .topic-opening h1 {
  position: relative;
  isolation: isolate;
  max-width: 100%;
  margin: 0;
  font: italic 400 clamp(34px, 3.7vw, 54px)/1.22 Georgia, "Times New Roman", serif !important;
  letter-spacing: -.015em !important;
  color: #f3dba7 !important;
  background: none !important;
  -webkit-text-fill-color: currentColor;
  text-shadow: 0 2px 12px #071b36;
  text-wrap: balance;
}
body main .topic-opening > p {
  margin: 1rem 0 1.35rem;
  max-width: 62ch;
  color: #e1eaf0;
  font: 400 1.08rem/1.55 system-ui;
}
body #inhalt.compact-topic :is(.topic-detail-original > section, .topic-detail-stage, .mini-example) {
  background: var(--topic-tone);
}
body main .topic-opening-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(.6rem, 1.35vw, 1rem);
}
body main.compact-topic > .topic-opening-actions {
  padding-block: .3rem clamp(1.75rem, 3.5vw, 3rem);
  background: linear-gradient(180deg, var(--topic-tone), #091e32);
}
body main .topic-opening-actions a {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 50px;
  padding: .8rem 1rem;
  border: 1px solid #92abaa;
  border-radius: .65rem;
  background: #15343c;
  color: #f2f6ef;
  font: 650 1rem/1.35 system-ui;
  text-decoration: none;
  text-align: center;
}
body main .topic-opening-actions a:last-child {
  border-color: #dec58a;
  background: linear-gradient(120deg, #e1c68b, #f3deb3);
  color: #252e2b;
}
body main .topic-opening-actions a:hover {text-decoration: underline; text-underline-offset: .2em}
body main .topic-opening-actions a:focus-visible {outline: 3px solid #fff2cc; outline-offset: 3px}
.compact-topic .home-scene-step {color: #dae5e5}

.topic-title-sparks {
  position: absolute;
  z-index: -1;
  inset: -1.4rem 0 -1rem;
  overflow: hidden;
  pointer-events: none;
  mask-image: linear-gradient(transparent, #000 18%, #000 80%, transparent);
}
.topic-title-sparks::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 55%, #e5bf5830, transparent 57%),
              radial-gradient(ellipse at 68% 50%, #82dfff20, transparent 56%);
  filter: blur(14px);
}
.topic-title-sparks i {
  position: absolute;
  left: var(--x);
  top: 90%;
  width: var(--size);
  height: calc(var(--size) * 1.4);
  background: radial-gradient(ellipse, #fff8e6, #ffe4ac 15%, #e6c37966 38%, transparent 72%);
  filter: drop-shadow(0 0 5px #f4d69b);
  opacity: 0;
  animation: topic-spark-rise var(--time) var(--delay) linear infinite paused;
}
.topic-title-sparks i:nth-child(3n) {
  background: radial-gradient(ellipse, #f1fcff, #bfeeff 15%, #87d5f566 38%, transparent 72%);
  filter: drop-shadow(0 0 5px #97dfff);
}
body:not(.udo-motion-paused) .topic-sparks-visible .topic-title-sparks i {animation-play-state: running}
@keyframes topic-spark-rise {
  0% {opacity: 0; transform: translate(0, 0) scale(.6)}
  18% {opacity: .7}
  74% {opacity: .5}
  100% {opacity: 0; transform: translate(var(--drift), -8rem) scale(.3)}
}
@media (prefers-reduced-motion: reduce) {.topic-title-sparks i {animation: none}}
@media (max-width: 650px) {
  body main .topic-opening h1 {font-size: clamp(31px, 8vw, 42px) !important; line-height: 1.24 !important}
}
@media (max-width: 540px) {
  body main .topic-opening-actions {grid-template-columns: 1fr}
}
.topic-opening-group .topic-opening {display:none}
.topic-opening-group .topic-opening:first-child,.topic-opening-group .topic-opening:target {display:block}
.topic-opening-group:has(.topic-opening:target) .topic-opening:not(:target) {display:none}
.topic-identity>.life-path,.topic-identity .personal-topic-landing>.offer-back,.topic-identity .personal-topic-landing>.exam-hero {display:none!important}
.compact-topic .topic-detail-original {padding:0}
body .compact-topic .topic-detail-original>section,body .compact-topic .topic-detail-stage,body .compact-topic .mini-example {margin:0;padding:clamp(.8rem,2vw,1.6rem) clamp(1rem,4vw,3.6rem);background:var(--topic-tone,#132b36);color:#fbf7eb}
.compact-topic .topic-detail-original>section>:not(.udo-scroll-track):not([class$="-stage"]),.compact-topic .transformation-habit-choice,.compact-topic .phobia-animal-choice {display:none!important}
.compact-topic .udo-scroll-track,.compact-topic .topic-story-stage,.compact-topic .transformation-stage {margin-block:0!important}
.compact-topic .topic-story header {margin:0 0 .75rem}
.compact-topic .topic-story-heading {color:#e4ece9!important}
.compact-topic .topic-story {margin:0}
.compact-topic .home-scene-controls {display:flex;gap:1rem;align-items:center;justify-content:center;padding:.65rem 0}
.compact-topic .home-scene-controls button {font:600 1rem/1.35 system-ui;padding:.55rem .9rem;border:1px solid #c4cfc7;background:#f7f4eb;color:#253c35;border-radius:.45rem;cursor:pointer}
.compact-topic .home-scene-controls button:disabled {opacity:.5}
.compact-topic .home-scene-announcement {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
body .compact-topic .mini-stage {background:#19333b;color:white;max-width:850px;margin:auto;border-radius:.8rem;overflow:hidden}
/* The dedicated page hides the selector. Its former grid row must go too. */
.compact-topic .transformation-example-ready,
.compact-topic .phobia-pattern-stage {
  grid-template-rows: minmax(0, 1fr) auto;
}
.compact-topic .mini-stage ol {
  margin: 0;
  padding: 0;
  list-style: none;
  font: 400 1.06rem/1.5 system-ui;
}
.compact-topic .mini-stage img {
  display: block;
  width: 100%;
  height: clamp(160px, 35vh, 360px);
  object-fit: contain;
  background: #132b36;
}
.compact-topic .mini-caption {padding: 1rem 1.3rem 1.15rem}
.compact-topic .mini-caption strong {display: block; margin-bottom: .4rem; color: #edd4a1}
.compact-topic .mini-stage[data-phase] ol {display: grid}
.compact-topic .mini-stage[data-phase] li {grid-area: 1 / 1; visibility: hidden; opacity: 0}
.compact-topic .mini-stage[data-phase] li[aria-current="step"] {visibility: visible; opacity: 1}
@media (prefers-reduced-motion: no-preference) {
  .compact-topic .mini-stage[data-phase] li {transition: opacity .18s ease-out}
}

body main .topic-opening .topic-name {margin:0 0 .55rem;color:#d9e6e2;font:650 1rem/1.4 system-ui}
body main .topic-opening .topic-skip {display:inline-block;margin-top:.6rem;padding:.3rem 0;color:#f2dfb4;font:600 .93rem/1.4 system-ui;text-underline-offset:.2em}
body main .topic-opening-actions {scroll-margin-block-start:5rem}
body main .topic-opening-actions .topic-session-facts {grid-column:1/-1;display:grid;gap:.18rem;margin:.45rem 0 .15rem;color:#eef4ed;font:400 .96rem/1.45 system-ui}
body main .topic-opening-actions .topic-session-facts strong {font-weight:650;color:#f1dcac}
