/* HomeMadeFoodGifts – themes are CSS custom properties on .theme-classic / .theme-modern.
   The body carries the app-shell theme; a public jar page wraps itself in the owner's chosen theme. */

/* ---------- Theme tokens ---------- */
.theme-classic {
    --bg: #fbfaf6;
    --surface: #ffffff;
    --fg: #141414;
    --muted: #5c5c5c;
    --accent: #141414;
    --accent-fg: #ffffff;
    --accent-soft: #efede6;
    --border: #141414;
    --border-soft: #d8d5cb;
    --danger: #8b1a1a;
    --success: #234d20;
    --radius: 2px;
    --shadow: none;
    --font-body: "EB Garamond", Georgia, "Times New Roman", serif;
    --font-head: "Cormorant Garamond", Georgia, serif;
    --head-weight: 700;
    --card-border: 1px solid var(--border);
    --card-outline: 3px double var(--border);
}

.theme-modern {
    --bg: #fff6f2;
    --surface: #ffffff;
    --fg: #2b1d22;
    --muted: #7a6870;
    --accent: #c2185b;
    --accent-fg: #ffffff;
    --accent-soft: #fde4ec;
    --border: #f0d6de;
    --border-soft: #f3e3e8;
    --danger: #c62828;
    --success: #2e7d32;
    --radius: 14px;
    --shadow: 0 6px 24px rgba(194, 24, 91, .08);
    --font-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-head: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --head-weight: 700;
    --card-border: 1px solid var(--border);
    --card-outline: none;
}

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

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.6;
}

h1, h2, h3, legend {
    font-family: var(--font-head);
    font-weight: var(--head-weight);
    line-height: 1.2;
    margin: 0 0 .5em;
}
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
.theme-classic h1, .theme-classic h2 { letter-spacing: .01em; }

