/* =============================================================================
   Aaron Portfolio — Custom CSS
   Academic · Minimal · Modern
   ============================================================================= */

/* ── 1. CSS Custom Properties ─────────────────────────────────────────────── */
:root {
  --color-navy:      #0c1f3a;
  --color-blue:      #2563eb;
  --color-blue-dark: #1d4ed8;
  --color-blue-tint: #eff6ff;
  --color-text:      #1e293b;
  --color-muted:     #64748b;
  --color-bg:        #f8fafc;
  --color-surface:   #ffffff;
  --color-border:    #e2e8f0;
  --color-border-lt: #f1f5f9;

  --header-height:   64px;
  --toc-width:       220px;
  --content-max:     740px;

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;

  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.05);

  --transition: 150ms ease;

  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── 2. Base Reset & Body ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

img,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ── 3. Site Header ───────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-height);
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  transition: box-shadow var(--transition);
}

.site-header.is-scrolled {
  box-shadow: var(--shadow-sm);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 2rem;
}

/* Site title in header */
.site-header .wp-block-site-title {
  margin: 0;
}

.site-header .wp-block-site-title a,
.site-header .wp-block-site-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-navy);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-header .wp-block-site-title a:hover {
  color: var(--color-blue);
  text-decoration: none;
}

/* Header navigation */
.site-header .wp-block-navigation {
  font-size: 0.875rem;
  font-weight: 500;
}

.site-header .wp-block-navigation a {
  color: var(--color-muted);
  text-decoration: none;
  padding: 0.25rem 0;
  transition: color var(--transition);
  position: relative;
}

.site-header .wp-block-navigation a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--color-blue);
  transition: width var(--transition);
  border-radius: 1px;
}

.site-header .wp-block-navigation a:hover {
  color: var(--color-navy);
}

.site-header .wp-block-navigation a:hover::after {
  width: 100%;
}

/* Mobile nav toggle */
.wp-block-navigation__responsive-container-close,
.wp-block-navigation__responsive-container-open {
  color: var(--color-navy) !important;
}

/* ── 4. Portfolio Layout (TOC + Content Two-Column) ──────────────────────── */
.portfolio-wrapper {
  display: grid;
  grid-template-columns: var(--toc-width) 1fr;
  /* align-items must be stretch (default) so the TOC grid cell is tall
     enough for position:sticky to scroll within it */
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
  min-height: calc(100vh - var(--header-height));
}

/* ── 5. TOC Sidebar ───────────────────────────────────────────────────────── */
.toc-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 2rem);
  max-height: calc(100vh - var(--header-height) - 4rem);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2.5rem 1.5rem 2.5rem 2rem;

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.toc-sidebar::-webkit-scrollbar {
  width: 4px;
}

.toc-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.toc-sidebar::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

.toc-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin: 0 0 0.75rem 0;
  padding-left: 0.75rem;
}

#toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#toc-list li {
  margin: 0;
}

#toc-list a {
  display: block;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  line-height: 1.4;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

#toc-list a:hover {
  color: var(--color-navy);
  border-left-color: var(--color-border);
  background: var(--color-border-lt);
}

#toc-list a.is-active {
  color: var(--color-blue);
  border-left-color: var(--color-blue);
  background: var(--color-blue-tint);
  font-weight: 600;
}

/* H3 sub-items */
#toc-list .toc-h3 a {
  padding-left: 1.5rem;
  font-size: 0.775rem;
  font-weight: 400;
}

/* Mobile TOC toggle */
.toc-mobile-toggle {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-navy);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background var(--transition);
}

.toc-mobile-toggle:hover {
  background: var(--color-border-lt);
}

.toc-mobile-toggle svg {
  flex-shrink: 0;
  transition: transform var(--transition);
}

.toc-mobile-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

/* ── 6. Portfolio Content Column ─────────────────────────────────────────── */
.portfolio-content {
  min-width: 0;
  padding: 3rem 2.5rem 5rem 3rem;
  border-left: 1px solid var(--color-border);
}

/* ── 7. Portfolio Sections ────────────────────────────────────────────────── */
.portfolio-section {
  max-width: var(--content-max);
  padding-bottom: 3.5rem;
  margin-bottom: 3.5rem;
  border-bottom: 1px solid var(--color-border-lt);
}

.portfolio-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

