/*
 * Bonus-Realitätscheck – Styles.
 * Scope: .pd-shell (klassenbasiert, damit mehrere Instanzen pro Seite möglich sind).
 * Optionales Dark-Theme: <section class="pd-shell pd-shell--auto-dark">
 * Optionaler Vollbreiten-Rand auf Mobile: <section class="pd-shell pd-shell--bleed">
 */

.pd-shell {
    --pd-bg: #f5f7fa;
    --pd-panel: #ffffff;
    --pd-text: #182433;
    --pd-muted: #5f6d7c;
    --pd-border: #d9e1e8;
    --pd-accent: #1f5f86;
    --pd-accent-dark: #174968;
    --pd-accent-soft: #eaf2f7;
    --pd-accent-rgb: 31, 95, 134;
    --pd-good: #236743;
    --pd-good-bg: #edf7f1;
    --pd-warning: #7a570d;
    --pd-warning-bg: #fff8e6;
    --pd-danger: #8a3030;
    --pd-danger-bg: #fff0f0;
    --pd-radius: 16px;
    --pd-radius-sm: 10px;
    --pd-shadow: 0 12px 32px rgba(24, 36, 51, 0.08);
    --pd-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --pd-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    color: var(--pd-text);
    background: var(--pd-bg);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius);
    box-shadow: var(--pd-shadow);
    font-family: var(--pd-font);
    line-height: 1.55;
    margin: 2rem 0;
    max-width: 100%;
    padding: clamp(1rem, 3vw, 2rem);
}

.pd-shell *,
.pd-shell *::before,
.pd-shell *::after {
    box-sizing: border-box;
}

.pd-shell .pd-header {
    max-width: 840px;
    margin: 0 0 1.5rem;
}

.pd-shell .pd-eyebrow {
    color: var(--pd-accent);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin: 0 0 0.35rem;
    text-transform: uppercase;
}

.pd-shell h3 {
    color: var(--pd-text);
    font-size: clamp(1.35rem, 2.5vw, 1.85rem);
    line-height: 1.2;
    margin: 0 0 0.65rem;
}

.pd-shell .pd-intro,
.pd-shell .pd-note p,
.pd-shell .pd-status p,
.pd-shell .pd-score-card p {
    color: var(--pd-muted);
    margin: 0;
}

.pd-shell .pd-noscript {
    background: var(--pd-warning-bg);
    border-left: 4px solid var(--pd-warning);
    border-radius: var(--pd-radius-sm);
    color: var(--pd-text);
    font-size: 0.88rem;
    margin: 0 0 1.25rem;
    padding: 0.8rem 1rem;
}

.pd-shell .pd-layout {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
}

.pd-shell .pd-form,
.pd-shell .pd-results {
    min-width: 0;
}

.pd-shell .pd-form {
    margin: 0;
}

.pd-shell .pd-fields {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pd-shell .pd-field {
    display: grid;
    gap: 0.4rem;
    min-width: 0;
}

.pd-shell .pd-field--wide {
    grid-column: 1 / -1;
}

.pd-shell .pd-field > span:first-child {
    color: var(--pd-text);
    font-size: 0.9rem;
    font-weight: 700;
}

.pd-shell .pd-field small {
    color: var(--pd-muted);
    font-size: 0.78rem;
    font-weight: 500;
}

.pd-shell .pd-input-wrap {
    align-items: center;
    background: var(--pd-panel);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius-sm);
    display: flex;
    min-height: 48px;
    overflow: hidden;
}

.pd-shell .pd-input-wrap > span {
    color: var(--pd-muted);
    flex: 0 0 auto;
    font-size: 0.92rem;
    padding: 0 0.85rem 0 0.25rem;
}

.pd-shell .pd-input-wrap--prefix > span {
    padding: 0 0.25rem 0 0.85rem;
}

.pd-shell input,
.pd-shell select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--pd-panel);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius-sm);
    color: var(--pd-text);
    font: inherit;
    font-size: 16px; /* verhindert Auto-Zoom auf iOS */
    line-height: 1.3;
    margin: 0;
    min-height: 48px;
    padding: 0.7rem 0.85rem;
    width: 100%;
}

.pd-shell .pd-input-wrap input {
    background: transparent;
    border: 0;
    border-radius: 0;
    min-width: 0;
    outline: 0;
}

.pd-shell select {
    background-image:
        linear-gradient(45deg, transparent 50%, var(--pd-muted) 50%),
        linear-gradient(135deg, var(--pd-muted) 50%, transparent 50%);
    background-position:
        right 1.15rem center,
        right 0.85rem center;
    background-repeat: no-repeat;
    background-size: 5px 5px, 5px 5px;
    padding-right: 2.5rem;
}

.pd-shell input:focus-visible,
.pd-shell select:focus-visible,
.pd-shell .pd-formula:focus-visible {
    outline: 3px solid rgba(var(--pd-accent-rgb), 0.28);
    outline-offset: 2px;
}

.pd-shell .pd-input-wrap:focus-within {
    border-color: var(--pd-accent);
    box-shadow: 0 0 0 3px rgba(var(--pd-accent-rgb), 0.12);
}

.pd-shell .pd-results {
    display: grid;
    align-content: start;
    gap: 0.9rem;
}

