/* ============================================================
   DOPAI WORKATION 2026 — styles
   3 themes: nang (sunset / light) · dem (midnight neon) · pop (y2k tropic)
   ============================================================ */

/* ---------- THEME TOKENS ---------- */
:root,
:root[data-theme="nang"] {
  --bg:        #fdf4e8;
  --bg-2:      #fbe9d4;
  --aurora-1:  #ff6a3d;
  --aurora-2:  #ffc23d;
  --aurora-3:  #14b8a6;
  --surface:   #fffdf9;
  --surface-2: #fff3e2;
  --line:      #eadcc6;
  --line-2:    #e1cfb2;
  --text:      #241a12;
  --dim:       #6f5f4d;
  --faint:     #a08a72;
  --a1:        #ff5a3c;   /* coral */
  --a2:        #0ea5a0;   /* teal */
  --a3:        #f5a623;   /* sun */
  --on-a1:     #fff7f0;
  --on-a2:     #f0fffd;
  --on-a3:     #2a1c06;
  --logo:      #241a12;
  --card-shadow: 0 18px 50px -22px rgba(60,40,20,.45);
  --grain-op:  .035;
  --hero-text: #241a12;
  color-scheme: light;
}

:root[data-theme="dem"] {
  --bg:        #06060e;
  --bg-2:      #0c0d1c;
  --aurora-1:  #21e6c1;
  --aurora-2:  #6a5cff;
  --aurora-3:  #ff4d9d;
  --surface:   #101226;
  --surface-2: #161a35;
  --line:      #232745;
  --line-2:    #313760;
  --text:      #eef0ff;
  --dim:       #a6abce;
  --faint:     #6a7099;
  --a1:        #21e6c1;   /* cyan */
  --a2:        #8b7bff;   /* violet */
  --a3:        #ff5d9e;   /* magenta */
  --on-a1:     #04201a;
  --on-a2:     #0a0820;
  --on-a3:     #2a0617;
  --logo:      #eef0ff;
  --card-shadow: 0 22px 60px -26px rgba(0,0,0,.8);
  --grain-op:  .05;
  --hero-text: #eef0ff;
  color-scheme: dark;
}

:root[data-theme="pop"] {
  --bg:        #fbeafe;
  --bg-2:      #ffe4f0;
  --aurora-1:  #ff2e88;
  --aurora-2:  #7b5bff;
  --aurora-3:  #14d6e6;
  --surface:   #ffffff;
  --surface-2: #fff0f8;
  --line:      #f4cde6;
  --line-2:    #eeb6da;
  --text:      #2a0c3d;
  --dim:       #7a4d86;
  --faint:     #ac7fb8;
  --a1:        #ff2e88;   /* hot pink */
  --a2:        #6b4bff;   /* electric violet */
  --a3:        #19c4d4;   /* aqua */
  --on-a1:     #fff0f6;
  --on-a2:     #f3f0ff;
  --on-a3:     #042b30;
  --logo:      #2a0c3d;
  --card-shadow: 0 18px 50px -22px rgba(120,30,120,.4);
  --grain-op:  .04;
  --hero-text: #2a0c3d;
  color-scheme: light;
}

/* ---------- RESET / BASE ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  overflow-x: hidden;
  transition: background .5s ease, color .5s ease;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.display {
  font-family: 'Bricolage Grotesque', 'Be Vietnam Pro', sans-serif;
  font-weight: 800;
  line-height: .98;
  letter-spacing: -.02em;
}
::selection { background: var(--a1); color: var(--on-a1); }

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ---------- LAYOUT ---------- */
.wrap { width: min(1180px, 92vw); margin: 0 auto; }
section { position: relative; }
.sec-pad { padding: clamp(64px, 11vh, 140px) 0; }

/* eyebrow label */
.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; font-weight: 600;
  letter-spacing: .28em; text-transform: uppercase;
  color: var(--a1);
  display: inline-flex; align-items: center; gap: 10px;
}
.eyebrow::before {
  content: ""; width: 26px; height: 2px; background: var(--a1); border-radius: 2px;
}

.sec-title {
  font-family: 'Bricolage Grotesque', 'Be Vietnam Pro', sans-serif;
  font-weight: 800; letter-spacing: -.025em; line-height: 1;
  font-size: clamp(34px, 5.6vw, 68px);
  margin: 18px 0 0;
}
.sec-lead { color: var(--dim); font-size: clamp(15px, 1.5vw, 18px); max-width: 56ch; margin-top: 16px; }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(34px); transition: opacity .8s cubic-bezier(.2,.7,.2,1), transform .8s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; transition: none; }
}

