/* --- Hinweis zu :hover ---
   Alle :hover-Regeln in dieser Datei stehen in
   @media (hover: hover) and (pointer: fine). Ohne diese Abfrage bleibt auf
   Touch der Hover-Zustand nach dem ersten Tippen kleben. */

/* ============================================
   BILD-WERKZEUGE
   Nur das Eigene — Karte, Stufen, Drop-Zone, Knöpfe und
   Toasts kommen aus ../converter/converter.css.
   ============================================ */

/* Marken-Symbol (Bilderrahmen) in der Kopfzeile — gleiche Machart wie
   .yk-brand-icon (Yoink): Emoji mit blauem Schein, Bewegung nur über
   transform. `color` faerbt ein Emoji nicht und faellt deshalb weg. */
.bl-brand-icon {
    font-size: 1.1rem;
    line-height: 1;
    display: inline-block;
    filter: drop-shadow(0 0 10px rgba(41, 151, 255, 0.5));
    animation: blRahmen 3.6s ease-in-out infinite;
}
@keyframes blRahmen {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50%      { transform: scale(1.1) rotate(2.5deg); }
}
@media (prefers-reduced-motion: reduce) {
    .bl-brand-icon { animation: none; }
}

/* --- Arbeitsfläche: Steuerung links, Bild rechts --- */
.bl-work {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    align-items: start;
}
@media (max-width: 860px) {
    .bl-work { grid-template-columns: 1fr; gap: 1.4rem; }
    /* Auf dem Handy zuerst das Bild: beim Zuschneiden zieht man darin den
       Ausschnitt auf, und bei allem anderen sieht man sofort die Wirkung. */
    .bl-stage-out { order: -1; }
}

/* --- Steuerelemente --- */
.bl-field {
    display: block;
    margin-bottom: 1rem;
}
.bl-field > span {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}
.bl-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin-top: 0.35rem;
    text-transform: none;
    letter-spacing: 0;
}
.bl-input {
    width: 100%;
    font-family: var(--font-body);
    font-size: 0.98rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    min-height: 42px;
    transition: border-color 0.3s ease, background 0.3s ease;
}
[data-theme="light"] .bl-input { background: rgba(0, 0, 0, 0.03); }
.bl-input:focus { border-color: var(--primary); outline: none; }

.bl-row { display: flex; gap: 0.8rem; }
.bl-row > .bl-field { flex: 1 1 0; min-width: 0; }

.bl-check {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 1rem;
    cursor: pointer;
}
.bl-check input { flex: none; width: 18px; height: 18px; accent-color: var(--primary); }

.bl-color {
    width: 100%;
    height: 42px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
}

