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

:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #f1f3f7;
  --brand: #2563eb;
  --brand-soft: #dbeafe;
  --text: #171a1f;
  --text-muted: #5c6470;
  --border: #dfe4ec;
  --accent: #171a1f;
  --accent-hover: #2b313b;
  --shadow-soft: 0 16px 40px -30px rgba(15, 23, 42, 0.45);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --max-width: 840px;
  --radius: 14px;
  --transition: 0.25s ease;
}

[data-theme="dark"] {
  --bg: #0e1117;
  --surface: #141a23;
  --surface-soft: #1a2230;
  --brand: #60a5fa;
  --brand-soft: #1d3a63;
  --text: #eff3f8;
  --text-muted: #9aa5b5;
  --border: #263143;
  --accent: #eff3f8;
  --accent-hover: #c9d3df;
  --shadow-soft: 0 18px 45px -35px rgba(0, 0, 0, 0.8);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: radial-gradient(circle at top right, var(--surface-soft) 0%, transparent 34%), var(--bg);
  color: var(--text);
  line-height: 1.65;
  transition: background-color var(--transition), color var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.lang-sep {
  font-size: 0.75rem;
  color: var(--border);
}

.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.2rem 0.1rem;
  transition: color var(--transition);
}

.lang-btn:hover,
.lang-btn.active {
  color: var(--text);
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 0.25rem;
  border-radius: 6px;
  transition: color var(--transition), background-color var(--transition);
}

.theme-toggle:hover {
  color: var(--text);
  background-color: var(--surface-soft);
}

/* ── Main ── */
main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Flip Card ── */
.card-scene {
  width: 100%;
  perspective: 1400px;
  margin-top: auto;
  margin-bottom: auto;
}

.card-flip {
  position: relative;
  width: 100%;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-flip.is-flipped {
  transform: rotateY(180deg);
}

.card-face {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.card-back {
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
}

.back-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
  flex-shrink: 0;
}

.back-flip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.25rem 0;
  transition: color var(--transition);
}

.back-flip-btn:hover {
  color: var(--text);
}

.projects-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.projects-scroll::-webkit-scrollbar {
  width: 4px;
}

.projects-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.projects-scroll::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 2px;
}

.back-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

/* Flip back face must be absolute — higher specificity overrides presentation-card */
.card-flip .card-back {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.presentation-card {
  position: relative;
  padding: 1.4rem;
  border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--border));
  border-radius: 24px;
  background:
    radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--brand-soft) 75%, transparent) 0%, transparent 36%),
    linear-gradient(
      150deg,
      color-mix(in srgb, var(--brand-soft) 52%, var(--surface)) 0%,
      color-mix(in srgb, var(--surface) 88%, var(--surface-soft)) 42%,
      color-mix(in srgb, var(--surface-soft) 66%, var(--surface)) 100%
    );
  box-shadow: 0 16px 40px -30px color-mix(in srgb, var(--brand) 35%, rgba(15, 23, 42, 0.35));
}

.card-controls {
  position: absolute;
  top: 0.8rem;
  right: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  opacity: 0.82;
}

.hero {
  padding: 3.2rem 0 1rem;
}

