/* Magazine-Inspired University Directory - Mobile-First Design */
/* Inspired by Kinfolk, Cereal, and Monocle aesthetics */

:root {
  /* Magazine Color Palette - Off-white with refined accents */
  --bg: #fafaf9;
  --paper: #ffffff;
  --ink: #1a1a1a;
  --muted: #737373;
  --line: #e5e5e5;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,.05), 0 20px 60px rgba(0,0,0,.12);
  
  /* Editorial Typography */
  --serif: "Playfair Display", "Georgia", "Cambria", "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "Monaco", "Courier New", monospace;
  
  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
}

/* ========== Base Styles ========== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--ink);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent);
}

/* AdSense (avoid inline styles for CSP) */
.adsbygoogle--block {
  display: block;
}

/* ========== Layout Container ========== */
.wrap {
  width: min(1200px, 94vw);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.muted {
  color: var(--muted);
}

/* ========== Minimal Navigation ========== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 250, 249, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  transition: transform 0.3s ease;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  left: var(--space-md);
  top: var(--space-md);
  width: auto;
  height: auto;
  padding: var(--space-sm) var(--space-md);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  z-index: 101;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: var(--space-lg) 0;
  max-width: 1200px;
  margin: 0 auto;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
}

.brand__kicker {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.brand__title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  gap: var(--space-sm);
}

.nav__link {
  padding: var(--space-sm) var(--space-md);
  font-size: 14px;
  font-weight: 500;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.nav__link:hover {
  background: var(--line);
}

/* Header Browse dropdown (button + vertical country list) */
.nav__dropdown { position: relative; }
.nav__dropdown > summary { list-style: none; cursor: pointer; }
.nav__dropdown > summary::-webkit-details-marker { display: none; }
.nav__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  max-height: 60vh;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 30;
}
.nav__menuitem {
  display: block;
  padding: var(--space-sm) var(--space-md);
  border-radius: 4px;
  text-decoration: none;
  color: var(--ink);
}
.nav__menuitem:hover { background: var(--line); }
.nav__menuitem[aria-current="true"] { background: var(--accent-light); }

/* ========== Hero Section ========== */
.hero {
  padding: var(--space-3xl) 0 var(--space-2xl);
  background: linear-gradient(to bottom, var(--bg), var(--paper));
}

.hero__grid {
  display: grid;
  gap: var(--space-2xl);
}

.kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.display {
  font-family: var(--serif);
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0 0 var(--space-lg);
  color: var(--ink);
}

.deck {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
  max-width: 65ch;
  margin: 0;
}

/* ========== Featured Cards & Aside ========== */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card--aside {
  padding: var(--space-xl);
  margin: var(--space-lg) 0;
}

.h {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 var(--space-lg);
  letter-spacing: -0.02em;
}

.h--section {
  margin-top: var(--space-2xl);
}

.compact {
  list-style: none;
  padding: 0;
  margin: 0;
}

.compact li {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
}

.compact li:last-child {
  border-bottom: none;
}

.compact a {
  font-weight: 500;
  flex: 1;
}

.compact a:hover {
  color: var(--accent);
}

/* ========== Search & Filters ========== */
.page {
  padding: var(--space-2xl) 0;
}

.filters {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: var(--space-xl);
  margin: var(--space-xl) 0;
  box-shadow: var(--shadow);
}

.filters__row {
  display: grid;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.filters__row:last-child {
  margin-bottom: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.field__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

input, select, textarea {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 2px;
  padding: var(--space-md);
  font-family: var(--sans);
  font-size: 15px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.filters__actions {
  display: flex;
  gap: var(--space-md);
  align-items: end;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  border-radius: 2px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
  transform: translateY(-1px);
}

.btn--ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.btn--ghost:hover {
  background: var(--line);
  border-color: var(--muted);
  color: var(--ink);
}

.btn--tiny {
  padding: var(--space-sm) var(--space-md);
  font-size: 12px;
}

/* ========== Index Meta & Toggle ========== */
.index-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin: var(--space-xl) 0 var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--line);
}

.toggle {
  display: flex;
  gap: var(--space-sm);
}

/* ========== Card Grid ========== */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
}

.card__media {
  display: block;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  aspect-ratio: 16 / 9;
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.card:hover .card__media img {
  transform: scale(1.05);
}

.ph {
  height: 100%;
  border: 1px dashed var(--line);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}

.card__body {
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.pill {
  display: inline-flex;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.card__title {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.card__title a {
  text-decoration: none;
  transition: color 0.2s ease;
}

.card__title a:hover {
  color: var(--accent);
}

.card__desc {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mini {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin: 0;
  padding-top: var(--space-md);
  border-top: 1px solid var(--line);
}

.mini dt {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.mini dd {
  margin: 0;
  font-weight: 600;
  font-size: 15px;
}

.card__actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

/* ========== Pagination ========== */
.pager {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--line);
}

/* ========== Article/Detail Page ========== */
.article {
  padding: var(--space-2xl) 0 var(--space-3xl);
}

.article__header {
  padding: var(--space-xl) 0 var(--space-2xl);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-2xl);
}

.article__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.article__grid {
  display: grid;
  gap: var(--space-2xl);
}

/* ========== Gallery ========== */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.gallery__item {
  margin: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 2px;
  background: var(--bg);
}

.gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery__item:hover img {
  transform: scale(1.05);
}

/* ========== Prose/Content Block ========== */
.prose {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow);
}

.prose h2 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 var(--space-lg);
  letter-spacing: -0.02em;
}

.prose p {
  margin: 0 0 var(--space-md);
  line-height: 1.7;
}

.prose p:last-child {
  margin-bottom: 0;
}

/* ========== Tags ========== */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: 0;
  margin: 0;
  list-style: none;
}

.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg);
  transition: all 0.2s ease;
}

