/* ========================================
   Theme Variables
   ======================================== */
:root {
  --color-bg: #fbfbfd;
  --color-surface: rgba(255, 255, 255, 0.72);
  --color-surface-solid: #ffffff;
  --color-surface-hover: rgba(245, 245, 247, 0.8);
  --color-text: #1d1d1f;
  --color-text-secondary: #6e6e73;
  --color-text-tertiary: #86868b;
  --color-accent: #0071e3;
  --color-accent-hover: #0077ed;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-solid: #d2d2d7;
  --color-nav-bg: rgba(251, 251, 253, 0.72);
  --color-shadow: rgba(0, 0, 0, 0.06);
  --color-shadow-hover: rgba(0, 0, 0, 0.1);
  --color-tag-bg: #f0f0f5;
  --color-tag-text: #424245;
  --color-toggle-bg: #e8e8ed;
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
    'Inter', 'Helvetica Neue', sans-serif;
  --max-width: 820px;
  --radius: 20px;
  --radius-sm: 14px;
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dark Mode */
[data-theme="dark"] {
  --color-bg: #000000;
  --color-surface: rgba(255, 255, 255, 0.06);
  --color-surface-solid: #1c1c1e;
  --color-surface-hover: rgba(255, 255, 255, 0.1);
  --color-text: #f5f5f7;
  --color-text-secondary: #a1a1a6;
  --color-text-tertiary: #86868b;
  --color-accent: #2997ff;
  --color-accent-hover: #64b5f6;
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-solid: #424245;
  --color-nav-bg: rgba(0, 0, 0, 0.72);
  --color-shadow: rgba(0, 0, 0, 0.3);
  --color-shadow-hover: rgba(0, 0, 0, 0.5);
  --color-tag-bg: rgba(255, 255, 255, 0.08);
  --color-tag-text: #a1a1a6;
  --color-toggle-bg: #2c2c2e;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #000000;
    --color-surface: rgba(255, 255, 255, 0.06);
    --color-surface-solid: #1c1c1e;
    --color-surface-hover: rgba(255, 255, 255, 0.1);
    --color-text: #f5f5f7;
    --color-text-secondary: #a1a1a6;
    --color-text-tertiary: #86868b;
    --color-accent: #2997ff;
    --color-accent-hover: #64b5f6;
    --color-border: rgba(255, 255, 255, 0.08);
    --color-border-solid: #424245;
    --color-nav-bg: rgba(0, 0, 0, 0.72);
    --color-shadow: rgba(0, 0, 0, 0.3);
    --color-shadow-hover: rgba(0, 0, 0, 0.5);
    --color-tag-bg: rgba(255, 255, 255, 0.08);
    --color-tag-text: #a1a1a6;
    --color-toggle-bg: #2c2c2e;
  }
}

/* ========================================
   Reset & Base
   ======================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.47059;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 32px;
}

/* ========================================
   Sticky Glassmorphic Nav
   ======================================== */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--color-nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--color-border);
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.35s var(--ease-out), opacity 0.35s var(--ease-out);
}

.nav.visible {
  transform: translateY(0);
  opacity: 1;
}

.nav__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: transform 0.3s var(--ease-out);
}

.nav__logo:hover {
  transform: scale(1.08);
}

.nav__logo + .nav__name {
  margin-left: 10px;
}

.nav__name {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 20px;
  list-style: none;
}

