/* Family controls keep their order and semantics across the five layouts. */
:root[data-child-theme] :is(#strom, #osoby) {
  --room-corner: 1.1rem;
  --room-rhythm: var(--accent);
  --room-base: var(--surface);
  --room-pattern: none;
}

.world-context-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(7rem, 13rem);
  grid-template-areas: "copy art";
  align-items: center;
  gap: 1rem;
  margin: 0 0 1rem;
  padding: clamp(.85rem, 2.4vw, 1.55rem);
  border: 1px solid var(--border);
  border-radius: var(--room-corner, 1rem);
  background: var(--room-pattern), var(--room-base, var(--surface));
}

.world-context-copy { grid-area: copy; min-width: 0; overflow-wrap: anywhere; }
.world-context-copy :is(h3, p) { margin-block: .2rem; }
.world-context-copy .kicker { color: var(--room-rhythm, var(--accent)); }
.world-context-copy > strong { display: block; color: var(--text); font: 650 clamp(1.12rem, 3vw, 1.75rem)/1.13 var(--serif); }
.world-context-copy ul { display: flex; flex-wrap: wrap; gap: .3rem; padding: 0; margin: .5rem 0 0; list-style: none; }
.world-context-copy li { padding: .18rem .45rem; border: 1px solid var(--border); border-radius: var(--room-corner); background: var(--surface); color: var(--text); font-size: .74rem; }
.world-context-art { grid-area: art; min-width: 0; }
.world-context-art svg { display: block; width: 100%; height: auto; }

:root[data-child-theme] #strom > #tree-mode-picker {
  padding: .55rem;
  border: 1px solid var(--border);
  border-radius: var(--room-corner);
  background: var(--room-base);
}

:root[data-child-theme] #strom :is(.family-network-viewport, #anulka-fan-stage, #pedigree) {
  border-radius: var(--room-corner);
  background: var(--room-pattern), var(--room-base);
}

:root[data-child-theme] #strom :is(.tree-network-heading, .tree-mode-toolbar, .tree-network-detail),
:root[data-child-theme] #osoby :is(.directory-toolbar, .directory-filter-panel) {
  border-radius: var(--room-corner);
}

:root[data-child-theme] #osoby #people:not(.directory-cards) .directory-entry > a {
  min-height: 2.9rem;
  border-radius: var(--room-corner);
}

/* Terka: parallel stage tracks and numbered lighting steps. */
:root[data-child-theme="kpop"] :is(#strom, #osoby) {
  --room-corner: .55rem;
  --room-pattern: linear-gradient(115deg, transparent 46%, #b471db32 46.2% 46.6%, transparent 46.8% 49%, #56cad144 49.2% 49.7%, transparent 50%),
    repeating-linear-gradient(0deg, transparent 0 8px, #8362ba15 9px 10px);
}

:root[data-child-theme="kpop"] #strom #tree-mode-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .4rem;
}

:root[data-child-theme="kpop"] #strom #tree-mode-picker button { border-inline-start: 3px solid #7f52c2; }
:root[data-child-theme="kpop"] #strom #tree-mode-picker button:nth-child(3n + 2) { border-inline-start-color: #bc569e; }
:root[data-child-theme="kpop"] #strom #tree-mode-picker button:nth-child(3n) { border-inline-start-color: #2b929d; }
:root[data-child-theme="kpop"] #strom .family-network-tile { rx: 3px; }
:root[data-child-theme="kpop"] #strom .family-network-edge.is-highlighted { filter: drop-shadow(0 0 2px #8b59c6); }
:root[data-child-theme="kpop"] #osoby #people .directory-card {
  border-radius: .45rem;
  background: var(--room-pattern), var(--surface);
  border-block-start: 3px solid #9064c9;
}
:root[data-child-theme="kpop"] #osoby #people .directory-entry:nth-child(3n + 2) .directory-card { border-block-start-color: #bc569e; }
:root[data-child-theme="kpop"] #osoby #people .directory-entry:nth-child(3n) .directory-card { border-block-start-color: #2b929d; }