.tag:hover {
  background: var(--line);
  border-color: var(--muted);
}

/* ========== Facts/Data List ========== */
.facts {
  display: grid;
  gap: var(--space-md);
  margin: 0 0 var(--space-xl);
}

.facts dt {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.facts dd {
  margin: 0;
  font-weight: 600;
  font-size: 16px;
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--line);
}

.facts dd:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

/* ========== Map (OpenStreetMap) ========== */
.map {
  margin: var(--space-xl) 0;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.map iframe {
  width: 100%;
  height: 400px;
  border: 0;
  display: block;
}

/* ========== Table ========== */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 2px;
  margin: var(--space-xl) 0;
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  background: var(--paper);
}

.table th,
.table td {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

.table th {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--bg);
  color: var(--muted);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover {
  background: var(--bg);
}

/* ========== Footer ========== */
.site-footer {
  border-top: 1px solid var(--line);
  padding: var(--space-2xl) 0;
  background: var(--bg);
  margin-top: var(--space-3xl);
}

/* ========== Responsive Breakpoints ========== */
@media (min-width: 640px) {
  .filters__row {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .cards {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .hero__grid {
    grid-template-columns: 2fr 1fr;
    gap: var(--space-3xl);
  }
}

@media (min-width: 1024px) {
  .filters__row {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .cards {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .article__grid {
    grid-template-columns: 2fr 1fr;
    gap: var(--space-3xl);
  }
  
  .mini {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========== Animations ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeIn 0.5s ease forwards;
}

/* Stagger animation for cards */
.cards .card:nth-child(1) { animation-delay: 0.05s; }
.cards .card:nth-child(2) { animation-delay: 0.1s; }
.cards .card:nth-child(3) { animation-delay: 0.15s; }
.cards .card:nth-child(4) { animation-delay: 0.2s; }
.cards .card:nth-child(5) { animation-delay: 0.25s; }
.cards .card:nth-child(6) { animation-delay: 0.3s; }

/* Smooth scroll */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* Accessibility: Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========== Enhanced Focus Styles ========== */
body.keyboard-nav *:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

body.keyboard-nav *:focus:not(:focus-visible) {
  outline: none;
}

/* ========== Print Styles ========== */
@media print {
  .site-header,
  .site-footer,
  .filters,
  .btn,
  .pager {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* ========== Loading States ========== */
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* ========== Selection Styling ========== */
::selection {
  background: var(--accent-light);
  color: var(--ink);
}

/* ========== Enhanced Card Hover ========== */
.card__media::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.3));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover .card__media::after {
  opacity: 1;
}

/* ========== Improved Typography ========== */
.display {
  text-wrap: balance;
}

.deck {
  text-wrap: pretty;
}

/* ========== Custom Scrollbar (for webkit browsers) ========== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ========== Utility Classes ========== */
.field--full {
  grid-column: 1 / -1;
}

.text-sm {
  font-size: 13px;
}

.text-md {
  font-size: 14px;
}

.font-medium {
  font-weight: 500;
}

.btn--full {
  width: 100%;
  text-align: center;
}

.facts--spaced {
  margin-top: var(--space-lg);
}

.link-sm {
  font-size: 14px;
}

.section-note {
  font-size: 14px;
  margin-bottom: var(--space-lg);
}

.indicator-dd {
  font-size: 14px;
}

.footer__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-lg);
  padding: var(--space-xl) 0;
}

.footer__copyright {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.footer__tagline {
  margin: var(--space-xs) 0 0;
  font-size: 13px;
}

.footer__nav {
  display: flex;
  gap: var(--space-lg);
  font-size: 14px;
}

.map-link {
  margin-top: var(--space-md);
}
.footer__inner{display:flex; flex-direction:column; gap:6px}

@media (min-width: 840px){
  .hero__grid{grid-template-columns: 2fr 1fr; align-items:start}
  .filters__row{grid-template-columns: 2fr 1fr 1fr}
  .filters__row:nth-child(2){grid-template-columns: 1fr 1fr 1fr auto}
  .cards{grid-template-columns: repeat(3, 1fr)}
  .article__grid{grid-template-columns: 2fr 1fr}
  .gallery{grid-template-columns: repeat(3, 1fr)}
  .toggle{display:flex; gap:8px}
  .footer__inner{flex-direction:row; justify-content:space-between; align-items:center}
}
