/* =========================================================
   Motif Market Reports
   market-intelligence.php + market-report.php
   ========================================================= */

:root {
    --mr-black: #171717;
    --mr-charcoal: #2a2a2a;
    --mr-gray: #6f706f;
    --mr-light-gray: #999;
    --mr-line: #ded9d0;
    --mr-paper: #f7f5f1;
    --mr-white: #fff;
    --mr-gold: #b68a3d;
    --mr-gold-dark: #8a672d;
    --mr-green: #597b42;
    --mr-red: #9b5449;
}

* { box-sizing: border-box; }

body.motif-market-page {
    margin: 0;
    background: var(--mr-white);
    color: var(--mr-black);
    font-family: 'Questrial', sans-serif;
}

/* Shared header: force solid black treatment on report pages */
.motif-market-page .motif-main-header {
    position: relative !important;
    background: #111 !important;
    border-bottom: 1px solid rgba(255,255,255,.08) !important;
}

.motif-market-page .motif-main-header .motif-main-nav > a,
.motif-market-page .motif-main-header .motif-nav-dropdown-toggle {
    color: #fff !important;
}

.motif-market-page .motif-main-header .motif-main-nav > a::after,
.motif-market-page .motif-main-header .motif-nav-dropdown-toggle::after {
    background: var(--mr-gold) !important;
}

/* HERO */
.mr-hero {
    position: relative;
    min-height: 360px;
    display: flex;
    align-items: stretch;
    overflow: hidden;
    border-bottom: 1px solid var(--mr-line);
}

.mr-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(247,245,241,.98) 0%, rgba(247,245,241,.94) 30%, rgba(247,245,241,.18) 56%, rgba(247,245,241,0) 72%),
        url('/assets/img/market-report-hero.png') center / cover no-repeat;
}

.mr-town-hero::before {
    background:
        linear-gradient(90deg, rgba(247,245,241,.98) 0%, rgba(247,245,241,.94) 30%, rgba(247,245,241,.18) 56%, rgba(247,245,241,0) 72%),
        var(--mr-hero-image) center 48% / cover no-repeat;
}

