/* Ultra minimalist, monochromatic */

:root {
  --bg: #fafafa;
  --fg: #0a0a0a;
  --muted: #737373;
  --border: #e5e5e5;
  --reveal-faint: #d1d1d1;
  --gap: clamp(1.5rem, 4vw, 3rem);
  --max: 52rem;
}

/* Auto dark/light: entire site follows system preference */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --fg: #fafafa;
    --muted: #a3a3a3;
    --border: #262626;
    --reveal-faint: #404040;
  }
}

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

html {
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  padding-top: 0;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-weight: 300;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
}

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

/* Hero: background aligned to top edge; content has safe spacing */
.hero {
  position: relative;
  padding: 0 0 clamp(0.75rem, 2vw, 1.5rem);
  overflow: hidden;
  min-height: 38rem;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  user-drag: none;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

@keyframes hero-bg-fade-in {
  from { opacity: 0; }
  to { opacity: 0.2; }
}

.hero-bg::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  /* Taller so parallax translate doesn't reveal bottom edge */
  height: 140%;
  background-image: var(--hero-bg-url, none);
  background-size: cover;
  /* Position so face (upper half of image) is in the visible band */
  background-position: center 35%;
  background-repeat: no-repeat;
  opacity: 0;
  will-change: transform;
  transform: translateY(calc(var(--hero-parallax, 0) * 1px));
}

.hero-bg.hero-bg-loaded::before {
  animation: hero-bg-fade-in 2s ease-out forwards;
}

/* Smooth bottom gradient to merge with page background (uses var(--bg) for light/dark) */
.hero-bg::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 45%;
  background: linear-gradient(to top, var(--bg) 0%, transparent 100%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  padding-top: max(1.25rem, env(safe-area-inset-top));
}

