/* ============================================================
   YP LOCAL DIRECTORY — style.css
   Mobile-first. Breakpoints: 600px (tablet), 900px (desktop)
   ============================================================ */

/* ─────────────────────────────────────────
   CSS Custom Properties
───────────────────────────────────────── */
:root {
  --dark:          #1c2b1c;
  --dark-mid:      #2e422e;
  --yellow:        #f0d800;
  --yellow-hover:  #ffe000;
  --green-light:   #a8c890;
  --water:         #1a4a6a;

  --bg:            #ffffff;
  --bg-alt:        #f5f2ee;
  --bg-cat:        #f0d800;
  --bg-rail:       #f0ede8;
  --bg-highlight:  #fffbe8;

  --text:          #1c1c1c;
  --text-mid:      #444;
  --text-muted:    #777;
  --text-link:     #185aa0;

  --border:        #e0ddd8;
  --border-mid:    #c0bdb8;

  --header-h:      48px;
  --search-h:      76px;
  --rail-w:        28px;
  --splash-bdr:    10px;

  --radius-sm:     2px;
  --radius-md:     4px;
  --font-serif:    Georgia, 'Times New Roman', serif;
  --font-sans:     -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}


/* ─────────────────────────────────────────
   Base Reset
───────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.4;
  background: var(--dark);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--text-link);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}


/* ═══════════════════════════════════════════
   SPLASH SCREEN
═══════════════════════════════════════════ */
.splash {
  position: fixed;
  inset: 0;
  background: var(--dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.splash.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.97);
}

