:root {
  --bg-color: #0a0a0a;
  --text-color: #f0f0f0;
  --border-color: #333;
  --card-bg: #111;
  --card-hover-border: #555;
  --tag-bg: #222;
  --muted: #a8a8a8;
  --profile-image-size: 168px;
  --min-touch-target-size: 48px;
}

[data-theme="light"] {
  --bg-color: #f5f5f5;
  --text-color: #121212;
  --border-color: #d0d0d0;
  --card-bg: #fff;
  --card-hover-border: #888;
  --tag-bg: #e9e9e9;
  --muted: #555;
}

html {
  scroll-behavior: smooth;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
  overflow-x: hidden;
  position: relative;
}

/* Main Layout */
.main-container {
  padding: 2rem 2rem 6rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Profile Section: 60vh side-by-side hero */
.profile-section {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2.5rem;
  min-height: 60svh;
  margin-bottom: 2rem;
  max-width: 880px;
  margin-left: auto;
  margin-right: auto;
}

.profile-text {
  flex: 1;
  min-width: 0;
}

.profile-img-container {
  flex-shrink: 0;
}

.profile-img {
  width: var(--profile-image-size);
  height: var(--profile-image-size);
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-color);
  display: block;
}

.profile-img-container picture {
  display: block;
  line-height: 0;
}

.profile-name-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.profile-name-title h1 {
  margin-bottom: 1rem;
}

.profile-content {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Scroll reveal: one subtle rise per section, JS-gated only */
.js .section.reveal {
  opacity: 0;
  transform: translateY(16px);
  visibility: hidden;
}

.js .section.reveal.is-visible {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .js .section.reveal,
  .js .section.reveal.is-visible {
    opacity: 1 !important;
    transform: none !important;
    visibility: visible !important;
  }
}

@media print {
  .js .section.reveal,
  .js .section.reveal.is-visible {
    opacity: 1 !important;
    transform: none !important;
    visibility: visible !important;
  }

}

/* Typography */
h1 {
  font-size: clamp(2.25rem, 1.2rem + 4vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin-bottom: 0.75rem;
}

h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin: 0 0 2rem;
  padding-bottom: 0;
}

h2::after {
  content: '';
  display: block;
  width: 32px;
  height: 1px;
  background: var(--border-color);
  margin-top: 0.75rem;
}

p {
  margin-bottom: 1rem;
}

.bio-highlight {
  font-size: 1.3rem;
  line-height: 1.8;
  margin: 0.5rem 0 1rem;
  opacity: 0.9;
  max-width: 800px;
}

/* Tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-start;
}

.tag {
  display: inline-block;
  background: var(--tag-bg);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

/* Competitions */
.competitions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 1.25rem;
}

.competition-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  border-radius: 6px;
  transition: border-color 0.2s;
}

.competition-card:hover {
  border-color: var(--card-hover-border);
}

.competition-title {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
  margin-top: 0;
}

/* Card metadata & badges */
.card-meta {
  font-size: 0.8125rem;
  line-height: 1.5;
  min-height: 1.5em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.card-badge {
  display: inline-block;
  background: var(--tag-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
  margin-right: 0.35rem;
}

/* Single badge style for all card metadata */

/* Sections */
.section {
  margin-bottom: 5rem;
  max-width: 880px;
  margin-left: auto;
  margin-right: auto;
}

#vision {
  max-width: 640px;
  text-align: center;
}

#vision h2::after {
  margin-left: auto;
  margin-right: auto;
}

/* Projects */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 1.25rem;
}

.project-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  border-radius: 6px;
  transition: border-color 0.2s;
}

.project-card:hover {
  border-color: var(--card-hover-border);
}

.project-title {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
  margin-top: 0;
}

.project-card,
.competition-card {
  display: flex;
  flex-direction: column;
}

.project-card p,
.competition-card p,
.leadership-item p {
  font-size: 0.95rem;
  line-height: 1.65;
}

.project-title,
.competition-title {
  margin-bottom: 0.75rem;
}

.learn-more-btn {
  margin-top: auto;
  padding-top: 0.75rem;
}

/* Leadership: quiet resume rows */
.leadership-list {
  display: flex;
  flex-direction: column;
}

.leadership-item {
  padding: 1rem 0;
  border-top: 1px solid var(--border-color);
}

.leadership-list .leadership-item:last-child {
  border-bottom: 1px solid var(--border-color);
}

.leadership-title {
  font-weight: 600;
  margin-bottom: 0.375rem;
  margin-top: 0;
  font-size: 1.05rem;
}

