/* ==============================
   Reset & Base
   ============================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root{
  --green: #1a9850;
  --green-dark: #158241;
  --panel-shadow: 0 2px 10px rgba(0,0,0,0.2);
  --radius: 10px;
  --z-ui: 1200;
  --z-panel: 1250;
  --z-modal: 1300;
}

body{
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color:#333;
  background:#fff;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==============================
   Header + top controls
   ============================== */
header{
  background: var(--green);
  color: #fff;
  padding: 16px 14px 14px;
  text-align: center;
  position: relative;
  z-index: var(--z-ui);
}

header h1{
  font-size: 1.8rem;
  margin-bottom: 6px;
}

header p{
  font-size: 0.98rem;
  opacity: 0.95;
}

.header-controls{
  margin: 12px auto 0;
  max-width: 920px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}

#address-search{
  flex: 1;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

#address-input{
  flex: 1;
  min-width: 220px;
  max-width: 520px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
}

#address-input::placeholder{ color: rgba(0,0,0,0.45); }

#search-btn{
  padding: 10px 14px;
  background: #fff;
  color: var(--green);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}
#search-btn:hover{ filter: brightness(0.96); }

#legend-burger{
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}

/* ==============================
   Map
   ============================== */
#map{
  height: calc(100vh - 170px);
  width: 100%;
  position: relative;
  z-index: 0;
}

/* ==============================
   Desktop panels (legend + info)
   ============================== */
#legend,
#info-panel{
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
}

#legend{
  position: absolute;
  top: 190px;
  right: 16px;
  width: 280px;
  max-height: calc(100vh - 250px);
  overflow-y: auto;
  z-index: var(--z-panel);
  padding: 14px 14px 12px;
  transition: width 0.2s ease;
}

#legend.collapsed{
  width: auto;
  min-width: 140px;
}

#legend h3{
  font-size: 1.05rem;
  margin-bottom: 8px;
}

#legend h4{
  font-size: 0.95rem;
  margin: 8px 0 8px 0;
  color: #555;
}

#legend-toggle{
  transition: transform 0.2s ease;
}

#legend-toggle:hover{
  color: #333;
}

.legend-row{
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  font-size: 0.95rem;
}

.legend-square{
  width: 18px;
  height: 18px;
  border-radius: 2px;
  border: 1px solid #ccc;
  flex-shrink: 0;
}

