/**
 * LIVZO — "Society insights" (homepage module 5).
 *
 * A residential intelligence panel: an illustrated society on the left, the
 * everyday categories on the right. Visually distinct from the comparison module
 * above it — no table, no row of identical cards, but the same tokens and motion
 * language so the page still reads as one system.
 *
 * Motion index
 *   reveal-on-scroll → [data-lz-inview] + .is-in (assets/js/societies.js)
 *   score rings      → .lz-insights__ring-value stroke-dashoffset on reveal
 *   score meters     → .lz-insights__bar-fill scaleX on reveal
 *   ambient          → glow drift, map-line crawl, floating pins
 *
 * Layout
 *   ≥1000px : two columns (visual ≈45%), the image stretched to the panel height
 *   <1000px : stacked — the framed image, then the panel
 */

/* ==========================================================================
   1. Shell + decorative background
   ========================================================================== */

.lz-insights {
    position: relative;
    isolation: isolate;
    padding: clamp(60px, 6.6vw, 96px) 0 clamp(68px, 8vw, 100px);
    scroll-margin-top: calc(var(--lz-header-h) + 16px);
}

.lz-insights__bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.lz-insights__glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(72px);
}

.lz-insights__glow--a {
    top: -14%;
    left: -8%;
    width: min(46vw, 540px);
    aspect-ratio: 1;
    background-image: radial-gradient(circle at 50% 50%, rgba(109, 74, 255, 0.16), rgba(109, 74, 255, 0) 70%);
    animation: lzDrift 24s ease-in-out infinite;
}

.lz-insights__glow--b {
    bottom: -20%;
    right: -10%;
    width: min(42vw, 500px);
    aspect-ratio: 1;
    background-image: radial-gradient(circle at 50% 50%, rgba(109, 74, 255, 0.11), rgba(109, 74, 255, 0) 70%);
    animation: lzDrift 30s ease-in-out infinite reverse;
}