.leadership-org {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

/* Footer */
footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.9;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  color: var(--text-color);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

footer p {
  opacity: 0.7;
  margin-bottom: 0;
  padding-bottom: 1.5rem;
}

/* Contact Buttons */
.contact-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.25rem 0 0;
  justify-content: flex-start;
}

.contact-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  min-height: 48px;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1;
  background: var(--tag-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-color);
  text-decoration: none;
  transition: border-color 0.2s;
}

.contact-button:hover {
  border-color: var(--card-hover-border);
}

.contact-button .contact-arrow {
  display: inline-flex;
  align-items: center;
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.2s, width 0.2s;
}

.contact-button:hover .contact-arrow,
.contact-button:focus-visible .contact-arrow {
  opacity: 1;
  width: 1.25em;
}

.learn-more-btn {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  gap: 6px;
  color: var(--text-color);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 14px;
}

.arrow-icon {
  flex-shrink: 0;
}

/* Header Controls */
.header-controls {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top, 0px));
  right: calc(1rem + env(safe-area-inset-right, 0px));
  display: flex;
  gap: 0.75rem;
  z-index: 900;
}

.header-left {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top, 0px));
  left: calc(1rem + env(safe-area-inset-left, 0px));
  z-index: 900;
}

.home-button {
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
}

#to-top {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

#to-top.show {
  opacity: 1;
  visibility: visible;
}

.header-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--min-touch-target-size);
  height: var(--min-touch-target-size);
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  cursor: pointer;
  transition: border-color 0.2s;
}

.header-button:hover {
  border-color: var(--card-hover-border);
}

/* NAV BREAKPOINT: 1280px — bottom bar below it, vertical rail at/above it.
   Change the min-width query below together with nothing else. */
.dotnav {
  position: fixed;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  left: 50%;
  right: auto;
  top: auto;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 900;
}

.dotnav-stars {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.25rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.375rem 0.75rem;
}

.dotnav a,
.dotnav button {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0;
  font-family: inherit;
}

.dotnav button:hover,
.dotnav button:focus-visible {
  color: var(--text-color);
}

.dotnav #theme-toggle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  font-size: 1rem;
}

.dotnav #theme-toggle:hover {
  border-color: var(--card-hover-border);
}

@media (max-width: 1279px) {
  [data-theme="light"] .dotnav-stars,
  [data-theme="light"] .dotnav #theme-toggle {
    box-shadow: 0 2px 12px rgb(0 0 0 / 0.12);
  }
}

.dotnav a span {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  transition: background-color 0.2s, border-color 0.2s;
}

.dotnav a:hover span,
.dotnav a:focus-visible span {
  border-color: var(--text-color);
}

.dotnav a.active span {
  display: none;
}

.dotnav a i {
  display: none;
  font-size: 1rem;
  color: var(--text-color);
}

.dotnav a.active i {
  display: block;
}

.dotnav a::after,
.dotnav button::after {
  display: none;
  content: attr(data-label);
  position: absolute;
  right: calc(100% + 0.75rem);
  white-space: nowrap;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.dotnav a:hover::after,
.dotnav a:focus-visible::after,
.dotnav button:hover::after,
.dotnav button:focus-visible::after,
.dotnav a.active::after {
  opacity: 1;
}

.dotnav a.active::after {
  color: var(--text-color);
}

/* Header Controls: hidden on index (constellation owns nav);
   donate/404 have no dotnav so theirs always show. */
.dotnav ~ .header-controls {
  display: none;
}

/* Vertical rail at/above the breakpoint: bare dots, no pill */
@media (min-width: 1280px) {
  .dotnav {
    top: 50%;
    bottom: auto;
    left: auto;
    right: calc(1rem + env(safe-area-inset-right, 0px));
    transform: translateY(-50%);
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }

  .dotnav-stars {
    display: contents;
  }

  .dotnav a,
  .dotnav button {
    width: 32px;
    height: 32px;
  }

  .dotnav #theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: 0;
    background: none;
    border: none;
    box-shadow: none;
  }

  .dotnav a::after,
  .dotnav button::after {
    display: block;
    opacity: 0;
  }
  .dotnav a:hover::after,
  .dotnav a:focus-visible::after,
  .dotnav button:hover::after,
  .dotnav button:focus-visible::after,
  .dotnav a.active::after {
    opacity: 1;
  }

  .main-container {
    padding-bottom: 2rem;
  }
}

