:root {
  /* --- DARK MODE (Default) --- */
  --bg: #0a0b10;
  --text: #FAF7F2;
  --text-muted: #C9B5A0;
  --accent: #D97B4F;
  --accent-bright: #FF8C5A;
  --surface: rgba(255, 255, 255, 0.04);
  --border: rgba(217, 123, 79, 0.15);
  --bg-overlay: linear-gradient(to bottom, rgba(10, 11, 16, 0.96), rgba(10, 11, 16, 0.99));

  /* --- SPACING SYSTEM --- */
  --space: 20px;
  --radius: 25px;

  /* --- CARD SPACING CONTROLS (Tune these to make cards more compact) --- */
  --card-padding: 20px;                            /* Internal card padding (currently 30px) */
  --card-gap: 20px;                                /* Gap between media and text */
  --card-element-gap: 2px;                         /* Gap between elements inside card*/
  --card-title-margin: 0px;                        /* Space below titles */
  --card-bottom-margin: 15px;                      /* Space between cards */
  --card-text-only-margin: 3px;
  --card-text-only-padding: 0px;
}

/* --- LIGHT MODE --- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #FAF7F2;
    --text: #2A1713;
    --text-muted: #684b40;
    --accent: #BF550C;
    --accent-bright: #D97B4F;
    --surface: rgba(191, 85, 12, 0.08);
    --border: rgba(42, 23, 19, 0.1);
    --bg-overlay: linear-gradient(to bottom, rgba(250, 247, 242, 0.94), rgba(250, 247, 242, 0.97));
  }
}

:root[data-theme="light"] {
  --bg: #FAF7F2;
  --text: #2A1713;
  --text-muted: #684b40;
  --accent: #BF550C;
  --accent-bright: #D97B4F;
  --surface: rgba(191, 85, 12, 0.08);
  --border: rgba(42, 23, 19, 0.1);
  --bg-overlay: linear-gradient(to bottom, rgba(250, 247, 242, 0.94), rgba(250, 247, 242, 0.97));
}

/* --- RESET & GLOBAL --- */
* { 
  box-sizing: border-box; 
  margin: 0; 
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.45'/%3E%3C/svg%3E"),
    repeating-linear-gradient(45deg, transparent 0px, transparent 2px, rgba(0, 0, 0, 0.15) 3px, rgba(0, 0, 0, 0.15) 6px),
    repeating-linear-gradient(-45deg, transparent 0px, transparent 2px, rgba(255, 255, 255, 0.1) 3px, rgba(255, 255, 255, 0.1) 6px),
    radial-gradient(circle at 50% 0%, rgba(232, 99, 63, 0.2), transparent 100%),
    var(--bg-overlay),
    url('../images/background.jpg');
  background-blend-mode: multiply, overlay, overlay, normal, normal, normal;
  background-size: 150px 150px, auto, auto, auto, cover, cover;
  background-position: 0 0, center, center, center top, center, center;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  padding: calc(var(--space) * 2.5) var(--space);
  max-width: 1000px;
  margin: 0 auto;
  min-height: 100vh;
}

h2 { margin-bottom: var(--space); }

a {
  color: inherit;
  text-decoration: none;
  transition: 0.25s;
}
a:hover { color: var(--accent-bright); }

section { margin-bottom: calc(var(--space) * 2); }

.highlight {
  color: var(--accent-bright);
  font-weight: 600;
}

/* --- HERO --- */
.hero {
  display: flex;
  align-items: center;
  gap: calc(var(--space) * 2);
  margin-bottom: calc(var(--space) * 2);
}

.avatar {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(232, 99, 63, 0.2);
  transition: 0.4s;
}
.avatar:hover {
  transform: scale(1.03);
  box-shadow: 0 24px 64px rgba(232, 99, 63, 0.2);
}

.hero-text .subtitle {
  color: var(--text-muted);
  margin-top: calc(var(--space) / 4);
}

/* --- BADGES & BUTTONS --- */
.badges,
.chips,
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--space) / 2);
  margin-top: var(--space);
}

.badge,
.chip,
.btn {
  padding: calc(var(--space) / 2) var(--space);
  border: 3px solid var(--border);
  border-radius: 100px;
  color: var(--text-muted);
  transition: 0.25s;
}

