/* Prevent iOS Safari auto-zoom on input focus (requires >= 16px) */
@media (max-width: 767px) {
  input:not([type='checkbox']):not([type='radio']):not([type='hidden']):not([type='file']):not([type='color']):not([type='range']):not([type='button']):not([type='submit']):not([type='reset']),
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* ── Mobile liquid tabbar (fixed, 3D) ── */
#liquid-tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 0 10px max(10px, env(safe-area-inset-bottom));
  pointer-events: none;
}

.liquid-tabbar-shell {
  pointer-events: auto;
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(255,241,242,0.88) 100%);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: 28px 28px 22px 22px;
  box-shadow:
    0 -12px 40px rgba(244,63,94,0.18),
    0 4px 16px rgba(0,0,0,0.06),
    inset 0 1px 0 rgba(255,255,255,1);
  transform: perspective(900px) rotateX(10deg);
  transform-origin: bottom center;
  padding: 6px 8px 8px;
  overflow: hidden;
}

.liquid-tabbar-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.5) 0%, transparent 50%);
  border-radius: inherit;
  pointer-events: none;
}

.liquid-tabbar-track {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  z-index: 1;
}

.liquid-tabbar-blob {
  position: absolute;
  top: 4px;
  left: 0;
  width: var(--blob-w, 52px);
  height: 44px;
  background: linear-gradient(145deg, #fb923c 0%, #ef4444 50%, #f43f5e 100%);
  border-radius: 40% 60% 55% 45% / 55% 45% 55% 45%;
  box-shadow:
    0 8px 20px rgba(239,68,68,0.5),
    0 2px 8px rgba(251,146,60,0.4),
    inset 0 2px 4px rgba(255,255,255,0.35);
  transition:
    transform 0.5s cubic-bezier(0.34, 1.45, 0.64, 1),
    width 0.35s ease,
    border-radius 0.6s ease;
  animation: liquidMorph 3.5s ease-in-out infinite;
  z-index: 0;
  will-change: transform, border-radius;
}

@keyframes liquidMorph {
  0%, 100% { border-radius: 42% 58% 54% 46% / 54% 46% 54% 46%; }
  33% { border-radius: 58% 42% 46% 54% / 46% 54% 46% 54%; }
  66% { border-radius: 48% 52% 58% 42% / 52% 48% 52% 48%; }
}

.liquid-tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px 4px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: color 0.25s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.liquid-tab-item svg,
.liquid-tab-item i {
  width: 20px;
  height: 20px;
  transition: transform 0.3s cubic-bezier(0.34, 1.45, 0.64, 1);
}

.liquid-tab-item.active {
  color: #fff;
}

.liquid-tab-item.active svg,
.liquid-tab-item.active i {
  transform: translateY(-2px) scale(1.12);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.liquid-tab-item:active {
  transform: scale(0.92);
}

@media (min-width: 1024px) {
  #liquid-tabbar { display: none !important; }
}

.has-mobile-tabbar {
  padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 1024px) {
  .has-mobile-tabbar { padding-bottom: 0; }
}

/* Admin tabs */
.admin-tab-btn.active {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}

/* Noto Sans Thai ทุกส่วน */
*, *::before, *::after { font-family: 'Noto Sans Thai', sans-serif !important; }

/* Cursor: แสดงเคอร์เซอร์พิมพ์เฉพาะช่องที่กรอกได้ */
body { cursor: default; }

input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="color"]),
textarea,
select {
  cursor: text;
}

button,
a,
summary,
[role="button"],
.nav-btn,
.filter-tab,
.like-btn,
.preset-btn,
.liquid-tab-item,
.admin-tab-btn,
label.cursor-pointer {
  cursor: pointer;
}

/* ข้อความแสดงผล — ไม่ให้คลิกแล้วเกิด caret / ไฮไลต์ */
.ui-static,
#teacher-name-header,
#teacher-badge,
#teacher-department,
#teacher-name-card,
#teacher-title,
#teacher-quote,
header h1 {
  user-select: none;
  cursor: default;
}

