/* ============================================================
   Felipe M. Affonso — Personal Site
   Design language: book shell aesthetic + coral particles
   ============================================================ */

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

:root {
  --bg: #f8f9fa;
  --bg-white: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #333333;
  --text-dim: #666666;
  --coral: #DA7756;
  --coral-dark: #c86a4a;
  --border: #e0e0e0;
  --border-light: #eee;
  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html.dark {
  --bg: #1a1a1e;
  --bg-white: #232328;
  --text: #e8e8e8;
  --text-secondary: #cccccc;
  --text-dim: #999999;
  --coral: #e08866;
  --coral-dark: #eda48a;
  --border: #333333;
  --border-light: #2a2a2a;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  transition: background-color 0.3s, color 0.3s;
}

a {
  color: var(--coral);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--coral-dark);
}

/* --- Nav Bar (fixed, all pages) --- */
.nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 64px;
}

.nav-bar canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.nav {
  position: relative;
  z-index: 2;
  padding: 0 48px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- Hero Banner (subpages) --- */
.page-banner {
  margin-top: 64px;
}

.page-banner-title {
  position: relative;
  z-index: 2;
  text-align: left;
  padding: 20px 48px 28px;
  max-width: 868px;
  margin: 0 auto;
}

.page-banner-title h1 {
  font-size: 28px;
  font-weight: 300;
  color: var(--text);
  letter-spacing: -0.2px;
}

.nav-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.5px;
}

.nav-links {
  display: flex;
  gap: 32px;
  list-style: none;
}

.nav-links a {
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: color 0.2s;
  position: relative;
}

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

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--coral);
}

.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  position: relative;
  z-index: 3;
}

.nav-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  margin: 5px 0;
  transition: transform 0.3s, opacity 0.3s;
}

/* --- Home: Full-viewport hero with particles --- */
.hero-full {
  position: relative;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 80px;
  overflow: hidden;
}

.hero-full canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.hero-inner {
  position: relative;
  z-index: 2;
  max-width: 820px;
  padding: 0 48px;
}

.hero-header {
  text-align: center;
  margin-bottom: 36px;
  opacity: 0;
  animation: fadeUp 0.8s ease 0.2s forwards;
}

.hero-name {
  font-size: 36px;
  font-weight: 300;
  color: var(--text);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.hero-title {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-secondary);
}

.hero-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 40px;
  align-items: start;
  opacity: 0;
  animation: fadeUp 0.8s ease 0.5s forwards;
}

.hero-photo img {
  width: 100%;
  display: block;
}

.hero-bio p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Page Layout --- */
.page {
  padding: 32px 48px 80px;
  max-width: 820px;
  margin: 0 auto;
}

.page-wide {
  max-width: 960px;
}

/* --- Sections --- */
.section {
  margin-bottom: 48px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.body-text {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* --- Publications --- */
.pub-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-toggle {
  cursor: pointer;
  user-select: none;
}

.section-toggle:hover {
  color: var(--text-secondary);
}

.toggle-icon {
  font-size: 11px;
  margin-left: 4px;
  color: var(--text-dim);
}

.pub-note-sub {
  font-size: 14px;
  color: var(--text-dim);
  margin: -16px 0 20px 0;
}

.pub-note-header {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.pub-entry {
  font-size: 15px;
  color: var(--text);
  line-height: 1.7;
}

.pub-entry a {
  color: var(--coral);
  transition: color 0.2s;
}

.pub-entry a:hover {
  color: var(--coral-dark);
}

/* --- Teaching --- */
.subsection-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 32px 0 16px 0;
}

.subsection-title:first-of-type {
  margin-top: 0;
}

.institution-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin: 20px 0 8px 0;
}

.course-list {
  list-style: none;
  padding: 0;
}

.course-list li {
  font-size: 15px;
  color: var(--text-secondary);
  padding: 4px 0 4px 16px;
  position: relative;
}

.course-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  width: 4px;
  height: 4px;
  background: var(--border);
  border-radius: 50%;
}

