/**
 * Shared primitives for the school detail sections, mirroring
 * components/compare/sectionShared.tsx.
 *
 * Deliberately minimal: the sections were extracted as verbatim moves from the
 * two detail views, so wrapping their markup in heavyweight primitives would
 * risk changing the DOM the CSS modules depend on. This provides only the
 * outer <section> shell every section shares, plus the stylesheet.
 *
 * All section components are SERVER components — no 'use client' anywhere in
 * this directory except AdmissionsViewToggle.
 */

import type { ReactNode } from 'react';
import styles from './schoolSections.module.css';

export const sectionStyles = styles;

/** Tone class for a progress score: positive, negative, or neutral. */
export function progressClass(val: number | null | undefined): string {
  if (val == null) return '';
  if (val > 0) return styles.progressPositive;
  if (val < 0) return styles.progressNegative;
  return '';
}

/**
 * The section shell. `id` must match the id buildNavItems emits, because the
 * sticky nav's scroll-spy locates sections with document.getElementById.
 */
export function Section({
  id,
  children,
}: {
  id: string;
  children: ReactNode;
}) {
  return (
    <section id={id} className={styles.card}>
      {children}
    </section>
  );
}
