/* ─── Google Fonts ─── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

/* ─── CSS Custom Properties ─── */
:root {
  --background: 60 9% 98%;
  --foreground: 0 0% 10%;
  --card: 0 0% 100%;
  --card-foreground: 0 0% 10%;
  --primary: 0 0% 10%;
  --primary-foreground: 60 9% 98%;
  --secondary: 60 5% 94%;
  --secondary-foreground: 0 0% 10%;
  --muted: 60 5% 94%;
  --muted-foreground: 0 0% 40%;
  --accent: 173 58% 39%;
  --accent-foreground: 0 0% 100%;
  --border: 60 5% 88%;
  --input: 60 5% 88%;
  --ring: 173 58% 39%;
  --radius: 0.5rem;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

.dark {
  --background: 0 0% 5%;
  --foreground: 60 9% 98%;
  --card: 0 0% 8%;
  --card-foreground: 60 9% 98%;
  --primary: 60 9% 98%;
  --primary-foreground: 0 0% 5%;
  --secondary: 0 0% 15%;
  --secondary-foreground: 60 9% 98%;
  --muted: 0 0% 15%;
  --muted-foreground: 0 0% 65%;
  --accent: 173 58% 45%;
  --accent-foreground: 0 0% 100%;
  --border: 0 0% 20%;
  --input: 0 0% 20%;
  --ring: 173 58% 45%;
}

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

html {
  scroll-behavior: smooth;
  font-family: var(--font-body);
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  margin: 0;
  padding: 0;
  transition: background-color 0.3s, color 0.3s;
}

/* ─── Section Container ─── */
.section-container {
  margin-left: auto;
  margin-right: auto;
  max-width: 80rem; /* 1280px */
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}
@media (min-width: 1024px) {
  .section-container {
    padding-left: 3rem;
    padding-right: 3rem;
  }
}

/* ─── Typography ─── */
.font-display { font-family: var(--font-display); }

/* ─── Custom Keyframes ─── */

/* Hero entrance animations */
@keyframes heroFadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes heroFadeScale {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes navSlideDown {
  from { opacity: 0; transform: translateY(-100%); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Reused utility */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── Hero entrance helpers ─── */
.hero-animate {
  opacity: 0;
  animation: heroFadeUp 0.6s ease-out forwards;
}
.hero-animate-scale {
  opacity: 0;
  animation: heroFadeScale 0.8s ease-out forwards;
}

/* Delays */
.delay-200  { animation-delay: 0.2s; }
.delay-400  { animation-delay: 0.4s; }
.delay-600  { animation-delay: 0.6s; }
.delay-800  { animation-delay: 0.8s; }
.delay-1000 { animation-delay: 1.0s; }
.delay-1500 { animation-delay: 1.5s; }

/* ─── Navbar ─── */
nav.site-nav {
  animation: navSlideDown 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ─── Typewriter cursor ─── */
.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background-color: hsl(var(--accent));
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink-cursor 1s step-end infinite;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ─── Mouse spotlight ─── */
.spotlight-section {
  position: relative;
  overflow: hidden;
}
.spotlight-overlay {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 0;
  transition: opacity 0.3s;
}
.spotlight-section > * { position: relative; z-index: 1; }

/* ─── Grid background (hero) ─── */
.grid-bg {
  background-image:
    linear-gradient(hsl(var(--foreground) / 0.03) 1px, transparent 1px),
    linear-gradient(90deg, hsl(var(--foreground) / 0.03) 1px, transparent 1px);
  background-size: 4rem 4rem;
}

/* ─── Logo marquee ─── */
.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee 30s linear infinite;
}
@keyframes marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.marquee-fade-left {
  background: linear-gradient(to right, hsl(var(--background)) 0%, transparent 100%);
}
.marquee-fade-right {
  background: linear-gradient(to left, hsl(var(--background)) 0%, transparent 100%);
}

/* ─── Timeline (Experience) ─── */
/* ─── Experience Timeline (CSS Grid — spine in its own column) ─── */

/* The continuous spine runs behind all rows */
#experience-list {
  position: relative;
}
#experience-list::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 1rem;                         /* mobile: aligns with node column centre */
  width: 1px;
  background: hsl(var(--border));
  z-index: 0;
}
@media (min-width: 768px) {
  #experience-list::before {
    left: 50%;
    transform: translateX(-0.5px);    /* desktop: true centre */
  }
}

/* Each row: [card] [node] [empty]  or  [empty] [node] [card] */
.exp-item {
  display: grid;
  grid-template-columns: 2rem 1fr;    /* mobile: spine-col | card-col */
  grid-template-areas: "node card";
  margin-bottom: 2.5rem;
  position: relative;
}
@media (min-width: 768px) {
  .exp-item {
    grid-template-columns: 1fr 4rem 1fr; /* desktop: left | spine-col | right */
  }
  .exp-item--left  { grid-template-areas: "card node empty"; }
  .exp-item--right { grid-template-areas: "empty node card"; }
}

.exp-item__card  { grid-area: card;  }
.exp-item__node  { grid-area: node;  }
.exp-item__empty { grid-area: empty; display: none; }

@media (min-width: 768px) {
  .exp-item__empty { display: block; }
  .exp-item--left  .exp-item__card { padding-right: 1.75rem; }
  .exp-item--right .exp-item__card { padding-left:  1.75rem; }
}

/* Node column: centres the dot and sits above the spine pseudo-element */
.exp-item__node {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 1.75rem;
  position: relative;
  z-index: 1;
}

/* The dot */
.exp-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: hsl(var(--accent));
  box-shadow: 0 0 0 4px hsl(var(--background));
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

/* ─── Gradient text ─── */
.gradient-text {
  background: linear-gradient(
    135deg,
    hsl(var(--foreground)) 0%,
    hsl(var(--muted-foreground)) 50%,
    hsl(var(--foreground)) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ─── Link underline animation ─── */
.link-underline {
  position: relative;
}
.link-underline::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background-color: hsl(var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}
.link-underline:hover::after { transform: scaleX(1); }

/* ─── D3 World Map ─── */
#world-map-svg {
  width: 100%;
  height: 100%;
}
#world-map-svg .land {
  fill: hsl(var(--secondary));
  stroke: hsl(var(--background));
  stroke-width: 0.5;
  transition: fill 0.2s;
}
.dark #world-map-svg .land {
  fill: hsl(var(--secondary));
}
.map-pin {
  fill: #0d9488;
  stroke: white;
  stroke-width: 1.5;
  cursor: pointer;
  transform-origin: center;
  transform-box: fill-box;
  transition: transform 0.2s, filter 0.2s;
}
.map-pin:hover {
  transform: scale(1.5);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.map-tooltip {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  max-width: 220px;
  z-index: 10;
}
.map-tooltip.visible { opacity: 1; }
.map-tooltip .badge-work     { background: hsl(173 58% 39% / 0.15); color: hsl(173 58% 39%); }
.map-tooltip .badge-personal { background: hsl(var(--secondary)); color: hsl(var(--muted-foreground)); }
.map-tooltip .badge-both     { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }

/* ─── Contact form ─── */
.form-input {
  width: 100%;
  background: transparent;
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  color: hsl(var(--foreground));
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus {
  border-color: hsl(var(--accent));
  box-shadow: 0 0 0 3px hsl(var(--accent) / 0.1);
}
.form-input::placeholder { color: hsl(var(--muted-foreground)); }
.form-error {
  color: hsl(0 84.2% 60.2%);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* ─── Hero Photo Frame ─── */
.hero-photo-wrapper {
  position: relative;
  display: inline-block;
}
.hero-photo-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 1.25rem;
  border: 1.5px solid hsl(var(--accent) / 0.55);
  transform: translate(-12px, -12px);
  pointer-events: none;
  z-index: 0;
}
.hero-photo-frame {
  position: relative;
  z-index: 1;
  border-radius: 1rem;
  border: 1px solid hsl(var(--border));
  box-shadow: 0 4px 32px hsl(var(--foreground) / 0.06);
  background: transparent;
}

/* ─── Custom Cursor ─── */
@media (pointer: fine) {
  body, a, button, [role="button"], label, input, textarea, select { cursor: none; }
}

#cursor-dot {
  position: fixed;
  top: 0; left: 0;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: hsl(var(--accent));
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: opacity 0.2s;
}

#cursor-ring {
  position: fixed;
  top: 0; left: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid hsl(var(--accent) / 0.55);
  pointer-events: none;
  z-index: 9998;
  transform: translate(-50%, -50%);
  transition: width 0.18s ease, height 0.18s ease,
              background 0.18s ease, border-color 0.18s ease, opacity 0.2s;
}

