/* =====================================================================================================================
   Paukku theme: pixel art, a night sky with fireworks.
   Everything is served from this app (no external fonts or images), so it also works in the Storage without a connection.
   Component styles live next to their components (*.razor.css); this file holds the fonts, the palette and the shared parts.
   ===================================================================================================================== */

/* ---------- Fonts: Google Fonts, self-hosted. SIL Open Font License (see fonts/OFL-*.txt) ---------- */

@font-face {
    font-family: 'Silkscreen';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/Silkscreen-Regular.woff2') format('woff2');
}

@font-face {
    font-family: 'Silkscreen';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/Silkscreen-Bold.woff2') format('woff2');
}

/* ---------- Palette (a test checks the contrast of every text and background pair below) ---------- */

:root {
    color-scheme: dark;

    --earth-900: #1a110a;   /* page background */
    --earth-800: #2e1d10;   /* panels, header, navigation */
    --earth-700: #4d3219;   /* raised parts */
    --line: #b07a3a;      /* borders and dividers */
    --ink: #f7e8c4;       /* text */
    --ink-dim: #d1b98f;   /* secondary text */
    --rocket: #f0b323;    /* main action (golden yellow) */
    --spark: #ffd23f;     /* headings, selection, focus */
    --ok: #7bdc5a;
    --warn: #ff9b3d;
    --danger: #ff5d4a;
    --info: #6cc0e8;
    --shadow: #080503;    /* hard pixel shadow */
    --edge-light: #c99552; /* lit edge of a raised part (top and left) */
    --edge-dark: #0d0804;  /* shaded edge (bottom and right) */

    --font-display: 'Silkscreen', ui-monospace, 'Courier New', monospace;
    --font-body: 'Silkscreen', ui-monospace, 'Courier New', monospace;

    --px: 4px;            /* one "pixel" of borders and shadows */
    --tap: 44px;          /* smallest size of anything that is pressed */
    --nav-height: 66px;
    --page-width: 40rem;
}

/* ---------- Base ---------- */

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

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

html,
body {
    height: 100%;
    overflow: hidden;           /* the main area scrolls, not the page (see .app-main) */
    overscroll-behavior: none;
}

body {
    margin: 0;
    background: var(--earth-900);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.4;
    -webkit-font-smoothing: none;
    font-smooth: never;
}

img,
svg {
    image-rendering: pixelated;
}

h1,
h2,
h3 {
    margin: 0 0 1rem;
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1.5;
}

h1 {
    color: var(--spark);
    font-size: 24px;
    text-shadow: var(--px) var(--px) 0 var(--shadow);
}

h2 {
    color: var(--ink);
    font-size: 14px;
}

p {
    margin: 0 0 0.75rem;
}

a {
    color: var(--info);
}

:focus-visible {
    outline: var(--px) solid var(--spark);
    outline-offset: 2px;
}

/* After each page change the app moves the focus to the page heading, so that screen readers announce the new page.
   A heading cannot be pressed, so it does not need a visible focus ring. */
h1:focus-visible {
    outline: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ---------- Shared building blocks ---------- */

/* The heading of a page, with its icon. */
.page-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
    font-size: 20px;
}

.page-title .pixel-icon {
    width: 32px;
    height: 32px;
}

/* A panel with a hard pixel border and shadow. */
.card {
    margin: 0 0 1rem;
    padding: 0.85rem;
    background: var(--earth-800);
    border: var(--px) solid var(--line);
    border-color: var(--edge-light) var(--edge-dark) var(--edge-dark) var(--edge-light);   /* a raised panel, as in 1990s game menus */
    box-shadow: var(--px) var(--px) 0 var(--shadow);
}

.card > :last-child {
    margin-bottom: 0;
}

.muted {
    color: var(--ink-dim);
}

/* A text field. */
.input {
    display: block;
    width: 100%;
    min-height: var(--tap);
    padding: 0 0.75rem;
    background: var(--earth-900);
    border: var(--px) solid var(--line);
    border-color: var(--edge-dark) var(--edge-light) var(--edge-light) var(--edge-dark);   /* sunk into the panel */
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1rem;
}

