/* ============================================================
   AARG WEBSITE — SHARED STYLES + THREE THEMES
   Light (default) | Dark | Pirate
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,wght@0,300;0,400;0,600;1,300;1,400&family=DM+Sans:wght@300;400;500;600&family=UnifrakturMaguntia&family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,700&family=IM+Fell+English:ital@0;1&display=swap');

/* ── CSS VARIABLES ─────────────────────────────────────────── */

:root,
body.theme-light,
html.theme-light {
  --bg-primary:       #fafaf8;
  --bg-secondary:     #f0ede8;
  --bg-card:          #ffffff;
  --text-primary:     #1a1a1a;
  --text-secondary:   #555550;
  --text-muted:       #6e6e68;
  --accent:           #4b2e83;
  --accent-hover:     #3a2268;
  --accent-gold:      #b7a57a;
  --accent-gold-dark: #6b5c3e;
  --border:           #e2ddd6;
  --border-strong:    #c8c2b8;
  --nav-bg:           #ffffff;
  --nav-border:       #e2ddd6;
  --shadow:           0 2px 12px rgba(75, 46, 131, 0.08);
  --shadow-hover:     0 6px 24px rgba(75, 46, 131, 0.14);
  --font-display:     'Source Serif 4', Georgia, serif;
  --font-body:        'DM Sans', sans-serif;
  --font-accent:      'Source Serif 4', Georgia, serif;
  --radius:           6px;
  --radius-lg:        12px;
  --transition:       0.2s ease;
}

body.theme-dark,
html.theme-dark {
  --bg-primary:       #0f0e0d;
  --bg-secondary:     #1a1917;
  --bg-card:          #201e1c;
  --text-primary:     #f0ede8;
  --text-secondary:   #b8b4ad;
  --text-muted:       #9e9890;
  --accent:           #8b6bbf;
  --accent-hover:     #a484d8;
  --accent-gold:      #b7a57a;
  --accent-gold-dark: #c9a96e;
  --border:           #2e2b28;
  --border-strong:    #403c38;
  --nav-bg:           #141312;
  --nav-border:       #2e2b28;
  --shadow:           0 2px 12px rgba(0, 0, 0, 0.4);
  --shadow-hover:     0 6px 24px rgba(0, 0, 0, 0.6);
  --font-display:     'Source Serif 4', Georgia, serif;
  --font-body:        'DM Sans', sans-serif;
  --font-accent:      'Source Serif 4', Georgia, serif;
}

body.theme-pirate,
html.theme-pirate {
  --bg-primary:       #f2e8d9;
  --bg-secondary:     #e8dcc8;
  --bg-card:          #f7f0e4;
  --text-primary:     #3a2e22;
  --text-secondary:   #6b5a47;
  --text-muted:       #7a6a58;
  --accent:           #7a6248;
  --accent-hover:     #5e4a35;
  --accent-gold:      #b09a6e;
  --accent-gold-dark: #5e4d30;
  --border:           #d4c4a8;
  --border-strong:    #b8a484;
  --nav-bg:           #e8dcc8;
  --nav-border:       #d4c4a8;
  --shadow:           0 2px 12px rgba(58, 46, 34, 0.10);
  --shadow-hover:     0 6px 24px rgba(58, 46, 34, 0.18);
  --font-display:     'UnifrakturMaguntia', 'Playfair Display', serif;
  --font-body:        'IM Fell English', 'Playfair Display', Georgia, serif;
  --font-accent:      'IM Fell English', 'Playfair Display', Georgia, serif;
}

/* Prevent flash of wrong theme before body renders */
html.theme-dark  { background-color: #0f0e0d; }
html.theme-pirate { background-color: #f2e8d9; }
html.theme-light  { background-color: #fafaf8; }

/* ── RESET + BASE ───────────────────────────────────────────── */

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

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  transition: background-color 0.4s ease, color 0.4s ease;
  min-height: 100vh;
}

/* ── PIRATE TEXTURE OVERLAY ─────────────────────────────────── */

body.theme-pirate::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.5;
}

/* ── NAVIGATION ─────────────────────────────────────────────── */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  backdrop-filter: blur(8px);
  transition: background 0.4s ease, border-color 0.4s ease;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1.5rem;
}