/* Section heading row (h2 + optional label/year) */
.section-heading-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* ── 8. Hero / About Section ─────────────────────────────────────────────── */
.section-hero {
  padding-top: 1.5rem;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-blue);
  margin-bottom: 1rem;
}

.hero-eyebrow::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 2px;
  background: var(--color-blue);
  border-radius: 1px;
}

.hero-name {
  font-size: clamp(2.25rem, 5vw, 3.25rem) !important;
  font-weight: 700 !important;
  letter-spacing: -0.025em !important;
  color: var(--color-navy) !important;
  line-height: 1.1 !important;
  margin: 0 0 0.5rem !important;
}

.hero-subtitle {
  font-size: 1.125rem;
  color: var(--color-muted);
  font-weight: 400;
  margin: 0 0 2rem;
  line-height: 1.5;
}

.hero-bio {
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--color-text);
  max-width: 660px;
}

/* Skill tags */
.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.75rem;
}

.skill-tag {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  font-size: 0.775rem;
  font-weight: 500;
  color: var(--color-blue-dark);
  background: var(--color-blue-tint);
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

/* ── 9. Work Experience ───────────────────────────────────────────────────── */
.experience-category {
  margin-bottom: 2.5rem;
}

.experience-category:last-child {
  margin-bottom: 0;
}

.category-heading {
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.1em !important;
  text-transform: uppercase !important;
  color: var(--color-muted) !important;
  margin: 0 0 1.25rem !important;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.job-entry {
  position: relative;
  padding: 1.25rem 1.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 0.875rem;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.job-entry:last-child {
  margin-bottom: 0;
}

.job-entry:hover {
  box-shadow: var(--shadow-sm);
  border-color: #cbd5e1;
}

.job-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.job-title {
  font-size: 0.9375rem !important;
  font-weight: 600 !important;
  color: var(--color-navy) !important;
  margin: 0 !important;
  line-height: 1.3 !important;
}

.job-org {
  font-size: 0.875rem;
  color: var(--color-blue);
  font-weight: 500;
  margin: 0.15rem 0 0;
}

.job-dates {
  font-size: 0.775rem;
  font-weight: 500;
  color: var(--color-muted);
  white-space: nowrap;
  background: var(--color-bg);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 0.1rem;
}

.job-description {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin: 0.5rem 0 0;
  line-height: 1.65;
}

/* Current position badge */
.badge-current {
  display: inline-block;
  font-size: 0.675rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #059669;
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.5rem;
}

/* ── 10. Education ────────────────────────────────────────────────────────── */
.education-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 1rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--color-border-lt);
}

.education-entry:first-of-type {
  padding-top: 0;
}

.education-entry:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.education-degree {
  font-size: 1rem !important;
  font-weight: 600 !important;
  color: var(--color-navy) !important;
  margin: 0 0 0.2rem !important;
}

.education-field {
  font-size: 0.9rem;
  color: var(--color-text);
  margin: 0 0 0.2rem;
}

.education-institution {
  font-size: 0.875rem;
  color: var(--color-blue);
  font-weight: 500;
  margin: 0;
}

.education-year {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
  padding-top: 0.15rem;
}

/* ── 11. Research & Blog Cards ───────────────────────────────────────────── */
.research-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.research-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  text-decoration: none;
  display: block;
}

.research-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #93c5fd;
  transform: translateY(-2px);
  text-decoration: none;
}

.research-card-tag {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-blue);
  margin-bottom: 0.5rem;
}

.research-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-navy);
  margin: 0 0 0.5rem;
  line-height: 1.35;
}

.research-card-excerpt {
  font-size: 0.8125rem;
  color: var(--color-muted);
  line-height: 1.6;
  margin: 0;
}

/* ── 12. Contact Section ──────────────────────────────────────────────────── */
.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-navy);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all var(--transition);
}

.contact-link:hover {
  background: var(--color-blue);
  color: #ffffff;
  border-color: var(--color-blue);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ── 13. Footer ───────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 2rem;
  text-align: center;
}

.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-copyright {
  font-size: 0.8125rem;
  color: var(--color-muted);
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  font-size: 0.8125rem;
  color: var(--color-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--color-navy);
}

/* ── 14. Block Style Overrides ────────────────────────────────────────────── */

