/**
 * Town of Sylvan Lake Infrastructure Map
 * Optimized Stylesheet
 */

/* ============================================================================
   CSS VARIABLES
   ============================================================================ */
:root {
  --color-primary: #ee7622;
  --color-secondary: #407cc9;
  --color-background: #ffffe6;
  --color-background-alt: #d6d6b0;
  --color-text-dark: #333;
  --color-text-light: #fff;
  --color-border: #00827a;
  --header-height: 60px;
  --transition-fast: 150ms ease;
  --transition-medium: 300ms ease;
  --transition-slow: 500ms ease;
  --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.25);
}

/* ============================================================================
   BASE STYLES
   ============================================================================ */
html,
body {
  padding: 0;
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ============================================================================
   MAP CONTAINER
   ============================================================================ */
#viewDiv {
  position: absolute;
  right: 0;
  left: 0;
  top: var(--header-height);
  bottom: 0;
  margin: 0;
}

/* ============================================================================
   HEADER STYLES
   ============================================================================ */
.header {
  position: absolute;
  top: 0;
  width: 100%;
  height: var(--header-height);
  z-index: 10;
  box-shadow: var(--shadow-light);
}

.banner-container {
  padding: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  height: 100%;
}

.banner {
  flex-grow: 1;
  background-color: var(--color-secondary);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.banner-content {
  margin: 0;
  padding: 0 10px;
  color: var(--color-text-light);
  font-weight: bold;
  font-size: clamp(14px, 3vw, 22px);
  text-align: center;
}

.img-container {
  flex-shrink: 0;
  height: 100%;
  padding: 5px 10px;
  background-color: var(--color-secondary);
  display: flex;
  align-items: center;
}

.img-container .img {
  max-height: 50px;
  width: auto;
}

/* ============================================================================
   LOADING INDICATOR
   ============================================================================ */
#loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  z-index: 100;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

#loading.visible {
  opacity: 1;
}

/* ============================================================================
   LAYER TOGGLE PANEL (RESPONSIVE)
   ============================================================================ */
.layer-toggle-panel {
  position: absolute;
  top: calc(var(--header-height) + 10px);
  left: 60px;
  z-index: 99;
  background-color: var(--color-primary);
  border-radius: 8px;
  box-shadow: var(--shadow-light);
  overflow: hidden;
  min-width: 160px;
  max-width: 90vw;
  transition: transform var(--transition-medium), opacity var(--transition-medium);
}

.layer-toggle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 15px;
  background: transparent;
  border: none;
  color: var(--color-text-light);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.layer-toggle-header:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.toggle-icon {
  font-size: 10px;
  transition: transform var(--transition-medium);
}

.layer-toggle-header[aria-expanded="false"] .toggle-icon {
  transform: rotate(-90deg);
}

.layer-toggle-content {
  background-color: var(--color-background);
  padding: 10px;
  max-height: 300px;
  overflow-y: auto;
  transition: max-height var(--transition-medium), padding var(--transition-medium), opacity var(--transition-medium);
}

.layer-toggle-content.collapsed {
  max-height: 0;
  padding: 0 10px;
  opacity: 0;
  overflow: hidden;
}

.layer-option {
  display: flex;
  align-items: center;
  padding: 8px 5px;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color var(--transition-fast);
  user-select: none;
}

.layer-option:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.layer-option input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  height: 18px;
  width: 18px;
  border: 2px solid var(--color-primary);
  border-radius: 3px;
  margin-right: 10px;
  flex-shrink: 0;
  position: relative;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.layer-option input:checked ~ .checkmark {
  background-color: var(--color-primary);
}

.checkmark::after {
  content: "";
  position: absolute;
  display: none;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.layer-option input:checked ~ .checkmark::after {
  display: block;
}

.layer-label {
  font-size: 13px;
  color: var(--color-text-dark);
}

.aerial-info {
  text-align: center;
  font-size: 11px;
  color: #666;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #ccc;
  font-style: italic;
}

/* Mobile responsiveness for layer toggle */
@media screen and (max-width: 600px) {
  .layer-toggle-panel {
    left: 10px;
    right: 10px;
    max-width: calc(100vw - 20px);
  }
  
  .layer-toggle-header {
    padding: 12px 15px;
    font-size: 16px;
  }
  
  .layer-option {
    padding: 12px 5px;
  }
  
  .layer-label {
    font-size: 15px;
  }

  /* Default to collapsed on mobile */
  .layer-toggle-content {
    max-height: 0;
    padding: 0 10px;
    opacity: 0;
    overflow: hidden;
  }
}

/* ============================================================================
   LAYER PANEL MINIMIZE / RESTORE
   ============================================================================ */

/* Header row: flex container for the toggle button + minimize button */
.layer-toggle-header-row {
  display: flex;
  align-items: center;
}

.layer-toggle-header-row .layer-toggle-header {
  flex: 1;
  border-radius: 0;
}

.layer-minimize-btn {
  background: transparent;
  border: none;
  color: var(--color-text-light);
  cursor: pointer;
  padding: 0 12px;
  height: 100%;
  font-size: 18px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  line-height: 1;
}

.minimize-icon {
  display: block;
  transition: transform var(--transition-medium);
}

.layer-minimize-btn:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.layer-minimize-btn:hover .minimize-icon {
  transform: scale(1.3);
}

/* ---- Panel minimize animation ---- */
.layer-toggle-panel {
  transform-origin: top left;
}

.layer-toggle-panel.minimizing {
  animation: panelShrink 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes panelShrink {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.95) rotate(-1deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.3) rotate(-3deg);
    pointer-events: none;
  }
}

