/* Loading line, running hen and app tour. Loaded by the shop, sign-in and farm-management layouts, so it carries its
 * own colours (the tokens of reports/design-system.md) instead of relying on the --mk-* or --pp-* names.
 * Animations use transform and opacity only. */

/* ---------- realistic running & jumping hen data loader + top hairline bar ---------- */
.ph-load { position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 1500; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .18s ease, visibility .18s ease; }
.ph-load.is-on { opacity: 1; visibility: visible; }
.ph-load-card { display: contents; }
.ph-load-track { position: relative; width: 100%; height: 3px; overflow: hidden; background: transparent; border-radius: 99px; }
.ph-load-fill { display: block; width: 100%; height: 100%; background: var(--mk-accent, #16A34A); border-radius: 99px; }
.ph-load-run, .ph-load-label { display: none; }
.ph-load.is-hen {
    inset: 0; top: 0; bottom: 0; height: 100%;
    display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(2, 6, 23, .16); backdrop-filter: blur(2px);
}
.ph-load.is-hen .ph-load-card {
    display: inline-flex; flex-direction: column; align-items: center; gap: 6px;
    width: min(380px, 92vw); padding: 10px 16px 10px;
    border-radius: 20px;
    background: var(--mk-card, #FFFFFF);
    border: 1px solid var(--mk-border, #E2E8F0);
    box-shadow: 0 16px 40px rgba(2, 6, 23, .22);
    backdrop-filter: blur(10px);
    overflow: hidden; box-sizing: border-box;
    will-change: transform, opacity;
    transition: opacity 220ms ease, transform 220ms cubic-bezier(.22, 1, .36, 1);
}
.ph-load.is-hen.is-exiting .ph-load-card { opacity: 0; transform: translateY(-8px) scale(.96); }
.ph-load.is-hen .ph-load-track { display: block; width: 100%; height: 3px; background: var(--mk-tint, rgba(22, 163, 74, .14)); margin-top: 2px; }
.ph-load.is-hen .ph-load-run {
    display: block; width: 100%; height: 88px; padding-top: 20px; box-sizing: border-box;
    overflow: hidden; position: relative;
    border-bottom: 2px dashed color-mix(in srgb, var(--mk-accent, #16A34A) 45%, transparent);
}
.ph-load.is-hen .ph-load-label { display: block; margin: 0; font-size: 12px; font-weight: 700; color: var(--mk-muted, #475569); }
.ph-load.is-hen .ph-hen { width: 56px; height: 56px; }
.ph-hen-runner { display: block; width: 100%; height: 100%; will-change: transform; }
.ph-hen-leap { display: inline-block; will-change: transform; transform-origin: 50% 85%; }
.ph-load.is-hen.is-on .ph-hen-runner { animation: ph-hen-traverse 1.6s linear infinite; }
.ph-load.is-hen.is-on .ph-hen-leap { animation: ph-hen-hop 1.6s ease-in-out infinite; }
.ph-load.is-hen.is-on .ph-hen-shadow { transform-origin: 48px 88px; animation: ph-hen-shadow-pulse 1.6s ease-in-out infinite; }
.is-on .ph-load-fill { animation: ph-run-bar 1.15s ease-in-out infinite; }
@keyframes ph-run-bar { 0% { transform: translateX(-100%); } 50% { transform: translateX(0); } 100% { transform: translateX(100%); } }
@keyframes ph-hen-traverse {
    0% { transform: translateX(-14%); }
    100% { transform: translateX(96%); }
}
@keyframes ph-hen-hop {
    0%, 22%, 56%, 82%, 100% { transform: translateY(0) scaleY(1) rotate(0deg); }
    29% { transform: translateY(2px) scaleY(.92) rotate(2deg); }
    41% { transform: translateY(-14px) scaleY(1.03) rotate(-7deg); }
    64% { transform: translateY(2px) scaleY(.94) rotate(2deg); }
    72% { transform: translateY(-9px) scaleY(1.02) rotate(-4deg); }
}
@keyframes ph-hen-shadow-pulse {
    0%, 22%, 56%, 82%, 100% { transform: scaleX(1); opacity: .9; }
    41% { transform: scaleX(.58); opacity: .35; }
    72% { transform: scaleX(.72); opacity: .5; }
}

/* ---------- the hen: fast 340 ms run stride, wing flap, tail bounce & bobbing head ---------- */
.ph-hen { display: block; width: 96px; height: 96px; overflow: visible; }
.ph-hen-leg-near { transform-origin: 46px 62px; transform: rotate(16deg); }
.ph-hen-leg-far { transform-origin: 51px 62px; transform: rotate(-16deg); }
.ph-hen-wing { transform-origin: 48px 48px; }
.ph-hen-tail { transform-origin: 26px 47px; }
.is-on .ph-hen-leg { animation: ph-step .34s linear infinite; }
.is-on .ph-hen-leg-far { animation-delay: -.17s; }
.is-on .ph-hen-body { animation: ph-bob .34s ease-in-out infinite; }
.is-on .ph-hen-wing { animation: ph-wing .34s ease-in-out infinite; }
.is-on .ph-hen-tail { animation: ph-tail .34s ease-in-out infinite; }
@keyframes ph-step {
    0% { transform: translateY(1.5px) rotate(-30deg); }
    25% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(1.5px) rotate(30deg); }
    75% { transform: translateY(-6px) rotate(4deg); }
    100% { transform: translateY(1.5px) rotate(-30deg); }
}
@keyframes ph-bob { 0%, 50%, 100% { transform: translateY(0); } 25%, 75% { transform: translateY(-2px); } }
@keyframes ph-wing { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-11deg) translateY(-1.5px); } }
@keyframes ph-tail { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(4deg); } }

/* ---------- centered pill shown while a payment/fetch step is in flight ---------- */
.ph-chip { position: fixed; left: 50%; top: 50%; z-index: 1450; display: flex; align-items: center; gap: 10px; width: max-content; max-width: 90vw; padding: 12px 20px 12px 14px; background: var(--mk-card, #FFFFFF); color: var(--mk-ink, #0F172A); border: 1px solid var(--mk-border, #E2E8F0); border-radius: 16px; box-shadow: 0 18px 42px rgba(2, 6, 23, .28); font-size: 14px; font-weight: 700; line-height: 1.5; transform: translate(-50%, -50%) scale(.95); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s ease, transform .2s cubic-bezier(.2, .7, .2, 1), visibility .2s; }
.ph-chip.is-on { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
.ph-chip-art .ph-hen { width: 36px; height: 36px; }

.ph-vh { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- "App tour" entry in the account sheet ---------- */
.mk-sheet-list .ph-tour-link { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 8px 6px; border: 0; border-bottom: 1px solid var(--mk-border, #E2E8F0); background: transparent; color: var(--mk-ink, #0F172A); font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.mk-sheet-list .ph-tour-link .mk-icon { color: var(--mk-accent, #16A34A); }

/* ---------- app tour ---------- */
html.ph-tour-open, html.ph-tour-open body { overflow: hidden; }
.ph-tour { position: fixed; inset: 0; z-index: 1800; display: flex; justify-content: center; align-items: stretch; background: var(--mk-surface, #FFFFFF); color: var(--mk-ink, #0F172A); animation: ph-tour-fade .30s cubic-bezier(.22, 1, .36, 1); transition: opacity .22s ease; }
.ph-tour.is-closing { opacity: 0; pointer-events: none; }
.ph-tour [hidden] { display: none !important; }
.ph-tour-panel { display: flex; flex-direction: column; width: 100%; max-width: 480px; min-height: 0; padding: calc(8px + env(safe-area-inset-top)) 0 calc(16px + env(safe-area-inset-bottom)); background: var(--mk-card, #FFFFFF); outline: none; animation: ph-tour-panel-in .36s cubic-bezier(.22, 1, .36, 1); transition: transform .22s cubic-bezier(.22, 1, .36, 1), opacity .22s ease; }
.ph-tour.is-closing .ph-tour-panel { transform: translateY(12px) scale(.97); opacity: 0; }
@keyframes ph-tour-fade { from { opacity: 0; } }
@keyframes ph-tour-panel-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
.ph-tour-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px 0 20px; }
.ph-tour-name { min-width: 0; font-size: 14px; font-weight: 700; color: var(--mk-muted, #475569); }
.ph-tour-skip { flex: none; min-width: 64px; min-height: 48px; padding: 6px 14px; border: 0; border-radius: 12px; background: transparent; color: var(--mk-accent, #16A34A); font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.ph-tour-skip:hover { background: var(--mk-tint, #F0FDF4); }
.ph-tour-view { flex: 1; min-height: 0; overflow: hidden; touch-action: pan-y; }
.ph-tour-track { display: flex; height: 100%; transition: transform .3s cubic-bezier(.2, .7, .2, 1); }
.ph-slide { flex: 0 0 100%; display: flex; flex-direction: column; align-items: center; min-width: 0; max-height: 100%; overflow-x: hidden; overflow-y: auto; padding: 8px 24px; text-align: center; touch-action: pan-y; }
.ph-slide > :first-child { margin-top: auto; }
.ph-slide > :last-child { margin-bottom: auto; }
.ph-art { flex: 0 1 auto; width: 100%; max-width: 300px; height: auto; min-height: 120px; }
.ph-tour .ph-slide-title { margin: 22px 0 10px; font-family: inherit; font-size: 22px; font-weight: 700; line-height: 1.4; color: var(--mk-ink, #0F172A); text-wrap: balance; overflow-wrap: anywhere; }
.ph-tour .ph-slide-text { max-width: 36ch; margin: 0 0 auto; font-size: 16px; line-height: 1.65; color: var(--mk-muted, #475569); overflow-wrap: anywhere; } /* auto: centres the slide */
.ph-dots { display: flex; justify-content: center; padding: 6px 0; }
.ph-dot { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.ph-dot::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--mk-card, #FFFFFF); border: 2px solid var(--mk-border-control, #94A3B8); transition: transform .2s; }
.ph-dot[aria-current="step"]::before { background: var(--mk-accent, #16A34A); border-color: var(--mk-accent, #16A34A); transform: scale(1.35); }
.ph-tour-nav { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 12px; padding: 0 20px; }
.ph-tour-btn { min-height: 52px; padding: 10px 14px; border: 2px solid transparent; border-radius: 12px; font: inherit; font-size: 16px; font-weight: 700; line-height: 1.35; cursor: pointer; overflow-wrap: anywhere; }
.ph-tour-back { background: var(--mk-card, #FFFFFF); color: var(--mk-ink, #0F172A); border-color: var(--mk-border, #E2E8F0); }
.ph-tour-back:disabled { visibility: hidden; }
.ph-tour-go { background: var(--mk-accent, #22C55E); color: var(--mk-on-accent, #FFFFFF); }
.ph-tour-go:hover { background: var(--mk-accent-strong, #16A34A); }
.ph-tour :focus-visible { outline: 3px solid var(--mk-accent, #22C55E); outline-offset: 2px; }
.ph-tour .ph-tour-panel:focus { outline: none; }

/* larger screens: a card over a dimmed page */
@media (min-width: 600px) and (min-height: 600px) {
    .ph-tour { align-items: center; padding: 24px; background: rgba(2, 6, 23, .65); backdrop-filter: blur(4px); }
    .ph-tour-panel { height: min(660px, 100%); padding-top: 12px; padding-bottom: 20px; border-radius: 20px; border: 1px solid var(--mk-border, #E2E8F0); box-shadow: 0 24px 60px rgba(2, 6, 23, .45); }
}
/* small phones: a little less picture and heading, so the longest Indian-language slides fit without scrolling */
@media (max-height: 680px) {
    .ph-art { max-width: 240px; }
    .ph-tour .ph-slide-title { margin-top: 12px; font-size: 20px; }
}
/* short screens (landscape phones): smaller picture so the words and buttons stay in reach */
@media (max-height: 520px) {
    .ph-art { max-width: 180px; min-height: 0; }
    .ph-tour .ph-slide-title { margin-top: 8px; font-size: 18px; }
    .ph-dot { height: 28px; }
}

/* reduced motion: a still line half filled with a centered still hen, and slides that change without sliding */
@media (prefers-reduced-motion: reduce) {
    .ph-tour-track, .ph-dot::before { transition: none; }
    .is-on .ph-hen-leg, .is-on .ph-hen-body, .is-on .ph-hen-wing, .is-on .ph-hen-tail, .is-on .ph-hen-runner, .is-on .ph-hen-leap, .is-on .ph-hen-shadow, .is-on .ph-load-fill { animation: none; }
    .ph-hen-runner { display: flex; justify-content: center; transform: none; }
    .ph-load-fill { transform: translateX(-50%); }
}
@media print { .ph-load, .ph-chip, .ph-tour { display: none !important; } }