/* grain overlay */
.grain {
  pointer-events: none; position: fixed; inset: 0; z-index: 9999;
  opacity: var(--grain-op); mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* logo: swap white/dark png by theme — CSS bg so it inlines on bundle (capture-safe) */
.logo { display: inline-flex; align-items: center; }
.logo .lw, .logo .ld { height: 100%; aspect-ratio: 254 / 90; background-size: contain; background-repeat: no-repeat; background-position: center; }
.logo .lw { background-image: url(assets/dopai-logo-white.png); display: none; }
.logo .ld { background-image: url(assets/dopai-logo-dark.png); display: block; }
:root[data-theme="dem"] .logo .lw { display: block; }
:root[data-theme="dem"] .logo .ld { display: none; }

/* pill / chip */
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--dim);
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 26px; border-radius: 999px;
  font-weight: 700; font-size: 15px; cursor: pointer;
  border: none; transition: transform .25s, box-shadow .25s, background .3s;
}
.btn-primary { background: var(--a1); color: var(--on-a1); box-shadow: 0 10px 30px -10px var(--a1); }
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -12px var(--a1); }
.btn-ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line-2); }
.btn-ghost:hover { border-color: var(--a1); color: var(--a1); transform: translateY(-3px); }

/* generic card */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--card-shadow);
}

/* ---------- AUTH (Google login phân quyền) ---------- */
/* Note quyền — luôn hiện */
.perm-note {
  margin-top: 26px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--dim); background: color-mix(in srgb, var(--a3) 12%, transparent);
  padding: 8px 14px; border-radius: 999px;
}
.perm-note b { color: var(--a1); }

/* Chip người đã đăng nhập */
.auth-chip {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 26px;
  padding: 7px 8px 7px 12px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--card-shadow);
}
.auth-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; }
.auth-name { font-weight: 700; font-size: 13.5px; color: var(--text); }
.auth-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.auth-badge.ok { color: var(--a2); background: color-mix(in srgb, var(--a2) 14%, transparent); }
.auth-badge.no { color: #b3261e; background: color-mix(in srgb, #e0483a 16%, transparent); }
.auth-signout {
  border: 1px solid var(--line-2); background: transparent; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--dim); padding: 5px 12px; border-radius: 999px;
  transition: border-color .2s, color .2s;
}
.auth-signout:hover { border-color: var(--a1); color: var(--a1); }

/* Popup đăng nhập (hiện khi bấm Upload lúc chưa đăng nhập) */
.auth-modal-backdrop {
  position: fixed; inset: 0; z-index: 10001; background: rgba(0,0,0,.55);
  display: grid; place-items: center; padding: 5vh 5vw; animation: lb-in .16s ease;
  backdrop-filter: blur(3px);
}
.auth-modal {
  position: relative; width: min(420px, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: 22px; padding: 30px 28px 28px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); text-align: center;
}
.auth-modal-x {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 50%;
  border: none; cursor: pointer; background: var(--surface-2); color: var(--dim); font-size: 14px;
}
.auth-modal-x:hover { background: var(--line); color: var(--text); }
.auth-modal-ic {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--a1) 14%, transparent); color: var(--a1);
}
.auth-modal-title { font-family: 'Bricolage Grotesque', sans-serif; font-size: 22px; color: var(--text); }
.auth-modal-sub { font-size: 14px; color: var(--dim); margin: 8px 0 20px; line-height: 1.5; }
.auth-modal-sub b { color: var(--a1); }
.gsi-btn { display: flex; justify-content: center; min-height: 44px; }
.auth-modal-err {
  margin-top: 16px; font-size: 12.5px; color: #fff; background: #e0483a;
  padding: 8px 12px; border-radius: 10px;
}

