:root {
  --u: min(1vw, 1vh);
  --bg: #0b131a;
  --ink: #ffffff;
  --card: rgba(13, 22, 30, 0.75);
  --line: rgba(255, 255, 255, 0.22);
  --btn: rgba(13, 22, 30, 0.8);
  --btn-ink: #ffffff;
  --amber: #f2b134;
  --spotify-green: #1db954;
  --vinyl: #0d1318;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Prompt", system-ui, sans-serif;
}

/* Background Video Layer */
.bg-video {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  pointer-events: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  background: transparent;
  z-index: 30;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

/* Gate Overlay - โปร่งใสเบลอพื้นหลังในหน้าแรก */
.gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(11, 19, 26, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    opacity 0.5s 0.5s,
    visibility 0s 1.1s;
}

.enter {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 2);
  border: 1px solid var(--line);
  cursor: pointer;
  background: rgba(13, 22, 30, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--btn-ink);
  padding: calc(var(--u) * 1.5) calc(var(--u) * 4);
  border-radius: calc(var(--u) * 10);
  font-weight: 600;
  font-size: calc(var(--u) * 3);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  transition:
    transform 0.8s cubic-bezier(0.7, 0, 0.25, 1),
    opacity 0.6s 0.3s,
    background 0.3s;
}

.enter:hover {
  background: rgba(255, 255, 255, 0.25);
}

.disc {
  width: calc(var(--u) * 3.8);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(var(--amber) 0 22%, var(--vinyl) 24%);
  animation: spin 3s linear infinite;
}

.entered .enter {
  transform: translateY(-75dvh);
  opacity: 0;
}

.entered .gate {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Main Profile Layer - แอนิเมชันสมูท นุ่มนวล */
.profile {
  position: relative;
  z-index: 5;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(6dvh);
  transition:
    opacity 0.5s ease-out,
    transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.entered .profile {
  opacity: 1;
  transform: none;
}

.side {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.cover {
  align-self: stretch;
  height: calc(var(--u) * 14);
  background: linear-gradient(
    120deg,
    rgba(22, 56, 79, 0.5),
    rgba(43, 27, 77, 0.5) 55%,
    rgba(107, 45, 79, 0.5)
  );
}

.avatar {
  width: calc(var(--u) * 15); /* ปรับขนาดความกว้าง */
  height: calc(
    var(--u) * 18
  ); /* ปรับความสูงให้เป็นสี่เหลี่ยมแนวตั้ง (หรือปรับให้เท่ากันถ้าอยากได้สี่เหลี่ยมจัตุรัส) */
  border-radius: calc(
    var(--u) * 2.5
  ); /* ความโค้งมนของมุมสี่เหลี่ยม (ปรับมาก/น้อยได้ตามชอบ) */
  margin-top: calc(var(--u) * -8);
  border: calc(var(--u) * 0.6) solid rgba(11, 19, 26, 0.8);
  background: #101b25;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* ซ่อนส่วนที่เกินขอบสี่เหลี่ยม */
  box-sizing: border-box;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%; /* ปรับตำแหน่งโฟกัสรูปภาพ */
  border-radius: inherit; /* ให้รูปโค้งมนตามกรอบ */
}

h1 {
  font-size: calc(var(--u) * 5);
  font-weight: 600;
  margin: calc(var(--u) * 1) 0 0;
  line-height: 1.1;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--u) * 0.9);
  font-size: calc(var(--u) * 2.15);
  margin: calc(var(--u) * 0.7) 0;
  padding: 0 calc(var(--u) * 1.8);
  background: rgba(11, 19, 26, 0.75);
  border: 1px solid var(--line);
  border-radius: 99px;
  backdrop-filter: blur(8px);
}

.status i {
  width: calc(var(--u) * 1.1);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #3ccf7a;
}

.bio {
  font-size: calc(var(--u) * 2.5);
  margin: 0 0 calc(var(--u) * 1.5);
  opacity: 0.95;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

/* Spotify Widget (ทึบแสงอ่านง่าย) */
.spotify-widget {
  position: relative;
  display: flex;
  align-items: center;
  width: calc(100% - 6vw);
  max-width: calc(var(--u) * 44);
  margin: calc(var(--u) * 1.5) 0 calc(var(--u) * 2);
  padding: calc(var(--u) * 1.4) calc(var(--u) * 2.2) calc(var(--u) * 1.4)
    calc(var(--u) * 9.5);
  background: rgba(13, 22, 30, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: calc(var(--u) * 3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
}

.album-art-wrapper {
  position: absolute;
  left: calc(var(--u) * -2.5);
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.album-art {
  position: relative;
  width: calc(var(--u) * 10);
  height: calc(var(--u) * 10);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  padding: 0;
  background: #101b25;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.album-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  animation: spin 8s linear infinite;
  animation-play-state: paused;
}

.playing .album-art img {
  animation-play-state: running;
}

.album-art:hover {
  transform: scale(1.05);
}

.play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  border-radius: 50%;
}

.album-art:hover .play-overlay {
  opacity: 1;
}

.play-icon {
  color: #ffffff;
  font-size: calc(var(--u) * 3);
  margin-left: 2px;
}

.player-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 0.4);
  min-width: 0;
}

.track-title {
  font-size: calc(var(--u) * 2.3);
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.artist-name {
  font-size: calc(var(--u) * 1.8);
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: calc(var(--u) * 0.4);
}

.progress-container {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 1);
}

.time-text {
  font-size: calc(var(--u) * 1.6);
  color: rgba(255, 255, 255, 0.75);
  font-family: monospace;
}

.progress-bar-bg {
  flex: 1;
  height: calc(var(--u) * 0.8);
  background: rgba(255, 255, 255, 0.25);
  border-radius: 99px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--amber), #ff6b6b);
  border-radius: 99px;
  transition: width 0.1s linear;
}

.main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 2);
  padding: calc(var(--u) * 2) 5vw 0;
}