/* Add spacing at top for fixed buttons */
.main-container {
  padding-top: 5rem;
}

/* 404 Page Specific Styles */
body.error-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.error-container {
  text-align: center;
  max-width: 600px;
  padding: 2rem;
  margin: 0 auto;
  position: relative;
  z-index: 10;
}

.error-code {
  font-size: 4.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  line-height: 1;
  color: var(--text-color);
}

.error-title {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

.error-message {
  font-size: 1.2rem;
  margin-bottom: 2rem;
  opacity: 0.85;
}

.buttons-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-color);
  text-decoration: none;
  transition: border-color 0.2s;
}

/* Starfield: static night sky, no motion */
#space-container {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.star {
  position: absolute;
  background-color: var(--text-color);
  border-radius: 50%;
}

.star.tiny {
  width: 1px;
  height: 1px;
  opacity: 0.18;
}

.star.small {
  width: 2px;
  height: 2px;
  opacity: 0.28;
}

.star.medium {
  width: 2px;
  height: 2px;
  opacity: 0.42;
}

.star.bright {
  width: 3px;
  height: 3px;
  opacity: 0.6;
}

.button:hover {
  border-color: var(--card-hover-border);
}

@media (max-width: 768px) {
  :root {
    --profile-image-size: 128px;
  }

  .main-container {
    padding: 1.25rem 1.25rem 5.5rem;
  }

  .profile-section {
    flex-direction: column;
    text-align: center;
    gap: 1.25rem;
    min-height: 0;
    padding-top: 2.5rem;
  }

  .profile-name-title,
  .profile-content {
    align-items: center;
    text-align: center;
  }

  .contact-buttons {
    justify-content: center;
  }

  .tags {
    justify-content: center;
  }

  h1 {
    font-size: 2.25rem;
  }

  .section {
    margin-bottom: 3.5rem;
  }

  .error-code {
    font-size: 6rem;
  }
  
  .error-title {
    font-size: 1.5rem;
  }
  
  .error-message {
    font-size: 1rem;
  }
  
  .buttons-container {
    flex-direction: column;
    align-items: center;
  }
  
  .button {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .main-container {
    padding: 1rem 1rem calc(5.5rem + env(safe-area-inset-bottom, 0px));
  }

  .bio-highlight {
    font-size: 1.05rem;
    line-height: 1.7;
  }
}

@media (max-width: 360px) {
  .dotnav a,
  .dotnav button {
    width: 36px;
    height: 36px;
  }

  .dotnav #theme-toggle {
    width: 50px;
    height: 50px;
  }

  .dotnav-stars {
    padding: 0.375rem 0.5rem;
  }
}

/* Landscape phones: compact hero */
@media (min-width: 700px) and (max-height: 500px) {
  .dotnav-stars {
    padding: 0.375rem 0.5rem;
  }

  .dotnav a,
  .dotnav button {
    width: 36px;
    height: 36px;
  }

  .dotnav #theme-toggle {
    width: 50px;
    height: 50px;
  }

  :root {
    --profile-image-size: 96px;
  }

  .profile-section {
    min-height: 0;
    padding-top: 4rem;
  }
}

/* Center the content similar to 404 page */
.main-container {
  position: relative;
  z-index: 1;
}

/* Theme toggle button */
.theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  width: var(--min-touch-target-size);
  height: var(--min-touch-target-size);
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s;
  z-index: 100;
}

.theme-toggle:hover {
  border-color: var(--card-hover-border);
}

.home-link {
  margin-top: 2rem;
  opacity: 0.7;
  font-size: 0.9rem;
}

.home-link a {
  color: var(--text-color);
  text-decoration: none;
}

.home-link a:hover {
  text-decoration: underline;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  background: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  z-index: 2000;
}

.skip-link:focus {
  top: 1rem;
}

*:focus-visible {
  outline: 2px solid var(--card-hover-border);
  outline-offset: 2px;
}

::selection {
  background: var(--text-color);
  color: var(--bg-color);
}

.loading-text,
.error-text,
.muted-text {
  font-size: 0.95rem;
  color: var(--muted);
}

.error-text {
  opacity: 0.95;
  color: #ff7a7a;
}

@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;
  }

  /* Cards have no transform, blur, or shadow to reset; only the
     border-color change remains, which is safe under reduced motion. */
}

@media print {
  #space-container,
  .header-controls,
  .dotnav,
  .theme-toggle,
  .skip-link {
    display: none !important;
  }

  body,
  .main-container {
    background: #fff !important;
    color: #000 !important;
  }
}
