/* ==========================================================================
   1. VARIABLES & THEMES
   ========================================================================== */
:root {
  /* LIGHT - Brand Colors */
  --bg: #ffffff;
  --text: #000000;
  --muted: #000000;
  --muted-2: #000000;
  --ku-grey: #7a7a7a;
  --ku-green: #325d3d;

  /* UI Elements */
  --line: rgba(0, 0, 0, .12);
  --card: rgba(255, 255, 255, .92);
  --shadow: 0 18px 40px rgba(0, 0, 0, .10);
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, .08);
  --radius: 18px;
  --max: 1120px;
}

:root[data-theme="dark"] {
  /* DARK - Adjusting brand colors for visibility */
  --bg: #0b0f19;
  --text: #ffffff;
  --muted: #ffffff;
  --muted-2: #ffffff;
  --ku-grey: #a1a1aa;
  --ku-green: #6c8c74;

  --line: rgba(255, 255, 255, .14);
  --card: rgba(17, 24, 39, .72);
  --shadow: 0 18px 40px rgba(0, 0, 0, .35);
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, .28);
}

/* ==========================================================================
   2. GLOBAL STYLES
   ========================================================================== */
* { box-sizing: border-box; }
html {
  scroll-behavior: smooth; /* This makes the anchor link glide down */
}

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

/* Smooth theme transitions (prevent flash via .ready class in JS) */
body.ready, body.ready .member, body.ready .link {
  transition: background-color 260ms ease, color 260ms ease, border-color 260ms ease, box-shadow 260ms ease;
}

a { color: inherit; text-decoration: none; transition: color 0.2s ease; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

.container { max-width: var(--max); margin: 0 auto; padding: 0 22px; }
section { padding: 40px 0; }

/* Apply KU Green to all headings */
h1, h2, h3, h4, h5, h6 {
  color: var(--ku-green);
}

/* Apply KU Green to all bold text */
b, strong {
  color: var(--ku-green);
}

/* ==========================================================================
   3. NAVIGATION
   ========================================================================== */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  padding: 4px;
}

.nav-logo {
  height: 36px;
  width: auto;
  transition: all 0.2s ease;
}

.brand:hover .nav-logo {
  opacity: 0.8;
  transform: scale(1.02);
}

[data-theme="dark"] .nav-logo { filter: invert(1) brightness(2); }

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 500;
  color: var(--muted);
}

.nav-links a {
  padding: 10px 10px;
  border-radius: 999px;
  transition: all 0.2s ease;
}

.nav-links a:hover {
  background: transparent;
  color: var(--ku-green) !important;
  text-decoration: none;
}

/* Theme Toggle */
.theme-toggle {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 999px;
  transition: all 200ms ease;
}

.theme-toggle svg { width: 22px; height: 22px; }
.theme-toggle:hover { color: var(--ku-green) !important; transform: translateY(-1px); }

/* ==========================================================================
   4. HERO & LOGO ANIMATION
   ========================================================================== */
.hero-full {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  text-align: center;
  transition: min-height 1.2s cubic-bezier(0.65, 0, 0.35, 1);
}

#expandableLogo {
  font-family: "Optima", "Candara", "Segoe UI", sans-serif;
  font-size: clamp(32px, 5vw, 64px);
  font-weight: 500;
  color: var(--ku-grey);
  margin-bottom: 40px;
  margin-top: 20px;
  letter-spacing: -0.02em;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0;
  transform: translateY(-68px);
  transition: transform 1.2s cubic-bezier(0.65, 0, 0.35, 1), gap 1.5s cubic-bezier(0.65, 0, 0.35, 1);
}

#expandableLogo.expanded { gap: 0.3em; }

.logo-title b { color: var(--ku-green); font-weight: 500; }

.word { display: inline-flex; align-items: baseline; }

.ext {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  max-width: 0;
  opacity: 0;
  color: var(--ku-grey);
  vertical-align: bottom;
  position: relative;
  transition: max-width 1.2s cubic-bezier(0.65, 0, 0.35, 1), opacity 0.4s ease;
}

.logo-title.expanded .ext { max-width: 300px; opacity: 1; }

/* The Glide Cursor */
.ext::after {
  content: "";
  position: absolute;
  right: 0;
  top: 15%;
  height: 70%;
  width: 2px;
  background-color: var(--ku-green);
  opacity: 0;
}

.logo-title.expanded .ext::after {
  animation: cursor-fade-in 0.1s forwards, cursor-blink 0.8s infinite 0.2s, cursor-hide 0.2s forwards 1.2s;
}

@keyframes cursor-fade-in { to { opacity: 1; } }
@keyframes cursor-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes cursor-hide { to { opacity: 0; width: 0; } }

