/* ============================================================================
   TOKENS
============================================================================ */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}
:root {
  --bg: #f7f4ec;
  --bg-alt: #efe8d9;
  --panel: #17170f14;
  --fg: #1c1b18;
  --fg-muted: #55534c;
  --fg-faint: #6b6858;
  --accent: #5c6e49;
  --accent-dim: #45542f;
  --accent-soft: rgba(92, 110, 73, 0.12);
  --accent-warm: #b4693c;
  --border: rgba(28, 27, 24, 0.14);
  --border-strong: rgba(28, 27, 24, 0.26);
  --danger: #a83e32;
  --cat-2: #5b6b78;
  --cat-3: #a15a6b;
  --font-display: "Lora", Georgia, "Times New Roman", serif;
  --font-body: "Inter", "Helvetica Neue", Arial, sans-serif;
  --max-width: 1180px;
  --gutter: clamp(24px, 6vw, 96px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(28, 27, 24, 0.09) 1px, transparent 1px);
  background-size: 18px 18px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

a { color: inherit; }
img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ============================================================================
   EDIT-MODE AFFORDANCES — hidden unless <body class="is-owner">
============================================================================ */
.edit-btn, .owner-only { display: none; }
.is-owner .edit-btn, .is-owner .owner-only { display: inline-flex; }
.is-owner #owner-login-trigger { display: none; } /* already signed in */
body:not(.is-owner) #sign-out-btn { display: none; }

.edit-btn {
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.edit-btn:hover { background: var(--accent-soft); border-color: var(--accent); }

.add-btn { margin-left: auto; }

.item-edit-controls {
  display: none;
  gap: 8px;
  margin-top: 14px;
}
.is-owner .item-edit-controls { display: flex; }

/* ============================================================================
   NAV
============================================================================ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  padding: 22px var(--gutter);
  display: flex;
  transition: background 0.25s ease, border-color 0.25s ease, padding 0.25s ease;
  border-top: 4px solid var(--fg);
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: rgba(247, 244, 236, 0.86);
  backdrop-filter: blur(10px);
  border-bottom-color: var(--border);
  padding-top: 14px;
  padding-bottom: 14px;
}
.nav-inner {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.nav-links {
  display: flex;
  gap: 32px;
}
.nav-links a {
  text-decoration: none;
  font-size: 14px;
  color: var(--fg-muted);
  position: relative;
  padding-bottom: 4px;
  transition: color 0.15s ease;
}
.nav-links a:hover, .nav-links a.active { color: var(--fg); }
.nav-links a.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: var(--accent);
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 28px;
}
.nav-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.nav-icon-btn:hover { color: var(--accent); border-color: var(--accent-dim); }
.nav-icon-btn svg { width: 15px; height: 15px; }
/* Explicit (ID-level) so this never loses a specificity tie with .nav-icon-btn's own display rule */
#sign-out-btn { display: none; }
.is-owner #sign-out-btn { display: inline-flex; }
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.nav-toggle span {
  width: 22px; height: 1.5px;
  background: var(--fg);
}

@media (max-width: 860px) {
  .nav-links {
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    width: min(300px, 80vw);
    background: var(--bg-alt);
    border-left: 1px solid var(--border);
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 40px var(--gutter);
    gap: 26px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }
  .nav-links.open { transform: translateX(0); }
  .nav-toggle { display: flex; }
  .nav-actions { margin-left: 16px; }
}

/* ============================================================================
   HERO
============================================================================ */
.hero {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  align-items: center;
  gap: 40px;
  padding: 90px var(--gutter);
}
.hero-text {
  display: flex;
  flex-direction: column;
  gap: 28px;
  max-width: 640px;
}
.hero-headline {
  font-size: clamp(52px, 6.5vw, 88px);
  font-weight: 700;
  line-height: 1.02;
  display: flex;
  flex-direction: column;
}
.hero-headline #headline-line2 { color: var(--fg-muted); }
.hero-tagline {
  max-width: 46ch;
  color: var(--fg-muted);
  font-size: 16px;
}
.hero-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.hero-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-self: center;
  gap: 22px;
}

/* Frame is the sizing anchor; caption is positioned against it so it can
   straddle the top edge regardless of which slide is showing.
   min() caps it at the doubled size but keeps it from overflowing the
   column on narrower desktop widths; aspect-ratio keeps it proportional. */
.hero-photo-frame {
  position: relative;
  width: min(440px, 38vw);
  aspect-ratio: 11 / 14;
}
.hero-carousel {
  position: absolute;
  inset: 0;
  border-radius: 52px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--bg-alt);
  box-shadow: 0 32px 64px -28px rgba(0, 0, 0, 0.6);
}
.hero-carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.35s ease;
  touch-action: pan-y;
  cursor: grab;
}
.hero-carousel-track.dragging { transition: none; cursor: grabbing; }
.hero-carousel-slide {
  min-width: 100%;
  height: 100%;
  flex-shrink: 0;
  user-select: none;
}
.hero-carousel-slide img {
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.hero-carousel-slide-text {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: var(--bg-alt);
}
.hero-carousel-slide-text p {
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.5;
  text-align: center;
  color: var(--fg);
  white-space: pre-line;
}
.hero-photo-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--fg-faint);
  font-size: 12px;
  padding: 8px;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(10, 14, 26, 0.4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.85;
  backdrop-filter: blur(3px);
  transition: opacity 0.15s ease, background 0.15s ease;
  z-index: 3;
}
.carousel-arrow:hover { opacity: 1; background: rgba(10, 14, 26, 0.6); }
.carousel-arrow svg { width: 15px; height: 15px; }
.carousel-arrow-left { left: 8px; }
.carousel-arrow-right { right: 8px; }

