/* ============================================================
   branchen.css - Sector silo ("Branchen")
   Depends on: styles.css (:root tokens, navbar, footer, buttons)
               home.css (hero engine, cta-section, section-title)
   Scoped prefix: br-   ·   Signature: "Sektoren-Dossier"
   All animation entry-states live here; branchen.js owns motion.
   ============================================================ */

/* ----------------------------------------------------------
   0 · Silo-local tokens
   A warmer structural accent (survey/blueprint amber) layered
   ON TOP of the brand blues - never replacing them. This is the
   one axis of freedom the brief leaves open, spent on a colour
   that reads "engineering / infrastructure dossier", not generic.
   ---------------------------------------------------------- */
.br-scope {
    --br-amber: #c8781e;          /* survey-line amber, structural accent */
    --br-amber-soft: rgba(200, 120, 30, 0.12);
    --br-ink: #10203a;            /* deep slate ink for dossier headings */
    --br-line: rgba(16, 32, 58, 0.14);
    --br-line-strong: rgba(16, 32, 58, 0.26);
    --br-paper: rgba(252, 253, 255, 0.9);
    --br-grid: rgba(19, 4, 234, 0.05);
    --br-mono: 'Inter', ui-monospace, 'SFMono-Regular', 'Menlo', monospace;
}

/* ----------------------------------------------------------
   1 · Hero modifier - keeps shared hero engine untouched,
   only tightens measure + adds a dossier reference line.
   ---------------------------------------------------------- */
.hero--branchen .hero-subheadline {
    max-width: 40rem;
}

.hero--branchen .hero-headline {
    font-size: clamp(1.9rem, 5.8vw, 3.9rem);
}

/* Coordinate strip under the hero CTA - a subtle "field survey" tag.
   Purely decorative; hidden from AT. Animated in by branchen.js. */
.br-hero-coords {
    margin-top: 1.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--br-mono);
    font-size: 0.66rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(16, 32, 58, 0.5);
    opacity: 0;                 /* branchen.js reveals */
}

.br-hero-coords .br-coord-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--br-amber);
    box-shadow: 0 0 0 3px var(--br-amber-soft);
}

/* ----------------------------------------------------------
   2 · Shared silo shell
   ---------------------------------------------------------- */
.br-shell {
    width: 100%;
    max-width: 76rem;
    margin: 0 auto;
    padding: 0 clamp(1.25rem, 5vw, 4rem);
}

.br-section {
    position: relative;
    padding-block: clamp(3.5rem, 9vh, 7rem);
}

/* Blueprint hairline that opens most sections - encodes "a new plate
   in the dossier", not decoration. */
.br-plate-rule {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: clamp(2rem, 4vh, 3rem);
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--br-line);
}

.br-plate-index {
    font-family: var(--br-mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--br-amber);
    flex-shrink: 0;
}

.br-plate-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.br-plate-rule::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: -1px;
    width: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--br-amber));
    transition: width 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.br-plate-rule.is-drawn::after {
    width: 42%;
}

.br-h2 {
    font-size: clamp(1.6rem, 3.6vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.022em;
    line-height: 1.12;
    margin: 0 0 1rem;
    color: var(--text-primary);
}

.br-lead {
    font-size: clamp(1rem, 1.9vw, 1.15rem);
    line-height: 1.7;
    color: var(--text-muted);
    max-width: 44rem;
    margin: 0;
}

/* ============================================================
   HUB - /branchen/  ·  "Sektoren-Index"
   ============================================================ */

/* ---- Hub intro band with live sector field (Three.js) ---- */
.br-hub-hero {
    position: relative;
    padding-block: clamp(3rem, 7vh, 5.5rem) clamp(2rem, 4vh, 3rem);
}

.br-hub-hero-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: clamp(2rem, 5vw, 4.5rem);
    align-items: center;
}

.br-hub-kicker {
    font-family: var(--br-mono);
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--br-amber);
    margin: 0 0 1rem;
}

.br-hub-title {
    font-size: clamp(1.9rem, 4.4vw, 3.1rem);
    font-weight: 800;
    letter-spacing: -0.028em;
    line-height: 1.08;
    margin: 0 0 1.25rem;
    color: var(--text-primary);
}

.br-hub-title em {
    font-style: normal;
    color: var(--neon-blue);
}

.br-hub-desc {
    font-size: clamp(1rem, 1.7vw, 1.14rem);
    line-height: 1.7;
    color: var(--text-muted);
    margin: 0 0 1.75rem;
    max-width: 34rem;
}

/* The signature field canvas - an ambient node lattice that the
   three sectors "belong to". Falls back to a static SVG poster. */
