/* ============================================================
   UK Medical Schools Comparison Tool — Stylesheet
   Clinical / academic aesthetic. Max-width 1200px.
   ============================================================ */

/* --- Reset & custom properties --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:            #f4f5f7;
  --card-bg:       #ffffff;
  --border:        #e2e5ea;
  --border-light:  #eef0f3;
  --text-primary:  #1a1d23;
  --text-secondary:#4b5563;
  --text-muted:    #9ca3af;
  --accent:        #1a4a7a;
  --accent-mid:    #2563a8;
  --accent-light:  #edf3fb;
  --accent-border: #c5d8ef;
  --tag-bg:        #f0f4fa;
  --tag-text:      #1a4a7a;
  --green-bg:      #ecfdf5;
  --green-text:    #065f46;
  --amber-bg:      #fffbeb;
  --amber-text:    #92400e;
  --red-bg:        #fef2f2;
  --red-text:      #991b1b;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.06), 0 1px 8px rgba(0,0,0,0.04);
  --shadow:        0 1px 4px rgba(0,0,0,0.06), 0 3px 14px rgba(0,0,0,0.05);
  --radius:        6px;
  --max-width:     1200px;
  --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter',
                   'Helvetica Neue', Arial, sans-serif;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Layout --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

/* --- Header & Navigation --- */
.site-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 0;
  gap: 1.5rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.nav-tag {
  flex-shrink: 0;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
}

.nav-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.75rem;
  flex-shrink: 0;
}

.nav-links a {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Hero --- */
.hero {
  padding: 3.5rem 0 2rem;
}

.hero-title {
  font-size: clamp(1.5rem, 3vw, 2.125rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 620px;
  line-height: 1.65;
}

/* --- Panels --- */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.panel-heading {
  font-size: 1.1875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 1rem;
  line-height: 1.3;
}

.panel p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-bottom: 0.875rem;
  line-height: 1.7;
}

.panel p:last-child {
  margin-bottom: 0;
}

/* --- Section label row --- */
.section-label-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.625rem;
}

.section-num {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.section-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  border: 1px solid var(--accent-border);
}

.sub-label {
  font-size: 0.75rem !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted) !important;
  margin-bottom: 0.4rem !important;
}

/* --- Note / callout --- */
.note {
  background: #f9fafb;
  border-left: 3px solid var(--border);
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem !important;
  color: var(--text-muted) !important;
  border-radius: 0 4px 4px 0;
  line-height: 1.6 !important;
}

/* --- Flourish embed --- */
.flourish-container {
  margin: 1.5rem 0 1rem;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.flourish-container .flourish-embed {
  display: block;
  width: 100%;
}

/* --- Chart placeholders --- */
.chart-container {
  position: relative;
  margin: 1.5rem 0 1rem;
  background: #f9fafb;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  min-height: 260px;
  display: flex;
  align-items: stretch;
}

.chart-img {
  width: 100%;
  height: auto;
  display: block;
  min-height: 260px;
  object-fit: cover;
  opacity: 0.5;
}

.chart-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 12px,
    rgba(0, 0, 0, 0.015) 12px,
    rgba(0, 0, 0, 0.015) 24px
  );
}

.chart-type-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.92);
  padding: 0.35rem 0.875rem;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.chart-caption {
  font-size: 0.8125rem !important;
  color: var(--text-muted) !important;
  font-style: italic;
  line-height: 1.6 !important;
}

/* --- Intro & further panels --- */
.intro-panel {
  border-left: 3px solid var(--accent);
}

.further-panel {
  background: var(--accent-light);
  border-color: var(--accent-border);
}

/* --- Comparison table --- */
.table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-select {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8125rem;
  font-family: var(--font);
  color: var(--text-secondary);
  background: #ffffff;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.filter-select:focus {
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 3px rgba(37,99,168,0.1);
}

.search-input {
  width: 280px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.875rem;
  font-family: var(--font);
  color: var(--text-primary);
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 3px rgba(37, 99, 168, 0.1);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.table-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.comparison-table thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.comparison-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.12s, background 0.12s;
}

.comparison-table thead th.sortable:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.comparison-table thead th.sort-asc .sort-icon,
.comparison-table thead th.sort-desc .sort-icon {
  color: var(--accent);
  opacity: 1;
}

.sort-icon {
  font-size: 0.7rem;
  opacity: 0.35;
  margin-left: 0.25rem;
}

.comparison-table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: top;
  line-height: 1.5;
}

.comparison-table tbody tr:last-child td {
  border-bottom: none;
}