/* Sequence Delays */
.word:nth-child(2) .ext { transition-delay: 0.15s; }
.word:nth-child(3) .ext { transition-delay: 0.3s; }

/* Building Image & Intro Logic */
.hero-image-raw img {
  max-width: 800px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

[data-theme="dark"] .dark-toggle-img { filter: invert(1) brightness(2); }

.hero-welcome,
.hero-image-raw,
.hero-scroll {
  opacity: 0;
  max-height: 0;
  margin: 0;
  overflow: hidden;
}

.hero-welcome {
  font-size: 22px;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: var(--muted);
  transition:
    opacity 1s ease 0.6s,
    max-height 1s ease 0.6s,
    margin 1s ease 0.6s,
    color 160ms ease;
}

.hero-image-raw,
.hero-scroll {
  transition:
    opacity 1s ease 0.6s,
    max-height 1s ease 0.6s,
    margin 1s ease 0.6s;
}

.scroll-arrow { width: 32px; height: 32px; color: var(--ku-green); animation: bounce 2s infinite; }

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
  60% { transform: translateY(-4px); }
}

header,
footer,
main > section:not(.hero-full) {
  opacity: 0;
  pointer-events: none;
  /* Delay shifted to 0.6s to sync with 'Welcome to the' */
  transition: opacity 1s ease 0.6s;
}

/* State Changes via JS */
body.intro-complete .hero-full { min-height: 50vh; }
body.intro-complete #expandableLogo { transform: translateY(0); }
body.intro-complete .hero-welcome { opacity: 1; max-height: 50px; margin-bottom: 0px; }
body.intro-complete .hero-image-raw { opacity: 1; max-height: 800px; margin-top: 20px; }
body.intro-complete .hero-scroll { opacity: 1; max-height: 50px; }
body.intro-complete header, body.intro-complete footer, body.intro-complete main > section:not(.hero-full) {
  opacity: 1; pointer-events: auto;
}

body.no-intro .ext::after {
  display: none !important;
  content: none !important;
  animation: none !important;
}
body.no-intro .hero-full { min-height: 50vh !important; }
body.no-intro #expandableLogo,
body.no-intro .ext,
body.no-intro .hero-welcome,
body.no-intro .hero-image-raw,
body.no-intro .hero-scroll,
body.no-intro header,
body.no-intro footer,
body.no-intro main > section {
  opacity: 1 !important;
  pointer-events: auto !important;
  max-height: none !important;
  transition: none !important;
}
body.no-intro #expandableLogo {
  gap: 0.3em;
  transform: translateY(0);
}
body.no-intro .ext {
  max-width: 300px;
  opacity: 1;
}

/* ==========================================================================
   5. CONTENT SECTIONS & GRID
   ========================================================================= */
.description-text {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  line-height: 1.7;
  font-weight: 300;
}
.description-text strong { font-weight: 600; color: var(--ku-green); }

.section-title {
  text-align: center;
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  font-weight: 300;
  margin-bottom: 50px;
  text-transform: uppercase;
  scroll-margin-top: 100px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px 24px;
}

.member {
  grid-column: span 4;
  background: transparent;
  text-align: center;
  cursor: default;
  padding: 10px 8px;
  border-radius: 12px;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.member:hover {
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--ku-green) 4%, transparent);
}

.member-name {
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1.15rem;
  text-transform: none;
  font-weight: 300;
  letter-spacing: 0;
  margin: 0 0 10px 0;
}

.member-body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Icons styling */
.links { display: flex; justify-content: center; gap: 10px; }
.link {
  color: var(--text);
  opacity: 0.7;
  transition: color 0.3s ease, opacity 0.3s ease, transform 0.2s ease;
}
.link:hover {
  opacity: 1;
  color: var(--ku-green) !important;
  transform: translateY(-2px);
}
.icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke: currentColor;
  transition: fill 0.3s ease, stroke 0.3s ease;
}
.link span {
  display: none;
}
.icon[fill="none"] {
  fill: none;
}

.members-section {
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding-top: 10px;
}

/* ==========================================================================
   6. FOOTER
   ========================================================================== */
.ku-footer {
  margin-top: 50px;
  padding: 0 0 40px;
}

.footer-brand-strip {
  display: flex;
  align-items: flex-end;
  gap: 0;
  padding-top: 4px;
  padding-bottom: 20px;
}

.footer-brandmark {
  display: block;
  width: 180px;
  height: auto;
  flex: 0 0 auto;
}

.footer-separator {
  flex: 1;
  height: 1px;
  background: rgb(168, 0, 59);
  margin-left: -180px;
  margin-bottom: 5.56px;
}

.footer-content {
  display: flex;
  align-items: flex-start;
  padding-top: 0;
}

.footer-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

.footer-logo {
  display: none;
}

.footer-address {
  font-style: normal;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  border-left: none;
  padding-left: 0;
}

