/* Heulomat – moderner Automat mit amtlicher Bescheinigung */

.heul-page { max-width: 980px; margin-inline: auto; }

.heul-intro { text-align: center; margin-bottom: clamp(26px, 4vw, 40px); }
.heul-intro h1 { font-size: clamp(2.6rem, 6vw, 4.2rem); }
.heul-intro p { margin: 10px auto 0; max-width: 46ch; color: var(--ink-soft); font-size: 1.15rem; }

/* ---------- Gehäuse ---------- */

.machine {
    --alu: #e9edee;
    --alu-dark: #c9d1d3;
    --panel: #20262f;
    position: relative;
    padding: clamp(14px, 2.4vw, 24px);
    border-radius: 34px;
    background:
        repeating-linear-gradient(90deg, rgba(255,255,255,.5) 0 1px, transparent 1px 4px),
        linear-gradient(180deg, #f7f9f9, var(--alu) 40%, #dde3e4);
    box-shadow:
        inset 0 2px 0 #fff,
        inset 0 -6px 0 var(--alu-dark),
        0 2px 2px rgba(29,36,48,.08),
        0 30px 60px -28px rgba(29,36,48,.45),
        0 60px 80px -60px rgba(29,36,48,.4);
}

.machine__marquee {
    display: flex;
    justify-content: center;
    gap: clamp(4px, 1vw, 12px);
    padding: clamp(14px, 2.4vw, 22px) 16px;
    margin-bottom: clamp(12px, 2vw, 20px);
    border-radius: 22px;
    background: linear-gradient(180deg, #fff, #f1f4f4);
    box-shadow: inset 0 0 0 1px rgba(29,36,48,.08), inset 0 -3px 0 rgba(29,36,48,.06);
    font-family: var(--font-display);
    font-size: clamp(2rem, 6.4vw, 4rem);
    line-height: 1;
}
.machine__marquee span { color: var(--c); text-shadow: 0 3px 0 var(--d), 0 0 22px color-mix(in srgb, var(--c) 45%, transparent); }
.machine__marquee span:nth-child(6n+1) { --c: var(--cobalt); --d: var(--cobalt-dark); }
.machine__marquee span:nth-child(6n+2) { --c: var(--tomato); --d: var(--tomato-dark); }
.machine__marquee span:nth-child(6n+3) { --c: var(--sun); --d: var(--sun-dark); }
.machine__marquee span:nth-child(6n+4) { --c: var(--mint); --d: var(--mint-dark); }
.machine__marquee span:nth-child(6n+5) { --c: var(--magenta); --d: var(--magenta-dark); }
.machine__marquee span:nth-child(6n+6) { --c: var(--orange); --d: var(--orange-dark); }
@media (prefers-reduced-motion: no-preference) {
    .machine__marquee span { animation: marquee-glow 3.2s ease-in-out infinite; animation-delay: calc(var(--i, 0) * 120ms); }
    .machine__marquee span:nth-child(2) { --i: 1; } .machine__marquee span:nth-child(3) { --i: 2; } .machine__marquee span:nth-child(4) { --i: 3; }
    .machine__marquee span:nth-child(5) { --i: 4; } .machine__marquee span:nth-child(6) { --i: 5; } .machine__marquee span:nth-child(7) { --i: 6; } .machine__marquee span:nth-child(8) { --i: 7; }
    @keyframes marquee-glow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.12) saturate(1.1); } }
}

.machine__body { position: relative; }
.machine__form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: clamp(12px, 2vw, 20px);
}

/* Sichtfenster */
.machine__window {
    position: relative;
    min-height: 340px;
    padding: clamp(22px, 3.6vw, 40px);
    border-radius: 22px;
    background: linear-gradient(160deg, #ffffff, #f4f8f8 60%, #eaf1f1);
    box-shadow:
        inset 0 0 0 1px rgba(29,36,48,.1),
        inset 0 8px 18px -10px rgba(29,36,48,.25);
    overflow: hidden;
}
.machine__window::after {
    /* Glasspiegelung */
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 0 68%, rgba(255,255,255,.75) 68% 76%, transparent 76% 80%, rgba(255,255,255,.5) 80% 82%, transparent 82%);
    opacity: .6;
    pointer-events: none;
}
.machine__window > * { position: relative; z-index: 1; }