.bl-range {
    flex: 1;
    width: 100%;
    accent-color: var(--primary);
    /* Der Standard-Schieber ist auf Touch nur wenige Pixel hoch. */
    height: 26px;
}
.bl-range-row { display: flex; align-items: center; gap: 0.7rem; }
.bl-range-val {
    flex: none;
    min-width: 3.4em;
    text-align: right;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

/* --- Knopfreihe statt Auswahlliste, wo es wenige Werte sind --- */
.bl-choice {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.bl-choice-btn {
    appearance: none;
    padding: 0.45rem 0.8rem;
    min-height: 38px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.3s ease, border-color 0.3s ease, background 0.3s ease, transform 0.3s cubic-bezier(0.16,1,0.3,1);
    -webkit-tap-highlight-color: transparent;
}
[data-theme="light"] .bl-choice-btn { background: rgba(0, 0, 0, 0.03); }
.bl-choice-btn.active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(41, 151, 255, 0.32);
}
@media (hover: hover) and (pointer: fine) {
    .bl-choice-btn:not(.active):hover {
        color: var(--text);
        border-color: rgba(41, 151, 255, 0.35);
        transform: translateY(-1px);
    }
}

/* --- Erklärtexte in der Steuerung --- */
.bl-note {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.2rem;
}
.bl-warn {
    font-size: 0.85rem;
    color: #ff9f0a;
    line-height: 1.5;
    margin-bottom: 1rem;
}
.bl-info {
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: rgba(48, 209, 88, 0.1);
    border: 1px solid rgba(48, 209, 88, 0.28);
    font-size: 0.9rem;
    line-height: 1.55;
    margin-bottom: 1rem;
}
.bl-info:empty { display: none; }
.bl-info strong { color: var(--text); }
.bl-info-sub {
    margin-top: 0.4rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* --- Bild-Vorschau --- */
.bl-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    min-height: 260px;
    overflow: hidden;
}
[data-theme="light"] .bl-preview { background: rgba(0, 0, 0, 0.02); }
/* Der Rahmen muss sich exakt an das Bild schmiegen: der Zuschnitt-Kasten
   wird in Prozent davon gesetzt. Darum inline-block statt Blockbreite.
   Und weil er genau so groß ist wie das Bild, gehört das Schachbrett hierhin
   und nicht auf den Kasten drumherum — sonst sieht ein deckendes Bild aus,
   als hätte es durchsichtige Ränder. */
.bl-canvas-wrap {
    position: relative;
    display: inline-block;
    line-height: 0;
    max-width: 100%;
    touch-action: none;
    background-color: rgba(255, 255, 255, 0.06);
    background-image:
        linear-gradient(45deg, rgba(255,255,255,0.07) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.07) 75%),
        linear-gradient(45deg, rgba(255,255,255,0.07) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.07) 75%);
    background-size: 22px 22px;
    background-position: 0 0, 11px 11px;
    border-radius: 8px;
}
[data-theme="light"] .bl-canvas-wrap {
    background-color: rgba(0, 0, 0, 0.04);
    background-image:
        linear-gradient(45deg, rgba(0,0,0,0.06) 25%, transparent 25%, transparent 75%, rgba(0,0,0,0.06) 75%),
        linear-gradient(45deg, rgba(0,0,0,0.06) 25%, transparent 25%, transparent 75%, rgba(0,0,0,0.06) 75%);
}
#vorschauCanvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}
.bl-out-meta {
    text-align: center;
    font-size: 0.86rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    margin: 0.9rem 0 1.2rem;
    min-height: 1.4em;
}
/* „Hintergrund entfernen" schreibt in diese Zeile einen ganzen Satz mit
   hervorgehobenen Stellen und meldet darin auch Grenzfaelle (zu grosses Bild). */
.bl-out-meta strong { color: var(--text); }
.bl-out-meta.warn { color: #ff9f0a; }

/* --- Zuschneiden: der Auswahlkasten --- */
.bl-crop-box {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid var(--primary);
    /* Der ganze Rest des Bildes wird abgedunkelt — der Schatten nach außen
       ist billiger als vier zusätzliche Elemente. */
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
    pointer-events: none;
}
.bl-crop-box::before,
.bl-crop-box::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
}
/* Drittel-Linien als Hilfe beim Ausrichten */
.bl-crop-box::before {
    background:
        linear-gradient(to right, transparent calc(33.33% - 1px), rgba(255,255,255,0.35) calc(33.33% - 1px), rgba(255,255,255,0.35) 33.33%, transparent 33.33%),
        linear-gradient(to right, transparent calc(66.66% - 1px), rgba(255,255,255,0.35) calc(66.66% - 1px), rgba(255,255,255,0.35) 66.66%, transparent 66.66%);
}
.bl-crop-box::after {
    background:
        linear-gradient(to bottom, transparent calc(33.33% - 1px), rgba(255,255,255,0.35) calc(33.33% - 1px), rgba(255,255,255,0.35) 33.33%, transparent 33.33%),
        linear-gradient(to bottom, transparent calc(66.66% - 1px), rgba(255,255,255,0.35) calc(66.66% - 1px), rgba(255,255,255,0.35) 66.66%, transparent 66.66%);
}
.bl-crop-tip {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.6rem;
}

