/* Recepty: phone-first styles. Colours are tokens with a dark-mode override. */

:root {
    --bg: #faf7f2;
    --surface: #ffffff;
    --surface-2: #f1ece4;
    --border: #e3dcd1;
    --text: #2b2520;
    --muted: #7a6f65;
    --accent: #c4582f;
    --accent-text: #ffffff;
    --accent-soft: #f7e3d9;
    --danger: #b3261e;
    --warning-bg: #fff4d6;
    --warning-text: #6b4e00;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(60, 40, 20, 0.08);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1b1815;
        --surface: #26221e;
        --surface-2: #312c27;
        --border: #3d3731;
        --text: #f3ede6;
        --muted: #a99d91;
        --accent: #e07a4f;
        --accent-text: #1b1815;
        --accent-soft: #3f2a20;
        --danger: #f2706a;
        --warning-bg: #3d3216;
        --warning-text: #f5d98a;
        --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
        color-scheme: dark;
    }
}

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

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 17px;
    line-height: 1.5;
}

a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.5rem; }
img { max-width: 100%; display: block; }

.page { max-width: 1100px; margin: 0 auto; padding: 16px 16px 96px; }
.narrow { max-width: 640px; }
.muted { color: var(--muted); }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.error {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0 0 12px;
}

/* ---- buttons and inputs ---- */

.button, button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; padding: 0 16px;
    border-radius: 12px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button.danger, button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.link-button { background: none; border: none; color: var(--muted); font-weight: 500; min-height: 44px; padding: 0 4px; text-decoration: underline; }

input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="url"], textarea {
    width: 100%; min-height: 44px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
input:focus-visible, textarea:focus-visible, button:focus-visible, .button:focus-visible, a:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px;
}

/* ---- message page ---- */

.message { text-align: center; padding-top: 20vh; }

/* ---- login ---- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
    width: 100%; max-width: 360px; text-align: center;
    background: var(--surface); border-radius: 20px; padding: 32px 24px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 0; font-size: 1.75rem; }
.login-card .muted { margin: 0 0 12px; }
.login-logo { font-size: 3rem; line-height: 1; }

/* ---- top bar ---- */

.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar h1 { flex: 1; margin: 0; font-size: 1.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    text-decoration: none; font-size: 1.2rem;
}
.topbar .action { color: var(--accent); font-weight: 700; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; padding: 0 4px; background: none; border: 0; }

/* ---- home ---- */

.banner {
    background: var(--warning-bg); color: var(--warning-text);
    border-radius: 12px; padding: 10px 14px; margin: 0 0 12px;
}
.banner a { color: inherit; font-weight: 700; }
.search { margin-bottom: 12px; }
.search input { border-radius: 999px; padding-left: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
    display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px;
    border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.95rem;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 700px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
}
.card {
    display: block; overflow: hidden; text-decoration: none; color: inherit;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-image { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; }
.card-image img { width: 100%; height: 100%; object-fit: cover; }
.card-image .placeholder { font-size: 2.2rem; opacity: 0.5; }
.badge {
    position: absolute; right: 8px; bottom: 8px;
    background: rgba(0, 0, 0, 0.65); color: #fff; border-radius: 999px;
    width: 28px; height: 28px; display: grid; place-items: center; font-size: 0.8rem;
}
.card-body { padding: 8px 10px 10px; }
.card-body h2 { font-size: 1rem; margin: 0 0 2px; }
.card-body p { margin: 0; font-size: 0.85rem; }
.empty { text-align: center; padding: 48px 0; }
.logout { text-align: center; margin-top: 32px; }
.fab {
    position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom));
    background: var(--accent); color: var(--accent-text);
    border-radius: 999px; padding: 14px 20px; font-weight: 700; text-decoration: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

/* ---- recipe page ---- */

