/* PratoLeve — mobile-first, modo claro/escuro
 * Ideia: a proteína de cada receita aparece como o número de um dorsal de corrida.
 * Tipos: Barlow Condensed (títulos e números) + Barlow (texto). Fontes alojadas localmente (OFL).
 */

@font-face { font-family: "Barlow"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/barlow-400.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/barlow-500.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/barlow-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/barlow-condensed-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/barlow-condensed-700.woff2") format("woff2"); }

:root {
    --bg: #edf1e9;          /* salva pálida */
    --surface: #ffffff;
    --surface-2: #e2e8dd;
    --text: #13241a;        /* tinta verde-floresta */
    --muted: #57695c;
    --border: #d0d9cb;
    --accent: #1d5a3c;      /* folha */
    --accent-ink: #ffffff;
    --accent-soft: #d5e7d9;
    --bib: #d4f06a;         /* lima do dorsal */
    --bib-ink: #13241a;
    --pin: #edf1e9;
    --beet: #a22d59;        /* beterraba: calorias e favoritos */
    --beet-soft: #f6dde6;
    --danger: #b3261e;
    --radius-lg: 22px;
    --radius: 14px;
    --radius-sm: 10px;
    --tabbar-h: 66px;
    --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d1912;
        --surface: #15241b;
        --surface-2: #1d3025;
        --text: #e7efe3;
        --muted: #9bb0a0;
        --border: #284032;
        --accent: #8fd3a8;
        --accent-ink: #0d1912;
        --accent-soft: #1f3a2a;
        --bib: #d4f06a;
        --bib-ink: #13241a;
        --pin: #0d1912;
        --beet: #f28bb0;
        --beet-soft: #3a1f2b;
        --danger: #ff8a80;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0d1912;
    --surface: #15241b;
    --surface-2: #1d3025;
    --text: #e7efe3;
    --muted: #9bb0a0;
    --border: #284032;
    --accent: #8fd3a8;
    --accent-ink: #0d1912;
    --accent-soft: #1f3a2a;
    --bib: #d4f06a;
    --bib-ink: #13241a;
    --pin: #0d1912;
    --beet: #f28bb0;
    --beet-soft: #3a1f2b;
    --danger: #ff8a80;
    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: 17px/1.5 var(--font);
    min-height: 100dvh;
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}
body.login-page { padding-bottom: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.05; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout ---------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.topbar__brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 700; font-size: 1.5rem; letter-spacing: -.01em; }
main { max-width: 640px; margin: 0 auto; padding: 4px 16px 16px; }

.view__title { font-size: 2.75rem; margin: 12px 0 4px; }
.view__lead { color: var(--muted); font-size: 1.0625rem; margin-bottom: 20px; }

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(4, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: .8rem; font-weight: 500;
}
.tabbar svg { width: 24px; height: 24px; padding: 2px 14px; box-sizing: content-box; border-radius: 999px; transition: background-color .2s; }
.tabbar a[aria-current="page"] { color: var(--text); font-weight: 600; }
.tabbar a[aria-current="page"] svg { background: var(--bib); color: var(--bib-ink); }

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 16px;
}
.stack > * + * { margin-top: 22px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }

