/* =========================================================
   THEME TOKENS
   ========================================================= */

/* light theme (default) */
:root {
  /* surfaces */
  --bg: #ffffff;
  --card: #ffffff;
  --text: #111111;

  /* grays */
  --muted: rgba(0, 0, 0, 0.60);
  --muted2: rgba(0, 0, 0, 0.40);
  --border: #E0E0E0;         /* steel gray */
  --gray: #6D6E71;           /* iron gray */

  /* navigation */
  --nav-bg: #ffffff;
  --link-text: #111111;

  /* CMU accents */
  --accent: #C41230;         /* carnegie red */
  --accent-2: #941120;       /* skibo red */
  --accent-soft: rgba(196, 18, 48, 0.12);
  --accent-border: rgba(196, 18, 48, 0.35);

  /* secondary accents */
  --teal: #008F91;           /* teal thread */
  --deep-teal: #1F4C4C;      /* hornbostel teal */

  /* alias used in popovers, focus outlines, etc. */
  --link: var(--accent);
}

/* dark theme overrides (applied when html[data-theme="dark"]) */
html[data-theme="dark"] {
  --bg: #0f1115;
  --card: #151923;
  --text: #e7e7e7;

  --muted: rgba(231, 231, 231, 0.72);
  --muted2: rgba(231, 231, 231, 0.55);
  --border: rgba(255, 255, 255, 0.14);

  --nav-bg: #0f1115;
  --link-text: #e7e7e7;

  /* same CMU reds, slightly stronger soft/border */
  --accent: #C41230;
  --accent-2: #941120;
  --accent-soft: rgba(196, 18, 48, 0.18);
  --accent-border: rgba(196, 18, 48, 0.45);

  --teal: #008F91;
  --deep-teal: #1F4C4C;

  --link: var(--accent);
}

/* =========================================================
   BASE / GLOBALS
   ========================================================= */

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

a { color: var(--accent); }
a:hover { color: var(--accent-2); }

h4 { letter-spacing: .1rem; }
.container { max-width: 800px; }

/* =========================================================
   HEADER
   ========================================================= */

.header {
  margin-top: 60px;
  margin-bottom: 60px;
  text-align: left;
}

.main-description h1 { margin-bottom: 0px; }
.main-description p  { margin-bottom: 0px; }

.main-description .fa {
  font-size: 22px;
  margin-top: 5px;
}

/* =========================================================
   PUBLICATIONS
   ========================================================= */

.paper { margin-bottom: 20px; }
/* .paper .title { text-transform: uppercase; } */
.paper p { margin-bottom: 2px; }
.paper-buttons { margin-top: 5px; }

/* =========================================================
   BUTTONS
   ========================================================= */

.button {
  display: inline-block;
  height: 25px;
  line-height: 25px;
  padding: 0 25px;
  font-weight: 100;
  text-transform: none;

  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  cursor: pointer;
}

.button:hover { background: rgba(0,0,0,0.03); }
html[data-theme="dark"] .button:hover { background: rgba(255,255,255,0.06); }

