/* =====================================================================
   CODEX & REGELN (app/codex-page.js -> #infoGrid <div class="codex">).
   Wortschatz der neuen Seiten: Abschnitte mit roemischer Nummer, Karten mit
   Goldwinkeln, Bilder im Look des echten Spiels (Brettfelder, Zugpunkte,
   Mana-Leiste, Effekt-Chips; codex-art.js), Fraktions-Reiter mit gleitender
   Markierung in Fraktionsfarbe. Suetlac sitzt als Bibliothekarin im Titel
   (wie Support), keine Ecken-Begleiterin. Grundbreite: main-10.css (.codex).
   ===================================================================== */
.codex { container-type: inline-size; }
.codex .duell-head { max-width: none; margin-bottom: 44px; }
.codex .duell-sub { max-width: 620px; }

/* ── Titel: zweite Zeile = „REGELN" + Katze + Blase ── */
.codex .cx-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: auto;
  max-width: none;
}
.codex .cx-title-line { display: block; }
.codex .cx-title-row { display: flex; align-items: flex-end; gap: .2em; max-width: 100%; }
/* Die Katzen-Zeile erbt vom Titel (Riesenschrift, Gold als Text-Fill) — zuruecksetzen. */
.codex .cx-title-row .mascotLine {
  margin: 0 0 -.04em;
  gap: 14px;
  letter-spacing: 0;
  font-weight: 400;
  line-height: 1.5;
  -webkit-text-fill-color: currentcolor;
  min-width: 0;
}
.codex .cx-title-row .mascotLine-cat .coachCat { width: .9em; }
.codex .cx-title-row .mascotLine-bubble { margin-top: .08em; max-width: 440px; }
.codex .cx-title-row .mascotLine-text { font-size: 16.5px; }
@media (max-width: 820px) {
  .codex .cx-title-row { flex-wrap: wrap; }
  .codex .cx-title-row .mascotLine { flex-basis: 100%; margin: 18px 0 0; align-items: flex-start; }
  .codex .cx-title-row .mascotLine-cat .coachCat { width: 72px; }
  .codex .cx-title-row .mascotLine-bubble { margin-top: 2px; }
}

/* ── Abschnitte (I Regeln, II Fraktionen) ── */
.codex .cx-sec + .cx-sec { margin-top: 54px; }
.codex .cx-sec-label {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  font-family: var(--mp-mono);
  font-size: 11px;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  color: var(--mp-ink-dim);
  scroll-margin-top: 90px;
}
.codex .cx-sec-label .num { color: var(--mp-gold-2); letter-spacing: 2px; }
.codex .cx-sec-label .line { width: 46px; height: 1px; background: linear-gradient(90deg, var(--mp-gold-3), transparent); }

/* ── I · Regel-Karten: Bild links, Text rechts ── */
.codex .cx-rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.codex .cx-rule {
  position: relative;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  padding: 22px 26px 22px 20px;
  background: linear-gradient(180deg, rgba(20, 23, 31, .65), rgba(11, 13, 18, .82));
  border: 1px solid rgba(216, 177, 90, .14);
  scroll-margin-top: 90px;
  transition: border-color 220ms ease, background 220ms ease;
}
.codex .cx-rule::before, .codex .cx-rule::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid var(--mp-gold-3);
  transition: border-color 220ms ease;
}
.codex .cx-rule::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.codex .cx-rule::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.codex .cx-rule:hover { border-color: rgba(216, 177, 90, .26); background: linear-gradient(180deg, rgba(24, 27, 36, .8), rgba(12, 14, 20, .9)); }
.codex .cx-rule:hover::before, .codex .cx-rule:hover::after { border-color: var(--mp-gold-1); }
.codex .cx-art { display: grid; place-items: center; min-height: 152px; }
.codex .cx-rule-num { font-family: var(--mp-mono); font-size: 10px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--mp-gold-2); margin-bottom: 6px; }
.codex .cx-rule-title { margin: 0 0 10px; font-family: var(--mp-serif); font-size: 22px; font-weight: 600; letter-spacing: 1px; line-height: 1.05; color: var(--mp-bone); }
.codex .cx-rule-body { margin: 0; font-family: var(--mp-serif-body); font-size: 16px; line-height: 1.55; color: var(--mp-ink); text-wrap: pretty; }
.codex .cx-rule-body b { color: var(--mp-bone); font-weight: 600; }

