/* =========================================================
   Jansher Chang Portfolio — Stylesheet
   Theme: dark, blue/purple gradient accents, code-inspired signature
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500&display=swap');

:root {
  --bg: #0a0e17;
  --bg-alt: #121826;
  --surface: #111827;
  --surface-border: #1f2937;
  --text: #ffffff;
  --text-muted: #c9cedd;
  --accent-blue: #5b7cfa;
  --accent-purple: #a463f2;
  --gradient: linear-gradient(120deg, var(--accent-blue), var(--accent-purple));
  --radius: 14px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

/* ---------- Light theme override ----------
   Toggled via JS by adding .light-theme to <html>. Base (dark) theme is
   defined in :root above; only the values that need to flip are redefined
   here so every component built on the CSS variables adapts automatically. */
.light-theme {
  --bg: #f6f5fd;
  --bg-alt: #e7e2fa;
  --surface: #ffffff;
  --surface-border: #e2defb;
  --text: #1c1b33;
  --text-muted: #33394a;
}

.light-theme body {
  background-image:
    radial-gradient(circle at 12% -10%, rgba(91, 124, 250, 0.10), transparent 42%),
    radial-gradient(circle at 90% 110%, rgba(164, 99, 242, 0.10), transparent 45%);
  background-color: var(--bg);
  background-attachment: fixed;
}
.light-theme body::before { color: rgba(91, 124, 250, 0.05); }
.light-theme .site-header { background: rgba(246, 245, 253, 0.82); }
.light-theme .hero-image-placeholder { background: linear-gradient(160deg, #ffffff, #f1eefc); border-color: #ded8fb; }
.light-theme .card,
.light-theme .skill-pill { box-shadow: 0 1px 2px rgba(28, 27, 51, 0.04); }
.light-theme .card:hover { box-shadow: 0 20px 44px rgba(107, 92, 231, 0.14); }
.light-theme .portfolio-thumb-placeholder { opacity: 0.35; }
.light-theme .gradient-text { filter: saturate(1.15); }
.light-theme .form-group input,
.light-theme .form-group textarea { background: #ffffff; }

html { scroll-behavior: smooth; direction: ltr; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
  direction: ltr;
  text-align: left;
}

/* subtle code-bracket watermark behind the whole page */
body::before {
  content: "</>";
  position: fixed;
  top: -4vw;
  right: -3vw;
  font-family: var(--font-mono);
  font-size: 28vw;
  color: rgba(91, 124, 250, 0.035);
  z-index: 0;
  pointer-events: none;
  user-select: none;
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate(0, 0) rotate(0deg); }
  to { transform: translate(-14px, 18px) rotate(3deg); }
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

h1, h2, h3 { font-family: var(--font-display); margin: 0; }

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% auto;
  animation: shine 6s linear infinite;
}
@keyframes shine { to { background-position: 200% center; } }

.type-cursor { color: var(--accent-purple); font-weight: 400; animation: blink 0.9s step-end infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 13px 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 8px 24px rgba(91, 124, 250, 0.25);
}
.btn-primary:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 12px 30px rgba(164, 99, 242, 0.35); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--surface-border);
}
.btn-outline:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.btn-block { width: 100%; text-align: center; border: none; }

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 14, 23, 0.75);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--surface-border);
  animation: slideDown 0.6s ease;
}
@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}
.logo {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.main-nav { display: flex; gap: 32px; }
.nav-link {
  font-size: 0.92rem;
  color: var(--text-muted);
  position: relative;
  padding: 4px 0;
  transition: color 0.2s ease;
  font-weight: 700;
}
.nav-link:hover { color: var(--text); }
.nav-link::after {
  content: '';
  position: absolute;
  left: 0; bottom: -2px;
  width: 0; height: 2px;
  background: var(--gradient);
  transition: width 0.25s ease;
}
.nav-link:hover::after { width: 100%; }

.header-actions { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 16px; }
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.icon-btn:hover { border-color: var(--accent-blue); color: var(--accent-blue); transform: translateY(-2px) rotate(8deg); }
.theme-toggle .icon-sun { display: none; }
.light-theme .theme-toggle .icon-moon { display: none; }
.light-theme .theme-toggle .icon-sun { display: block; }
.admin-link { color: var(--text-muted); }
.admin-link:hover { color: var(--accent-purple); border-color: var(--accent-purple); }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.nav-toggle span { width: 24px; height: 2px; background: var(--text); border-radius: 2px; }

/* ---------- Hero ---------- */
.hero { padding: 90px 0 30px; overflow: hidden; }
.hero-inner {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  align-items: center;
}
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-blue);
  letter-spacing: 0.05em;
  margin: 0 0 12px;
}
.hero-heading { font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.15; margin-bottom: 10px; }
.hero-subheading { font-size: clamp(1.1rem, 2.5vw, 1.5rem); font-weight: 700; margin-bottom: 20px; background: linear-gradient(120deg, #22d3ee, #34d399); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-bio { color: var(--text-muted); max-width: 52ch; margin-bottom: 30px; text-align: justify; }
.hero-actions { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.hero-social { display: flex; gap: 16px; flex-wrap: wrap; }
.social-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--text-muted); border-bottom: 1px solid transparent; transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease; }
.social-chip:hover { color: var(--text); border-color: var(--accent-purple); transform: translateY(-2px); }
.social-icon { width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; overflow: hidden; }
.social-icon svg { display: block; width: 100%; height: 100%; }

.hero-image { position: relative; display: flex; justify-content: flex-start; }
.hero-image-glow {
  position: absolute;
  inset: 10%;
  background: var(--gradient);
  filter: blur(60px);
  opacity: 0.35;
  border-radius: 50%;
  z-index: 0;
  animation: pulse 5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.35; }
  50% { transform: scale(1.12); opacity: 0.5; }
}
.hero-image img {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 340px;
  height: auto;
  animation: float 4.5s ease-in-out infinite;
  filter: drop-shadow(0 25px 35px rgba(0, 0, 0, 0.3));
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}
.hero-image-placeholder {
  position: relative;
  z-index: 1;
  width: 300px;
  height: 380px;
  border-radius: 28px;
  border: 1px solid var(--surface-border);
  animation: float 4.5s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 700;
  background: var(--surface);
  color: var(--accent-blue);
}

