/*
 * Mobile interaction refinement layer.
 *
 * Page-specific styles continue to own business layouts. This file is loaded
 * last to keep touch targets, navigation, forms and feedback predictable across
 * the customer portal. Visual treatment stays quiet so the task remains first.
 */

:root {
    --brand: #486a50;
    --brand-strong: #294b34;
    --brand-soft: #eef4ef;
    --ink: #18201a;
    --text: #37423a;
    --muted: #68736b;
    --subtle: #8c958f;
    --line: #e1e5e2;
    --line-strong: #cdd3cf;
    --surface: #f8faf8;
    --surface-raised: #ffffff;
    --page-bg: #f3f5f4;
    --shadow-focus: 0 0 0 3px rgb(72 106 80 / 16%);
    --radius-card: 12px;
    --radius-control: 12px;
    --tap: 50px;
    --touch-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html {
    font-size: 100%;
    scroll-padding-top: calc(58px + env(safe-area-inset-top));
}

body {
    background: var(--page-bg);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
    font-size: 15px;
    line-height: 1.55;
    overscroll-behavior-y: auto;
}

body.is-rule-open {
    overflow: hidden;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

/* Only fixed navigation uses material depth; content surfaces stay solid. */
.header,
body.system-flow-page:not(.home-page):not(.auth-page) .header,
body:not(.home-page):not(.auth-page) .header {
    border-bottom: 1px solid rgb(24 32 26 / 8%);
    background: rgb(255 255 255 / 92%);
    box-shadow: none;
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
}

.header-row,
body:not(.home-page):not(.auth-page) .header-row {
    min-height: calc(52px + env(safe-area-inset-top));
    padding-inline: 10px;
}

.header h1,
body:not(.home-page):not(.auth-page) .header h1 {
    color: var(--ink);
    font-size: 17px;
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: -0.012em;
}

.nav-back,
.header-placeholder {
    width: 44px;
    height: 44px;
}

.header-action,
.channel-badge,
body:not(.home-page):not(.auth-page) .header-action,
body:not(.home-page):not(.auth-page) .channel-badge {
    min-height: 44px;
    padding-inline: 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    font-size: 13px;
}

.container,
body:not(.home-page):not(.auth-page) .container,
body.system-flow-page:not(.home-page):not(.auth-page) .container {
    gap: 14px;
    padding: 12px 16px calc(94px + env(safe-area-inset-bottom));
    background: var(--page-bg);
}

.no-tabbar .container,
body:not(.home-page):not(.auth-page).no-tabbar .container,
body.system-flow-page:not(.home-page):not(.auth-page).no-tabbar .container {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.card,
.task-panel,
.collapsible-section,
.hero-card,
body:not(.home-page):not(.auth-page) .card,
body:not(.home-page):not(.auth-page) .task-panel,
body:not(.home-page):not(.auth-page) .benefits-hero,
body:not(.home-page):not(.auth-page) .collapsible-section,
body.system-flow-page:not(.home-page):not(.auth-page) .card,
body.system-flow-page:not(.home-page):not(.auth-page) .task-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface-raised);
    box-shadow: none;
}

.card-title,
.home-section-title,
body:not(.home-page):not(.auth-page) .card-title,
body:not(.home-page):not(.auth-page) .home-section-title {
    color: var(--ink);
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -0.008em;
}

.app-title,
.task-title,
body:not(.home-page):not(.auth-page) .app-title,
body:not(.home-page):not(.auth-page) .task-title {
    color: var(--ink);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.018em;
}

.app-subtitle,
.task-subtitle,
body:not(.home-page):not(.auth-page) .app-subtitle,
body:not(.home-page):not(.auth-page) .task-subtitle {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

/* Controls use one predictable touch rhythm. */
.form-group input,
.form-group select,
.form-control,
.form-input,
.form-select,
.auth-input-shell {
    min-height: var(--tap);
    border-color: var(--line-strong);
    border-radius: var(--radius-control);
    background: var(--surface-raised);
    color: var(--ink);
    font-size: 16px !important;
    box-shadow: none;
}

.form-group textarea,
.form-textarea {
    min-height: 104px;
    border-color: var(--line-strong);
    border-radius: var(--radius-control);
    background: var(--surface-raised);
    font-size: 16px !important;
}

.form-group label {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.form-control:focus,
.form-input:focus,
.form-select:focus {
    border-color: var(--brand);
    box-shadow: var(--shadow-focus);
}

.btn {
    min-height: var(--tap);
    border-radius: var(--radius-control);
    font-size: 16px;
    font-weight: 650;
    transition: transform 100ms ease-out, opacity 140ms ease-out, background-color 140ms ease-out;
}

.btn-sm,
.btn-fit {
    min-height: 44px;
    border-radius: 10px;
    font-size: 13px;
}

.btn-primary,
.btn-success,
.btn-wechat {
    background: var(--brand-strong);
}

.btn-outline {
    border-color: var(--line-strong);
    background: var(--surface-raised);
}

.btn:active,
.nav-back:active,
.header-action:active,
.tabbar-item:active,
.action-item:active,
.action-card:active,
.farm-shop-card:active,
.product-card:active,
.me-row:active,
.compact-row:active {
    transform: scale(0.98);
    transition-duration: 80ms;
}

.btn:disabled,
.btn.is-disabled {
    opacity: 0.45;
}

.bottom-actions,
.no-tabbar .bottom-actions {
    bottom: calc(64px + env(safe-area-inset-bottom));
    margin-inline: -16px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top-color: rgb(24 32 26 / 8%);
    background: rgb(255 255 255 / 94%);
    box-shadow: 0 -8px 24px rgb(24 32 26 / 4%);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
}

.no-tabbar .bottom-actions {
    bottom: 0;
}

/* Stable five-item navigation, including safe-area spacing. */
.tabbar,
body:not(.home-page):not(.auth-page) .tabbar,
body.system-flow-page:not(.home-page):not(.auth-page) .tabbar,
body.contract-center-page.system-flow-page:not(.home-page):not(.auth-page) .tabbar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-content: initial;
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid rgb(24 32 26 / 10%);
    border-radius: 0;
    background: rgb(255 255 255 / 90%);
    box-shadow: none;
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
}

.tabbar-item,
body:not(.home-page):not(.auth-page) .tabbar-item {
    min-width: 0;
    min-height: 56px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.tabbar-item.active,
body:not(.home-page):not(.auth-page) .tabbar-item.active {
    background: transparent;
    color: var(--brand-strong);
    font-weight: 650;
}

.tabbar-item.active::after,
body:not(.home-page):not(.auth-page) .tabbar-item.active::after {
    content: none;
}

.tabbar-icon.material-symbols-outlined {
    font-size: 22px;
}

.tabbar-item.active .tabbar-icon.material-symbols-outlined {
    font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
}

/* Home prioritizes account status, then familiar list navigation. */
body.home-system-page.system-flow-page:not(.home-page):not(.auth-page) .membership-card-carousel {
    margin-top: 6px;
}

body.home-system-page.system-flow-page:not(.home-page):not(.auth-page) .membership-card {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-raised);
    box-shadow: none;
}

body.home-system-page.system-flow-page:not(.home-page):not(.auth-page) .membership-card .hero-card__title {
    color: var(--ink);
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

body.home-system-page.system-flow-page:not(.home-page):not(.auth-page) .membership-card__code {
    color: var(--brand-strong);
    font-size: 28px;
    font-weight: 700;
}

body.home-system-page.system-flow-page:not(.home-page):not(.auth-page) .membership-card .hero-card__cta {
    min-width: 96px;
    min-height: 44px;
    padding-inline: 14px 10px;
    border-radius: 10px;
    background: var(--brand-strong);
    box-shadow: none;
}

body.home-system-page.system-flow-page:not(.home-page):not(.auth-page) .home-action-section .action-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface-raised);
}

body.home-system-page.system-flow-page:not(.home-page):not(.auth-page) .action-card {
    grid-template-columns: 38px minmax(0, 1fr) 20px;
    justify-items: stretch;
    align-items: center;
    min-height: 72px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

body.home-system-page.system-flow-page:not(.home-page):not(.auth-page) .action-card:last-child {
    border-bottom: 0;
}

body.home-system-page.system-flow-page:not(.home-page):not(.auth-page) .action-card::after {
    content: "chevron_right";
    color: var(--subtle);
    font-family: "Material Symbols Outlined";
    font-size: 20px;
    line-height: 1;
}

body.home-system-page.system-flow-page:not(.home-page):not(.auth-page) .action-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    font-size: 21px;
}

body.home-system-page.system-flow-page:not(.home-page):not(.auth-page) .action-card-copy {
    gap: 3px;
    text-align: left;
}

body.home-system-page.system-flow-page:not(.home-page):not(.auth-page) .action-card-copy strong {
    font-size: 14px;
    font-weight: 650;
}

/* Dense business cards remain easy to tap without looking promotional. */
body.farm-select-page.system-flow-page:not(.home-page):not(.auth-page) .farm-shop-card {
    min-height: 88px;
    padding: 12px;
    border-radius: var(--radius-card);
    box-shadow: none;
}

body.farm-select-page.system-flow-page:not(.home-page):not(.auth-page) .farm-shop-card__logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
}

