/* Design tokens and the few element styles every screen shares.
   Component-specific styles live next to each component (*.razor.css). */

:root {
    --bg: #F3F6F4;
    --surface: #FFFFFF;
    --ink: #14201B;
    --muted: #55635C;

    --green: #0B6B4F;
    --green-hover: #084F3B;
    --green-tint: #E1F0EA;

    --amber: #9A4A06;
    --amber-text: #7A3A04;
    --amber-tint: #FCEBD5;

    --blue: #1D4E89;
    --blue-tint: #DCE9F7;

    --red: #B3261E;

    --border: #DCE4DF;

    --font-text: Inter, system-ui, sans-serif;
    --font-display: 'Space Grotesk', Inter, system-ui, sans-serif;

    --radius-card: 14px;
    --radius-control: 12px;
    --radius-button: 16px;
    --tap: 44px;

    --track: #E1EAE5;
    /* Height of the phone tab bar, for things that sit just above it. */
    --tabbar-height: calc(57px + max(14px, env(safe-area-inset-bottom)));
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-text);
    font-size: 16px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

h1, h2, h3 {
    font-family: var(--font-display);
    line-height: 1.15;
}

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

a:hover {
    color: var(--green-hover);
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

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

/* Headings receive focus after navigation so screen readers announce the new page; no ring needed for that. */
h1:focus {
    outline: none;
}

.page-title {
    margin: 4px 0 12px;
    font-size: 28px;
    font-weight: 700;
}

.placeholder, .hint {
    color: var(--muted);
}

.hint {
    font-size: 13px;
}

.app-status {
    margin: 0;
    padding: 24px 20px;
    color: var(--muted);
}

/* Buttons (also used on links that act as buttons) */
.btn {
    min-height: 48px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-button);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn:disabled {
    cursor: default;
    opacity: 0.7;
}

.btn-primary {
    background: var(--green);
    color: #FFFFFF;
    font-family: var(--font-display);
    font-size: 17px;
}

.btn-primary:hover:not(:disabled) {
    background: var(--green-hover);
    color: #FFFFFF;
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--green);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--green);
    color: var(--green-hover);
}

.btn-quiet {
    min-height: var(--tap);
    padding: 0 12px;
    background: none;
    color: inherit;
    text-decoration: underline;
}

/* Forms */
.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 14px;
    font-weight: 600;
}

.field input,
.field select,
.field textarea {
    min-height: 48px;
    box-sizing: border-box;
    width: 100%;
    padding: 0 14px;
    border: 1px solid var(--muted);
    border-radius: var(--radius-control);
    background: var(--surface);
}

/* Two lines to start with; where the browser can, it grows with what is typed. */
.field textarea {
    display: block;
    min-height: 70px;
    padding: 11px 14px;
    line-height: 1.45;
    resize: vertical;
    field-sizing: content;
}

/* A hint with a count at its end, such as "185 of 200". */
.hint-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.hint-row .count {
    flex: none;
    font-variant-numeric: tabular-nums;
}

.field-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

/* A group of radio buttons. */
.choice {
    margin: 0;
    padding: 0;
    border: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.choice legend {
    padding: 0;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 600;
}

.choice label {
    min-height: var(--tap);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
}

.choice input[type=radio] {
    flex: none;
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--green);
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-ok {
    margin: 0;
    color: var(--green-hover);
    font-size: 15px;
    font-weight: 500;
}

.form-error {
    margin: 0;
    color: var(--red);
    font-size: 15px;
    font-weight: 500;
}

/* A sentence above a form that says who the form is for. */
.form-note {
    margin: 0 0 16px;
    color: var(--ink);
    font-size: 15px;
}

.form-alt {
    margin: 20px 0 0;
    color: var(--muted);
    font-size: 15px;
}

/* Pieces several screens share */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.card {
    box-sizing: border-box;
    padding: 14px 16px;
    border-radius: var(--radius-card);
    background: var(--surface);
}

a.card {
    color: var(--ink);
    text-decoration: none;
}

a.card:hover {
    color: var(--ink);
    box-shadow: 0 0 0 1px var(--border);
}

/* A list of cards: one column on a phone, a grid from 900px. */
.cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}

.cards > li {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.cards > li > * {
    flex: 1;
}

.section-label {
    margin: 0;
    color: var(--muted);
    font-family: var(--font-text);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    line-height: 1.45;
    text-transform: uppercase;
}

.amount {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.badge {
    flex: none;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-amber {
    background: var(--amber-tint);
    color: var(--amber-text);
}

.badge-green {
    background: var(--green-tint);
    color: var(--green-hover);
}

.badge-outline {
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

/* A text-only button, such as "Edit" or "+ Add an item". */
.link-button {
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
    padding: 0 4px;
    border: 0;
    background: none;
    color: var(--green);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.link-button:hover {
    color: var(--green-hover);
}

.link-button.danger {
    color: var(--red);
    font-weight: 500;
}

.add-dashed {
    min-height: 56px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border: 1.5px dashed var(--green);
    border-radius: var(--radius-card);
    background: none;
    color: var(--green-hover);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.add-dashed:hover {
    background: var(--green-tint);
    color: var(--green-hover);
}

.btn-danger {
    background: var(--red);
    color: #FFFFFF;
}

.empty {
    margin: 0;
    padding: 20px 16px;
    border-radius: var(--radius-card);
    background: var(--surface);
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.empty p {
    margin: 0;
}

/* "Are you sure?" shown in place, before something is removed. */
.confirm {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--radius-card);
    background: var(--amber-tint);
    color: var(--amber-text);
    font-size: 15px;
}

.confirm p {
    margin: 0;
}

.confirm .buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* A page that takes the whole phone screen (scan, review): no space chip, no tab bar. */
@media (max-width: 899.98px) {
    .shell:has(.flow-page) .top,
    .shell:has(.flow-page) .tabs {
        display: none;
    }

    .shell:has(.flow-page) .content {
        padding: 0;
    }

    .flow-page {
        min-height: 100vh;
        min-height: 100dvh;
    }

    /* On a phone the page's own heading stands in for this one. */
    .phone-sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

@media (min-width: 900px) {
    .cards {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 14px;
    }

    /* Forms and single-item pages stay readable instead of stretching across the column. */
    .narrow {
        max-width: 560px;
    }

    .form-actions {
        flex-direction: row;
    }
}

/* Shown by index.html before the app has started, and if it fails. */
.app-boot {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    padding: 12px 20px;
    background: var(--amber-tint);
    color: var(--amber-text);
    font-size: 15px;
}

#blazor-error-ui a {
    color: inherit;
    margin-left: 12px;
}