.footer-address strong {
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (max-width: 640px) {
  .footer-brandmark {
    width: clamp(150px, 34vw, 220px);
  }

  .footer-separator {
    margin-bottom: 15px;
  }
}

/* ==========================================================================
   7. RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 980px) {
  .member { grid-column: span 4; }
}

@media (max-width: 640px) {
  .nav-links { gap: 4px; }
  .nav-links a { padding: 10px 8px; }
  .member { grid-column: span 6; }
  .footer-left { flex-direction: column; align-items: flex-start; gap: 16px; }
  .footer-address { border-left: none; border-top: 1px solid var(--line); padding: 16px 0 0; }
}

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

/* ==========================================================================
   8. ICONS PREVIEW
   ========================================================================== */
.member-icons-preview {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.member-icons-preview .icon {
  width: 18px;
  height: 18px;
  opacity: 0.5;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.member-icons-preview .link:hover .icon {
  opacity: 1;
  transform: translateY(-2px);
}

/* ==========================================================================
   9. JOIN PAGE SPECIFICS
   ========================================================================== */
.join-page {
  max-width: 900px;
  margin: 0 auto;
}

.group-photo-container {
  text-align: center;
  margin-bottom: 50px;
}

.group-photo {
  width: 100%;
  max-width: 600px;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: block;
  margin: 0 auto;
}

.photo-caption {
  margin-top: 12px;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--muted);
}

.join-content {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-soft);
}

.join-content h2 {
  color: var(--ku-green);
  margin-top: 0;
}

.join-info {
  margin-top: 30px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.join-list {
  padding-left: 20px;
  margin-top: 10px;
}

.join-list li {
  margin-bottom: 8px;
}

.join-list li::marker {
  color: var(--ku-green);
}

.info-block {
  margin-bottom: 24px;
}

.info-block h4 {
  margin-bottom: 8px;
  font-size: 1.05rem;
  color: var(--ku-green);
  font-weight: 600;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin-top: 30px;
  margin-bottom: 10px;
}

.join-content a {
  color: var(--ku-green);
  font-weight: 500; /* Makes them slightly bolder to stand out */
  text-decoration: none;
}

.join-content a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.join-info h3:first-child {
  margin-top: 0px;
}

/* ==========================================================================
   10. VISITORS SECTION
   ========================================================================== */
.visitors-section {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  margin-top: 40px;
}

.guestlists h3 {
  margin-top: 30px;
  margin-bottom: 15px;
  font-size: 1.2rem;
  font-weight: 500;
}

.toggle::before {
  content: '▼ ';
  font-size: 0.8em;
  display: inline-block;
  transition: transform 0.2s ease;
}

.toggle.collapsed::before {
  transform: rotate(-90deg);
}

.visitor-data {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.6;
}

.visitor-data a {
  color: var(--ku-green);
  text-decoration: none;
}

.visitor-data a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   11. PAST MEMBERS SECTION
   ========================================================================== */
.past-members-section {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  margin-top: 40px;
}

.past-members-list {
  list-style: none;
  padding: 0;
  margin: 0;
  line-height: 1.8;
  text-align: center;
}

.past-members-list li {
  display: inline; /* Places them side-by-side */
}

/* Adds a comma and space after every list item EXCEPT the last one */
.past-members-list li:not(:last-child)::after {
  content: ", ";
  color: var(--text);
}

.past-members-list a {
  color: var(--ku-green);
  text-decoration: none;
  white-space: nowrap; /* Prevents a person's first and last name from splitting across two lines */
}

.past-members-list a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ==========================================================================
   12. RESEARCH / PAPERS SECTION
   ========================================================================== */
.research-intro {
  max-width: 800px;
  margin: 0 auto;
  text-align: left;
  font-size: 1.2rem;
  font-weight: 300;
  color: var(--text);
}

.arxiv-container {
  margin-top: 25px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.loading-text {
  text-align: center;
  color: var(--ku-grey);
  font-style: italic;
}

.paper-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.paper-item {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.paper-item:last-child {
  border-bottom: none;
}

.paper-title {
  font-size: 1.15rem;
  margin: 0 0 8px 0;
  font-weight: 500;
  line-height: 1.4;
}

.paper-title a {
  color: var(--ku-green);
  text-decoration: none;
}

.paper-title a:hover {
  text-decoration: underline;
}

.paper-authors {
  color: var(--text);
  margin: 0 0 4px 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.paper-authors strong {
  color: var(--text);
  font-weight: 600;
}

.paper-date {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

main.container section {
  padding-bottom: 10px;
}

.arxiv-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.arxiv-link:hover {
  color: var(--ku-green);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.update-timestamp {
  text-align: right;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  border-top: 1px solid var(--line);
  padding-top: 15px;
}