/* MUTCDSearch.com - Temporary Traffic Control Reference Finder Styles
   Phase 2: Mobile-First Interactive Field Reference
   FHWA MUTCD 11th Edition with Revision 1 (December 2025)
*/

:root {
  --bg-dark: #0b0f19;
  --bg-card: #111827;
  --bg-card-hover: #172033;
  --bg-input: #1a2234;
  --border-color: #2d3748;
  --border-focus: #f59e0b;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --accent-amber: #f59e0b;
  --accent-amber-hover: #d97706;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Sibling Bar */
.sibling-tools-bar {
  background: #111827;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
}
.sibling-tools-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 0.85rem;
}
.sibling-label {
  color: var(--accent-amber);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.75rem;
}
.sibling-tools-inner a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.sibling-tools-inner a:hover,
.sibling-tools-inner a.active {
  color: #fff;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* App Container */
.finder-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

/* Header & Disclaimer */
.finder-header {
  margin-bottom: 24px;
}
.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.finder-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
}
.edition-badge {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.header-lead {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

/* Mandatory Disclaimer Banner */
.disclaimer-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-left: 4px solid var(--accent-red);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}
.disclaimer-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #fca5a5;
  font-size: 0.9rem;
  margin-bottom: 4px;
}
.disclaimer-text {
  font-size: 0.82rem;
  color: #d1d5db;
  line-height: 1.45;
}

/* Filter Controls Panel */
.filter-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #d1d5db;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.filter-group select,
.filter-group input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.filter-group select:focus,
.filter-group input:focus {
  border-color: var(--border-focus);
}

.filter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.active-count-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.active-count {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-amber);
}
.active-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.filter-btn-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-reset, .btn-show-all {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-reset:hover, .btn-show-all:hover {
  color: #fff;
  border-color: #6b7280;
  background: rgba(255, 255, 255, 0.05);
}
.btn-show-all {
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--accent-amber);
}

/* Results Cards Grid */
.results-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ta-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.ta-card:hover {
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 8px 16px -2px rgba(0, 0, 0, 0.5);
}

.ta-card-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.ta-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.ta-badge-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge-ta {
  background: #f59e0b;
  color: #000;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 4px;
}
.badge-fig {
  color: #d1d5db;
  font-size: 0.8rem;
  font-weight: 600;
}
.citation-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 4px;
}
.ta-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.35;
}
.ta-category {
  font-size: 0.8rem;
  color: var(--accent-amber);
  margin-bottom: 10px;
}

/* Criteria Pills */
.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pill {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 9999px;
  background: #1f2937;
  color: #9ca3af;
  border: 1px solid #374151;
}

/* Card Body */
.ta-card-body {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
}
@media (max-width: 860px) {
  .ta-card-body {
    grid-template-columns: 1fr;
  }
}

