/* Camera, processing and result screens share a restrained blue/pink palette. */
@property --card-glow-angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}
@keyframes card-border-glow {
    to { --card-glow-angle: 360deg; }
}
.baby-card { --card-glow-color: rgba(44, 145, 211, 0.8); }
.baby-card.pink { --card-glow-color: rgba(225, 92, 142, 0.8); }
.baby-card::before {
    content: "";
    position: absolute;
    inset: -2px;
    z-index: 1;
    padding: 2px;
    border-radius: inherit;
    pointer-events: none;
    background: conic-gradient(from var(--card-glow-angle), transparent 0deg 270deg, var(--card-glow-color) 322deg, transparent 360deg);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    animation: card-border-glow 6s linear infinite;
}
.baby-card:nth-child(2)::before { animation-delay: -3s; }
.baby-card:hover::before { animation-duration: 3s; }
.baby-card .heart {
    width: 36px;
    height: 36px;
    color: #0874bb;
    background: linear-gradient(145deg, #fff, #e7f5ff);
    border: 1px solid rgba(255,255,255,0.96);
    box-shadow: 0 4px 15px rgba(7, 72, 126, 0.25), 0 0 0 2px rgba(22, 137, 212, 0.12);
    pointer-events: none;
    transition: box-shadow 250ms ease, background 250ms ease;
}
.baby-card.pink .heart {
    color: #d43f77;
    background: linear-gradient(145deg, #fff, #fff0f6);
    box-shadow: 0 4px 15px rgba(142, 42, 86, 0.24), 0 0 0 2px rgba(226, 80, 141, 0.12);
}
.baby-card .heart svg {
    width: 19px;
    height: 19px;
    filter: drop-shadow(0 2px 3px rgba(7, 72, 126, 0.2));
    transform-origin: center;
}
@keyframes card-heart-beat {
    0%, 100% { transform: scale(1); }
    35% { transform: scale(1.2); }
    65% { transform: scale(0.94); }
}
.baby-card:is(:hover, :active, :focus-within) .heart svg { animation: card-heart-beat 650ms ease-in-out; }
@media (max-width: 768px) {
    .baby-card .heart { width: 30px; height: 30px; top: 6px; right: 6px; }
    .baby-card .heart svg { width: 16px; height: 16px; }
}
/* Soft, brand-specific depth behind the landing cards. */
.brand-section { isolation: isolate; overflow: hidden; }
.brand-section .content-wrapper { position: relative; z-index: 1; }
.gerber {
    background:
        radial-gradient(ellipse at 82% 18%, rgba(255,255,255,0.94), transparent 36%),
        radial-gradient(ellipse at 22% 82%, rgba(116,195,240,0.42), transparent 48%),
        linear-gradient(145deg, #f6fcff 0%, #eaf7ff 45%, #d7edfc 100%);
}
.cerelac {
    background:
        radial-gradient(ellipse at 18% 18%, rgba(255,255,255,0.96), transparent 38%),
        radial-gradient(ellipse at 80% 82%, rgba(249,150,186,0.36), transparent 48%),
        linear-gradient(215deg, #fffafb 0%, #fff0f5 45%, #f9dce8 100%);
}
.brand-section::before,
.brand-section::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    will-change: transform;
}
@keyframes bubble-drift {
    from { transform: translate3d(-8px, 10px, 0); }
    to { transform: translate3d(10px, -12px, 0); }
}
@keyframes bubble-drift-mirrored {
    from { transform: scaleX(-1) translate3d(-7px, 8px, 0); }
    to { transform: scaleX(-1) translate3d(9px, -11px, 0); }
}
.brand-section::before { animation: bubble-drift 8s ease-in-out infinite alternate; }
.brand-section::after { animation: bubble-drift 11s ease-in-out -3s infinite alternate-reverse; }
.gerber::before {
    background:
        radial-gradient(circle 138px at 86% 30%, rgba(255,255,255,0.65) 0 18%, rgba(117,191,234,0.18) 55%, rgba(58,149,207,0.22) 69%, transparent 72%),
        radial-gradient(circle 86px at 18% 54%, rgba(255,255,255,0.66) 0 18%, rgba(117,191,234,0.17) 58%, rgba(58,149,207,0.2) 69%, transparent 72%),
        radial-gradient(circle 118px at 76% 82%, rgba(255,255,255,0.56) 0 18%, rgba(117,191,234,0.18) 55%, rgba(58,149,207,0.22) 69%, transparent 72%),
        radial-gradient(circle 54px at 23% 88%, rgba(255,255,255,0.7) 0 18%, rgba(117,191,234,0.2) 57%, rgba(58,149,207,0.23) 69%, transparent 72%),
        radial-gradient(circle 37px at 57% 10%, rgba(255,255,255,0.72) 0 18%, rgba(117,191,234,0.18) 57%, rgba(58,149,207,0.22) 69%, transparent 72%);
}
.cerelac::before {
    background:
        radial-gradient(circle 138px at 14% 46%, rgba(255,255,255,0.67) 0 18%, rgba(246,156,188,0.2) 55%, rgba(218,94,139,0.22) 69%, transparent 72%),
        radial-gradient(circle 86px at 81% 67%, rgba(255,255,255,0.66) 0 18%, rgba(246,156,188,0.18) 58%, rgba(218,94,139,0.2) 69%, transparent 72%),
        radial-gradient(circle 118px at 24% 87%, rgba(255,255,255,0.56) 0 18%, rgba(246,156,188,0.2) 55%, rgba(218,94,139,0.22) 69%, transparent 72%),
        radial-gradient(circle 54px at 77% 30%, rgba(255,255,255,0.7) 0 18%, rgba(246,156,188,0.2) 57%, rgba(218,94,139,0.23) 69%, transparent 72%),
        radial-gradient(circle 37px at 42% 12%, rgba(255,255,255,0.72) 0 18%, rgba(246,156,188,0.18) 57%, rgba(218,94,139,0.22) 69%, transparent 72%);
}
.brand-section::after {
    background:
        radial-gradient(circle 174px at 26% 92%, rgba(255,255,255,0.47) 0 20%, rgba(255,255,255,0.2) 55%, rgba(255,255,255,0.46) 69%, transparent 72%),
        radial-gradient(circle 68px at 70% 47%, rgba(255,255,255,0.52) 0 20%, rgba(255,255,255,0.12) 55%, rgba(255,255,255,0.4) 69%, transparent 72%),
        radial-gradient(circle 42px at 65% 10%, rgba(255,255,255,0.56) 0 20%, rgba(255,255,255,0.12) 55%, rgba(255,255,255,0.42) 69%, transparent 72%);
}
.cerelac::after { animation-name: bubble-drift-mirrored; }
@media (max-width: 768px) {
    .brand-section::before, .brand-section::after { opacity: 0.7; }
}
.camera-modal,
.result-page { --flow-accent: #0874bb; --flow-accent-soft: #e6f4ff; }
.camera-modal[data-brand="cerelac"],
.result-page[data-brand="cerelac"] { --flow-accent: #d92f69; --flow-accent-soft: #fff0f5; }

#screen-camera, #screen-confirm {
    background: radial-gradient(circle at 50% 0, #1a3550, #071625 70%);
}
.cam-bg-glow { opacity: 0.18; }
.cam-top-bar, .confirm-top {
    min-height: 76px;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.cam-brand-logo {
    height: clamp(42px, 7vh, 66px);
    max-width: 125px;
    padding: 4px 10px;
    border-radius: 14px;
    background: rgba(255,255,255,0.96);
    filter: none;
}
.back-cam-btn {
    left: 18px;
    right: auto;
    min-height: 42px;
    padding: 9px 16px;
    background: rgba(255,255,255,0.13);
    border-color: rgba(255,255,255,0.25);
}
.cam-viewfinder {
    width: min(100% - 32px, 650px);
    margin: 14px auto 0;
    border-radius: 24px;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.22), 0 22px 56px rgba(0,0,0,0.38);
}
.vf-scan-line { opacity: 0.35; }
.vf-hint {
    max-width: calc(100% - 32px);
    background: rgba(5,20,36,0.75);
    border-color: rgba(255,255,255,0.32);
}
.camera-status {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 32px;
    text-align: center;
    color: #fff;
    font-size: 1rem;
    line-height: 1.6;
    background: rgba(4,16,30,0.88);
}
.camera-status[hidden], .camera-status button[hidden] { display: none; }
.camera-status button,
.photo-upload-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.35);
    background: rgba(255,255,255,0.12);
    color: #fff;
    font: 700 0.9rem 'Tajawal', sans-serif;
    cursor: pointer;
}
.camera-status button { padding: 10px 22px; }
.cam-bottom {
    gap: 11px;
    padding: 16px 20px max(18px, env(safe-area-inset-bottom, 0px));
}
.cam-instruction { color: #d9e4ed; font-size: 0.9rem; }
.photo-upload-btn { padding: 9px 20px; }
.photo-upload-btn:hover, .camera-status button:hover { background: rgba(255,255,255,0.22); }
.shutter-btn { width: 72px; height: 72px; }
.shutter-ring { border-width: 4px; }

.confirm-body { padding: 14px 20px; }
.confirm-img-wrap {
    height: 100%;
    max-width: min(100%, 560px);
    border-radius: 22px;
}
.confirm-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 22px;
}
.confirm-img.from-upload { transform: none !important; }
#screen-confirm { overflow-x: hidden; }
.confirm-bottom {
    gap: 7px;
    padding: 16px 20px max(20px, env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(8,24,41,0.94);
}
.confirm-sub { max-width: 450px; line-height: 1.45; color: #cbd7e3; }
.confirm-actions { max-width: 540px; margin-top: 10px; }
.btn-retake, .btn-use { min-height: 52px; border-radius: 16px; }
.btn-retake { border-color: rgba(255,255,255,0.32); background: rgba(255,255,255,0.12); }
.btn-use { background: var(--flow-accent); box-shadow: 0 8px 24px rgba(0,0,0,0.24); }
.btn-retake:disabled, .btn-use:disabled { opacity: 0.55; cursor: not-allowed; }

#screen-loading {
    --wait-accent: #0874bb;
    --wait-soft: #e5f4ff;
    --wait-border: #b7dff8;
    background: radial-gradient(circle at 50% 17%, #ffffff 0, #e9f6ff 45%, #cdeaff 100%);
}
.camera-modal[data-brand="cerelac"] #screen-loading {
    --wait-accent: #cf3268;
    --wait-soft: #fff0f5;
    --wait-border: #f5bbd2;
    background: radial-gradient(circle at 50% 17%, #ffffff 0, #fff0f5 45%, #ffd5e4 100%);
}
.ld-deco { display: none; }
.loading-content {
    width: min(calc(100% - 32px), 500px);
    max-width: none;
    gap: 14px;
    padding: 30px;
    margin: auto;
    border: 1px solid var(--wait-border);
    border-radius: 30px;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 24px 70px color-mix(in srgb, var(--wait-accent) 16%, transparent);
}
.loading-brand {
    display: grid;
    place-items: center;
    width: 132px;
    height: 62px;
    border-radius: 18px;
    background: white;
    box-shadow: 0 8px 26px color-mix(in srgb, var(--wait-accent) 12%, transparent);
}
.loading-brand img { display: block; width: 112px; height: 52px; object-fit: contain; }
.loading-ring { width: 132px; height: 132px; }
.ring-track { stroke: var(--wait-border); }
.ring-progress { stroke: var(--wait-accent); }
.loading-preview {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    background: #f4f8fb;
    box-shadow: 0 5px 18px rgba(24,55,85,0.2);
}
.loading-preview.is-brand { object-fit: contain; padding: 10px; background: #fff; }
.loading-title { font-size: clamp(1.5rem, 3vw, 1.9rem); color: #17283a; }
.dots-anim { display: none; }
.loading-sub { max-width: 420px; color: #475569; line-height: 1.55; }
.loading-steps-card {
    padding: 10px;
    border: 1px solid var(--wait-border);
    border-radius: 18px;
    background: color-mix(in srgb, var(--wait-soft) 48%, white);
    box-shadow: none;
}
.lstep { justify-content: flex-start; padding: 10px 12px; margin: 1px 0; color: #718093; }
.lstep span { text-align: start; }
.lstep-ico-end { display: none; }
.lstep.active { background: var(--wait-soft); color: #263648; }
.lstep.done .lstep-ico { border-color: var(--wait-accent); background: var(--wait-accent); }
.lstep.active .lstep-ico { border-color: var(--wait-accent); border-top-color: transparent; }
.lstep-note { color: #586b7b; line-height: 1.5; font-family: 'Tajawal', sans-serif; }
.load-privacy {
    border-radius: 14px;
    line-height: 1.5;
    text-align: start;
    color: var(--wait-accent);
    background: var(--wait-soft);
    border-color: var(--wait-border);
}

.result-page { background: #f4f8fb; }
.res-deco { opacity: 0.07; }
.result-action-panel {
    background: linear-gradient(155deg, #fff, var(--flow-accent-soft));
}
.result-title {
    background: none;
    color: #152a3d;
    -webkit-text-fill-color: currentColor;
}
.result-subtitle { max-width: 410px; line-height: 1.55; color: #536579; }
.result-actions { max-width: 390px; }
.btn-result { border-radius: 15px; min-height: 52px; }
.btn-result-primary { background: var(--flow-accent); box-shadow: 0 8px 22px rgba(20,73,118,0.18); }
.btn-result-outline { color: var(--flow-accent); border-color: var(--flow-accent) !important; }
.res-qr-card { background: rgba(255,255,255,0.86); }
.result-image-panel { background: #142439; }

@media (max-width: 768px) {
    .cam-top-bar, .confirm-top { min-height: 62px; padding: 8px 16px; }
    .cam-brand-logo { height: 46px; }
    .back-cam-btn { left: 12px; min-height: 40px; padding: 7px 12px; }
    .cam-viewfinder { width: calc(100% - 24px); margin-top: 10px; border-radius: 20px; }
    .vf-hint { bottom: 12px; font-size: 0.8rem; padding: 7px 12px; }
    .cam-bottom { gap: 9px; padding: 12px 12px max(14px, env(safe-area-inset-bottom, 0px)); }
    .cam-instruction { font-size: 0.83rem; }
    .shutter-btn { width: 66px; height: 66px; }
    .photo-upload-btn { min-height: 42px; font-size: 0.86rem; }
    .confirm-body { min-height: 0; max-height: none; padding: 10px 14px; overflow: hidden; }
    .confirm-bottom { gap: 5px; padding: 12px 14px max(14px, env(safe-area-inset-bottom, 0px)); }
    .confirm-title { font-size: 1.25rem; }
    .confirm-sub { font-size: 0.82rem; }
    .confirm-actions { flex-direction: row; gap: 9px; margin-top: 8px; }
    .btn-retake, .btn-use { width: auto; min-width: 0; padding: 9px 10px; font-size: 0.88rem; }
    .btn-retake { flex: 1; } .btn-use { flex: 1.5; }
    .loading-content { width: calc(100% - 24px); gap: 12px; padding: 24px 18px; border-radius: 24px; }
    .loading-ring { width: 112px; height: 112px; }
    .loading-preview { width: 76px; height: 76px; }
    .loading-title { font-size: 1.45rem; }
    .loading-sub { font-size: 0.88rem; }
    .lstep { padding: 9px 10px; font-size: 0.88rem; }
    .load-privacy { font-size: 0.78rem; }
    .result-page { overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .result-content { height: auto; min-height: 100dvh; }
    .result-image-panel {
        order: -1;
        flex: none;
        height: min(50dvh, 460px);
        min-height: 300px;
        padding: 14px;
    }
    .result-action-panel {
        flex: none;
        overflow: visible;
        gap: 9px;
        padding: 16px 18px max(24px, env(safe-area-inset-bottom, 0px));
        border-radius: 22px 22px 0 0;
    }
    .res-corner-logo { height: 38px !important; margin-bottom: 0 !important; }
    .result-title { font-size: 1.55rem; }
    .result-subtitle { font-size: 0.85rem; }
    .result-actions { gap: 8px; }
    .btn-result { min-height: 48px; }
    .res-qr-card { margin-top: 6px; padding: 12px; }
    #final-qr-code { width: 120px !important; height: 120px !important; }
}

@media (max-width: 360px) {
    .confirm-actions { flex-direction: column; }
    .btn-retake, .btn-use { width: 100%; min-height: 44px; }
    .result-image-panel { height: 46dvh; min-height: 250px; }
}

@media (max-height: 600px) and (orientation: landscape) {
    .confirm-body { flex: 1 1 auto; max-height: none; }
    .confirm-bottom { padding-block: 8px; }
    .loading-content { margin-block: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .baby-card::before { animation: none; }
    .baby-card:is(:hover, :active, :focus-within) .heart svg { animation: none; }
    .brand-section::before, .brand-section::after { animation: none; will-change: auto; }
    .cerelac::after { transform: scaleX(-1); }
    .vf-scan-line, .ld-deco, .res-deco, .ring-svg, .ring-emoji { animation: none; }
}