/* ---------- Sections ---------- */
.section { padding: 90px 0; }
.section-alt { background: var(--bg-alt); }
.section-title { font-size: clamp(1.6rem, 3.5vw, 2.3rem); text-align: center; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.04em; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.section-subtitle { text-align: justify; color: var(--text); opacity: 1; max-width: 900px; margin: 0 auto 50px; }

.grid { display: grid; gap: 24px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 28px;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.25s ease, box-shadow 0.3s ease;
}
.card:hover {
  transform: translateY(-8px);
  border-color: var(--accent-blue);
  box-shadow: 0 20px 44px rgba(91, 124, 250, 0.16);
}
.card-title { font-size: 1.15rem; margin-bottom: 10px; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; text-transform: uppercase; letter-spacing: 0.03em; }
.custom-item-card { padding: 0; overflow: hidden; }
.custom-item-image { width: 100%; background: var(--bg-alt); display: flex; align-items: center; justify-content: center; min-height: 160px; }
.custom-item-image img { width: 100%; height: auto; max-height: 320px; object-fit: contain; display: block; }
.custom-item-card .card-title, .custom-item-card .card-text { padding-left: 24px; padding-right: 24px; }
.custom-item-card .card-title { margin-top: 20px; }
.custom-item-card .card-text { margin-bottom: 24px; }
.custom-item-card.no-image .card-title { padding-top: 24px; }
.card-text { color: var(--text-muted); font-size: 0.95rem; margin: 0; text-align: justify; }

.services-grid { grid-template-columns: repeat(2, 1fr); }

/* ---------- Skills ---------- */
.skills-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.skill-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 500;
  font-size: 0.92rem;
  transition: border-color 0.25s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}
.skill-pill:hover { border-color: var(--accent-purple); transform: translateY(-5px) scale(1.03); box-shadow: 0 14px 30px rgba(164, 99, 242, 0.15); }
.skill-icon { width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px; overflow: hidden; }
.skill-icon svg, .skill-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Portfolio ---------- */
.portfolio-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.portfolio-card { padding: 0; overflow: hidden; display: block; }
.portfolio-thumb { aspect-ratio: 16/10; overflow: hidden; background: var(--bg-alt); }
.portfolio-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.portfolio-card:hover .portfolio-thumb img { transform: scale(1.08) rotate(1deg); }
.portfolio-thumb-placeholder { width: 100%; height: 100%; background: var(--gradient); opacity: 0.25; transition: transform 0.5s ease; }
.portfolio-card:hover .portfolio-thumb-placeholder { transform: scale(1.1) rotate(2deg); }
.portfolio-info { padding: 20px 22px; }
.portfolio-link { font-size: 0.85rem; color: var(--accent-blue); font-family: var(--font-mono); transition: letter-spacing 0.2s ease; }
.portfolio-card:hover .portfolio-link { letter-spacing: 0.5px; }