/* Jača: a rose window above the chart and tall lancet portrait cards. */
:root[data-child-theme="gothic"] :is(#strom, #osoby) {
  --room-corner: .25rem;
  --room-pattern: radial-gradient(ellipse at 50% 0, #a56bb43c 0 20%, transparent 58%),
    repeating-linear-gradient(60deg, transparent 0 30px, #7f5c9f15 31px 32px, transparent 33px 63px),
    repeating-linear-gradient(-60deg, transparent 0 30px, #7f5c9f15 31px 32px, transparent 33px 63px);
}

:root[data-child-theme="gothic"] .world-context-banner { grid-template-columns: minmax(7rem, 12rem) minmax(0, 1fr); grid-template-areas: "art copy"; border-style: double; border-width: 3px; }
:root[data-child-theme="gothic"] #strom .family-network-tile { rx: 16px; ry: 12px; }
:root[data-child-theme="gothic"] #strom .family-fan-sector { stroke-width: 1.6px; }
:root[data-child-theme="gothic"] #osoby #people .directory-card {
  align-items: center;
  text-align: center;
  padding-top: 1.65rem;
  border-radius: 50% 50% .35rem .35rem / 2.5rem 2.5rem .35rem .35rem;
  background: var(--room-pattern), var(--surface);
  box-shadow: inset 0 0 0 .25rem color-mix(in srgb, var(--border) 55%, transparent);
}
:root[data-child-theme="gothic"] #osoby #people .directory-card-top { max-width: 100%; margin-inline: auto; flex-direction: column; }
:root[data-child-theme="gothic"] #osoby #people .directory-card-top .compact-portrait { width: 3.1rem; border-radius: 50% 50% 15% 15%; }

/* Ača: a shell-shaped opening and a compact collection of pearl keepsakes. */
:root[data-child-theme="pets"] :is(#strom, #osoby) {
  --room-corner: 1.55rem;
  --room-pattern: radial-gradient(ellipse at 18% 28%, #eca5c74d, transparent 48%),
    radial-gradient(ellipse at 89% 7%, #a0e7dd65, transparent 48%),
    radial-gradient(circle at 50% 50%, #d8ac9440 0 1.5px, transparent 2px) 0 0 / 16px 16px;
}
:root[data-child-theme="pets"] .world-context-banner { border-radius: 2.8rem 1.1rem 2.8rem 1.1rem; }
:root[data-child-theme="pets"] #strom #tree-mode-picker { justify-content: center; }
:root[data-child-theme="pets"] #strom #tree-mode-picker button { border-radius: 999px; }
:root[data-child-theme="pets"] #strom .family-network-tile { rx: 22px; }
:root[data-child-theme="pets"] #strom .family-network-edge { stroke-linecap: round; }
:root[data-child-theme="pets"] #osoby #people .directory-card {
  min-height: 10rem;
  border-radius: 1.45rem .8rem 1.45rem .8rem;
  background: var(--room-pattern), var(--surface);
}
:root[data-child-theme="pets"] #osoby #people .directory-card .compact-portrait { border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--border); }

/* Jarda: squared room tiles on a dungeon-map grid. */
:root[data-child-theme="dungeon"] :is(#strom, #osoby) {
  --room-corner: .12rem;
  --room-pattern: linear-gradient(#72926d30 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, #72926d30 1px, transparent 1px) 0 0 / 24px 24px;
}
:root[data-child-theme="dungeon"] #strom #tree-mode-picker button,
:root[data-child-theme="dungeon"] #osoby .directory-toolbar .person-link { border-radius: .1rem; font-family: Consolas, monospace; }
:root[data-child-theme="dungeon"] #strom .family-network-tile { rx: 0; }
:root[data-child-theme="dungeon"] #strom :is(.family-network-name, .family-network-year, .family-network-caption) { font-family: Consolas, monospace; }
:root[data-child-theme="dungeon"] #osoby #people .directory-card {
  border-radius: 0;
  background: var(--room-pattern), var(--surface);
  box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4px var(--border);
}
:root[data-child-theme="dungeon"] #osoby #people .directory-card strong { font-family: Consolas, monospace; font-size: 1rem; }
:root[data-child-theme="dungeon"] #osoby #people .directory-card .compact-portrait { border-radius: .1rem; }

/* Aňulka: two-page folio with a binding and a gold-ruled tree. */
:root[data-child-theme="velvet"] :is(#strom, #osoby) {
  --room-corner: .45rem;
  --room-pattern: linear-gradient(90deg, #a85c7433, transparent 13%),
    repeating-linear-gradient(0deg, transparent 0 26px, #b38d5140 27px 28px);
}
:root[data-child-theme="velvet"] .world-context-banner { border-inline-start: .45rem solid var(--gold); }
:root[data-child-theme="velvet"] #strom #tree-mode-picker button { border-radius: .35rem .95rem .35rem .35rem; }
:root[data-child-theme="velvet"] #strom .family-network-tile { rx: 6px; stroke-width: 1.7; }
:root[data-child-theme="velvet"] #strom .family-network-name { font-family: var(--serif); }
:root[data-child-theme="velvet"] #osoby #people .directory-card {
  border-inline-start: .32rem solid var(--gold);
  border-radius: .25rem 1rem 1rem .25rem;
  background: var(--room-pattern), var(--surface);
}

@media (min-width: 850px) {
  :root[data-child-theme="gothic"] #strom:not([hidden]),
  :root[data-child-theme="dungeon"] #strom:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(8.5rem, 12rem) minmax(0, 1fr);
    align-items: start;
    gap: .65rem 1rem;
  }
  :root:is([data-child-theme="gothic"], [data-child-theme="dungeon"]) #strom > :is(.chapter-heading, .world-context-banner, .tree-mode-toolbar, .tree-find-results) { grid-column: 1 / -1; }
  :root:is([data-child-theme="gothic"], [data-child-theme="dungeon"]) #strom > #tree-mode-picker { display: grid; grid-column: 1; margin: 0; }
  :root:is([data-child-theme="gothic"], [data-child-theme="dungeon"]) #strom > .tree-mode-panel { grid-column: 2; min-width: 0; }
  :root[data-child-theme="dungeon"] #strom { grid-template-columns: minmax(9rem, 13rem) minmax(0, 1fr); }
  :root[data-child-theme="dungeon"] #strom #tree-mode-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root[data-child-theme="kpop"] #osoby #people.directory-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  :root[data-child-theme="pets"] #osoby #people.directory-cards,
  :root[data-child-theme="dungeon"] #osoby #people.directory-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  :root[data-child-theme="velvet"] #osoby #people.directory-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root[data-child-theme="velvet"] #osoby #people .directory-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(6rem, .53fr);
    align-content: start;
    min-height: 10rem;
  }
  :root[data-child-theme="velvet"] #osoby #people .directory-card-top,
  :root[data-child-theme="velvet"] #osoby #people .directory-card-action { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .world-context-banner { grid-template-columns: minmax(0, 1fr) minmax(4.4rem, 6rem); gap: .65rem; }
  :root[data-child-theme="gothic"] .world-context-banner { grid-template-columns: minmax(4.4rem, 6rem) minmax(0, 1fr); }
  :root[data-child-theme="kpop"] #strom #tree-mode-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root[data-child-theme="velvet"] #osoby #people.directory-cards { grid-template-columns: minmax(0, 1fr); }
  :root[data-child-theme="velvet"] #osoby #people .directory-card { min-height: 9rem; }
}