.ptal-4b{ background:#006837; }
.ptal-4a{ background:#1a9850; }
.ptal-3{ background:#a6d96a; }
.ptal-2{ background:#fee08b; }
.ptal-1{ background:#d73027; }

/* SVG overlay patterns - target path elements with composite pattern classes */
path.flood-ptal4b,
path.flood-ptal4a,
path.flood-ptal3,
path.flood-ptal2,
path.flood-ptal1 {
  fill: url(#flood-ptal4b) !important;
}

/* SVG overlay patterns - target child path elements */
.flood-ptal4b path { fill: url(#flood-ptal4b) !important; }
.flood-ptal4a path { fill: url(#flood-ptal4a) !important; }
.flood-ptal3 path { fill: url(#flood-ptal3) !important; }
.flood-ptal2 path { fill: url(#flood-ptal2) !important; }
.flood-ptal1 path { fill: url(#flood-ptal1) !important; }

.parking-ptal4b path { fill: url(#parking-ptal4b) !important; }
.parking-ptal4a path { fill: url(#parking-ptal4a) !important; }
.parking-ptal3 path { fill: url(#parking-ptal3) !important; }
.parking-ptal2 path { fill: url(#parking-ptal2) !important; }
.parking-ptal1 path { fill: url(#parking-ptal1) !important; }

.flood-parking-ptal4b path { fill: url(#flood-parking-ptal4b) !important; }
.flood-parking-ptal4a path { fill: url(#flood-parking-ptal4a) !important; }
.flood-parking-ptal3 path { fill: url(#flood-parking-ptal3) !important; }
.flood-parking-ptal2 path { fill: url(#flood-parking-ptal2) !important; }
.flood-parking-ptal1 path { fill: url(#flood-parking-ptal1) !important; }

.legend-divider{
  margin: 12px 0;
  padding-top: 12px;
  border-top: 1px solid #e6e6e6;
}

.legend-muted{
  margin-top: 6px;
  font-size: 0.85rem;
  color: #666;
  line-height: 1.3;
}

#mismatch-toggle, #flood-toggle, #parking-toggle{
  transform: translateY(1px);
  cursor: pointer;
}

/* Info panel desktop - SMALLER */
#info-panel{
  position: absolute;
  top: 190px;
  left: 16px;  /* Was on right, move back to left */
  width: 320px;
  max-height: calc(100vh - 250px);
  z-index: calc(var(--z-panel) + 1);
  padding: 14px 14px 12px;
  overflow-y: auto;
}

#info-panel.hidden{ display: none; }

#close-panel{
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
}
#close-panel:hover{ color:#333; }

#info-panel h2{
  font-size: 1.3rem;
  margin-bottom: 4px;
}

#info-panel h3{
  font-size: 1rem;
  margin: 12px 0 8px 0;
}

#capacity-info{
  background: #e3f2fd;
  padding: 10px;
  border-radius: 8px;
  margin: 10px 0;
}

.mismatch-warning{
  background:#fff3cd;
  border-left: 4px solid #ffc107;
  padding: 10px;
  border-radius: 8px;
  margin-top: 10px;
  line-height: 1.4;
}

.mismatch-warning p{
  margin: 0;
  font-size: 0.9rem;
}

table{
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table td{
  padding: 6px 8px;
  border-bottom: 1px solid #eee;
}

#nearby-stops{
  list-style: none;
  padding: 0;
}

#nearby-stops li{
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  line-height: 1.3;
  font-size: 0.9rem;
}

#nearby-stops li:last-child{
  border-bottom: none;
}

/* ==============================
   Footer
   ============================== */
footer{
  background:#f5f5f5;
  padding: 14px;
  text-align:center;
  font-size: 0.9rem;
}

footer .meta{
  margin-top: 6px;
  font-size: 0.85rem;
  color: #666;
}

footer .disclaimer{
  margin-top: 10px;
  font-size: 0.8rem;
  color: #666;
  line-height: 1.4;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

footer .disclaimer strong{
  color: #333;
}

/* ==============================
   Mobile layout
   ============================== */
@media (max-width: 768px){

  header{
    padding: 14px 12px 12px;
    text-align: left;
  }

  header h1{
    font-size: 1.35rem;
    margin-bottom: 4px;
  }

  header p{
    font-size: 0.9rem;
  }

  .header-controls{
    justify-content: space-between;
  }

  #legend-burger{
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #address-search{
    justify-content: flex-start;
  }

  #address-input{
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  #map{
    height: calc(100vh - 175px);
  }

  #info-panel{
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    width: auto;
    max-height: 50vh;
    transform: translateY(120%);
    transition: transform 0.25s ease;
    z-index: var(--z-modal);
  }

  #info-panel.show{
    transform: translateY(0);
  }

  #legend{
    position: fixed;
    left: 12px;
    right: 12px;
    top: 160px;
    width: auto;
    max-height: 65vh;
    overflow-y: auto;
    transform: translateY(-140%);
    transition: transform 0.22s ease;
    z-index: var(--z-modal);
    padding: 14px;
  }

  #legend.open{
    transform: translateY(0);
  }

  #legend-toggle{
    display: none !important;
  }
}

/* ==============================
   Embed mode (triggered by ?embed=1)
   ============================== */
html.embed body {
  /* Optional: slightly lighter bg around the map when header/footer are gone */
  background: #fafafa;
}

/* Hide chrome in embed */
html.embed header,
html.embed footer {
  display: none !important;
}

/* Hide header controls (search + burger) for a clean graphic */
html.embed .header-controls,
html.embed #legend-burger {
  display: none !important;
}

/* Keep the desktop-style side panels even on small widths */
@media (max-width: 768px) {
  html.embed #info-panel {
    position: absolute !important;
    top: 12px !important;
    left: 12px !important;
    right: auto !important;
    bottom: auto !important;
    width: 320px !important;
    max-height: calc(100vh - 40px) !important;
    transform: none !important;
    z-index: var(--z-panel);
  }
  html.embed #legend {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    left: auto !important;
    width: 280px !important;
    max-height: calc(100vh - 40px) !important;
    transform: none !important;
    z-index: var(--z-panel);
  }
}

/* Desktop positions tightened for embeds too */
html.embed #info-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 320px;
  max-height: calc(100vh - 40px);
}

html.embed #legend {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 280px;
  max-height: calc(100vh - 40px);
  padding: 12px;
}

/* Map height: predictable inside CMS pages
   (Editors can still set iframe height; this prevents 100vh quirks inside the iframe) */
html.embed #map {
  height: 620px; /* Adjust if you want taller/shorter */
}

/* Optional: smaller type for a tighter card-like look */
html.embed #legend h3,
html.embed #legend h4 {
  margin: 6px 0;
}

html.embed .legend-row {
  margin: 4px 0;
  font-size: 0.9rem;
}

/* Tooltips shouldn't capture the mouse */
.leaflet-tooltip,
.leaflet-tooltip.ptal-tip {
  pointer-events: none;      /* prevents re-entrancy / ghosting */
  transition: opacity .08s;  /* snappier fade reduces trails */
}

/* Optional: slightly smaller tooltip for dense grids */
.leaflet-tooltip.ptal-tip {
  font-size: 12px;
  line-height: 1.2;
  padding: 4px 6px;
}
