/* NJ School Performance Lookup — 2024-25
   Styled in the NJ.com data-explorer family (matches NJ School Spending Explorer)
   but using the NJ.com red brand color. */

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

:root {
  --red:       #B8232F;   /* NJ.com brand red */
  --red-dark:  #8A1822;
  --red-soft:  #FFF1F2;
  --charcoal:  #2D2D2D;
  --darkgray:  #444;
  --midgray:   #888;
  --lightgray: #E8E8E8;
  --offwhite:  #F7F7F5;
  --white:     #FFF;
  --blue:      #2271B1;
  --green:     #1B8C3D;
  --orange:    #E67E22;
  --gold:      #BCD031;  /* hero accent (lime green, matches reference) */

  --font-sans:  'Libre Franklin', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Noto Serif', Georgia, "Times New Roman", serif;

  --max-w: 1200px;
  --radius: 8px;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  color: var(--charcoal);
  background: var(--offwhite);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===================== Site header ===================== */
.site-header {
  background: var(--charcoal);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.site-header img { height: 36px; width: auto; flex-shrink: 0; }
.site-header .tag {
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ===================== Hero ===================== */
.hero {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
  color: var(--white);
  padding: 48px 20px 40px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}
.hero-inner { max-width: var(--max-w); margin: 0 auto; position: relative; z-index: 1; }
.hero h1 {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 900;
  line-height: 1.15;
  margin-bottom: 8px;
}
.hero h1 span { color: var(--gold); }
.hero .subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(15px, 2.5vw, 18px);
  color: rgba(255, 255, 255, 0.78);
  max-width: 720px;
  margin-bottom: 28px;
}
.hero .source { font-size: 12px; color: rgba(255, 255, 255, 0.5); margin-top: 24px; }
.hero .source a { color: var(--gold); }
.hero .source a:hover { color: #fff; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.stat-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 16px 14px;
  backdrop-filter: blur(4px);
}
.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 800;
  color: var(--gold);
}
.stat-card .note { font-size: 11px; color: var(--gold); opacity: 0.8; margin-top: 4px; font-weight: 600; }

/* ===================== Search section ===================== */
.search-section {
  background: var(--white);
  border-bottom: 1px solid var(--lightgray);
  padding: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}
.search-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(240px, 2fr) repeat(3, minmax(150px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.search-box { position: relative; }
.search-box label,
.filter-select label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--midgray);
  margin-bottom: 4px;
}
.search-box .field-wrap { position: relative; }
.search-box input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 2px solid var(--lightgray);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font-sans);
  background: var(--white);
  color: var(--charcoal);
  transition: border-color 0.2s;
}
.search-box input::placeholder { color: var(--midgray); }
.search-box input:focus { outline: none; border-color: var(--red); }
.search-box .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--midgray);
  pointer-events: none;
  width: 18px;
  height: 18px;
}
.search-box .results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--lightgray);
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 340px;
  overflow-y: auto;
  display: none;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.search-box .results.show { display: block; }
.search-box .results .item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.search-box .results .item:last-child { border-bottom: none; }
.search-box .results .item:hover,
.search-box .results .item.active { background: var(--red-soft); color: var(--red-dark); }
.search-box .results .item .meta { font-size: 12px; color: var(--midgray); }
.search-box .results .item .badge {
  display: inline-block;
  font-size: 10px;
  background: var(--blue);
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  font-weight: 700;
}
.search-box .results .item .badge.district { background: var(--red); }
.search-box .results .item .name { font-weight: 600; color: var(--charcoal); }
.search-box .results .item:hover .name,
.search-box .results .item.active .name { color: var(--red-dark); }

.filter-select select {
  width: 100%;
  padding: 12px 36px 12px 16px;
  border: 2px solid var(--lightgray);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-sans);
  background-color: var(--white);
  color: var(--charcoal);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.filter-select select:focus { outline: none; border-color: var(--red); }
.filter-select select:disabled {
  background-color: #f5f5f3;
  color: #b6b6b6;
  cursor: not-allowed;
}

.btn-reset {
  padding: 12px 18px;
  border: 2px solid var(--lightgray);
  background: var(--white);
  color: var(--darkgray);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-reset:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-soft);
}

/* ===================== Main ===================== */
.main { max-width: var(--max-w); margin: 0 auto; padding: 24px 20px 60px; }

/* Landing / empty state */
.landing-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--lightgray);
  padding: 32px;
  text-align: center;
  margin-top: 20px;
}
.landing-card h3 { font-size: 20px; font-weight: 700; margin-bottom: 8px; color: var(--charcoal); }
.landing-card p { color: var(--midgray); font-size: 15px; max-width: 560px; margin: 0 auto 12px; }
.landing-tips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 24px;
  text-align: left;
}
.landing-tip {
  padding: 16px;
  background: var(--offwhite);
  border-radius: var(--radius);
  border: 1px solid var(--lightgray);
}
.landing-tip .ti { font-size: 22px; margin-bottom: 6px; }
.landing-tip h4 { font-size: 14px; font-weight: 700; margin-bottom: 4px; color: var(--charcoal); }
.landing-tip p { font-size: 13px; color: var(--midgray); margin: 0; }

