
/* #region FONT ---------------------------- */

/* Fira Sans Regular */
@font-face {
    font-display: swap;
    font-family: 'Fira Sans';
    font-style: normal;
    font-weight: 400;
    src: url('../fonts/fira-sans-v18-latin-regular.woff2') format('woff2');
}

/* Fira Sans Medium */
@font-face {
    font-display: swap;
    font-family: 'Fira Sans';
    font-style: normal;
    font-weight: 500;
    src: url('../fonts/fira-sans-v18-latin-500.woff2') format('woff2');
}

/* Fira Sans Bold */
@font-face {
    font-display: swap;
    font-family: 'Fira Sans';
    font-style: normal;
    font-weight: 600;
    src: url('../fonts/fira-sans-v18-latin-600.woff2') format('woff2');
}

/* #endregion */
/* #region APP ----------------------------- */

:root {
    --gallery-scrollbar-space: 16px;
    --gray-section: #f7f7f7;
    --gray-tag: #e8e8e8;
    --gray-button: #808080;
}

* {
    box-sizing: border-box;
}

.page {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

body {
    margin: 0;
    background: var(--gray-section);
    color: black;
    font-family: "Fira Sans", sans-serif;
    font-size: 15px;
}

h2 {
    font-size: 26px;
    margin: 10px 0 10px;
}

h3 {
    font-size: 18px;
    margin: 10px 0 4px;
    text-align: left;
}

p {
    line-height: 1.4;
    margin-top: 0;
    margin-bottom: 0;
    text-align: left;
}

.text-center {
    text-align: center;
}

.text-link {
    overflow-wrap: anywhere;
    word-break: break-all;
}

label {
    display: block;
    font-weight: 600;
    text-align: left;
}

.button {
    display: inline-block;
    background: var(--gray-button);
    color: white;
    border: 0;
    border-radius: 22px;
    padding: 13px 20px;
    text-decoration: none;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    height: 44px;
}

.hidden {
    display: none !important;
}

/* #endregion */
/* #region CARD ---------------------------- */

.card {
    position: relative;
    flex: 0 1 700px;
    width: 100%;
    min-width: 0;
    max-width: 700px;
    padding: 20px;
    background: white;
    border-radius: 24px;
    box-shadow: 0 12px 40px #0000000d;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.card-footer {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-top: 16px;
    padding: 0;
    flex-shrink: 0;
    gap: 8px;
}

.card-footer p {
    margin: 0;
    font-size: 12px;
    color: black;
    margin-bottom: 4px;
}

.card-footer .form-row img {
    width: auto;
    height: 36px;
    border-radius: 15px;
    cursor: pointer;
}

/* #endregion */
/* #region IDs ----------------------------- */

#claim {
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

.claim-dev {
    background: red; /* #FFD500 */
    color: white;
}

.copyright {
    position: relative;
    top: 1px;
}

/* #endregion */
/* #region MEDIA --------------------------- */

.mouse-only {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    .mouse-only {
        display: inline;
    }
}

@media (max-width: 700px) {
    .card {
        padding: 22px 16px;
    }

    .page {
        padding: 10px;
    }

    /* Formularfelder untereinander */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Footer-Buttons immer nebeneinander */
    .card-footer .form-row {
        flex-direction: row;
        justify-content: center;
        gap: 16px;
    }

    .form-group {
        width: 100%;
    }
}

@media (max-width: 500px) {
    .card-footer .form-row { /* bis 500 px 2 nebeneinander, 3. zentriert */
        display: grid;
        grid-template-columns: repeat(2, max-content);
        justify-content: center;
        justify-items: center;
        gap: 10px 16px;
    }

    .card-footer .form-row a:last-child {
        grid-column: 1 / -1;
    }
}

/* #endregion */
/* #region FORM ---------------------------- */

form {
    text-align: left;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin-top: 20px;
    min-width: 0;
}

form .button {
    width: 100%;
}

.form-group {
    flex: 1;
    min-width: 0;
}

.form-group > label {
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    max-width: 100%;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    padding: 10px 12px;
    font: inherit;
    color: black;
    accent-color: black;
}

.form-group input[type="datetime-local"] {
    display: block;
    min-width: 0;
    width: 100%;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
    height: 44px;
    max-height: 44px;
}

.form-group input[type="datetime-local"]::-webkit-date-and-time-value {
    text-align: left;
}

.form-group > label:has(+ .file-bar) {
    margin-bottom: 0;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.form-bar input[type="file"] {
    flex: 1;
    min-width: 0;
}

.form-bar .paste-button {
    margin-left: auto;
    flex-shrink: 0;
}

.form-bar.file-bar {
    align-items: flex-end;
}

#formStatus {
    overflow-wrap: anywhere;
}

#formStatus:empty {
    display: none;
}

