/* ================================================================
   GoaKeys — Global Responsive & Accessibility Upgrade Layer
   -----------------------------------------------------------------
   Design source: Google Stitch "Emerald Legacy" design system (elder-friendly, WCAG AA)
   Principles: mobile-first, fluid spacing (8px rhythm), WCAG AA
   contrast, elderly-friendly sizing (18px+ body, 48px+ targets).

   Loaded AFTER every page's own stylesheet. Contains ONLY additive
   overrides — every existing class name, ID and JS hook is preserved.
   ================================================================ */

:root {
    /* Stitch color tokens (Emerald Legacy, light theme) */
    --surface: #F9F9F7;
    --surface-container-lowest: #ffffff;
    --surface-container-low: #EBF2EE;
    --surface-container: #E7EEE9;
    --surface-container-high: #DDE7E1;
    --on-surface: #1A1C1B;
    --on-surface-variant: #414943;
    --outline: #5F6B64;
    --outline-variant: #D1D5DB;
    --primary: #004225;
    --on-primary: #ffffff;
    --primary-container: #004225;
    --on-primary-container: #e7f6ec;
    --secondary-container: #D4AF37;
    --on-secondary-container: #3D2E00;
    --error: #ba1a1a;
    --gold: #d4af37;

    /* 8px spacing rhythm */
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 40px;
    --space-6: 48px;
    --space-7: 64px;
    --space-8: 96px;

    /* Fluid type scale (clamp: min 360px / max 1440px) */
    --text-display: clamp(2.1rem, 4.5vw + 1rem, 3.4rem);
    --text-h1: clamp(1.85rem, 3vw + 0.9rem, 2.9rem);
    --text-h2: clamp(1.5rem, 2vw + 1rem, 2.25rem);
    --text-h3: clamp(1.25rem, 1vw + 1rem, 1.6rem);
    --text-body: clamp(1.125rem, 0.4vw + 1rem, 1.1875rem);
    --text-small: 0.9375rem;

    /* Contrast fix: replace washed-out grey with readable slate */
    --text-light: #414943;

    /* Better tap/hit targets (56px minimum per Stitch reference) */
    --touch-target: 56px;

    --radius-lg: 16px;
    --radius-md: 12px;

    --font-serif: "Source Serif 4", "EB Garamond", Georgia, serif;
    --font-sans: "Atkinson Hyperlegible Next", "Plus Jakarta Sans", sans-serif;
}

/* ------------------------------------------------------------------
   Base typography — larger, higher-contrast, elderly-friendly
   ------------------------------------------------------------------ */
html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Atkinson Hyperlegible Next', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: var(--text-body);
    line-height: 1.65;
    background-color: var(--surface);
    color: var(--on-surface);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Source Serif 4', 'EB Garamond', 'Playfair Display', serif;
    line-height: 1.2;
    letter-spacing: 0;
    font-weight: 600;
    color: var(--on-surface);
    overflow-wrap: break-word;
}

h1 { font-size: var(--text-h1); }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); }

p, li, dd, dt {
    overflow-wrap: break-word;
}

/* Prevent iOS auto-zoom on inputs while keeping text ≥16px */
input, select, textarea, button {
    font-family: inherit;
    font-size: 1rem;
}

a {
    color: var(--primary);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
}

img {
    max-width: 100%;
    height: auto;
}

/* ------------------------------------------------------------------
   Focus & accessibility
   ------------------------------------------------------------------ */
:focus-visible {
    outline: 3px solid var(--secondary-container) !important;
    outline-offset: 3px;
    border-radius: 4px;
}

::selection {
    background: var(--secondary-container);
    color: var(--on-secondary-container);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ------------------------------------------------------------------
   Shared layout & spacing
   ------------------------------------------------------------------ */
.container {
    width: min(1200px, 92vw);
    margin-inline: auto;
    padding-inline: clamp(16px, 4vw, 32px);
}

section {
    padding-block: clamp(48px, 8vw, 96px);
}

/* Header / nav */
.header {
    padding-inline: clamp(16px, 4vw, 32px);
}

.nav-link {
    font-size: 1.0625rem;
    padding-block: 10px;
}

.nav-toggle {
    min-width: var(--touch-target);
    min-height: var(--touch-target);
}

.header-menu .btn {
    margin-block: 4px;
}

/* ------------------------------------------------------------------
   Buttons, inputs, controls — large, comfortable targets
   ------------------------------------------------------------------ */
.btn {
    min-height: var(--touch-target);
    padding: 12px 26px;
    font-size: 1.0625rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary,
.btn-full {
    background: var(--primary);
    color: var(--on-primary);
}

.btn-primary:hover,
.btn-full:hover {
    background: #024b31;
    box-shadow: 0 6px 16px rgba(1, 50, 32, 0.28);
}

.btn-outline {
    border-width: 2px;
    background: transparent;
}

.btn-search,
.btn-send,
.btn-approve,
.btn-reject,
.btn-toggle,
.btn-white,
.btn-secondary {
    min-height: var(--touch-target);
    padding: 12px 24px;
    font-size: 1.0625rem;
    border-radius: var(--radius-md);
}

.input-group label,
.filter-group label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--on-surface);
}

