/* style.css – Polished styling for New Canaan Cameras */

/* ===== Design Tokens (matching DeFlock aesthetic) ===== */
:root {
  --blue: rgb(18, 151, 195);
  --blue-dark: #0081ac;
  --bg: #0a0a1a;
  --bg-alt: #111;
  --text: #f0f0f0;
  --text-dim: #aaa;
  --header-bg: rgba(10,10,26,0.9);
  --header-text: white;
  --control-bg: rgba(26,26,46,0.8);
  --control-border: rgba(255,255,255,0.08);
  --card-bg: rgba(26,26,46,0.6);
  --shadow: 0 4px 20px rgba(0,0,0,0.4);

  /* Easing */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

/* Light theme (optional) */
[data-theme="light"] {
  --bg: #f8f9fa;
  --bg-alt: #ffffff;
  --text: #222;
  --text-dim: #666;
  --header-bg: rgba(255,255,255,0.9);
  --header-text: #007bff;
  --control-bg: rgba(255,255,255,0.8);
  --control-border: rgba(0,0,0,0.08);
  --card-bg: rgba(248,249,250,0.9);
}

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

body {
  margin: 0;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s var(--ease-in-out), color 0.3s var(--ease-in-out);
  font-size: 15px;
}

/* Typography */
h1 { font-size: clamp(1.4rem, 3vw, 1.8rem); font-weight: 700; }
h2 { font-size: clamp(1.1rem, 2.5vw, 1.4rem); font-weight: 600; margin-bottom: 16px; }
h3 { font-size: clamp(0.9rem, 2vw, 1.05rem); font-weight: 600; }
p { margin-bottom: 12px; }

/* ===== Header ===== */
#header {
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--control-border);
  color: var(--header-text);
  padding: clamp(16px, 3vh, 24px) 20px;
  text-align: center;
  position: relative;
  z-index: 1000;
}

.hero-tagline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.tagline-label {
  font-size: clamp(0.65rem, 1.2vw, 0.75rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--blue);
  background: rgba(18,151,195,0.1);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(18,151,195,0.2);
}

#header h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  line-height: 1.2;
}

.hero-sub {
  margin: 0 auto 12px;
  max-width: 600px;
  font-size: clamp(0.9rem, 1.8vw, 1.05rem);
  line-height: 1.5;
  opacity: 0.9;
  font-weight: 400;
}

/* ===== Controls ===== */
#controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: clamp(12px, 3vw, 24px);
  flex-wrap: wrap;
}

#controls button,
#controls input {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  font-family: inherit;
  outline: none;
  min-width: 130px;
  text-align: center;
}

#controls button {
  position: relative;
  overflow: hidden;
}

#controls button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--blue);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.2s var(--ease-out);
}

#controls button:hover::before {
  opacity: 0.1;
}

#controls button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(18,151,195,0.15);
}

#controls button:active {
  transform: scale(0.97);
}

#controls button:hover {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

#controls button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

#controls input {
  min-width: 220px;
  background: var(--bg-alt);
  border: 1px solid var(--control-border);
  text-align: center;
}

/* Primary CTA button */
#controls .btn-primary {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
  font-weight: 500;
}

#controls .btn-primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: white;
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 20px rgba(18,151,195,0.3);
}

#controls input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(18,151,195,0.2);
}

/* Button links */
.list-link {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--control-border);
  background: var(--blue);
  color: white;
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  font-weight: 500;
}

.list-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(18,151,195,0.3);
}

.list-link:active {
  transform: scale(0.97);
}

/* ===== Map ===== */
#map {
  width: 100%;
  height: calc(100vh - 150px);
}

/* Dark mode: apply filter ONLY to tile pane */
.leaflet-tile-pane {
  filter: invert(0.85) hue-rotate(180deg) contrast(1.05) brightness(0.92);
}

[data-theme="light"] .leaflet-tile-pane {
  filter: none;
}

/* Leaflet controls */
.leaflet-control-zoom {
  border-radius: 8px !important;
  overflow: hidden !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3) !important;
  border: 1px solid var(--control-border) !important;
}