/* A button that looks like a link, for the secondary choice next to a main button. */
.link-button {
    min-width: var(--tap);
    min-height: var(--tap);
    padding: 0 0.5rem;
    background: none;
    border: 0;
    color: var(--info);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

/* A short confirmation of what has just been done. */
.notice {
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    background: var(--earth-800);
    border: var(--px) solid var(--ok);
    color: var(--ink);
    font-weight: 700;
}

.alert--violation {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-width: 6px;
    background: var(--danger);
    color: var(--shadow);
    font-size: 1.1rem;
}

/* Large figures, such as the units sold. */
.big-number {
    margin: 0;
    color: var(--spark);
    font-family: var(--font-display);
    font-size: 20px;
    line-height: 1.5;
}

/* A message that must not be missed. */
.alert {
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    background: var(--earth-800);
    border: var(--px) solid var(--danger);
    color: var(--ink);
    font-weight: 700;
}

/* ---------- Loading screen (shown by index.html until the app has started) ---------- */

.boot {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 1.5rem;
    min-height: 100dvh;
    padding: 1rem;
}

.boot__logo {
    display: flex;
    gap: 0.5rem;
}

.boot__logo span {
    width: 16px;
    height: 16px;
    background: var(--spark);
    animation: boot-blink 1s steps(2, end) infinite;
}

.boot__logo span:nth-child(2) {
    background: var(--rocket);
    animation-delay: 0.25s;
}

.boot__logo span:nth-child(3) {
    background: var(--info);
    animation-delay: 0.5s;
}

.boot__bar {
    width: min(16rem, 70vw);
    height: 24px;
    padding: 4px;
    border: var(--px) solid var(--line);
    background: var(--earth-800);
}

.boot__fill {
    width: var(--blazor-load-percentage, 0%);
    height: 100%;
    background: var(--spark);
}

.boot__percent {
    min-height: 1.5em;
    color: var(--ink-dim);
    font-family: var(--font-display);
    font-size: 10px;
}

.boot__percent::after {
    content: var(--blazor-load-percentage-text, "");
}

@keyframes boot-blink {
    50% {
        opacity: 0.2;
    }
}

/* ---------- Unexpected errors (shown by Blazor; the text is set in index.html in the chosen language) ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: 1rem 3.5rem 1rem 1rem;
    background: var(--danger);
    border-top: var(--px) solid var(--ink);
    color: var(--shadow);
    font-weight: 700;
}

#blazor-error-ui a {
    color: var(--shadow);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    place-items: center;
    width: var(--tap);
    height: var(--tap);
    cursor: pointer;
    font-size: 28px;
}

/* ---------- Connection and outbox status (under the header) ---------- */

.sync-status:empty {
    display: none;
}

.sync-status {
    padding: 0 1rem;
}

.sync-status__line {
    margin: 0.5rem 0 0;
    padding: 0.5rem 0.75rem;
    background: var(--earth-800);
    border: var(--px) solid var(--earth-700);
    font-weight: 700;
}

.sync-status--offline .sync-status__offline {
    border-color: var(--warn);
}

.sync-status__failed,
.sync-status__flagged {
    border-color: var(--danger);
}

.sync-status__now {
    margin-left: 0.75rem;
}

/* ---------- Limit alerts on every screen ---------- */

.limit-alerts {
    padding: 0 1rem;
}

.limit-alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0 0;
    color: inherit;
    text-decoration: none;
}

.alert--violation.limit-alert {
    color: var(--shadow);
}

.limit-alert--negative {
    border-color: var(--warn);
}

/* ---------- Lists of products with figures (Storage, Closet, Forecast) ---------- */

.stock-list {
    display: grid;
    gap: var(--px);
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
}

.stock-list__item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--earth-900);
    border-left: var(--px) solid var(--line);
}

.stock-list__item.is-negative {
    border-left-color: var(--danger);
}

.stock-list__name {
    font-weight: 700;
    overflow-wrap: anywhere;
}

.stock-list__units {
    color: var(--spark);
    font-family: var(--font-display);
    font-size: 16px;
    line-height: 1.9;
    white-space: nowrap;
}

.stock-list__sub {
    grid-column: 1 / -1;
    color: var(--ink-dim);
    font-size: 0.9rem;
}

.forecast-order {
    grid-column: 1 / -1;
    margin-top: 0.25rem;
    color: var(--spark);
    font-weight: 700;
}

.forecast-group--now .stock-list__item {
    border-left-color: var(--danger);
}

.forecast-group--soon .stock-list__item {
    border-left-color: var(--warn);
}

/* ---------- The screen of waiting changes ---------- */

.outbox-list {
    display: grid;
    gap: var(--px);
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
}

.outbox-item {
    padding: 0.5rem 0.75rem;
    background: var(--earth-900);
    border-left: var(--px) solid var(--line);
}

.outbox-item--failed {
    border-left-color: var(--danger);
}

.outbox-item__title {
    margin: 0;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.outbox-item__detail {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
}

.outbox-problem,
.outbox-ask {
    margin: 0.5rem 0 0;
}

.outbox-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin-top: 0.5rem;
}