.comparison-table tbody tr:hover td {
  background: #fafbfc;
}

/* --- Table column widths & cell styles --- */
.th-uni      { min-width: 170px; }
.th-fees     { min-width: 170px; }
.th-travel   { min-width: 150px; }
.th-yn       { min-width: 76px;  text-align: center; }
.th-fund     { min-width: 190px; }
.th-elective { min-width: 95px;  white-space: nowrap; }
.th-expand   { width: 36px; }

.col-uni  {
  font-weight: 600;
  color: var(--text-primary) !important;
  white-space: nowrap;
}
.col-fees {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}
.col-yn       { text-align: center; vertical-align: middle !important; }
.col-fund     { font-size: 0.8125rem; max-width: 200px; }
.col-elective { font-size: 0.8125rem; white-space: nowrap; }
.col-expand   { width: 36px; text-align: center; vertical-align: middle !important; }

/* zebra striping */
.comparison-table tbody tr.data-row:nth-child(4n+1) td,
.comparison-table tbody tr.data-row:nth-child(4n+2) td {
  background: #fafbfc;
}
.comparison-table tbody tr.data-row:hover td,
.comparison-table tbody tr.data-row.row-open td {
  background: var(--accent-light) !important;
}

.fees-val {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
}

.muted {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.8125rem;
}

.expand-icon {
  display: inline-block;
  font-size: 0.65rem;
  transition: transform 0.2s ease;
  opacity: 0.4;
  color: var(--text-muted);
}

.data-row {
  cursor: pointer;
  transition: background 0.1s;
}

.data-row:hover .expand-icon { opacity: 0.9; }

.data-row.row-open .expand-icon {
  transform: rotate(180deg);
  opacity: 1;
  color: var(--accent);
}

.data-row.row-open td {
  border-bottom: none;
}

/* --- Expandable detail row --- */
.detail-row {
  display: none;
}

.detail-row[aria-hidden="false"] {
  display: table-row;
}

.detail-row td {
  padding: 0 !important;
  border-bottom: 2px solid var(--accent-border) !important;
  background: #f5f8fd;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 1.25rem 1.5rem;
  gap: 1rem 2rem;
}

.detail-block {
  min-width: 0;
}

.detail-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.detail-value {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-sub {
  margin-bottom: 0.25rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.detail-sub-label {
  font-weight: 600;
  color: var(--text-primary);
}

.resource-tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--accent-border);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  margin: 0.1rem 0.1rem 0.1rem 0;
}

.na-cell {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.8125rem;
}

.table-note {
  font-size: 0.75rem !important;
  color: var(--text-muted) !important;
  margin-top: 0.75rem !important;
  font-style: italic;
}

/* --- Badges --- */
.badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.b-yes    { background: var(--green-bg); color: var(--green-text); }
.b-no     { background: var(--red-bg);   color: var(--red-text);   }
.b-nr     { background: #f3f4f6;         color: var(--text-muted); }
.b-travel { background: #eff6ff;         color: #1d4ed8;           }

.loading-cell {
  text-align: center !important;
  color: var(--text-muted) !important;
  padding: 2.5rem !important;
  font-style: italic;
}

/* --- About page list --- */
.about-list {
  list-style: none;
  margin: 0.5rem 0 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.about-list li {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-left: 1.25rem;
  position: relative;
}

.about-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-border);
}

.about-list strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--border);
  background: #ffffff;
  margin-top: 3rem;
}

.footer-inner {
  padding: 2rem 0;
}

.footer-text {
  font-size: 0.8125rem !important;
  font-weight: 600;
  color: var(--text-secondary) !important;
  margin-bottom: 0.25rem !important;
}

.footer-note {
  font-size: 0.75rem !important;
  color: var(--text-muted) !important;
  margin-bottom: 0 !important;
}

/* --- Utilities --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .nav-title { display: none; }
}

@media (max-width: 680px) {
  .container { padding: 0 1rem; }

  .panel { padding: 1.5rem 1.25rem; }

  .hero { padding: 2.25rem 0 1.5rem; }

  .table-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input { width: 100%; }

  .comparison-table thead th,
  .comparison-table tbody td {
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
  }

  .detail-grid {
    grid-template-columns: 1fr 1fr;
  }

  .filter-group {
    width: 100%;
  }

  .filter-select {
    flex: 1;
    min-width: 140px;
  }
}

@media (max-width: 480px) {
  .nav-links { gap: 1rem; }
  .hero-title { font-size: 1.375rem; }
}