/* Header — centered copy, no side controls */
.site-header {
  width: 100%;
  overflow: visible;
}

.header-copy {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: visible;
}

.header-line {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 100%;
  overflow: visible;
}

.header-fit-target {
  display: inline-flex;
  justify-content: center;
  max-width: 100%;
  transform-origin: center center;
  overflow: visible;
}

.header-line + .header-line {
  margin-top: 0.35rem;
}

.header-line:first-child {
  margin-bottom: 0.15rem;
}

.header-badge-text,
.header-title-text,
.header-dept-text,
#teacher-badge,
#teacher-name-header,
#teacher-department {
  white-space: nowrap;
}

#teacher-name-header,
#teacher-department,
#teacher-badge {
  display: inline-block;
  transform-origin: center center;
}

.header-badge-text {
  font-size: clamp(0.5625rem, 1.6vw + 0.42rem, 0.75rem);
  line-height: 1.25;
}

.header-title-text {
  font-size: clamp(1.375rem, 3.8vw + 0.65rem, 3rem);
  line-height: 1.15;
}

.header-dept-text {
  font-size: clamp(0.5625rem, 1.7vw + 0.45rem, 0.875rem);
  line-height: 1.25;
}

@keyframes spinSlow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.animate-spin-slow { animation: spinSlow 14s linear infinite; }
@keyframes floatCute {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(8deg); }
}
.animate-float-cute { animation: floatCute 3s ease-in-out infinite; }
.scrollbar-none::-webkit-scrollbar { display: none; }
.scrollbar-none { -ms-overflow-style: none; scrollbar-width: none; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fadeIn { animation: fadeIn 0.3s ease-out; }

@keyframes wishPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.45); border-color: #fda4af; }
  50% { box-shadow: 0 0 0 8px rgba(244, 63, 94, 0); border-color: #fb7185; }
}
.wish-new-highlight {
  animation: wishPulse 1s ease-in-out 3;
  border-color: #fda4af !important;
}

/* ── Profile media: canvas video fade + CSS mask for image ── */
.profile-wrap {
  position: relative;
  width: 234px;
  height: 296px;
  margin: 0 auto 1.25rem;
}

.profile-media {
  position: relative;
  width: 100%;
  height: 100%;
}

.profile-media-clip {
  --profile-edge-mask: radial-gradient(
    ellipse 94% 100% at 50% 52%,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 1) 34%,
    rgba(255, 255, 255, 0.84) 48%,
    rgba(255, 255, 255, 0.56) 62%,
    rgba(255, 255, 255, 0.28) 76%,
    rgba(255, 255, 255, 0.08) 90%,
    rgba(255, 255, 255, 0) 100%
  );
  position: relative;
  width: 100%;
  height: 100%;
}

.profile-video-canvas,
.profile-media-clip img,
.profile-media-clip #teacher-image-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.profile-video-canvas {
  pointer-events: none;
}

.profile-media-clip img {
  object-fit: cover;
  object-position: top center;
  -webkit-mask-image: var(--profile-edge-mask);
  mask-image: var(--profile-edge-mask);
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.profile-video-source {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 4px;
  height: 4px;
  opacity: 0.001;
  pointer-events: none;
}

.profile-media-clip .hidden {
  display: none !important;
}

.profile-media-clip #teacher-image-fallback {
  object-fit: contain;
}

