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

:root{
  --brisbane-blue: #0052A5;
  --header-color: #0052A5;
  --brisbane-blue-dark: #003d7a;
  --brisbane-yellow: #FDB913;
  --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;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

/* ==============================
   Header + top controls
   ============================== */
header{
  background: var(--header-color, #0052A5);
  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: var(--brisbane-yellow);
  color: var(--brisbane-blue-dark);
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  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;
}

.region-switcher-header {
  display: flex;
  gap: 10px;
  align-items: center;
}

.region-switcher-header a {
  display: flex;
  align-items: center;
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.2s;
}

.region-switcher-header a:hover {
  opacity: 0.85;
  transform: scale(1.05);
}

.region-switcher-header a.active {
  opacity: 1;
  transform: scale(1.1);
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.6));
}
/* ==============================
   Map
   ============================== */
#map{
  flex: 1;
  min-height: 400px;
  height: 100%;
}

/* ==============================
   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 */
path.flood-ptal4b,
path.flood-ptal4a,
path.flood-ptal3,
path.flood-ptal2,
path.flood-ptal1 {
  fill: url(#flood-ptal4b) !important;
}

.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, #greenspace-toggle{
  transform: translateY(1px);
  cursor: pointer;
}

#info-panel{
  position: absolute;
  top: 190px;
  left: 16px;
  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 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 1.3rem;
  margin-bottom: 4px;
}

#info-panel h2 a {
  white-space: nowrap;
  flex-shrink: 0;
}

#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;
}

/* Region Switcher */
.region-switcher {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.9rem;
}

.region-switcher a {
  color: inherit;
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.region-switcher a:hover,
.region-switcher a.active {
  opacity: 1;
  text-decoration: underline;
}

.region-switcher .separator {
  opacity: 0.5;
  margin: 0 0.5rem;
}

/* Gold Coast button override */
body[data-region="goldcoast"] #search-btn {
  background-color: #00A8B5;
  color: white;
}

body[data-region="goldcoast"] #search-btn:hover {
  background-color: #008A94;
}

/* ==============================
   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(100svh - 190px);
    height: calc(100vh - 190px);
  }

  #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
   ================================ */
body.embed header,
body.embed footer {
  display: none !important;
}

body.embed {
  padding-top: 0;
}

body.embed #map {
   flex: none;
   height: 650px;
  max-height: 650px;
}

body.embed #legend,
body.embed #legend-burger {
  display: none !important;
}

body.embed #info-panel {
  max-height: 90%;
}