.carousel-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(10, 14, 26, 0.55);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  z-index: 4;
}
.carousel-delete-btn:hover { background: var(--danger); }

.carousel-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 3;
}
.carousel-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  border: none;
  padding: 0;
  cursor: pointer;
}
.carousel-dot.active { background: var(--accent); }

/* Caption: straddles the top edge of the frame (half above, half on the photo) */
.hero-photo-caption {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 9px 22px;
  border-radius: 999px;
  white-space: nowrap;
}

.hero-photo-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding: 60px var(--gutter); gap: 48px; }
  .hero-avatar-wrap { order: -1; }
  .hero-photo-frame { width: min(352px, 78vw); aspect-ratio: 11 / 14; }
  .hero-carousel { border-radius: 44px; }
}

/* ============================================================================
   BUTTONS
============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-outline {
  border: none;
  color: var(--accent);
  background: transparent;
  padding: 4px 0;
  border-bottom: 1px solid var(--accent);
  border-radius: 0;
  font-weight: 600;
}
.btn-outline::after { content: "\2192"; margin-left: 7px; }
.btn-outline:hover { color: var(--accent-dim); border-color: var(--accent-dim); }
.btn-text {
  background: none; border: none;
  color: var(--fg-muted);
  padding: 8px 4px;
  text-underline-offset: 3px;
}
.btn-text:hover { color: var(--fg); text-decoration: underline; }
.btn-text-danger {
  background: none; border: none;
  color: var(--danger);
  font-size: 14px;
  cursor: pointer;
}

/* ============================================================================
   SECTIONS (general)
============================================================================ */
.section { padding: 120px var(--gutter); }
.section-alt {
  background-color: var(--bg-alt);
  background-image: radial-gradient(rgba(28, 27, 24, 0.09) 1px, transparent 1px);
  background-size: 18px 18px;
}
.section-inner { max-width: var(--max-width); margin: 0 auto; }
.section-heading-block {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 48px;
}
.section-index {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  font-weight: 500;
  color: var(--fg-faint);
  line-height: 1;
  flex-shrink: 0;
}
.section-heading { position: relative; z-index: 1; font-size: clamp(30px, 4vw, 40px); }
@media (max-width: 640px) {
  .section-index { display: none; }
}

/* About */
.about-grid { max-width: 780px; }
.about-body { color: var(--fg-muted); font-size: 17px; white-space: pre-line; }

/* Timeline (Experience / Education) */
.timeline {
  position: relative;
  padding-left: 32px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 44px;
}
.timeline-item { position: relative; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -37.5px; top: 6px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline-dates {
  font-size: 13px;
  color: var(--fg-faint);
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}
.timeline-title { font-size: 20px; margin: 6px 0 2px; }
.timeline-org { color: var(--accent); font-size: 14px; margin-bottom: 10px; }
.timeline-desc { color: var(--fg-muted); font-size: 15px; white-space: pre-line; }

/* Card grid (Achievements) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
.card {
  background: var(--bg);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.section-alt .card { background: var(--bg-alt); }
.card-title { font-size: 18px; }
.card-date { font-size: 12px; color: var(--fg-faint); font-family: var(--font-display); }
.card-desc { color: var(--fg-muted); font-size: 14px; white-space: pre-line; }
.card-link { font-size: 13px; color: var(--accent); text-decoration: none; margin-top: auto; }
.card-link:hover { text-decoration: underline; }

/* Project list (row-based, not a grid — no phantom empty cells on partial rows) */
.project-list {
  display: flex;
  flex-direction: column;
}
.project-row {
  display: flex;
  gap: 28px;
  padding: 30px 0;
  border-top: 1px solid var(--border);
  transition: background 0.15s ease;
}
.project-row:first-child { border-top: none; padding-top: 0; }
.project-number {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  color: var(--fg-faint);
  flex-shrink: 0;
  width: 28px;
  padding-top: 2px;
}
.project-thumb {
  width: 104px;
  height: 104px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-alt);
}
.project-thumb img { width: 100%; height: 100%; object-fit: cover; }
.project-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--fg-faint);
}
.project-content { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.project-title { font-size: 19px; }
.project-desc { color: var(--fg-muted); font-size: 14px; white-space: pre-line; }

.empty-state {
  color: var(--fg-faint);
  font-size: 14px;
  font-style: italic;
}

/* Contact */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
}
.contact-intro { color: var(--fg-muted); max-width: 42ch; margin: 18px 0 20px; }
.contact-email { color: var(--accent); font-size: 15px; }
.contact-form { display: flex; flex-direction: column; gap: 18px; }
.contact-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--fg-muted);
}
.contact-form input, .contact-form textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 3px;
  resize: vertical;
}
.section-alt .contact-form input, .section-alt .contact-form textarea { background: var(--bg-alt); }
.contact-form input:focus, .contact-form textarea:focus { border-color: var(--accent); }
.contact-form .btn { align-self: flex-start; margin-top: 6px; }
.form-status { font-size: 13px; color: var(--fg-muted); min-height: 18px; }
.form-error { font-size: 13px; color: var(--danger); min-height: 16px; }