body.farm-select-page.system-flow-page:not(.home-page):not(.auth-page) .farm-shop-card__action {
    min-height: 44px;
    padding-inline: 12px;
    border-radius: 10px;
    background: var(--brand-strong);
}

body.contract-center-page.system-flow-page:not(.home-page):not(.auth-page) .task-panel,
body.contract-center-page.system-flow-page:not(.home-page):not(.auth-page) .contract-status-card,
body.orders-page.payment-flow-page:not(.home-page):not(.auth-page) .order-card,
body.pay-page.payment-flow-page:not(.home-page):not(.auth-page) .product-card,
body.me-page.system-flow-page:not(.home-page):not(.auth-page) .task-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface-raised);
    box-shadow: none;
}

.status-pill,
.badge,
.state-badge {
    min-height: 24px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 650;
}

.hero-note,
.state-note {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
}

/* Feedback is immediate but visually quiet. */
.loading-overlay {
    background: rgb(24 32 26 / 18%);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.loading-panel {
    min-width: 120px;
    padding: 18px;
    border: 1px solid rgb(255 255 255 / 70%);
    border-radius: 14px;
    background: rgb(255 255 255 / 94%);
    color: var(--ink);
    box-shadow: 0 12px 32px rgb(24 32 26 / 14%);
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--line-strong);
    border-top-color: var(--brand-strong);
}