/* ---------- Contact ---------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 50px; align-items: start; }
.contact-list { list-style: none; padding: 0; margin: 30px 0 0; display: flex; flex-direction: column; gap: 12px; }
.contact-list strong { color: var(--text); font-weight: 600; }
.contact-list li { color: var(--text-muted); }

.contact-form { display: flex; flex-direction: column; gap: 18px; }
.contact-form-wrap { padding: 3px; border-radius: 20px; background: var(--gradient); }
.contact-form-wrap .contact-form { background: var(--surface); padding: 28px; border-radius: 17px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 0.85rem; color: var(--text-muted); }
.form-group input, .form-group textarea {
  background: var(--surface);
  border: 2.5px solid rgba(91, 124, 250, 0.7);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  resize: vertical;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(91, 124, 250, 0.15);
}
.form-group select {
  background: var(--surface);
  border: 1.5px solid rgba(91, 124, 250, 0.45);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.phone-input-row { display: flex; gap: 8px; }
.phone-input-row select { flex: 0 0 auto; width: auto; max-width: 130px; }
.phone-input-row input { flex: 1; min-width: 0; }

.alert { padding: 14px 16px; border-radius: 10px; margin-bottom: 20px; font-size: 0.9rem; }
.alert-success { background: rgba(52, 211, 153, 0.1); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.3); }
.alert-error { background: rgba(248, 113, 113, 0.1); color: #f87171; border: 1px solid rgba(248, 113, 113, 0.3); }

.empty-state { color: var(--text-muted); text-align: center; grid-column: 1 / -1; }

/* ---------- Footer ---------- */
.site-footer { padding: 50px 0; border-top: 1px solid var(--surface-border); }
.footer-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.footer-nav { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; }
.footer-nav a { color: var(--text-muted); font-size: 0.9rem; }
.footer-nav a:hover { color: var(--accent-blue); }
.footer-social { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.footer-social .social-chip { color: var(--text-muted); }
.footer-social .social-chip:hover { color: var(--text); }
.footer-copy { color: var(--text-muted); font-size: 0.85rem; margin: 0; }

/* ---------- Scroll reveal ---------- */
.reveal { opacity: 1; transform: none; }
.reveal.is-visible { opacity: 1; transform: translateY(0); }

.services-grid .reveal:nth-child(1) { transition-delay: 0s; }
.services-grid .reveal:nth-child(2) { transition-delay: 0.08s; }
.services-grid .reveal:nth-child(3) { transition-delay: 0.16s; }
.services-grid .reveal:nth-child(4) { transition-delay: 0.24s; }
.skills-grid .reveal:nth-child(n) { transition-delay: calc(0.05s * var(--i, 0)); }
.portfolio-grid .reveal:nth-child(1) { transition-delay: 0s; }
.portfolio-grid .reveal:nth-child(2) { transition-delay: 0.1s; }
.portfolio-grid .reveal:nth-child(3) { transition-delay: 0.2s; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
  body::before, .hero-image-glow, .hero-image img, .hero-image-placeholder, .gradient-text, .site-header { animation: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero-inner { grid-template-columns: 1fr; text-align: center; }
  .hero-actions, .hero-social { justify-content: center; }
  .contact-grid { grid-template-columns: 1fr; }
  .hero-image img { max-width: min(280px, 65vw); }
  .hero-image-placeholder { width: min(280px, 65vw); height: min(360px, 82vw); }
  .hero-image { justify-content: center; }
  .services-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .phone-input-row { flex-direction: column; }
  .phone-input-row select { max-width: 100%; width: 100%; }
}
@media (max-width: 720px) {
  .main-nav {
    position: fixed;
    top: 72px; left: 0; right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--surface-border);
    flex-direction: column;
    padding: 20px 24px;
    gap: 18px;
    transform: translateY(-150%);
    transition: transform 0.3s ease;
  }
  .main-nav.is-open { transform: translateY(0); }
  .nav-toggle { display: flex; }
}