.recipe .chips.static { margin: 12px 0 4px; }
.recipe .chip { min-height: 32px; font-size: 0.9rem; }
.section { margin-top: 24px; }
.section h2 { font-size: 1.15rem; }
.section h4 { margin: 16px 0 6px; color: var(--muted); font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.03em; }
.tick { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.tick input { width: 22px; height: 22px; margin: 1px 0 0; flex-shrink: 0; accent-color: var(--accent); }
.tick input:checked + span { text-decoration: line-through; color: var(--muted); }
.step { margin: 0 0 12px; }
.step .n { font-weight: 700; color: var(--accent); margin-right: 4px; }
.meta { margin-top: 24px; font-size: 0.9rem; }
.actions { display: flex; gap: 10px; margin-top: 16px; }
.actions > * { flex: 1; }
.actions form button { width: 100%; }

.carousel { position: relative; margin: -16px -16px 0; }
.carousel-track {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    aspect-ratio: 4 / 3; background: var(--surface-2);
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-track img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: center; }
.carousel-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 999px;
    background: rgba(0, 0, 0, 0.45); color: #fff; border: 0; font-size: 1.4rem;
}
.carousel-nav.prev { left: 10px; }
.carousel-nav.next { right: 10px; }
.dots { display: flex; justify-content: center; gap: 6px; padding: 8px 0 0; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.dot.on { background: var(--accent); }
@media (min-width: 700px) {
    .carousel { margin: 0; border-radius: var(--radius); overflow: hidden; }
}

.video, .embed { margin: 0 0 16px; }
.video video { width: 100%; max-height: 70vh; border-radius: 12px; background: #000; }
.video figcaption, .embed figcaption { font-size: 0.9rem; margin-top: 4px; overflow-wrap: anywhere; }
.embed iframe { width: 100%; border: 0; border-radius: 12px; background: var(--surface-2); display: block; }
.embed-youtube iframe { aspect-ratio: 16 / 9; }
.embed-instagram iframe { height: 640px; max-width: 480px; }
.embed-tiktok iframe { height: 740px; max-width: 360px; }
.link-card { overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }

dialog.confirm-dialog {
    border: 0; border-radius: 18px; padding: 20px; max-width: min(92vw, 380px);
    background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
dialog.confirm-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog.confirm-dialog p { margin: 0 0 16px; }
.confirm-buttons { display: flex; gap: 10px; }
.confirm-buttons button { flex: 1; }

/* ---- recipe form ---- */

.recipe-form { display: flex; flex-direction: column; gap: 4px; }
.field { margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.field label, .field legend { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; padding: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chip-check { position: relative; display: inline-flex; }
.chip-check input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip-check span {
    display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
    border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.chip-check input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip-check input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.field .chips { margin-bottom: 0; }

.tiles { display: flex; flex-wrap: wrap; gap: 10px; }
.tiles.column { flex-direction: column; flex-wrap: nowrap; margin-bottom: 10px; }
.tiles.column:empty { display: none; }
.tile {
    position: relative; border-radius: 12px; overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--border);
}
/* Photo tiles: the thumbnail, then a bar with two full-size (44 px) buttons. */
.tile.photo { width: 104px; min-height: 148px; display: flex; flex-direction: column; }
.tile.photo img { width: 100%; height: 104px; object-fit: cover; }
.tile-bar { display: flex; border-top: 1px solid var(--border); }
.tile-bar > * { flex: 1; height: 44px; }
.tile-bar .cover { position: relative; margin: 0; cursor: pointer; }
.tile-bar .cover input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.tile-bar .cover span { display: grid; place-items: center; height: 100%; font-size: 1.2rem; color: var(--muted); }
.tile-bar .cover input:checked + span { background: var(--accent); color: var(--accent-text); }
.tile-bar .cover input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: -3px; }
.tile .remove {
    min-height: 0; padding: 0; border: 0; border-radius: 0;
    background: transparent; color: var(--text); font-size: 1rem;
}
.tile-bar .remove { border-left: 1px solid var(--border); }
.tile.wide { width: 100%; min-height: 52px; display: flex; align-items: center; padding: 4px 56px 4px 12px; }
.tile.wide .remove { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: 44px; height: 44px; }
.tile-label { overflow-wrap: anywhere; font-size: 0.95rem; }
.tile .progress { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 6px; border-radius: 3px; background: rgba(0, 0, 0, 0.3); overflow: hidden; }
.tile .progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.tile .tile-error { display: grid; place-items: center; flex: 1; padding: 6px; text-align: center; font-size: 0.75rem; color: var(--danger); }
.tile.photo .tile-error + .remove { height: 44px; border-top: 1px solid var(--border); }
.tile.wide .tile-error { place-items: center start; }
.tile.add {
    display: grid; place-items: center; cursor: pointer; border-style: dashed;
    color: var(--muted); font-size: 1.8rem;
}
.tile.add input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.button.block { width: 100%; margin-top: 8px; }
.inline-row { display: flex; gap: 8px; }
.inline-row input { flex: 1; }

/* ---- categories ---- */

.cat-list { list-style: none; margin: 0 0 20px; padding: 0; }
.cat-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.cat-rename { display: flex; gap: 8px; }
.cat-rename input { flex: 1; }
.cat-rename button { width: 44px; padding: 0; flex-shrink: 0; }
.cat-tools { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.cat-tools > span { flex: 1; font-size: 0.9rem; }
.cat-tools button { width: 44px; padding: 0; }
.upload-button { position: relative; overflow: hidden; }
.upload-button input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.hint { font-size: 0.85rem; margin: 6px 0 10px; }
[hidden] { display: none !important; }
.field .upload-button { display: flex; width: 100%; color: var(--text); font-size: 1rem; margin-bottom: 0; }
