/**
 * PhotoMagnet – ein Stylesheet für alles.
 *
 * Die Anwendung ist bewusst immer hell, auch wenn das Gerät im Dunkelmodus läuft.
 *
 * Zwei Gründe: Fotos wirken auf hellem Grund, und ein Gast auf einer Hochzeit erwartet
 * etwas Freundliches. Vor allem aber ist ein einziges, durchgestaltetes Erscheinungsbild
 * verlässlicher als zwei – jede Farbe, die man in einem der beiden Modi vergisst, wird
 * genau dort unlesbar. `color-scheme: light` sagt dem Browser ausdrücklich, dass er nichts
 * umdrehen soll; ohne diese Zeile faucht iOS die Formularfelder und Hintergründe eigenmächtig
 * dunkel.
 *
 * Mobile-first: Der Gast bedient die Seite auf dem Handy, der Betreiber am Laptop. Beide
 * bekommen dieselbe Formensprache.
 */

/* ---------------------------------------------------------------------------------------
   Farben und Maße
   --------------------------------------------------------------------------------------- */

:root {
    color-scheme: light;

    --brand: #4f46e5;
    --brand-hover: #4338ca;
    --brand-soft: #eef2ff;
    --on-brand: #fff;

    --bg: #f7f7f9;
    --surface: #fff;
    --surface-2: #f2f3f5;
    --text: #16181d;
    --text-muted: #6b7280;
    --line: #e4e6ea;

    --ok-bg: #ecfdf5;   --ok-text: #065f46;   --ok-line: #a7f3d0;
    --warn-bg: #fffbeb; --warn-text: #92400e; --warn-line: #fde68a;
    --err-bg: #fef2f2;  --err-text: #991b1b;  --err-line: #fecaca;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgb(16 24 40 / 5%), 0 4px 16px rgb(16 24 40 / 6%);
    --shadow-lg: 0 8px 32px rgb(16 24 40 / 10%);

    --step: 0.25rem;
}

/* ---------------------------------------------------------------------------------------
   Grundlagen
   --------------------------------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;

    /* Sonst zieht ein Wisch im Editor die ganze Seite mit. */
    overscroll-behavior-y: none;
}

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 calc(var(--step) * 2); }
h2 { font-size: 1.15rem; font-weight: 650; margin: calc(var(--step) * 8) 0 calc(var(--step) * 3); }

p { margin: 0 0 calc(var(--step) * 4); }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.875em;
    background: var(--surface-2);
    padding: 0.15em 0.4em;
    border-radius: 6px;
}

hr { border: 0; border-top: 1px solid var(--line); margin: calc(var(--step) * 6) 0; }

.muted { color: var(--text-muted); font-size: 0.875rem; }
.center { text-align: center; }
.stack > * + * { margin-top: calc(var(--step) * 4); }

/* Immer sichtbarer Fokusring – auf einer Feier bedient auch mal jemand mit Tastatur. */
:where(a, button, input, select, textarea):focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ---------------------------------------------------------------------------------------
   Aufbau
   --------------------------------------------------------------------------------------- */

.app-header {
    display: flex;
    align-items: center;
    gap: calc(var(--step) * 4);
    padding: calc(var(--step) * 3) calc(var(--step) * 5);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-header .brand {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}
.app-header .brand:hover { text-decoration: none; }

.app-header nav { display: flex; gap: calc(var(--step) * 4); font-size: 0.9375rem; }
.app-header .spacer { flex: 1; }

.page { padding: calc(var(--step) * 6) calc(var(--step) * 5); max-width: 64rem; margin: 0 auto; }
.page--narrow { max-width: 30rem; }

/* ---------------------------------------------------------------------------------------
   Karten
   --------------------------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: calc(var(--step) * 5);
    box-shadow: var(--shadow);
    margin-bottom: calc(var(--step) * 4);
}

.card--flush { padding: 0; overflow: hidden; }
.card > :last-child { margin-bottom: 0; }

.card--done {
    background: var(--ok-bg);
    border-color: var(--ok-line);
    color: var(--ok-text);
}

/* ---------------------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: calc(var(--step) * 2);
    padding: 0.7rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--brand);
    color: var(--on-brand);
    font: inherit;
    font-weight: 600;
    font-size: 0.9375rem;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, transform .05s, opacity .15s;

    /* Auf dem Handy muss man ihn mit dem Daumen sicher treffen. */
    min-height: 44px;
}