/* Faint architectural grid, faded out towards the edges. */
.lz-insights__grid-lines {
    position: absolute;
    inset: -6% -6% 0;
    background-image: linear-gradient(rgba(11, 27, 51, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(11, 27, 51, 0.045) 1px, transparent 1px);
    background-size: 68px 68px;
    -webkit-mask-image: radial-gradient(ellipse 66% 60% at 50% 40%, #000 0%, transparent 74%);
    mask-image: radial-gradient(ellipse 66% 60% at 50% 40%, #000 0%, transparent 74%);
}

/* Very subtle map routes with tiny nodes — the "where" behind the numbers. */
.lz-insights__map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    color: var(--lz-accent);
    opacity: 0.13;
}

.lz-insights__map path { animation: lzInsMapDash 34s linear infinite; }
.lz-insights__map path:nth-of-type(2) { animation-duration: 42s; animation-direction: reverse; }

@keyframes lzInsMapDash {
    to { stroke-dashoffset: -150; }
}

.lz-insights__pin {
    position: absolute;
    color: var(--lz-accent);
}

.lz-insights__pin .lz-icon { width: 100%; height: 100%; }

.lz-insights__pin--a {
    top: 15%;
    right: 4%;
    width: 24px;
    opacity: 0.10;
    animation: lzFloat 13s ease-in-out infinite;
}

.lz-insights__pin--b {
    top: 64%;
    left: 3%;
    width: 18px;
    opacity: 0.08;
    animation: lzFloat 16s ease-in-out infinite reverse;
}

.lz-insights__pin--c {
    top: 9%;
    left: 32%;
    width: 15px;
    opacity: 0.07;
    animation: lzFloat 11s ease-in-out infinite;
}

/* ==========================================================================
   2. Section header
   ========================================================================== */

.lz-insights__head {
    display: grid;
    gap: 22px;
}

.lz-insights__intro { max-width: 700px; }

.lz-insights__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--lz-accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.lz-insights__eyebrow-ico {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--lz-accent-soft);
    color: var(--lz-accent);
    animation: lzPulse 3.4s var(--lz-ease) infinite;
}

.lz-insights__eyebrow-ico .lz-icon { width: 14px; height: 14px; }

.lz-insights__title {
    margin-top: 14px;
    font-size: clamp(1.9rem, 1.25rem + 2.05vw, 2.9rem);
    letter-spacing: -0.035em;
    text-wrap: balance;
}

.lz-insights__title-accent {
    background-image: linear-gradient(100deg, var(--lz-accent-700) 0%, var(--lz-accent) 34%, #9C86FF 62%, var(--lz-accent) 100%);
    background-size: 220% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: var(--lz-accent);
    -webkit-text-fill-color: transparent;
    animation: lzAccentFlow 9s var(--lz-ease) infinite;
}

.lz-insights__lead {
    margin-top: 14px;
    max-width: 58ch;
    font-size: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
    line-height: 1.7;
    color: var(--lz-body);
}

.lz-insights__viewall {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 11px 18px;
    border: 1px solid var(--lz-line-2);
    border-radius: var(--lz-r-pill);
    background-color: #fff;
    box-shadow: var(--lz-sh-1);
    color: var(--lz-navy);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: color var(--lz-t) var(--lz-ease),
        border-color var(--lz-t) var(--lz-ease),
        box-shadow var(--lz-t) var(--lz-ease),
        transform var(--lz-t) var(--lz-ease);
}

.lz-insights__viewall:hover {
    color: var(--lz-accent);
    border-color: rgba(109, 74, 255, 0.32);
    transform: translateY(-2px);
    box-shadow: 0 16px 30px -18px rgba(109, 74, 255, 0.70);
}

.lz-insights__viewall-ico {
    width: 17px;
    height: 17px;
    transition: transform 0.34s var(--lz-ease-out);
}

.lz-insights__viewall:hover .lz-insights__viewall-ico { transform: translateX(4px); }

@media (min-width: 960px) {
    .lz-insights__head {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
        gap: clamp(28px, 4vw, 56px);
    }

    .lz-insights__viewall { justify-self: end; }
}

/* ==========================================================================
   3. Two-column body
   ========================================================================== */

.lz-insights__body {
    display: grid;
    /* Explicit shrinkable column: the stacked layout must not inherit the
       min-content width of the swipe row inside it. */
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(24px, 3vw, 40px);
    margin-top: clamp(30px, 3.6vw, 48px);
}

@media (min-width: 1000px) {
    .lz-insights__body {
        grid-template-columns: minmax(0, 0.84fr) minmax(0, 1fr);
        align-items: stretch;
        gap: clamp(28px, 3.4vw, 52px);
    }
}

/* ==========================================================================
   4. Society visual (SocietyVisual)
   ========================================================================== */

.lz-insights__visual {
    position: relative;
    min-width: 0;
    min-height: clamp(280px, 32vw, 430px);
}

.lz-insights__frame {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 26px;
    background-color: var(--lz-bg-2);
    box-shadow: 0 1px 2px rgba(11, 27, 51, 0.05), 0 34px 66px -44px rgba(11, 27, 51, 0.42);
}

.lz-insights__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* The artwork carries its own title at the top, so the crop takes the foreground
       foliage at the bottom rather than slicing the heading in half. */
    object-position: center top;
}

/* ==========================================================================
   5. Intelligence panel
   ========================================================================== */

.lz-insights__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: clamp(13px, 1.4vw, 17px);
    padding: clamp(16px, 1.7vw, 22px);
    border: 1px solid var(--lz-line);
    border-radius: 24px;
    background-color: var(--lz-surface);
    box-shadow: 0 1px 2px rgba(11, 27, 51, 0.05), 0 26px 52px -40px rgba(11, 27, 51, 0.34);
    overflow: hidden;
}

/* Faint lavender wash in the top corner — the dashboard's "power on" light. */
.lz-insights__panel::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background-image: radial-gradient(120% 72% at 100% 0%, rgba(109, 74, 255, 0.07), rgba(109, 74, 255, 0) 62%);
    pointer-events: none;
}

.lz-insights__panel-title {
    font-size: clamp(1.1rem, 0.96rem + 0.5vw, 1.34rem);
    letter-spacing: -0.028em;
}