.input-group input,
.input-group select,
.input-group textarea,
.input-control,
.filter-group select,
.filter-group input {
    min-height: 56px;
    padding: 13px 16px;
    font-size: 1.0625rem;
    border-radius: var(--radius-md);
    border: 2px solid var(--outline-variant);
    background: var(--surface-container-lowest);
    color: var(--on-surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus,
.input-control:focus,
.filter-group select:focus,
.filter-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(1, 50, 32, 0.18);
    outline: none;
}

.input-group .input-icon {
    min-height: 56px;
    display: flex;
    align-items: center;
}

/* 56px minimum touch targets on compact controls (Stitch) */
.nav-item {
    min-height: 56px;
}

.nav-link {
    min-height: 56px;
    display: inline-flex;
    align-items: center;
}

.sort-select,
.lead-reveal-btn,
.propbot-send,
.propbot-close,
.btn-close-modal,
.mobile-menu-btn {
    min-height: 56px;
    min-width: 56px;
}

.mobile-menu-btn,
.btn-close-modal,
.propbot-close,
.propbot-send {
    width: 56px;
    height: 56px;
}

.chat-back-btn {
    min-width: 56px;
    min-height: 56px;
}

.inbox-header > .material-symbols-rounded {
    width: 56px;
    height: 56px;
}

.form-group input,
.form-group select {
    min-height: 56px;
}

/* ------------------------------------------------------------------
   Homepage components
   ------------------------------------------------------------------ */
.hero-content h1 {
    font-size: var(--text-display);
    font-weight: 600;
}

.search-box {
    width: min(720px, 100%);
    margin-inline: auto;
}

.search-box input {
    min-height: 56px;
    font-size: 1.0625rem;
    padding-inline: 18px;
}

.search-box button {
    min-height: 56px;
    padding-inline: 28px;
}

.categories-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: clamp(14px, 2.5vw, 24px);
}

.category-card {
    padding: clamp(20px, 3vw, 28px);
    border-radius: var(--radius-lg);
}

.category-card .cat-icon {
    font-size: 2rem;
}

.property-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(20px, 3vw, 32px);
}

@media (min-width: 560px) {
    .property-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .property-grid { grid-template-columns: repeat(3, 1fr); }
}

.property-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.property-details {
    font-size: 1rem;
    line-height: 1.6;
}

.badge {
    font-size: 0.875rem;
    padding: 6px 12px;
    border-radius: 999px;
}

.fav-btn {
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.location {
    font-size: 1rem;
}

.stats span {
    font-size: 1rem;
}

/* ------------------------------------------------------------------
   Auth pages
   ------------------------------------------------------------------ */
.auth-container {
    width: min(460px, 92vw);
    margin-inline: auto;
    padding: clamp(28px, 5vw, 48px);
    border-radius: var(--radius-lg);
}

.auth-container h2 {
    font-size: var(--text-h2);
}

/* ------------------------------------------------------------------
   Dashboard
   ------------------------------------------------------------------ */
.main-content {
    padding: clamp(20px, 4vw, 48px);
}

.sidebar {
    padding-block: 20px;
}

.nav-item {
    font-size: 1.0625rem;
    padding-block: 14px;
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.metric-info h3 {
    font-size: 1.0625rem;
}

.metric-info .value {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
}

/* Dashboard property cards / filters */
.filters-sidebar {
    border-radius: var(--radius-lg);
}

.filter-group {
    margin-bottom: 24px;
}

.property-card .card-image-container img {
    min-height: 200px;
    object-fit: cover;
}

/* Tables — scroll horizontally instead of squashing on small screens */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    min-width: 640px;
}

.table-responsive th,
.table-responsive td {
    font-size: 1rem;
    padding: 14px 16px;
}

/* ------------------------------------------------------------------
   Listing wizard & search
   ------------------------------------------------------------------ */
.step-title {
    font-size: var(--text-h2);
}

.step-subtitle {
    font-size: 1.0625rem;
    color: var(--on-surface-variant);
}

/* ------------------------------------------------------------------
   Footer (homepage)
   ------------------------------------------------------------------ */
.footer {
    margin-top: 64px;
    background: var(--primary);
    color: var(--surface-container-low);
    padding: clamp(40px, 6vw, 64px) clamp(16px, 4vw, 32px) 24px;
}

.footer-container {
    max-width: 1200px;
    margin-inline: auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
}

.footer-logo {
    font-family: 'Source Serif 4', 'EB Garamond', serif;
    font-size: 1.9rem;
    font-weight: 700;
    color: #ffffff;
}

.footer-tagline {
    margin-top: 10px;
    font-size: 1.0625rem;
    line-height: 1.6;
    color: #cfe0d6;
    max-width: 34ch;
}

.footer-heading {
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--secondary-container);
    margin-bottom: 16px;
}