/* ── Dreamy bokeh background ── */
.dreamy-bg {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(1200px 780px at 12% -5%, #ffe4e6 0%, transparent 55%),
    radial-gradient(1000px 720px at 105% 8%, #fef3c7 0%, transparent 50%),
    radial-gradient(1000px 900px at 50% 118%, #fce7f3 0%, transparent 55%),
    linear-gradient(135deg, #fff1f2 0%, #fff7ed 46%, #fdf2f8 100%);
}
.orb {
  position: absolute; border-radius: 50%; filter: blur(46px);
  opacity: 0.5; will-change: transform;
  animation: orbFloat 20s ease-in-out infinite;
}
.dreamy-bg .orb-1 { width: 320px; height: 320px; top: -40px; left: 6%;
  background: radial-gradient(circle at 30% 30%, #fbcfe8, #f9a8d4); }
.dreamy-bg .orb-2 { width: 260px; height: 260px; top: 4%; right: 4%;
  background: radial-gradient(circle at 30% 30%, #fed7aa, #fdba74); animation-delay: -3s; }
.dreamy-bg .orb-3 { width: 220px; height: 220px; top: 42%; left: -60px;
  background: radial-gradient(circle at 30% 30%, #ddd6fe, #c4b5fd); animation-delay: -6s; }
.dreamy-bg .orb-4 { width: 300px; height: 300px; bottom: -60px; left: 30%;
  background: radial-gradient(circle at 30% 30%, #fecdd3, #fda4af); animation-delay: -9s; }
.dreamy-bg .orb-5 { width: 200px; height: 200px; bottom: 8%; right: 8%;
  background: radial-gradient(circle at 30% 30%, #fef08a, #fcd34d); animation-delay: -12s; opacity: 0.4; }
.dreamy-bg .orb-6 { width: 180px; height: 180px; top: 60%; right: 34%;
  background: radial-gradient(circle at 30% 30%, #bfdbfe, #93c5fd); animation-delay: -15s; opacity: 0.38; }

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(24px, -20px) scale(1.06); }
  66% { transform: translate(-18px, 16px) scale(0.96); }
}

/* ── Glassmorphic card ── */
.glass-card {
  background: linear-gradient(160deg, rgba(255,255,255,0.78) 0%, rgba(255,255,255,0.58) 100%);
  backdrop-filter: blur(26px) saturate(1.35);
  -webkit-backdrop-filter: blur(26px) saturate(1.35);
  box-shadow: 0 18px 50px rgba(190,120,150,0.14), inset 0 1px 0 rgba(255,255,255,0.9);
}

/* ── 3D glass hearts cluster ── */
.glass-heart-cluster { position: relative; width: 150px; height: 130px; }
.glass-heart {
  position: absolute; display: block;
  filter: drop-shadow(0 8px 18px rgba(244,114,182,0.28));
  animation: heartBob 5s ease-in-out infinite;
}
.glass-heart::before,
.glass-heart::after {
  content: ''; position: absolute; top: 0;
  width: var(--hw, 44px); height: calc(var(--hw, 44px) * 1.6);
  border-radius: 50% 50% 0 0;
  background: var(--hfill, linear-gradient(135deg, rgba(255,182,193,0.6), rgba(196,181,253,0.5)));
  backdrop-filter: blur(3px);
  box-shadow: inset 0 3px 10px rgba(255,255,255,0.75), inset 0 -6px 14px rgba(236,72,153,0.18);
  border: 1px solid rgba(255,255,255,0.55);
}
.glass-heart::before { left: var(--hw, 44px); transform: rotate(-45deg); transform-origin: 0 100%; }
.glass-heart::after  { left: 0; transform: rotate(45deg); transform-origin: 100% 100%; }
.glass-heart .gloss {
  position: absolute; z-index: 3; top: 12%; left: 24%;
  width: 30%; height: 26%; border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0));
  transform: rotate(-20deg); pointer-events: none;
}
.glass-heart.heart-big {
  --hw: 46px; left: 16px; top: 26px;
  --hfill: linear-gradient(135deg, rgba(251,146,60,0.55), rgba(244,114,182,0.5), rgba(196,181,253,0.5));
}
.glass-heart.heart-sm {
  --hw: 30px; left: 0; top: 4px; animation-delay: -1.5s;
  --hfill: linear-gradient(135deg, rgba(244,114,182,0.55), rgba(253,164,175,0.5));
}
.glass-heart.heart-tiny {
  --hw: 22px; left: 92px; top: 66px; animation-delay: -3s;
  --hfill: linear-gradient(135deg, rgba(196,181,253,0.55), rgba(147,197,253,0.5));
}
@keyframes heartBob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(-3deg); }
}
.orb-cta-1 { position: absolute; width: 120px; height: 120px; top: -30px; right: -20px;
  background: radial-gradient(circle at 30% 30%, #fed7aa, #fdba74); filter: blur(34px); opacity: 0.5; }
.orb-cta-2 { position: absolute; width: 100px; height: 100px; bottom: -30px; left: -20px;
  background: radial-gradient(circle at 30% 30%, #fbcfe8, #f9a8d4); filter: blur(30px); opacity: 0.5; }

@media (prefers-reduced-motion: reduce) {
  .orb, .glass-heart { animation: none !important; }
}

/* ── 3D Avatar picker & display ── */
.avatar-3d {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(145deg, rgba(255,255,255,0.9), rgba(255,241,242,0.7));
  box-shadow:
    0 4px 12px rgba(244,114,182,0.22),
    inset 0 1px 0 rgba(255,255,255,0.9);
}
.avatar-3d-svg {
  display: block;
  transform: translateY(2px);
}
.avatar-picker-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  max-height: 168px;
  overflow-y: auto;
  padding: 4px 2px;
}
.avatar-pick-btn {
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 4px;
  background: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-pick-btn:hover {
  transform: scale(1.06);
  border-color: rgba(251,146,60,0.45);
}
.avatar-pick-btn.is-selected {
  border-color: #f97316;
  box-shadow: 0 0 0 3px rgba(249,115,22,0.25);
  background: rgba(255,247,237,0.95);
  transform: scale(1.04);
}
@media (max-width: 480px) {
  .avatar-picker-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
  #toast { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
}

/* ── Global animated progress bar ── */
.app-progress-wrap {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.app-progress-wrap.is-active {
  opacity: 1;
}

.app-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(90deg, #f97316, #e11d48, #fb7185, #f59e0b, #f97316);
  background-size: 300% 100%;
  animation: app-progress-shimmer 1.1s linear infinite;
  box-shadow: 0 0 12px rgba(225, 29, 72, 0.45);
  transition: width 0.2s ease-out;
}

.app-progress-wrap.is-done .app-progress-bar {
  animation: none;
  background: linear-gradient(90deg, #10b981, #34d399);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.45);
}

@keyframes app-progress-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -200% 0; }
}

/* ── Site entrance motion ── */
body.site-loading {
  overflow: hidden;
}

body.site-loading .reveal-item {
  opacity: 0;
  pointer-events: none;
}

body.site-revealed {
  overflow-x: hidden;
}

body.site-revealed .reveal-item {
  pointer-events: auto;
  animation: siteRevealIn 0.95s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--reveal-i, 0) * 0.1s + 0.08s);
}

@keyframes siteRevealIn {
  from {
    opacity: 0;
    transform: translateY(32px) scale(0.97);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

.dreamy-bg.reveal-item {
  animation-name: siteRevealBg;
  animation-duration: 1.2s;
}

@keyframes siteRevealBg {
  from { opacity: 0; transform: scale(1.05); }
  to { opacity: 1; transform: scale(1); }
}

#top-section.reveal-item {
  animation-name: siteRevealShell;
  animation-duration: 1.05s;
}

@keyframes siteRevealShell {
  from {
    opacity: 0;
    transform: translateY(44px) scale(0.955);
    filter: blur(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

#teacher-name-header.reveal-item {
  animation-name: siteRevealTitle;
}

@keyframes siteRevealTitle {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.9);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

#liquid-tabbar.reveal-item {
  animation-name: siteRevealTabbar;
}

@keyframes siteRevealTabbar {
  from {
    opacity: 0;
    transform: translateY(100%) perspective(900px) rotateX(10deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) perspective(900px) rotateX(10deg);
  }
}

.app-progress-wrap.site-load-progress .app-progress-bar {
  transition: width 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  body.site-loading {
    overflow: auto;
  }
  body.site-loading .reveal-item,
  body.site-revealed .reveal-item {
    opacity: 1 !important;
    animation: none !important;
    transform: none !important;
    filter: none !important;
    pointer-events: auto;
  }
}
