/* Waterwise application foundation
   Shared, index-derived rules for public and authenticated pages. These
   selectors deliberately require .ww-app so maps and third-party widgets do
   not inherit broad component styling. The class is mounted by ww-header.js. */

body.ww-app {
    min-width: 320px;
    margin: 0;
    overflow-x: clip;
    background: var(--ww-bg);
    color: var(--ww-text);
    font-family: "Inter", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

.ww-app :target { scroll-margin-top: 94px; }

.ww-app .ww-header:not(.ww-home-header) {
    background: color-mix(in srgb, var(--ww-paper) 94%, transparent);
    border-bottom-color: var(--ww-border);
}

.ww-app .ww-nav {
    max-width: var(--ww-content);
    min-height: 74px;
    padding: 0 24px;
}

.ww-app .ww-brand {
    flex: 0 0 auto;
    gap: 11px;
    color: var(--ww-ink-soft);
    font-family: "Manrope", "Inter", Arial, sans-serif;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
}

.ww-app .ww-brand-mark {
    width: 30px;
    height: 38px;
    flex: 0 0 30px;
    border-radius: 0;
    background: transparent;
    color: var(--ww-blue);
    box-shadow: none;
    font-size: 21px;
}

.ww-app .ww-nav-links { flex-wrap: nowrap; }
.ww-app .ww-nav-links > li { flex: 0 0 auto; }
.ww-app .ww-nav-links > li > a,
.ww-app .ww-nav-action { white-space: nowrap; }

.ww-app main { min-width: 0; }
.ww-app h1,
.ww-app h2,
.ww-app h3,
.ww-app .ww-brand {
    font-family: "Manrope", "Inter", Arial, sans-serif;
    text-wrap: balance;
}

.ww-app :where(a, button, input, select, textarea, summary):focus-visible {
    outline: 3px solid color-mix(in srgb, var(--ww-focus) 34%, transparent) !important;
    outline-offset: 3px;
}

.ww-app :where(button, input, select, textarea) { font: inherit; }
.ww-app :where(button, [type="submit"], [role="button"]) { touch-action: manipulation; }
.ww-app :where(button, [type="submit"]):disabled { cursor: wait; opacity: .58; }

/* Shared controls. Existing page class names are retained to avoid changing
   form submission, Firebase auth, or commerce wiring. */
.ww-app :where(.ww-btn, .waterwise-auth-button, .waterwise-contact-button) {
    min-height: var(--ww-control-height);
    border-radius: 999px !important;
    font-weight: 700;
    letter-spacing: -.01em;
    transition: transform .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.ww-app :where(.ww-btn-primary, .waterwise-auth-button, .waterwise-contact-button:not(.light)) {
    border-color: var(--ww-ink-soft) !important;
    background: var(--ww-ink-soft) !important;
    color: #fff !important;
    box-shadow: var(--ww-shadow-sm) !important;
}

.ww-app :where(.ww-btn-primary, .waterwise-auth-button, .waterwise-contact-button:not(.light)):hover:not(:disabled) {
    border-color: var(--ww-blue) !important;
    background: var(--ww-blue) !important;
    transform: translateY(-1px);
}

.ww-app .ww-btn-secondary,
.ww-app .waterwise-contact-button.light {
    border: 1px solid var(--ww-border) !important;
    background: var(--ww-surface) !important;
    color: var(--ww-ink-soft) !important;
    box-shadow: none !important;
}

.ww-app :where(.ww-btn-danger, .danger-zone button) {
    background: var(--ww-danger) !important;
    color: #fff !important;
}

.ww-app :where(.ww-input, .ww-select-native, .waterwise-form-group input, .waterwise-form-group select, .waterwise-form-group textarea) {
    width: 100%;
    min-height: var(--ww-control-height);
    border: 1px solid var(--ww-border) !important;
    border-radius: var(--ww-radius-sm) !important;
    background: var(--ww-surface) !important;
    color: var(--ww-text) !important;
    box-shadow: none;
}

.ww-app :where(.ww-input, .ww-select-native, .waterwise-form-group input, .waterwise-form-group select, .waterwise-form-group textarea):focus {
    border-color: var(--ww-focus) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ww-focus) 13%, transparent) !important;
}

