/* Media feature — section nav, photo gallery + lightbox, PDF cards, products,
 * location map, and the owner media/products managers. Uses the palette tokens
 * from public.css / account.css, so light & dark themes come for free. */

/* ---- Section nav (Overview / Photos / …) ---- */
.sec-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
  margin: 1rem 0 1.5rem; padding: .35rem 0;
  border-bottom: 1px solid var(--hairline, #d3dcde);
  position: sticky; top: 0; z-index: 5;
  background: var(--ground, #e9eef0);
}
.sec-nav a {
  padding: .4rem .8rem; border-radius: 999px; font-size: .9rem; font-weight: 600;
  color: var(--ink-soft, #4a5f66); text-decoration: none;
  border: 1px solid transparent;
}
.sec-nav a:hover { color: var(--ink, #12303a); background: var(--surface-2, #f2f5f6); }

/* The page is now wide (for photos/products/map); keep prose readable. */
#overview .desc, #overview .facts { max-width: 70ch; }

.detail-sec { scroll-margin-top: 4rem; margin: 1.75rem 0; }
.detail-sec > h2 {
  font-size: 1.15rem; margin: 0 0 .9rem; color: var(--navy, #0d2b36);
  padding-bottom: .35rem; border-bottom: 2px solid var(--hairline-2, #c2ced1);
}

/* ---- Photo gallery ---- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.gallery__item {
  display: block; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 10px;
  background: var(--surface-2, #f2f5f6); border: 1px solid var(--hairline, #d3dcde);
}
.gallery__item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.gallery__item:hover img { transform: scale(1.05); }

/* ---- Lightbox ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 2000; display: none;
  align-items: center; justify-content: center;
  background: rgba(4, 16, 20, .92); padding: 2rem;
}
.lightbox.is-open { display: flex; }
.lightbox__fig { margin: 0; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.lightbox__img { max-width: 92vw; max-height: 80vh; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lightbox__cap { color: #eef3f4; font-size: .95rem; text-align: center; max-width: 60ch; }
.lightbox__close, .lightbox__nav {
  position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0;
  width: 46px; height: 46px; border-radius: 50%; font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.lightbox__close:hover, .lightbox__nav:hover { background: rgba(255,255,255,.25); }
.lightbox__close { top: 1rem; right: 1rem; }
.lightbox__prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox__next { right: 1rem; top: 50%; transform: translateY(-50%); }
body.lightbox-open { overflow: hidden; }

/* ---- PDF documents ---- */
.docs { display: grid; gap: .8rem; }
.doc-card { border: 1px solid var(--hairline, #d3dcde); border-radius: 12px; background: var(--surface, #fff); padding: .9rem 1rem; }
.doc-card__head { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.doc-ico { font-size: 1.2rem; }
.doc-card__name { font-weight: 700; color: var(--ink, #12303a); }
.doc-card__meta { color: var(--ink-soft, #4a5f66); font-size: .82rem; }
.doc-card__acts { display: flex; gap: .5rem; margin: .6rem 0 .2rem; flex-wrap: wrap; }
.doc-card__prev { margin-top: .4rem; }
.doc-card__prev > summary { cursor: pointer; color: var(--red-ink, #b3202b); font-weight: 600; font-size: .9rem; }
.pdf-frame { width: 100%; height: 600px; border: 1px solid var(--hairline, #d3dcde); border-radius: 8px; margin-top: .6rem; background: #fff; }

.btn-ghost {
  display: inline-block; padding: .4rem .8rem; border-radius: 8px; font-size: .85rem; font-weight: 600;
  text-decoration: none; color: var(--navy, #0d2b36); border: 1px solid var(--hairline-2, #c2ced1); background: var(--surface, #fff);
}
.btn-ghost:hover { border-color: var(--navy, #0d2b36); }

/* ---- Products & services (public) ---- */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.prod-card { border: 1px solid var(--hairline, #d3dcde); border-radius: 12px; background: var(--surface, #fff); overflow: hidden; display: flex; flex-direction: column; }
.prod-card__img { aspect-ratio: 16 / 10; background: var(--surface-2, #f2f5f6); }
.prod-card__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prod-card__body { padding: .8rem .9rem; }
.prod-card__top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.prod-card__top h3 { margin: 0; font-size: 1rem; color: var(--navy, #0d2b36); }
.prod-card__price { font-weight: 700; color: var(--gold, #b9862f); white-space: nowrap; }
.prod-card__desc { margin: .45rem 0 0; font-size: .9rem; color: var(--ink-soft, #4a5f66); }

/* ---- Map ---- */
.map { height: 340px; width: 100%; border-radius: 12px; overflow: hidden; border: 1px solid var(--hairline, #d3dcde); position: relative; z-index: 0; background: var(--surface-2, #f2f5f6); }
.map--edit { height: 300px; }
.map--full { position: fixed !important; inset: 0; width: 100vw; height: 100vh; border-radius: 0; z-index: 3000; }
body.map-full-open { overflow: hidden; }
.map-expand {
  position: absolute; top: 10px; right: 10px; z-index: 1000;
  background: var(--surface, #fff); color: var(--ink, #12303a); border: 1px solid var(--hairline-2, #c2ced1);
  border-radius: 8px; padding: .35rem .6rem; font-size: .8rem; font-weight: 600; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.map-expand:hover { border-color: var(--navy, #0d2b36); }
.map-addr { color: var(--ink-soft, #4a5f66); margin: 0 0 .6rem; }
.map-link { margin: .55rem 0 0; font-size: .85rem; }
.map-pin__dot {
  display: block; width: 20px; height: 20px; border-radius: 50%;
  background: var(--red, #b3202b); border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.4);
}

/* ---- Owner managers (account edit pages) ---- */
.mm-badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; vertical-align: middle; }
.mm-badge--on   { background: rgba(47,125,91,.15); color: var(--good, #2f7d5b); }
.mm-badge--wait { background: rgba(185,134,47,.18); color: var(--gold, #b9862f); }
.mm-badge--no   { background: rgba(179,32,43,.14); color: var(--red-ink, #b3202b); }
.media-note { font-size: .8rem; color: var(--red-ink, #b3202b); margin: .3rem 0 0; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.media-item { border: 1px solid var(--hairline, #d3dcde); border-radius: 10px; padding: .5rem; background: var(--surface, #fff); }
.media-thumb { position: relative; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: var(--surface-2, #f2f5f6); }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb .mm-badge { position: absolute; left: 5px; top: 5px; background: rgba(0,0,0,.6); color: #fff; }
.media-caption { display: flex; gap: .3rem; margin-top: .45rem; }
.media-caption input { flex: 1; min-width: 0; }
.media-ctl { display: flex; gap: .35rem; margin-top: .35rem; align-items: center; }
.media-ctl .inline { display: inline; }

.btn-text { background: none; border: 0; color: var(--navy, #0d2b36); font-weight: 600; cursor: pointer; padding: .25rem .4rem; font-size: .85rem; border-radius: 6px; }
.btn-text:hover { background: var(--surface-2, #f2f5f6); }
.btn-text:disabled { opacity: .35; cursor: default; }
.btn-text--danger { color: var(--red-ink, #b3202b); }

.media-upload { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .5rem; }
.media-upload input[type=file] { flex: 1; min-width: 200px; }

.doc-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; }
.doc-row { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border: 1px solid var(--hairline, #d3dcde); border-radius: 10px; background: var(--surface, #fff); }
.doc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.doc-meta { font-size: .78rem; color: var(--ink-soft, #4a5f66); display: flex; gap: .4rem; align-items: center; }

.prod-edit { border: 1px solid var(--hairline, #d3dcde); border-radius: 12px; padding: .9rem 1rem; margin-bottom: 1rem; background: var(--surface, #fff); }
.prod-edit__head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.prod-edit__n { font-weight: 700; color: var(--ink-soft, #4a5f66); }
.prod-edit__ctl { margin-left: auto; display: flex; gap: .3rem; }
.prod-photo { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--hairline, #d3dcde); }
.prod-photo select { max-width: 60%; }
.prod-add { margin-top: .5rem; padding-top: 1rem; border-top: 1px dashed var(--hairline, #d3dcde); }

/* Leaflet attribution: keep it legible on both themes (map tiles are always light). */
.leaflet-container .leaflet-control-attribution { background: rgba(255,255,255,.8); color: #333; }
.leaflet-container .leaflet-control-attribution a { color: #0d2b36; }

@media (max-width: 560px) {
  .pdf-frame { height: 420px; }
  .map { height: 260px; }
}

/* ---- Island-wide directory map (/map) ---- */
.dirmap-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.dirmap-count { color: var(--ink-soft, #4a5f66); font-size: .9rem; }
.dirmap-filters { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.dirmap-filters button {
  padding: .35rem .75rem; border-radius: 999px; font-size: .85rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--hairline-2, #c2ced1); background: var(--surface, #fff); color: var(--ink-soft, #4a5f66);
}
.dirmap-filters button:hover { border-color: var(--navy, #0d2b36); color: var(--ink, #12303a); }
.dirmap-filters button[aria-pressed="true"] { background: var(--navy, #0d2b36); border-color: var(--navy, #0d2b36); color: #fff; }
/* In dark mode --navy is a LIGHT colour, so the pressed chip needs dark text.
   These overrides must stay scoped to dark mode (the media query / data-theme),
   otherwise they wrongly darken the text in light mode too. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dirmap-filters button[aria-pressed="true"] { color: #0b1f26; }
}
:root[data-theme="dark"] .dirmap-filters button[aria-pressed="true"] { color: #0b1f26; }

.dirmap { height: 70vh; min-height: 420px; width: 100%; border-radius: 14px; overflow: hidden; border: 1px solid var(--hairline, #d3dcde); background: var(--surface-2, #f2f5f6); position: relative; z-index: 0; }
.dirmap-empty { text-align: center; color: var(--ink-soft, #4a5f66); padding: 2rem; }

/* Toolbar "switch to the other view" button (map ⇆ directory) */
.toolbar__switch { padding: 12px 18px; border-radius: 11px; font-size: 15px; font-weight: 700; flex: 0 0 auto; }

/* Category colour legend (static) */
.dirmap-legend { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; margin: 0 0 1rem; font-size: .82rem; color: var(--ink-soft, #4a5f66); }
.dm-leg { display: inline-flex; align-items: center; gap: .4rem; }

/* Map + preview-panel layout (panel only on wide screens; popup used otherwise) */
.dirmap-wrap { display: flex; gap: 1rem; align-items: stretch; }
.dirmap-wrap .dirmap { flex: 1 1 auto; min-width: 0; }
.dirmap-panel { display: none; }
@media (min-width: 900px) {
  .dirmap-panel {
    display: block; flex: 0 0 340px; width: 340px; align-self: stretch;
    border: 1px solid var(--hairline, #d3dcde); border-radius: 14px; background: var(--surface, #fff);
    overflow: auto; max-height: 70vh; min-height: 420px; position: relative;
  }
}
.dirmap-panel__empty { color: var(--ink-soft, #4a5f66); padding: 2.5rem 1.2rem; text-align: center; }
.dirmap-panel__close { position: absolute; top: .5rem; right: .5rem; z-index: 2; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--hairline-2, #c2ced1); background: var(--surface, #fff); color: var(--ink, #12303a); font-size: 1.15rem; line-height: 1; cursor: pointer; }
.dirmap-panel__photo { aspect-ratio: 16 / 10; background: var(--surface-2, #f2f5f6); border-radius: 14px 14px 0 0; overflow: hidden; }
.dirmap-panel__photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dirmap-panel__body { padding: 1rem 1.1rem 1.3rem; }
.dirmap-panel__name { margin: 0; font-size: 1.15rem; color: var(--navy, #0d2b36); }
.dirmap-panel__meta { color: var(--ink-soft, #4a5f66); font-size: .85rem; margin: .2rem 0 .7rem; }
.dirmap-panel__desc { color: var(--ink, #12303a); font-size: .92rem; margin: 0 0 .85rem; }
.dirmap-panel__facts { list-style: none; margin: 0 0 .85rem; padding: 0; display: grid; gap: .45rem; font-size: .88rem; }
.dirmap-panel__facts li { display: grid; grid-template-columns: 70px 1fr; gap: .4rem; }
.dirmap-panel__facts span { color: var(--stone, #5c6b70); }
.dirmap-panel__when { color: var(--navy, #0d2b36); font-weight: 600; font-size: .9rem; margin: 0 0 .7rem; }
.dirmap-panel__tags { font-size: .82rem; color: var(--ink-soft, #4a5f66); margin-bottom: 1rem; }
.dirmap-panel__cta { display: inline-block; }

/* "Recently viewed" strip (under the map): a horizontally-scrolling row of chips
   the visitor can tap to return to a listing or event they just opened. Driven by
   the `recent_listings` cookie; no JS. */
.recent { margin: 1.6rem 0 .4rem; }
.recent__h { font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; color: var(--stone, #5c6b70); margin: 0 0 .6rem; }
.recent__list { list-style: none; margin: 0; padding: 0 0 .3rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.recent__link {
  display: inline-flex; align-items: center; gap: .45rem; max-width: 260px;
  padding: .45rem .75rem; border: 1px solid var(--hairline, #d3dcde); border-radius: 999px;
  background: var(--surface, #fff); color: var(--ink, #12303a); text-decoration: none; font-size: .88rem;
}
.recent__link:hover { border-color: var(--pin, #b3202b); }
.recent__item--event .recent__link:hover { border-color: #d946ef; }
.recent__badge { flex: none; font-size: .95rem; line-height: 1; }
.recent__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Pin popups */
.leaflet-popup-content { margin: .7rem .9rem; }
.map-pop__name { font-weight: 700; color: var(--navy, #0d2b36); font-size: 1rem; }
.map-pop__meta { color: var(--ink-soft, #4a5f66); font-size: .82rem; margin: .15rem 0 .5rem; }
.map-pop__link { font-weight: 600; }
/* Category pins: a round badge with a glyph; colour per category via --pin.
   (CSP forbids inline style, so colour is carried by the .dm-cat-* class.) */
.dm-pin-wrap { background: transparent; border: 0; }
.dm-pin {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: #fff; border: 3px solid var(--pin, #b3202b);
  box-shadow: 0 1px 5px rgba(0,0,0,.4); font-size: 15px; line-height: 1;
}

/* Filter chip swatch */
.dm-chip { display: inline-flex; align-items: center; gap: .4rem; }
.dm-sw { width: 12px; height: 12px; border-radius: 50%; background: var(--pin, #b3202b); flex: none; }

/* Category colours — shared by pins and chip swatches (keys = business_type_slug()) */
.dm-cat-hotel         { --pin: #2f7d5b; }
.dm-cat-self-catering { --pin: #2f80d8; }
.dm-cat-restaurant    { --pin: #b3202b; }
.dm-cat-pub           { --pin: #b9862f; }
.dm-cat-retail        { --pin: #8e44ad; }
.dm-cat-attraction    { --pin: #e67e22; }
.dm-cat-tours         { --pin: #16a085; }
.dm-cat-health        { --pin: #d6336c; }
.dm-cat-professional  { --pin: #34495e; }
.dm-cat-trades        { --pin: #6b7a8f; }
.dm-cat-arts          { --pin: #6c5ce7; }
.dm-cat-other         { --pin: #5c6b70; }
.dm-cat-event         { --pin: #d946ef; }

/* ---- Split display template (display_template = 2) ---- */
.detail-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6rem; align-items: start; }
.detail-split__main { min-width: 0; }
.feature-panel { display: flex; flex-direction: column; gap: .8rem; position: sticky; top: 1rem; }
.feature-panel__item { display: block; position: relative; border-radius: 12px; overflow: hidden; text-decoration: none; border: 1px solid var(--hairline, #d3dcde); }
.feature-panel__item img { width: 100%; height: auto; display: block; }
.feature-panel__cap { position: absolute; left: 0; right: 0; bottom: 0; padding: .55rem .7rem; font-size: .85rem; line-height: 1.3; color: #fff; background: linear-gradient(transparent, rgba(8, 25, 31, .72)); }
@media (max-width: 760px) {
  .detail-split { grid-template-columns: 1fr; }
  .feature-panel { position: static; }
}

/* ---- Media manager: featured star + display-template chooser ---- */
.media-thumb.is-featured { outline: 2px solid var(--gold, #b9862f); outline-offset: 2px; }
.mm-star { position: absolute; left: 6px; bottom: 6px; z-index: 2; font-size: 11px; font-weight: 800; color: #fff; background: var(--gold, #b9862f); padding: 2px 7px; border-radius: 999px; }
.tmpl-choice { border: 1px solid var(--hairline, #d3dcde); border-radius: 12px; padding: .7rem 1rem 1rem; margin: 1.1rem 0; }
.tmpl-choice legend { font-weight: 700; padding: 0 .4rem; }
.tmpl-opt { display: flex; gap: .6rem; align-items: flex-start; padding: .4rem 0; cursor: pointer; }
/* Override the form stylesheet (which makes every input a full-width box). */
.tmpl-opt input[type="radio"] {
  width: 1.15rem; height: 1.15rem; min-width: 0; min-height: 0; flex: 0 0 auto;
  margin: .15rem 0 0; padding: 0; border: 0; background: none; box-shadow: none;
  appearance: auto; -webkit-appearance: radio;
}
.tmpl-opt > span { flex: 1 1 auto; min-width: 0; }

/* ---- Window-sticker panel (owner edit forms) ---- */
.sticker-line { display: flex; align-items: baseline; gap: .6rem; margin: .4rem 0; flex-wrap: wrap; }
.sticker-key { min-width: 3rem; font-weight: 700; color: var(--ink-soft, #4a5f66); }
.sticker-code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1.3rem; font-weight: 800; letter-spacing: .18em;
  padding: .1rem .55rem; border-radius: .4rem;
  background: var(--surface-2, #f2f5f6); color: var(--navy, #0d2b36);
}
.sticker-url { word-break: break-all; }

/* ---- Events on a business page ---- */
.ev-list { list-style: none; margin: 0 0 .4rem; padding: 0; display: grid; gap: .5rem; }
.ev-item__link {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem 1rem;
  padding: .7rem .9rem; border: 1px solid var(--hairline, #d3dcde); border-radius: 10px;
  background: var(--surface, #fff); text-decoration: none;
}
.ev-item__link:hover { border-color: var(--navy, #0d2b36); }
.ev-item__title { font-weight: 700; color: var(--navy, #0d2b36); }
.ev-item__when { color: var(--ink-soft, #4a5f66); font-size: .9rem; margin-left: auto; }
.ev-prev { margin-top: .6rem; }
.ev-prev > summary { cursor: pointer; color: var(--navy, #0d2b36); font-weight: 600; font-size: .92rem; padding: .2rem 0; }
.ev-list--prev { margin-top: .6rem; }
.ev-list--prev .ev-item__title { font-weight: 600; color: var(--ink-soft, #4a5f66); }

/* ---- Social share row ---- */
.share { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 1.1rem 0 .2rem; }
.share__label { font-weight: 700; color: var(--ink-soft, #4a5f66); font-size: .9rem; margin-right: .1rem; }
.share__btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  border: 1px solid var(--hairline, #d3dcde); background: var(--surface, #fff);
  color: var(--ink, #12303a); cursor: pointer; text-decoration: none;
}
.share__btn:hover { border-color: var(--navy, #0d2b36); color: var(--navy, #0d2b36); }
.share__btn svg { width: 18px; height: 18px; fill: currentColor; }
.share-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(12px);
  background: var(--navy, #0d2b36); color: #fff; padding: .6rem 1rem; border-radius: 10px;
  font-size: .9rem; opacity: 0; pointer-events: none; z-index: 4000;
  transition: opacity .2s ease, transform .2s ease;
}
.share-toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.share-copytmp { position: absolute; left: -9999px; top: 0; }
