/* Phase 8: marketplace public header and region selector */
:root { --header-height: 104px; --catalog-top: 114px; }
.header-service-row { min-height: 34px; border-bottom: 1px solid var(--border-subtle); background: #f4f7f5; }
.header-service-row__inner { display: flex; min-height: 34px; align-items: center; justify-content: space-between; gap: 16px; }
.header-service-row__note { color: var(--text-secondary); font-size: .7rem; }
.marketplace-header {
    grid-template-areas: "brand catalog search sign-in orders favorites cart";
    grid-template-columns: auto auto minmax(260px,1fr) minmax(68px,auto) minmax(68px,auto) minmax(78px,auto) minmax(68px,auto);
    gap: 7px; min-height: 70px;
}
.marketplace-header > [data-header-item="search"] { grid-area: search; min-width: 0; }
.marketplace-header > [data-header-item="search"] .marketplace-search { width: 100%; }
.header-service-row .region-selector { grid-area: auto; }
.header-service-row svg,.region-selector__panel svg { width:22px; height:22px; flex:0 0 auto; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.header-service-row .region-selector summary { min-width: 0; min-height: 32px; gap: 6px; padding: 2px 7px; border-radius: 8px; }
.header-service-row .region-selector summary > svg:first-child { width: 17px; height: 17px; }
.header-service-row .region-selector__caption { display: none; }
.header-service-row .region-selector summary strong { max-width: 280px; font-size: .73rem; }
.header-auth-entry { position: relative; grid-area: sign-in; min-width: 0; }
.header-auth-entry__trigger,.header-action {
    position: relative; display: grid; min-width: 64px; min-height: 54px; align-content: center; justify-items: center; gap: 2px;
    padding: 4px 6px; border: 1px solid transparent; border-radius: 12px; color: var(--brand-primary);
    background: transparent; box-shadow: none; font-size: .69rem; font-weight: 730; line-height: 1.1; text-decoration: none; white-space: nowrap;
}
.header-auth-entry__trigger:hover,.header-action:hover,.header-auth-entry[data-open="true"] .header-auth-entry__trigger { border-color: var(--border-subtle); color: var(--brand-primary); background: var(--surface-subtle); }
.header-auth-entry__trigger svg,.header-action svg { width: 23px; height: 23px; }
.header-action--orders { grid-area: orders; }
.header-action--favorites { grid-area: favorites; }
.header-action--cart { grid-area: cart; }
.header-action__count { position: absolute; top: 3px; right: 7px; min-width: 17px; padding: 2px 4px; border-radius: 999px; color: #fff; background: var(--status-error); font-size: .58rem; line-height: 1.2; text-align: center; }
.header-auth-entry__menu {
    position: absolute; z-index: 90; top: calc(100% + 7px); right: -96px; width: 310px; padding: 12px;
    visibility: hidden; opacity: 0; transform: translateY(-4px); pointer-events: none;
    border: 1px solid var(--border-subtle); border-radius: 16px; background: #fff; box-shadow: var(--shadow-overlay);
    transition: opacity .14s ease,transform .14s ease,visibility .14s;
}
.header-auth-entry:hover .header-auth-entry__menu,.header-auth-entry:focus-within .header-auth-entry__menu,.header-auth-entry[data-open="true"] .header-auth-entry__menu { visibility: visible; opacity: 1; transform: none; pointer-events: auto; }
.header-auth-entry__menu::before { content:""; position:absolute; inset:-9px 0 auto; height:10px; }
.header-auth-entry__menu > p { display:grid; margin:0 0 7px; padding:5px 7px 9px; border-bottom:1px solid var(--border-subtle); }
.header-auth-entry__menu > p span { color:var(--text-secondary); font-size:.72rem; }
.header-auth-entry__menu > a { display:grid; grid-template-columns:38px 1fr; min-height:62px; align-items:center; gap:9px; padding:8px; border-radius:11px; color:var(--text-primary); text-decoration:none; }
.header-auth-entry__menu > a:hover,.header-auth-entry__menu > a:focus-visible { background:var(--surface-subtle); }
.header-auth-entry__menu > a > svg { width:23px; height:23px; justify-self:center; color:var(--brand-secondary); }
.header-auth-entry__menu > a span { display:grid; }
.header-auth-entry__menu small { color:var(--text-secondary); font-size:.68rem; font-weight:500; }
.catalog-dialog { inset: var(--catalog-top) 0 auto; max-height: calc(100dvh - var(--catalog-top) - 16px); }
.region-selector__panel { top:calc(100% + 6px); right:auto; left:0; width:min(430px,calc(100vw - 24px)); padding:0; overflow:hidden; }
.region-selector__head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:18px 18px 13px; color:#fff; background:var(--brand-primary); }
.region-selector__head h2 { color:#fff; font-size:1.35rem; }
.region-selector__eyebrow { margin:0 0 2px!important; color:#f1c98c!important; font-size:.65rem!important; font-weight:780; letter-spacing:.1em; text-transform:uppercase; }
.region-selector__close { width:44px; min-width:44px; min-height:44px; padding:0; border-color:rgb(255 255 255/.25); background:rgb(255 255 255/.1); }
.region-selector__current { display:flex; justify-content:space-between; gap:10px; margin:0!important; padding:11px 18px; border-bottom:1px solid var(--border-subtle); font-size:.75rem!important; }
.region-selector__current span { color:var(--text-secondary); }
.region-selector__form { display:grid; gap:8px; padding:14px 18px 8px; }
.region-search-control { position:relative; }
.region-search-control > svg { position:absolute; top:12px; left:12px; width:20px; height:20px; color:var(--text-muted); pointer-events:none; }
.region-search-control input { padding-left:40px; }
.region-search-results { max-height:216px; overflow:auto; border:1px solid var(--border-default); border-radius:10px; background:#fff; box-shadow:var(--shadow-control); }
.region-search-results button { display:grid; width:100%; min-height:50px; justify-content:stretch; gap:0; padding:7px 11px; border:0; border-radius:0; color:var(--text-primary); background:#fff; box-shadow:none; text-align:left; }
.region-search-results button+button { border-top:1px solid var(--border-subtle); }
.region-search-results button:hover,.region-search-results button:focus-visible { color:var(--text-primary); background:var(--surface-subtle); }
.region-search-results small { color:var(--text-secondary); font-size:.68rem; }
.region-search-results p { padding:12px; }
.region-selector__selection { margin:0!important; font-size:.72rem!important; }
.region-popular { padding:7px 18px 11px; }
.region-popular > p { margin:0 0 6px!important; font-weight:720; }
.region-popular > div { display:flex; flex-wrap:wrap; gap:6px; }
.region-chip { min-height:36px; padding:6px 9px; border-color:var(--border-default); color:var(--brand-primary); background:#fff; box-shadow:none; font-size:.71rem; }
.region-chip:hover { color:var(--brand-primary); background:var(--surface-subtle); }
.region-selector__modes { display:flex; gap:4px; padding:4px 12px; border-top:1px solid var(--border-subtle); }
.region-selector__modes form { flex:1; }
.region-selector__modes button { width:100%; min-height:40px; padding:6px; font-size:.71rem; }
.region-selector__privacy { margin:0!important; padding:8px 18px 13px; background:#f7f8f6; font-size:.64rem!important; line-height:1.35; }
.region-selector__privacy a { display:inline-flex; min-height:44px; align-items:center; white-space:nowrap; }
.favorite-toggle-form { position:absolute; z-index:4; top:8px; right:8px; margin:0; }
.favorite-toggle { position:absolute; z-index:4; top:8px; right:8px; display:inline-flex; width:44px; height:44px; min-height:44px; align-items:center; justify-content:center; padding:0; border:1px solid rgb(23 63 53/.12); border-radius:50%; color:var(--brand-primary); background:rgb(255 255 255/.94); box-shadow:var(--shadow-control); text-decoration:none; }
.favorite-toggle-form .favorite-toggle { position:static; }
.favorite-toggle:hover { color:var(--status-error); background:#fff; }
.favorite-toggle.is-active { border-color:#e7b6b2; color:var(--status-error); background:#fff5f4; }
.favorite-toggle.is-active svg { fill:currentColor; }
.favorite-toggle svg { width:21px!important; height:21px!important; }
.market-product-card { position:relative; }
.market-product-card__link { position:relative; z-index:1; }
@media(max-width:1199px){
 .brand__word{display:none}.marketplace-header{grid-template-columns:auto auto minmax(220px,1fr) repeat(4,minmax(61px,auto));}
 .header-auth-entry__trigger,.header-action{min-width:58px;padding-inline:3px}
}
@media(max-width:899px){
 :root{--header-height:156px}
 .marketplace-header{grid-template-areas:"brand catalog search search" "sign-in orders favorites cart";grid-template-columns:auto auto minmax(0,1fr) minmax(64px,auto);grid-template-rows:54px 50px;gap:6px 8px;min-height:122px;padding:7px 0}
 .brand__word{display:inline}.header-auth-entry__trigger,.header-action{min-height:48px}
 .catalog-dialog{inset:var(--catalog-top) 0 auto;max-height:calc(100dvh - var(--catalog-top) - 8px)}
}
@media(max-width:640px){
 :root{--header-height:190px}
 .header-service-row,.header-service-row__inner{min-height:44px}
 .header-service-row__note{display:none}.header-service-row__inner{justify-content:flex-start}
 .header-service-row .region-selector summary{min-height:44px}
 .header-service-row .region-selector{max-width:100%;justify-self:start}
 .header-service-row .region-selector summary strong{max-width:235px;font-size:.69rem}
 .marketplace-header{grid-template-areas:"brand brand brand catalog" "search search search search" "sign-in orders favorites cart";grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:44px 48px 48px;min-height:146px;padding:6px 0}
 .brand{grid-column:1/4}.catalog-trigger{grid-column:4;width:46px;min-width:46px;min-height:44px;padding:0}.catalog-trigger__text{display:none}
 .marketplace-search{height:48px}.marketplace-search{grid-template-columns:minmax(0,1fr) auto}.marketplace-search__leading{display:none}
 .marketplace-search input{min-height:44px;padding-inline:11px 5px;font-size:.84rem}.marketplace-search button{min-width:48px;min-height:44px;padding:0 9px}.search-button__text{display:none}.search-button__icon{display:block}
 .header-auth-entry__trigger,.header-action{width:100%;min-width:0;min-height:48px;padding:2px;font-size:.59rem}.header-auth-entry__trigger svg,.header-action svg{width:21px;height:21px}
 .header-auth-entry__menu{position:fixed;top:auto;right:10px;bottom:calc(10px + env(safe-area-inset-bottom));left:10px;width:auto}
 .region-chip{min-height:44px}
 .region-selector__panel{position:fixed;z-index:100;top:calc(8px + env(safe-area-inset-top));right:10px;bottom:8px;left:10px;width:auto;max-height:calc(100dvh - 16px - env(safe-area-inset-top));overflow:auto}
 .catalog-dialog{inset:0 0 0 auto;width:100%;height:100dvh;max-height:none}
 #regional-feed-title{scroll-margin-top:204px}
}
@media(max-width:350px){.brand{font-size:.88rem}.brand__mark{width:24px!important;height:24px!important}.header-service-row .region-selector summary strong{max-width:205px}}
@media(prefers-reduced-motion:reduce){.header-auth-entry__menu{transition:none}}
