/* Markets page. Colours are CSS variables so a theme can retune them without touching the markup. */
.markets-page {
    --mk-accent: #c0392b;
    --mk-accent-dark: #962d22;
    --mk-ink: #212529;
    --mk-muted: #6c757d;
    --mk-line: #e6e1da;
    --mk-soft: #faf7f2;
    margin-bottom: 2rem;
}

.markets-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .5rem .75rem; margin-bottom: 1rem; }
.markets-header h1 { margin: 0; }
.markets-header .markets-intro { grid-column: 1 / -1; }
.markets-propose { white-space: nowrap; }
@media (max-width: 575px) {
    /* phone: title, intro, then the button */
    .markets-header { grid-template-columns: minmax(0, 1fr); }
    .markets-propose { order: 1; justify-self: start; }
}
.markets-cantons { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--mk-line); font-size: .9rem; color: var(--mk-muted); }
.markets-cantons a { margin-left: .6rem; color: var(--mk-accent); white-space: nowrap; }
.markets-cantons a:hover { color: var(--mk-accent-dark); }

/* propose form (public) */
.markets-form { max-width: 52rem; }
.markets-form .form-group label { font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.markets-form .mk-section { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--mk-muted); margin: 1.6rem 0 .6rem; }
.markets-form-notice { border-radius: .7rem; padding: .8rem 1rem; margin: 1rem 0; background: #fff6e5; border: 1px solid #f3d38a; color: #7a4a00; }
.markets-form-notice.is-error { background: #fdecea; border-color: #f2b6ae; color: #8a1f12; }
.markets-form-notice ul { margin: .4rem 0 0 1.1rem; padding: 0; }
.markets-form-thanks { border-radius: .9rem; padding: 1.5rem; background: #e7f3ec; border: 1px solid #b6dcc4; color: #1f6b43; }
/* required fields get an asterisk; the note under the title explains it */
.markets-form .form-group:has(> [required]) > label::after { content: " *"; color: var(--mk-accent); }
.markets-required-note { font-size: .85rem; color: var(--mk-muted); }
.markets-required-note span { color: var(--mk-accent); }
.markets-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.markets-intro { color: var(--mk-muted); max-width: 46rem; margin: 0; }

/* filters */
.markets-filters {
    display: grid;
    grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr));
    gap: .6rem;
    margin: 1.2rem 0;
}
.markets-filters .form-control { height: 2.75rem; border-radius: .6rem; }

/* list + map */
.markets-layout {
    display: grid;
    grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
    gap: 1.2rem;
    align-items: start;
}
.markets-side { min-width: 0; max-height: 640px; overflow-y: auto; padding-right: .3rem; }
.markets-map-wrap { position: sticky; top: 1rem; }
.markets-map { height: 640px; border-radius: .9rem; border: 1px solid var(--mk-line); z-index: 0; }

/* While swisstopo sends the first tiles the map would be an empty grey box: show a soft background with a
   "loading" line instead. It sits under Leaflet's panes, so the tiles simply cover it once they arrive. */
.markets-map.leaflet-container, .markets-map { background: var(--mk-soft, #faf7f2); }
.markets-map[data-loading]::before {
    content: attr(data-loading);
    position: absolute; inset: 0; z-index: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--mk-muted, #6c757d); font-size: .9rem;
    animation: markets-map-pulse 1.6s ease-in-out infinite;
}
@keyframes markets-map-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .markets-map[data-loading]::before { animation: none; } }

/* list / map switch: phones only, and only once markets.js runs (without it there is no map anyway) */
.markets-view-switch { display: none; }

.markets-count { color: var(--mk-muted); font-size: .88rem; margin-bottom: .6rem; }
.markets-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.markets-empty { color: var(--mk-muted); padding: 1.2rem 0; }

.markets-card { border: 1px solid var(--mk-line); border-radius: .8rem; background: #fff; transition: box-shadow .15s, border-color .15s; }
.markets-card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .08); }
.markets-card.is-selected { border-color: var(--mk-accent); box-shadow: 0 0 0 2px rgba(192, 57, 43, .18); }
.markets-card-btn { all: unset; box-sizing: border-box; display: block; width: 100%; padding: .85rem 1rem; cursor: pointer; }
.markets-card-btn:focus-visible { outline: 2px solid var(--mk-accent); outline-offset: 2px; border-radius: .8rem; }
.markets-card-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .35rem; }
.markets-card-title { font-size: 1.05rem; font-weight: 600; margin: 0 0 .1rem; color: var(--mk-ink); }
.markets-card-place { color: var(--mk-muted); font-size: .9rem; }
.markets-card-when { margin-top: .5rem; font-size: .9rem; color: var(--mk-ink); }
.markets-card-time { color: var(--mk-muted); }