.btn:hover { background: var(--brand-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn--ghost {
    background: var(--surface);
    color: var(--text);
    border-color: var(--line);
}
.btn--ghost:hover { background: var(--surface-2); }

.btn--danger { background: #dc2626; color: #fff; }
.btn--danger:hover { background: #b91c1c; }

.btn--block { display: flex; width: 100%; }
.btn--sm { padding: 0.45rem 0.8rem; min-height: 36px; font-size: 0.875rem; }

.btn-row { display: flex; flex-wrap: wrap; gap: calc(var(--step) * 2); }

/* ---------------------------------------------------------------------------------------
   Formulare
   --------------------------------------------------------------------------------------- */

.field { margin-bottom: calc(var(--step) * 4); }
.field > label { display: block; font-size: 0.875rem; font-weight: 550; margin-bottom: calc(var(--step) * 1.5); }
.field .help { display: block; font-size: 0.8125rem; color: var(--text-muted); margin-top: calc(var(--step) * 1.5); }

.input, .select, .textarea {
    display: block;
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;

    /* Unter 16px zoomt iOS beim Antippen ins Feld hinein. */
    font-size: 16px;
    transition: border-color .15s, box-shadow .15s;
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.textarea { resize: vertical; min-height: 4.5rem; }

.select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                      linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 2.2rem;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 calc(var(--step) * 4); }
@media (max-width: 34rem) { .field-row { grid-template-columns: 1fr; } }

.check {
    display: flex;
    gap: calc(var(--step) * 2.5);
    align-items: flex-start;
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: calc(var(--step) * 3);
    cursor: pointer;
}
.check input { margin-top: .2rem; width: 1.05rem; height: 1.05rem; accent-color: var(--brand); flex: none; }

input[type=file] {
    width: 100%;
    padding: calc(var(--step) * 3);
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-bottom: calc(var(--step) * 3);
}

/* ---------------------------------------------------------------------------------------
   Hinweise
   --------------------------------------------------------------------------------------- */

.notice {
    padding: calc(var(--step) * 3) calc(var(--step) * 4);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    margin-bottom: calc(var(--step) * 4);
    font-size: 0.9375rem;
}

.notice--ok   { background: var(--ok-bg);   color: var(--ok-text);   border-color: var(--ok-line); }
.notice--warn { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-line); }
.notice--err  { background: var(--err-bg);  color: var(--err-text);  border-color: var(--err-line); }
.notice--info { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.notice ul { margin: 0; padding-left: 1.1rem; }

/* ---------------------------------------------------------------------------------------
   Badges und Kacheln
   --------------------------------------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-muted);
    white-space: nowrap;
}

.badge--NEW, .badge--QUEUED   { background: var(--brand-soft); color: var(--brand); }
.badge--PRINTING              { background: var(--warn-bg); color: var(--warn-text); }
.badge--PRINTED,
.badge--COMPLETED             { background: var(--ok-bg); color: var(--ok-text); }
.badge--CANCELLED,
.badge--ERROR                 { background: var(--err-bg); color: var(--err-text); }

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    gap: calc(var(--step) * 3);
    margin-bottom: calc(var(--step) * 5);
}

.tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: calc(var(--step) * 4);
    box-shadow: var(--shadow);
}
.tile .k { font-size: 0.8125rem; color: var(--text-muted); }
.tile .v { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }

/* ---------------------------------------------------------------------------------------
   Tabellen
   --------------------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

th, td {
    text-align: left;
    padding: calc(var(--step) * 3) calc(var(--step) * 3.5);
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--surface-2);
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

/* ---------------------------------------------------------------------------------------
   Kontingent
   --------------------------------------------------------------------------------------- */

.quota {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: calc(var(--step) * 4);
    margin-bottom: calc(var(--step) * 5);
    box-shadow: var(--shadow);
}

.quota--warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }
.quota--full { background: var(--err-bg);  border-color: var(--err-line);  color: var(--err-text); }

.bar {
    height: 0.5rem;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    margin: calc(var(--step) * 2) 0;
}
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }
.quota--warn .bar > i { background: #f59e0b; }
.quota--full .bar > i { background: #dc2626; }

/* ---------------------------------------------------------------------------------------
   Gast: Schritte, Editor, Status
   --------------------------------------------------------------------------------------- */

.steps {
    display: flex;
    gap: calc(var(--step) * 1.5);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: calc(var(--step) * 5);
    list-style: none;
    padding: 0;
}
.steps li { display: flex; align-items: center; gap: calc(var(--step) * 1.5); }
.steps li + li::before { content: "›"; color: var(--line); }
.steps .now { color: var(--brand); font-weight: 650; }

.progress { display: flex; gap: calc(var(--step) * 1.5); }
.progress i {
    flex: 1;
    height: 0.3rem;
    border-radius: 999px;
    background: var(--surface-2);
    transition: background .3s;
}
.progress i.on { background: var(--brand); }

.order-no {
    font-size: 2.75rem;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.03em;
}

.thumb {
    width: 100%;
    border-radius: var(--radius-sm);
    display: block;
    background: var(--surface-2);
}

/* Bewusst groß: Der Betreiber muss vor dem Druck eine Sichtprüfung vornehmen können
   (Kapitel 20 und 75.1). */
.thumb--queue {
    width: 112px;
    height: 112px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    display: block;
    background: var(--surface-2);
}

#canvas {
    touch-action: none;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface-2);
    display: block;
}

.hint { text-align: center; font-size: 0.9375rem; margin: calc(var(--step) * 3) 0; }
.hint--ok      { color: var(--ok-text); }
.hint--warn    { color: var(--warn-text); }
.hint--blocked { color: var(--err-text); font-weight: 600; }

.upload-status { font-size: 0.9375rem; margin: calc(var(--step) * 2.5) 0 0; }
.upload-status:empty { display: none; }
.upload-status.muted { color: var(--text-muted); }
.upload-status.ok    { color: var(--ok-text); }
.upload-status.warn  { color: var(--warn-text); }
.upload-status.err   { color: var(--err-text); font-weight: 600; }

/* ---------------------------------------------------------------------------------------
   Galerie
   --------------------------------------------------------------------------------------- */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: calc(var(--step) * 3);
}

.grid a {
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    color: inherit;
    box-shadow: var(--shadow);
    transition: transform .1s, box-shadow .15s;
}
.grid a:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); text-decoration: none; }
.grid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.grid .meta { padding: calc(var(--step) * 2.5) calc(var(--step) * 3); }

.placeholder {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* ---------------------------------------------------------------------------------------
   Pflichtangaben
   --------------------------------------------------------------------------------------- */

/* Impressum und Datenschutz müssen von jeder Seite erreichbar sein (Kapitel 76.4) – auch
   von der Eventseite, auf der der Gast sein Foto hochlädt. */
.legal-links {
    display: flex;
    justify-content: center;
    gap: calc(var(--step) * 2);
    margin-top: calc(var(--step) * 10);
    padding-top: calc(var(--step) * 4);
    border-top: 1px solid var(--line);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.legal-links a { color: var(--text-muted); }
.legal-links a:hover { color: var(--brand); }