.footer-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-col a {
    color: var(--surface-container-low);
    font-size: 1.0625rem;
    text-decoration: none;
    padding-block: 2px;
}

.footer-col a:hover {
    color: var(--secondary-container);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.footer-bottom {
    max-width: 1200px;
    margin: 40px auto 0;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    font-size: 0.95rem;
    color: #cfe0d6;
    text-align: center;
}

@media (min-width: 560px) {
    .footer-container { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .footer-container { grid-template-columns: 2fr 1fr 1fr 1fr; }
    .footer-bottom { text-align: left; }
}

/* ------------------------------------------------------------------
   Responsive refinements by breakpoint
   ------------------------------------------------------------------ */
@media (max-width: 767px) {
    .btn-full { width: 100%; }

    .hero-content p {
        font-size: 1.125rem;
    }

    .sidebar + .main-content,
    .main-content {
        margin-left: 0;
    }

    .filters-sidebar {
        width: 100%;
    }

    .stats {
        flex-wrap: wrap;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .categories-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .nav-link {
        padding: 0 16px;
        width: 100%;
        justify-content: center;
    }

    .user-actions .btn {
        min-height: 56px;
    }

    .btn {
        padding-inline: 18px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .main-content {
        padding: 28px;
        margin-left: 264px;
    }

    .sidebar {
        width: 264px;
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
}

@media (min-width: 1024px) {
    .main-content { padding: 40px 48px; }
    .sidebar { width: 280px; }
}

@media (min-width: 1440px) {
    body { font-size: 1.125rem; }
}

/* ------------------------------------------------------------------
   Compact legal-only footers — ALL breakpoints.
   Every page except the homepage shares a small "Legal & Compliance"
   footer (.footer with a single .footer-col); it renders as one thin
   strip: inline links + copyright line. Homepage uses .gk-footer and
   is untouched; .footer-rich is a future escape hatch for full footers.
   ------------------------------------------------------------------ */
.footer:not(.footer-rich) {
    margin-top: 40px;
    padding: 18px 16px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
}

/* Auth pages (login/signup/verify/reset) center their content with a row
   flex body - without this the footer becomes a flex item squeezed beside
   the auth card (or stretched to full height by align-self). Let any flex
   body wrap, and give the footer a full row of its own. Harmless on block
   layouts, and consistent with dashboard.css's row-flex fix. */
body:has(> .footer) {
    flex-wrap: wrap;
}

body > .footer {
    flex: 1 1 100%;
    width: 100%;
    align-self: stretch;
    box-sizing: border-box;
}

.footer:not(.footer-rich) .footer-container {
    display: block;
}

.footer:not(.footer-rich) .footer-col {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px 8px;
}

.footer:not(.footer-rich) .footer-col a {
    font-size: 0.85rem;
}

/* Dot separators between inline legal links */
.footer:not(.footer-rich) .footer-col a + a::before {
    content: "\00B7";
    margin-right: 8px;
    opacity: 0.5;
}

/* The nav's aria-label="Legal and Compliance" carries the context for
   assistive tech; the visual heading is dropped to keep the strip slim. */
.footer:not(.footer-rich) .footer-heading {
    display: none;
}

.footer:not(.footer-rich) .footer-bottom {
    margin: 6px auto 0;
    padding-top: 8px;
    font-size: 0.8rem;
}

@media (max-width: 767px) {
    .footer:not(.footer-rich) {
        margin-top: 20px;
        padding: 14px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}
