/* ============================================
   John Staub House Catalog -- Styles
   ============================================ */

:root {
  --color-bg: #f5f5f0;
  --color-surface: #ffffff;
  --color-text: #2c2c2c;
  --color-text-secondary: #6b6b6b;
  --color-accent: #4a6741;
  --color-accent-light: #e8ede7;
  --color-border: #e0ddd8;
  --color-marker: #4a6741;
  --color-marker-active: #c0392b;
  --sidebar-width: 420px;
  --header-height: 56px;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Georgia", "Times New Roman", serif;
}

/* ---- Reset ---- */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-stack);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */

.site-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
}

.site-header h1 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text);
}

.site-header h1 span {
  color: var(--color-text-secondary);
  font-weight: 400;
  font-size: 14px;
  margin-left: 12px;
}

/* ---- App Layout ---- */

.app-layout {
  display: flex;
  height: calc(100vh - var(--header-height));
  width: 100vw;
  overflow: hidden;
}

/* ---- Sidebar ---- */

.sidebar {
  width: var(--sidebar-width);
  min-width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  padding: 16px;
}

.sidebar-count {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
  padding: 0 4px;
}

/* ---- House Cards ---- */

.house-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 12px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.house-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.house-card.active {
  border-color: var(--color-accent);
  box-shadow: 0 2px 12px rgba(74, 103, 65, 0.15);
}

.house-card-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  background: var(--color-border);
}

.house-card-body {
  padding: 12px 16px;
}

.house-card-name {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.house-card-address {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.house-card-year {
  font-size: 12px;
  color: var(--color-text-secondary);
  font-style: italic;
}

.house-card-details-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.house-card-details-btn:hover {
  background: var(--color-accent);
  color: #fff;
}

/* ---- Map ---- */

.map-container {
  flex: 1;
  min-width: 0;
  position: relative;
}

#map {
  height: 100%;
  width: 100%;
}

/* ---- Custom Map Markers ---- */

.marker-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-marker);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, background 0.2s;
}

.marker-icon.demolished {
  background: #999;
  border-style: dashed;
}

.marker-icon.active {
  background: var(--color-marker-active);
  transform: scale(1.5);
  z-index: 1000 !important;
}

.marker-icon.demolished.active {
  background: var(--color-marker-active);
}

/* ---- Modal ---- */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: var(--color-surface);
  border-radius: 12px;
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--color-bg);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--color-text-secondary);
  transition: background 0.2s;
  z-index: 1;
}

.modal-close:hover {
  background: var(--color-border);
}

.modal-image {
  width: 100%;
  height: 280px;
  object-fit: cover;
  display: block;
  border-radius: 12px 12px 0 0;
  background: var(--color-border);
}

.modal-body {
  padding: 24px;
}

.modal-name {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--color-text-secondary);
}

.modal-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.modal-description {
  font-size: 15px;
  line-height: 1.7;
  color: var(--color-text);
  margin-bottom: 24px;
}

.modal-articles-heading {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

.modal-article {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.modal-article:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.modal-article-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.modal-article-title a {
  color: var(--color-accent);
  text-decoration: none;
}

.modal-article-title a:hover {
  text-decoration: underline;
}

.modal-article-source {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.modal-article-summary {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.modal-no-articles {
  font-size: 14px;
  color: var(--color-text-secondary);
  font-style: italic;
}

/* ---- Status Badges ---- */

.house-card-status.demolished,
.modal-status.demolished {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a0522d;
  background: #fdf2e9;
  border: 1px solid #e8c9a0;
  border-radius: 3px;
  padding: 1px 6px;
  margin-left: 8px;
  vertical-align: middle;
  font-family: var(--font-stack);
  font-style: normal;
}

.modal-status.demolished {
  font-size: 11px;
  padding: 2px 8px;
}

/* ---- Modal Extra Fields ---- */

.modal-client,
.modal-neighborhood {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.modal-client {
  margin-top: 12px;
}

.modal-neighborhood {
  margin-bottom: 16px;
}

/* ---- Image Placeholder ---- */

.image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-border);
  color: var(--color-text-secondary);
  font-size: 13px;
}

/* ---- Loading / Error States ---- */

.loading-message,
.error-message {
  padding: 24px;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 14px;
}

.error-message {
  color: #c0392b;
}

/* ---- Mobile Toggle ---- */

.mobile-toggle {
  display: none;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
  .mobile-toggle {
    display: flex;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    background: var(--color-surface);
    border-radius: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    padding: 4px;
    gap: 2px;
  }

  .mobile-toggle-btn {
    padding: 8px 24px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-stack);
    cursor: pointer;
    background: transparent;
    color: var(--color-text-secondary);
    transition: background 0.2s, color 0.2s;
  }

  .mobile-toggle-btn.active {
    background: var(--color-accent);
    color: #fff;
  }

  .app-layout {
    flex-direction: column;
  }

  /* Map view: full screen map, hide sidebar */
  .app-layout[data-mobile-view="map"] .sidebar {
    display: none;
  }

  .app-layout[data-mobile-view="map"] .map-container {
    width: 100%;
    height: calc(100vh - var(--header-height));
    order: 1;
  }

  /* List view: full screen list, hide map */
  .app-layout[data-mobile-view="list"] .map-container {
    display: none;
  }

  .app-layout[data-mobile-view="list"] .sidebar {
    width: 100%;
    min-width: unset;
    height: calc(100vh - var(--header-height));
    order: 1;
    border-right: none;
  }

  /* Compact cards on mobile */
  .house-card {
    display: flex;
    flex-direction: row;
    margin-bottom: 8px;
  }

  .house-card-image {
    width: 100px;
    min-width: 100px;
    height: auto;
    min-height: 90px;
    border-radius: 8px 0 0 8px;
  }

  .house-card-body {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .house-card-name {
    font-size: 14px;
  }

  .house-card-address {
    font-size: 12px;
  }

  .house-card-year {
    font-size: 11px;
  }

  .house-card-details-btn {
    margin-top: 6px;
    padding: 4px 10px;
    font-size: 11px;
  }

  /* Larger marker tap targets on mobile */
  .marker-icon {
    width: 20px;
    height: 20px;
  }

  .marker-wrapper {
    width: 20px !important;
    height: 20px !important;
    margin-left: -10px !important;
    margin-top: -10px !important;
  }

  /* Modal full-screen on mobile */
  .modal-overlay {
    padding: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .modal-content {
    max-height: 100dvh;
    max-height: 100vh; /* fallback */
    height: 100dvh;
    height: 100vh; /* fallback */
    border-radius: 0;
    max-width: 100%;
  }

  @supports (height: 100dvh) {
    .modal-content {
      max-height: 100dvh;
      height: 100dvh;
    }
  }

  .modal-image {
    height: 200px;
    border-radius: 0;
  }

  .modal-body {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .modal-name {
    font-size: 20px;
  }

  .modal-close {
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
    width: 36px;
    height: 36px;
    font-size: 22px;
    background: rgba(255, 255, 255, 0.9);
  }
}

/* ---- Body scroll lock ---- */

body.modal-open {
  overflow: hidden;
}