/* Maus- oder Handy-Fassung (Text und Effektleisten-Bild). */
.codex .cx-phone,
.codex .cx-pad { display: none; }
body.mp-phone .codex .cx-desk { display: none; }
body.mp-phone .codex span.cx-phone { display: inline; }
body.mp-phone .codex .cx-coins.cx-phone { display: flex; }

/* ── II · Fraktionen: Reiter ── */
.codex .cx-tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(216, 177, 90, .14);
  scroll-margin-top: 90px;
}
.codex .cx-tab {
  --fc: var(--mp-gold-1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 10px 15px;
  border: 0;
  background: none;
  font-family: var(--mp-serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--mp-ink-dim);
  cursor: var(--mp-cur-pointer);
  transition: color 280ms ease;
}
.codex .cx-tab:hover { color: var(--mp-bone); }
.codex .cx-tab.is-active { color: var(--fc); }
.codex .cx-tab:focus-visible { outline: 1px solid var(--mp-gold-1); outline-offset: -4px; }
/* Kleine Raute als Sockel, die Koenigsfigur steht darin. */
.codex .cx-tab-gem { position: relative; display: grid; place-items: center; width: 36px; height: 36px; flex: none; }
.codex .cx-tab-gem::before {
  content: "";
  position: absolute;
  inset: 5px;
  rotate: 45deg;
  border: 1px solid rgba(216, 177, 90, .22);
  background: rgba(8, 10, 14, .85);
  transition: border-color 280ms ease, box-shadow 280ms ease;
}
.codex .cx-tab-gem img {
  position: relative;
  height: 40px;
  margin-top: -10px;
  object-fit: contain;
  filter: grayscale(.7) brightness(.72) drop-shadow(0 2px 3px rgba(0, 0, 0, .7));
  transition: filter 320ms ease, translate 320ms cubic-bezier(.3, .9, .3, 1.2);
}
.codex .cx-tab:hover .cx-tab-gem img { filter: grayscale(.3) brightness(.9) drop-shadow(0 2px 3px rgba(0, 0, 0, .7)); }
.codex .cx-tab.is-active .cx-tab-gem::before { border-color: var(--fc); box-shadow: 0 0 12px color-mix(in srgb, var(--fc) 28%, transparent); }
.codex .cx-tab.is-active .cx-tab-gem img { filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .7)); translate: 0 -3px; }
.codex .cx-tabs-glide {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 0;
  height: 2px;
  opacity: 0;
  pointer-events: none;
  background-color: var(--fc, var(--mp-gold-1));
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
  transition: translate 460ms cubic-bezier(.3, .8, .25, 1), width 460ms cubic-bezier(.3, .8, .25, 1), background-color 460ms ease;
}

/* ── Fraktions-Banner: Portrait rechts, Name, Spielstil, Werte ── */
.codex .cx-folk {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 250px;
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--fc) 26%, rgba(216, 177, 90, .1));
  background: linear-gradient(180deg, rgba(14, 17, 23, .92), rgba(8, 9, 13, .96));
}
.codex .cx-folk::before, .codex .cx-folk::after {
  content: "";
  position: absolute;
  z-index: 2;
  width: 14px;
  height: 14px;
  border: 1px solid var(--fc);
  opacity: .7;
}
.codex .cx-folk::before { top: 6px; left: 6px; border-right: 0; border-bottom: 0; }
.codex .cx-folk::after { bottom: 6px; right: 6px; border-left: 0; border-top: 0; }
.codex .cx-folk-art {
  position: absolute;
  top: 0;
  right: 0;
  width: 70%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 24%;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, .6) 26%, #000 48%);
  mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, .6) 26%, #000 48%);
}
.codex .cx-folk-text { position: relative; z-index: 1; max-width: min(440px, 50%); padding: 30px 34px; }
.codex .cx-folk-name {
  margin: 0 0 10px;
  font-family: var(--mp-serif);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 3px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--fc);
}
.codex .cx-folk-desc { margin: 0 0 20px; font-family: var(--mp-serif-body); font-size: 17px; line-height: 1.5; color: var(--mp-ink); text-wrap: pretty; }
.codex .cx-stats { display: grid; gap: 10px; max-width: 320px; }
.codex .cx-stat { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 12px; }
.codex .cx-stat .lbl { font-family: var(--mp-mono); font-size: 10px; letter-spacing: 1.8px; text-transform: uppercase; color: var(--mp-ink-dim); }
.codex .cx-stat .bar { position: relative; height: 3px; overflow: hidden; background: rgba(255, 255, 255, .07); }
/* Fuellt sich, sobald das Banner im Bild ist (.is-live, codex-page.js). */
.codex .cx-stat .fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  scale: 0 1;
  background: linear-gradient(90deg, color-mix(in srgb, var(--fc) 45%, transparent), var(--fc));
  box-shadow: 0 0 8px color-mix(in srgb, var(--fc) 45%, transparent);
  transition: scale 900ms cubic-bezier(.2, .8, .2, 1) calc(160ms + var(--i) * 90ms);
}
.codex .cx-folk.is-live .cx-stat .fill { scale: var(--v) 1; }