.ww-app :where(.ww-form-group label, .waterwise-form-group label) {
    color: var(--ww-ink-soft) !important;
    font-weight: 700 !important;
}

.ww-app :where(.ww-form-hint, .form-help, .waterwise-form-group small) { color: var(--ww-muted) !important; }

/* Cards and operational surfaces use restrained spacing rather than the
   homepage's oversized editorial layout. */
.ww-app :where(.ww-card, .waterwise-auth-card, .waterwise-contact-card, .waterwise-contact-panel) {
    border-color: var(--ww-border) !important;
    border-radius: var(--ww-radius) !important;
    background: var(--ww-surface) !important;
    box-shadow: var(--ww-shadow-sm) !important;
}

.ww-app :where(.ww-card-tag, .ww-setup-status, .status-badge) {
    border-radius: 999px !important;
    font-weight: 700;
    letter-spacing: .02em;
}

.ww-app :where(.ww-message.error, [role="alert"].error, .error-message) {
    border: 1px solid var(--ww-danger) !important;
    border-radius: var(--ww-radius-sm) !important;
    background: var(--ww-danger-soft) !important;
    color: var(--ww-danger) !important;
}

.ww-app :where(.ww-message.success, .success-message) {
    border: 1px solid var(--ww-green) !important;
    border-radius: var(--ww-radius-sm) !important;
    background: var(--ww-green-soft) !important;
    color: var(--ww-green) !important;
}

/* Authentication pages: same split layout, now using the index palette and
   scale. No auth controls or Firebase behavior are changed. */
.ww-app .waterwise-auth-page { background: var(--ww-bg) !important; }
.ww-app .waterwise-auth-intro h1 { font-size: clamp(36px, 5vw, 68px) !important; letter-spacing: -.055em !important; }
.ww-app .waterwise-auth-card { padding: clamp(24px, 4vw, 38px) !important; }
.ww-app .auth-benefit i { color: var(--ww-blue) !important; }

/* Prediction limitations remain visible without implying field validation or
   introducing a frontend dependency on an unavailable forecast API. */
.ww-app .ww-evaluation-details { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--ww-warning); border-radius: var(--ww-radius-sm); background: var(--ww-warning-soft); }
.ww-app .ww-evaluation-details p { margin: 9px 0 0; color: var(--ww-text); line-height: 1.6; }

/* Keep maps usable and provider controls above cards/dialog interiors. */
.ww-app :where(.leaflet-container, [class*="map"]) { max-width: 100%; }
.ww-app .leaflet-control-container { position: relative; z-index: 800; }
.ww-app dialog::backdrop { background: rgba(5, 9, 12, .64); backdrop-filter: blur(3px); }

@media (max-width: 780px) {
    .ww-app .ww-nav { min-height: 64px; padding: 0 16px; }
    .ww-app .ww-brand { gap: 8px; font-size: 17px; }
    .ww-app .ww-brand-mark { width: 30px; height: 34px; flex-basis: 30px; font-size: 19px; }
    .ww-app :where(.ww-dash, .ww-account-shell, .ww-eligibility-shell, .ww-kit-shell) { padding-left: 16px !important; padding-right: 16px !important; }
    .ww-app :where(.ww-card-head, .ww-inline-actions) { align-items: flex-start; }
    .ww-app :where(.ww-btn, .waterwise-auth-button) { min-height: 46px; }
    .ww-app :target { scroll-margin-top: 78px; }
}

@media (prefers-reduced-motion: reduce) {
    .ww-app *, .ww-app *::before, .ww-app *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