/* #endregion */
/* #region WALKING ANTS --------------------- */

.form-section.file-drop-zone {
    position: relative;
    transition: background-color 0.2s;
}

.form-section.file-drop-zone.drag-over {
    background-color: var(--gray-tag);
}

.file-drop-zone.drag-over > .drop-ants {
    display: block;
}

.drop-ants {
    display: none;
    position: absolute;
    top: 1px;
    left: 1px;
    width: calc(100% - 2px);
    height: calc(100% - 2px);
    overflow: visible;
    pointer-events: none;
    z-index: 5;
}

.drop-ants rect {
    fill: none;
    stroke: black;
    stroke-width: 2px;
    stroke-dasharray: 6px 6px;
    animation: swipiegram-drop-ants 0.6s linear infinite;
}

@keyframes swipiegram-drop-ants {
    from { stroke-dashoffset: 0; }
    to   { stroke-dashoffset: -12px; }
}

/* #endregion */
/* #region TAG GALLERY --------------------- */

.tag-gallery {
    display: flex;
    flex-direction: row;
    gap: 10px;
    height: calc(36px + var(--gallery-scrollbar-space));
    width: 100%;
    padding: 0;
    margin-bottom: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.tag-gallery-item {
    flex: 0 0 auto;
    height: 36px;
    padding: 0 15px;
    border: 0;
    border-radius: 18px;
    background: var(--gray-tag);
    color: var(--gray-button);
    font: inherit;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.tag-gallery-item.selected {
    background: var(--gray-button);
    color: white;
}

/* #endregion */
/* #region TOP GALLERY --------------------- */

.top-gallery {
    display: flex;
    flex-direction: row;
    gap: 10px;
    height: calc(120px + var(--gallery-scrollbar-space));
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.top-gallery-item {
    flex: 0 0 120px;
    height: 120px;
    padding: 0;
    border: 3px solid transparent;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    overflow: hidden;
    scroll-snap-align: start;
}

.top-gallery-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px; /* 3px border berücksichtigen */
}

.top-gallery-item.selected {
    border-color: var(--gray-button);
}

.top-gallery-item:focus-visible {
    outline: 2px solid var(--gray-button);
    outline-offset: 2px;
}

/* #endregion */
/* #region INPUT --------------------------- */

input,
select {
    height: 44px;
}

input,
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font: inherit;
    background: white;
}

input {
    padding: 10px;
}

/* #endregion */
/* #region UPLOAD -------------------------- */

.upload-preview {
    display: block;
    width: 100%;
    max-height: 240px;
    margin-top: 8px;
    object-fit: contain;
    border-radius: 12px;
    background: transparent;
}

/* #endregion */
/* #region IMAGE BUTTON -------------------- */

.image-button {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    align-self: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    border: 1px solid var(--gray-button);
    background: var(--gray-button);
}

.image-button img {
    width: 20px;
    height: 20px;
    object-fit: scale-down;
    filter: invert(1);
}

/* #endregion */
/* #region SCRATCH ------------------------- */

.scratch-wrap {
    position: relative;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 24px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.scratch-background {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    z-index: 0;
}

#scratchCanvas {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: auto;
    touch-action: none;
    cursor: pointer;
}

.scratch-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffffdd;
}

.scratch-again-wrapper.hidden {
    display: none;
}

.scratch-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 21px;
}

#scratchProgressTrack {
    flex: 1;
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

.scratch-progress-fill {
    width: 0;
    height: 100%;
    background: red;
    border-radius: inherit;
    transition: width 0.15s ease-out;
}

#scratchProgressPercent {
    flex: 0 0 42px;
    text-align: right;
    font-size: 13px;
}

/* #endregion */
/* #region SCRATCH ANIMATION---------------- */