/* Card style for groups */
.wp-block-group.is-style-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* Callout style */
.wp-block-group.is-style-callout {
  background: var(--color-blue-tint);
  border-left: 3px solid var(--color-blue);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1.25rem 1.5rem;
}

/* Tag style for paragraphs */
.wp-block-paragraph.is-style-tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--color-blue-tint);
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: var(--color-blue-dark);
  font-size: 0.8125rem;
  font-weight: 500;
}

/* Separator */
.wp-block-separator {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0;
}

/* ── 15. Scroll-Reveal Animation ─────────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children */
.reveal-children > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.reveal-children.is-visible > * {
  opacity: 1;
  transform: translateY(0);
}

.reveal-children.is-visible > *:nth-child(1) { transition-delay: 0ms; }
.reveal-children.is-visible > *:nth-child(2) { transition-delay: 80ms; }
.reveal-children.is-visible > *:nth-child(3) { transition-delay: 160ms; }
.reveal-children.is-visible > *:nth-child(4) { transition-delay: 240ms; }
.reveal-children.is-visible > *:nth-child(5) { transition-delay: 320ms; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal-children > * {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ── 16. Typography Polish ────────────────────────────────────────────────── */
.portfolio-content p {
  max-width: 66ch;
}

.portfolio-content h2 {
  scroll-margin-top: calc(var(--header-height) + 1.5rem);
}

.portfolio-content h3 {
  scroll-margin-top: calc(var(--header-height) + 1rem);
}

/* Lead paragraph */
.is-style-lead,
.lead {
  font-size: 1.125rem !important;
  color: var(--color-muted) !important;
  font-weight: 400 !important;
  line-height: 1.7 !important;
}

/* ── 17. Responsive ──────────────────────────────────────────────────────── */

/* Tablet: hide TOC, expand content */
@media (max-width: 1024px) {
  .portfolio-wrapper {
    grid-template-columns: 1fr;
  }

  .toc-sidebar {
    position: static;
    max-height: none;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    overflow: hidden;
  }

  .toc-sidebar.is-collapsed #toc-nav {
    display: none;
  }

  .toc-mobile-toggle {
    display: flex;
  }

  .portfolio-content {
    border-left: none;
    padding: 2.5rem 1.5rem 4rem;
  }

  .research-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  .site-header-inner {
    padding: 0 1.25rem;
  }

  .portfolio-content {
    padding: 2rem 1.25rem 3rem;
  }

  .job-entry-header {
    flex-direction: column;
    gap: 0.4rem;
  }

  .job-dates {
    align-self: flex-start;
  }

  .education-entry {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .hero-name {
    font-size: clamp(1.875rem, 8vw, 2.5rem) !important;
  }

  .contact-links {
    flex-direction: column;
  }

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

  .site-footer-inner {
    flex-direction: column;
    text-align: center;
  }

  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ── 18. Shiny App Embed ─────────────────────────────────────────────────── */
.shiny-embed-wrapper {
  margin: 2rem 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.shiny-embed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.shiny-embed-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.shiny-embed-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-blue);
  text-decoration: none;
  transition: color var(--transition);
}

.shiny-embed-link:hover {
  color: var(--color-blue-dark);
  text-decoration: underline;
}

.shiny-embed-frame {
  position: relative;
  width: 100%;
  /* Fixed height — Shiny apps need explicit height, not aspect-ratio */
  height: 800px;
}

.shiny-embed-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.shiny-embed-caption {
  font-size: 0.775rem;
  color: var(--color-muted);
  text-align: center;
  padding: 0.5rem 1rem;
  margin: 0;
  border-top: 1px solid var(--color-border-lt);
}

.shiny-embed-caption a {
  color: var(--color-blue);
}

/* Shrink height on mobile so it doesn't dominate the viewport */
@media (max-width: 768px) {
  .shiny-embed-frame {
    height: 560px;
  }
}

/* ── 19. Print Styles ────────────────────────────────────────────────────── */
@media print {
  .site-header,
  .toc-sidebar,
  .toc-mobile-toggle {
    display: none;
  }

  .portfolio-wrapper {
    display: block;
  }

  .portfolio-content {
    border: none;
    padding: 0;
  }

  .job-entry,
  .research-card {
    break-inside: avoid;
    border: 1px solid #ccc;
  }

  .shiny-embed-wrapper {
    display: none;
  }
}