.lz-insights__panel-lead {
    margin-top: 5px;
    color: var(--lz-body);
    font-size: 0.88rem;
    line-height: 1.5;
}

/* The society the panel describes — a route into its profile. */
.lz-insights__panel-society {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin-top: 9px;
    padding-top: 9px;
    border-top: 1px solid var(--lz-line);
}

.lz-insights__panel-society-ico {
    display: inline-flex;
    color: var(--lz-accent);
}

.lz-insights__panel-society-link {
    color: var(--lz-navy);
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color var(--lz-t) var(--lz-ease-out), border-color var(--lz-t) var(--lz-ease-out);
}

.lz-insights__panel-society-link:hover {
    color: var(--lz-accent);
    border-bottom-color: var(--lz-accent-soft-2);
}

.lz-insights__panel-society-loc {
    color: var(--lz-body);
    font-size: 0.84rem;
    font-weight: 500;
}

/* --- Metric grid ------------------------------------------------------- */

.lz-insights__metrics {
    display: grid;
    gap: clamp(9px, 1vw, 13px);
}

/* ==========================================================================
   6. Insight metrics (InsightMetric + ScoreIndicator)
   ========================================================================== */

/* --- Ring categories (the highlight three) ------------------------------ */

.lz-insights__rings {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(8px, 0.9vw, 11px);
}

.lz-insights__metric--ring {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    min-width: 0;
    padding: 12px 11px 11px;
    border: 1px solid var(--lz-line);
    border-radius: 18px;
    background-image: radial-gradient(120% 90% at 50% 0%, rgba(109, 74, 255, 0.05), rgba(109, 74, 255, 0) 72%),
        linear-gradient(180deg, #FFFFFF, var(--lz-bg-2));
    text-align: center;
    transition: transform 0.3s var(--lz-ease-out),
        box-shadow 0.3s var(--lz-ease-out),
        border-color 0.3s var(--lz-ease),
        background-color 0.3s var(--lz-ease);
}

.lz-insights__metric--ring:hover {
    transform: translateY(-3px);
    border-color: rgba(109, 74, 255, 0.28);
    background-color: #F8F6FF;
    box-shadow: 0 18px 34px -24px rgba(109, 74, 255, 0.65);
}

.lz-insights__gauge {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 58px;
    height: 58px;
}

.lz-insights__ring {
    position: absolute;
    inset: 0;
}

.lz-insights__ring-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.lz-insights__ring-track {
    fill: none;
    stroke: rgba(11, 27, 51, 0.09);
    stroke-width: 5;
}

.lz-insights__ring-value {
    fill: none;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dashoffset: var(--lz-ring-offset, 0px);
    transition: stroke-dashoffset 1.05s var(--lz-ease-out) var(--lz-insight-delay, 180ms),
        stroke-width 0.3s var(--lz-ease);
}

.lz-insights__metric--ring:hover .lz-insights__ring-value { stroke-width: 6.6; }

/* Rating band → gauge colour. Both variants (ring and bar) read the same 0–5 bands as
   every other gauge on the site (livzo_rating_tone), so a 3.9 is amber wherever it
   appears. A CSS `stroke` beats the builder's `stroke="url(#…)"` attribute. */
.lz-insights__ring--success .lz-insights__ring-value { stroke: var(--lz-band-success); }
.lz-insights__ring--warning .lz-insights__ring-value { stroke: var(--lz-band-warning); }
.lz-insights__ring--danger .lz-insights__ring-value { stroke: var(--lz-band-danger); }

.lz-insights__bar--success .lz-insights__bar-fill {
    background-image: linear-gradient(90deg, var(--lz-band-success), var(--lz-band-success-2));
}

.lz-insights__bar--warning .lz-insights__bar-fill {
    background-image: linear-gradient(90deg, var(--lz-band-warning), var(--lz-band-warning-2));
}

.lz-insights__bar--danger .lz-insights__bar-fill {
    background-image: linear-gradient(90deg, var(--lz-band-danger), var(--lz-band-danger-2));
}

.lz-insights__metric-score {
    position: relative;
    color: var(--lz-navy);
    font-size: 1.06rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s var(--lz-ease);
}

.lz-insights__metric--ring:hover .lz-insights__metric-score { color: var(--lz-accent-700); }

/* --- Bar categories (the compact supporting three) ---------------------- */

.lz-insights__bars {
    display: grid;
    border: 1px solid var(--lz-line);
    border-radius: 20px;
    background-color: var(--lz-surface);
    overflow: hidden;
}

.lz-insights__metric--bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px 14px;
    padding: 9px 16px 10px;
    transition: background-color 0.3s var(--lz-ease);
}