.pd-shell .pd-score-card,
.pd-shell .pd-metric,
.pd-shell .pd-status,
.pd-shell .pd-formula {
    background: var(--pd-panel);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius-sm);
}

.pd-shell .pd-score-card {
    align-items: baseline;
    display: grid;
    grid-template-columns: auto auto 1fr;
    padding: 1rem;
}

.pd-shell .pd-score-label {
    color: var(--pd-muted);
    font-size: 0.85rem;
    font-weight: 700;
    grid-column: 1 / -1;
}

.pd-shell .pd-score {
    color: var(--pd-accent-dark);
    font-size: 2.35rem;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin-top: 0.35rem;
}

.pd-shell .pd-score-suffix {
    color: var(--pd-muted);
    font-weight: 700;
    margin-left: 0.25rem;
}

.pd-shell .pd-score-card p {
    align-self: center;
    font-size: 0.82rem;
    grid-column: 1 / -1;
    margin-top: 0.55rem;
}

.pd-shell .pd-metrics {
    display: grid;
    gap: 0.7rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pd-shell .pd-metric {
    min-width: 0;
    padding: 0.85rem;
}

.pd-shell .pd-metric span {
    color: var(--pd-muted);
    display: block;
    font-size: 0.78rem;
    margin-bottom: 0.2rem;
}

.pd-shell .pd-metric strong {
    color: var(--pd-text);
    display: block;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.pd-shell .pd-status {
    border-left: 4px solid var(--pd-border);
    padding: 0.9rem 1rem;
}

.pd-shell .pd-status strong {
    display: block;
    margin-bottom: 0.25rem;
}

.pd-shell .pd-status[data-state="good"] {
    background: var(--pd-good-bg);
    border-left-color: var(--pd-good);
}

.pd-shell .pd-status[data-state="warning"] {
    background: var(--pd-warning-bg);
    border-left-color: var(--pd-warning);
}

.pd-shell .pd-status[data-state="danger"] {
    background: var(--pd-danger-bg);
    border-left-color: var(--pd-danger);
}

.pd-shell .pd-formula {
    max-width: 100%;
    overflow-x: auto;
    padding: 0.8rem 0.9rem;
    -webkit-overflow-scrolling: touch;
}

.pd-shell .pd-formula code {
    color: var(--pd-muted);
    font-family: var(--pd-mono);
    font-size: 0.78rem;
    white-space: nowrap;
}

.pd-shell .pd-note {
    border-top: 1px solid var(--pd-border);
    display: grid;
    gap: 0.45rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
}

.pd-shell .pd-note p {
    font-size: 0.82rem;
}

.pd-shell .pd-note strong {
    color: var(--pd-text);
}

@media (max-width: 820px) {
    .pd-shell .pd-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .pd-shell .pd-fields,
    .pd-shell .pd-metrics {
        grid-template-columns: 1fr;
    }

    .pd-shell .pd-field--wide {
        grid-column: auto;
    }

    /* Formel umbrechen statt horizontal scrollen */
    .pd-shell .pd-formula {
        overflow-x: visible;
    }

    .pd-shell .pd-formula code {
        overflow-wrap: anywhere;
        white-space: normal;
    }

    /* Randlos über die volle Breite – nur mit Modifier-Klasse aktiv,
       damit es in Themes ohne overflow-Kontrolle keinen H-Scroll gibt. */
    .pd-shell--bleed {
        border-left: 0;
        border-radius: 0;
        border-right: 0;
        margin-left: -1rem;
        margin-right: -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (prefers-color-scheme: dark) {
    .pd-shell--auto-dark {
        --pd-bg: #131a22;
        --pd-panel: #1b242e;
        --pd-text: #e8eef5;
        --pd-muted: #9fb0c0;
        --pd-border: #2c3945;
        --pd-accent: #6fb2dc;
        --pd-accent-dark: #9ccdec;
        --pd-accent-soft: #1d2c38;
        --pd-accent-rgb: 111, 178, 220;
        --pd-good: #7fd3a4;
        --pd-good-bg: #172a20;
        --pd-warning: #e2b95c;
        --pd-warning-bg: #2b2418;
        --pd-danger: #f09a9a;
        --pd-danger-bg: #2e1d1d;
        --pd-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    }
}

@media (forced-colors: active) {
    .pd-shell,
    .pd-shell .pd-input-wrap,
    .pd-shell .pd-score-card,
    .pd-shell .pd-metric,
    .pd-shell .pd-status,
    .pd-shell .pd-formula {
        border-color: CanvasText;
    }

    .pd-shell input:focus-visible,
    .pd-shell select:focus-visible,
    .pd-shell .pd-formula:focus-visible {
        outline: 3px solid CanvasText;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pd-shell *,
    .pd-shell *::before,
    .pd-shell *::after {
        scroll-behavior: auto;
        transition-duration: 0.01ms;
        animation-duration: 0.01ms;
        animation-iteration-count: 1;
    }
}

@media print {
    .pd-shell {
        border: 1px solid #999;
        box-shadow: none;
    }

    .pd-shell .pd-formula {
        overflow: visible;
    }

    .pd-shell .pd-formula code {
        white-space: normal;
    }
}
