/* assets/css/templates/pulse.css — mobile-first, clarity-first */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&display=swap');

.tpl-pulse {
    --pulse-bg: #f4f7fb;
    --pulse-surface: #ffffff;
    --pulse-ink: #1a2332;
    --pulse-muted: #5b6b7c;
    --pulse-line: #d8e0ea;
    --pulse-accent: #e85d4c;
    --pulse-accent-soft: #fff1ef;
    --pulse-sky: #3d7ea6;
    --pulse-glow: rgba(61, 126, 166, 0.12);
    --accent: var(--pulse-accent);
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'DM Sans', sans-serif;

    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, var(--pulse-glow), transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(232, 93, 76, 0.08), transparent 50%),
        var(--pulse-bg);
    color: var(--pulse-ink);
    font-family: var(--font-body);
    line-height: 1.5;
    overflow-x: hidden;
    width: 100%;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.tpl-pulse .container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
}

@media (min-width: 640px) {
    .tpl-pulse .container {
        padding: 0 1.5rem;
    }
}

/* Top bar */
.pulse-top-bar {
    padding: 0.85rem 0 0;
    position: relative;
    z-index: 50;
}

.pulse-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.35rem 0.75rem 0.35rem 0.5rem;
    border-radius: 999px;
    background: var(--pulse-surface);
    border: 1px solid var(--pulse-line);
    color: var(--pulse-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.2s, border-color 0.2s;
}

.pulse-back:hover {
    color: var(--pulse-ink);
    border-color: var(--pulse-sky);
}

.pulse-back .icon-back {
    width: 18px;
    height: 18px;
}

/* Header */
.pulse-header {
    padding: 1.75rem 0 1.25rem;
    text-align: center;
}

.pulse-logo {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 20px;
    margin-bottom: 1rem;
    box-shadow: 0 8px 24px rgba(26, 35, 50, 0.12);
    border: 3px solid var(--pulse-surface);
}

.pulse-hero h1 {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 6vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin: 0 0 0.5rem;
    color: var(--pulse-ink);
    overflow-wrap: break-word;
}

.pulse-tagline {
    margin: 0;
    color: var(--pulse-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

/* Sticky category nav — mobile chip rail */
.tpl-pulse .category-nav,
.tpl-pulse .pulse-nav {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0.5rem 0 0.75rem;
    position: sticky;
    top: var(--alvita-sticky-top, 0px);
    z-index: 100;
}

.tpl-pulse .category-nav-scroll-container {
    position: relative;
}

.tpl-pulse .pulse-nav-inner {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.35rem 0;
}

.tpl-pulse .pulse-nav-inner::-webkit-scrollbar {
    display: none;
}

.tpl-pulse .category-nav-link {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 44px;
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    background: var(--pulse-surface);
    border: 1px solid var(--pulse-line);
    color: var(--pulse-ink);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}

.tpl-pulse .category-nav-link:hover,
.tpl-pulse .category-nav-link:focus-visible {
    background: var(--pulse-ink);
    color: #fff;
    border-color: var(--pulse-ink);
    outline: none;
}

.tpl-pulse .nav-arrow {
    background: var(--pulse-surface);
    border: 1px solid var(--pulse-line);
    color: var(--pulse-ink);
    box-shadow: 0 2px 8px rgba(26, 35, 50, 0.08);
}

.tpl-pulse .nav-mask-left,
.tpl-pulse .nav-mask-right {
    display: none;
}

@media (max-width: 768px) {
    .tpl-pulse .category-nav,
    .tpl-pulse .pulse-nav {
        background: rgba(244, 247, 251, 0.92);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--pulse-line);
        box-shadow: 0 6px 18px rgba(26, 35, 50, 0.04);
        padding: 0.4rem 0 0.55rem;
    }

    .tpl-pulse .nav-arrow {
        display: none;
    }
}

/* Main sections */
.pulse-main {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom));
}

.pulse-section {
    scroll-margin-top: calc(var(--alvita-sticky-top, 0px) + 4.5rem);
    padding: 1.25rem 0 0.5rem;
}

.pulse-section-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
}

.pulse-section-head h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.02em;
}