/* Notes Section */
.notes-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.note-block {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.83rem;
  line-height: 1.48;
}
.note-standard {
  background: rgba(239, 68, 68, 0.09);
  border-left: 3px solid var(--accent-red);
}
.note-guidance {
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid var(--accent-amber);
}
.note-option {
  background: rgba(59, 130, 246, 0.08);
  border-left: 3px solid var(--accent-blue);
}
.note-support {
  background: rgba(156, 163, 175, 0.08);
  border-left: 3px solid #6b7280;
}
.note-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.note-standard .note-label { color: #f87171; }
.note-guidance .note-label { color: #fbbf24; }
.note-option .note-label { color: #60a5fa; }
.note-support .note-label { color: #9ca3af; }

.note-item {
  margin-bottom: 6px;
}
.note-item:last-child {
  margin-bottom: 0;
}
.note-num {
  font-weight: 700;
  color: #fff;
  margin-right: 4px;
}

/* Accordion for Guidance/Options on mobile */
.notes-accordion-toggle {
  background: #1f2937;
  color: #d1d5db;
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 4px;
  transition: all 0.2s;
}
.notes-accordion-toggle:hover {
  background: #283344;
  color: #fff;
  border-color: #4b5563;
}
.notes-accordion-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.notes-accordion-content.collapsed {
  display: none;
}

/* Signs list */
.signs-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.signs-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.sign-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sign-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1f2937;
  border: 1px solid #374151;
  color: #fff;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.78rem;
  transition: all 0.2s;
}
.sign-badge:hover {
  background: #374151;
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}
.sign-badge .sign-code {
  font-weight: 700;
  color: var(--accent-amber);
}
.sign-badge .sign-size {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Diagram Preview Column */
.diagram-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.diagram-thumb-wrap {
  position: relative;
  width: 100%;
  max-width: 260px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  transition: transform 0.2s;
}
.diagram-thumb-wrap:hover {
  transform: scale(1.02);
  border-color: var(--accent-amber);
}
.diagram-thumb {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}
.diagram-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
  padding: 8px;
}
.diagram-thumb-wrap:hover .diagram-overlay {
  opacity: 1;
}

.btn-open-diagram {
  width: 100%;
  max-width: 260px;
  background: #1f2937;
  color: #fff;
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-open-diagram:hover {
  background: #374151;
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

.btn-calc-link {
  width: 100%;
  max-width: 260px;
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-calc-link:hover {
  background: var(--accent-amber);
  color: #000;
}

/* Modal for High-Res Diagram Inspection with Zoom Controls */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 1000px;
  width: 100%;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.7);
}
.modal-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #111827;
}
.modal-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.modal-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: #fff;
}
.modal-citation {
  font-size: 0.75rem;
  color: var(--accent-amber);
}

.modal-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-zoom {
  background: #1f2937;
  color: #d1d5db;
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-zoom:hover {
  color: #fff;
  border-color: #6b7280;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
.modal-close:hover {
  color: #fff;
}
.modal-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: block;
  background: #e2e8f0;
  touch-action: pan-x pan-y;
}
.modal-body img {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  transition: width 0.2s ease;
}

.diagram-thumb-wrap {
  border: 0;
  padding: 0;
  width: 100%;
  text-align: inherit;
  cursor: pointer;
}
.diagram-thumb-wrap:focus-visible,
.filter-panel button:focus-visible,
.filter-diagnostics summary:focus-visible,
.modal-controls button:focus-visible {
  outline: 3px solid var(--accent-amber);
  outline-offset: 3px;
}
.filter-diagnostics {
  margin: 14px 0 20px;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--card-bg, #172033);
  color: var(--text-muted);
}
.filter-diagnostics[hidden] { display: none; }
.filter-diagnostics summary { cursor: pointer; color: #fff; font-weight: 700; }
.filter-diagnostics p { margin: 10px 0; }
.filter-diagnostics .filter-error { color: #fecaca; }
.sign-match-evidence {
  margin: 9px 0;
  padding: 8px 10px;
  border-left: 3px solid var(--accent-amber);
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.12);
  color: #fff;
  font-size: 0.9rem;
}
.classification-evidence {
  margin: 8px 0;
  color: #fde68a;
  font-size: 0.84rem;
  line-height: 1.45;
}
.exclusion-list {
  max-height: 360px;
  overflow: auto;
  padding-left: 20px;
  line-height: 1.55;
}
.exclusion-list li { margin: 8px 0; }

/* Empty State */
.no-results {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}
.no-results h3 {
  color: #fff;
  margin-bottom: 8px;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .finder-container {
    padding: 16px 12px 48px;
  }
  .finder-header h1 {
    font-size: 1.35rem;
  }
  .filter-panel {
    padding: 14px;
  }
  .ta-card-header {
    padding: 14px;
  }
  .ta-card-body {
    padding: 14px;
  }
  .ta-title {
    font-size: 1.02rem;
  }
  .modal-content {
    height: 94vh;
    padding: 0;
  }
  .modal-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .modal-controls {
    width: 100%;
    justify-content: space-between;
    margin-top: 6px;
  }
}

/* Print Stylesheet */
@media print {
  .site-header,
  .sibling-tools-bar,
  .filter-panel,
  .btn-open-diagram,
  .btn-calc-link,
  .notes-accordion-toggle,
  .modal-backdrop,
  footer {
    display: none !important;
  }
  .notes-accordion-content.collapsed {
    display: flex !important;
  }
  body, .finder-container {
    background: #fff !important;
    color: #000 !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
  .ta-card {
    border: 1px solid #999 !important;
    page-break-inside: avoid;
    margin-bottom: 24px;
    background: #fff !important;
    color: #000 !important;
  }
  .ta-title {
    color: #000 !important;
  }
  .note-standard, .note-guidance, .note-option, .note-support {
    background: #f8fafc !important;
    border-color: #475569 !important;
    color: #000 !important;
  }
  .note-num {
    color: #000 !important;
  }
  .diagram-thumb-wrap {
    max-width: 240px !important;
  }
}