.button:focus {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* =========================================================
   SECTIONS / FOOTER
   ========================================================= */

.section-header {
  text-transform: uppercase;
  font-size: 1.5rem;
  letter-spacing: .2rem;
  font-weight: 600;
}

/* default section spacing */
.docs-section {
  border-top: 1px solid var(--border);
  padding: 4rem 0;
  margin-bottom: 0;
}

/* single-page navigation mode:
   - if JS hides/shows one section at a time, the visible section sits directly under the navbar.
   - we remove the section top border to avoid a "double-thick" line (navbar border + section border).
*/
.docs-section.section-page { border-top: 0; }

.footer {
  text-align: center;
  color: var(--muted2);
  border-top: 1px solid var(--border);
  padding: 15px 0 40px 0;
  margin-bottom: 0;
}

.title-subtitle h3 { margin-bottom: 0px; }
.title-subtitle h5 { color: var(--muted); }
.image { text-align: center; }

/* =========================================================
   PROJECT CARDS
   ========================================================= */

.project-container { margin-bottom: 30px; }

.project-image-container {
  border: 1px solid rgba(0,0,0,0.2);
  padding: 3px;
  transition: 0.3s;
}

.project-image-container:hover { transition: 0.3s; }
.project-image-container:hover img { opacity: 0.4; }

.project-caption { padding: 3px; }

/* =========================================================
   NAVBAR (hidden on mobile by default)
   ========================================================= */

.navbar { display: none; }

/* =========================================================
   THEME TOGGLE
   ========================================================= */

.theme-toggle {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 1000;

  display: inline-flex;
  gap: 8px;
  align-items: center;

  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);

  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  margin-top: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.theme-toggle:focus {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

/* =========================================================
   TIMELINE (Resume)
   ========================================================= */

/* layout */
.timeline { position: relative; }

/* center spine */
.timeline::before {
  left: 50% !important;
  transform: translateX(-50%) !important;
}

/* cards */
.timeline li .flag {
  border-radius: 8px;
  padding: 8px 14px;
}

/* remove template's attached markers */
.timeline .flag::before,
.timeline .flag::after {
  content: none !important;
}

/* one marker per item anchored to spine */
.timeline > li { position: relative; }

.timeline > li::before {
  content: "";
  position: absolute;
  top: 32px;    /* aligns with flag vertically */
  left: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--accent);
  z-index: 10;
  transform: translateX(calc(-50% - 3px)) !important; /* try 2px–6px */
}

/* space between cards and spine (desktop) */
.timeline .direction-l { padding-right: 32px !important; }
.timeline .direction-r { padding-left: 32px !important; }

/* date pill positioning (desktop) */
.timeline .flag-wrapper { position: relative; }

.timeline .time-wrapper {
  position: absolute !important;
  top: 50% !important;
  white-space: nowrap;
  opacity: 1 !important; /* ensure visible */
}

.timeline .direction-l .time-wrapper {
  right: 100% !important;
  margin-right: 12px !important;
  left: auto !important;
}

.timeline .direction-r .time-wrapper {
  left: 100% !important;
  margin-left: 12px !important;
  right: auto !important;
}

/* date pill styling */
.timeline .time {
  color: var(--accent) !important;
  border: 1px solid var(--accent-border) !important;
  background: var(--accent-soft) !important;
}

/* dark mode timeline overrides */
html[data-theme="dark"] .timeline li .flag {
  background: #151923 !important;
  color: #e7e7e7 !important;
  border: 1px solid rgba(255,255,255,0.15) !important;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}

html[data-theme="dark"] .timeline li .desc { color: #d6d6d6; }

html[data-theme="dark"] .timeline li .time {
  color: #f3f4f6 !important;
  background: rgba(255,255,255,0.10) !important;
  border: 1px solid rgba(255,255,255,0.18) !important;
}

html[data-theme="dark"] .timeline:before {
  background: rgba(255,255,255,0.18);
}

html[data-theme="dark"] .timeline li .marker {
  background: #0f1115;
  border: 3px solid var(--accent);
}

/* =========================================================
   TEXT FORMATTING (desktop only)
   ========================================================= */

@media (min-width: 750px) {
  #bio p {
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
  }

  #fun {
    text-align: justify;
    text-justify: inter-word;
    line-height: 1.65;
    hyphens: auto;
  }
}

/* =========================================================
   SOCIAL ICONS
   ========================================================= */

.social-icons {
  display: flex;
  align-items: center;
  gap: 2px;
}