.email-badge:hover .copy-icon,
.badge:hover,
.chip:hover,
.btn:hover {
  color: var(--accent-bright);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.icon-badge {
  padding: calc(var(--space) / 1.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.email-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.copy-icon {
  opacity: 0.6;
  transition: 0.25s;
  flex-shrink: 0;
}

.toggle-btn {
  display: block;
  margin: var(--space) auto;
  padding: calc(var(--space) / 1.5) calc(var(--space) * 2);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: 0.25s;
}
.toggle-btn:hover {
  color: var(--accent-bright);
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* --- CARDS --- */
.card {
  background: linear-gradient(145deg, rgba(10, 11, 16, 0.85) 0%, rgba(10, 11, 16, 0.75) 100%);
  background-image: 
    linear-gradient(145deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.02) 100%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.4);
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 
    0 8px 32px 0 rgba(0, 0, 0, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  border-radius: var(--radius);
  padding: var(--card-padding);              /* â† Controlled by variable */
  margin-bottom: var(--card-bottom-margin);  /* â† Controlled by variable */
  transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.card:hover {
  transform: translateY(-5px);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
  box-shadow: 0 12px 40px 0 rgba(217, 123, 79, 0.15);
  border-top-color: rgba(255, 255, 255, 0.6);
}

/* --- ABOUT --- */
.about-text a {
  color: var(--text);
  border-bottom: 2px solid var(--accent);
}

/* --- NEWS --- */
.news-list { 
  list-style: none; 
  padding: 0;
  max-height: 440px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

.news-item {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: var(--space);
  padding: calc(var(--space) / 2.5) 0;
  border-bottom: 1px solid var(--border);
}

.news-date {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}

.news-content { color: var(--text-muted); }
.news-content strong { 
  color: var(--text); 
  font-weight: 600; 
}

/* --- PUBLICATIONS --- */
.pub {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--card-gap);  /* â† Controlled by variable */
}

.pub-media {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  border-radius: var(--radius);
  transition: 0.3s;
}
.pub:hover .pub-media { opacity: 0.9; }

.pub-media-placeholder { display: none; }

.pub-meta {
  color: var(--text-muted);
}
.pub-meta a { text-decoration: underline; }

.pub-desc {
  color: var(--text);
  margin-bottom: 0;
}

.status-tag {
  display: inline-block;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--card-title-margin);  /* â† Controlled by variable */
}

/* Text-only publications */
.pub-text-only {
  padding-top: var(--card-text-only-padding);
  grid-template-columns: 1fr;
}

.pub-text-only > div {
  display: grid;
  grid-template-columns: 2fr 1.2fr auto;
  gap: var(--card-text-only-margin);
  align-items: center;
}

.pub-text-only h3,
.pub-text-only h4 {
  grid-column: 1 / -1;
  margin: 0 0 0 0;
}

.pub-text-only .pub-meta,
.pub-text-only .status-tag,
.pub-text-only .btn-group {
  margin: 0;
}

.pub-text-only .btn-group {
  justify-self: end;
}

/* --- THEME TOGGLE FAB --- */
.theme-toggle-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface);
  backdrop-filter: blur(40px);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transition: 0.3s;
}

.theme-toggle-fab:hover {
  transform: translateY(-3px) scale(1.05);
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(232, 99, 63, 0.3);
  background: rgba(232, 99, 63, 0.1);
}

.theme-toggle-fab svg {
  width: 24px;
  height: 24px;
}

/* --- TOGGLE ANIMATIONS --- */
#more-pubs {
  opacity: 1;
  visibility: visible;
  max-height: 10000px;
  transition: opacity 0.3s ease, max-height 0.3s ease;
}

#more-pubs.hidden {
  opacity: 0;
  visibility: hidden;
  max-height: 0;
  overflow: hidden;
}

/* --- RESPONSIVE --- */
@media (max-width: 700px) {
  .pub { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .hero { 
    flex-direction: column; 
    text-align: center; 
  }

  .badges { justify-content: center; }

  .news-item { 
    grid-template-columns: 1fr; 
    gap: calc(var(--space) / 3); 
  }
}