/* Theme wrapper for unified cross-fade */
#theme-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: opacity 0.3s ease;
  opacity: 1;
}
#theme-wrapper.fade-out {
  opacity: 0;
}

:root {
  --bg-color: #fff;
  --text-color: #333;
  --header-color: #000;
  --card-bg: #f9f9f9;
  --toggle-icon-color: #666;
  --section-top: 4rem;
}
.dark-mode {
  --bg-color: #121212;
  --text-color: #e0e0e0;
  --header-color: #fff;
  --card-bg: #1e1e1e;
  --toggle-icon-color: #aaa;
}

body {
  margin: 0;
  font-family: Helvetica, Arial, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  transition: background 0.3s, color 0.3s;
}

a {
  color: var(--text-color);
  text-decoration: none;
}

header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  background: var(--bg-color);
  padding: 1rem 2rem;
  z-index: 100;
}
.logo {
  font-size: 2rem;
  font-weight: bold;
  letter-spacing: -0.05em;
  text-transform: uppercase;
  color: var(--header-color);
}
#theme-toggle {
  position: absolute;
  right: 2rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--header-color);
}

main {
  flex: 1;
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
}

section {
  margin-bottom: 2rem;
}
section h2 {
  position: -webkit-sticky;
  position: sticky;
  top: var(--section-top);
  background: var(--bg-color);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  font-size: 1.75rem;
  margin: 0;
  padding: 0.5rem 0;
  color: var(--header-color);
}
.header-emoji {
  margin-right: 0.5rem;
  display: inline-block;
}
.toggle-icon {
  margin-left: auto;
  color: var(--toggle-icon-color);
  font-size: 1em;
  font-weight: normal;
  transition: transform 0.3s;
}
.section-content {
  margin-top: 0.5rem;
  transition: max-height 0.3s ease;
}
.section-content.collapsed {
  max-height: 0;
  overflow: hidden;
}

p {
  line-height: 1.6;
  margin-top: 0;
}
.about-img {
  float: left;
  width: 20%;
  max-width: 120px;
  margin: 0 1rem 0.5rem 0;
  border-radius: 4px;
}

.card p.description {
  font-size: 0.95em;
  margin: 0.5em 0 0.25em;
  line-height: 1.4;
}
.card p.detail {
  font-size: 0.8em;
  color: var(--toggle-icon-color);
  margin: 1rem 0 0;
  line-height: 1.3;
  font-style: italic;
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  transition: transform 0.2s;
}
.card:hover {
  transform: translateY(-5px);
}
.card img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  background: #ddd;
}
/* make Expertise & Credentials subtler on wider screens */
@media (min-width: 800px) {
  .expertise h3 {
    font-size: 1.2rem;                /* smaller than other headings */
    color: var(--toggle-icon-color);  /* muted color */
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
  }
  .expertise p {
    font-size: 0.9em;                 /* slightly smaller text */
    color: var(--toggle-icon-color);  /* same muted tone */
    margin: 0.25em 0;                 /* tight vertical spacing */
    line-height: 1.4;
  }
}
footer {
  padding: 1rem 2rem;
  text-align: right;
  font-size: 1.25rem;
}
footer a[aria-label="Email"] {
  font-size: 1.25em;
  vertical-align: bottom;
  margin-right: 0.5em;
}
.icon {
  width: 1.25em;
  height: 1.25em;
  vertical-align: bottom;
  margin-left: 0.5em;
}
.icon-light {
  display: inline;
}
.icon-dark {
  display: none;
}
.dark-mode .icon-light {
  display: none;
}
.dark-mode .icon-dark {
  display: inline;
}

/* Logo sweep */
.logo.sweep {
  background-image: linear-gradient(90deg,#ff595e,#ffca3a,#8ac926,#1982c4,#6a4c93);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  background-size: 200% 100%;
  animation: sweepBg 15s linear infinite;
  opacity: 0;
}
@keyframes sweepBg {
  0% { background-position: 0% 50%; opacity: 0; }
  10% { opacity: 1; }
  50% { background-position: 100% 50%; opacity: 1; }
  100% { background-position: 0% 50%; opacity: 1; }
}

/* Emoji burst */
.emoji-burst {
  position: fixed;
  pointer-events: none;
  font-size: 1.5rem;
  will-change: transform, opacity;
  animation: emojiBurst 1.5s ease-out forwards;
  z-index: 9999;
}
@keyframes emojiBurst {
  0% { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.5); opacity: 0; }
}