.lz-insights__metric--bar + .lz-insights__metric--bar { border-top: 1px solid var(--lz-line); }

.lz-insights__metric--bar:hover { background-color: #F8F6FF; }

.lz-insights__metric-id {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.lz-insights__metric-ico {
    display: grid;
    place-items: center;
    flex: none;
    color: var(--lz-accent);
    transition: transform 0.3s var(--lz-ease-out);
}

.lz-insights__metric-ico .lz-icon { width: 15px; height: 15px; }

.lz-insights__metric--ring:hover .lz-insights__metric-ico { transform: translateY(-1px) scale(1.14); }

.lz-insights__metric--bar:hover .lz-insights__metric-ico { transform: scale(1.14); }

.lz-insights__metric-name {
    color: var(--lz-navy);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: -0.015em;
}

/* Bar variant: name + score on the first line, meter + label beneath. */
.lz-insights__metric--bar .lz-insights__metric-id { grid-area: 1 / 1; }
.lz-insights__metric--bar .lz-insights__metric-score { grid-area: 1 / 2; }
.lz-insights__metric--bar .lz-insights__bar { grid-area: 2 / 1 / 3 / 3; margin-top: 4px; }
.lz-insights__metric--bar .lz-insights__metric-label { grid-area: 3 / 1 / 4 / 3; margin-top: 3px; }

.lz-insights__metric-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--lz-body);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: -0.005em;
}

.lz-insights__mentions {
    color: var(--lz-body);
    font-weight: 600;
}

.lz-insights__mentions::before {
    content: '·';
    margin-right: 6px;
    color: var(--lz-accent);
    opacity: 0.6;
}

/* --- The gauge itself --------------------------------------------------- */

.lz-insights__bar {
    display: block;
    height: 4px;
    border-radius: 999px;
    overflow: hidden;
    background-color: rgba(11, 27, 51, 0.07);
}

.lz-insights__bar-fill {
    display: block;
    height: 100%;
    width: var(--lz-insight-fill, 0%);
    border-radius: 999px;
    background-image: linear-gradient(90deg, var(--lz-accent-600), #9C86FF);
    transform-origin: left center;
}

/* With JS every gauge starts empty and fills once its block scrolls in. */
.has-js .lz-insights__ring-value { stroke-dashoffset: 163.36px; }
.has-js .lz-insights__metric--ring.is-in .lz-insights__ring-value {
    stroke-dashoffset: var(--lz-ring-offset, 0px);
}

.has-js .lz-insights__bar-fill {
    transform: scaleX(0);
    transition: transform 0.9s var(--lz-ease-out) var(--lz-insight-delay, 320ms);
}

.has-js .lz-insights__bars.is-in .lz-insights__bar-fill { transform: scaleX(1); }

/* ==========================================================================
   7. Resident sentiment + data context
   ========================================================================== */

.lz-insights__sentiment {
    padding: 13px 15px;
    border: 1px solid var(--lz-line);
    border-radius: 16px;
    background-color: var(--lz-bg-2);
}

.lz-insights__sentiment-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--lz-navy);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.lz-insights__sentiment-ico {
    display: grid;
    place-items: center;
    color: var(--lz-accent);
}

.lz-insights__sentiment-ico .lz-icon { width: 15px; height: 15px; }

.lz-insights__topics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
}

.lz-insights__topic {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px 5px 8px;
    border: 1px solid var(--lz-line);
    border-radius: var(--lz-r-pill);
    background-color: #fff;
    box-shadow: 0 1px 2px rgba(11, 27, 51, 0.04);
    color: var(--lz-body);
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    white-space: nowrap;
}

