/* ══════════════════════════════════════════════════
   dm-drogerie markt MCP — Modern CSS
   Layer order: reset → tokens → base → components → utilities → responsive
   ══════════════════════════════════════════════════ */

@layer reset, tokens, base, components, utilities, responsive;

/* ── Reset ───────────────────────────────────────── */
@layer reset {
    *, *::before, *::after { box-sizing: border-box; }
}

/* ── Tokens ──────────────────────────────────────── */
@layer tokens {
    @font-face {
        font-family: 'DMBrand';
        src: url('/static/fonts/DMBrand Light Font.woff2') format('woff2');
        font-weight: 300;
        font-style: normal;
        font-display: swap;
    }
    @font-face {
        font-family: 'DMBrand';
        src: url('/static/fonts/DMBrand Regular.woff2') format('woff2');
        font-weight: 400;
        font-style: normal;
        font-display: swap;
    }
    @font-face {
        font-family: 'DMBrand';
        src: url('/static/fonts/DMBrand Medium.woff2') format('woff2');
        font-weight: 500;
        font-style: normal;
        font-display: swap;
    }
    @font-face {
        font-family: 'DMBrand';
        src: url('/static/fonts/DMBrand Bold.woff2') format('woff2');
        font-weight: 700;
        font-style: normal;
        font-display: swap;
    }

    :root {
        /* ── Palette (dm-Theme) ── */
        --palette-headline-hex: #002878;
        --palette-cta-hex: #002878;
        --palette-text-hex: #525260;
        --palette-text-inactive-hex: #757580;
        --palette-text-success-hex: #268200;
        --palette-text-error-hex: #CF1322;
        --palette-background-hex: #FFFFFF;
        --palette-background-alternative-hex: #F6F6F7;
        --palette-background-info-hex: #E5E9F1;
        --palette-background-success-hex: #F6FFED;
        --palette-background-warning-hex: #FDF6E9;
        --palette-background-error-hex: #FDF2F2;
        --palette-border-hex: #E5E9F1;
        --palette-success-hex: #32A800;
        --palette-warning-hex: #e07000;
        --palette-error-hex: #D8241C;
        --palette-icon-inactive-hex: #94949d;

        /* ── Local (no dm-token) ── */
        --code-bg: #1e1e2e;
        --code-text: #cdd6f4;

        /* ── Spacing (dm-Theme) ── */
        --spacing-xxxs: 0.3125rem;
        --spacing-xxs: 0.625rem;
        --spacing-xs: 0.9375rem;
        --spacing-s: 1.25rem;
        --spacing-m: 1.5625rem;
        --spacing-l: 1.875rem;
        --spacing-xl: 2.5rem;
        --spacing-xxl: 3.125rem;

        /* ── Radius (dm-Theme) ── */
        --radius-xs: 0.125rem;
        --radius-s: 0.25rem;
        --radius-m: 0.375rem;
        --radius-l: 0.875rem;
        --radius-xl: 1.375rem;
        --radius-full: 999px;

        /* ── Typography (dm-Theme) ── */
        --font-family: dmbrand, Arial, Helvetica, sans-serif;
        --font-size-xxxl: 2.375rem;
        --font-size-xxl: 1.75rem;
        --font-size-xl: 1.375rem;
        --font-size-l: 1.125rem;
        --font-size-m: 1rem;
        --font-size-s: 0.875rem;
        --font-size-xs: 0.75rem;
        --line-height-xxxl: 1.1;
        --line-height-xxl: 1.15;
        --line-height-xl: 1.18;
        --line-height-l: 1.33;
        --line-height-m: 1.25;
        --line-height-s: 1.29;
        --line-height-xs: 1.33;

        /* ── Z-Index (dm-Theme) ── */
        --z-sticky: 1100;

        /* ── Shadow (dm-Theme) ── */
        --shadow-box: 1px 1px 3px 2px rgba(0, 0, 0, 0.1);
    }

    /* ── Dark Mode ── */
    :root[data-theme="dark"] {
        --palette-headline-hex: #a8b8e0;
        --palette-cta-hex: #6b8adb;
        --palette-text-hex: #c8c8d4;
        --palette-text-inactive-hex: #9898a8;
        --palette-text-success-hex: #5cb85c;
        --palette-text-error-hex: #e57373;
        --palette-background-hex: #1a1a2e;
        --palette-background-alternative-hex: #22223a;
        --palette-background-info-hex: #252545;
        --palette-background-success-hex: #1a2e1a;
        --palette-background-warning-hex: #2e2a1a;
        --palette-background-error-hex: #2e1a1a;
        --palette-border-hex: #3a3a55;
        --palette-success-hex: #4caf50;
        --palette-warning-hex: #ff9800;
        --palette-error-hex: #ef5350;
        --palette-icon-inactive-hex: #6a6a7a;
        --shadow-box: 1px 1px 3px 2px rgba(0, 0, 0, 0.3);
    }
}