/* --- Quelle: welche Datei ist gerade offen --- */
.bl-src {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    margin-bottom: 1.4rem;
}
[data-theme="light"] .bl-src { background: rgba(0, 0, 0, 0.025); }
.bl-src-icon { font-size: 1.4rem; line-height: 1; flex: none; }
.bl-src-info { flex: 1; min-width: 0; }
.bl-src-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bl-src-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    font-variant-numeric: tabular-nums;
}

/* --- Übersichtsseite: die sechs Werkzeuge --- */
.bl-tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1.6rem;
}
.bl-tool {
    display: block;
    padding: 1.4rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.035);
    color: inherit;
    text-decoration: none;
    transition: border-color 0.35s ease, background 0.35s ease, transform 0.4s cubic-bezier(0.16,1,0.3,1);
}
[data-theme="light"] .bl-tool { background: rgba(0, 0, 0, 0.02); }
@media (hover: hover) and (pointer: fine) {
    .bl-tool:hover {
        border-color: rgba(41, 151, 255, 0.4);
        background: rgba(41, 151, 255, 0.06);
        transform: translateY(-3px);
    }
}
.bl-tool-emoji { font-size: 1.7rem; line-height: 1; display: block; margin-bottom: 0.6rem; }
.bl-tool h3 { font-size: 1.05rem; margin-bottom: 0.35rem; }
.bl-tool p { font-size: 0.88rem; color: var(--text-muted); line-height: 1.55; }

.bl-cat-text {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.6;
}
.bl-more {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.95rem;
    line-height: 1.7;
}
.bl-more a { color: var(--primary); font-weight: 600; }

@media (max-width: 520px) {
    .bl-row { flex-direction: column; gap: 0; }
    .bl-choice-btn { font-size: 0.8rem; padding: 0.4rem 0.7rem; }
}

/* ── Hintergrund entfernen: die eine Seite, die auf dem Server rechnet ──
   Das Karomuster steckt schon in .bl-canvas-wrap — hier kommt nur dazu,
   was ein <img> statt eines <canvas> braucht, und die Kennzeichnung
   „rechnet auf dem Server" im Übersichtsraster. */
.bl-canvas-wrap img {
    display: block;
    max-width: 100%;
    max-height: 46vh;
    height: auto;
    border-radius: 8px;
}
.bl-ergebnis {
    margin: 0 auto 1.1rem;
    max-width: 100%;
}
/* Die Farbwahl ist ein <input type="color">. Mit dem Finger sind die 42 px
   aus .bl-color knapp unter dem 44-px-Richtwert — nur auf Touch anheben,
   damit die Felder am Desktop in einer Höhe mit den Auswahlknöpfen bleiben.
   Gilt für alle Bild-Werkzeuge mit Farbwahl (Wasserzeichen, Favicon,
   Hintergrund entfernen). */
@media (pointer: coarse) {
    .bl-color { height: 44px; }
}
.bl-badge {
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.45rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
}
[data-theme="light"] .bl-badge { background: rgba(0, 0, 0, 0.05); }
/* Wenn der Server das Modell nicht hat, ist die Ablagefläche tot — das
   soll man sehen, bevor man eine Datei darauf zieht. */
.cv-drop-off {
    opacity: 0.55;
    cursor: not-allowed;
}
.cv-drop-off:hover { border-color: var(--border); }

/* Auf Touch zu klein: 38 px bei den Auswahlknoepfen, 42 px bei den
   Eingabefeldern. Der Richtwert fuer eine zuverlaessige Tippflaeche liegt
   bei 44 px — am Desktop bleibt es bei den kleineren Werten, dort ist die
   Maus genau genug. (Aufgefallen an /bild/hintergrund.html, wo die
   Browser-Pruefung genau das gemessen hat.) */
@media (pointer: coarse) {
    .bl-choice-btn { min-height: 44px; padding-top: 0.6rem; padding-bottom: 0.6rem; }
    .bl-input { min-height: 44px; }
}