.lz-insights__topic-ico {
    display: grid;
    place-items: center;
    color: var(--lz-accent);
}

.lz-insights__topic-ico .lz-icon { width: 12px; height: 12px; }

.lz-insights__context {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px solid var(--lz-line);
    color: var(--lz-body);
    font-size: 0.72rem;
    line-height: 1.5;
}

.lz-insights__context-ico {
    display: grid;
    place-items: center;
    flex: none;
    color: var(--lz-accent);
}

.lz-insights__context-ico .lz-icon { width: 13px; height: 13px; }

/* ==========================================================================
   8. Bottom micro CTA + note
   ========================================================================== */

.lz-insights__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px 22px;
    margin-top: clamp(34px, 4vw, 54px);
    padding-top: clamp(26px, 3vw, 36px);
    border-top: 1px solid var(--lz-line);
}

.lz-insights__cta-title {
    color: var(--lz-navy);
    font-size: 1.06rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.lz-insights__cta-btn {
    border-color: rgba(109, 74, 255, 0.30);
    background-color: #fff;
    color: var(--lz-accent-700);
    box-shadow: var(--lz-sh-1);
}

.lz-insights__cta-btn:hover {
    background-color: var(--lz-accent-soft);
    border-color: rgba(109, 74, 255, 0.42);
    color: var(--lz-accent-700);
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -18px rgba(109, 74, 255, 0.80);
}

.lz-insights__cta-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--lz-body);
    font-size: 0.86rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: color var(--lz-t) var(--lz-ease);
}

.lz-insights__cta-link:hover { color: var(--lz-accent); }

.lz-insights__cta-link-ico {
    width: 15px;
    height: 15px;
    transition: transform 0.28s var(--lz-ease-out);
}

.lz-insights__cta-link:hover .lz-insights__cta-link-ico { transform: translateX(3px); }

.lz-insights__note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    color: var(--lz-body);
    font-size: 0.76rem;
    line-height: 1.5;
    text-align: center;
}

.lz-insights__note-ico {
    display: grid;
    place-items: center;
    flex: none;
    color: var(--lz-accent);
}

.lz-insights__note-ico .lz-icon { width: 14px; height: 14px; }

/* ==========================================================================
   9. Reveal on scroll (scoped copy — the module stays self-contained)
   ========================================================================== */

.has-js .lz-insights [data-lz-inview] {
    opacity: 0;
    transform: translateY(26px);
    transition: opacity 0.7s var(--lz-ease-out) var(--lz-delay, 0ms),
        transform 0.85s var(--lz-ease-out) var(--lz-delay, 0ms);
    will-change: opacity, transform;
}

.has-js .lz-insights [data-lz-inview].is-in {
    opacity: 1;
    transform: none;
    will-change: auto;
}

/* ==========================================================================
   10. Responsive
   ========================================================================== */

/* Stacked: the framed image leads, then the panel. */
@media (max-width: 999px) {
    .lz-insights__visual { min-height: 0; }

    .lz-insights__frame {
        position: relative;
        inset: auto;
        height: auto;
        aspect-ratio: 3 / 4;
    }
}

@media (max-width: 640px) {
    .lz-insights__rings { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .lz-insights__panel { border-radius: 22px; padding: 16px 15px; }
    .lz-insights__frame { border-radius: 22px; }

    .lz-insights__cta {
        flex-direction: column;
        gap: 14px;
        text-align: center;
    }
}

@media (max-width: 420px) {
    .lz-insights__title { letter-spacing: -0.03em; }
    .lz-insights__gauge { width: 54px; height: 54px; }
    .lz-insights__metric--ring { padding: 11px 9px 10px; }
}

/* ==========================================================================
   11. Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .has-js .lz-insights [data-lz-inview] {
        opacity: 1;
        transform: none;
    }

    .has-js .lz-insights__ring-value { stroke-dashoffset: var(--lz-ring-offset, 0px); }
    .has-js .lz-insights__bar-fill { transform: scaleX(1); }

    .lz-insights__title-accent,
    .lz-insights__eyebrow-ico,
    .lz-insights__glow,
    .lz-insights__map path,
    .lz-insights__pin {
        animation: none;
    }
}