.nav-logo {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.nav-logo:hover {
  color: var(--accent-hover);
}

body.theme-pirate .nav-logo {
  font-size: 1.4rem;
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
  align-items: center;
}

.nav-links a {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: color 0.2s ease;
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  right: 0;
  height: 1.5px;
  background: var(--accent-gold);
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
}

.nav-links a:hover::after,
.nav-links a.active::after {
  transform: scaleX(1);
}

body.theme-pirate .nav-links a {
  font-family: var(--font-body);
  text-transform: none;
  font-style: italic;
  font-size: 1rem;
}

/* ── SEARCH BAR (EASTER EGG) ────────────────────────────────── */

.nav-search {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-search input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem 0.35rem 2rem;
  border-radius: 20px;
  width: 160px;
  outline: none;
  transition: all 0.2s ease;
}

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

.nav-search input:focus {
  width: 200px;
  border-color: var(--border-strong);
  background: var(--bg-card);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-search-icon {
  position: absolute;
  left: 0.55rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  pointer-events: none;
}

/* Search icon sizing in pirate mode */
body.theme-pirate .nav-search-icon {
  font-size: 0.85rem;
}

body.theme-pirate .nav-search input::placeholder {
  content: 'Search the seas...';
}

/* Pirate mode readability — IM Fell English at body, Unfraktur only for big titles */
body.theme-pirate p,
body.theme-pirate li,
body.theme-pirate .member-blurb,
body.theme-pirate .page-subtitle,
body.theme-pirate .hero-lead,
body.theme-pirate .project-desc,
body.theme-pirate .research-card-desc {
  font-size: 1rem;
  line-height: 1.8;
  letter-spacing: 0.01em;
}

/* Restrict UnifrakturMaguntia to large display headings only */
body.theme-pirate h1,
body.theme-pirate .page-title,
body.theme-pirate .hero-title,
body.theme-pirate .nav-logo {
  font-family: 'UnifrakturMaguntia', serif;
}

/* Smaller headings use Playfair Display — far more readable */
body.theme-pirate h2,
body.theme-pirate h3,
body.theme-pirate .member-name,
body.theme-pirate .pet-name,
body.theme-pirate .project-title,
body.theme-pirate .paper-title,
body.theme-pirate .pets-sidebar-title {
  font-family: 'Playfair Display', Georgia, serif;
}

/* Bump up nav logo size slightly since UnifrakturMaguntia reads smaller */
body.theme-pirate .nav-logo {
  font-size: 1.5rem;
  letter-spacing: 0;
}

/* ── THEME TOGGLE BUTTON ────────────────────────────────────── */

.theme-toggle {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: var(--shadow);
  transition: background 0.2s ease, border-color 0.2s ease,
              transform 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle:hover {
  box-shadow: var(--shadow-hover);
  transform: rotate(20deg) scale(1.1);
  border-color: var(--border-strong);
}

body.theme-light  .theme-toggle-icon::before { content: '🌙'; }
body.theme-dark   .theme-toggle-icon::before { content: '☀️'; }
body.theme-pirate .theme-toggle-icon::before { content: '🌙'; }



.theme-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 30px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-hover);
  z-index: 9999;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  pointer-events: none;
}

.theme-toast.show {
  transform: translateX(-50%) translateY(0);
}

body.theme-pirate .theme-toast {
  background: var(--accent);
  font-family: var(--font-accent);
  font-style: italic;
}

/* ── PAGE LAYOUT ────────────────────────────────────────────── */

.page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

.page-header {
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 300;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-top: 0.75rem;
  font-weight: 300;
}

body.theme-pirate .page-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 3.5rem);
}

/* ── ACCENT RULE ────────────────────────────────────────────── */