/* --- Student Quotes --- */
.student-quotes {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.student-quotes blockquote {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  font-style: italic;
  padding-left: 20px;
  border-left: 2px solid var(--border);
  margin: 0;
}

/* --- CV --- */
.cv-intro {
  font-size: 15px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 16px;
}

.cv-download-link {
  text-align: center;
  margin-bottom: 32px;
}

.cv-embed {
  width: 100%;
  margin-bottom: 24px;
}

.cv-embed iframe {
  width: 100%;
  height: 800px;
  border: 1px solid var(--border);
}

.cv-download-link {
  margin-top: 16px;
}

.cv-download {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
  transition: color 0.2s, border-color 0.2s;
}

.cv-download:hover {
  color: var(--coral);
  border-bottom-color: var(--coral);
}

.cv-download svg {
  width: 16px;
  height: 16px;
  stroke: var(--coral);
}

/* --- Contact --- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  margin-top: 40px;
}

.contact-block h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.contact-block p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 8px;
}

.contact-block a {
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: border-color 0.2s, color 0.2s;
}

.contact-block a:hover {
  color: var(--coral);
  border-bottom-color: var(--coral);
}

.social-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.social-icon {
  width: 20px;
  height: 20px;
  fill: #999;
  flex-shrink: 0;
  transition: fill 0.2s;
}

.social-links a {
  font-size: 15px;
  color: var(--text-secondary);
  border-bottom: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.social-links a:hover {
  color: var(--coral);
}

.social-links a:hover .social-icon {
  fill: var(--coral);
}

/* --- Page Transition --- */
#page-content {
  transition: opacity 0.2s ease;
}

#page-content.fade-out {
  opacity: 0;
}

/* --- Theme Toggle --- */
.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background-color 0.3s;
  position: relative;
  z-index: 3;
}

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

.theme-icon {
  font-size: 16px;
  line-height: 1;
  color: var(--text-dim);
  transition: color 0.2s;
}

.theme-toggle:hover .theme-icon {
  color: var(--coral);
}

/* --- Footer Line --- */
.footer-line {
  padding: 48px 48px 32px;
}

.footer-line-inner {
  max-width: 120px;
  height: 2px;
  margin: 0 auto;
  background: linear-gradient(90deg, transparent, var(--coral), transparent);
  opacity: 0.4;
}

/* --- Dark Mode Overrides --- */
html.dark .nav-bar {
  background: #1a1a1e;
}

html.dark .nav-links a {
  color: var(--text-secondary);
}

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

html.dark .nav-name {
  color: var(--text);
}

html.dark .nav-hamburger span {
  background: var(--text);
}

html.dark .page-banner-title h1 {
  color: var(--text);
}

html.dark .cv-embed iframe {
  border-color: var(--border);
}

html.dark .student-quotes blockquote {
  border-left-color: var(--border);
}

html.dark .section-title {
  border-bottom-color: var(--border);
}

html.dark .social-icon {
  fill: #777;
}

html.dark .contact-block a {
  color: var(--text-secondary);
  border-bottom-color: var(--border);
}

html.dark .contact-block a:hover {
  color: var(--coral);
  border-bottom-color: var(--coral);
}

/* --- Mobile --- */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(248, 249, 250, 0.98);
    backdrop-filter: blur(12px);
    flex-direction: column;
    padding: 24px;
    gap: 20px;
    border-bottom: 1px solid var(--border);
  }

  html.dark .nav-links {
    background: rgba(26, 26, 30, 0.98);
  }

  .nav-links.open { display: flex; }
  .nav-hamburger { display: block; }
  .hero-inner { padding: 0 24px; }
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    max-width: 480px;
    margin: 0 auto;
  }
  .hero-photo img { max-width: 200px; margin: 0 auto; }
  .hero-name { font-size: 28px; }
  .nav { padding: 0 24px; }
  .page { padding: 24px 24px 60px; }
  .page-banner-title { padding: 16px 24px 20px; }
  .page-banner-title h1 { font-size: 24px; }

  .contact-grid { grid-template-columns: 1fr; gap: 32px; }
  .cv-embed iframe { height: 500px; }
  .footer-line { padding: 32px 24px 24px; }
}

@media (max-width: 480px) {
  .hero-name { font-size: 24px; }
  .hero-title { font-size: 14px; }
  .hero-bio { font-size: 14px; }
}