.app-toast {
    top: calc(60px + env(safe-area-inset-top));
    padding: 11px 14px;
    border-radius: 10px;
    background: rgb(24 32 26 / 94%);
    font-weight: 600;
}

.rule-overlay {
    background: var(--page-bg);
}

.rule-overlay-header {
    padding-top: env(safe-area-inset-top);
    background: rgb(255 255 255 / 92%);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
}

.rule-overlay-close {
    min-width: 44px;
    min-height: 44px;
}

.rule-overlay-body {
    overscroll-behavior-y: contain;
}

@media (max-width: 360px) {
    .container,
    body:not(.home-page):not(.auth-page) .container,
    body.system-flow-page:not(.home-page):not(.auth-page) .container {
        padding-right: 14px;
        padding-left: 14px;
    }

    body.farm-select-page.system-flow-page:not(.home-page):not(.auth-page) .farm-shop-card {
        grid-template-columns: 40px minmax(0, 1fr);
    }

    body.farm-select-page.system-flow-page:not(.home-page):not(.auth-page) .farm-shop-card__action {
        grid-column: 2;
        justify-self: start;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .app-main,
    .is-navigating .app-main,
    .btn,
    .nav-back,
    .tabbar-item,
    .action-card,
    .farm-shop-card,
    .product-card,
    .app-toast {
        animation: none !important;
        transition: opacity 100ms linear, color 100ms linear, background-color 100ms linear !important;
        transform: none !important;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .header,
    .tabbar,
    .bottom-actions,
    .rule-overlay-header,
    .loading-overlay,
    body.system-flow-page:not(.home-page):not(.auth-page) .header,
    body:not(.home-page):not(.auth-page) .header {
        background: var(--surface-raised);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

@media (prefers-contrast: more) {
    :root {
        --line: #bcc4be;
        --line-strong: #929d95;
    }

    .header,
    .tabbar,
    .card,
    .task-panel,
    .form-control,
    .form-group input,
    .form-group select,
    .form-group textarea {
        border-color: var(--line-strong);
    }
}