.br-field {
    position: relative;
    aspect-ratio: 1 / 1;
    width: 100%;
    max-width: 30rem;
    margin-inline: auto;
    border-radius: 1.5rem;
    overflow: hidden;
    background:
        radial-gradient(circle at 30% 25%, rgba(19, 4, 234, 0.1), transparent 60%),
        radial-gradient(circle at 75% 80%, rgba(200, 120, 30, 0.1), transparent 55%),
        var(--br-paper);
    border: 1px solid var(--glass-border);
    box-shadow: 0 18px 50px rgba(19, 4, 234, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.br-field canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.br-field-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.9;
}

.br-field.is-live .br-field-poster {
    opacity: 0;
    transition: opacity 0.6s ease;
}

/* ---- Sector index cards - asymmetric ledger rows, not a card grid ---- */
.br-index {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid var(--br-line);
}

.br-index-row {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: clamp(1rem, 3vw, 2.5rem);
    padding: clamp(1.5rem, 3.5vw, 2.4rem) 0.5rem;
    border-bottom: 1px solid var(--br-line);
    text-decoration: none;
    color: inherit;
    opacity: 0;                    /* branchen.js reveals */
    transform: translateY(24px);
    transition: background 0.35s ease;
    overflow: hidden;
}

/* Amber wipe on hover - reads like a highlighter over a survey sheet. */
.br-index-row::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--br-amber-soft), transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.br-index-row:hover::before,
.br-index-row:focus-visible::before {
    opacity: 1;
}

.br-index-row:focus-visible {
    outline: 2px solid var(--neon-purple);
    outline-offset: -2px;
    border-radius: 0.5rem;
}

.br-index-rank {
    position: relative;
    font-family: var(--br-mono);
    font-size: clamp(2.2rem, 6vw, 3.6rem);
    font-weight: 800;
    line-height: 0.85;
    color: var(--br-line-strong);
    letter-spacing: -0.04em;
    transition: color 0.35s ease;
    min-width: 2.4ch;
}

.br-index-row:hover .br-index-rank {
    color: var(--neon-blue);
}

.br-index-prio {
    display: block;
    margin-top: 0.4rem;
    font-family: var(--br-mono);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--br-amber);
}

.br-index-main {
    min-width: 0;
}

.br-index-name {
    font-size: clamp(1.25rem, 2.8vw, 1.9rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0 0 0.35rem;
    line-height: 1.1;
}

.br-index-desc {
    font-size: clamp(0.9rem, 1.6vw, 1rem);
    line-height: 1.55;
    color: var(--text-muted);
    margin: 0;
    max-width: 38rem;
}

.br-index-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.8rem;
}

.br-tag {
    font-family: var(--br-mono);
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--neon-blue);
    background: rgba(19, 4, 234, 0.06);
    border: 1px solid rgba(19, 4, 234, 0.16);
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
}

.br-index-go {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid var(--br-line-strong);
    color: var(--neon-blue);
    font-size: 1.1rem;
    transition: transform 0.3s ease, background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.br-index-row:hover .br-index-go {
    transform: translateX(4px);
    background: var(--neon-blue);
    border-color: var(--neon-blue);
    color: #fff;
}

/* ---- Hub value strip: why sector focus matters ---- */
.br-why {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(1.25rem, 3vw, 2rem);
    margin-top: clamp(2rem, 5vh, 3.5rem);
}

.br-why-item {
    padding: 1.75rem 1.5rem;
    background: var(--br-paper);
    border: 1px solid var(--glass-border);
    border-radius: 1.1rem;
    opacity: 0;
    transform: translateY(22px);
}

.br-why-num {
    font-family: var(--br-mono);
    font-size: 0.66rem;
    letter-spacing: 0.16em;
    color: var(--br-amber);
    margin: 0 0 0.9rem;
}

.br-why-item h3 {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin: 0 0 0.6rem;
}

.br-why-item p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin: 0;
}

/* ============================================================
   DETAIL PAGES - shared building blocks
   ============================================================ */

/* ---- Challenge ledger: two-column "Ist / wisepex" register ---- */
.br-ledger {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--br-line);
    border-radius: 1.1rem;
    overflow: hidden;
    background: var(--br-paper);
}

.br-ledger-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    opacity: 0;
    transform: translateY(20px);
}

.br-ledger-row + .br-ledger-row {
    border-top: 1px solid var(--br-line);
}

.br-ledger-cell {
    padding: clamp(1.25rem, 2.5vw, 1.85rem) clamp(1.25rem, 2.5vw, 1.85rem);
}

.br-ledger-cell--problem {
    background: rgba(16, 32, 58, 0.03);
    border-right: 1px solid var(--br-line);
}

.br-ledger-eyebrow {
    display: block;
    font-family: var(--br-mono);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin-bottom: 0.6rem;
}

.br-ledger-cell--problem .br-ledger-eyebrow { color: rgba(16, 32, 58, 0.5); }
.br-ledger-cell--answer  .br-ledger-eyebrow { color: var(--neon-blue); }