.splash-border {
  width: min(320px, 90vw);
  border: var(--splash-bdr) solid var(--yellow);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.splash-content {
  background: var(--dark);
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.splash-header {
  text-align: center;
}

.splash-logo {
  font-family: var(--font-serif);
  font-size: 72px;
  font-weight: 700;
  color: var(--yellow);
  line-height: 1;
  letter-spacing: -3px;
}

.splash-tagline {
  font-size: 10px;
  color: var(--green-light);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 4px;
}

.splash-map {
  width: 100%;
  max-width: 220px;
}

.splash-map svg {
  width: 100%;
  height: auto;
  display: block;
}

.splash-footer {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.splash-region {
  font-size: 10px;
  color: var(--green-light);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.splash-cta {
  background: var(--yellow);
  color: var(--dark);
  border: none;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 11px 32px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  width: 100%;
  max-width: 200px;
  -webkit-tap-highlight-color: transparent;
}

.splash-cta:hover,
.splash-cta:focus {
  background: var(--yellow-hover);
  outline: none;
}


/* ═══════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════ */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.app.visible {
  opacity: 1;
  pointer-events: auto;
}


/* ─────────────────────────────────────────
   APP HEADER
───────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  min-height: var(--header-h);
  background: var(--dark);
  border-bottom: 2px solid var(--yellow);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 10;
}

.header-home {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--yellow);
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
  letter-spacing: -1px;
  -webkit-tap-highlight-color: transparent;
}

.header-home:hover,
.header-home:focus {
  color: var(--yellow-hover);
  outline: none;
}

.header-region {
  font-size: 10px;
  color: var(--green-light);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-left: auto;
}


/* ─────────────────────────────────────────
   SEARCH BAR
───────────────────────────────────────── */
.search-bar {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px 8px;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

.search-toggle {
  display: flex;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: fit-content;
  margin-bottom: 7px;
}

.toggle-btn {
  background: var(--bg);
  border: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 14px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.toggle-btn.active {
  background: var(--dark);
  color: var(--yellow);
}

.search-input-wrap {
  position: relative;
}

.search-input {
  display: block;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  -webkit-appearance: none;
  appearance: none;
}

.search-input:focus {
  outline: none;
  border-color: var(--dark);
}

/* Autocomplete dropdown */
.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% - 8px);
  left: 10px;
  right: 10px;
  background: var(--bg);
  border: 1px solid var(--border-mid);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 6px 16px rgba(0,0,0,0.10);
}

.search-dropdown.open {
  display: block;
}

.search-dropdown li {
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 0.5px solid var(--border);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.search-dropdown li:last-child {
  border-bottom: none;
}

.search-dropdown li:hover,
.search-dropdown li.focused {
  background: var(--bg-highlight);
}

.search-dropdown-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}


/* ─────────────────────────────────────────
   DIRECTORY LAYOUT (mobile default)
───────────────────────────────────────── */
.directory-layout {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* Listings panel */
.listings-panel {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 8px 60px;
  min-width: 0;
}

/* Alpha rail — right edge */
.alpha-rail {
  width: var(--rail-w);
  flex-shrink: 0;
  background: var(--bg-rail);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
  scrollbar-width: none;
}

.alpha-rail::-webkit-scrollbar {
  display: none;
}

.alpha-tab {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 700;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.alpha-tab.has-content {
  color: var(--dark);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.alpha-tab.has-content:hover,
.alpha-tab.has-content:focus {
  background: var(--yellow);
  color: var(--dark);
  outline: none;
}

.alpha-tab.active {
  background: var(--yellow);
  color: var(--dark);
}

.alpha-tab.no-content {
  color: var(--border-mid);
  font-size: 9px;
  cursor: default;
}


/* ─────────────────────────────────────────
   CATEGORY HEADER
───────────────────────────────────────── */
.category-header {
  position: sticky;
  top: 0;
  z-index: 5;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  background: var(--bg-cat);
  border-left: 4px solid var(--dark);
  padding: 5px 8px;
  margin: 10px -8px 4px;
  letter-spacing: 0.01em;
  text-transform: capitalize;
}


/* ─────────────────────────────────────────
   BUSINESS LISTINGS
───────────────────────────────────────── */
.business-listing {
  padding: 8px 4px 8px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}

.business-listing:hover,
.business-listing:focus-within {
  background: var(--bg-highlight);
}

.business-listing:focus {
  background: var(--bg-highlight);
  outline: none;
}

.biz-name {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.biz-addr {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.biz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  gap: 8px;
}

.biz-website {
  font-size: 11px;
  color: var(--text-link);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
}

.biz-website:hover {
  text-decoration: underline;
}

.biz-phone {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Promoted listing — paid placement (full width always) */
.business-listing.promoted {
  border: 1.5px solid var(--yellow);
  border-radius: var(--radius-md);
  padding: 10px 10px;
  margin: 6px 0;
  background: #fffdf0;
}

.business-listing.promoted .biz-name {
  font-size: 15px;
}

/* Promoted spans both columns on tablet+ */
.business-listing.promoted-half {
  grid-column: 1 / -1;
}


/* ═══════════════════════════════════════════
   MAP MODAL — mobile (fixed overlay, slides up)
═══════════════════════════════════════════ */
.map-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.map-modal.open {
  pointer-events: auto;
}

.map-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0);
  transition: background 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.map-modal.open .map-modal-backdrop {
  background: rgba(0,0,0,0.45);
}

.map-modal-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.36s cubic-bezier(0.32,0.72,0,1);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.map-modal.open .map-modal-sheet {
  transform: translateY(0);
}

.map-modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border-mid);
  border-radius: 2px;
  margin: 10px auto 6px;
  flex-shrink: 0;
}

.google-map {
  width: 100%;
  height: 220px;
  flex-shrink: 0;
  background: #c8dfc8;
}

.map-modal-info {
  padding: 12px 16px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.map-biz-name {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.map-biz-addr {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.map-biz-phone {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
}

.map-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.map-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  border: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}

.map-action-btn:hover,
.map-action-btn:focus {
  opacity: 0.88;
  outline: none;
}

.map-btn-dir {
  background: var(--dark);
  color: var(--yellow);
  flex: 1.2;
}

.map-btn-web {
  background: var(--bg);
  color: var(--dark);
  border: 1.5px solid var(--dark) !important;
  flex: 1.2;
}

.map-btn-close {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border-mid) !important;
  flex: 0.7;
}


/* ═══════════════════════════════════════════
   RESPONSIVE — TABLET (600px+)
═══════════════════════════════════════════ */
@media (min-width: 600px) {

  :root {
    --rail-w: 34px;
  }

  /* CSS columns give top-to-bottom fill order — exactly like a printed directory.
     grid-template-columns fills left-to-right (wrong). column-count fills
     top-to-bottom in col 1 then spills into col 2 (correct). */
  .listings-panel {
    padding: 0 12px 60px;
    column-count: 2;
    column-gap: 16px;
    column-fill: balance;
  }

  /* Headers must span both columns to act as section breaks */
  .category-header {
    column-span: all;
    margin: 14px -12px 4px;
    font-size: 15px;
  }

  /* Prevent listings from breaking across columns mid-card */
  .business-listing {
    break-inside: avoid;
    page-break-inside: avoid; /* Safari fallback */
  }

  /* Promoted spans both columns */
  .business-listing.promoted-half {
    column-span: all;
  }

  .alpha-tab {
    width: 28px;
    height: 24px;
    font-size: 12px;
  }

  .google-map {
    height: 280px;
  }

  .splash-border {
    width: min(380px, 88vw);
  }

  .splash-logo {
    font-size: 88px;
  }

  .splash-map {
    max-width: 260px;
  }
}


/* ═══════════════════════════════════════════
   RESPONSIVE — DESKTOP (900px+)
   Map becomes a persistent right sidebar.
═══════════════════════════════════════════ */
@media (min-width: 900px) {

  body {
    background: #e8e5e0;
  }

  .directory-layout {
    position: relative;
  }

  /* On desktop the map modal becomes a persistent right panel */
  .map-modal {
    position: relative;
    inset: auto;
    flex: 0 0 38%;
    pointer-events: auto;
    z-index: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .map-modal-backdrop {
    display: none;
  }

  .map-modal-sheet {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    transform: none !important;
    border-radius: 0;
    border-left: 1px solid var(--border);
    flex: 1;
    max-height: none;
    transition: none;
  }

  .map-modal-handle {
    display: none;
  }

  .google-map {
    flex: 1;
    height: auto;
    min-height: 320px;
  }

  .map-modal-info {
    border-top: 1px solid var(--border);
    min-height: 160px;
  }

  .map-btn-close {
    display: none;
  }

  /* 3-column listings — denser, truer to printed directory feel */
  .listings-panel {
    padding: 0 14px 60px;
    column-count: 3;
    column-gap: 14px;
  }

  .category-header {
    column-span: all;
    margin: 14px -14px 4px;
  }

  /* Tighter map sidebar at desktop */
  .map-modal {
    flex: 0 0 32%;
  }
}