.markets-badge {
    display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
    padding: .18rem .55rem; border-radius: 99px; background: #eee; color: #444;
}
.markets-type-christmas { background: #fde8e6; color: #962d22; }
.markets-type-local { background: #e7f3ec; color: #1f6b43; }
.markets-type-craft { background: #fdf1dc; color: #8a5a00; }
.markets-type-fair { background: #e6eefb; color: #214b8f; }
.markets-type-flea { background: #efe8f7; color: #5a3b87; }
.markets-vendors-pill { font-size: .75rem; color: var(--mk-muted); }

/* detail panel */
.markets-detail { padding: .2rem .2rem 1rem; }
.markets-back { all: unset; cursor: pointer; color: var(--mk-accent); font-weight: 600; font-size: .9rem; display: block; margin-bottom: .8rem; }
.markets-back:hover { text-decoration: underline; }
.markets-detail-title { font-size: 1.5rem; margin: .5rem 0 .3rem; }
.markets-detail-address { color: var(--mk-muted); margin-bottom: .6rem; }
.markets-detail-description { white-space: pre-line; }
.markets-link { color: var(--mk-accent); font-weight: 600; }
.markets-link:hover { color: var(--mk-accent-dark); }
.markets-site { display: inline-block; margin-bottom: .8rem; }

.markets-edition { border-top: 1px solid var(--mk-line); padding: 1rem 0 .3rem; margin-top: .8rem; }
.markets-edition-title { font-size: 1rem; font-weight: 600; margin: 0 0 .3rem; }
.markets-edition-when { font-weight: 600; }
.markets-edition-time { color: var(--mk-muted); margin-bottom: .4rem; }
.markets-edition-label { margin-top: .8rem; font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--mk-muted); }
.markets-edition-notes { color: var(--mk-muted); font-size: .9rem; margin: .3rem 0 0; }
.markets-dates { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .92rem; }

.markets-vendor-list { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.markets-vendor { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .75rem .3rem .3rem; border: 1px solid var(--mk-line); border-radius: 99px; background: var(--mk-soft); color: var(--mk-ink); text-decoration: none; }
.markets-vendor:hover { border-color: var(--mk-accent); color: var(--mk-ink); }
.markets-vendor-img { width: 1.9rem; height: 1.9rem; border-radius: 50%; object-fit: cover; background: #ddd; }
.markets-vendor-initial { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #555; }
.markets-vendor-name { font-size: .9rem; }

/* map pin: a teardrop drawn with CSS, no image files */
.markets-pin { background: none; border: 0; }
.markets-pin span {
    display: block; width: 26px; height: 26px; margin: 2px auto 0;
    background: var(--mk-accent, #c0392b); border: 3px solid #fff; border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg); box-shadow: 0 2px 6px rgba(0, 0, 0, .4); transition: transform .15s;
}
.markets-pin.is-selected span { background: #1d3557; transform: rotate(-45deg) scale(1.2); }

@media (max-width: 991px) {
    .markets-filters { grid-template-columns: 1fr 1fr; }
    .markets-filters .markets-q { grid-column: 1 / -1; }
    .markets-layout { grid-template-columns: 1fr; }
    .markets-map-wrap { position: static; }
    .markets-map { height: 60vh; min-height: 320px; }
    .markets-page.is-ready .markets-view-switch {
        display: inline-flex; margin: 0 0 1rem; padding: .2rem; gap: .2rem;
        border: 1px solid var(--mk-line); border-radius: 999px; background: var(--mk-soft);
    }
    .markets-view-switch button {
        border: 0; background: transparent; color: var(--mk-muted); font-weight: 600; font-size: .9rem;
        min-height: 40px; padding: 0 1.1rem; border-radius: 999px; cursor: pointer;
    }
    .markets-view-switch button[aria-pressed="true"] { background: #fff; color: var(--mk-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
    /* the map only on request (also hides it in the instant before markets.js runs) */
    .markets-page:not([data-view="map"]) .markets-map-wrap { display: none; }
    .markets-page.is-ready[data-view="map"] .markets-side { display: none; }
    .markets-side { max-height: none; overflow: visible; padding-right: 0; }
}

/* page of a single market */
.market-page { max-width: 64rem; }
.market-crumbs { font-size: .85rem; color: var(--mk-muted); margin-bottom: .8rem; }
.market-crumbs a { color: var(--mk-muted); }
.market-crumbs a:hover { color: var(--mk-accent); }
.market-address { color: var(--mk-muted); margin-bottom: .8rem; }
.market-description { white-space: pre-line; max-width: 46rem; }
.market-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; margin-top: 1rem; align-items: start; }
.market-h2 { font-size: 1.15rem; font-weight: 600; margin: 1.2rem 0 .4rem; }
.market-page-map { height: 340px; position: sticky; top: 1rem; }
.market-related { padding-left: 1.1rem; }
.market-back { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--mk-line); }
@media (max-width: 767px) {
    .market-grid { grid-template-columns: 1fr; }
    .market-page-map { position: static; height: 260px; }
}

/* "Where to find me" on the vendor shop page */
.vendor-markets { margin: 1.25rem 0 .5rem; padding: 1rem 1.1rem; border: 1px solid #e6e1da; border-radius: .9rem; background: #faf7f2; }
.vendor-markets-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; margin-bottom: .75rem; }
.vendor-markets-title { font-size: 1.1rem; font-weight: 600; margin: 0; }
.vendor-markets-all { font-size: .9rem; }
.vendor-markets-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; }
.vendor-markets-item { display: flex; flex-direction: column; gap: .1rem; height: 100%; padding: .7rem .85rem; border: 1px solid #e6e1da; border-radius: .7rem; background: #fff; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.vendor-markets-item:hover { color: inherit; text-decoration: none; border-color: #d4c6b4; box-shadow: 0 4px 14px -8px rgba(43, 36, 32, .35); }
.vendor-markets-date { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #c0392b; }
.vendor-markets-name { font-weight: 600; line-height: 1.3; }
.vendor-markets-place { font-size: .85rem; color: #6c757d; }

/* "Meet the makers in person" on the marketplace home (WellmadeHomeMarkets): the next markets as cards.
   Section and title come from the theme (wm-section); date and place reuse the vendor-page styles. */
.home-markets-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.home-markets-item { display: flex; flex-direction: column; gap: .2rem; height: 100%; padding: 1rem 1.125rem; border: 1px solid #e6e1da; border-radius: .9rem; background: #fff; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.home-markets-item:hover { color: inherit; text-decoration: none; border-color: #d4c6b4; box-shadow: 0 4px 14px -8px rgba(43, 36, 32, .35); }
.home-markets-name { font-weight: 600; font-size: 1.05rem; line-height: 1.3; }
.home-markets-makers { align-self: flex-start; margin-top: .4rem; padding: .15rem .6rem; border-radius: 999px; background: #e6efe9; color: #2f4f43; font-size: .8rem; font-weight: 600; }
@media (max-width: 767.98px) {
    .home-markets-list { grid-template-columns: minmax(0, 1fr); gap: .6rem; }
}