.br-ledger-cell p {
    margin: 0;
    font-size: clamp(0.9rem, 1.7vw, 1rem);
    line-height: 1.6;
    color: var(--text-primary);
}

.br-ledger-cell--problem p { color: rgba(16, 32, 58, 0.78); }

/* ---- Deliverables: what wisepex delivers (icon rail list) ---- */
.br-deliver {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(1rem, 2.5vw, 1.75rem);
}

.br-deliver-item {
    display: flex;
    gap: 1rem;
    padding: 1.5rem 1.5rem;
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    background: var(--glass-bg);
    opacity: 0;
    transform: translateY(20px);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal), transform var(--transition-normal);
}

.br-deliver-item:hover {
    border-color: rgba(19, 4, 234, 0.4);
    box-shadow: 0 12px 34px rgba(19, 4, 234, 0.12);
    transform: translateY(-3px);
}

.br-deliver-icon {
    flex-shrink: 0;
    width: 2.6rem;
    height: 2.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.7rem;
    background: linear-gradient(135deg, rgba(19, 4, 234, 0.14), rgba(129, 55, 255, 0.14));
    color: var(--neon-blue);
}

.br-deliver-icon svg { width: 1.3rem; height: 1.3rem; }

.br-deliver-item h3 {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin: 0 0 0.4rem;
}

.br-deliver-item p {
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text-muted);
    margin: 0;
}

/* ---- Reference dossier: the anonymised flagship case ---- */
.br-ref {
    position: relative;
    padding: clamp(2rem, 5vw, 3.5rem);
    border-radius: 1.5rem;
    background:
        linear-gradient(160deg, rgba(19, 4, 234, 0.04), transparent 60%),
        var(--br-paper);
    border: 1px solid var(--glass-border);
    box-shadow: 0 16px 46px rgba(19, 4, 234, 0.1);
    overflow: hidden;
}

/* Redaction bar motif - signals "anonymised, freigegeben" honestly. */
.br-ref-stamp {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--br-mono);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--br-amber);
    padding: 0.35rem 0.75rem;
    border: 1px solid rgba(200, 120, 30, 0.35);
    border-radius: 999px;
    margin-bottom: 1.5rem;
}

.br-ref-stamp::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: var(--br-amber);
}

.br-ref-quote {
    font-size: clamp(1.15rem, 2.6vw, 1.7rem);
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: -0.015em;
    color: var(--br-ink);
    margin: 0 0 1.75rem;
}

/* Animated highlight sweep behind key phrase - GSAP drives width. */
.br-ref-mark {
    position: relative;
    white-space: nowrap;
}

.br-ref-mark::after {
    content: '';
    position: absolute;
    left: -0.1em;
    right: -0.1em;
    bottom: 0.08em;
    height: 0.42em;
    background: var(--br-amber-soft);
    z-index: -1;
    transform: scaleX(0);
    transform-origin: left center;
    border-radius: 2px;
}

.br-ref-mark.is-marked::after {
    transform: scaleX(1);
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.br-ref-metrics {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(1.5rem, 5vw, 4rem);
    padding-top: 1.5rem;
    border-top: 1px solid var(--br-line);
}

.br-ref-metric {
    min-width: 7rem;
    text-align: center;
}

.br-ref-metric-num {
    font-size: clamp(1.6rem, 3.4vw, 2.4rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--neon-blue);
    line-height: 1;
}

.br-ref-metric-label {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
}

/* ---- Signature visual stage (per-page Three.js / GSAP) ---- */
.br-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: 30rem;
    border-radius: 1.5rem;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 20%, rgba(19, 4, 234, 0.08), transparent 55%),
        var(--br-paper);
    border: 1px solid var(--glass-border);
    box-shadow: 0 16px 46px rgba(19, 4, 234, 0.1);
}

.br-stage canvas,
.br-stage svg.br-stage-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.br-stage-caption {
    position: absolute;
    left: clamp(1rem, 3vw, 1.75rem);
    bottom: clamp(1rem, 3vw, 1.5rem);
    font-family: var(--br-mono);
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(16, 32, 58, 0.55);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(6px);
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--br-line);
}

/* ---- Two-up: stage beside prose ---- */
.br-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(2rem, 5vw, 4rem);
    align-items: center;
}

.br-split--reverse .br-split-visual { order: 2; }

/* ---- Approach steps (sector-specific vertical flow) ---- */
.br-flow {
    display: flex;
    flex-direction: column;
    gap: 0;
    counter-reset: br-step;
}

.br-flow-step {
    position: relative;
    padding: 1.5rem 0 1.5rem 3.5rem;
    border-left: 2px solid var(--br-line);
    margin-left: 1rem;
    opacity: 0;
    transform: translateY(18px);
}