/* Điều khiển auth trên NAV */
.auth-nav {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 6px 4px 4px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
}
.auth-nav .auth-avatar { width: 26px; height: 26px; }
.auth-nav-dot {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--a1); color: var(--on-a1); font-weight: 800; font-size: 11px; flex: none;
}
.auth-nav-name {
  font-size: 13px; font-weight: 700; color: var(--text);
  max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.auth-nav-out {
  border: none; background: transparent; cursor: pointer; font-size: 11.5px; font-weight: 600;
  color: var(--faint); padding: 4px 9px; border-radius: 999px; transition: color .2s, background .2s;
}
.auth-nav-out:hover { color: var(--a1); background: var(--surface-2); }
.auth-nav-login {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 700; padding: 8px 15px; border-radius: 999px;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.auth-nav-login:hover { border-color: var(--a1); transform: translateY(-1px); box-shadow: 0 6px 16px -8px var(--a1); }
@media (max-width: 560px) {
  .auth-nav-name, .auth-nav-out { display: none; }
}

/* ---------- PHOTO UPLOAD (server-backed) ---------- */
.gallery-grid.is-over { outline: 2px dashed var(--a1); outline-offset: 6px; border-radius: 18px; }

/* a filled photo tile */
.photo-tile { position: relative; background: var(--surface-2); box-shadow: var(--card-shadow); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.photo-del {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%;
  border: none; cursor: pointer; background: rgba(0,0,0,.55); color: #fff; font-size: 13px;
  display: grid; place-items: center; opacity: 0; transition: opacity .15s, background .2s; backdrop-filter: blur(6px);
}
.photo-tile:hover .photo-del { opacity: 1; }
.photo-del:hover { background: var(--a1); color: var(--on-a1); }

/* the always-present upload button (≥1 nút upload) */
.gallery-grid .upload-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 2px dashed var(--line-2); background: var(--surface); color: var(--dim);
  cursor: pointer; transition: border-color .2s, color .2s, transform .2s, background .2s; text-align: center; padding: 10px;
}
.upload-tile:hover { border-color: var(--a1); color: var(--a1); transform: translateY(-2px); background: var(--surface-2); }
.upload-tile span { font-weight: 700; font-size: 14px; }
.upload-tile small { font-size: 11px; color: var(--faint); }
.upload-tile:disabled { opacity: .6; cursor: progress; }

.upload-note { margin-top: 16px; font-size: 13px; border-radius: 10px; padding: 9px 13px; display: inline-block; }
.upload-note code { font-family: 'JetBrains Mono', monospace; font-size: 12px; background: color-mix(in srgb, var(--text) 8%, transparent); padding: 1px 5px; border-radius: 5px; }
.upload-note.warn { color: var(--on-a3); background: color-mix(in srgb, var(--a3) 22%, transparent); }
.upload-note.ok   { color: var(--a2); background: color-mix(in srgb, var(--a2) 12%, transparent); }
.upload-note.err  { color: #fff; background: #e0483a; }

/* single image slot (điểm đến) */
.server-slot {
  position: relative; width: 100%; height: 100%; min-height: 320px; border-radius: 22px; overflow: hidden;
  background: var(--surface-2); box-shadow: var(--card-shadow); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: outline .15s;
}
.server-slot.filled { cursor: default; }
.server-slot.is-over { outline: 2px solid var(--a1); outline-offset: -2px; }
.server-slot img { width: 100%; height: 100%; object-fit: cover; }
.server-slot-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--faint);
  border: 2px dashed var(--line-2); border-radius: 18px; inset: 14px; position: absolute;
  justify-content: center; text-align: center; padding: 14px; transition: border-color .2s, color .2s;
}
.server-slot:hover .server-slot-empty { border-color: var(--a1); color: var(--a1); }
.server-slot-empty span { font-weight: 600; font-size: 14px; }
.server-slot-empty small { font-size: 11px; }
.server-slot-empty small.err { color: #e0483a; }
.server-slot-replace {
  position: absolute; bottom: 12px; right: 12px; border: none; cursor: pointer;
  background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 600; padding: 7px 13px;
  border-radius: 8px; opacity: 0; transition: opacity .15s, background .2s; backdrop-filter: blur(6px);
}
.server-slot:hover .server-slot-replace { opacity: 1; }
.server-slot-replace:hover { background: var(--a1); color: var(--on-a1); }
/* nút Xoá (✕) trên ô ảnh bìa — hiện khi hover */
.server-slot-del { opacity: 0; z-index: 2; }
.server-slot:hover .server-slot-del { opacity: 1; }

/* lightbox xem ảnh lớn */
.lightbox {
  position: fixed; inset: 0; z-index: 10000; background: rgba(0,0,0,.82);
  display: grid; place-items: center; padding: 4vh 4vw; cursor: zoom-out; animation: lb-in .18s ease;
}
.lightbox img { max-width: 100%; max-height: 92vh; border-radius: 12px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.7); }
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- THEME DOCK (cố định cuối màn hình) ---------- */
.theme-dock {
  position: fixed; bottom: 18px; right: 18px;
  z-index: 95; display: flex; gap: 4px; padding: 5px;
  border-radius: 999px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line); box-shadow: 0 14px 36px -12px rgba(0,0,0,.35);
  backdrop-filter: blur(14px);
}
.theme-dock-btn {
  border: none; cursor: pointer; border-radius: 999px;
  padding: 8px 18px; font-size: 12.5px; font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  background: transparent; color: var(--dim); transition: all .25s;
}
.theme-dock-btn.active { background: var(--a1); color: var(--on-a1); box-shadow: 0 6px 16px -6px var(--a1); }
.theme-dock-btn:not(.active):hover { color: var(--text); background: var(--surface-2); }
@media (max-width: 560px) {
  .theme-dock { bottom: 12px; right: 12px; }
  .theme-dock-btn { padding: 7px 14px; }
}

/* scrollbar */
::-webkit-scrollbar { width: 11px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid var(--bg-2); }
::-webkit-scrollbar-thumb:hover { background: var(--a1); }
