/* ===== Food scan: home entry, camera, result sheet (food-scan.js) ===== */

/* ---------- Home entry: a slim 3D row between the week and the challenges ---------- */
.fs-entry {
    width: 100%;
    min-height: 62px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px 8px 10px;
    border: 2px solid #ececfb;
    border-radius: 20px;
    background: var(--card-bg);
    box-shadow: 0 4px 0 #e4e4f7;
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
}
.fs-entry:active { transform: translateY(4px); box-shadow: 0 0 0 #e4e4f7; }
.fs-entry-icon {
    position: relative;
    width: 42px;
    height: 42px;
    flex: none;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 14px;
    background: var(--tint-primary);
    color: var(--primary);
}
.fs-entry-icon i {
    position: absolute;
    left: 9px;
    right: 9px;
    top: 50%;
    height: 2px;
    border-radius: 2px;
    background: var(--violet);
    box-shadow: 0 0 6px rgba(139, 92, 246, 0.7);
    animation: fsEntryLaser 5s ease-in-out infinite;
}
@keyframes fsEntryLaser {
    0%, 62%, 100% { transform: translateY(0); opacity: 0; }
    68% { transform: translateY(-11px); opacity: 1; }
    80% { transform: translateY(11px); opacity: 1; }
    88% { transform: translateY(0); opacity: 0; }
}
.fs-entry-label { flex: 1; min-width: 0; font-size: 16px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-entry-go { flex: none; display: grid; place-items: center; color: var(--text-muted); }
.fs-entry-plus { display: inline-flex; align-items: center; gap: 4px; }

html[data-theme="dark"] .fs-entry { border-color: #2e2850; box-shadow: 0 4px 0 #2a2448; }
html[data-theme="dark"] .fs-entry:active { box-shadow: 0 0 0 #2a2448; }
html[data-theme="dark"] .fs-entry-icon { color: #a5b4fc; }

/* ---------- Camera ---------- */
.fs-cam {
    --fs-win-w: min(78vw, 300px);
    --fs-win-h: calc(var(--fs-win-w) * 0.6);
    position: fixed;
    inset: 0;
    z-index: 160;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0d0b1c;
    color: #fff;
    animation: fsCamIn 0.28s var(--ease-out, ease-out) both;
}
.fs-cam.is-leaving { animation: fsCamOut 0.22s ease-in both; }
@keyframes fsCamIn { from { opacity: 0; transform: scale(1.04); } }
@keyframes fsCamOut { to { opacity: 0; transform: scale(1.03); } }

.fs-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.4s;
}
.fs-cam.is-live .fs-video { opacity: 1; }

.fs-top {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 10px;
}
.fs-round {
    width: 44px;
    height: 44px;
    flex: none;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 15px;
    background: rgba(13, 11, 28, 0.55);
    color: #fff;
    cursor: pointer;
}
.fs-round[hidden] { display: grid; visibility: hidden; }
.fs-round.is-on { background: #fde68a; color: #3b1d00; }
.fs-round:active { transform: scale(0.92); }
.fs-quota {
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(13, 11, 28, 0.55);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.fs-stage {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
}
/* The window darkens everything around it with one large shadow. */
.fs-window {
    position: relative;
    width: var(--fs-win-w);
    height: var(--fs-win-h);
    border-radius: 26px;
    box-shadow: 0 0 0 100vmax rgba(13, 11, 28, 0.62);
    transition: transform 0.35s var(--ease-spring, ease);
}
.fs-cam:not(.is-live) .fs-window { box-shadow: none; }
.fs-corner {
    position: absolute;
    width: 38px;
    height: 38px;
    border: 5px solid #fff;
    transition: border-color 0.2s, transform 0.35s var(--ease-spring, ease);
}
.fs-corner.is-tl { top: -3px; left: -3px; border-right: 0; border-bottom: 0; border-top-left-radius: 26px; }
.fs-corner.is-tr { top: -3px; right: -3px; border-left: 0; border-bottom: 0; border-top-right-radius: 26px; }
.fs-corner.is-bl { bottom: -3px; left: -3px; border-right: 0; border-top: 0; border-bottom-left-radius: 26px; }
.fs-corner.is-br { bottom: -3px; right: -3px; border-left: 0; border-top: 0; border-bottom-right-radius: 26px; }
.fs-laser {
    position: absolute;
    left: 14px;
    right: 14px;
    top: 50%;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, transparent, #a78bfa 18%, #c4b5fd 50%, #a78bfa 82%, transparent);
    box-shadow: 0 0 14px 3px rgba(139, 92, 246, 0.55);
    animation: fsLaser 2.2s ease-in-out infinite;
}
.fs-cam.is-burst .fs-laser { animation-duration: 0.7s; }
@keyframes fsLaser {
    0%, 100% { transform: translateY(calc(var(--fs-win-h) * -0.36)); }
    50% { transform: translateY(calc(var(--fs-win-h) * 0.36)); }
}
.fs-found {
    position: absolute;
    inset: 0;
    border-radius: 26px;
    background: rgba(34, 197, 94, 0.22);
    opacity: 0;
}
.fs-cam.is-locked .fs-corner { border-color: #4ade80; }
.fs-cam.is-locked .fs-corner.is-tl { transform: translate(6px, 6px); }
.fs-cam.is-locked .fs-corner.is-tr { transform: translate(-6px, 6px); }
.fs-cam.is-locked .fs-corner.is-bl { transform: translate(6px, -6px); }
.fs-cam.is-locked .fs-corner.is-br { transform: translate(-6px, -6px); }
.fs-cam.is-locked .fs-laser { opacity: 0; }
.fs-cam.is-locked .fs-found { animation: fsFlash 0.6s ease-out both; }
@keyframes fsFlash { 0% { opacity: 1; } 100% { opacity: 0.35; } }

.fs-hint {
    min-height: 34px;
    margin: 0;
    padding: 7px 14px;
    border-radius: 12px;
    background: rgba(13, 11, 28, 0.55);
    font-size: 15px;
    font-weight: 700;
    text-align: center;
}
.fs-hint.is-error { color: #fde68a; animation: fsShake 0.4s; }
@keyframes fsShake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.fs-manual {
    position: relative;
    z-index: 2;
    display: flex;
    gap: 8px;
    margin: 0 20px 14px;
}
.fs-manual[hidden] { display: none; }
.fs-manual input {
    flex: 1;
    min-width: 0;
    height: 52px;
    padding: 0 16px;
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    background: rgba(13, 11, 28, 0.75);
    color: #fff;
    font: inherit;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.04em;
}
.fs-manual input:focus { outline: none; border-color: #a78bfa; }
.fs-manual input::placeholder { color: rgba(255, 255, 255, 0.45); letter-spacing: 0; font-weight: 700; }
.fs-manual button {
    width: 52px;
    height: 52px;
    flex: none;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 16px;
    background: var(--grad-primary);
    box-shadow: 0 4px 0 var(--primary-3d);
    color: #fff;
    cursor: pointer;
}
.fs-manual button:active { transform: translateY(4px); box-shadow: none; }

.fs-bottom {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 6px 24px calc(env(safe-area-inset-bottom, 0px) + 26px);
}
.fs-side {
    justify-self: start;
    width: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 0;
    border: 0;
    background: none;
    color: #fff;
    cursor: pointer;
}
.fs-side small { font-size: 11px; font-weight: 700; color: rgba(255, 255, 255, 0.7); }
button.fs-side { height: 56px; justify-content: center; border-radius: 18px; background: rgba(13, 11, 28, 0.55); }
/* Shutter: white ring, 3D indigo core that sinks when pressed. */
.fs-shutter {
    width: 84px;
    height: 84px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 5px solid #fff;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}
.fs-shutter span {
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--grad-primary);
    box-shadow: 0 5px 0 var(--primary-3d);
    color: #fff;
    transform: translateY(-3px);
    transition: transform 0.1s, box-shadow 0.1s;
}
.fs-shutter:active span { transform: translateY(2px); box-shadow: 0 0 0 var(--primary-3d); }
.fs-cam.is-burst .fs-shutter span { animation: fsPulse 0.7s ease-in-out infinite; }
@keyframes fsPulse { 50% { filter: brightness(1.25); } }

.fs-cam.is-nocam .fs-window { opacity: 0.35; }
.fs-cam.is-nocam .fs-laser { display: none; }
.fs-cam.is-nocam .fs-shutter { opacity: 0.4; }

/* ---------- Result sheet (above the camera) ---------- */
.fs-sheet { z-index: 170; }
.fs-sheet .sheet-content { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); }

.fs-head { display: flex; align-items: center; gap: 12px; padding-right: 44px; }
.fs-thumb {
    width: 64px;
    height: 64px;
    flex: none;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 16px;
    background: #fff;
    border: 2px solid var(--border-light);
    color: var(--text-muted);
}
.fs-thumb img { width: 100%; height: 100%; object-fit: contain; }
.fs-head-text { min-width: 0; }
.fs-head h3 {
    margin: 0;
    text-align: left;
    font-size: 19px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.fs-head small { display: block; margin-top: 3px; font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Hero: protein ring + verdict with its gauge */
.fs-hero {
    --tone: var(--primary);
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-light);
}
.fs-hero.is-good { --tone: var(--success); }
.fs-hero.is-mid { --tone: var(--gold); }
.fs-hero.is-bad { --tone: #f43f5e; }
.fs-ring { position: relative; width: 124px; height: 124px; flex: none; }
.fs-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.fs-ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.fs-ring-rail { stroke: #ededf7; }
.fs-ring-fill {
    stroke: var(--tone);
    stroke-dasharray: var(--len);
    stroke-dashoffset: var(--len);
    transition: stroke-dashoffset 1s 0.15s cubic-bezier(.22, 1, .36, 1);
}
.fs-result.is-in .fs-ring-fill { stroke-dashoffset: var(--to); }
.fs-ring-value {
    position: absolute;
    left: 0;
    right: 0;
    top: 33px;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 1px;
    color: var(--text-primary);
}
.fs-ring-value b { font-family: 'Nunito', sans-serif; font-size: 36px; font-weight: 900; line-height: 1; }
.fs-ring-value i { font-style: normal; font-size: 16px; font-weight: 800; color: var(--text-secondary); }
.fs-ring small {
    position: absolute;
    left: 14px;
    right: 14px;
    top: 72px;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    color: var(--text-muted);
}

.fs-verdict { flex: 1; min-width: 0; }
.fs-verdict strong { display: block; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; color: var(--tone); }
.fs-verdict p { margin: 8px 0 0; font-size: 13px; font-weight: 600; line-height: 1.35; color: var(--text-secondary); }
.fs-verdict p b { color: var(--text-primary); font-weight: 800; }
.fs-gauge { position: relative; margin-top: 12px; height: 12px; }
.fs-gauge-rail { display: grid; grid-template-columns: 24fr 26fr 50fr; gap: 3px; height: 8px; margin-top: 2px; }
.fs-gauge-rail i { border-radius: 4px; opacity: 0.3; }
.fs-gauge-rail .is-bad { background: #f43f5e; }
.fs-gauge-rail .is-mid { background: var(--gold); }
.fs-gauge-rail .is-good { background: var(--success); }
.fs-hero.is-bad .fs-gauge-rail .is-bad,
.fs-hero.is-mid .fs-gauge-rail .is-mid,
.fs-hero.is-good .fs-gauge-rail .is-good { opacity: 1; }
.fs-gauge-knob {
    position: absolute;
    top: -4px;
    left: 0;
    width: 20px;
    height: 20px;
    margin-left: -10px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 4px solid var(--tone);
    box-shadow: 0 2px 0 rgba(30, 27, 75, 0.18);
    transition: left 1s 0.25s cubic-bezier(.34, 1.4, .64, 1);
}
.fs-result.is-in .fs-gauge-knob { left: var(--x); }

/* Portion */
.fs-portion {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 10px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}
.fs-portion > b { font-size: 15px; font-weight: 800; color: var(--text-primary); }
.fs-need { flex-basis: 100%; display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.fs-need small { flex: none; font-size: 12px; font-weight: 700; color: var(--text-muted); }
.fs-need-bar { flex: 1; height: 8px; overflow: hidden; border-radius: 4px; background: #ededf7; }
.fs-need-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--primary); transition: width 0.9s 0.4s cubic-bezier(.22, 1, .36, 1); }
.fs-result.is-in .fs-need-bar i { width: var(--w); }

/* Nutrient rows */
.fs-rows { margin: 0; padding: 6px 0 0; list-style: none; }
.fs-row {
    --tone: #c7c7e4;
    display: grid;
    grid-template-columns: 96px 1fr 64px;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--border-light);
}
.fs-row:first-child { border-top: 0; }
.fs-row.is-sub { padding-top: 0; border-top: 0; }
.fs-row.is-good { --tone: var(--success); }
.fs-row.is-mid { --tone: var(--gold); }
.fs-row.is-bad { --tone: #f43f5e; }
.fs-row-label { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.fs-row.is-sub .fs-row-label { padding-left: 10px; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.fs-row-bar { height: 8px; overflow: hidden; border-radius: 4px; background: #ededf7; }
.fs-row-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--tone); transition: width 0.7s calc(0.35s + var(--i) * 0.06s) cubic-bezier(.22, 1, .36, 1); }
.fs-result.is-in .fs-row-bar i { width: var(--w); }
.fs-row > b { font-size: 15px; font-weight: 800; text-align: right; white-space: nowrap; color: var(--text-primary); }
.fs-row > b small { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.fs-row.is-sub > b { font-size: 13px; }

.fs-source { margin: 10px 0 0; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.fs-again { width: 100%; margin-top: 16px; }
.fs-note { margin: 12px 0 0; font-size: 13px; font-weight: 700; text-align: center; color: var(--text-secondary); }

/* Not found / offline */
.fs-missing { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px 0; text-align: center; }
.fs-missing h3 { margin: 0; font-size: 19px; font-weight: 800; color: var(--text-primary); }
.fs-missing p { margin: 0; max-width: 300px; font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--text-secondary); }
.fs-missing .fs-missing-note { font-size: 13px; color: var(--text-muted); }
.fs-missing .btn { width: 100%; margin-top: 14px; }

html[data-theme="dark"] .fs-thumb { border-color: #2e2850; }
html[data-theme="dark"] .fs-ring-rail { stroke: #2a2448; }
html[data-theme="dark"] .fs-gauge-rail i { opacity: 0.35; }
html[data-theme="dark"] .fs-hero.is-bad .fs-gauge-rail .is-bad,
html[data-theme="dark"] .fs-hero.is-mid .fs-gauge-rail .is-mid,
html[data-theme="dark"] .fs-hero.is-good .fs-gauge-rail .is-good { opacity: 1; }
html[data-theme="dark"] .fs-need-bar,
html[data-theme="dark"] .fs-row-bar { background: #2a2448; }
html[data-theme="dark"] .fs-row { --tone: #4c4785; }
html[data-theme="dark"] .fs-row.is-good { --tone: var(--success); }
html[data-theme="dark"] .fs-row.is-mid { --tone: var(--gold); }
html[data-theme="dark"] .fs-row.is-bad { --tone: #f43f5e; }

@media (prefers-reduced-motion: reduce) {
    .fs-entry-icon i, .fs-laser { animation: none; }
    .fs-ring-fill, .fs-gauge-knob, .fs-row-bar i, .fs-need-bar i { transition: none; }
}

/* ---------- Paywall slide: a skyr scanned, protein ring filling ---------- */
.pwb-food { display: flex; align-items: center; justify-content: center; gap: 14px; }
.pwb-food-pack { position: relative; width: 92px; height: 132px; }
.pwb-food-pack svg { width: 100%; height: 100%; }
.pwb-food-laser {
    position: absolute;
    left: -8px;
    right: -8px;
    top: 58%;
    height: 3px;
    border-radius: 3px;
    background: #c4b5fd;
    box-shadow: 0 0 12px 3px rgba(167, 139, 250, 0.7);
    opacity: 0;
}
.pwb-slide.is-on .pwb-food-laser { animation: pwbFoodLaser 0.4s ease-in-out 3 alternate both; }
@keyframes pwbFoodLaser { 0% { transform: translateY(-14px); opacity: 1; } 100% { transform: translateY(26px); opacity: 1; } }
.pwb-slide.is-on .pwb-food-pack .pwb-food-code { animation: pwbFoodCode 0.3s 1.1s both; }
@keyframes pwbFoodCode { to { stroke: #4ade80; } }
.pwb-food-card {
    width: 150px;
    padding: 12px;
    border-radius: 20px;
    background: var(--pwb-faint);
    text-align: left;
}
.pwb-slide.is-on .pwb-food-card { animation: pwbPlus 0.5s 1.1s var(--pwb-spring) both; }
.pwb-food-ring { position: relative; width: 74px; height: 74px; margin: 0 auto 8px; }
.pwb-food-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.pwb-food-ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.pwb-food-ring .is-rail { stroke: rgba(255, 255, 255, 0.12); }
.pwb-food-ring .is-fill { stroke: #4ade80; stroke-dasharray: 239; stroke-dashoffset: 239; }
.pwb-slide.is-on .pwb-food-ring .is-fill { animation: pwbFoodRing 1s 1.3s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes pwbFoodRing { to { stroke-dashoffset: 72; } }
.pwb-food-ring b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 1px; font-family: 'Nunito', sans-serif; font-size: 24px; font-weight: 900; }
.pwb-food-ring b small { font-size: 14px; }
.pwb-food-card ul { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.pwb-food-card li { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: rgba(255, 255, 255, 0.6); }
.pwb-food-card li i { height: 6px; border-radius: 3px; background: var(--c); transform-origin: left; width: var(--w); }
.pwb-slide.is-on .pwb-food-card li i { animation: pwbFoodBar 0.6s calc(1.4s + var(--i) * 0.1s) var(--ease-out, ease-out) both; }
@keyframes pwbFoodBar { from { transform: scaleX(0); } }