.scratch-wrap {
    position: relative;
    overflow: hidden;
}

.scratch-hand {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    top: 10px;
    left: 10px;
    width: 48px;
    height: 48px;
    margin: 0;
    z-index: 3;
    pointer-events: none;
    user-select: none;
    border-radius: 50%;
    background: rgb(from var(--gray-button) r g b / 70%);
    animation: scratch-hand-move 0.6s ease-in-out infinite alternate;
}

.scratch-hand img {
    display: block;
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: invert(1);
}

@keyframes scratch-hand-move {
    from { transform: translate(0, 0) rotate(-10deg); }
    to   { transform: translate(96px, 0px) rotate(55deg); }
}

/* #endregion */
/* #region RESULT -------------------------- */

#result {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.result-image {
    display: block;
    width: 100%;
    max-width: 650px;
    height: auto;
    margin: 20px auto;
    border-radius: 24px;
}

.result-buttons {
    display: grid;
    gap: 12px;
    width: 100%;
    margin-top: 20px;
}

.result-buttons.columns-1 {
    grid-template-columns: 1fr;
}

.result-buttons .button {
    display: block;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 12px 4px;
    text-align: center;
    white-space: nowrap;
}

/* #endregion */
/* #region RESULT GALLERY ------------------ */

/* Ergebnisgalerie */
#resultGallery {
    display: flex;
    flex-direction: row;
    gap: 10px;
    height: calc(142px + var(--gallery-scrollbar-space));
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

/* Items mit 10 px Innenabstand */
.result-gallery-item {
    display: flex;
    flex: 0 0 120px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    height: 142px;
    padding: 7px;
    border: 3px solid transparent;
    border-radius: 8px;
    background:  var(--gray-button);
    cursor: pointer;
    overflow: hidden;
    scroll-snap-align: start;
    text-align: left;
}

/* Auswahlrahmen */
.result-gallery-item.selected {
    border-color: var(--gray-button);
}

.result-gallery-item:focus-visible {
    outline: 2px solid var(--gray-button);
    outline-offset: 2px;
}

/* Einheitliche Beschriftung */
.result-gallery-caption {
    display: block;
    flex: 0 0 18px;
    width: 100%;
    overflow: hidden;
    font-size: 13px;
    line-height: 18px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: white;
}

/* Link und Kurzcode */
.result-gallery-text {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    width: 100px;
    height: 100px;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: left;
    font-size: 11px;
    line-height: 1.4;
    color: white;
}

/* Inhaltsbereich: 100 × 100 px */
.result-gallery-body {
    position: relative;
    flex: 0 0 100px;
    width: 100px;
    height: 100px;
    overflow: hidden;
}

/* Galeriebilder identisch skalieren */
.result-gallery-composite-image,
.result-gallery-body > img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100px;
    max-height: 100px;
    object-fit: contain;
    border-radius: 8px;
}

/* Beseitigt iPhone-Refresh-Problem */
.result-gallery-body > img {
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden; 
}

.code-error {
    color: red;
}

.clipboard-helper {
    position: fixed;
    opacity: 0;
}

/* #endregion */
/* #region IMAGE VIEWER -------------------- */

#imageViewer {
    margin-top: 20px;
    text-align: center;
}

#imageViewer img {
    display: block;
    width: 100%;
    max-width: 650px;
    height: auto;
    margin: 0 auto 20px;
    border-radius: 24px;
    cursor: pointer;
}

.image-viewer-hint {
    color: black;
    text-align: center;
}

/* #endregion */
/* #region CODE ---------------------------- */

/* Gemeinsame Gestaltung aller grauen Formularbereiche. */
.form-section {
    background: var(--gray-section);
    padding: 12px;
    border-radius: 12px;
    min-width: 0;
}

/* Abstand zwischen 2a (Galerie) und 2b (eigene Datei). */
.form-section:not(.advanced-options) > .form-group + .form-group {
    margin-top: 16px;
}

/* Abstand zum ersten Formularbereich */
#createForm {
    margin-top: 10px;
}

.gift-code-entry:not(.hidden) + #createForm {
    margin-top: 16px;
}

.gift-code-entry {
    margin-top: 10px;
}

.gift-code-entry form {
    margin: 0;
    gap: 0;
}

.gift-code-entry .form-bar {
    margin-top: 8px;
}

