/* ═══════════════════════════════════════════════════════════
   Cardiff Capital Region - Business Directory
   To CCR spec: sofia-pro (Sofia Sans stand-in), 600-weight
   headings in #243036, #AF1218 red, SQUARE corners, flat
   surfaces, chevron motif from the CCR mark.
   ═══════════════════════════════════════════════════════════ */

:root {
    --slate: #243036;
    --slate-2: #3d4a51;
    --red: #AF1218;
    --red-dark: #8c0e13;
    --grey: #72797F;
    --light: #F4F5F5;
    --line: #e2e5e6;
    --white: #ffffff;
    --shadow: 0 4px 24px rgba(23, 32, 37, .14);
    --amm: #AF1218;
    --cbe: #D97B29;
    --creative: #7D5BA6;
    --ehc: #1F8A70;
    --hrt: #C99700;
    --fintech: #2E6F9E;
    --mast-h: 74px;
    --sector-h: 74px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: 'Sofia Sans', 'Segoe UI', system-ui, sans-serif;
    color: var(--slate);
    background: var(--light);
    -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

#map { position: fixed; inset: 0; top: calc(var(--mast-h) + var(--sector-h)); }
#map canvas { outline: none; }

.chev { width: 11px; height: 13px; fill: var(--red); flex: none; }

/* ══ Loading ══ */
#loading {
    position: fixed; inset: 0; z-index: 100;
    background: var(--white);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 20px; transition: opacity .6s, visibility .6s;
}
#loading.done { opacity: 0; visibility: hidden; }
.load-chevrons { display: flex; flex-direction: column-reverse; gap: 5px; }
.load-chevrons svg { width: 58px; height: 16px; fill: var(--red); opacity: 0; animation: chev-rise 1.6s infinite; }
.load-chevrons svg:nth-child(2) { animation-delay: .2s; }
.load-chevrons svg:nth-child(3) { animation-delay: .4s; }
@keyframes chev-rise {
    0% { opacity: 0; transform: translateY(8px); }
    35%, 65% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-6px); }
}
.load-logo { width: min(330px, 68vw); }
.load-title {
    font-size: 22px; font-weight: 700; color: var(--slate);
    display: flex; flex-direction: column; align-items: center; line-height: 1.35;
}
.load-title span { font-size: 13px; font-weight: 400; color: var(--grey); }
.load-bar { width: min(280px, 58vw); height: 3px; background: var(--line); overflow: hidden; }
.load-bar-fill { height: 100%; width: 0%; background: var(--red); transition: width .3s; }
.load-hint { font-size: 13px; color: var(--grey); }

/* ══ Masthead ══ */
.masthead {
    position: fixed; z-index: 30; top: 0; left: 0; right: 0;
    height: var(--mast-h);
    background: var(--white); border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 18px;
    padding: 0 22px;
}
.brand { display: flex; align-items: center; }
.brand img { height: 46px; width: auto; display: block; }
.mast-sep { width: 1px; height: 40px; background: var(--line); }
.mast-title h1 { font-size: 20px; font-weight: 700; line-height: 1.1; letter-spacing: .01em; }
.mast-title span { font-size: 11.5px; color: var(--grey); }
.searchbox {
    flex: 1; max-width: 430px; margin-left: auto;
    display: flex; align-items: center; gap: 9px;
    background: var(--light); border: 1px solid var(--line);
    padding: 0 13px; height: 44px;
}
.searchbox:focus-within { border-color: var(--slate); }
.searchbox svg { width: 17px; height: 17px; color: var(--grey); flex: none; }
.searchbox input { flex: 1; border: 0; outline: 0; background: none; font-size: 15px; color: var(--slate); }
.search-clear { border: 0; background: none; font-size: 21px; color: var(--grey); line-height: 1; }
.showcase-wrap { position: relative; }
.showcase-btn {
    display: flex; align-items: center; gap: 8px;
    height: 44px; padding: 0 18px;
    background: var(--red); border: 0; color: #fff;
    font-size: 14px; font-weight: 700; letter-spacing: .02em;
}
.showcase-btn:hover { background: var(--red-dark); }
.showcase-btn svg { width: 19px; height: 19px; }
.showcase-pop {
    position: absolute; top: calc(100% + 9px); right: 0;
    min-width: 300px; background: var(--white);
    border: 1px solid var(--line); border-top: 3px solid var(--red);
    box-shadow: var(--shadow); z-index: 40;
}
.showcase-head {
    padding: 10px 14px; font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .09em; color: var(--grey);
    border-bottom: 1px solid var(--line);
}
.showcase-item {
    width: 100%; display: flex; align-items: center; gap: 11px;
    padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line);
    background: none; text-align: left; color: var(--slate);
}
.showcase-item:last-child { border-bottom: 0; }
.showcase-item:hover { background: var(--light); }
.showcase-item .biz-logo { width: 38px; height: 38px; }
.showcase-item b { font-size: 13.5px; display: block; }
.showcase-item small { font-size: 11px; color: var(--grey); display: flex; align-items: center; gap: 5px; }
.showcase-item small svg { width: 13px; height: 13px; fill: var(--red); }