@media (max-width: 860px) {
  .contact-grid { grid-template-columns: 1fr; }
  .section { padding: 88px var(--gutter); }
}

/* ============================================================================
   FOOTER
============================================================================ */
/* ============================================================================
   AFFILIATIONS — Infinite auto-scrolling strip (with Drag & Hover Pause)
============================================================================ */
.affiliations-section {
  padding: 56px 0;
  border-top: 1px solid var(--border);
  overflow: hidden;
}

.affiliations-top {
  padding-top: 150px;
  border-top: none;
}

.affiliations-heading-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.eyebrow-label {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.marquee {
  width: 100vw;
  position: relative;
  left: 50%;
  margin-left: -50vw;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, black 6%, black 94%, transparent);
  mask-image: linear-gradient(90deg, transparent, black 6%, black 94%, transparent);
  
  /* Hide scrollbars across all browsers */
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.marquee::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.marquee-track {
  display: flex;
  align-items: center;
  gap: 48px;
  width: max-content;
  cursor: grab;
  touch-action: pan-y; /* Prevents vertical swipe conflicts */
  will-change: transform;
}

.marquee-track:active {
  cursor: grabbing;
}
@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; }
  .marquee { overflow-x: auto; }
}

.affiliation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 var(--gutter);
  white-space: nowrap;
  flex-shrink: 0;
}
.affiliation-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--fg);
  transition: color 0.15s ease;
}
.affiliation-link:hover { color: var(--accent); }
.affiliation-badge {
  width: 40px; height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.affiliation-badge img { width: 100%; height: 100%; object-fit: cover; }
.affiliation-badge-empty {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  color: var(--fg-faint);
}
.affiliation-name { font-size: 15px; font-weight: 500; }
.affiliation-item-controls {
  display: none;
  align-items: center;
  gap: 4px;
}
.is-owner .affiliation-item-controls { display: flex; }
.affiliation-item-controls .edit-btn { padding: 4px 10px; font-size: 12px; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px var(--gutter);
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}
.footer-social { display: flex; gap: 16px; }
.footer-social a {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--fg-muted);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.footer-social a:hover { color: var(--accent); border-color: var(--accent-dim); }
.footer-social svg { width: 16px; height: 16px; }
.footer-meta { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.footer-meta p { margin: 0; color: var(--fg-faint); font-size: 13px; }
.footer-links { display: flex; gap: 16px; }
.link-btn {
  background: none; border: none; padding: 0;
  color: var(--fg-faint);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-family: var(--font-body);
}
.link-btn:hover { color: var(--fg); }

/* ============================================================================
   MODALS
============================================================================ */
.modal {
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg-alt);
  color: var(--fg);
  padding: 0;
  width: min(440px, 92vw);
}
.modal::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); }
.modal-form { padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.modal-form h3 { font-size: 20px; margin-bottom: 4px; }
.modal-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; color: var(--fg-muted);
}
.modal-form input, .modal-form textarea, .modal-form select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 3px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 8px; }
.modal-actions-split { justify-content: space-between; }
.modal-actions-right { display: flex; gap: 12px; }
.privacy-body { color: var(--fg-muted); font-size: 14px; white-space: pre-line; line-height: 1.7; }

/* ============================================================================
   HERO ENTRANCE — one deliberate moment, respects reduced motion
============================================================================ */
.hero-text > * {
  opacity: 0;
  animation: rise 0.7s ease forwards;
}
.hero-text > *:nth-child(1) { animation-delay: 0.05s; }
.hero-text > *:nth-child(2) { animation-delay: 0.15s; }
.hero-text > *:nth-child(3) { animation-delay: 0.25s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-text > * { opacity: 1; animation: none; }
}

.skip-link {
  position: absolute;
  top: -60px;
  left: 16px;
  z-index: 100;
  background: var(--fg);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 16px;
}

/* ============================================================================
   TOAST (upload / save feedback)
============================================================================ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 10px);
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 22px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); color: #1a0d0a; }