.br-flow-step::before {
    counter-increment: br-step;
    content: counter(br-step, decimal-leading-zero);
    position: absolute;
    left: -1.15rem;
    top: 1.35rem;
    width: 2.2rem;
    height: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--br-mono);
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--neon-blue);
    background: var(--br-paper);
    border: 2px solid var(--br-line-strong);
    border-radius: 50%;
}

.br-flow-step:last-child { border-left-color: transparent; }

.br-flow-step h3 {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.br-flow-step p {
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin: 0;
}

/* ---- CTA hook local to silo (uses shared cta-box) ---- */
.br-scope .cta-section { padding-top: clamp(2rem, 5vh, 4rem); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .br-hub-hero-grid { grid-template-columns: 1fr; gap: 2.5rem; }
    .br-field { max-width: 24rem; order: -1; }
    .br-why { grid-template-columns: 1fr; }
    .br-deliver { grid-template-columns: 1fr; }
    .br-split { grid-template-columns: 1fr; }
    .br-split--reverse .br-split-visual { order: 0; }
}

@media (max-width: 640px) {
    .br-index-row {
        grid-template-columns: auto 1fr;
        gap: 1rem 1.25rem;
    }
    .br-index-go {
        grid-column: 1 / -1;
        justify-self: start;
        width: 2.5rem;
        height: 2.5rem;
    }
    .br-ledger-row { grid-template-columns: 1fr; }
    .br-ledger-cell--problem { border-right: none; border-bottom: 1px solid var(--br-line); }
    .br-ref-metrics {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem 2rem;
    }
    .br-ref-metric { width: 100%; }
}

/* ============================================================
   Reduced motion - collapse all entry states to visible
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .br-hero-coords,
    .br-index-row,
    .br-why-item,
    .br-ledger-row,
    .br-deliver-item,
    .br-flow-step {
        opacity: 1 !important;
        transform: none !important;
    }
    .br-plate-rule::after { width: 42%; }
    .br-ref-mark::after { transform: scaleX(1); }
}

/* ============================================================
   REFERENCE DOSSIER · Infrastruktur modifier (.br-ref--infra)
   Scoped to /branchen/infrastruktur-energieversorgung only -
   the other sector pages keep the base .br-ref untouched.
   Fixes: the nowrap highlight (overflow on phones, orphaned
   first line on desktop) and the quote's vertical rhythm.
   ============================================================ */
.br-ref--infra {
    padding: clamp(1.75rem, 5vw, 3.5rem);
}

.br-ref--infra .br-ref-stamp {
    margin-bottom: clamp(1.25rem, 3vw, 1.75rem);
}

/* Fluid type + readable measure. Soft hyphens (&shy;) in the markup
   stay dormant on wide screens (hyphens: none) and are only activated
   on phones, where long German compounds would otherwise overflow.
   overflow-wrap is the last safety net so no word can cross the edge. */
.br-ref--infra .br-ref-quote {
    max-width: 58ch;
    margin: 0 0 clamp(1.75rem, 4vw, 2.5rem);
    font-size: clamp(1.1rem, 0.85rem + 1.1vw, 1.65rem);
    line-height: 1.42;
    overflow-wrap: break-word;
    -webkit-hyphens: none;
    hyphens: none;
    text-wrap: pretty;
}

/* Highlight rebuilt as an inline background instead of an absolute
   ::after, so the phrase can wrap freely. With the default
   box-decoration-break (slice) the sweep runs line 1 -> line 2 like
   a single highlighter stroke. Still driven by .is-marked (branchen.js). */
.br-ref--infra .br-ref-mark {
    white-space: normal;
    padding: 0 0.06em;
    margin: 0 -0.06em;
    background-image: linear-gradient(var(--br-amber-soft), var(--br-amber-soft));
    background-repeat: no-repeat;
    background-position: 0 88%;
    background-size: 0% 0.42em;
    transition: background-size 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.br-ref--infra .br-ref-mark::after {
    content: none;
}

.br-ref--infra .br-ref-mark.is-marked {
    background-size: 100% 0.42em;
}

/* Metrics intentionally inherit the base .br-ref-metrics layout
   (centred row on desktop, centred stack on phones) so this page
   matches the other sector dossiers. Only the quote is modified. */

/* Phones: activate the dormant soft hyphens in the quote. */
@media (max-width: 640px) {
    .br-ref--infra .br-ref-quote {
        -webkit-hyphens: manual;
        hyphens: manual;
    }
}

/* Very narrow phones: keep the stamp on one line on 320px devices. */
@media (max-width: 359px) {
    .br-ref--infra .br-ref-stamp {
        letter-spacing: 0.08em;
        white-space: nowrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    .br-ref--infra .br-ref-mark {
        background-size: 100% 0.42em;
        transition: none;
    }
}