.mast-count { display: flex; align-items: center; gap: 9px; }
.mast-count b { font-size: 30px; font-weight: 700; color: var(--red); line-height: 1; }
.mast-count span { font-size: 10.5px; line-height: 1.25; text-transform: uppercase; letter-spacing: .07em; color: var(--grey); }

/* ══ Sector tabs ══ */
.sector-bar {
    position: fixed; z-index: 29; top: var(--mast-h); left: 0; right: 0;
    height: var(--sector-h);
    background: var(--white); border-bottom: 1px solid var(--line);
    display: flex; align-items: stretch;
    overflow-x: auto; scrollbar-width: none;
}
.sector-bar::-webkit-scrollbar { display: none; }
.sector-tab {
    flex: 1 1 0; min-width: 138px;
    border: 0; border-right: 1px solid var(--line); background: none;
    display: flex; align-items: center; gap: 11px;
    padding: 0 16px; position: relative; text-align: left;
    color: var(--slate); transition: background .15s;
}
.sector-tab:hover { background: var(--light); }
.sector-tab::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
    background: var(--c, var(--slate)); opacity: 0; transition: opacity .15s;
}
.sector-tab.on { background: color-mix(in srgb, var(--c) 7%, #fff); }
.sector-tab.on::after { opacity: 1; }
.sector-icon {
    width: 34px; height: 34px; flex: none;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--c, var(--slate)) 12%, #fff);
    color: var(--c, var(--slate));
}
.sector-icon svg { width: 19px; height: 19px; }
.sector-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sector-txt b { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sector-txt span { font-size: 11px; color: var(--grey); }

/* ══ Directory panel ══ */
.panel {
    position: fixed; z-index: 25;
    top: calc(var(--mast-h) + var(--sector-h) + 16px);
    left: 16px; bottom: 16px; width: 360px;
    background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow);
    display: flex; flex-direction: column; overflow: hidden;
}
.panel-grip { display: none; }
.panel-tools { display: flex; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.select-wrap { flex: 1; position: relative; }
.select-wrap::after {
    content: ''; position: absolute; right: 13px; top: 50%;
    width: 7px; height: 7px; border-right: 2px solid var(--grey); border-bottom: 2px solid var(--grey);
    transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.select-wrap select {
    width: 100%; height: 40px; border: 1px solid var(--line);
    background: var(--white); color: var(--slate); font-size: 14px; font-weight: 600;
    padding: 0 32px 0 12px; appearance: none; outline: none;
}
.reset-btn {
    border: 1px solid var(--red); background: none; color: var(--red);
    font-size: 13px; font-weight: 700; padding: 0 14px;
}
.reset-btn:hover { background: var(--red); color: #fff; }
.panel-meta {
    padding: 9px 16px; font-size: 11.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em; color: var(--grey);
    border-bottom: 1px solid var(--line);
}
.panel-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.panel-list::-webkit-scrollbar { width: 9px; }
.panel-list::-webkit-scrollbar-thumb { background: #cfd4d6; border: 2px solid #fff; }

.biz-row {
    width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line);
    background: none; display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; transition: background .12s; position: relative;
}
.biz-row:hover { background: var(--light); }
.biz-row.on { background: color-mix(in srgb, var(--red) 6%, #fff); }
.biz-row.on::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--red);
}
.biz-logo {
    width: 44px; height: 44px; flex: none;
    background: #fff center/74% no-repeat; border: 1px solid var(--line);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 15px; color: #fff;
}
.biz-name { font-size: 14.5px; font-weight: 700; line-height: 1.2; }
.biz-sub { font-size: 11.5px; color: var(--grey); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.biz-sub .dot { width: 7px; height: 7px; flex: none; }
.panel-foot {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 16px; border-top: 1px solid var(--line);
    background: var(--slate); color: #fff;
    font-size: 12px; font-weight: 700; letter-spacing: .04em; text-decoration: none;
}
.panel-foot .chev { fill: #fff; }
.panel-foot:hover { background: var(--slate-2); }

/* ══ Detail drawer ══ */
.detail {
    position: fixed; z-index: 28;
    top: calc(var(--mast-h) + var(--sector-h) + 16px);
    right: 16px; width: 350px; max-height: calc(100vh - var(--mast-h) - var(--sector-h) - 32px);
    background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow);
    padding: 20px; overflow-y: auto;
}
.detail-rule { position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--red); }
.icon-btn {
    border: 0; background: var(--light); color: var(--slate);
    width: 30px; height: 30px; font-size: 18px; line-height: 1;
}
.icon-btn:hover { background: var(--line); }
.detail-close { position: absolute; top: 14px; right: 14px; }
.detail-head { display: flex; gap: 14px; align-items: flex-start; padding-right: 28px; }
.detail-logo {
    width: 66px; height: 66px; flex: none;
    background: #fff center/74% no-repeat; border: 1px solid var(--line);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 24px; color: #fff;
}
.detail-kicker {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .09em; color: var(--c, var(--red)); margin-bottom: 3px;
}
.detail-title h2 { font-size: 20px; font-weight: 700; line-height: 1.12; }
.detail-site { font-size: 11.5px; color: var(--grey); margin-top: 3px; font-style: italic; }
.detail-desc { font-size: 13.5px; line-height: 1.6; color: var(--slate-2); margin: 14px 0; }
.detail-rows { display: flex; flex-direction: column; gap: 9px; }
.drow { display: flex; gap: 10px; font-size: 12.5px; line-height: 1.45; color: var(--slate-2); }
.drow .chev { margin-top: 2px; }
.drow a { color: var(--red); text-decoration: none; font-weight: 700; word-break: break-all; }
.drow a:hover { text-decoration: underline; }
.detail-actions { display: flex; gap: 8px; margin-top: 16px; }
.act-btn {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 44px; font-size: 14px; font-weight: 700; text-decoration: none; border: 0;
}
.act-btn svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.act-btn.primary { background: var(--red); color: #fff; }
.act-btn.primary:hover { background: var(--red-dark); }
.act-btn.secondary { background: none; border: 1px solid var(--slate); color: var(--slate); }
.act-btn.secondary:hover { background: var(--slate); color: #fff; }

/* ══ Map controls ══ */
.mapctl {
    position: fixed; z-index: 24; right: 16px; bottom: 46px;
    display: flex; flex-direction: column;
    background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.mapctl button {
    width: 44px; height: 44px; border: 0; background: none;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 600; color: var(--slate);
}
.mapctl button:last-child { border-bottom: 0; }
.mapctl button:hover { background: var(--light); color: var(--red); }
.mapctl button svg { width: 20px; height: 20px; }
#ctl-3d-label { font-size: 13px; font-weight: 800; letter-spacing: .02em; }

/* ══ Legend ══ */
.legend-chip {
    position: fixed; z-index: 24; left: 392px; bottom: 16px;
    display: flex; align-items: center; gap: 9px;
    background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow);
    padding: 10px 15px; font-size: 12.5px; font-weight: 700; color: var(--slate);
}
.legend-chip:hover { border-color: var(--slate); }
.legend-pop {
    position: fixed; z-index: 26; left: 392px; bottom: 62px;
    width: 330px; background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow);
    padding: 18px;
}
.legend-pop h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.legend-pop p { font-size: 12.5px; line-height: 1.5; color: var(--slate-2); }
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 12px 0; }
.legend-item {
    display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600;
    border: 0; background: none; color: var(--slate); text-align: left;
    padding: 5px 6px; transition: background .12s;
}
.legend-item:hover { background: var(--light); }
.legend-item.on { background: color-mix(in srgb, var(--red) 8%, #fff); box-shadow: inset 3px 0 0 var(--red); }
.legend-item .dot { width: 11px; height: 11px; flex: none; }
.legend-item.all { grid-column: 1 / -1; border-bottom: 1px solid var(--line); padding-bottom: 7px; }
.legend-src { font-size: 11px; color: var(--grey); }

.osm-credit {
    position: fixed; z-index: 23; right: 16px; bottom: 16px;
    font-size: 10px; color: var(--grey); text-decoration: none;
    background: rgba(255,255,255,.85); padding: 3px 8px;
}

/* ══ Markers: NPT-style callout - dot, leader line, name pill ══ */
.marker-layer {
    position: absolute; inset: 0; overflow: hidden;
    pointer-events: none; z-index: 1;
}
.marker {
    position: absolute; left: 0; top: 0;
    display: flex; flex-direction: column; align-items: center;
    cursor: pointer; pointer-events: auto;
    will-change: transform;
}
.m-label {
    display: flex; align-items: center; gap: 7px;
    border: 1px solid var(--slate); background: #fff; color: var(--slate);
    padding: 4px 10px 4px 4px; white-space: nowrap;
    font-size: 12px; font-weight: 700;
    box-shadow: 0 2px 10px rgba(23,32,37,.35);
    transition: transform .12s;
}
.m-logo {
    width: 22px; height: 22px; flex: none;
    background: #fff center/82% no-repeat; border: 1px solid var(--line);
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 800; color: #fff;
}
.m-stalk {
    width: 2px; height: var(--h, 26px);
    background: linear-gradient(to top, var(--c, var(--red)), color-mix(in srgb, var(--c, var(--red)) 55%, transparent));
}
.m-dot {
    width: 9px; height: 9px; border-radius: 50%; margin-top: -1px;
    background: var(--c, var(--red)); border: 2px solid #fff;
    box-shadow: 0 1px 5px rgba(23,32,37,.5);
}
.marker:hover { z-index: 5; }
.marker:hover .m-label { transform: scale(1.06); border-color: var(--c, var(--red)); }
.marker.on { z-index: 6; }
.marker.on .m-label { border: 2px solid var(--red); padding: 3px 9px 3px 3px; }
/* at low zoom the pill collapses to a round logo badge on the leader line;
   hover or selection expands it back to the full name button */
.labels-off .marker:not(.on):not(:hover) .m-name { display: none; }
.labels-off .marker:not(.on):not(:hover) .m-label {
    padding: 0; border-radius: 50%;
    border-color: var(--c, var(--red));
    box-shadow: 0 2px 8px rgba(23,32,37,.4);
}
.labels-off .marker:not(.on):not(:hover) .m-logo {
    width: 28px; height: 28px; border-radius: 50%; border: 0;
    background-size: 78%;
}
.labels-off .marker:not(.on):not(:hover) .m-stalk { height: 14px; }
/* VR accent: this company has a virtual tour */
.m-vr {
    position: absolute; top: -7px; right: -7px;
    width: 17px; height: 17px; border-radius: 50%;
    background: var(--red); border: 1.5px solid #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 4px rgba(23,32,37,.4);
}
.m-vr svg { width: 10px; height: 10px; fill: #fff; }
.m-label { position: relative; }

/* ══ Virtual tour modal ══ */
.tour-modal {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(23, 32, 37, .78);
    display: flex; align-items: center; justify-content: center;
    padding: 3vh 3vw;
}
.tour-modal[hidden] { display: none; }
.tour-frame {
    width: min(1280px, 96vw); height: min(86vh, 900px);
    background: var(--white); border-top: 4px solid var(--red);
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    display: flex; flex-direction: column;
}
.tour-head {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.tour-head .tour-vr { width: 22px; height: 22px; fill: var(--red); flex: none; }
.tour-head h3 { font-size: 16px; font-weight: 700; flex: 1; }
.tour-frame iframe { flex: 1; border: 0; width: 100%; }
.maplibregl-popup-content {
    font-family: 'Sofia Sans', sans-serif; border-radius: 0;
    padding: 8px 12px; font-size: 12.5px; font-weight: 700; color: var(--slate);
    box-shadow: var(--shadow);
}
.maplibregl-popup-tip { display: none; }

/* ══ Mobile ══ */
@media (max-width: 900px) {
    :root { --mast-h: 60px; --sector-h: 62px; }
    .masthead { padding: 0 12px; gap: 10px; }
    .brand img { height: 36px; }
    .mast-sep, .mast-title span, .mast-count span { display: none; }
    .mast-title h1 { font-size: 15px; }
    .mast-count b { font-size: 20px; }
    .searchbox { height: 38px; max-width: none; }
    .sector-tab { min-width: 124px; flex: 0 0 auto; }

    .panel {
        top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 78vh;
        border: 0; border-top: 1px solid var(--line);
        transition: transform .3s cubic-bezier(.3,.8,.3,1);
    }
    .panel[data-state="peek"] { transform: translateY(calc(100% - 108px)); }
    .panel[data-state="half"] { transform: translateY(52%); }
    .panel[data-state="full"] { transform: translateY(0); }
    .panel-grip { display: flex; justify-content: center; padding: 9px 0 3px; }
    .panel-grip span { width: 46px; height: 4px; background: #cfd4d6; }

    .detail {
        top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 74vh;
        border: 0; border-top: 1px solid var(--line);
    }
    .legend-chip { left: 12px; bottom: 122px; }
    .legend-pop { left: 12px; bottom: 168px; width: calc(100vw - 24px); }
    .mapctl { bottom: 128px; right: 12px; }
    .mapctl button { width: 40px; height: 40px; }
    .osm-credit { display: none; }
}