.machine__progress {
    margin: 0 0 18px;
    font-weight: 800;
    font-size: .9rem;
    letter-spacing: .08em;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
}
.js .machine__progress { display: block; }
.machine__progress { display: none; }

.questions { list-style: none; margin: 0; padding: 0; display: grid; gap: 30px; }
.question fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.question legend {
    padding: 0;
    margin-bottom: 22px;
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3.2vw, 2.2rem);
    line-height: 1.12;
    color: var(--ink);
    text-wrap: balance;
}
.question__no {
    display: block;
    margin-bottom: 8px;
    font-family: var(--font-body);
    font-size: .9rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--cobalt-dark);
}

/* Mit JS: immer nur eine Frage im Fenster */
.js .questions { display: block; }
.js .question { display: none; }
.js .question.is-current { display: block; }
@media (prefers-reduced-motion: no-preference) {
    .js .question.is-current { animation: q-in .5s var(--ease-out) both; }
    @keyframes q-in { from { transform: translateY(18px); opacity: .001; filter: blur(4px); } to { transform: none; opacity: 1; filter: none; } }
}

/* Große Automaten-Tasten */
.answer-keys { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 2vw, 18px); max-width: 520px; }
.key { position: relative; display: block; cursor: pointer; }
.key input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.key span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 84px;
    border-radius: 20px;
    font-family: var(--font-display);
    font-size: clamp(1.7rem, 3.6vw, 2.3rem);
    letter-spacing: .04em;
    color: #fff;
    background: radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,.35), transparent 55%), var(--k);
    box-shadow:
        inset 0 -6px 0 var(--k-dark),
        0 8px 0 -2px color-mix(in srgb, var(--k-dark) 70%, #000),
        0 16px 22px -10px rgba(29,36,48,.55);
    transform: translateY(0);
    transition: transform .12s ease-out, box-shadow .12s ease-out, filter .2s;
    user-select: none;
}
.key--yes { --k: var(--mint); --k-dark: var(--mint-dark); }
.key--no { --k: var(--tomato); --k-dark: var(--tomato-dark); }
.key:hover span { filter: brightness(1.06); }
.key input:focus-visible + span { outline: 3px solid var(--cobalt); outline-offset: 4px; }
.key input:checked + span,
.key span:active {
    transform: translateY(6px);
    box-shadow: inset 0 -2px 0 var(--k-dark), 0 2px 0 -1px color-mix(in srgb, var(--k-dark) 70%, #000), 0 6px 10px -6px rgba(29,36,48,.5);
}
.key input:checked + span { box-shadow: inset 0 -2px 0 var(--k-dark), 0 0 0 4px #fff, 0 0 0 7px var(--k), 0 6px 10px -6px rgba(29,36,48,.5); }

.consent {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 18px;
    margin-bottom: 22px;
    border-radius: 14px;
    background: #fff6d6;
    color: var(--ink-soft);
    font-size: .95rem;
    cursor: pointer;
}
.consent strong { display: block; color: var(--ink); margin-bottom: 4px; }
.consent input { width: 22px; height: 22px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--cobalt-dark); }
.machine__go { width: 100%; min-height: 58px; font-size: 1.12rem; }

/* Bedienfeld rechts */
.machine__panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    padding: 20px 18px;
    border-radius: 22px;
    background: linear-gradient(180deg, #2a313b, var(--panel));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08), inset 0 -4px 0 rgba(0,0,0,.35);
    color: #c8d3d6;
}
.lcd {
    margin: 0;
    padding: 14px 12px;
    border-radius: 10px;
    background:
        repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px),
        #0f2a22;
    box-shadow: inset 0 2px 8px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.06);
    color: #6ef2c0;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-align: center;
    text-shadow: 0 0 8px rgba(110, 242, 192, .7);
    min-height: 48px;
    display: flex; align-items: center; justify-content: center;
}
.lcd.is-busy span::after { content: ""; animation: dots 1s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.leds { display: flex; justify-content: center; gap: 10px; }
.led {
    width: 14px; height: 14px; border-radius: 50%;
    background: #3a434f;
    box-shadow: inset 0 1px 2px rgba(0,0,0,.6);
    transition: background-color .3s, box-shadow .3s;
}
.led.is-on { background: var(--sun); box-shadow: 0 0 10px var(--sun), inset 0 -2px 0 var(--sun-dark); }
.led.is-current { background: #8a95a3; }
.coin {
    align-self: center;
    width: 64px; height: 92px;
    border-radius: 14px;
    background: linear-gradient(180deg, #3a424d, #2b323b);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 2px 0 rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center;
}
.coin span { width: 6px; height: 46px; border-radius: 3px; background: #0b0e12; box-shadow: inset 0 0 4px #000, 0 1px 0 rgba(255,255,255,.08); }
.machine__label {
    margin: auto 0 0;
    text-align: center;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #8996a3;
}

/* Ergebnisfenster */
.machine__window--result { min-height: 0; text-align: center; display: grid; gap: 14px; justify-items: center; }
.lcd--big { font-size: clamp(1.2rem, 3.6vw, 2rem); padding: 22px 28px; width: min(100%, 560px); }
.machine__hint { margin: 0; color: var(--ink-soft); font-weight: 600; }

/* ---------- Ausgabefach ---------- */

.machine__tray {
    position: relative;
    margin-top: clamp(14px, 2.4vw, 22px);
    padding: 0 clamp(8px, 3vw, 40px) clamp(14px, 2.4vw, 24px);
    border-radius: 22px;
    background: linear-gradient(180deg, #d5dcde, #e4e9ea 30%);
    box-shadow: inset 0 10px 18px -10px rgba(29,36,48,.5);
}
.machine__slot {
    height: 26px;
    margin: 0 auto 0;
    width: 88%;
    border-radius: 0 0 14px 14px;
    background: linear-gradient(180deg, #11151b, #2b323b);
    box-shadow: inset 0 -2px 0 rgba(255,255,255,.08);
}
.machine:not(.machine--done) .machine__tray { padding-bottom: 18px; }

.tray-out { position: relative; margin-top: -8px; }
@media (prefers-reduced-motion: no-preference) {
    .tray-out { animation: print-out 1.6s var(--ease-out) .3s both; }
    @keyframes print-out {
        from { clip-path: inset(0 0 100% 0); transform: translateY(-30px); }
        to { clip-path: inset(0 0 -40px 0); transform: none; }
    }
}

.tray-out--sad {
    padding: clamp(24px, 4vw, 40px);
    background: var(--paper);
    border-radius: 4px;
    box-shadow: var(--shadow-print);
    text-align: center;
}
.tray-out--sad h2 { font-size: clamp(1.5rem, 3.4vw, 2.2rem); margin-bottom: 20px; }
.tray-out--sad img { max-height: 300px; width: auto; margin-inline: auto; border-radius: 8px; }

/* ---------- Zertifikat ---------- */

.certificate {
    position: relative;
    max-width: 800px;
    margin-inline: auto;
    padding: clamp(36px, 7vw, 72px) clamp(26px, 7vw, 76px) clamp(30px, 5vw, 52px);
    background:
        radial-gradient(120% 80% at 50% 0%, #fbfdf9, #f2f6ee);
    color: #1d2430;
    box-shadow: var(--shadow-print);
    border-radius: 2px;
    overflow: hidden;
}
.cert-guilloche { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.certificate > :not(svg) { position: relative; }

.cert-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1.5px solid #2f6b5a;
    text-align: left;
}
.cert-crest { width: 52px; height: auto; flex-shrink: 0; }
.cert-authority { margin: 0; font-weight: 800; font-size: clamp(.95rem, 2.2vw, 1.2rem); letter-spacing: .06em; text-transform: uppercase; }
.cert-dept { margin: 2px 0 0; font-size: .88rem; color: #3f4a57; }

.cert-ref {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 14px 0 0;
    font-size: .82rem;
}
.cert-ref div { display: flex; gap: 6px; }
.cert-ref dt { color: #56606c; }
.cert-ref dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .04em; }

.cert-title {
    margin-top: clamp(22px, 4vw, 34px);
    text-align: center;
    font-size: clamp(2.6rem, 7vw, 4.4rem);
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #20473c;
}
.cert-sub { margin: 6px 0 0; text-align: center; font-weight: 700; letter-spacing: .04em; color: #3f4a57; }

.cert-body {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: clamp(18px, 4vw, 34px);
    align-items: start;
    margin-top: clamp(24px, 4vw, 36px);
}
.cert-photo {
    padding: 6px 6px 4px;
    background: #fff;
    border: 1px solid #c7d0cb;
    text-align: center;
    transform: rotate(-2deg);
}
.cert-photo img { width: 100%; aspect-ratio: 35 / 45; object-fit: contain; background: #eef2ef; filter: grayscale(1) contrast(1.05); }
.cert-photo span { display: block; margin-top: 3px; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: #6b7584; }
.cert-text p { margin: 0 0 10px; font-size: 1.05rem; }
.cert-small { font-size: .8rem !important; color: #56606c; font-style: italic; }
.cert-verdict {
    margin-top: 18px !important;
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3.6vw, 2.1rem) !important;
    line-height: 1.1;
    color: #1f4fae;
}

.cert-foot {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 24px;
    align-items: end;
    margin-top: clamp(30px, 6vw, 56px);
}
.cert-line { display: block; padding-bottom: 4px; border-bottom: 1px solid #1d2430; font-size: .95rem; }
.cert-foot small { display: block; margin-top: 4px; font-size: .75rem; color: #56606c; letter-spacing: .06em; text-transform: uppercase; }
.cert-sign { text-align: center; }
.cert-sign svg { width: 70%; height: auto; margin: 0 auto -16px; display: block; }
.cert-sign small { font-weight: 800; color: #1d2430; }
.cert-stamp {
    width: clamp(104px, 17vw, 136px);
    margin-bottom: -10px;
    transform: rotate(-14deg);
    mix-blend-mode: multiply;
}
@media (prefers-reduced-motion: no-preference) {
    .cert-stamp { animation: stamp .5s cubic-bezier(.2, 1.6, .4, 1) 1.8s both; }
    @keyframes stamp { from { transform: rotate(-14deg) scale(2.2); opacity: 0; } to { transform: rotate(-14deg) scale(1); opacity: 1; } }
}
.cert-micro {
    margin: clamp(26px, 4vw, 38px) 0 0;
    text-align: center;
    font-size: .68rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #6b7a72;
}

.cert-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 26px;
}

/* ---------- Statistik ---------- */

.stats { margin-top: clamp(56px, 8vw, 96px); }
.stats h2 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); margin-bottom: 26px; }
.stats__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
.stats__list p { margin: 0 0 10px; font-weight: 700; }
.bar { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--door-shade); }
.bar__yes, .bar__no { width: var(--w); transition: width 1s var(--ease-out); }
.bar__yes { background: var(--mint); }
.bar__no { background: var(--tomato); }
.bar__legend { display: flex; justify-content: space-between; margin-top: 6px; font-size: .85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar__legend span:first-child { color: var(--mint-dark); }
.bar__legend span:last-child { color: var(--tomato-dark); }

/* ---------- Responsiv ---------- */

@media (max-width: 760px) {
    .machine { border-radius: 26px; }
    .machine__form { grid-template-columns: 1fr; }
    .machine__panel { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 14px; gap: 12px; }
    .machine__panel .lcd { flex: 1 1 100%; }
    .machine__panel .coin, .machine__label { display: none; }
    .machine__panel .leds { flex: 1; }
    .machine__window { min-height: 0; }
    .key span { min-height: 72px; }
    .cert-body { grid-template-columns: 1fr; justify-items: center; text-align: center; }
    .cert-photo { width: 110px; }
    .cert-foot { grid-template-columns: 1fr; text-align: center; }
    .cert-stamp { justify-self: center; margin: -6px 0 -4px; }
    .cert-ref { flex-direction: column; gap: 2px; align-items: center; }
    .cert-head { flex-direction: column; text-align: center; }
}

/* Druck: nur die Urkunde */
@media print {
    .heul-intro, .machine__marquee, .machine__body, .machine__slot, .cert-actions, .stats { display: none !important; }
    .machine, .machine__tray { background: none !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; }
    .tray-out { animation: none !important; }
    .certificate { box-shadow: none; max-width: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    .cert-stamp { animation: none !important; }
    @page { size: A4 portrait; margin: 10mm; }
}