.nav__links a {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.nav__links a:hover {
  color: var(--color-text);
}

/* Theme Toggle */
.theme-toggle {
  background: var(--color-toggle-bg);
  border: none;
  border-radius: 980px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.theme-toggle:hover {
  transform: scale(1.08);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.4s var(--ease-spring);
}

.theme-toggle:hover svg {
  transform: rotate(15deg);
}

.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun  { display: block; }

[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: none; }
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* JS-triggered fade-in (fallback) */
.fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}

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

/* CSS scroll-driven animations (progressive enhancement) */
@supports (animation-timeline: view()) {
  .fade-in {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 1s var(--ease-out) both;
    animation-timeline: view();
    animation-range: entry 0% entry 30%;
    transition: none;
  }

  .fade-in.is-visible {
    /* Let CSS scroll timeline take over */
  }
}

@keyframes heroIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Blur-up photo load */
@keyframes photoReveal {
  from {
    filter: blur(10px);
    opacity: 0.6;
  }
  to {
    filter: blur(0);
    opacity: 1;
  }
}

/* ========================================
   Hero
   ======================================== */
.hero {
  padding: 140px 0 80px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero > .container {
  animation: heroIn 1s var(--ease-out) both;
}

.hero::before {
  content: '';
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 1000px;
  height: 600px;
  background:
    radial-gradient(ellipse at 25% 40%, rgba(0, 113, 227, 0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 40%, rgba(88, 86, 214, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 90%, rgba(52, 199, 89, 0.04) 0%, transparent 55%);
  pointer-events: none;
  animation: heroGlow 8s ease-in-out infinite alternate;
}

@keyframes heroGlow {
  0% { opacity: 0.6; transform: translateX(-50%) scale(1); }
  100% { opacity: 1; transform: translateX(-50%) scale(1.08); }
}

.hero__photo-wrapper {
  position: relative;
  display: inline-block;
  margin-bottom: 36px;
}

.hero__photo-wrapper::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    #0071e3, #5856d6, #af52de, #ff2d55, #ff9500, #34c759, #0071e3
  );
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 0;
  animation: ringRotate 4s linear infinite;
}

@keyframes ringRotate {
  to { transform: rotate(360deg); }
}

.hero__photo-wrapper:hover::before {
  opacity: 0.7;
}

.hero__photo-wrapper::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    #0071e3, #5856d6, #af52de, #ff2d55, #ff9500, #34c759, #0071e3
  );
  opacity: 0;
  filter: blur(20px);
  transition: opacity 0.5s ease;
  z-index: -1;
}

.hero__photo-wrapper:hover::after {
  opacity: 0.35;
}

.hero__photo {
  position: relative;
  z-index: 1;
  width: 152px;
  height: 152px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--color-bg);
  box-shadow: 0 4px 24px var(--color-shadow);
  transition: transform 0.5s var(--ease-out), border-color 0.4s ease;
  animation: photoReveal 0.8s var(--ease-out) both;
  animation-delay: 0.2s;
}

.hero__photo-wrapper:hover .hero__photo {
  transform: scale(1.04);
}

.hero h1 {
  font-size: 4rem;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.05;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--color-text) 0%, var(--color-text-secondary) 50%, var(--color-text) 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 6s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.hero__title {
  font-size: 1.5rem;
  color: var(--color-text-secondary);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}

.hero__location {
  font-size: 0.9375rem;
  color: var(--color-text-tertiary);
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hero__location::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #34c759;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(52, 199, 89, 0.5);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========================================
   Sections
   ======================================== */
section {
  padding: 72px 0;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-text);
  margin-bottom: 32px;
  text-transform: none;
  position: relative;
  display: inline-block;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 36px;
  height: 3px;
  background: linear-gradient(90deg, var(--color-accent), #5856d6);
  border-radius: 2px;
}

/* Divider */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border), transparent);
  border: none;
  margin: 0;
}

/* ========================================
   About
   ======================================== */
.about p {
  color: var(--color-text-secondary);
  font-size: 1.25rem;
  line-height: 1.7;
  max-width: 640px;
}

/* ========================================
   Cards (shared)
   ======================================== */
.card {
  padding: 28px 32px;
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px var(--color-shadow);
  transition: all 0.4s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--color-accent), #5856d6);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.card:hover {
  border-color: var(--color-border-solid);
  box-shadow: 0 8px 32px var(--color-shadow-hover);
  transform: translateY(-3px);
}