/* ── Base ────────────────────────────────────────── */
@layer base {
    body {
        font-family: var(--font-family);
        line-height: var(--line-height-l);
        color: var(--palette-text-hex);
        margin: 0;
        padding: 0;
        background-color: var(--palette-background-hex);
        -webkit-font-smoothing: antialiased;
    }

    h2 {
        color: var(--palette-headline-hex);
        font-size: var(--font-size-xxl);
        font-weight: 700;
        margin-block: var(--spacing-l) var(--spacing-xxs);
        padding-block-end: 0;
        border-block-end: none;
    }

    h3 {
        color: var(--palette-headline-hex);
        font-size: var(--font-size-l);
        font-weight: 500;
        margin-block: var(--spacing-m) var(--spacing-xxs);
    }

    p {
        color: var(--palette-text-hex);
        margin-block: 0 var(--spacing-xs);
    }

    code {
        background: var(--palette-background-alternative-hex);
        padding: 2px 8px;
        border-radius: var(--radius-s);
        font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
        font-size: var(--font-size-s);
        color: var(--palette-cta-hex);
    }

    table {
        border-collapse: collapse;
        inline-size: 100%;
    }

    th {
        background: var(--palette-background-alternative-hex);
        color: var(--palette-headline-hex);
        padding: var(--spacing-s) var(--spacing-m);
        text-align: start;
        font-weight: 500;
        font-size: var(--font-size-s);
        text-transform: uppercase;
        letter-spacing: 0.03em;
        border-block-end: 1px solid var(--palette-border-hex);
    }

    td {
        padding: var(--spacing-s) var(--spacing-m);
        border-block-end: 1px solid color-mix(in srgb, var(--palette-border-hex) 60%, var(--palette-background-hex));
        vertical-align: top;
        font-size: var(--font-size-s);
    }

    :where(tr:last-child) td {
        border-block-end: none;
    }

    tr:hover {
        background: var(--palette-background-alternative-hex);
    }
}