/* ---------- Formulários ---------- */
.field { display: block; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { display: block; font-weight: 600; font-size: .9rem; color: var(--muted); margin-bottom: 8px; padding: 0; }
.field > legend small { font-weight: 400; }
input[type="text"], input:not([type]), textarea {
    width: 100%;
    padding: 13px 15px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    font-size: 17px; /* evita zoom no iOS */
}
input:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { resize: vertical; min-height: 68px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips--scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; margin: 0 -16px 14px; padding-inline: 16px; scrollbar-width: none; }
.chips--scroll::-webkit-scrollbar { display: none; }
.chip { position: relative; flex-shrink: 0; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
    display: inline-block; padding: 8px 15px; border-radius: 999px;
    border: 1.5px solid var(--border); background: transparent;
    font-size: .95rem; font-weight: 500; white-space: nowrap; user-select: none;
    transition: background-color .15s, border-color .15s;
}
.chip input:checked + span { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Modo: três opções lado a lado */
.segmented { display: flex; background: var(--surface-2); border-radius: 16px; padding: 4px; gap: 4px; }
.segmented label { position: relative; flex: 1 1 0; min-width: 0; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
    display: block; text-align: center; padding: 10px 4px; border-radius: 12px;
    font-family: var(--display); font-size: 1.0625rem; font-weight: 600; white-space: nowrap;
    color: var(--muted); transition: background-color .15s, color .15s;
}
.segmented input:checked + span { background: var(--bib); color: var(--bib-ink); font-weight: 700; }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper output { min-width: 2ch; text-align: center; font-family: var(--display); font-weight: 700; font-size: 1.75rem; line-height: 1; }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 52px; padding: 0 22px;
    border: 1.5px solid transparent; border-radius: 999px;
    font-weight: 600; font-size: 1.0625rem; cursor: pointer; text-decoration: none;
    background: var(--surface-2); color: var(--text);
    transition: transform .1s, opacity .15s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--ghost { background: transparent; border-color: var(--text); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--link { background: none; min-height: 40px; padding: 0; color: var(--accent); font-size: 1rem; }
.btn--block { width: 100%; }
.btn--big { min-height: 58px; font-family: var(--display); font-size: 1.375rem; font-weight: 700; letter-spacing: .01em; }
.btn--fav { min-height: 42px; padding: 0 16px; font-size: 1rem; background: var(--beet-soft); color: var(--beet); }
.btn--fav[aria-pressed="true"] { background: var(--beet); color: var(--bg); }
.icon-btn {
    display: inline-grid; place-items: center;
    width: 42px; height: 42px; border-radius: 50%;
    border: 1.5px solid var(--border); background: var(--surface); cursor: pointer;
    font-size: 1.25rem; line-height: 1;
}
.chip-btn {
    border: 1.5px solid var(--border); background: transparent; border-radius: 999px;
    padding: 7px 13px; font-size: .9rem; cursor: pointer; color: var(--text);
}

/* ---------- Dorsal (proteína) ---------- */
.bib {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background-color: var(--bib); color: var(--bib-ink);
    border-radius: 10px;
    padding: 14px 10px 10px;
    text-align: center;
    /* os quatro alfinetes */
    background-image:
        radial-gradient(circle at 9px 9px, var(--pin) 3px, transparent 3.5px),
        radial-gradient(circle at calc(100% - 9px) 9px, var(--pin) 3px, transparent 3.5px),
        radial-gradient(circle at 9px calc(100% - 9px), var(--pin) 3px, transparent 3.5px),
        radial-gradient(circle at calc(100% - 9px) calc(100% - 9px), var(--pin) 3px, transparent 3.5px);
}
.bib__num { font-family: var(--display); font-weight: 700; font-size: 2.6rem; line-height: .9; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.bib__num small { font-size: .5em; letter-spacing: 0; margin-left: 1px; }
.bib__label { font-size: .75rem; font-weight: 600; margin-top: 2px; }

/* ---------- Cartões de receita ---------- */
.cards { display: grid; gap: 12px; margin-bottom: 16px; }
.recipe-card {
    display: grid; grid-template-columns: 84px 1fr; gap: 14px; align-items: start;
    text-align: left; width: 100%;
    background: var(--surface); border: 0; border-radius: var(--radius-lg);
    padding: 14px; cursor: pointer; color: inherit;
    transition: transform .12s;
}
.recipe-card:active { transform: scale(.985); }
.recipe-card .bib { min-height: 92px; }
.recipe-card__body { min-width: 0; padding-top: 2px; }
.recipe-card h3 { font-size: 1.35rem; margin-bottom: 4px; }
.recipe-card p { color: var(--muted); font-size: .95rem; line-height: 1.4; margin-bottom: 10px; }
.recipe-card__fav { color: var(--beet); margin-left: 4px; font-family: var(--font); }

.facts { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; padding: 0; margin: 0; font-size: .875rem; font-weight: 600; }
.facts li { display: inline-flex; align-items: center; gap: 5px; }
.facts svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .7; }
.facts .kcal { color: var(--beet); }

.alert { padding: 13px 15px; border-radius: var(--radius); background: var(--beet-soft); color: var(--text); margin-bottom: 14px; }

.skeleton { height: 120px; border-radius: var(--radius-lg); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- Detalhe (dialog) ---------- */
.sheet {
    width: 100%; max-width: 640px; height: 100dvh; max-height: 100dvh;
    margin: 0 auto; padding: 0; border: 0;
    background: var(--bg); color: var(--text);
}
.sheet::backdrop { background: rgb(0 0 0 / .45); }
.sheet[open] { animation: sheet-in .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 700px) {
    .sheet { height: calc(100dvh - 48px); margin-top: 24px; border-radius: var(--radius-lg); }
}
.sheet__inner { height: 100%; overflow-y: auto; padding: 0 18px calc(28px + env(safe-area-inset-bottom)); }
.sheet__bar {
    position: sticky; top: 0; z-index: 2;
    display: flex; justify-content: space-between; align-items: center;
    padding: calc(env(safe-area-inset-top) + 10px) 0 10px;
    background: var(--bg);
}
.rd-kicker { color: var(--muted); font-weight: 600; font-size: .9rem; margin: 6px 0 6px; }
.rd-title { font-size: 2.6rem; line-height: 1; margin-bottom: 10px; }
.rd-desc { font-size: 1.0625rem; }
.rd-saved { color: var(--beet); font-weight: 600; font-size: .9rem; }

.rd-numbers { display: grid; grid-template-columns: 112px 1fr; gap: 10px; margin: 18px 0 6px; }
.rd-numbers .bib { min-height: 120px; }
.rd-numbers .bib__num { font-size: 3.4rem; }
.splits { display: grid; grid-template-rows: repeat(3, 1fr); background: var(--surface); border-radius: var(--radius); padding: 4px 14px; }
.splits div { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--border); padding: 6px 0; }
.splits div:last-child { border-bottom: 0; }
.splits span { color: var(--muted); font-size: .9rem; }
.splits b { font-family: var(--display); font-size: 1.375rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.splits .kcal b { color: var(--beet); }
.rd-note { color: var(--muted); font-size: .8rem; margin-bottom: 22px; }

.rd-section { font-size: 1.75rem; margin: 26px 0 10px; }
.ingredients { list-style: none; margin: 0; background: var(--surface); border-radius: var(--radius); padding: 2px 16px; }
.ingredients li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.ingredients span { order: -1; }
.ingredients li:last-child { border-bottom: 0; }
.ingredients b { font-weight: 600; color: var(--accent); text-align: right; max-width: 45%; }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 38px 1fr; gap: 10px; margin-bottom: 14px; }
.steps li::before {
    content: counter(step);
    font-family: var(--display); font-weight: 700; font-size: 1.75rem; line-height: 1;
    color: var(--accent);
}
.tip { border-left: 4px solid var(--bib); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; padding: 12px 15px; margin: 22px 0; }
.tip strong { font-family: var(--display); font-size: 1.125rem; display: block; margin-bottom: 2px; }

/* ---------- Chat ---------- */
.chat { margin-top: 26px; }
.chat__head { display: flex; justify-content: space-between; align-items: center; }
.chat__head h3 { font-size: 1.75rem; margin: 0; }
.chat__msgs { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 12px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.msg--user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 5px; }
.msg--assistant { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 5px; }
.msg--error { align-self: center; background: var(--beet-soft); font-size: .9rem; }
.msg--typing::after { content: "▍"; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.chat__suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chat__form { display: flex; gap: 8px; }
.chat__form input { flex: 1; }

/* ---------- Conta ---------- */
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.card h2 { font-size: 1.5rem; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); z-index: 50;
    background: var(--text); color: var(--bg);
    padding: 11px 18px; border-radius: 999px; font-size: .95rem; font-weight: 500; max-width: calc(100% - 32px);
}

/* ---------- Login ---------- */
.login {
    max-width: 420px; margin: 0 auto; min-height: 100dvh;
    display: flex; flex-direction: column; justify-content: center;
    padding: calc(env(safe-area-inset-top) + 32px) 20px calc(env(safe-area-inset-bottom) + 48px);
}
.login__bib {
    margin: 0 auto 28px; max-width: 300px; padding: 30px 20px 24px;
    transform: rotate(-2deg);
}
.login__bib .bib__num { font-size: 3.6rem; }
.login__bib .bib__label { font-size: .95rem; font-weight: 500; margin-top: 8px; max-width: 22ch; }
.login__card { text-align: center; }
.login__card form { text-align: left; }
.login__card .field { margin-bottom: 16px; }
.login__hint { color: var(--muted); font-size: .9rem; margin: 12px 0 4px; }

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

/* Páginas simples (erro, sem ligação) */
.login__brand { text-align: center; }
.login__brand h1 { font-size: 3rem; margin-top: 12px; }