.social-icon {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* font icons (LinkedIn, GitHub) */
.social-icon .fa {
  font-size: 22px;
  line-height: 1;
  transform: translateY(0px);
}

/* academicons (Google Scholar) */
.social-icon .ai-google-scholar {
  font-size: 22px;
  line-height: 1;
  transform: translateY(2.5px);
}

/* image icons (X) */
.social-icon img {
  width: 22px;
  height: 22px;
  display: block;
  transform: translateY(2px);
}

/* image icons (Strava) */
.social-icon img.icon-small {
  width: 20px;
  height: 20px;
}

/* image icons (goodreads) */
.social-icon img.icon-smaller {
  width: 19px;
  height: 19px;
}

/* dark mode - invert image-based icons */
html[data-theme="dark"] .social-icon img { filter: invert(1); }

/* footer social row tweaks */
.footer .footer-social {
  justify-content: center;
  gap: 2px;
  opacity: 0.55;
}

.footer .footer-social .social-icon {
  width: 26px;
  height: 26px;
}

/* footer icon vertical alignment */
.footer .footer-social .fa { transform: translateY(2px); }
.footer .footer-social .ai-google-scholar { transform: translateY(2.5px); }

.footer .footer-social img {
  transform: translateY(2px);
  opacity: 0.6;
}

/* full opacity on hover */
.footer .footer-social:hover {
  opacity: 1;
  transition: opacity 0.15s ease;
}

/* =========================================================
   MAP IMAGE
   ========================================================= */

.map-image {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem 0;
  border: none;
  box-shadow: none;
}

/* =========================================================
   MOBILE NAV (hidden on desktop)
   ========================================================= */

.mobile-nav { display: none; } /* hidden on desktop */

/* =========================================================
   CONFERENCE TALKS LAYOUT
   ========================================================= */

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

.talk-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.talk-row:last-child { border-bottom: none; }

.talk-main {
  flex: 1 1 auto;
  min-width: 0;
}

.talk-title { margin-bottom: 6px; }

.talk-meta {
  color: var(--muted);
  line-height: 1.4;
}

.talk-type {
  font-weight: 700;     /* bold */
  color: var(--text);   /* darker than muted line */
  margin-left: 8px;
  white-space: nowrap;
}

.talk-type--invited { color: var(--accent); }
.talk-star { color: var(--accent); }

.talk-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

/* larger than phone */
@media (min-width: 550px) {
  .header { margin-top: 5rem; }
}

/* smaller theme toggle on small screens */
@media (max-width: 550px) {
  .theme-toggle {
    top: 12px;
    right: 12px;
    padding: 5px 9px;
    font-size: 13px;
  }
}

/* desktop navbar + popovers (tablet & up) */
@media (min-width: 750px) {
  .navbar,
  .navbar-spacer {
    display: block;
    width: 100%;
    height: 6.5rem;
    background: var(--nav-bg);
    z-index: 99;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .navbar-spacer { display: none; }
  .navbar > .container { width: 100%; }

  .navbar-list {
    list-style: none;
    margin-bottom: 0;
  }

  .navbar-item {
    position: relative;
    float: left;
    margin-bottom: 0;
  }

  .navbar-link {
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .2rem;
    margin-right: 35px;
    text-decoration: none;
    line-height: 6.5rem;
    color: var(--link-text);
  }

  .navbar-link.active { color: var(--accent); }

  /* popover (template feature) */
  .popover.open { display: block; }

  .popover {
    display: none;
    position: absolute;
    top: 92%;
    left: -50%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    -webkit-filter: drop-shadow(0 0 6px rgba(0,0,0,.1));
       -moz-filter: drop-shadow(0 0 6px rgba(0,0,0,.1));
            filter: drop-shadow(0 0 6px rgba(0,0,0,.1));
  }

  .popover-item:first-child .popover-link:after,
  .popover-item:first-child .popover-link:before {
    bottom: 100%;
    left: 50%;
    border: solid transparent;
    content: " ";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
  }

  .popover-item:first-child .popover-link:after {
    border-color: rgba(255, 255, 255, 0);
    border-bottom-color: #fff;
    border-width: 10px;
    margin-left: -10px;
  }

  .popover-item:first-child .popover-link:before {
    border-color: rgba(238, 238, 238, 0);
    border-bottom-color: #eee;
    border-width: 11px;
    margin-left: -11px;
  }

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

  .popover-item { padding: 0; margin: 0; }

  .popover-link {
    position: relative;
    color: var(--link-text);
    display: block;
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    text-transform: uppercase;
    font-size: 1.0rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: .1rem;
  }

  .popover-item:first-child .popover-link { border-radius: 4px 4px 0 0; }

  .popover-item:last-child .popover-link {
    border-radius: 0 0 4px 4px;
    border-bottom-width: 0;
  }

  .popover-link:hover {
    color: #fff;
    background: var(--link);
  }

  .popover-link:hover,
  .popover-item:first-child .popover-link:hover:after {
    border-bottom-color: var(--link);
  }
}

/* timeline on mobile (stacked single-column layout) */
@media (max-width: 768px) {
  /* iPhone safari safe-area so nothing is clipped */
  .container {
    max-width: 100% !important;
    padding-left: calc(16px + env(safe-area-inset-left)) !important;
    padding-right: calc(16px + env(safe-area-inset-right)) !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }

  .timeline {
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }

  /* center vertical line */
  .timeline:before {
    z-index: 1 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }

  /* kill desktop L/R layout */
  .timeline li,
  .timeline li .direction-l,
  .timeline li .direction-r {
    float: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
    position: relative !important;
    box-sizing: border-box !important;
  }

  /* each item = grid: flag -> desc -> date */
  .timeline li .direction-l,
  .timeline li .direction-r {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "flag"
      "desc"
      "date" !important;
    justify-items: center !important;
    align-items: start !important;
    text-align: center !important;
  }

  .timeline li .flag-wrapper { display: contents !important; }

  .timeline li .flag { grid-area: flag !important; }
  .timeline li .desc { grid-area: desc !important; }
  .timeline li .time-wrapper { grid-area: date !important; }

  .timeline li .flag,
  .timeline li .desc {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
    box-sizing: border-box !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
    text-align: center !important;
  }

  .timeline li .flag {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    border-radius: 12px !important;
  }

  .timeline li .desc {
    margin-top: 14px !important;
    padding-top: 14px !important;
    padding-bottom: 14px !important;
    border-radius: 14px !important;
  }

  /* center date pills */
  .timeline li .time-wrapper {
    float: none !important;
    position: static !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;

    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;

    margin: 12px 0 20px 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }

  .timeline li .time {
    display: inline-block !important;
    white-space: nowrap !important;
    padding: 6px 10px !important;
    border-radius: 10px !important;
    border-color: var(--accent-border) !important;
    color: var(--accent) !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
  }

  /* remove markers/dots & triangles on mobile */
  .timeline li .direction-l .flag:after,
  .timeline li .direction-r .flag:after,
  .timeline li .direction-l .flag:before,
  .timeline li .direction-r .flag:before,
  .timeline li:before,
  .timeline li:after,
  .timeline .marker,
  .timeline li .marker {
    display: none !important;
    content: none !important;
  }

  /* dark mode readability on mobile */
  html[data-theme="dark"] .timeline li .flag,
  html[data-theme="dark"] .timeline li .desc,
  html[data-theme="dark"] .timeline li .time,
  html[data-theme="dark"] .timeline li .desc * {
    opacity: 1 !important;
    filter: none !important;
    -webkit-text-fill-color: currentColor !important;
  }

  html[data-theme="dark"] .timeline li .flag,
  html[data-theme="dark"] .timeline li .desc {
    background: #151923 !important;
    color: #e7e7e7 !important;
    border: 1px solid rgba(255,255,255,0.16) !important;
    box-shadow: 0 8px 22px rgba(0,0,0,0.45) !important;
  }

  html[data-theme="dark"] .timeline li .time {
    background: var(--accent-soft) !important;
    color: var(--accent) !important;
    border: 1px solid var(--accent-border) !important;
  }
}

/* mobile menu */
@media (max-width: 750px) {
  .mobile-nav { display: block; }

  .mobile-menu-btn {
    position: fixed;
    z-index: 3000;

    top: calc(12px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));

    width: 44px;
    height: 44px;
    border-radius: 999px;

    border: 1px solid var(--border);
    background: var(--card);

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0,0,0,0.18);

    padding: 0;
    box-sizing: border-box;
  }

  /* keep toggle in safe-area */
  .theme-toggle {
    top: calc(12px + env(safe-area-inset-top));
    right: calc(12px + env(safe-area-inset-right));
  }

  .hamburger {
    width: 20px;
    height: 14px;
    position: relative;
    display: block;
    margin: 0;
    padding: 0;
  }

  .hamburger::before,
  .hamburger::after,
  .hamburger span {
    content:"";
    position:absolute;
    left:0;
    width:100%;
    height:2px;
    background: var(--text);
    border-radius: 2px;
    display:block;
  }

  .hamburger::before { top: 0; }
  .hamburger::after { bottom: 0; }

  .hamburger span {
    top: 50%;
    transform: translateY(-50%);
  }

  .mobile-menu {
    position: fixed;
    top: calc(64px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    z-index: 2999;

    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 0;
    box-shadow: 0 14px 30px rgba(0,0,0,0.20);

    display: none;
  }

  .mobile-menu.open { display: block; }

  .mobile-menu a {
    display: block;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    letter-spacing: .06rem;
    text-transform: uppercase;
    font-size: 12px;
  }

  /* talks stack on mobile */
  .talk-row {
    flex-direction: column;
    gap: 10px;
  }

  .talk-actions { justify-content: flex-start; }
  .talk-type { white-space: normal; }
}

/* =========================================================
   PHOTOGRAPHY
   ========================================================= */
.photo-grid {
  column-gap: 18px;
  row-gap: 32px;         /* more air between rows */
}

.photo-card{
  margin: 0;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  margin-bottom: 28px;
}

.photo-card a { display: block; }

.photo-card img{
  width: 100%;
  max-width: 380px;     /* constrain large photos */
  height: auto;
  display: block;
  border-radius: 0;     /* no curved edges */
  box-shadow: none;     /* no card feel */
}

.photo-card figcaption{
  padding: 8px 0 0 0;   /* caption below photo */
  color: var(--muted);
  line-height: 1.35;
  padding-top: 10px;
  margin-bottom: 6px;
}

.photo-title{
  display: block;
  color: var(--text);
  font-weight: 600;
  margin: 0 0 2px 0;
}

.photo-meta{
  display: block;
  font-size: 0.95em;
}

.photo-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 18px;
  row-gap: 32px;
  margin-top: 18px;
}

@media (max-width: 500px){
  .photo-grid{
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   TEACHING
   ========================================================= */
.teaching-entry{
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.teaching-entry:last-child{
  border-bottom: none;
}

.teaching-recognition{
  font-size: 0.95em;
  color: var(--muted);
  margin: 4px 0 6px 0;
}

.fun-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); /* was ~220px */
  gap: 15px;
}

.fun-item {
  text-align: center;
}

.fun-item img {
  width: 100%;
  aspect-ratio: 3 / 4;   /* Enforces 3:4 ratio */
  object-fit: cover;     /* Crops instead of stretching */
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  transition: transform 0.2s ease;
}

.fun-item img:hover {
  transform: scale(1.03);
}

.fun-item p {
  margin-top: 8px;
  font-size: 0.9em;
  color: #555;
}