#cursor-ring.hovering {
  width: 42px; height: 42px;
  background: hsl(var(--accent) / 0.07);
  border-color: hsl(var(--accent) / 0.85);
}

@media (pointer: coarse) {
  #cursor-dot, #cursor-ring { display: none; }
}

/* ─── Section backgrounds ─── */
.bg-section-dark {
  background-color: hsl(var(--foreground));
  color: hsl(var(--primary-foreground));
}

/* Contact form inputs sit on the inverted dark/light section background,
   so text and borders must use --primary-foreground (always the inverse). */
#contact-footer-wrapper .form-input {
  color: hsl(var(--primary-foreground));
  background: hsl(var(--primary-foreground) / 0.08);
  border-color: hsl(var(--primary-foreground) / 0.25);
}
#contact-footer-wrapper .form-input:focus {
  border-color: hsl(var(--accent));
  background: hsl(var(--primary-foreground) / 0.12);
  box-shadow: 0 0 0 3px hsl(var(--accent) / 0.15);
}
#contact-footer-wrapper .form-input::placeholder {
  color: hsl(var(--primary-foreground) / 0.45);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground)); }

/* ─── Mobile menu overlay ─── */
#mobile-menu {
  transition: opacity 0.2s, transform 0.2s;
}
#mobile-menu.hidden-menu {
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
}
#mobile-menu.visible-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ═══════════════════════════════════════════════════════════
   CHATBOT