.leaflet-control-zoom a {
  color: var(--text) !important;
  background: var(--control-bg) !important;
  border-bottom: 1px solid var(--control-border) !important;
  transition: background 0.2s var(--ease-out) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--blue) !important;
  color: white !important;
}

.leaflet-control-attribution {
  border-radius: 6px !important;
  background: var(--control-bg) !important;
  color: var(--text-dim) !important;
  font-size: 0.8rem !important;
  padding: 4px 10px !important;
  backdrop-filter: blur(10px);
}

/* Marker clusters */
.marker-cluster {
  background: var(--blue) !important;
  border: 2px solid var(--bg) !important;
  color: white !important;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3) !important;
  border-radius: 50% !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
  transition: transform 0.2s var(--ease-out) !important;
}

.marker-cluster:hover {
  transform: scale(1.1);
}

.marker-cluster span {
  text-shadow: 0 2px 4px rgba(0,0,0,0.3) !important;
}

/* Popups */
.leaflet-popup-content-wrapper {
  background: var(--card-bg) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3) !important;
  border-radius: 12px !important;
  border: 1px solid var(--control-border) !important;
}

.leaflet-popup-content {
  margin: 12px 16px !important;
  line-height: 1.5 !important;
  color: var(--text) !important;
  font-size: 14px !important;
}

.leaflet-popup-content b {
  color: var(--blue) !important;
  font-weight: 600 !important;
}

.leaflet-popup-tip {
  background: var(--card-bg) !important;
  border: 1px solid var(--control-border) !important;
}

.leaflet-popup-close-button {
  color: var(--text-dim) !important;
  font-size: 18px !important;
  padding: 4px 8px !important;
  opacity: 0.7;
  transition: opacity 0.2s var(--ease-out) !important;
}

.leaflet-popup-close-button:hover {
  opacity: 1;
}

/* ===== List page ===== */
#list-container {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

#camera-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--card-bg);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  border: 1px solid var(--control-border);
}

#camera-table th {
  background: var(--control-bg);
  font-weight: 600;
  color: var(--text);
  padding: 14px 16px;
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--control-border);
}

#camera-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--control-border);
  transition: background 0.2s var(--ease-out);
}

#camera-table tbody tr:hover {
  background: rgba(18,151,195,0.08);
}

#camera-table td:first-child {
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
}

#camera-table td:nth-child(6),
#camera-table td:nth-child(7) {
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
}

[data-theme="light"] tbody tr:hover {
  background: rgba(18,151,195,0.05);
}

/* ===== About/risks/take-action pages ===== */
#about-container {
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
  line-height: 1.8;
}

.about-section {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--control-border);
}

.about-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.about-section h2 {
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
  margin-bottom: 16px;
  color: var(--text);
  position: relative;
  padding-bottom: 8px;
}

.about-section h2:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--blue);
}

.about-section h3 {
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  margin: 16px 0 8px;
  color: var(--blue);
}

.about-section a {
  color: var(--blue);
  text-decoration: none;
  transition: color 0.2s var(--ease-out);
  position: relative;
}

.about-section a:after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--blue);
  transition: width 0.2s var(--ease-out);
}

