/* SPDX-FileCopyrightText: 2026 the QtCraft authors */
/* SPDX-License-Identifier: GPL-3.0-or-later */

/* Sizes and colours follow HandbookScreen.qml, HandbookLink.qml and HandbookRecipe.qml; the
   colours come from the game's palette (data/theme.css, --qc-*). */

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    background: linear-gradient(var(--qc-menuTop), var(--qc-menuBottom));
    color: var(--qc-text);
    font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

button,
input,
select {
    font: inherit;
    color: var(--qc-text);
    background: var(--qc-panelRaised);
    border: 1px solid var(--qc-separator);
    border-radius: 4px;
    padding: 6px 10px;
}

button {
    cursor: pointer;
}

button:hover:not(:disabled),
select:hover {
    background: var(--qc-slotHover);
}

button:disabled {
    color: var(--qc-textMuted);
    cursor: default;
}

input:focus,
select:focus,
button:focus-visible,
.entries:focus-visible {
    outline: 2px solid var(--qc-link);
    outline-offset: -1px;
}

.screen {
    position: fixed;
    inset: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: var(--qc-panel);
    border: 1px solid var(--qc-panelBorder);
    border-radius: 6px;
}

.bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bar h1 {
    margin: 0;
    font-size: 24px;
}

.spacer {
    flex: 1;
}

#search {
    width: 320px;
    min-width: 0;
}

.columns {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 12px;
}

.separator {
    width: 1px;
    background: var(--qc-separator);
}

.categories,
.entries,
.page {
    overflow-y: auto;
    min-height: 0;
}

.categories {
    flex: 0 0 190px;
}

.entries {
    flex: 0 0 270px;
}

.page {
    flex: 1;
    min-width: 0;
    padding-right: 16px;
}

.row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-bottom: 1px;
    padding: 6px 10px;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: var(--qc-text);
    text-align: left;
    text-decoration: none;
}

.row:hover {
    background: var(--qc-rowHighlight);
}

.row.selected {
    background: var(--qc-linkHover);
}

.row .count {
    margin-left: auto;
    color: var(--qc-textMuted);
}

.entries .row {
    min-height: 36px;
    padding: 4px 8px;
}

.entries .row .label {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.entries .row .title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.entries .row .sub {
    color: var(--qc-textMuted);
    font-size: 11px;
}

.entries .header {
    padding: 8px 8px 4px;
    color: var(--qc-heading);
    font-weight: bold;
}

.empty {
    margin-top: 40%;
    text-align: center;
    color: var(--qc-textMuted);
}

/* Item icons: cells of data/icons.png, placed by handbook.js; pixel art stays sharp. */
.icon {
    flex: none;
    display: inline-block;
    background-image: url("data/icons.png");
    background-repeat: no-repeat;
    image-rendering: pixelated;
}

.page-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-icon {
    flex: none;
    width: 56px;
    height: 56px;
    padding: 6px;
    background: var(--qc-panelRaised);
    border-radius: 3px;
}

.page-head h2 {
    margin: 0;
    font-size: 26px;
    line-height: 1.2;
}

.page-head .meta {
    color: var(--qc-textMuted);
}

.text {
    font-size: 15px;
}

.text p,
.text ul {
    margin: 0 0 8px;
}

.text ul {
    padding-left: 22px;
}

.text code {
    padding: 0 3px;
    background: var(--qc-linkBackground);
    border-radius: 3px;
    font-size: 13px;
}

.page > * + * {
    margin-top: 12px;
}

.facts {
    display: grid;
    grid-template-columns: 210px 1fr;
    gap: 4px 10px;
    padding: 6px 8px;
    background: var(--qc-rowHighlight);
    border-radius: 4px;
}

.facts .label {
    padding-top: 4px;
    color: var(--qc-textMuted);
}

.flow {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px;
}

.facts .value {
    padding-top: 4px;
}

.section h3 {
    margin: 0 0 6px;
    color: var(--qc-heading);
    font-size: 18px;
}

.section > * + * {
    margin-top: 6px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 6px;
    color: var(--qc-link);
    background: var(--qc-linkBackground);
    border: 1px solid var(--qc-separator);
    border-radius: 3px;
    text-decoration: none;
}

.chip:hover {
    background: var(--qc-linkHover);
}

.chip .note {
    color: var(--qc-textMuted);
}

.recipes {
    gap: 18px;
}

.recipe {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recipe-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.grid {
    display: grid;
    gap: 2px;
}

.cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 2px;
    background: var(--qc-panelRaised);
    border: 1px solid var(--qc-slotBorder);
    border-radius: 2px;
    color: var(--qc-text);
    font-size: 9px;
    text-align: center;
    text-decoration: none;
    overflow: hidden;
}

a.cell:hover {
    background: var(--qc-slotHover);
}

.cell .amount {
    position: absolute;
    right: 3px;
    bottom: 1px;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 0 var(--qc-textOutline), -1px -1px 0 var(--qc-textOutline), 1px -1px 0 var(--qc-textOutline), -1px 1px 0 var(--qc-textOutline);
}

.arrow {
    font-size: 26px;
}

.arrow.machine {
    color: var(--qc-warning);
}

.recipe .note {
    max-width: 360px;
    color: var(--qc-textMuted);
    font-size: 12px;
}

.hint {
    color: var(--qc-textMuted);
}

.load-error {
    margin: 0 0 12px;
    padding: 6px 8px;
    color: var(--qc-error);
    background: var(--qc-rowHighlight);
    border-radius: 4px;
}

.narrow-only {
    display: none;
}

.noscript {
    padding: 20px;
}

/* Narrow windows and phones: one column at a time, the lists or the open page. */
@media (max-width: 820px) {
    .screen {
        inset: 0;
        border-radius: 0;
        border: 0;
        padding: 10px 16px;
    }

    .narrow-only {
        display: inline-block;
    }

    .bar {
        flex-wrap: wrap;
    }

    .bar h1 {
        font-size: 20px;
    }

    #search {
        order: 10;
        flex: 1 1 100%;
        width: auto;
    }

    .columns {
        flex-direction: column;
    }

    .separator {
        display: none;
    }

    .categories {
        flex: none;
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 4px;
    }

    .categories .row {
        width: auto;
        flex: none;
        white-space: nowrap;
    }

    .entries {
        flex: 1;
    }

    .screen.show-page .categories,
    .screen.show-page .entries {
        display: none;
    }

    .screen:not(.show-page) .page {
        display: none;
    }

    .facts {
        grid-template-columns: 1fr;
        gap: 0 10px;
    }

    .facts .value {
        padding-top: 0;
        margin-bottom: 6px;
    }

    .hint {
        display: none;
    }
}
