/* ─────────────────────────────────────────────────────────────
   preisschild.css  –  Autowelt Trier
   Druckfertiges Preisschild (A4 hochkant) für Fahrzeug-Detailseiten.
   Wird von build.js in jede fahrzeug-*.html eingebunden.

   Aufbau:
     1. Knopf auf der Detailseite
     2. Overlay (Bildschirm-Vorschau)
     3. Das Blatt selbst (A4 hochkant)
     4. @media print – nur das Blatt kommt aufs Papier
   ───────────────────────────────────────────────────────────── */

:root {
    --ps-white:      #ffffff;
    --ps-off-white:  #f5f7fa;
    --ps-blue-tint:  #eaf2fc;
    --ps-border:     #dce2ea;
    --ps-text:       #0d1b2a;
    --ps-text-mid:   #445566;
    --ps-text-muted: #8899aa;
    --ps-blue:       #1b3f6e;
    --ps-blue-mid:   #2257a0;
}

/* ── 1. Knopf auf der Detailseite ──────────────────────────── */

.preisschild-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    width: 100%;
    margin-top: 1.25rem;
    padding: 1.1rem 2rem;
    background: var(--ps-blue);
    color: var(--ps-white);
    border: 2px solid var(--ps-blue);
    border-radius: 3px;
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.preisschild-btn:hover {
    background: var(--ps-blue-mid);
    border-color: var(--ps-blue-mid);
}

.preisschild-btn:focus-visible {
    outline: 3px solid var(--ps-blue-mid);
    outline-offset: 3px;
}

.preisschild-btn svg {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── 2. Overlay (Bildschirm-Vorschau) ──────────────────────── */

.ps-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(13, 27, 42, 0.74);
    /* Vorschau immer bis zum Blattfuß durchscrollbar */
    overflow-x: auto;
    overflow-y: scroll;
    overscroll-behavior: contain;
    padding: 1rem 1rem 4rem;
    -webkit-overflow-scrolling: touch;
}

.ps-overlay[hidden] {
    display: none;
}

.ps-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1rem;
    margin: -1rem -1rem 1.25rem;
    background: rgba(13, 27, 42, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.ps-toolbar-hinweis {
    flex: 1 1 100%;
    text-align: center;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.7);
}

.ps-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.8rem 1.6rem;
    border-radius: 3px;
    border: 2px solid transparent;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.ps-btn-print {
    background: var(--ps-white);
    color: var(--ps-blue);
    border-color: var(--ps-white);
}

.ps-btn-print:hover {
    background: var(--ps-blue-tint);
    border-color: var(--ps-blue-tint);
}

.ps-btn-close {
    background: transparent;
    color: var(--ps-white);
    border-color: rgba(255, 255, 255, 0.45);
}

.ps-btn-close:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--ps-white);
}

.ps-btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── 3. Das Blatt (A4 hochkant: 210 × 297 mm) ──────────────── */

/* Bühne: nur für die Bildschirm-Verkleinerung auf schmalen Geräten.
   Bleibt im Druck immer 1, damit sie den Passfaktor nicht verfälscht. */
.ps-buehne {
    zoom: 1;
}

/* Das Blatt bleibt gerendert immer exakt 210 × 297 mm.
   --ps-fit wird von preisschild.js verkleinert, wenn der Inhalt sonst
   nicht aufs Blatt passt: zoom verkleinert alles proportional, und
   width/height werden durch den Faktor geteilt, damit das Blatt
   trotzdem A4 groß bleibt. */
.ps-blatt {
    --ps-fit: 1;
    zoom: var(--ps-fit);
    width: calc(210mm / var(--ps-fit));
    min-height: calc(297mm / var(--ps-fit));
    margin: 0 auto;
    padding: 14mm 14mm 12mm;
    background: var(--ps-white);
    color: var(--ps-text);
    font-family: 'Inter', -apple-system, sans-serif;
    display: flex;
    flex-direction: column;
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.4);
}

/* Messzustand: kurz zugeschaltet, um den echten Platzbedarf zu ermitteln.
   Ohne feste Höhe und ohne den auto-Abstand über dem Preis. */
.ps-blatt.ps-messen {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
}

.ps-blatt.ps-messen .ps-preis {
    margin-top: 0 !important;
}

/* Kopf: Firmendaten */
.ps-kopf {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8mm;
    padding-bottom: 4mm;
    border-bottom: 2.5pt solid var(--ps-blue);
}

.ps-firma-name {
    font-size: 23pt;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.015em;
    color: var(--ps-blue);
}

.ps-firma-sub {
    margin-top: 1.5mm;
    font-size: 8pt;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ps-text-muted);
}

.ps-kontakt {
    text-align: right;
    font-size: 8.5pt;
    line-height: 1.6;
    color: var(--ps-text-mid);
    white-space: nowrap;
}

