/*
 * ux-restructure.css — SelfPrint UX Restructure v1.0
 * ใช้คู่กับ js/ux-restructure.js
 * เพิ่มใน index.html: <link rel="stylesheet" href="css/ux-restructure.css">
 *
 * ✅ Isolated styles — ไม่ override ตัวเลขใน quiz, insight card, archetype display
 * ✅ ใช้ CSS variables จาก main.css (--gold, --tx, --tx2, --bg, --panel)
 * ✅ Mobile-first, tap target ≥ 44px
 *
 * Last Updated: 2026-07-26
 */

/* ─── CSS VARIABLE FALLBACKS (ถ้า main.css โหลดก่อน ตัวเหล่านี้จะไม่ทำงาน) ─── */
:root {
  --av-gold     : var(--gold,     #f0c040);
  --av-tx       : var(--tx,       #e8e0d0);
  --av-tx2      : var(--tx2,      #9a9080);
  --av-bg       : var(--bg,       #0d0b14);
  --av-panel    : var(--panel,    #1a1728);
  --av-primary  : #7c5cbf;
  --av-radius   : 16px;
  --av-nav-h    : 68px;
  --av-anim     : 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BOTTOM NAVIGATION
   ═══════════════════════════════════════════════════════════════════════════ */

.av-bottom-nav {
  position     : fixed;
  bottom       : 0;
  left         : 0;
  right        : 0;
  height       : var(--av-nav-h);
  background   : rgba(15,31,63, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top   : 1px solid rgba(255,255,255,0.06);
  display      : flex;
  align-items  : stretch;
  z-index      : 900;
  padding-bottom: env(safe-area-inset-bottom);
}

.av-nav-tab {
  flex         : 1;
  display      : flex;
  flex-direction: column;
  align-items  : center;
  justify-content: center;
  gap          : 3px;
  background   : none;
  border       : none;
  cursor       : pointer;
  padding      : 8px 4px;
  min-height   : 44px;
  color        : var(--av-tx2);
  transition   : color var(--av-anim);
  -webkit-tap-highlight-color: transparent;
}

.av-nav-tab:active { opacity: 0.7; }

.av-nav-tab--active {
  color: var(--av-gold);
}

.av-nav-tab--center .av-nav-icon {
  width        : 44px;
  height       : 44px;
  background   : linear-gradient(135deg, var(--av-primary), #6D5A96);
  border-radius: 50%;
  display      : flex;
  align-items  : center;
  justify-content: center;
  font-size    : 20px;
  margin-bottom: 2px;
  box-shadow   : 0 4px 12px rgba(139,123,184,0.4);
}

.av-nav-icon  { font-size: 20px; line-height: 1; }
.av-nav-label { font-size: 10px; font-weight: 600; letter-spacing: 0.3px; }

/* Body padding ไม่ให้ content ซ่อนใต้ nav */
body { padding-bottom: calc(var(--av-nav-h) + env(safe-area-inset-bottom)); }

/* ═══════════════════════════════════════════════════════════════════════════
   SC-WELCOME — Welcome Screen
   ═══════════════════════════════════════════════════════════════════════════ */

#sc-welcome {
  min-height   : 100dvh;
  display      : flex;
  flex-direction: column;
  align-items  : center;
  justify-content: center;
  padding      : 40px 24px calc(var(--av-nav-h) + 40px);
  text-align   : center;
  background   : radial-gradient(ellipse at 50% 30%, rgba(139,123,184,0.15) 0%, transparent 70%);
}

.welcome-logo {
  font-size    : 64px;
  margin-bottom: 20px;
  animation    : av-float 3s ease-in-out infinite;
}

@keyframes av-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

.welcome-title {
  font-size    : 28px;
  font-weight  : 700;
  color        : var(--av-tx);
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.welcome-sub {
  font-size    : 15px;
  color        : var(--av-tx2);
  line-height  : 1.6;
  max-width    : 280px;
  margin       : 0 auto 40px;
}

.welcome-btn {
  display      : block;
  width        : 100%;
  max-width    : 280px;
  padding      : 16px 24px;
  background   : linear-gradient(135deg, var(--av-primary), #6D5A96);
  color        : #fff;
  font-size    : 16px;
  font-weight  : 700;
  border       : none;
  border-radius: var(--av-radius);
  cursor       : pointer;
  box-shadow   : 0 6px 20px rgba(139,123,184,0.35);
  transition   : transform 0.15s, box-shadow 0.15s;
  margin       : 0 auto;
}

.welcome-btn:active {
  transform    : scale(0.97);
  box-shadow   : 0 3px 10px rgba(139,123,184,0.25);
}

.welcome-skip {
  margin-top   : 16px;
  background   : none;
  border       : none;
  color        : var(--av-tx2);
  font-size    : 13px;
  cursor       : pointer;
  padding      : 8px;
  min-height   : 44px;
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SC-INTENT — Intent Selection Screen
   ═══════════════════════════════════════════════════════════════════════════ */

#sc-intent {
  min-height   : 100dvh;
  padding      : 48px 20px calc(var(--av-nav-h) + 24px);
  display      : flex;
  flex-direction: column;
}

.intent-heading {
  font-size    : 22px;
  font-weight  : 700;
  color        : var(--av-tx);
  text-align   : center;
  margin-bottom: 8px;
}

.intent-sub {
  font-size    : 14px;
  color        : var(--av-tx2);
  text-align   : center;
  margin-bottom: 32px;
}

.intent-grid {
  display      : grid;
  grid-template-columns: repeat(2, 1fr);
  gap          : 12px;
  flex         : 1;
}

.intent-card {
  background   : var(--av-panel);
  border       : 1.5px solid rgba(255,255,255,0.07);
  border-radius: var(--av-radius);
  padding      : 20px 12px 16px;
  display      : flex;
  flex-direction: column;
  align-items  : center;
  gap          : 8px;
  cursor       : pointer;
  transition   : border-color var(--av-anim), transform 0.15s, background var(--av-anim);
  min-height   : 100px;
  -webkit-tap-highlight-color: transparent;
}

.intent-card:active {
  transform    : scale(0.96);
  border-color : var(--av-gold);
  background   : rgba(240,192,64,0.06);
}

.intent-card:focus-visible {
  outline      : 2px solid var(--av-gold);
  outline-offset: 2px;
}

.intent-icon  { font-size: 28px; }
.intent-label { font-size: 13px; font-weight: 700; color: var(--av-tx); text-align: center; }
.intent-sub-label { font-size: 10px; color: var(--av-tx2); text-align: center; }

/* ═══════════════════════════════════════════════════════════════════════════
   SC-JOURNEY — Personal Journey Animation
   ═══════════════════════════════════════════════════════════════════════════ */

#sc-journey {
  min-height   : 100dvh;
  display      : flex;
  flex-direction: column;
  align-items  : center;
  justify-content: center;
  padding      : 40px 24px;
  text-align   : center;
}

.journey-orbit {
  position     : relative;
  width        : 140px;
  height       : 140px;
  margin-bottom: 32px;
}

.journey-orbit-ring {
  position     : absolute;
  inset        : 0;
  border       : 2px solid rgba(240,192,64,0.2);
  border-radius: 50%;
  animation    : av-orbit-spin 4s linear infinite;
}

.journey-orbit-ring::before {
  content      : '';
  position     : absolute;
  top          : -4px;
  left         : 50%;
  width        : 8px;
  height       : 8px;
  background   : var(--av-gold);
  border-radius: 50%;
  transform    : translateX(-50%);
  box-shadow   : 0 0 8px var(--av-gold);
}

@keyframes av-orbit-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

#journey-icon {
  position     : absolute;
  top          : 50%;
  left         : 50%;
  transform    : translate(-50%, -50%);
  font-size    : 48px;
}

.journey-title {
  font-size    : 20px;
  font-weight  : 700;
  color        : var(--av-tx);
  margin-bottom: 6px;
}

#journey-focus {
  font-size    : 16px;
  color        : var(--av-gold);
  font-weight  : 600;
  margin-bottom: 32px;
}

.journey-bar-wrap {
  width        : 100%;
  max-width    : 280px;
  height       : 6px;
  background   : rgba(255,255,255,0.08);
  border-radius: 99px;
  overflow     : hidden;
  margin-bottom: 16px;
}

#journey-bar {
  height       : 100%;
  width        : 0%;
  background   : linear-gradient(90deg, var(--av-primary), var(--av-gold));
  border-radius: 99px;
  transition   : width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#journey-label {
  font-size    : 13px;
  color        : var(--av-tx2);
  min-height   : 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SC-HOME — 4-Item Dashboard
   ═══════════════════════════════════════════════════════════════════════════ */

#sc-home {
  padding      : 20px 16px calc(var(--av-nav-h) + 16px);
  min-height   : 100dvh;
}

.home-greeting {
  font-size    : 18px;
  font-weight  : 700;
  color        : var(--av-tx);
  margin-bottom: 16px;
  padding-top  : 8px;
}

/* Dashboard cards grid */
.dash-cards {
  display      : flex;
  flex-direction: column;
  gap          : 12px;
}

.dash-card {
  background   : var(--av-panel);
  border       : 1px solid rgba(255,255,255,0.06);
  border-radius: var(--av-radius);
  padding      : 16px;
  overflow     : hidden;
}

.dash-card-title {
  font-size    : 11px;
  font-weight  : 700;
  color        : var(--av-tx2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

/* Card 1: Today's Insight */
.dash-insight-chip {
  display      : inline-block;
  font-size    : 10px;
  font-weight  : 700;
  color        : var(--av-gold);
  background   : rgba(240,192,64,0.1);
  padding      : 3px 8px;
  border-radius: 99px;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.dash-insight-text {
  font-size    : 15px;
  color        : var(--av-tx);
  line-height  : 1.6;
}

/* Card 2: Continue Journey */
.dash-continue-btn {
  display      : flex;
  align-items  : center;
  gap          : 8px;
  width        : 100%;
  padding      : 14px 16px;
  background   : linear-gradient(135deg, rgba(139,123,184,0.15), rgba(109,90,150,0.1));
  border       : 1.5px solid rgba(139,123,184,0.3);
  border-radius: 12px;
  color        : var(--av-tx);
  font-size    : 14px;
  cursor       : pointer;
  text-align   : left;
  transition   : border-color var(--av-anim), background var(--av-anim);
  min-height   : 44px;
}

.dash-continue-btn:active {
  border-color : var(--av-primary);
  background   : rgba(139,123,184,0.2);
}

.dash-arrow {
  margin-left  : auto;
  color        : var(--av-tx2);
}

.dash-done {
  font-size    : 14px;
  color        : var(--av-gold);
  text-align   : center;
  padding      : 8px 0;
}

/* Card 3: Ask AI */
.dash-ask-btn {
  display      : block;
  width        : 100%;
  padding      : 14px 16px;
  background   : rgba(255,255,255,0.04);
  border       : 1.5px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  color        : var(--av-tx2);
  font-size    : 14px;
  cursor       : pointer;
  text-align   : left;
  transition   : border-color var(--av-anim);
  min-height   : 44px;
}

.dash-ask-btn:active { border-color: var(--av-primary); }

/* Card 4: Recent Progress */
.dp-row {
  display      : flex;
  justify-content: space-between;
  align-items  : center;
  padding      : 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size    : 13px;
  color        : var(--av-tx2);
}

.dp-row:last-child { border-bottom: none; }
.dp-row strong    { color: var(--av-tx); font-weight: 700; }

.dp-next {
  margin-top   : 10px;
  font-size    : 11px;
  color        : var(--av-gold);
  opacity      : 0.8;
  text-align   : center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SC-GUIDE — AI Guide Screen
   ═══════════════════════════════════════════════════════════════════════════ */

#sc-guide {
  padding      : 24px 16px calc(var(--av-nav-h) + 16px);
  min-height   : 100dvh;
}

.guide-header {
  display      : flex;
  align-items  : center;
  gap          : 12px;
  margin-bottom: 24px;
}

.guide-avatar { font-size: 36px; }

.guide-title {
  font-size    : 18px;
  font-weight  : 700;
  color        : var(--av-tx);
}

.guide-sub {
  font-size    : 12px;
  color        : var(--av-tx2);
}

#guide-content { display: flex; flex-direction: column; gap: 10px; }

.guide-tip {
  background   : var(--av-panel);
  border       : 1px solid rgba(255,255,255,0.06);
  border-left  : 3px solid var(--av-gold);
  border-radius: 12px;
  padding      : 14px 16px;
  font-size    : 14px;
  color        : var(--av-tx);
  line-height  : 1.6;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SC-JOURNEY-HUB — All Modules with Lock State
   ═══════════════════════════════════════════════════════════════════════════ */

#sc-journey-hub {
  padding      : 24px 16px calc(var(--av-nav-h) + 16px);
  min-height   : 100dvh;
}

.jh-page-title {
  font-size    : 20px;
  font-weight  : 700;
  color        : var(--av-tx);
  margin-bottom: 4px;
}

.jh-page-sub {
  font-size    : 13px;
  color        : var(--av-tx2);
  margin-bottom: 20px;
}

.jh-group { margin-bottom: 20px; }

.jh-group-hd {
  font-size    : 11px;
  font-weight  : 700;
  color        : var(--av-gold);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  padding-left : 4px;
}

.jh-item {
  display      : flex;
  align-items  : center;
  gap          : 12px;
  padding      : 14px 12px;
  border-radius: 12px;
  margin-bottom: 6px;
  transition   : background var(--av-anim);
}

.jh-on {
  background   : var(--av-panel);
  border       : 1px solid rgba(255,255,255,0.06);
  cursor       : pointer;
}

.jh-on:active { background: rgba(139,123,184,0.15); }

.jh-off {
  background   : rgba(255,255,255,0.02);
  border       : 1px solid rgba(255,255,255,0.03);
  opacity      : 0.55;
}

.jh-done { border-color: rgba(80,200,120,0.2) !important; }

.jh-icon  { font-size: 24px; flex-shrink: 0; }
.jh-info  { flex: 1; }
.jh-name  { font-size: 14px; font-weight: 600; color: var(--av-tx); }
.jh-th    { font-size: 11px; color: var(--av-tx2); margin-top: 2px; }

.jh-go    { font-size: 16px; color: var(--av-tx2); flex-shrink: 0; }

.jh-lock {
  display      : flex;
  flex-direction: column;
  align-items  : center;
  font-size    : 16px;
  flex-shrink  : 0;
  gap          : 2px;
}

.jh-lock small {
  font-size    : 9px;
  color        : var(--av-tx2);
  font-weight  : 600;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FEATURE LOCK BADGE  (on [data-av-screen] elements)
   ═══════════════════════════════════════════════════════════════════════════ */

.av-locked {
  position     : relative;
  pointer-events: none;
  opacity      : 0.45;
}

.av-lock-badge {
  position     : absolute;
  top          : 8px;
  right        : 8px;
  font-size    : 10px;
  font-weight  : 700;
  color        : #fff;
  background   : rgba(139,123,184,0.8);
  padding      : 3px 8px;
  border-radius: 99px;
  pointer-events: none;
  z-index      : 10;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RECOMMENDATION BANNER
   ═══════════════════════════════════════════════════════════════════════════ */

.av-rec-banner {
  position     : fixed;
  bottom       : calc(var(--av-nav-h) + 12px);
  left         : 12px;
  right        : 12px;
  background   : #1e1a2e;
  border       : 1px solid rgba(240,192,64,0.25);
  border-radius: var(--av-radius);
  box-shadow   : 0 8px 24px rgba(0,0,0,0.5);
  z-index      : 950;
  overflow     : hidden;
  transform    : translateY(20px);
  opacity      : 0;
  transition   : transform var(--av-anim), opacity var(--av-anim);
}

.av-rec-banner--in {
  transform    : translateY(0);
  opacity      : 1;
}

.av-rec-inner {
  display      : flex;
  gap          : 12px;
  padding      : 14px 16px;
  align-items  : flex-start;
}

.av-rec-avatar {
  font-size    : 24px;
  flex-shrink  : 0;
  margin-top   : 2px;
}

.av-rec-body   { flex: 1; }

.av-rec-msg {
  font-size    : 14px;
  color        : var(--av-tx);
  line-height  : 1.55;
  margin-bottom: 12px;
}

.av-rec-actions {
  display      : flex;
  gap          : 8px;
}

.av-rec-btn-yes,
.av-rec-btn-no {
  padding      : 8px 16px;
  border-radius: 8px;
  font-size    : 13px;
  font-weight  : 600;
  cursor       : pointer;
  border       : none;
  min-height   : 36px;
  transition   : opacity 0.15s;
}

.av-rec-btn-yes:active,
.av-rec-btn-no:active { opacity: 0.7; }

.av-rec-btn-yes {
  background   : linear-gradient(135deg, var(--av-primary), #6D5A96);
  color        : #fff;
  flex         : 1;
}

.av-rec-btn-no {
  background   : rgba(255,255,255,0.06);
  color        : var(--av-tx2);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Landscape + larger screens
   ═══════════════════════════════════════════════════════════════════════════ */

@media (min-width: 420px) {
  .intent-grid  { grid-template-columns: repeat(3, 1fr); }
  .dash-cards   { display: grid; grid-template-columns: 1fr 1fr; }
  #sc-home .dash-cards > .dash-card:first-child,
  #sc-home .dash-cards > .dash-card:last-child { grid-column: span 2; }
}

@media (min-width: 768px) {
  .av-bottom-nav { max-width: 480px; left: 50%; right: auto; transform: translateX(-50%); border-radius: 20px 20px 0 0; }
  #sc-home       { max-width: 480px; margin: 0 auto; }
  #sc-guide      { max-width: 480px; margin: 0 auto; }
  #sc-journey-hub{ max-width: 480px; margin: 0 auto; }
  .av-rec-banner { max-width: 480px; left: 50%; right: auto; transform: translateX(-50%) translateY(20px); }
  .av-rec-banner--in { transform: translateX(-50%) translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   DARK MODE SAFE — ตัวแปรทั้งหมดพึ่ง CSS variables ไม่ hardcode สี
   ═══════════════════════════════════════════════════════════════════════════ */