.pulse-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--pulse-accent-soft);
    color: var(--pulse-accent);
    font-size: 0.75rem;
    font-weight: 700;
}

.pulse-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

/* Item cards — large touch-friendly rows */
.pulse-item {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 0.85rem;
    background: var(--pulse-surface);
    border: 1px solid var(--pulse-line);
    border-radius: 18px;
    padding: 0.75rem;
    box-shadow: 0 4px 16px rgba(26, 35, 50, 0.04);
    transition: transform 0.2s, box-shadow 0.2s;
}

.pulse-item.no-image {
    grid-template-columns: 1fr;
}

.pulse-item:active {
    transform: scale(0.995);
}

.pulse-item-media {
    width: 96px;
    height: 96px;
    border-radius: 14px;
    overflow: hidden;
    background: var(--pulse-bg);
    flex-shrink: 0;
}

.pulse-item-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pulse-item-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 0.35rem;
}

.pulse-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.65rem;
}

.pulse-item-top h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
    letter-spacing: -0.01em;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.pulse-price {
    flex-shrink: 0;
    font-weight: 700;
    font-size: 1rem;
    color: var(--pulse-sky);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.pulse-desc {
    margin: 0;
    font-size: 0.875rem;
    color: var(--pulse-muted);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.pulse-item-actions {
    margin-top: auto;
    padding-top: 0.35rem;
}

.tpl-pulse .alvita-add-btn {
    min-height: 44px;
    width: 100%;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    background: var(--pulse-accent);
    color: #fff;
    border: none;
    padding: 0.65rem 1rem;
}

.tpl-pulse .alvita-add-btn:hover,
.tpl-pulse .alvita-add-btn:focus-visible {
    filter: brightness(1.05);
    outline: none;
}

/* Meta / pills / macros */
.tpl-pulse .ingredients {
    font-size: 0.78rem;
    color: var(--pulse-muted);
    margin: 0.15rem 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

.tpl-pulse .statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0.2rem 0;
}

.tpl-pulse .status-pill {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    background: var(--pulse-bg);
    border: 1px solid var(--pulse-line);
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.tpl-pulse .macros-details {
    margin-top: 0.25rem;
    border-radius: 10px;
    background: var(--pulse-bg);
    border: 1px solid var(--pulse-line);
}

.tpl-pulse .macros-summary {
    min-height: 40px;
    padding: 0.45rem 0.65rem;
    font-size: 0.78rem;
}

/* Footer */
.pulse-footer {
    padding: 2rem 0 calc(2rem + env(safe-area-inset-bottom));
    text-align: center;
    color: var(--pulse-muted);
    font-size: 0.8rem;
}

.pulse-footer p {
    margin: 0;
}

@media (max-width: 380px) {
    .pulse-item {
        grid-template-columns: 80px 1fr;
        gap: 0.65rem;
        padding: 0.65rem;
    }
    .pulse-item-media {
        width: 80px;
        height: 80px;
    }
    .pulse-item-top h3 {
        font-size: 0.98rem;
    }
    .pulse-price {
        font-size: 0.92rem;
    }
}

/* Wider screens: slightly larger cards */
@media (min-width: 640px) {
    .pulse-item {
        grid-template-columns: 120px 1fr;
        padding: 1rem;
        gap: 1rem;
        border-radius: 20px;
    }

    .pulse-item-media {
        width: 120px;
        height: 120px;
        border-radius: 16px;
    }

    .pulse-item-actions .alvita-add-btn,
    .tpl-pulse .alvita-add-btn {
        width: auto;
        min-width: 140px;
    }

    .pulse-item-actions {
        display: flex;
        justify-content: flex-end;
    }
}

@media (min-width: 900px) {
    .tpl-pulse .container {
        max-width: 860px;
    }

    .pulse-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .pulse-item.no-image {
        grid-column: span 1;
    }
}

/* Long item details need the image above the content on phones. Keeping a
   fixed thumbnail beside allergens, nutrition and an action button leaves an
   unusable blank column, as the card grows vertically. */
@media (max-width: 520px) {
    .pulse-item {
        grid-template-columns: minmax(0, 1fr);
    }

    .pulse-item-media {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
        border-radius: 12px;
    }
}