.layer-toggle-panel.minimized {
  opacity: 0;
  transform: scale(0.3) rotate(-3deg);
  pointer-events: none;
  position: absolute;
}

/* ---- Panel restore animation ---- */
.layer-toggle-panel.restoring {
  animation: panelGrow 450ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes panelGrow {
  0% {
    opacity: 0;
    transform: scale(0.3) rotate(-3deg);
  }
  60% {
    opacity: 1;
    transform: scale(1.03) rotate(0.5deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

/* ---- Staggered layer items on restore ---- */
.layer-toggle-panel.restoring .layer-option {
  animation: layerSlideIn 350ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.layer-toggle-panel.restoring .layer-option:nth-child(1) { animation-delay: 100ms; }
.layer-toggle-panel.restoring .layer-option:nth-child(2) { animation-delay: 160ms; }
.layer-toggle-panel.restoring .layer-option:nth-child(3) { animation-delay: 220ms; }
.layer-toggle-panel.restoring .layer-option:nth-child(4) { animation-delay: 280ms; }

@keyframes layerSlideIn {
  0% {
    opacity: 0;
    transform: translateX(-12px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ---- Restore button (minimized state) ---- */
.layer-restore-btn {
  position: absolute;
  top: calc(var(--header-height) + 10px);
  left: 60px;
  z-index: 99;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background-color: var(--color-primary);
  color: var(--color-text-light);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-light);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
  transition: opacity var(--transition-medium), 
              transform var(--transition-medium) cubic-bezier(0.34, 1.56, 0.64, 1),
              background-color var(--transition-fast),
              border-radius var(--transition-medium);
}

.layer-restore-btn.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.layer-restore-btn:hover {
  background-color: #d5671c;
  border-radius: 12px;
  transform: scale(1.1);
}

.layer-restore-btn:hover .restore-icon {
  animation: iconPulse 600ms ease infinite alternate;
}

.layer-restore-btn:active {
  transform: scale(0.95);
}

.layer-restore-btn.visible:hover {
  transform: scale(1.1);
}

@keyframes iconPulse {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(8deg); }
}

/* Mobile adjustment */
@media screen and (max-width: 600px) {
  .layer-restore-btn {
    left: 10px;
    width: 48px;
    height: 48px;
  }
}

/* ============================================================================
   MEASUREMENT TOOLBAR
   ============================================================================ */
#toolbarDiv {
  position: absolute;
  top: calc(var(--header-height) + 15px);
  right: 15px;
  cursor: default;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 2px;
  z-index: 99;
}

/* ============================================================================
   DISCLAIMER OVERLAY (FULLSCREEN WITH ANIMATION)
   ============================================================================ */
.disclaimer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.disclaimer-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.disclaimer-content {
  background-color: var(--color-background);
  border-radius: 12px;
  border: 3px solid var(--color-primary);
  padding: 30px 40px;
  max-width: 540px;
  width: 90%;
  text-align: left;
  box-shadow: var(--shadow-medium);
  transform: scale(0.9) translateY(20px);
  transition: transform var(--transition-slow) cubic-bezier(0.34, 1.56, 0.64, 1);
}

.disclaimer-overlay.visible .disclaimer-content {
  transform: scale(1) translateY(0);
}

.disclaimer-title {
  color: var(--color-primary);
  font-size: 28px;
  font-weight: bold;
  margin: 0;
  text-align: center;
}

.disclaimer-divider {
  border: none;
  border-top: 2px solid var(--color-primary);
  margin: 15px 0 20px 0;
}

.disclaimer-text {
  color: var(--color-text-dark);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 16px 0;
}

.disclaimer-text-last {
  margin-bottom: 24px;
}

.disclaimer-close-btn {
  display: block;
  width: 80%;
  margin: 0 auto;
  padding: 14px 40px;
  background-color: var(--color-secondary);
  color: var(--color-text-light);
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.disclaimer-close-btn:hover {
  background-color: #3569ab;
  transform: scale(1.02);
}

.disclaimer-close-btn:active {
  transform: scale(0.98);
}

/* Disclaimer closing animation */
.disclaimer-overlay.closing {
  opacity: 0;
}

.disclaimer-overlay.closing .disclaimer-content {
  transform: scale(0.9) translateY(-20px);
}

/* ============================================================================
   ESRI WIDGET OVERRIDES
   ============================================================================ */
.esri-search__input:-ms-input-placeholder {
  color: var(--color-border);
}

.esri-search__input::-webkit-input-placeholder {
  color: var(--color-border);
}

.esri-search__submit-button {
  border-left: none;
  border-right: solid 1px var(--color-border);
}

.esri-search__sources-button {
  border-right: none;
  border-left: solid 1px var(--color-border);
}

.esri-menu .esri-menu__header {
  background-color: var(--color-primary) !important;
}

.esri-input {
  background-color: var(--color-background);
  border: 1px solid var(--color-background);
  color: var(--color-border);
  font-family: inherit;
  font-size: 14px;
}

.esri-widget--button {
  font-size: 14px;
  background-color: var(--color-primary);
  color: var(--color-text-light);
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
  align-items: center;
  transition: background-color 125ms ease-in-out;
}

.esri-widget--button:hover,
.esri-widget--button.active {
  background-color: #d5671c;
}

.esri-menu__list-item--active,
.esri-menu__list-item--active:hover,
.esri-menu__list-item--active:focus {
  background-color: var(--color-background);
  border-left-color: var(--color-background);
}

.esri-menu__list {
  margin: 0;
  padding: 0;
  list-style: none;
  background-color: var(--color-background);
}

.esri-popup__main-container {
  pointer-events: auto;
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 1000px;
  background-color: var(--color-background);
  display: flex;
  flex-flow: column nowrap;
  padding: 0;
  justify-content: center !important;
}

.esri-popup__header-title {
  color: transparent;
  background-color: var(--color-background-alt);
  display: block;
  margin: auto !important;
  justify-content: center !important;
  font-size: smaller;
  font-weight: bold;
  font-style: italic;
}

.esri-popup__header-container {
  background-color: var(--color-primary);
  padding: 1px !important;
  justify-content: center !important;
  align-items: center !important;
  width: 100% !important;
  margin: auto !important;
  flex: 1;
  cursor: pointer;
}

.esri-popup__content {
  display: flex;
  flex-flow: column nowrap;
  flex: 1 1 auto;
  font-size: 14px;
  border: solid 1px black;
  margin: 10px;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  line-height: normal;
  background-color: #fff !important;
  padding: 10px !important;
  min-height: 200px;
  max-height: 60vh;
  cursor: default;
}

.esri-popup__content img,
.esri-popup__content iframe {
  max-width: 100% !important;
}

.esri-popup__button:hover {
  color: rgb(175, 29, 29);
  background-color: var(--color-primary);
}

.esri-view-width-xlarge .esri-popup__main-container,
.esri-view-width-large .esri-popup__main-container,
.esri-view-width-medium .esri-popup__main-container {
  pointer-events: auto;
  position: relative;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  width: 100%;
  border: 1px solid black;
  max-height: 75vh !important;
  max-width: 420px !important;
  background-color: var(--color-background);
}

.esri-popup.esri-widget {
  max-height: 100%;
}

.esri-view-width-xlarge .esri-popup__main-container {
  width: 420px;
}

.esri-view-height-less-than-medium .esri-popup__main-container {
  max-height: 500px;
}

.esri-widget__table tr td,
.esri-widget__table tr th {
  padding: 0.5em 0.7em;
  word-break: break-word;
  vertical-align: top;
  font-weight: 400;
  background-color: var(--color-background);
}

.esri-widget__table tr td {
  width: 50%;
  background-color: var(--color-background);
}

.esri-legend__service {
  background-color: var(--color-background);
  border: solid 1px var(--color-primary);
}

/* ============================================================================
   ACCESSIBILITY & FOCUS STATES
   ============================================================================ */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================================
   LOT SEARCH PANEL
   ============================================================================ */
.lot-search-panel {
  position: absolute;
  top: calc(var(--header-height) + 57px);
  right: 15px;
  z-index: 98;
  background-color: var(--color-primary);
  border-radius: 8px;
  box-shadow: var(--shadow-light);
  overflow: hidden;
  width: 220px;
  max-width: 90vw;
}

.lot-search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 15px;
  background: transparent;
  border: none;
  color: var(--color-text-light);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.lot-search-header:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.lot-search-header[aria-expanded="false"] .toggle-icon {
  transform: rotate(-90deg);
}

.lot-search-content {
  background-color: var(--color-background);
  padding: 10px;
  max-height: 320px;
  transition: max-height var(--transition-medium), padding var(--transition-medium), opacity var(--transition-medium);
}

.lot-search-content.collapsed {
  max-height: 0;
  padding: 0 10px;
  opacity: 0;
  overflow: hidden;
}

.lot-search-field {
  display: block;
  margin-bottom: 8px;
}

.lot-search-label {
  display: block;
  font-size: 12px;
  font-weight: bold;
  color: var(--color-text-dark);
  margin-bottom: 3px;
}

.lot-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text-dark);
  background-color: #fff;
  border: 1px solid var(--color-primary);
  border-radius: 4px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.lot-search-input:focus {
  outline: none;
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 2px rgba(64, 124, 201, 0.25);
}

.lot-search-buttons {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.lot-search-btn {
  flex: 1;
  padding: 8px 0;
  font-size: 13px;
  font-weight: bold;
  font-family: inherit;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background-color: var(--color-background-alt);
  color: var(--color-text-dark);
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.lot-search-btn:hover {
  background-color: #c5c59c;
}

.lot-search-btn:active {
  transform: scale(0.97);
}

.lot-search-btn-primary {
  background-color: var(--color-secondary);
  color: var(--color-text-light);
}

.lot-search-btn-primary:hover {
  background-color: #3569ab;
}

.lot-search-message {
  margin-top: 8px;
  font-size: 12px;
  color: var(--color-text-dark);
  min-height: 14px;
}

.lot-search-message.error {
  color: #af1d1d;
  font-weight: bold;
}

/* Mobile responsiveness for lot search panel */
@media screen and (max-width: 600px) {
  .lot-search-panel {
    top: calc(var(--header-height) + 62px);
    right: 10px;
    width: 200px;
  }

  .lot-search-header {
    padding: 12px 15px;
    font-size: 16px;
  }

  .lot-search-input {
    font-size: 15px;
    padding: 8px;
  }

  /* Default to collapsed on mobile */
  .lot-search-content {
    max-height: 0;
    padding: 0 10px;
    opacity: 0;
    overflow: hidden;
  }
}

/* ============================================
   POPUP CURSOR FIX - only pointer on links
   (from townmap.css)
   ============================================ */
.esri-popup__content * {
  cursor: default;
}
.esri-popup__content a {
  cursor: pointer;
}

/* ============================================
   RESPONSIVE POPUP FOR MOBILE (from townmap.css)
   ============================================ */
@media screen and (max-height: 700px) {
  .esri-popup__content {
    min-height: 150px;
    max-height: 45vh;
  }
}

@media screen and (max-height: 500px) {
  .esri-popup__content {
    min-height: 100px;
    max-height: 35vh;
  }
}

/* ============================================================================
   LEGAL POPUP — styled to match the townmap parcel popup
   Same class names and rules as townmap.css (.tm-parcel-popup subset),
   scoped so nothing else on the page is affected.
   ============================================================================ */

.tm-parcel-popup {
  font-family: "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color: #2b2b2b;
  line-height: 1.4;
}

/* Section blocks */
.tm-parcel-popup .tm-section {
  margin-bottom: 14px;
}
.tm-parcel-popup .tm-section__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #ee7622;
  padding-bottom: 4px;
  margin-bottom: 6px;
  border-bottom: 2px solid #ee7622;
}

/* Label / value rows */
.tm-parcel-popup .tm-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 2px;
  border-bottom: 1px dotted #e8e2d0;
  gap: 12px;
}
.tm-parcel-popup .tm-row:last-child {
  border-bottom: none;
}
.tm-parcel-popup .tm-row__label {
  color: #6a6a6a;
  font-weight: 500;
  flex: 0 0 auto;
}
.tm-parcel-popup .tm-row__value {
  color: #1f1f1f;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

/* Mobile tuning */
@media screen and (max-width: 480px) {
  .tm-parcel-popup {
    font-size: 12px;
  }
}

/* ============================================================================
   LOT SEARCH AUTOCOMPLETE
   ============================================================================ */

/* The panel clips overflow for its rounded corners, which would cut off the
   suggestion dropdowns. Let it overflow and round the children instead. */
.lot-search-panel {
  overflow: visible;
}

.lot-search-header {
  border-radius: 8px 8px 0 0;
}

.lot-search-content {
  border-radius: 0 0 8px 8px;
}

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

.lot-search-suggestions {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 200;
  background-color: #fff;
  border: 1px solid var(--color-primary);
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 160px;
  overflow-y: auto;
  box-shadow: var(--shadow-light);
}

.lot-search-suggestions.visible {
  display: block;
}

.lot-search-suggestion {
  padding: 6px 8px;
  font-size: 13px;
  color: var(--color-text-dark);
  cursor: pointer;
}

.lot-search-suggestion:hover,
.lot-search-suggestion.active {
  background-color: var(--color-background-alt);
}

@media screen and (max-width: 600px) {
  .lot-search-suggestion {
    padding: 9px 10px;
    font-size: 15px;
  }
}