.about-section a:hover:after {
  width: 100%;
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.card {
  padding: 24px;
  background: var(--card-bg);
  border: 1px solid var(--control-border);
  border-radius: 12px;
  transition: all 0.2s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.card:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--blue);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.card h3 {
  margin-top: 0;
  font-size: 1rem;
  position: relative;
  z-index: 1;
}

.card p {
  font-size: 0.9rem;
  opacity: 0.9;
  position: relative;
  z-index: 1;
}

.card ul {
  padding-left: 20px;
  position: relative;
  z-index: 1;
}

.card li {
  margin: 6px 0;
  font-size: 0.9rem;
  opacity: 0.9;
}

/* Resource list */
.resource-list {
  list-style: none;
  padding: 0;
}

.resource-list li {
  padding: 16px 20px;
  background: var(--card-bg);
  border: 1px solid var(--control-border);
  border-radius: 10px;
  margin-bottom: 12px;
  transition: all 0.2s var(--ease-out);
}

.resource-list li:hover {
  transform: translateX(4px);
  border-color: var(--blue);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.resource-list strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.resource-list a {
  color: var(--blue);
  text-decoration: none;
}

.resource-list a:hover {
  text-decoration: underline;
}

/* Action items */
.action-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.action-item {
  padding: 24px;
  background: var(--card-bg);
  border: 1px solid var(--control-border);
  border-radius: 12px;
  transition: all 0.2s var(--ease-out);
}

.action-item:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.action-item h3 {
  margin-top: 0;
  font-size: 1.05rem;
  color: var(--blue);
  position: relative;
  padding-bottom: 8px;
}

.action-item h3:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 30px;
  height: 1px;
  background: var(--blue);
}

.action-item ul {
  padding-left: 20px;
  margin-top: 8px;
}

.action-item li {
  margin: 6px 0;
  font-size: 0.95rem;
}

/* Template boxes */
.template-box {
  background: var(--card-bg);
  border: 1px solid var(--control-border);
  border-radius: 10px;
  padding: 24px;
  margin: 16px 0;
  font-family: 'Fira Code', UI mono, 'Segoe UI monospace', monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-x: auto;
  border-left: 3px solid var(--blue);
}

.template-box strong {
  font-family: inherit;
  font-weight: 600;
  color: var(--blue);
}

.template-box a {
  color: var(--blue);
  text-decoration: none;
}

/* Contact grid */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.contact-card {
  padding: 20px;
  background: var(--card-bg);
  border: 1px solid var(--control-border);
  border-radius: 10px;
  transition: all 0.2s var(--ease-out);
}

.contact-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  transform: translateY(-3px);
}

.contact-card h4 {
  margin-top: 0;
  color: var(--blue);
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.contact-card p {
  margin: 8px 0;
  font-size: 0.9rem;
}

.contact-card a {
  color: var(--blue);
  text-decoration: none;
}

.contact-card a:hover {
  text-decoration: underline;
}

/* Action cards */
.action-card {
  text-align: center;
}

.action-card h3 {
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.action-card p {
  margin-bottom: 16px;
  opacity: 0.9;
}

/* Button links */
.btn-link {
  display: inline-block;
  padding: 10px 24px;
  background: var(--blue);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  font-size: 0.85rem;
}

.btn-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(18,151,195,0.3);
}

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

.btn-link:hover {
  background: var(--blue-dark);
}

/* Risk cards */
.risk-card {
  border-left: 3px solid var(--blue);
}

.risk-card h3 {
  color: var(--blue);
  font-size: 1rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.risk-card h3:before {
  content: attr(data-risk);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--blue);
  color: white;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
}

.risk-card ul {
  padding-left: 20px;
  margin: 10px 0;
}

.risk-card li {
  margin: 6px 0;
  font-size: 0.9rem;
  opacity: 0.9;
}

/* Note callout */
.note {
  background: var(--card-bg);
  border-left: 3px solid var(--blue);
  padding: 16px 20px;
  margin: 16px 0;
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
}

.note strong {
  color: var(--blue);
  margin-right: 4px;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  #header {
    padding: 12px 14px;
  }
  #header h1 { font-size: 1.2rem; }
  #header p { font-size: 0.8rem; }
  #controls {
    gap: 6px;
  }
  #controls button,
  #controls input,
  .list-link {
    padding: 7px 14px;
    font-size: 0.8rem;
  }
  #controls input {
    min-width: 140px;
  }
  #map {
    height: calc(100vh - 140px);
  }

  #about-container {
    padding: 14px;
  }
  .about-section {
    margin-bottom: 32px;
    padding-bottom: 24px;
  }
  .card-grid,
  .action-items,
  .contact-grid {
    grid-template-columns: 1fr;
  }
  .card,
  .action-item,
  .contact-card {
    padding: 20px;
  }
  .template-box {
    font-size: 0.75rem;
    padding: 20px;
  }
  #camera-table {
    font-size: 0.8rem;
  }
  #camera-table th,
  #camera-table td {
    padding: 10px 12px;
  }
}