.tabs {
  flex: none;
  display: flex;
  gap: calc(var(--u) * 0.8);
  padding: calc(var(--u) * 0.6);
  background: rgba(11, 19, 26, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: calc(var(--u) * 3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: calc(var(--u) * 1.2) 0;
  font-size: calc(var(--u) * 2.5);
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  border-radius: calc(var(--u) * 2);
  transition: all 0.25s ease;
  position: relative;
}

.tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

.tab[aria-selected="true"] {
  color: #ffffff;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  bottom: calc(var(--u) * 0.6);
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--amber);
  border-radius: 2px;
}

.panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 1.4);
}

.panel[hidden] {
  display: none;
}

.link {
  flex: none;
  padding: calc(var(--u) * 1.8) calc(var(--u) * 2.8);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 1.6);
  background: var(--btn);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  color: var(--btn-ink);
  text-decoration: none;
  font-weight: 500;
  font-size: calc(var(--u) * 2.5);
  border-radius: calc(var(--u) * 2.8);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  transition:
    background 0.3s,
    transform 0.2s,
    border-color 0.3s,
    box-shadow 0.3s;
}

.link:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.stat {
  flex: none;
  padding: calc(var(--u) * 1.8) calc(var(--u) * 2.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: calc(var(--u) * 2.8);
  font-size: calc(var(--u) * 2.5);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.stat b {
  color: var(--amber);
}

.about {
  font-size: calc(var(--u) * 2.5);
  line-height: 1.6;
  margin: 0;
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  padding: calc(var(--u) * 2.5);
  border-radius: calc(var(--u) * 2.8);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-aspect-ratio: 5/4) {
  .profile {
    flex-direction: row;
  }
  .side {
    width: 38%;
    justify-content: center;
    border-right: 1px solid var(--line);
    background: rgba(11, 19, 26, 0.75);
    backdrop-filter: blur(10px);
    position: relative;
  }
  .cover {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: calc(var(--u) * 20);
  }
  .avatar {
    width: calc(var(--u) * 20);
    margin-top: calc(var(--u) * -3.5);
    position: relative;
    z-index: 2;
  }
  h1 {
    font-size: calc(var(--u) * 5.8);
  }
  .bio,
  .status {
    font-size: calc(var(--u) * 2.5);
  }
  .spotify-widget {
    margin-top: calc(var(--u) * 3);
  }
  .main {
    width: 62%;
    padding: calc(var(--u) * 4) 4.5vw;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .enter,
  .profile,
  .gate {
    transition-duration: 0.01s;
    transition-delay: 0s;
  }
  .album-art img,
  .disc {
    animation-duration: 12s;
  }
}
/* จัดระเบียบ Icon ให้มีขนาดเท่ากัน และเปลี่ยนสีตามฟอนต์อัตโนมัติ */
.btn-icon {
  width: calc(var(--u) * 3);
  height: calc(var(--u) * 3);
  flex-flow: none;
  stroke: currentColor;
  fill: none;
}
/* กำหนด Animation สำหรับการเฟดและเลื่อนขึ้นเบาๆ */
@keyframes panelFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* คลาสที่จะถูกเรียกใช้เมื่อมีการเปลี่ยนแท็บ */
.panel.animate-in {
  animation: panelFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ปุ่มในพาเนลที่กำลังแสดงผลจะค่อยๆ ทยอยลอยขึ้นมา */
.panel.animate-in .link {
  opacity: 0;
  animation: panelFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.panel.animate-in .link:nth-child(1) {
  animation-delay: 0.05s;
}
.panel.animate-in .link:nth-child(2) {
  animation-delay: 0.1s;
}
.panel.animate-in .link:nth-child(3) {
  animation-delay: 0.15s;
}
.panel.animate-in .link:nth-child(4) {
  animation-delay: 0.2s;
}