a { color: var(--accent); text-underline-offset: 3px; }
.theme-classic a { color: var(--fg); }
p { margin: 0 0 1em; }
code { font-size: .9em; background: var(--accent-soft); padding: .1em .35em; border-radius: 4px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.pre-line { white-space: pre-line; }
.ellipsis { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visually-hidden, .hp { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.req { color: var(--danger); }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.content { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.topbar {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    padding: .75rem 1rem; background: var(--surface);
    border-bottom: var(--card-border);
}
.theme-classic .topbar { border-bottom: var(--card-outline); }
.brand { display: flex; align-items: center; gap: .5rem; font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; text-decoration: none; color: var(--fg); }
.brand-mark { font-size: 1.5rem; }

.nav { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; margin-left: auto; }
.nav a { text-decoration: none; color: var(--fg); }
.nav a.active, .nav a:hover { text-decoration: underline; }
.nav-prefs { display: flex; align-items: center; gap: .4rem; font-size: .85rem; padding: 0 .5rem; border-left: 1px solid var(--border-soft); border-right: 1px solid var(--border-soft); }
.nav-prefs a.active { font-weight: 700; }
.nav-label { color: var(--muted); }
.nav-label:not(:first-child) { margin-left: .5rem; }
.nav-user { font-weight: 600; }
.nav-toggle, .nav-toggle-label { display: none; }

.site-footer { text-align: center; padding: 1.5rem 1rem; color: var(--muted); font-size: .9rem; }
.site-footer .ornament { display: block; font-size: 1.4rem; }

@media (max-width: 760px) {
    .nav-toggle-label { display: block; margin-left: auto; font-size: 1.6rem; cursor: pointer; }
    .nav { display: none; width: 100%; flex-direction: column; align-items: flex-start; margin-left: 0; }
    .nav-toggle:checked ~ .nav { display: flex; }
    .nav-prefs { border: 0; padding: 0; flex-wrap: wrap; }
}

/* ---------- Building blocks ---------- */
.card {
    background: var(--surface); border: var(--card-border); border-radius: var(--radius);
    padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.theme-classic .card { outline: 1px solid var(--border); outline-offset: 4px; margin: 6px 6px 1.6rem; }
.card.narrow { max-width: 30rem; margin-left: auto; margin-right: auto; }
.theme-classic .card.narrow { margin-left: auto; margin-right: auto; }
.empty { padding: 2.5rem; }
.big-icon { font-size: 3.5rem; line-height: 1; margin-bottom: .5rem; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1, .page-head h2 { margin-bottom: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; color: var(--muted); margin-bottom: .25rem; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 46rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions.center { justify-content: center; }
.links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; font-size: .95rem; }

.ornament-divider { text-align: center; font-size: 1.6rem; color: var(--muted); margin: 1rem 0; }
.theme-classic .ornament-divider::before, .theme-classic .ornament-divider::after {
    content: ""; display: inline-block; width: 4rem; height: 1px; background: var(--border); vertical-align: middle; margin: 0 .75rem;
}
.theme-modern .ornament-divider { color: var(--accent); opacity: .5; }

/* ---------- Forms ---------- */
label { display: block; margin-bottom: .9rem; font-weight: 600; font-size: .95rem; }
label.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
input, select, textarea {
    display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem;
    font: inherit; font-weight: 400; color: var(--fg); background: var(--surface);
    border: 1px solid var(--border-soft); border-radius: calc(var(--radius) / 1.5);
}
.theme-classic input, .theme-classic select, .theme-classic textarea { border-color: var(--border); }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; margin: 0; accent-color: var(--accent); }
textarea { resize: vertical; }
fieldset { border: var(--card-border); }
legend { padding: 0 .4rem; font-size: 1.3rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1rem; }
.grid-2.tight { gap: 0 .5rem; grid-template-columns: 1fr 1fr; }
.inline-form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.inline-form label { margin-bottom: 0; }
.inline-form input:not([type=checkbox]) { min-width: 14rem; }
.field-error { color: var(--danger); font-size: .875rem; font-weight: 400; margin-top: .25rem; }
.validation-message { color: var(--danger); font-size: .875rem; font-weight: 400; }
.pin-input { font-size: 1.6rem; letter-spacing: .3em; text-align: center; max-width: 12rem; margin: .3rem auto; }

button, .button {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    padding: .55rem 1.1rem; font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
    color: var(--accent-fg); background: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius);
}
.theme-classic button, .theme-classic .button { text-transform: uppercase; letter-spacing: .08em; font-size: .85rem; }
button:hover, .button:hover { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
.theme-classic button.secondary, .theme-classic .button.secondary { color: var(--fg); border-color: var(--fg); }
button.accent, .button.accent { background: var(--accent); }
.theme-classic button.accent { background: var(--fg); }
button.danger, .button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.small, .button.small { padding: .3rem .7rem; font-size: .85rem; }
button.link { background: none; border: 0; padding: 0; color: var(--fg); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: inherit; text-decoration: underline; }
button.icon { padding: .25rem .5rem; background: transparent; color: var(--fg); border-color: var(--border-soft); }
button.icon.danger { color: var(--danger); }
.block { width: 100%; }
form.inline { display: inline; }

.alert { padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.alert ul { margin: .5rem 0 0; padding-left: 1.2rem; }
.alert.error { color: var(--danger); border-color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.alert.success { color: var(--success); border-color: var(--success); background: color-mix(in srgb, var(--success) 6%, var(--surface)); }
.alert.info { border-color: var(--border); background: var(--accent-soft); }
.success { color: var(--success); font-weight: 600; }

.badge { display: inline-block; padding: .1rem .55rem; font-size: .75rem; font-weight: 600; border-radius: 999px; border: 1px solid var(--border-soft); background: var(--accent-soft); color: var(--fg); }
.theme-classic .badge { border-radius: 0; border-color: var(--border); background: transparent; text-transform: uppercase; letter-spacing: .08em; }
.badge.accent, .badge.state-published { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.badge.state-blank { border-style: dashed; }

.loading { display: flex; align-items: center; gap: .6rem; color: var(--muted); padding: 2rem 0; justify-content: center; }
.spinner { width: 1.1rem; height: 1.1rem; border: 2px solid var(--border-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: var(--card-border); margin-bottom: 1rem; }
.tabs button, .tabs a {
    background: transparent; color: var(--muted); border: 0; border-bottom: 3px solid transparent; border-radius: 0;
    padding: .6rem .9rem; text-decoration: none; font-weight: 600; text-transform: none; letter-spacing: 0; font-size: .95rem;
}
.tabs .active { color: var(--fg); border-bottom-color: var(--accent); }
.theme-classic .tabs .active { border-bottom-color: var(--fg); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.table tr.highlight { background: var(--accent-soft); }
.table td.actions { white-space: nowrap; }
.plain-list { list-style: none; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--border-soft); }
.pager { display: flex; gap: 1rem; justify-content: center; align-items: center; margin: 1rem 0; }

/* ---------- Home ---------- */
.hero { text-align: center; padding: 2.5rem 0 1rem; }
.hero .lead { margin: 0 auto 1.5rem; }
.hero .actions { justify-content: center; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
.feature-icon { font-size: 2rem; }

/* ---------- My pages ---------- */
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.page-card h2 { font-size: 1.3rem; margin: .4rem 0; }
.page-card h2 a { color: var(--fg); text-decoration: none; }
.page-card-head { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ---------- Editor ---------- */
.editor fieldset.card { padding-top: .75rem; }
.rows { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.row { display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; }
.row input, .row textarea { margin-top: 0; }
.row-name { flex: 1 1 14rem; min-width: 12rem; }
.row .qty { width: 6rem; flex: 0 0 6rem; }
.row .unit { width: 6rem; flex: 0 0 6rem; }
.row .note { flex: 1 1 9rem; }
.row-buttons { display: flex; gap: .25rem; }
.step-no { font-family: var(--font-head); font-weight: 700; padding-top: .55rem; min-width: 1.5rem; }
.sticky-actions {
    position: sticky; bottom: 0; z-index: 5; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
    padding: .75rem 1rem; background: var(--surface); border-top: var(--card-border); margin: 0 -1rem;
}

.picker { position: relative; }
.picker input.linked { padding-right: 2rem; }
.picker-linked { position: absolute; right: .6rem; top: .55rem; color: var(--success); font-weight: 700; }
.picker-list {
    position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: .2rem 0 0; padding: .25rem 0; list-style: none;
    background: var(--surface); border: var(--card-border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .12); max-height: 16rem; overflow-y: auto;
}
.picker-list li { padding: .4rem .75rem; cursor: pointer; }
.picker-list li:hover { background: var(--accent-soft); }
.picker-suggest { border-top: 1px solid var(--border-soft); color: var(--accent); font-weight: 600; }

.theme-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.theme-option { position: relative; cursor: pointer; font-weight: 400; margin: 0; }
.theme-option input { position: absolute; opacity: 0; }
.theme-sample {
    display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: 1.25rem;
    background: var(--bg); color: var(--fg); border: var(--card-border); border-radius: var(--radius);
    font-family: var(--font-body); box-shadow: var(--shadow);
}
.theme-classic .theme-sample { outline: 1px solid var(--border); outline-offset: 3px; }
.sample-title { font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; text-align: center; }
.sample-ornament { color: var(--muted); }
.theme-modern .sample-ornament { color: var(--accent); }
.theme-name { display: block; text-align: center; margin-top: .5rem; font-weight: 600; }
.theme-option.selected .theme-sample { box-shadow: 0 0 0 3px var(--accent); }
.theme-classic.theme-option.selected .theme-sample { box-shadow: 0 0 0 3px #141414; }
.allergen-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .25rem 1rem; padding: .75rem 1rem; margin-bottom: 1rem; }

/* ---------- Public jar page ---------- */
.page-view { background: var(--bg); color: var(--fg); font-family: var(--font-body); margin: -1.5rem -1rem 0; padding: 1.5rem 1rem 2rem; }
.page-view .card { max-width: 46rem; margin-left: auto; margin-right: auto; }
.jar-header { text-align: center; }
.jar-header h1 { font-size: clamp(2rem, 6vw, 3rem); }
.subtitle { font-style: italic; color: var(--muted); font-size: 1.15rem; }
.theme-classic .jar { border: var(--card-outline); padding: 2rem; }
.theme-classic .jar-header::before { content: "❧"; display: block; font-size: 1.6rem; color: var(--muted); }
.dedication blockquote {
    margin: 0 0 1.5rem; padding: 1rem 1.5rem; font-size: 1.25rem; font-style: italic; text-align: center; white-space: pre-line;
    background: var(--accent-soft); border-radius: var(--radius);
}
.theme-classic .dedication blockquote { background: transparent; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .75rem; margin: 0 0 1.5rem; }
.facts div { text-align: center; }
.facts.compact div { text-align: left; }
.facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.recipe h2, .jar section > h2 { border-bottom: 1px solid var(--border-soft); padding-bottom: .3rem; margin-top: 1.5rem; }
.theme-classic .recipe h2, .theme-classic .jar section > h2 { border-bottom-color: var(--border); text-align: center; }
.ingredients { list-style: none; padding: 0; }
.ingredients li { padding: .3rem 0; border-bottom: 1px dotted var(--border-soft); }
.ingredients .qty { display: inline-block; min-width: 6rem; font-weight: 600; }
.steps li { margin-bottom: .6rem; }
.allergens { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; margin: .75rem 0; font-size: .9rem; }
.allergens-label { font-weight: 600; }
.allergen { padding: .1rem .5rem; border: 1px solid var(--danger); color: var(--danger); border-radius: 999px; }
.theme-classic .allergen { border-radius: 0; }
.cook { display: flex; gap: 1rem; align-items: center; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border-soft); }
.cook-name { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; margin: 0; }
.avatar { width: 4rem; height: 4rem; border-radius: 50%; object-fit: cover; border: var(--card-border); }
.theme-classic .avatar { filter: grayscale(1); }
.markdown p:last-child { margin-bottom: 0; }
.owner-bar { max-width: 46rem; margin: 0 auto .75rem; text-align: right; font-size: .9rem; }
.blank-page .actions { margin-top: 1rem; }

/* ---------- Management ---------- */
.overview { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: start; }
.qr-box { text-align: center; }
.qr-box img { display: block; margin: 0 auto .75rem; border: var(--card-border); padding: .5rem; background: #fff; }
.link-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; word-break: break-all; }
@media (max-width: 640px) { .overview { grid-template-columns: 1fr; } }
.notes { list-style: none; padding: 0; margin: 0; }
.note { padding: 1rem 0; border-bottom: 1px solid var(--border-soft); }
.note.unread { border-left: 4px solid var(--accent); padding-left: .75rem; }
.note-head { display: flex; gap: .75rem; flex-wrap: wrap; align-items: baseline; margin-bottom: .3rem; }
.external-logins { display: flex; flex-direction: column; gap: .5rem; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); margin: 1rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }
.merge { display: inline-flex; gap: .25rem; align-items: center; }
.merge .qty { width: 4.5rem; margin: 0; padding: .3rem .4rem; }

/* ---------- Labels (screen preview + print). Mirrors the PDF layout (A4). ---------- */
.label-sheet { display: grid; gap: 0; background: #fff; color: #000; margin: 1rem auto; width: 210mm; max-width: 100%; border: 1px dashed #bbb; font-family: var(--font-body); }
.label-sheet.size-small { grid-template-columns: repeat(3, 1fr); }
.label-sheet.size-medium { grid-template-columns: repeat(2, 1fr); }
.label-sheet.size-large { grid-template-columns: repeat(2, 1fr); }
.label { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2mm; overflow: hidden; break-inside: avoid; border: 1px dotted #ddd; }
.size-small .label { height: 37mm; font-size: 7pt; }
.size-medium .label { height: 57mm; font-size: 10pt; }
.size-large .label { height: 148mm; font-size: 14pt; }
.label-qr svg { display: block; }
.size-small .label-qr svg { width: 26mm; height: 26mm; }
.size-medium .label-qr svg { width: 42mm; height: 42mm; }
.size-large .label-qr svg { width: 80mm; height: 80mm; }
.label-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.label-pin { font-weight: 700; letter-spacing: .1em; }

@media print {
    @page { size: A4; margin: 0; }
    body { background: #fff; }
    .no-print, .topbar, .site-footer, #blazor-error-ui, .owner-bar { display: none !important; }
    .content { padding: 0; max-width: none; }
    .label-sheet { margin: 0; width: 210mm; border: 0; }
    .label { border: 0; }
    .card { box-shadow: none; }
}

/* ---------- Blazor error UI ---------- */
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; width: 100%; z-index: 1000;
    padding: .75rem 1.25rem; background: #ffe9a8; color: #222; box-shadow: 0 -1px 4px rgba(0, 0, 0, .2);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