/* Desktop: hero background full viewport width, tall band so full face is visible */
@media (min-width: 768px) {
  .hero {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    /* Tall band: ~70vh so full face + shoulders fit; cap for very tall screens */
    min-height: min(56rem, 72vh);
  }
  .hero-content {
    max-width: var(--max);
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

/* Mobile: hero background full width of screen (break out of main padding) */
@media (max-width: 767px) {
  .hero {
    width: calc(100% + 2.5rem);
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

.hero h1 {
  margin: 0 0 0.35em;
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.hero .title {
  margin: 0 0 0.25em;
  font-weight: 400;
  color: var(--muted);
}

.hero .meta {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.hero a,
main section a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  border-bottom: 1px solid var(--border);
}

.hero a:hover,
main section a:hover {
  border-bottom-color: var(--fg);
}

/* Sections */
section {
  padding: var(--gap) 0;
  border-bottom: 1px solid var(--border);
}

.hero + section {
  padding-top: clamp(0.75rem, 2vw, 1.25rem);
}

section:last-of-type {
  border-bottom: none;
}

h2 {
  margin: 0 0 1rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Scroll reveal: words transition from faint to full color as they cross the reveal line */
.reveal-word {
  color: var(--reveal-faint);
  transition: color 1s ease-out;
}
.reveal-word.revealed {
  color: inherit;
}

.summary p {
  margin: 0;
  max-width: 38rem;
}

/* Competencies */
.competencies {
  margin: 0;
  padding: 0;
  list-style: none;
}

.competencies li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.competencies li:last-child {
  border-bottom: none;
}

.competencies li::before {
  content: "• ";
  color: var(--muted);
}

/* Roles */
.roles {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.roles article {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.roles .role {
  font-weight: 500;
}

.roles .company,
.roles .when {
  font-size: 0.9rem;
  color: var(--muted);
}

.roles p {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

/* Education */
.education {
  margin: 0;
  padding: 0;
  list-style: none;
}

.education li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.education li:last-child {
  border-bottom: none;
}

/* Footer */
footer {
  padding: var(--gap) 0 0;
  margin-top: var(--gap);
  font-size: 0.9rem;
  color: var(--muted);
}

footer a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  border-bottom: 1px solid var(--border);
}

footer a:hover {
  border-bottom-color: var(--fg);
}

footer .copyright {
  margin: 1rem 0 0;
  font-size: 0.8rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Chatbot widget: floating avatar + panel */
#chatbot-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}

.chatbot-cta-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-direction: row-reverse;
}

.chatbot-cta {
  display: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  animation: chatbot-cta-pulse 2.2s ease-in-out infinite;
}

@keyframes chatbot-cta-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@media (min-width: 768px) {
  .chatbot-cta {
    display: inline-block;
  }
}

.chatbot-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  animation: chatbot-toggle-halo 4s ease-in-out infinite;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chatbot-toggle::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    transparent 280deg,
    rgba(255, 255, 255, 0.35) 310deg,
    transparent 340deg
  );
  animation: chatbot-toggle-spin 8s linear infinite;
  z-index: 0;
}

.chatbot-toggle::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--bg);
  z-index: 1;
}

.chatbot-toggle:hover {
  border-color: var(--muted);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  animation-duration: 2s;
}

.chatbot-toggle svg {
  position: relative;
  z-index: 2;
  width: 1.5rem;
  height: 1.5rem;
  stroke: var(--fg);
}

@keyframes chatbot-toggle-halo {
  0%, 100% { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 0 14px 2px rgba(255, 255, 255, 0.07); }
  50% { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 0 22px 4px rgba(255, 255, 255, 0.14); }
}

@keyframes chatbot-toggle-spin {
  to { transform: rotate(360deg); }
}

.chatbot-panel {
  position: absolute;
  bottom: calc(100% + 0.75rem);
  right: 0;
  width: 22rem;
  max-width: calc(100vw - 3rem);
  max-height: 28rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem) scale(0.98);
  transition:
    opacity 0.35s ease-out,
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s 0.35s; /* delay visibility on close so exit animates */
}

.chatbot-panel-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition:
    opacity 0.35s ease-out,
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s 0s; /* visible immediately when opening */
}

/* Desktop: iPhone 17 portrait (vertical) aspect ratio 1206×2622, keep width 22rem */
@media (min-width: 768px) {
  .chatbot-panel {
    aspect-ratio: 1206 / 2622;
    height: auto;
    max-height: none;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .chatbot-bg-video {
    opacity: 0.07;
  }

  .chatbot-panel > .chatbot-header,
  .chatbot-panel > .chatbot-messages,
  .chatbot-panel > .chatbot-form {
    position: relative;
    z-index: 1;
  }

  .chatbot-messages {
    max-height: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .chatbot-form {
    flex-shrink: 0;
    margin-top: auto;
  }

  .chatbot-messages::before {
    display: none;
  }
}

/* Video background for all modes */
.chatbot-bg-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
  opacity: 0.07;
  transition: opacity 0.3s ease;
}

/* Fallback background when video fails */
.chatbot-bg-video[src="/chatvideoprofile.mp4"]:not([loaded]) {
  background-image: url("/profile.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.chatbot-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.chatbot-close:hover {
  color: var(--fg);
  background: var(--border);
}

.chatbot-close svg {
  width: 1rem;
  height: 1rem;
}

.chatbot-messages {
  flex: 1;
  min-height: 12rem;
  max-height: 18rem;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
}

/* Video background covers messages area on mobile */
.chatbot-messages > * {
  position: relative;
  z-index: 1;
}

.chatbot-msg {
  display: flex;
  justify-content: flex-start;
}

.chatbot-msg-user {
  justify-content: flex-end;
}

.chatbot-bubble {
  max-width: 85%;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  line-height: 1.5;
  border-radius: 0.5rem;
}

.chatbot-msg-assistant .chatbot-bubble {
  background: var(--border);
  background: color-mix(in srgb, var(--border) 92%, transparent);
  color: var(--fg);
  border: 1px solid var(--border);
  border-color: color-mix(in srgb, var(--border) 80%, transparent);
}

.chatbot-msg-user .chatbot-bubble {
  background: var(--fg);
  background: color-mix(in srgb, var(--fg) 92%, transparent);
  color: var(--bg);
  border: 1px solid var(--fg);
  border-color: color-mix(in srgb, var(--fg) 80%, transparent);
}

.chatbot-loading {
  position: absolute;
  top: 1rem;
  left: 1rem;
  padding: 0.25rem 0;
  font-size: 0.8rem;
  color: var(--muted);
  visibility: hidden;
}

.chatbot-loading-visible {
  visibility: visible;
}

/* Grok-style: single pill with input + send circle */
.chatbot-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.chatbot-input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: none;
  border-radius: 9999px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--fg);
  background: var(--border);
}

.chatbot-input::placeholder {
  color: var(--muted);
}

.chatbot-input:focus {
  outline: none;
  background: var(--border);
  box-shadow: 0 0 0 2px var(--muted);
}

.chatbot-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  color: var(--bg);
  background: var(--fg);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.chatbot-send:hover {
  opacity: 0.9;
}

.chatbot-send:active {
  transform: scale(0.96);
}

.chatbot-send svg {
  width: 1.15rem;
  height: 1.15rem;
}

/* Mobile: full-screen chat mode (Grok-style) */
@media (max-width: 767px) {
  #chatbot-widget {
    bottom: 1rem;
    right: 1rem;
  }

  #chatbot-widget:has(.chatbot-panel-open) .chatbot-cta-wrap {
    display: none;
  }

  .chatbot-panel {
    position: fixed;
    bottom: auto !important;
    right: auto !important;
    left: 0;
    top: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.35s;
  }

  .chatbot-bg-video {
    border-radius: 0;
  }

  .chatbot-panel-open {
    transform: translateY(0);
    visibility: visible;
  }

  .chatbot-header {
    padding: 1rem 1rem;
    padding-top: max(1rem, env(safe-area-inset-top));
    font-size: 0.75rem;
  }

  .chatbot-messages {
    max-height: none;
    min-height: 0;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
  }

  .chatbot-form {
    padding: 0.75rem 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    min-height: 3.5rem;
    flex-shrink: 0;
  }

  .chatbot-input {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    min-height: 2.75rem;
  }

  .chatbot-send {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
  }

.chatbot-send svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Email links in chat messages */
.chatbot-email-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  font-weight: 500;
  transition: opacity 0.15s;
}

.chatbot-email-link:hover {
  opacity: 0.8;
}

/* Ensure links don't break bubble styling */
.chatbot-msg-assistant .chatbot-email-link,
.chatbot-msg-user .chatbot-email-link {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
}

  .chatbot-close {
    width: 2.25rem;
    height: 2.25rem;
  }

  .chatbot-close svg {
    width: 1.25rem;
    height: 1.25rem;
  }
}