═══════════════════════════════════════════════════════════ */

/* Floating bubble */
#chat-bubble {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  width: 56px;
  height: 56px;
  border-radius: 1rem;
  background: hsl(var(--accent));
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px hsl(var(--accent) / 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px hsl(var(--accent) / 0.55);
}

/* Panel */
#chat-panel {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 999;
  width: 340px;
  max-width: calc(100vw - 2rem);
  border-radius: 1.25rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 12px 48px rgba(0,0,0,0.18);
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#chat-panel.chat-panel-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Header */
#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--accent) / 0.06);
}
#chat-title {
  font-family: var(--font-display, serif);
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}
#chat-subtitle {
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
  margin-top: 1px;
}
#chat-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  padding: 0.2rem;
  border-radius: 0.4rem;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
#chat-close-btn:hover { color: hsl(var(--foreground)); }

/* Messages area */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 300px;
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--accent) / 0.3) transparent;
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-thumb {
  background: hsl(var(--accent) / 0.35);
  border-radius: 2px;
}

/* Message bubbles */
.chat-msg {
  max-width: 85%;
  padding: 0.55rem 0.8rem;
  border-radius: 1rem;
  font-size: 0.82rem;
  line-height: 1.45;
  word-break: break-word;
}
.chat-msg.user {
  align-self: flex-end;
  background: hsl(var(--accent));
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}
.chat-msg.ai {
  align-self: flex-start;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-bottom-left-radius: 0.25rem;
}

/* Markdown inside AI bubbles */
.chat-msg.ai p  { margin: 0 0 0.35rem 0; }
.chat-msg.ai p:last-child { margin-bottom: 0; }
.chat-msg.ai br { display: block; margin: 0.2rem 0; content: ''; }
.chat-msg.ai ul { margin: 0.25rem 0 0.35rem 1rem; padding: 0; list-style: disc; }
.chat-msg.ai li { margin-bottom: 0.2rem; }
.chat-msg.ai strong { font-weight: 600; }
.chat-msg.ai em    { font-style: italic; }
.chat-msg.ai code  {
  font-family: monospace;
  font-size: 0.78em;
  background: hsl(var(--accent) / 0.1);
  border-radius: 0.25rem;
  padding: 0.1em 0.3em;
}

/* Typing indicator */
#chat-typing {
  display: none;
}
#chat-typing .chat-msg.ai {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.65rem 0.9rem;
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: hsl(var(--accent));
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* Starter chips */
#chat-starters {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
#chat-starters-label {
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.15rem;
}
.chat-starter {
  text-align: left;
  background: none;
  border: 1px solid hsl(var(--accent) / 0.4);
  color: hsl(var(--foreground));
  border-radius: 0.65rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chat-starter:hover {
  background: hsl(var(--accent) / 0.12);
  border-color: hsl(var(--accent));
  color: hsl(var(--accent));
}

/* Input row */
#chat-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border-top: 1px solid hsl(var(--border));
}
#chat-input {
  flex: 1;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  color: hsl(var(--foreground));
  outline: none;
  transition: border-color 0.15s;
}
#chat-input:focus {
  border-color: hsl(var(--accent));
}
#chat-input:disabled {
  opacity: 0.5;
}
#chat-input::placeholder {
  color: hsl(var(--muted-foreground));
}
#chat-send-btn {
  background: hsl(var(--accent));
  color: #fff;
  border: none;
  border-radius: 0.65rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}
#chat-send-btn:hover:not(:disabled) {
  opacity: 0.88;
  transform: scale(1.05);
}
#chat-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