/* Figuren-Karten (.rr-card aus der Sammlung, main-08.css) */
.codex .cx-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 0; }
.codex .cx-cards .rr-card { height: 300px; }

/* ── Einzug beim Oeffnen und Fraktionswechsel ── */
@keyframes cxRise {
  from { opacity: 0; translate: 0 14px; }
  to { opacity: 1; translate: 0 0; }
}
@keyframes cxArtIn {
  from { opacity: 0; scale: 1.05; }
  to { opacity: 1; scale: 1; }
}
.codex.is-enter .cx-sec-label,
.codex.is-enter .cx-rule,
.codex.is-enter .cx-tabs,
.codex.is-enter .cx-folk-stage {
  animation: cxRise 620ms cubic-bezier(.2, .8, .2, 1) both;
  animation-delay: calc(140ms + var(--i, 0) * 80ms);
}
.codex.is-enter .cx-folks .cx-sec-label,
.codex.is-enter .cx-tabs,
.codex.is-enter .cx-folk-stage { animation-delay: 420ms; }
.codex .cx-folk-panel.is-swap .cx-folk-art { animation: cxArtIn 700ms ease both; }
.codex .cx-folk-panel.is-swap .cx-folk-text > * { animation: cxRise 520ms cubic-bezier(.2, .8, .2, 1) both; }
.codex .cx-folk-panel.is-swap .cx-folk-desc { animation-delay: 60ms; }
.codex .cx-folk-panel.is-swap .cx-stats { animation-delay: 120ms; }
.codex .cx-folk-panel.is-swap .rr-card {
  animation: cxRise 520ms cubic-bezier(.2, .8, .2, 1) both;
  animation-delay: calc(120ms + var(--i) * 55ms);
}

/* ── Breiten ── */
@container (max-width: 900px) {
  .codex .cx-rules { grid-template-columns: minmax(0, 1fr); }
}
@container (max-width: 680px) {
  .codex .cx-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .codex .cx-folk { flex-direction: column; align-items: stretch; min-height: 0; }
  .codex .cx-folk-art { position: relative; width: 100%; height: 170px; -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent); mask-image: linear-gradient(180deg, #000 55%, transparent); }
  .codex .cx-folk-text { max-width: none; margin-top: -34px; padding: 0 22px 24px; }
  .codex .cx-folk-name { font-size: 32px; }
}
@container (max-width: 520px) {
  .codex .cx-rule { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 22px 20px 20px; }
  .codex .cx-art { min-height: 0; }
}

/* ── Handy ── */
body.mp-phone .codex .duell-head { margin-bottom: 30px; }
body.mp-phone .codex .duell-sub { font-size: 18px; }
body.mp-phone .codex .cx-sec + .cx-sec { margin-top: 40px; }
body.mp-phone .codex .cx-rule-title { font-size: 20px; }
body.mp-phone .codex .cx-rule-body { font-size: 15.5px; }
body.mp-phone .codex .cx-tab { flex-direction: column; gap: 6px; padding: 8px 4px 12px; font-size: 14px; letter-spacing: 1.5px; }
body.mp-phone .codex .cx-folk-desc { font-size: 16px; }
body.mp-phone .codex .cx-cards { gap: 10px; }
body.mp-phone .codex .cx-cards .rr-card { height: 260px; }
body.mp-phone .codex .cx-cards .rr-name { font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  .codex .cx-tabs-glide,
  .codex .cx-stat .fill,
  .codex .cx-tab-gem img { transition: none; }
  .codex .cx-folk-panel.is-swap * { animation: none !important; }
}