.accent-rule {
  width: 48px;
  height: 2px;
  background: var(--accent-gold);
  margin: 1rem 0;
}

body.theme-pirate .accent-rule {
  background: var(--accent);
  width: 64px;
}

/* ── CARDS ──────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

body.theme-pirate .card {
  border-radius: 2px;
  border-width: 2px;
  border-color: var(--accent-gold);
}

/* ── BUTTONS ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-outline:hover {
  background: var(--accent);
  color: #fff;
}

body.theme-pirate .btn {
  font-family: var(--font-accent);
  font-style: italic;
  border-radius: 0;
}

/* ── TYPOGRAPHY HELPERS ─────────────────────────────────────── */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--text-primary);
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

p {
  color: var(--text-secondary);
  line-height: 1.7;
}

a {
  color: var(--accent);
  transition: color 0.2s ease;
}

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

body.theme-pirate h2,
body.theme-pirate h3 {
  font-family: var(--font-display);
}

/* ── SECTION LABEL ──────────────────────────────────────────── */

.section-label {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-gold-dark);
  margin-bottom: 0.5rem;
}

body.theme-pirate .section-label {
  font-family: var(--font-body);
  text-transform: none;
  font-style: italic;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
}

/* ── FOOTER ─────────────────────────────────────────────────── */

.footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
}

.footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

body.theme-pirate .footer {
  font-family: var(--font-body);
}

/* ── ACCESSIBILITY ──────────────────────────────────────────── */

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

/* Focus styles — visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ── SCROLL REVEAL ──────────────────────────────────────────── */

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

/* ── REDUCED MOTION ─────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  html {
    scroll-behavior: auto;
  }
}

/* ── SCREEN-READER LIVE REGION ──────────────────────────────── */
.sr-live-region {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── HAMBURGER BUTTON ───────────────────────────────────────── */

.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius);
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.nav-hamburger:hover { background: var(--bg-secondary); }
.nav-hamburger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.nav-hamburger-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
  transform-origin: center;
}
.nav-hamburger[aria-expanded="true"] .nav-hamburger-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger[aria-expanded="true"] .nav-hamburger-bar:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger[aria-expanded="true"] .nav-hamburger-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── MOBILE NAV DRAWER ──────────────────────────────────────── */

.nav-mobile-drawer {
  display: none;
  flex-direction: column;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  padding: 0.75rem 1rem 1rem;
  gap: 0.25rem;
}
.nav-mobile-drawer.open { display: flex; }

.nav-mobile-drawer a {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  transition: background 0.15s ease, color 0.15s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.nav-mobile-drawer a:hover,
.nav-mobile-drawer a.active { background: var(--bg-secondary); color: var(--text-primary); }
.nav-mobile-drawer a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.nav-mobile-search { margin-top: 0.5rem; position: relative; display: flex; align-items: center; }
.nav-mobile-search-icon { position: absolute; left: 0.65rem; color: var(--text-muted); font-size: 0.85rem; pointer-events: none; }
.nav-mobile-search input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.6rem 0.75rem 0.6rem 2.1rem;
  border-radius: var(--radius);
  min-height: 44px;
  outline: none;
}
.nav-mobile-search input:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-mobile-search input::placeholder { color: var(--text-muted); }
body.theme-pirate .nav-mobile-drawer a { font-style: italic; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */

@media (max-width: 700px) {
  .nav-hamburger { display: flex; }
  .nav-links, .nav-search { display: none; }
  .nav-inner { padding: 0 1rem; height: 56px; }
  .page-container { padding: 1.5rem 1rem; }
  .btn { min-height: 44px; padding: 0.65rem 1.25rem; }
  .paper-link { min-height: 36px; padding: 0.35rem 0.75rem; font-size: 0.8rem; }
  .theme-toggle { width: 44px; height: 44px; }
}

@media (max-width: 480px) {
  .page-container { padding: 1.25rem 0.875rem; }
  .footer { padding: 1.5rem 1rem; }
}