/* ---------- Products page ---------- */
.products-rows {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
}

.products-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-top: 2px solid var(--line);
}

.products-row__text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.products-badge {
    align-self: flex-start;
    padding: 0.1rem 0.5rem;
    border: 2px solid var(--warn);
    color: var(--warn);
    font-weight: 700;
}

.products-badge--archived {
    border-color: var(--line);
    color: var(--ink-dim);
}

.products-search,
.products-new,
.products-form__buttons {
    margin-top: 1rem;
}

.products-form__buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}


/* ---------- Gear link in the header ---------- */
.settings-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--tap);
    min-height: var(--tap);
    background: var(--earth-900);
    border: var(--px) solid var(--line);
    color: var(--ink);
}

.settings-link:focus-visible {
    outline: var(--px) solid var(--spark);
}

.settings-products {
    margin-top: 1rem;
}

.products-row__text {
    flex: 1 1 auto;
    overflow-wrap: anywhere;
}

.products-row .pixel-button {
    flex: none;
    width: auto;
    min-width: 6rem;
}

/* ---------- Sold products table ---------- */
.sold-table {
    width: 100%;
    border-collapse: collapse;
}

.sold-table th,
.sold-table td {
    padding: 0.5rem 0.25rem;
    border-top: 2px solid var(--line);
    text-align: left;
    font-weight: 400;
    overflow-wrap: anywhere;
}

.sold-table thead th {
    color: var(--ink-dim);
    border-top: 0;
}

.sold-table tbody th {
    font-weight: 700;
}

.sold-table__num {
    padding-left: 0.75rem !important;
    text-align: right !important;
    white-space: nowrap;
}

/* ---------- Stock report ---------- */
.report-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.report-table {
    width: 100%;
    margin-top: 1rem;
    border-collapse: collapse;
}

.report-table th,
.report-table td {
    padding: 0.4rem 0.25rem;
    border-top: 2px solid var(--line);
    text-align: left;
    font-weight: 400;
    overflow-wrap: anywhere;
}

.report-table thead th {
    color: var(--ink-dim);
    border-top: 0;
}

.report-table tbody th {
    font-weight: 700;
}

.settings-products {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Printing: black on white, only the report. */
@media print {
    html,
    body,
    .app,
    .app-main {
        height: auto !important;
        overflow: visible !important;
    }

    .app-header,
    .bottom-nav,
    .no-print,
    .limit-alerts,
    #blazor-error-ui,
    nav,
    .sync-status {
        display: none !important;
    }

    html,
    body,
    .app,
    .app-main {
        background: #fff !important;
        color: #000 !important;
    }

    .card {
        background: #fff !important;
        border: 2px solid #000 !important;
        box-shadow: none !important;
        color: #000 !important;
        break-inside: avoid;
    }

    h1,
    h2,
    .muted,
    .report-table th,
    .report-table td {
        color: #000 !important;
        text-shadow: none !important;
    }

    .report-table th,
    .report-table td {
        border-color: #000 !important;
    }
}

.report-code {
    margin-left: 0.5rem;
    font-weight: 400;
}

/* ---------- 1990s game menu styling (bevels, title strips, dithered earth, segmented gauges) ---------- */

/* A dithered earth background: a fine checker of two nearly equal browns, as in 256-colour games. Text keeps its contrast. */
body {
    background-color: var(--earth-900);
    background-image: conic-gradient(#21160d 25%, transparent 0 50%, #21160d 0 75%, transparent 0);
    background-size: 8px 8px;
}

/* The heading of a panel is a title strip across its top. */
.card > h2:first-child {
    margin: calc(-1 * var(--px) - 0.85rem) calc(-1 * var(--px) - 0.85rem) 0.85rem;
    padding: 0.4rem 0.85rem;
    background: var(--earth-700);
    border-bottom: var(--px) solid var(--edge-dark);
    box-shadow: inset 0 var(--px) 0 var(--edge-light);
    color: var(--spark);
    text-shadow: var(--px) var(--px) 0 var(--shadow);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* The header and the bottom bar are lit on one edge, like toolbars. */
.app-header {
    box-shadow: inset 0 var(--px) 0 var(--edge-light);
}

.bottom-nav {
    box-shadow: inset 0 var(--px) 0 var(--edge-light);
}

/* ---------- Changes to check (T-056) ---------- */
.review__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.review__item {
    display: grid;
    gap: 0.25rem;
    padding: 0.75rem 0;
    border-top: 2px solid var(--line);
}

.review__item:first-child {
    border-top: 0;
}

.limit-alert--review {
    border-color: var(--warn);
}