.mr-hero-copy {
    position: relative;
    z-index: 2;
    width: min(760px, 54%);
    padding: 52px 4.5vw 46px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.mr-kicker,
.mr-panel-label {
    color: var(--mr-gold-dark);
    font-size: .72rem;
    letter-spacing: .18em;
    text-transform: uppercase;
}

.mr-hero h1 {
    margin: 10px 0 12px;
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: clamp(3.2rem, 5.2vw, 5.6rem);
    line-height: .93;
}

.mr-hero p {
    max-width: 610px;
    margin: 0;
    color: #464646;
    font-size: 1.05rem;
    line-height: 1.55;
}

.mr-updated {
    margin-top: 16px;
    color: var(--mr-gray);
    font-size: .76rem;
}

.mr-breadcrumbs {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    font-size: .72rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.mr-breadcrumbs a { color: var(--mr-gold-dark); text-decoration: none; }
.mr-breadcrumbs strong { font-weight: 400; }

/* SHELL */
.mr-shell {
    width: min(1500px, calc(100% - 64px));
    margin: 0 auto;
}

.mr-tabs {
    display: flex;
    gap: 36px;
    padding: 22px 0 0;
    border-bottom: 1px solid var(--mr-line);
}
.mr-tabs a {
    position: relative;
    padding: 0 0 15px;
    color: var(--mr-charcoal);
    font-size: .75rem;
    letter-spacing: .1em;
    text-decoration: none;
    text-transform: uppercase;
}
.mr-tabs a.active::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    background: var(--mr-gold);
}

/* KPI STRIP */
.mr-kpis {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    border: 1px solid var(--mr-line);
    border-top: 0;
}
.mr-town-report .mr-kpis {
    grid-template-columns: repeat(7, 1fr);
    margin-top: 0;
    border-top: 1px solid var(--mr-line);
}
.mr-kpi {
    min-width: 0;
    padding: 22px 18px;
    border-right: 1px solid var(--mr-line);
}
.mr-kpi:last-child { border-right: 0; }
.mr-kpi > span {
    display: block;
    min-height: 30px;
    color: var(--mr-gray);
    font-size: .66rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.mr-kpi strong {
    display: block;
    margin: 5px 0 7px;
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: clamp(1.45rem, 2vw, 2rem);
    white-space: nowrap;
}
.mr-kpi small {
    display: block;
    font-size: .68rem;
}
.mr-kpi small em {
    display: block;
    margin-top: 4px;
    color: var(--mr-gray);
    font-style: normal;
}
.up { color: var(--mr-green) !important; }
.down { color: var(--mr-red) !important; }
.neutral { color: var(--mr-gray) !important; }

/* PANELS */
.mr-dashboard,
.mr-town-dashboard {
    display: grid;
    gap: 0;
    margin-top: 24px;
    border: 1px solid var(--mr-line);
}
.mr-dashboard { grid-template-columns: 2fr .8fr; }
.mr-town-dashboard { grid-template-columns: .9fr 1.25fr .9fr; }

.mr-panel {
    padding: 28px;
    border-right: 1px solid var(--mr-line);
    background: #fff;
}
.mr-panel:last-child { border-right: 0; }

.mr-panel h2 {
    margin: 8px 0 0;
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: 2rem;
}
.mr-panel-note,
.mr-summary-panel p {
    color: var(--mr-gray);
    line-height: 1.55;
    font-size: .9rem;
}

.mr-chart {
    margin-top: 20px;
}
.mr-chart svg {
    display: block;
    width: 100%;
    height: 220px;
    overflow: visible;
}
.mr-chart line {
    stroke: #e8e4dc;
    stroke-width: .35;
}
.mr-chart polyline {
    fill: none;
    stroke: var(--mr-gold-dark);
    stroke-width: 1.15;
    vector-effect: non-scaling-stroke;
}
.mr-months {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    margin-top: 8px;
    color: var(--mr-gray);
    font-size: .63rem;
    text-align: center;
}

.mr-temperature {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.mr-temperature h2 {
    font-size: 1.8rem;
}
.mr-temperature > strong {
    margin-top: 6px;
    font-family: 'Playfair Display', serif;
    font-size: 2.1rem;
    font-weight: 400;
}
.mr-temperature > span:last-child {
    margin-top: 4px;
    color: var(--mr-gray);
    font-size: .75rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.mr-gauge {
    position: relative;
    width: 180px;
    height: 90px;
    margin: 24px 0 0;
    overflow: hidden;
}
.mr-gauge-arc {
    position: absolute;
    left: 10px; right: 10px; top: 10px;
    height: 160px;
    border: 15px solid #e6e1d8;
    border-bottom-color: var(--mr-gold);
    border-left-color: var(--mr-gold);
    border-radius: 50%;
    transform: rotate(45deg);
}
.mr-gauge-needle {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 2px;
    height: 72px;
    background: var(--mr-black);
    transform-origin: bottom center;
}

.mr-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin-top: 24px;
    border: 1px solid var(--mr-line);
}
.mr-grid-3 .mr-panel { min-height: 280px; }

.mr-type-list,
.mr-change-list,
.mr-ratio-list,
.mr-summary-list,
.mr-bar-list {
    margin-top: 20px;
}
.mr-type-list > div,
.mr-change-list > div,
.mr-ratio-list > div,
.mr-summary-list > div {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 14px;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid #ece8e0;
}
.mr-type-list span,
.mr-change-list span,
.mr-ratio-list span,
.mr-summary-list span {
    color: var(--mr-gray);
    font-size: .85rem;
}
.mr-type-list strong,
.mr-change-list strong,
.mr-ratio-list strong,
.mr-summary-list strong {
    font-weight: 400;
}
.mr-type-list small {
    color: var(--mr-light-gray);
}

.mr-summary-list > div,
.mr-ratio-list > div {
    grid-template-columns: 1fr auto;
}

.mr-ratio-meter {
    height: 7px;
    margin: 34px 0 18px;
    background: #ece7df;
}
.mr-ratio-meter span {
    display: block;
    height: 100%;
    background: var(--mr-gold);
}

.mr-bar-list > div {
    display: grid;
    grid-template-columns: 92px 1fr 42px;
    gap: 12px;
    align-items: center;
    margin: 15px 0;
    font-size: .78rem;
}
.mr-bar-list i {
    display: block;
    height: 10px;
    background: #eeeae3;
    font-style: normal;
}
.mr-bar-list b {
    display: block;
    height: 100%;
    background: var(--mr-gold);
}

/* TOWN EXPLORER */
.mr-town-section,
.mr-activity {
    padding: 38px 0 46px;
}
.mr-section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 22px;
}
.mr-section-heading h2 {
    margin: 6px 0 4px;
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 400;
}
.mr-section-heading p {
    margin: 0;
    color: var(--mr-gray);
}
.mr-section-heading > a {
    color: var(--mr-gold-dark);
    text-decoration: none;
    font-size: .78rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.mr-town-search {
    display: flex;
    width: min(520px, 100%);
}
.mr-town-search input {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0 16px;
    border: 1px solid var(--mr-line);
    font: inherit;
}
.mr-town-search button {
    height: 48px;
    padding: 0 22px;
    border: 1px solid var(--mr-gold-dark);
    background: var(--mr-gold-dark);
    color: #fff;
    font: inherit;
    cursor: pointer;
}

.mr-town-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--mr-line);
    border-left: 1px solid var(--mr-line);
}
.mr-town-card {
    padding: 22px;
    border-right: 1px solid var(--mr-line);
    border-bottom: 1px solid var(--mr-line);
    color: inherit;
    text-decoration: none;
}
.mr-town-card > span {
    display: block;
    color: var(--mr-gold-dark);
    font-size: .72rem;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.mr-town-card strong {
    display: block;
    margin: 8px 0 5px;
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    font-weight: 400;
}
.mr-town-card small {
    display: block;
    color: var(--mr-gray);
}
.mr-town-card em {
    display: block;
    margin-top: 20px;
    color: var(--mr-gold-dark);
    font-size: .72rem;
    font-style: normal;
    letter-spacing: .08em;
    text-transform: uppercase;
}

/* TOWN REPORT TOOLBAR */
.mr-report-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 0;
}
.mr-report-toolbar a {
    color: var(--mr-gold-dark);
    text-decoration: none;
    font-size: .75rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.mr-report-toolbar > div {
    display: flex;
    gap: 24px;
}

/* PROPERTY ACTIVITY */
.mr-property-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--mr-line);
    border-left: 1px solid var(--mr-line);
}
.mr-property-card {
    color: inherit;
    text-decoration: none;
    border-right: 1px solid var(--mr-line);
    border-bottom: 1px solid var(--mr-line);
}
.mr-property-image {
    position: relative;
    aspect-ratio: 4 / 2.6;
    overflow: hidden;
}
.mr-property-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.mr-property-image span {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 6px 8px;
    background: rgba(255,255,255,.94);
    font-size: .62rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.mr-property-body {
    padding: 15px 16px 18px;
}
.mr-property-body strong {
    display: block;
    font-family: 'Playfair Display', serif;
    font-size: 1.35rem;
    font-weight: 400;
}
.mr-property-body > span {
    display: block;
    margin-top: 5px;
}
.mr-property-body small {
    display: block;
    margin-top: 8px;
    color: var(--mr-gray);
}

/* CLOSE */
.mr-close {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin: 0 -32px;
    padding: 44px 32px;
    background: var(--mr-black);
    color: #fff;
}
.mr-close h2 {
    margin: 7px 0 0;
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    font-weight: 400;
    line-height: 1;
}
.mr-close-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    gap: 12px;
}
.mr-close-actions a {
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,.35);
    padding-bottom: 5px;
}

