/*
 * Global reader stylesheet for the standalone PWA.
 * Ported from the MAUI reader's wwwroot/css/app.css, extended with the
 * full-height shell, safe-area handling and search header styles.
 */

@font-face {
    font-family: "Edeka";
    src: url("edeka.woff2") format("woff2");
    font-display: swap;
}

@font-face {
    font-family: "Libre Barcode EAN13 Text";
    src: url("libre-barcode-ean13-text.woff2") format("woff2");
    font-display: swap;
}

:root {
    color-scheme: dark;
    --border-radius: .4rem;
    --background-color-light: #1e1e1e;
    --background-color-dark: #141414;
    --background-color-accent: #1f487e;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Roboto", sans-serif;
    margin: 0;
    background-color: var(--background-color-light);
    color: white;
    min-height: 100dvh;
}

/*
 * The Edeka brand font is loaded by the host page when it is available.
 * Keep the class so headings, mottos and the store name use it 1:1.
 */
.edeka {
    font-family: "Edeka", "Roboto", sans-serif;
    font-weight: normal !important;
}

.material-icons {
    font-size: 1.5em;
    user-select: none;
}

.barcode {
    font-family: 'Libre Barcode EAN13 Text', cursive;
    font-size: 6rem;
    background-color: white;
    color: black;
    padding: .5rem;
    border-radius: var(--border-radius);
    width: fit-content;
}

.page {
    margin: 1rem;
}

.box {
    margin: 1rem 0;
    padding: 1rem;
    background-color: var(--background-color-dark);
    border-radius: var(--border-radius);
}

.box *:first-child {
    margin-top: 0;
}

.box *:last-child {
    margin-bottom: 0;
}

input, button, textarea, select {
    font-family: "Roboto", sans-serif;
    font-size: inherit;
    appearance: none;
    color: white;
    background-color: var(--background-color-light);
    border-radius: var(--border-radius);
    border-width: 0 0 1px 0;
    border-color: gray;
    padding: .5rem;
    display: block;
    margin: 1rem 0;
}

input, textarea, select {
    width: 100%;
}

button {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
}

button:disabled {
    cursor: default;
    opacity: .6;
}

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

#blazor-error-ui {
    background: #b32121;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: white;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "Ein Fehler ist aufgetreten."
}

/* Reader page scaffolding. */
.reader-page {
    margin: 0;
}

.reader-loading {
    margin: 1rem;
}

.reader-state {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    align-items: flex-start;
}

.reader-state h1 {
    font-size: 1.5rem;
    margin: 0;
}

.reader-state p {
    margin: 0;
}

.reader-state .material-icons {
    font-size: 2rem;
}

.reader-not-authorized {
    margin: 1rem;
    padding: 1rem;
    background-color: var(--background-color-dark);
    border-radius: var(--border-radius);
}

.reader-not-authorized h1 {
    margin-top: 0;
}

/* Search page. */
.search-header {
    display: flex;
    gap: 1rem;
    align-items: stretch;
    margin-bottom: 1rem;
}

.search-header .back-button {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    margin: 0;
    padding: .5rem;
    background-color: var(--background-color-dark);
    border-radius: var(--border-radius);
    color: white;
    text-decoration: none;
    min-width: 2.75rem;
    min-height: 2.75rem;
}

.search-header input[type=search] {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 2.75rem;
    margin: 0;
    background-color: var(--background-color-dark);
    outline: none;
}

.search-header input[type=search]::-webkit-search-cancel-button {
    appearance: auto;
    filter: invert(1);
}

:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/*
 * Lock document scrolling while the full-screen image viewer is open.
 * The overlay is position: fixed, but the page behind it would otherwise keep
 * scrolling (scroll chaining). :has() toggles this without any JS interop.
 */
html:has(.image-viewer),
body:has(.image-viewer) {
    overflow: hidden;
    overscroll-behavior: none;
}