.card:hover::before {
  opacity: 1;
}

.card:active {
  transform: translateY(-1px) scale(0.995);
  transition-duration: 0.1s;
}

.card h3 {
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 4px;
}

.card .subtitle {
  font-size: 1rem;
  color: var(--color-accent);
  font-weight: 500;
}

.card .period {
  font-size: 0.8125rem;
  color: var(--color-text-tertiary);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.card .description {
  font-size: 1rem;
  color: var(--color-text-secondary);
  line-height: 1.7;
}

/* ========================================
   Skills / Tech
   ======================================== */
.skills-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.skill-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
  border-radius: 980px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.3s var(--ease-out);
  border: 1px solid transparent;
}

.skill-tag:hover {
  background: var(--color-surface);
  border-color: var(--color-border-solid);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--color-shadow);
}

.skill-tag:active {
  transform: translateY(0) scale(0.97);
  transition-duration: 0.1s;
}

.skill-tag svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

/* ========================================
   Certifications — Bento Grid
   ======================================== */
.cert-bento {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}

.cert-item {
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 1px 4px var(--color-shadow);
  transition: all 0.4s var(--ease-out);
  position: relative;
  overflow: hidden;
  grid-column: span 3;
}

/* Animated gradient border on hover */
.cert-item::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  background: linear-gradient(135deg, var(--color-accent), #5856d6, #af52de, var(--color-accent));
  background-size: 300% 300%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s ease;
  animation: gradientShift 3s ease-in-out infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.cert-item:hover::before {
  opacity: 1;
}

.cert-item:hover {
  box-shadow: 0 8px 32px var(--color-shadow-hover);
  transform: translateY(-4px);
}

.cert-item:active {
  transform: translateY(-1px) scale(0.98);
  transition-duration: 0.1s;
}

/* Bento sizes */
.cert-item--wide {
  grid-column: span 4;
}

.cert-item--narrow {
  grid-column: span 2;
}

.cert-item__badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(0, 113, 227, 0.1), rgba(88, 86, 214, 0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 1.125rem;
}

.cert-item h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  line-height: 1.35;
}

.cert-item .issuer {
  font-size: 0.8125rem;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* ========================================
   Contact
   ======================================== */
.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: var(--color-surface);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  border-radius: 980px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: 0 1px 4px var(--color-shadow);
  transition: all 0.35s var(--ease-out);
}

.contact-link:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(0, 113, 227, 0.3);
  transform: translateY(-2px);
}

.contact-link:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.2);
  transition-duration: 0.1s;
}

.contact-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.3s var(--ease-spring);
}

.contact-link:hover svg {
  transform: scale(1.15);
}

/* ========================================
   Footer
   ======================================== */
footer {
  padding: 48px 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-tertiary);
  position: relative;
}

footer::before {
  content: '';
  display: block;
  width: 40px;
  height: 2px;
  background: var(--color-border);
  margin: 0 auto 24px;
  border-radius: 1px;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 680px) {
  .hero {
    padding: 100px 0 56px;
  }

  .hero h1 {
    font-size: 2.6rem;
  }

  .hero__title {
    font-size: 1.2rem;
  }

  .hero__photo {
    width: 120px;
    height: 120px;
  }

  .container {
    padding: 0 20px;
  }

  .nav__inner {
    padding: 12px 20px;
  }

  .nav__links a {
    display: none;
  }

  section {
    padding: 48px 0;
  }

  .section-title {
    font-size: 1.5rem;
    margin-bottom: 24px;
  }

  .cert-bento {
    grid-template-columns: 1fr;
  }

  .cert-item,
  .cert-item--wide,
  .cert-item--narrow {
    grid-column: span 1;
  }

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

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

  .card {
    padding: 24px;
  }

  .about p {
    font-size: 1.0625rem;
  }
}

@media (max-width: 380px) {
  .hero h1 {
    font-size: 2.1rem;
  }
}