/* EMPTY */
.mr-empty {
    padding: 44px 0;
    color: var(--mr-gray);
}

/* RESPONSIVE */
@media (max-width: 1200px) {
    .mr-kpis,
    .mr-town-report .mr-kpis {
        grid-template-columns: repeat(3, 1fr);
    }
    .mr-kpi { border-bottom: 1px solid var(--mr-line); }
    .mr-grid-3,
    .mr-town-dashboard {
        grid-template-columns: 1fr;
    }
    .mr-grid-3 .mr-panel,
    .mr-town-dashboard .mr-panel {
        border-right: 0;
        border-bottom: 1px solid var(--mr-line);
    }
    .mr-town-cards,
    .mr-property-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 800px) {
    .mr-shell {
        width: min(100% - 28px, 1500px);
    }
    .mr-hero {
        min-height: 480px;
    }
    .mr-hero::before,
    .mr-town-hero::before {
        background:
            linear-gradient(180deg, rgba(247,245,241,.72) 0%, rgba(247,245,241,.95) 54%, rgba(247,245,241,1) 100%),
            var(--mr-hero-image, url('/assets/img/connecticut-market-hero.jpg')) center / cover no-repeat;
    }
    .mr-hero-copy {
        width: 100%;
        align-self: flex-end;
        padding: 150px 20px 28px;
    }
    .mr-hero h1 {
        font-size: clamp(2.9rem, 12vw, 4.7rem);
    }
    .mr-tabs {
        gap: 18px;
        overflow-x: auto;
    }
    .mr-kpis,
    .mr-town-report .mr-kpis {
        grid-template-columns: repeat(2, 1fr);
    }
    .mr-dashboard {
        grid-template-columns: 1fr;
    }
    .mr-dashboard .mr-panel {
        border-right: 0;
        border-bottom: 1px solid var(--mr-line);
    }
    .mr-section-heading {
        align-items: stretch;
        flex-direction: column;
    }
    .mr-town-search {
        width: 100%;
    }
    .mr-report-toolbar {
        align-items: flex-start;
        gap: 16px;
        flex-direction: column;
    }
    .mr-report-toolbar > div {
        flex-wrap: wrap;
    }
    .mr-town-cards,
    .mr-property-grid {
        grid-template-columns: 1fr;
    }
    .mr-close {
        grid-template-columns: 1fr;
    }
    .mr-close-actions {
        align-items: flex-start;
    }
}