/* ── Components ──────────────────────────────────── */
@layer components {

    /* Meta Navigation */
    .meta-nav {
        background-color: var(--palette-background-alternative-hex);
        padding: var(--spacing-xs) max(24px, calc(50% - 456px));
        font-size: var(--font-size-s);
        text-align: end;
        border-block-end: 1px solid var(--palette-border-hex);
        display: flex;
        justify-content: flex-end;
        gap: var(--spacing-xl);

        & a {
            color: var(--palette-cta-hex);
            text-decoration: none;
            font-weight: 400;
            transition: color 0.15s;

            &:hover {
                color: color-mix(in srgb, var(--palette-cta-hex) 70%, black);
            }
        }
    }

    /* Header */
    header {
        background-color: var(--palette-background-hex);
        color: var(--palette-headline-hex);
        padding: 14px max(24px, calc(50% - 456px));
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-shadow: var(--shadow-box);
        position: sticky;
        inset-block-start: 0;
        z-index: var(--z-sticky);

        & h1 {
            margin: 0;
            font-size: var(--font-size-l);
            color: var(--palette-headline-hex);
            font-weight: 500;
            letter-spacing: -0.01em;
        }
    }

    .logo-container {
        display: flex;
        align-items: center;
        gap: var(--spacing-s);
    }

    .dm-logo {
        block-size: 36px;
    }

    :root[data-theme="dark"] .dm-logo path[fill="#FFF"] {
        fill: var(--palette-background-hex);
    }

    /* Container */
    .container {
        max-inline-size: 960px;
        margin-inline: auto;
        padding: 32px 24px 48px;
    }

    /* Hero Section */
    .hero-section {
        padding-block: 40px 32px;
        margin-block-end: var(--spacing-xxs);
    }

    .hero-title {
        font-size: var(--font-size-xxxl);
        color: var(--palette-headline-hex);
        font-weight: 700;
        margin: 0 0 var(--spacing-xs);
        letter-spacing: -0.02em;
        line-height: var(--line-height-xxxl);
    }

    .hero-subtitle {
        font-size: var(--font-size-l);
        color: var(--palette-text-inactive-hex);
        max-inline-size: 600px;
        line-height: var(--line-height-l);
        margin: 0;
        font-weight: 400;
    }

    /* Banners */
    .banner {
        padding: var(--spacing-m);
        border-radius: var(--radius-l);
        display: flex;
        align-items: flex-start;
        gap: var(--spacing-xs);
        margin-block: var(--spacing-s);
        font-size: var(--font-size-m);
        line-height: 1.6;
    }

    .banner-highlight {
        padding: var(--spacing-l);
        border-radius: var(--radius-xl);

        & strong {
            font-size: var(--font-size-xxl);
            display: block;
            margin-block-end: var(--spacing-xs);
            color: var(--palette-text-hex);
        }
    }

    .banner-icon {
        flex-shrink: 0;
        inline-size: 24px;
        block-size: 24px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-block-start: 2px;

        & svg {
            inline-size: 14px;
            block-size: 14px;
        }
    }

    .banner-info {
        background-color: var(--palette-background-info-hex);

        & .banner-icon {
            background-color: var(--palette-cta-hex);
            color: white;
        }
    }

    .banner-success {
        background-color: var(--palette-background-success-hex);

        & .banner-icon {
            background-color: var(--palette-success-hex);
            color: white;
        }
    }

    .banner-warning {
        background-color: var(--palette-background-warning-hex);

        & .banner-icon {
            background-color: var(--palette-warning-hex);
            color: white;
        }
    }

    .banner-error {
        background-color: var(--palette-background-error-hex);

        & .banner-icon {
            background-color: var(--palette-error-hex);
            color: white;
        }
    }

    /* Cards */
    .card {
        background: var(--palette-background-hex);
        border: 1px solid var(--palette-border-hex);
        border-radius: var(--radius-l);
        padding: var(--spacing-m) var(--spacing-m) var(--spacing-s);
        transition: box-shadow 0.2s, transform 0.2s;
        display: flex;
        flex-direction: column;
        gap: var(--spacing-xxs);

        &:hover {
            box-shadow: 0 8px 24px color-mix(in srgb, var(--palette-cta-hex) 8%, transparent);
            transform: translateY(-2px);
        }

        & h3 {
            margin: 0;
            color: var(--palette-headline-hex);
            font-size: var(--font-size-l);
            font-weight: 500;
        }

        & p {
            margin: 0;
            font-size: var(--font-size-s);
            color: var(--palette-text-inactive-hex);
            line-height: 1.6;
        }
    }

    /* Service Grid */
    .service-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: var(--spacing-s);
        margin-block-start: var(--spacing-s);
    }

    /* Table Card */
    .table-card {
        background: var(--palette-background-hex);
        border-radius: var(--radius-m);
        overflow: hidden;
        border: 1px solid var(--palette-border-hex);
        margin-block-start: var(--spacing-s);
    }

    .table-card-header {
        padding: var(--spacing-s) var(--spacing-m);
        background: var(--palette-cta-hex);
        color: var(--palette-background-hex);

        & h3 {
            margin: 0;
            font-size: var(--font-size-m);
            font-weight: 500;
            color: var(--palette-background-hex);
        }
    }

    /* Code Block */
    .code-block {
        position: relative;
        margin-block: var(--spacing-s);
    }

    pre {
        background: var(--code-bg);
        color: var(--code-text);
        padding: var(--spacing-m);
        border-radius: var(--radius-m);
        overflow-x: auto;
        border: none;
        font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
        font-size: var(--font-size-s);
        line-height: var(--line-height-l);
    }

    .copy-btn {
        position: absolute;
        inset-block-start: var(--spacing-s);
        inset-inline-end: var(--spacing-s);
        background: color-mix(in srgb, white 8%, transparent);
        border: 1px solid color-mix(in srgb, white 12%, transparent);
        border-radius: var(--radius-s);
        padding: 6px 8px;
        cursor: pointer;
        color: color-mix(in srgb, white 50%, transparent);
        transition: all 0.15s;
        display: flex;
        align-items: center;
        gap: 4px;

        &:hover {
            background: color-mix(in srgb, white 15%, transparent);
            color: color-mix(in srgb, white 90%, transparent);
        }

        &.copied {
            background: var(--palette-success-hex);
            color: white;
            border-color: var(--palette-success-hex);
        }
    }

    .instruction-pre {
        background: var(--palette-background-alternative-hex);
        border-inline-start: 4px solid var(--palette-cta-hex);
        border-radius: var(--radius-s);
        padding: var(--spacing-m);
        font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
        font-size: var(--font-size-s);
        color: var(--palette-text-hex);
        white-space: pre-wrap;
        line-height: 1.6;
        margin-block: var(--spacing-m);
    }

    /* Hint Text */
    .hint-text {
        font-size: var(--font-size-xs);
        color: var(--palette-text-inactive-hex);
        margin-block-start: calc(-1 * var(--spacing-xxs));
    }

    /* Buttons */
    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: var(--spacing-xs);
        padding: 12px 32px;
        border-radius: var(--radius-full);
        font-family: inherit;
        font-size: var(--font-size-m);
        font-weight: 500;
        cursor: pointer;
        transition: all 0.15s;
        text-decoration: none;
        border: 2px solid transparent;
    }

    .btn-primary {
        background: var(--palette-cta-hex);
        color: var(--palette-background-hex);
        border-color: var(--palette-cta-hex);

        &:hover {
            background: color-mix(in srgb, var(--palette-cta-hex) 85%, black);
            border-color: color-mix(in srgb, var(--palette-cta-hex) 85%, black);
        }
    }

    .btn-secondary {
        background: transparent;
        color: var(--palette-cta-hex);
        border-color: var(--palette-cta-hex);

        &:hover {
            background: var(--palette-background-alternative-hex);
        }
    }

    /* Legend */
    .legend {
        margin-block: var(--spacing-m);
        padding: var(--spacing-m);
        background: var(--palette-background-alternative-hex);
        border-radius: var(--radius-m);
        border: 1px solid var(--palette-border-hex);
    }

    .legend-item {
        margin-inline-start: var(--spacing-xs);
        font-size: var(--font-size-s);
    }

    .legend-ready { color: var(--palette-text-success-hex); }
    .legend-not-ready { color: var(--palette-icon-inactive-hex); }

    .tool-list {
        margin: 0;
        padding-inline-start: var(--spacing-m);
        font-size: var(--font-size-s);
    }
    .tool-allowed { color: var(--palette-text-success-hex); }
    .tool-restricted { color: var(--palette-icon-inactive-hex); }
    .tool-none { color: var(--palette-icon-inactive-hex); font-style: italic; }

    /* Footer */
    footer {
        background-color: var(--palette-cta-hex);
        color: white;
        padding: 32px 24px;
        text-align: center;
        margin-block-start: 48px;

        & a {
            color: color-mix(in srgb, white 85%, var(--palette-cta-hex));
            text-decoration: none;
            margin-inline: 12px;
            font-size: var(--font-size-s);
            transition: color 0.15s;

            &:hover {
                color: white;
            }
        }

        & p {
            margin-block: 6px;
            color: white;
        }
    }

    .footer-copyright {
        font-weight: 500;
        font-size: var(--font-size-s);
        margin-block-end: 10px !important;
    }

    .footer-made-with {
        margin-block-start: 16px;
        opacity: 0.7;
        font-size: var(--font-size-xs);
    }

    /* Theme Toggle */
    .theme-toggle {
        background: var(--palette-background-alternative-hex);
        border: 1px solid var(--palette-border-hex);
        border-radius: var(--radius-full);
        padding: 6px 10px;
        cursor: pointer;
        color: var(--palette-text-hex);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.15s, color 0.15s;

        &:hover {
            background: var(--palette-background-info-hex);
            color: var(--palette-headline-hex);
        }

        & svg {
            inline-size: 18px;
            block-size: 18px;
        }
    }
}

/* ── Utilities ───────────────────────────────────── */
@layer utilities {
    .badge {
        padding: 3px 12px;
        border-radius: var(--radius-full);
        font-size: var(--font-size-xs);
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.02em;
    }

    .badge-ok {
        background-color: var(--palette-background-success-hex);
        color: var(--palette-text-success-hex);
    }

    .badge-down {
        background-color: var(--palette-background-error-hex);
        color: var(--palette-text-error-hex);
    }

    .link-primary {
        color: var(--palette-cta-hex);
        font-weight: 500;
        text-decoration: none;
        transition: color 0.15s;

        &:hover {
            text-decoration: underline;
        }
    }

    .section-divider {
        border: none;
        border-block-start: 1px solid var(--palette-border-hex);
        margin-block: var(--spacing-l) 0;
    }
}

/* ── Responsive ──────────────────────────────────── */
@layer responsive {
    @media (max-width: 600px) {
        .hero-title { font-size: 2rem; }
        .hero-section { padding-block: 48px 40px; }
        .container { padding: 32px 16px 48px; }
        header { padding: 12px 16px; }
        .service-grid { grid-template-columns: 1fr; }
    }
}
