/* ═══════════════════════════════════════════════════════════════════════════
   Student Perks - Modern Design System
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   CSS Variables & Theme
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  /* Dark Theme (Default) */
  --bg-primary: #0a0f1a;
  --bg-secondary: #0d1526;
  --bg-tertiary: #111b2e;
  --bg-card: rgba(17, 27, 46, 0.8);
  --bg-hover: rgba(72, 160, 255, 0.08);

  --text-primary: #e8eef6;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #48a0ff;
  --accent-hover: #6bb3ff;
  --accent-glow: rgba(72, 160, 255, 0.25);

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.1);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;

  --container-max: 1140px;
  --nav-height: 64px;
}

/* Light Theme */
@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-hover: rgba(72, 160, 255, 0.06);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --accent: #0066cc;
    --accent-hover: #0052a3;
    --accent-glow: rgba(0, 102, 204, 0.15);

    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.1);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.16);
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Base Reset & Typography
   ───────────────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 20px);
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Skip Link (Accessibility)
   ───────────────────────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 600;
  z-index: 1000;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 10px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Navigation Bar
   ───────────────────────────────────────────────────────────────────────────── */
.nav-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 15, 26, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 24px;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@media (prefers-color-scheme: light) {
  .nav-header {
    background: rgba(248, 250, 252, 0.85);
  }
}

.nav-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-title h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.nav-title h1 a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.nav-title h1 a:hover {
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.nav-links a:hover {
  color: var(--accent);
  background: var(--bg-hover);
}

/* Mobile Menu Toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Main Container
   ───────────────────────────────────────────────────────────────────────────── */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 32px 24px;
}

main {
  min-height: calc(100vh - var(--nav-height) - 200px);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Ad Containers
   ───────────────────────────────────────────────────────────────────────────── */
.ad-container {
  background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 24px 0;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.ad-container p {
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 8px 0;
  opacity: 0.7;
}

/* In-feed ads (between sections) - more subtle */
.ad-inline {
  background: transparent;
  border: 1px dashed var(--border-subtle);
  padding: 12px;
  margin: 32px 0;
}

/* Bottom ad - more prominent */
.ad-bottom {
  margin-top: 48px;
  padding: 20px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Typography
   ───────────────────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.5rem; }
h3 { font-size: 1.25rem; }

p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

strong, b {
  font-weight: 600;
  color: var(--text-primary);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Tables - Modern Responsive Design
   ───────────────────────────────────────────────────────────────────────────── */
.table-wrapper {
  width: 100%;
  margin: 1.5rem 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 700px;
}

thead {
  background: linear-gradient(180deg, rgba(72, 160, 255, 0.08), rgba(72, 160, 255, 0.03));
}

thead th {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-medium);
  white-space: nowrap;
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody td {
  padding: 14px 16px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

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

/* Table Column Styling */
tbody td:first-child {
  color: var(--text-primary);
  font-weight: 600;
}

tbody td:last-child a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.8rem;
  transition: all var(--transition-fast);
}

tbody td:last-child a:hover {
  background: var(--accent-hover);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* Type badges */
tbody td strong {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Details/Summary (Collapsible Sections)
   ───────────────────────────────────────────────────────────────────────────── */
details {
  margin: 1rem 0;
}

details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 8px 0;
  user-select: none;
  transition: color var(--transition-fast);
}

details summary:hover {
  color: var(--accent);
}

details[open] summary {
  margin-bottom: 0.5rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Code Blocks
   ───────────────────────────────────────────────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-tertiary);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
}

pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 1rem 0;
}

pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Blockquotes
   ───────────────────────────────────────────────────────────────────────────── */
blockquote {
  border-left: 3px solid var(--accent);
  background: var(--bg-tertiary);
  padding: 12px 16px;
  margin: 1rem 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Lists
   ───────────────────────────────────────────────────────────────────────────── */
ul, ol {
  padding-left: 1.5rem;
  margin: 1rem 0;
  color: var(--text-secondary);
}

li {
  margin: 0.4rem 0;
}

/* Navigation Lists (Category Nav) */
nav#categories-nav ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

nav#categories-nav li {
  margin: 0;
}

nav#categories-nav a {
  display: inline-block;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

nav#categories-nav a:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Back to Top Buttons (Badge Images)
   ───────────────────────────────────────────────────────────────────────────── */
div[align="left"] a img {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  border-radius: 4px;
}

div[align="left"] a:hover img {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Horizontal Rules
   ───────────────────────────────────────────────────────────────────────────── */
hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-medium), transparent);
  margin: 2.5rem 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Footer
   ───────────────────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: 48px;
}

footer a {
  color: var(--accent);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Images & Badges
   ───────────────────────────────────────────────────────────────────────────── */
img {
  max-width: 100%;
  height: auto;
}

/* Center aligned content (from README) */
div[align="center"] {
  text-align: center;
  margin-bottom: 2rem;
}

div[align="center"] h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

div[align="center"] p {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 1rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Mobile Responsive Styles
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --nav-height: 56px;
  }

  .nav-header {
    padding: 0 16px;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    flex-direction: column;
    padding: 16px;
    gap: 4px;
  }

  .nav-links.active {
    display: flex;
  }

  .nav-links a {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
  }

  .nav-toggle {
    display: block;
  }

  .container {
    padding: 20px 16px;
  }

  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }

  div[align="center"] h1 {
    font-size: 1.8rem;
  }

  /* Tables: horizontal scroll */
  .table-wrapper {
    border-radius: var(--radius-md);
  }

  table {
    font-size: 0.85rem;
  }

  thead th,
  tbody td {
    padding: 10px 12px;
  }

  /* Category nav: stack on mobile */
  nav#categories-nav ul {
    flex-direction: column;
  }

  nav#categories-nav a {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 16px 12px;
  }

  .ad-container {
    padding: 16px;
    margin: 20px 0;
  }

  table {
    font-size: 0.8rem;
  }

  thead th,
  tbody td {
    padding: 8px 10px;
  }

  tbody td:last-child a {
    padding: 5px 10px;
    font-size: 0.75rem;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Print Styles
   ───────────────────────────────────────────────────────────────────────────── */
@media print {
  .nav-header,
  .ad-container,
  .skip-link {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  a {
    color: black;
    text-decoration: underline;
  }
}