/* Eingabefeld und Öffnen-Button teilen sich den Platz */
.gift-code-entry .form-bar #giftCode,
.gift-code-entry .form-bar .button {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
}

/* Einfügen-Button: immer 44px */
.gift-code-entry .form-bar #giftCodePaste {
    flex: 0 0 44px;
}

/* #endregion */
/* #region LANGUAGE ------------------------ */

.language-buttons {
    display: flex;
    gap: 5px;
}

.language-button {
    background: transparent;
    border: none;
    font-size: 16px;
    cursor: pointer;
}

/* #endregion */
/* #region HOME ---------------------------- */

.home-button {
    position: absolute;
    right: 20px;
    bottom: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgb(from var(--gray-button) r g b / 85%);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    text-decoration: none;
    z-index: 10;
    transition: background 0.2s, transform 0.2s;
}

.home-button img {
    width: 20px;
    height: 20px;
    object-fit: scale-down;
    filter: invert(1);
}

.home-button:hover {
    background: var(--gray-button);
    transform: scale(1.10);
}

.home-button.floating {
    position: fixed;
    right: max(20px, calc((100vw - 700px) / 2 + 20px)); /* Breite Card */
    bottom: 20px;
    z-index: 1000;
}

.home-button.floating.at-card-bottom {
    position: absolute;
    right: 20px;
    bottom: 20px;
}

@media (max-width: 700px) {
    .home-button.floating {
        right: 30px;
    }

    .home-button.floating.at-card-bottom {
        right: 20px;
    }
}

/* #endregion */
/* #region OPTION -------------------------- */

/* Erstellen-Button */
#createForm > .form-bar > .button {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
}

/* Optionen-Button */
form #optionButton {
    flex: 0 0 60px;
    width: 60px;
    border-radius: 22px;
}

form #optionButton img {
    display: block;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    max-width: 20px;
    max-height: 20px;
    object-fit: contain;
    transition: transform 180ms ease;
}

form #optionButton[aria-expanded="true"] img {
    transform: rotate(180deg);
}

form #advancedOptions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

form #advancedOptions > .option-help:not(.hidden) {
    margin-top: -8px;
}

@media (prefers-reduced-motion: reduce) {
    form #optionButton img { transition: none; }
}

/* #endregion */
/* #region SHORT CODE ---------------------- */

.short-code-bar input { 
    flex: 1 1 auto; 
    min-width: 0; 
    width: 0; }

.short-code-bar .image-button { 
    flex: 0 0 44px; 
}

.option-help {
    padding: 12px;
    border-radius: 12px;
    background: white;
    color: black;
    text-align: left;
    line-height: 1.5;
    white-space: pre-line;
    scroll-margin-top: 20px;
}

.option-help p + p {
    margin-top: 10px;
}

.option-info-button.active {
    background: white;
}

.option-info-button.active img {
    filter: none;
}

@media (max-width: 390px) {
    .short-code-bar { gap: 5px; }
    .short-code-bar .image-button { flex-basis: 40px; width: 40px; height: 40px; }
}

/* Fehler beim Erstellen deutlich hervorheben */
#formStatus.form-status-error {
    color: red;
    font-weight: 600;
}

#shortCode.short-code-invalid {
    border-color: red;
    outline: 2px solid red;
    outline-offset: 1px;
}

/* Verhindert automatischen iPhone-Zoom bei allen Eingabefeldern */
input,
textarea,
select,
.form-group input,
.form-group select,
.gift-code-entry .form-bar input,
#shortCode {
    font-size: 16px;
}

/* #endregion */
/* #region FILE PICKER ----------------------*/

.file-picker {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.file-picker-button {
    padding: 8px 15px;
    margin-bottom: 0;
    border-radius: 18px;
    color: white;
    background: var(--gray-button);
    white-space: nowrap;
    font: inherit;
    font-size: 15px;
    font-weight: 600;    
}

.file-picker-button,
.file-picker input[type="file"],
.file-picker input[type="file"]::file-selector-button {
    cursor: pointer;
}

.file-picker input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-picker:focus-within {
    outline: 2px solid currentColor;
    outline-offset: 3px;
    border-radius: 8px;
}

#imageBottomFilename,
#imageTopFilename {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* #endregion */