.label {
  font-size: 0.78rem;
  font-weight: 500;
  color: color-mix(in srgb, var(--brand) 70%, var(--text-muted));
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.card-identity {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.card-name {
  font-size: clamp(2rem, 6vw, 2.8rem);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 0.2rem;
}

.profile-copy {
  min-width: 0;
}

.avatar {
  width: 146px;
  height: 146px;
  border-radius: 14px;
  display: block;
  object-fit: cover;
  object-position: center 42%;
  border: 2px solid color-mix(in srgb, var(--brand) 35%, var(--border));
}

.profile-role {
  font-size: 1.82rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.profile-location {
  margin-top: 0.28rem;
  font-size: 0.98rem;
  color: var(--text-muted);
}

.card-bio {
  font-size: 0.98rem;
  color: var(--text-muted);
  line-height: 1.58;
  margin-bottom: 1.15rem;
  max-width: 64ch;
}

.profile-stats {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.72rem;
}

.stat-item {
  border: 1px solid color-mix(in srgb, var(--brand) 18%, var(--border));
  border-radius: 16px;
  padding: 0.82rem 0.78rem 0.7rem;
  background-color: transparent;
}

.stat-top {
  display: flex;
  align-items: center;
  gap: 0.34rem;
}

.profile-stats strong {
  display: inline-block;
  margin-left: 0;
  font-size: 2.75rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.profile-stats span {
  display: block;
  margin-top: 0.34rem;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--text-muted);
  text-wrap: balance;
}

.stat-icon {
  color: color-mix(in srgb, var(--brand) 35%, var(--text-muted));
  transform: translateY(-1px);
}

.stat-icon svg {
  width: 13px;
  height: 13px;
}

.compact-links {
  margin-top: 0.98rem;
}

.section {
  margin-top: 0.85rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  box-shadow: var(--shadow-soft);
}

.section-compact {
  margin-top: 2.4rem;
  margin-bottom: 0.65rem;
  padding: 0.7rem 0.85rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  margin-top: 0.35rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
}

.back-link:hover {
  color: var(--text);
}

h2 {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.about-text {
  font-size: 0.96rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 0.7rem;
}

/* ── Projects ── */
.projects {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.project {
  padding: 1rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  transition: transform var(--transition), border-color var(--transition), background-color var(--transition);
}

.project:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
}

.project-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.project-name {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text);
}

.project-link {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  opacity: 0.65;
  transition: opacity var(--transition);
}

.project-link:hover {
  opacity: 1;
  color: var(--brand);
}

.project-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.65;
  max-width: 100%;
}

/* ── Links ── */
.links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.links li a,
.links li .link-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.78rem 0.9rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: color var(--transition), border-color var(--transition), background-color var(--transition), transform var(--transition);
}

.links li .link-btn {
  width: 100%;
  background: none;
  cursor: pointer;
  font-family: var(--font);
}

.links li a:hover,
.links li .link-btn:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  background-color: var(--surface-soft);
  transform: translateX(2px);
}

.link-left {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.link-left svg,
.arrow {
  opacity: 0.55;
  flex-shrink: 0;
}

/* ── Focus ── */
a:focus-visible,
button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 70%, transparent);
  outline-offset: 2px;
}

/* ── Responsive ── */
@media (max-width: 980px) {
  .hero {
    padding: 2.7rem 0 0.9rem;
  }

  .avatar {
    width: 126px;
    height: 126px;
  }

  .profile-role {
    font-size: 1.52rem;
  }

  .profile-stats strong {
    font-size: 2.25rem;
  }
}

@media (max-width: 760px) {
  .card-identity {
    align-items: flex-start;
    gap: 0.8rem;
  }

  .profile-role {
    font-size: 1.35rem;
  }

  .profile-stats {
    grid-template-columns: 1fr;
    gap: 0.58rem;
  }

  .profile-stats strong {
    font-size: 2rem;
  }
}

@media (max-width: 600px) {
  main {
    padding: 1rem 1.2rem;
  }

  .presentation-card {
    padding: 0.95rem;
  }

  .hero {
    padding: 2.2rem 0 0.8rem;
  }

  .card-identity {
    flex-direction: column;
    margin-bottom: 0.85rem;
  }

  .card-controls {
    top: 0.62rem;
    right: 0.68rem;
  }

  .avatar {
    width: 92px;
    height: 92px;
  }

}

@media (max-width: 390px) {
  main {
    padding: 0.85rem 0.95rem;
  }

  .profile-role {
    font-size: 1.15rem;
  }

  .hero {
    padding: 1.8rem 0 0.65rem;
  }

  .profile-location {
    font-size: 0.9rem;
  }

  .stat-item {
    padding: 0.7rem 0.62rem;
  }

  .profile-stats strong {
    font-size: 1.75rem;
  }

  .profile-stats span {
    font-size: 0.76rem;
    line-height: 1.3;
  }

  .presentation-card {
    padding: 0.76rem;
    border-radius: 14px;
  }

  .card-controls {
    top: 0.5rem;
    right: 0.52rem;
  }
}