.county-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 20px;
}
.county-btn {
  padding: 10px 14px;
  border: 1px solid var(--lightgray);
  border-radius: var(--radius);
  background: var(--white);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  color: var(--charcoal);
}
.county-btn:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.county-btn .num { color: var(--midgray); font-weight: 500; margin-left: 6px; font-size: 12px; }

/* Loading */
.loading-state { text-align: center; padding: 60px 20px; color: var(--midgray); font-size: 14px; }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--lightgray);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Entity (district or school detail) */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
  cursor: pointer;
  margin-bottom: 14px;
  padding: 6px 0;
  border: none;
  background: none;
  font-family: var(--font-sans);
}
.back-btn:hover { text-decoration: underline; }

.dist-header h2 {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 800;
  color: var(--charcoal);
  letter-spacing: -0.01em;
}
.dist-header .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.chip {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--lightgray);
  color: var(--darkgray);
  display: inline-flex;
  align-items: center;
}
.chip.county { background: #E8F4FD; color: var(--blue); }
.chip.district { background: var(--red-soft); color: var(--red-dark); }
.chip.code { background: #F4F2EC; color: var(--darkgray); font-variant-numeric: tabular-nums; }

.contact-card {
  background: var(--white);
  border: 1px solid var(--lightgray);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 20px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 24px;
}
.contact-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  color: var(--midgray);
  margin-bottom: 2px;
}
.contact-card .value { font-size: 14px; color: var(--charcoal); word-break: break-word; }
.contact-card .value a { word-break: break-word; }

/* Section heading + body */
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 32px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--lightgray);
  color: var(--charcoal);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.section-title:hover { color: var(--red); }
.section-title .count {
  font-size: 11px;
  font-weight: 600;
  background: var(--offwhite);
  color: var(--midgray);
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.section-title .chev {
  display: inline-block;
  margin-right: 8px;
  color: var(--midgray);
  transition: transform 0.2s;
  font-size: 13px;
}
.section.open .section-title .chev { transform: rotate(90deg); color: var(--red); }
.section.open .section-title { color: var(--red); }
.section-body { display: none; }
.section.open .section-body { display: block; }

/* Subsection (one sheet) */
.subsection { margin: 18px 0 26px; }
.subsection h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 4px;
  letter-spacing: -0.005em;
}
.subsection .desc {
  font-size: 12px;
  color: var(--midgray);
  margin-bottom: 10px;
}

/* Data tables (match .dt from reference) */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--lightgray);
  border-radius: var(--radius);
  background: var(--white);
}
.dt {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.dt th {
  text-align: right;
  padding: 8px 10px;
  background: #F8F8F6;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--midgray);
  border-bottom: 2px solid var(--lightgray);
  border-right: 1px solid var(--lightgray);
  white-space: normal;
  overflow-wrap: break-word;
  vertical-align: bottom;
  line-height: 1.2;
  max-width: 130px;
  min-width: 64px;
  position: sticky;
  top: 0;
  z-index: 1;
}
.dt th:last-child { border-right: none; }
.dt th:first-child,
.dt td:first-child {
  text-align: left; /* label column reads left-to-right */
}
.dt td {
  padding: 8px 10px;
  border-bottom: 1px solid #F0F0F0;
  border-right: 1px solid #F0F0F0;
  vertical-align: top;
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.dt td:last-child { border-right: none; }
.dt tr:last-child td { border-bottom: none; }
.dt tbody tr:hover td { background: #FAFAF8; }
.dt td.num { font-weight: 600; }
.dt td.null { color: #BABABA; }
.dt td.label-cell { font-weight: 600; color: var(--charcoal); text-align: left; }

/* Footer */
.footer {
  background: var(--charcoal);
  color: rgba(255, 255, 255, 0.6);
  padding: 28px 20px;
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
}
.footer a { color: var(--gold); }
.footer a:hover { color: var(--white); text-decoration: underline; }

/* ===================== Responsive ===================== */
@media (max-width: 900px) {
  .search-inner {
    grid-template-columns: 1fr 1fr;
  }
  .search-inner .search-box { grid-column: 1 / -1; }
  .btn-reset { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .site-header { padding: 8px 14px; gap: 10px; }
  .site-header img { height: 28px; }
  .site-header .tag { font-size: 11px; }
  .hero { padding: 28px 16px 24px; }
  .hero .subtitle { margin-bottom: 18px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .search-section { padding: 14px; }
  .search-inner { grid-template-columns: 1fr; }
  .main { padding: 16px 14px 60px; }
  .contact-card { padding: 14px 16px; gap: 10px 16px; }
  .dt { font-size: 12px; }
  .dt th, .dt td { padding: 8px 10px; }
  .section-title { font-size: 16px; }
  .landing-card { padding: 22px 16px; }
}

@media print {
  .search-section, .footer, .back-btn { display: none !important; }
}