.ps-kontakt span {
    color: var(--ps-text-muted);
}

/* Titel: Marke, Modell, Ausführung */
.ps-titel {
    margin-top: 7mm;
}

.ps-titel h1 {
    margin: 0;
    font-size: 31pt;
    font-weight: 700;
    line-height: 1.06;
    letter-spacing: -0.022em;
    color: var(--ps-text);
}

.ps-variante {
    margin: 2.5mm 0 0;
    font-size: 11.5pt;
    font-weight: 400;
    line-height: 1.4;
    color: var(--ps-text-mid);
}

/* Mitte: Foto + technische Daten */
.ps-mitte {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7mm;
    align-items: start;
    margin-top: 7mm;
}

.ps-foto {
    margin: 0;
    border: 1pt solid var(--ps-border);
    background: var(--ps-blue-tint);
}

.ps-foto img {
    display: block;
    width: 100%;
    height: 76mm;
    object-fit: cover;
}

.ps-daten {
    width: 100%;
    border-collapse: collapse;
    font-size: 9.5pt;
}

.ps-daten th {
    width: 42%;
    padding: 1.6mm 0;
    text-align: left;
    font-weight: 500;
    color: var(--ps-text-mid);
}

.ps-daten td {
    padding: 1.6mm 0;
    text-align: right;
    font-weight: 600;
    color: var(--ps-text);
}

.ps-daten tr + tr th,
.ps-daten tr + tr td {
    border-top: 0.75pt solid var(--ps-border);
}

/* Abschnittstitel */
.ps-abschnitt-titel {
    margin: 0 0 2.5mm;
    padding-bottom: 1.5mm;
    border-bottom: 0.75pt solid var(--ps-border);
    font-size: 8pt;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ps-blue);
}

/* Ausstattung */
.ps-ausstattung {
    margin-top: 7mm;
}

.ps-ausstattung p {
    margin: 0;
    font-size: 9.5pt;
    line-height: 1.65;
    color: var(--ps-text-mid);
}

/* Preis – wird durch margin-top:auto an den Blattfuß geschoben */
.ps-preis {
    margin-top: auto;
    padding: 6mm 6mm 5mm;
    border-radius: 1mm;
    background: var(--ps-blue);
    color: var(--ps-white);
    text-align: center;
}

.ps-preis-label {
    font-size: 8pt;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
}

.ps-preis-wert {
    margin-top: 1.5mm;
    font-size: 42pt;
    font-weight: 700;
    line-height: 1.02;
    letter-spacing: -0.02em;
}

.ps-preis-hinweis {
    margin-top: 2.5mm;
    font-size: 8.5pt;
    color: rgba(255, 255, 255, 0.82);
}

/* Blattfuß */
.ps-fuss {
    margin-top: 4mm;
    text-align: center;
    font-size: 7.5pt;
    line-height: 1.5;
    color: var(--ps-text-muted);
}

/* Kleine Bildschirme: Blatt verkleinert anzeigen (nur Vorschau).
   Läuft über die Bühne, damit --ps-fit unberührt bleibt. */
@media screen and (max-width: 860px) {
    .ps-buehne {
        zoom: 0.56;
    }
}

@media screen and (max-width: 480px) {
    .ps-buehne {
        zoom: 0.42;
    }
}

/* ── 4. Druck: nur das Blatt kommt aufs Papier ─────────────── */

@page {
    size: A4 portrait;
    margin: 0;
}

@media print {

    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        background: var(--ps-white) !important;
        overflow: visible !important;
    }

    /* Navigation, Inhalt, Footer usw. vom Blatt nehmen */
    body > *:not(.ps-overlay) {
        display: none !important;
    }

    /* Overlay wird zum reinen Seiteninhalt – auch wenn es zu ist */
    .ps-overlay,
    .ps-overlay[hidden] {
        display: block !important;
        position: static !important;
        inset: auto !important;
        z-index: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        background: none !important;
        overflow: visible !important;
    }

    .ps-toolbar {
        display: none !important;
    }

    /* Bildschirm-Verkleinerung darf im Druck nicht mitwirken */
    .ps-buehne {
        zoom: 1 !important;
    }

    /* Gerendert exakt A4; der Passfaktor wird herausgerechnet, damit
       das Blatt trotz Verkleinerung die ganze Seite füllt. */
    .ps-blatt {
        width: calc(210mm / var(--ps-fit)) !important;
        height: calc(297mm / var(--ps-fit)) !important;
        min-height: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
        box-shadow: none !important;
        break-inside: avoid;
        page-break-inside: avoid;
        break-after: avoid;
        page-break-after: avoid;
    }

    /* Flächen und Farben mitdrucken */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
