/* === 設計系統變數 === */
:root {
  --bg:         #F6F4F1;
  --text:       #9a8b87;
  --text-muted: #d7d0cd;
  --glow:       #E8E1D8;
  --divider:    rgba(154, 139, 135, 0.15);

  --font-serif: 'Noto Serif TC', Georgia, serif;
  --font-sans:  'Inter', system-ui, sans-serif;

  --section-gap: 40px;
  --line-height: 1.85;

  --header-logo-h:  28px;
  --header-pad-top: clamp(6px, 1.5svh, 12px);
  --header-pad-btm: clamp(6px, 1svh, 12px);
  --header-h: calc(var(--header-logo-h) + var(--header-pad-top) + var(--header-pad-btm));
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.no-scroll {
  /* 不鎖定滾動，保留 class 以免 JS 報錯 */
}

/* === 畫面容器 === */
.screen {
  display: none;
  min-height: 100vh;
  min-height: 100svh;
  width: 100%;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
}

/* landing 頁用 body.no-scroll 防捲動，不需 overflow:hidden，讓 header::before 100vw 不被剪裁 */
#screen-landing {
  overflow: visible;
}

.screen.active {
  display: flex;
}

/* summary 頁可滾動 */
#screen-summary {
  height: auto;
  min-height: 100svh;
  overflow: visible;
}

.screen-inner {
  width: 100%;
  max-width: 390px;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 進入頁：logo 左上，body flex-1 自適應，按鈕底部 */
.screen-inner--landing {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: max(72px, calc(env(safe-area-inset-bottom, 0px) + clamp(40px, 8svh, 72px)));
  padding-left: 0;
  padding-right: 0;
  justify-content: flex-start;
  gap: 0;
  height: 100vh;
  height: 100svh;
  overflow: visible; /* 讓 header::before 可以延伸至 100vw，外層 .screen 已有 overflow:hidden */
}

/* 狀態選擇頁 */
.screen-inner--status {
  justify-content: flex-start;
  align-items: center;
  gap: clamp(16px, 3svh, 35px);
  padding-top: calc(env(safe-area-inset-top, 0px) + var(--header-h) + clamp(16px, 3svh, 28px));
  padding-bottom: clamp(16px, 4svh, 40px);
  min-height: 100svh;
}

/* 感應中頁 */
.screen-inner--loading {
  justify-content: flex-start;
  align-items: center;
  gap: 0;
  padding-top: calc(env(safe-area-inset-top, 0px) + var(--header-h) + clamp(16px, 3svh, 28px));
  padding-bottom: 0;
  min-height: 100svh;
}

.loading-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
}


/* 卡牌顯示頁 */
.screen-inner--card {
  position: relative;
  padding-top: calc(env(safe-area-inset-top, 0px) + var(--header-h) + clamp(12px, 2svh, 20px));
  padding-bottom: clamp(80px, 14svh, 120px);
  gap: clamp(8px, 1.5svh, 16px);
  justify-content: flex-start;
  align-items: center;
  min-height: 100svh;
}

/* 宇宙訊息頁 */
.screen-inner--summary {
  padding-top: calc(env(safe-area-inset-top, 0px) + var(--header-h) + clamp(16px, 3svh, 28px));
  padding-bottom: max(60px, calc(env(safe-area-inset-bottom) + 40px));
  gap: 25px;
  justify-content: flex-start;
  align-items: center;
}

/* Landing 專屬結構與樣式 */
.landing-header {
  width: 100%;
  padding-top: var(--header-pad-top);
  padding-bottom: var(--header-pad-btm);
  padding-left: 32px;
  padding-right: 32px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 110;
  background: rgb(250, 250, 250);
  isolation: isolate;
}

/* Landing 頁保留原本相對定位行為 */
.screen-inner--landing .landing-header {
  position: relative;
  background: transparent;
}

/* 背景延伸至全寬：僅 landing 情境保留 */
.screen-inner--landing .landing-header::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100vw;
  background: rgb(250, 250, 250);
  z-index: -1;
}

.landing-logo {
  width: min(68px, 22vw);
  height: var(--header-logo-h);
  object-fit: contain;
  display: block;
  opacity: 0.60;
}

.landing-body {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  /* align-items 保持預設 stretch，讓子元素撐滿寬度，不依賴 width:100% */
  justify-content: flex-start;
  gap: clamp(108px, 20svh, 148px);
  padding: clamp(72px, 14svh, 112px) 32px clamp(20px, 4svh, 48px);
  overflow: hidden;
}

.landing-upper {
  /* stretch 預設，撐滿 landing-body 內容寬 */
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.landing-label {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1.2rem;
  color: #d7d0cd;
  letter-spacing: 0.18em;
  text-indent: 0.18em;   /* 補償 letter-spacing trailing space，修正視覺偏移 */
  line-height: 1.6;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.landing-label::after {
  content: '';
  display: block;
  width: 80px;
  height: 1px;
  background: #d8d2cd;
  opacity: 0.8;
}

.landing-headline {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(1.05rem, 2.8svh, 1.3rem);
  color: #a09590;
  line-height: 1.55;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  text-align: center;
}

.landing-headline-em {
  font-size: clamp(1.3rem, 3.5svh, 1.6rem);
}

.landing-lower {
  width: 100%;
}

.landing-secondary {
  width: 100%;
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(1rem, 2.6svh, 1.2rem);
  color: #a09590;
  line-height: 1.7;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  text-align: center;
  padding-right: 0.5em;
}

/* Landing 專用按鈕（膠囊，背景暫與頁面同色，未來直接換背景色即可） */
.btn-landing {
  background: #f6f4f1;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  padding: 13px 44px;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 0.4em;

  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.35rem;
  color: #9a8b87;
  letter-spacing: 0.22em;

  transition: opacity 0.6s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-landing:active {
  opacity: 0.6;
}

.btn-landing-text {
  letter-spacing: 0.22em;
  margin-left: 0.22em;   /* 補償 letter-spacing trailing space，讓按鈕文字視覺置中 */
}

.btn-landing-arrow {
  letter-spacing: 0;
}

/* === 狀態選擇頁 === */
.status-prompt {
  font-family: var(--font-serif);
  font-weight: 200;
  font-size: 1.1rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.06em;
  line-height: var(--line-height);
}

.status-options {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.status-btn {
  background: none;
  border: none;
  border-bottom: 1px solid rgba(154, 139, 135, 0.08);
  width: 100%;
  padding: clamp(16px, 3svh, 26px) 0;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: opacity 0.25s ease, background 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
}

/* 有選項被選中時，其他選項才淡退 */
.status-options:has(.selected) .status-btn:not(.selected) {
  opacity: 0.45;
}

.status-btn:first-child {
  border-top: 1px solid rgba(154, 139, 135, 0.08);
}

.status-btn:active {
  opacity: 0.5;
}

.status-btn.selected {
  background: var(--glow);
  opacity: 1;
  transform: translateX(4px) scale(0.98);
}

.status-btn.selected .status-label {
  color: var(--text);
}

.status-btn.selected .status-sub {
  opacity: 0.75;
}

.status-label {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1.3rem;
  color: var(--text);
  letter-spacing: 0.08em;
}

.status-sub {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  white-space: nowrap;
}

#btn-status-confirm {
  margin-top: auto;
  padding: 10px 32px;
  min-height: 44px;
  font-size: 1rem;
  padding-bottom: max(10px, calc(env(safe-area-inset-bottom) + 10px));
  margin-bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
}

#btn-status-confirm:disabled {
  opacity: 0.35;
  cursor: default;
}

.status-footer-hint {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.15em;
  opacity: 0.55;
  margin-top: auto;
  padding-bottom: max(30px, calc(env(safe-area-inset-bottom) + 24px)); /*按鈕高度=== */
}

/* === 感應中（Loading） === */
.breath-orb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at center, #d7d0cd 0%, transparent 70%);
  animation: breath 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes breath {
  0%, 100% { transform: scale(0.8);  opacity: 0.35; }
  50%       { transform: scale(1.2); opacity: 0.9; }
}

/* === 卡牌出現過渡遮罩 === */
#card-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  z-index: 100;
  pointer-events: none;
  animation: overlay-out 0.01s linear 0.8s forwards;
}

@keyframes overlay-out {
  to { opacity: 0; visibility: hidden; }
}

.loading-text {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1.2rem;
  color: var(--text-muted);
  line-height: var(--line-height);
  text-align: center;
  letter-spacing: 0.05em;
}

.loading-error {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.08em;
  opacity: 0.7;
}

/* === 卡牌顯示 === */
.card-position-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.45em;
  width: 100%;
  margin-bottom: 4px;
}
.card-position-title::before,
.card-position-title::after {
  content: '';
  flex: 0 0 28px;
  height: 1px;
  background: var(--text-muted);
  opacity: 0.35;
}

/* 卡牌圖：浮感，無陰影無邊框 */
.card-image-wrap {
  width: clamp(140px, 25svh, 230px);
  aspect-ratio: 2 / 3;
  flex-shrink: 0;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 6px;
}

/* 逆位旋轉 */
.card-image-wrap.reversed .card-image {
  transform: rotate(180deg);
}

.card-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.card-name {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1.4rem;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.1em;
}

.card-orientation {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  opacity: 0.45;
}


/* === Reading 分段動畫 === */
.reading-lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: auto;
  margin-bottom: auto;
}

.reading-line {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.4rem;
  line-height: 1.6;/* 卡片行距 */
  padding-top: 1.2em;
  padding-bottom: 1.2em;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.04em;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.65s ease, transform 0.65s ease;
}

.reading-line.visible {
  opacity: 1;
  transform: translateY(0);
}

/* 卡牌提示文字 */
.card-hint {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 2.2;
  letter-spacing: 0.05em;
  opacity: 0.8;
  width: 100%;
  margin-top: auto;
}

#btn-next-card {
  white-space: nowrap;
  margin-top: auto;
}

/* === 橢圓填滿按鈕 === */
.btn-ghost {
  background: #dcd5d3;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  padding: 13px 44px;
  min-height: 52px;

  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: 0.15em;

  transition: background 0.2s ease, color 0.05s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-ghost:hover,
.btn-ghost:focus-visible {
  background: #d0c9c7;
  outline: none;
}

.btn-ghost:active {
  background: #c5bebb;
  opacity: 0.7;
}

/* === 宇宙訊息頁 === */
.summary-cosmos {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 50px;
  padding: 32px 24px;
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
  width: 100%;
}

.summary-section-label {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.6em;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0.7;
}

.summary-section-label::before,
.summary-section-label::after {
  content: '';
  display: block;
  width: 20px;
  height: 1px;
  background: var(--divider);
  flex-shrink: 0;
}

.summary-cards {
  display: flex;
  flex-direction: column;
  gap: 48px;
  width: 100%;
}

.summary-card-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  opacity: 0;
  transform: translateY(16px);
  animation: section-enter 0.6s ease both;
}

.summary-card-section:nth-child(1) { animation-delay: 0.1s; }
.summary-card-section:nth-child(2) { animation-delay: 0.3s; }
.summary-card-section:nth-child(3) { animation-delay: 0.5s; }

@keyframes section-enter {
  to { opacity: 1; transform: translateY(0); }
}

.summary-position {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.45em;
  text-align: center;
  width: 100%;
}
.summary-position::before,
.summary-position::after {
  content: '';
  flex: 0 0 28px;
  height: 1px;
  background: var(--text-muted);
  opacity: 0.35;
}

.summary-card-image {
  width: 140px;
  aspect-ratio: 2 / 3;
  flex-shrink: 0;
}

.summary-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 6px;
}

.summary-card-image.reversed img {
  transform: rotate(180deg);
}

.summary-card-name {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1.25rem;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.08em;
}

.summary-orientation {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.18em;
}

.summary-reading {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1.1rem;
  line-height: 2;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.03em;
  width: 100%;
}

.summary-divider {
  width: 40px;
  height: 1px;
  background: var(--divider);
}

.summary-text {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.1rem;
  line-height: 1.75;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.05em;
  width: 100%;
 opacity: 0.5;
}

.summary-product-name {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.3em;
  opacity: 0.55;
}

.summary-product-name:empty {
  display: none;
}


.summary-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  margin-top: 50px;
  padding-bottom: 40px;
  width: 100%;
}

.summary-hint {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.18em;
  opacity: 0.5;
}

.summary-hint:first-child,
.summary-hint:last-child {
  opacity: 0.9;
  font-size: 1.1rem;
  letter-spacing: 0.2em;
}

.summary-hint:nth-child(2) {
  opacity: 0.9;
  font-size: 1rem;
  letter-spacing: 0.25em;
}

.summary-hint--link {
  cursor: pointer;
  opacity: 1;
  transition: color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

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

/* CTA 主次層級 */
.summary-hint--primary {
  opacity: 1;
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  color: var(--text);
}

.summary-hint--separator {
  opacity: 0.45;
  font-size: 0.9rem;
  letter-spacing: 0.25em;
}

.summary-hint--secondary {
  opacity: 0.55;
  font-size: 1rem;
  letter-spacing: 0.2em;
}

.summary-hint-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.summary-nfc-tip {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-align: center;
}

/* === LINE 瀏覽器補丁：底部導覽列遮住按鈕 === */
/*
  LINE 的內建瀏覽器底部有約 50-60px 的導覽列，
  但不會正確回報 safe-area-inset-bottom，
  導致 position:absolute 或 margin-top:auto 的底部按鈕被遮住。
  JS 偵測到 LINE UA 後會在 <html> 加上 .line-browser class。
*/

/* 狀態頁確認按鈕：LINE 底部導覽列額外補空間 */
.line-browser #btn-status-confirm {
  margin-bottom: max(32px, calc(env(safe-area-inset-bottom, 0px) + 24px));
}

/* 卡牌頁：底部絕對定位按鈕下移補償 */
.line-browser #btn-next-card,
.line-browser .card-hint {
  bottom: max(72px, calc(env(safe-area-inset-bottom, 0px) + 60px));
}

/* Landing 開始按鈕 */
.line-browser #btn-start {
  bottom: max(96px, calc(env(safe-area-inset-bottom, 0px) + 80px)) !important;
}

/* Landing 前置文字 */
.line-browser #landing-pre-text {
  bottom: max(160px, calc(env(safe-area-inset-bottom, 0px) + 144px)) !important;
}

/* === 桌面版：置中限寬 === */
@media (min-width: 520px) {
  body {
    display: flex;
    justify-content: center;
  }

  .screen {
    max-width: 480px;
  }

  .card-image-wrap {
    width: 240px;
  }

  .summary-card-image {
    width: 160px;
  }
}

/* === 導購頁 === */
.screen-inner--promo {
  justify-content: flex-start;
  align-items: center;
  gap: 28px;
  padding-top: calc(env(safe-area-inset-top, 0px) + var(--header-h) + clamp(48px, 8svh, 80px));
  padding-bottom: 10svh;
  min-height: 100svh;
  text-align: center;
}


.promo-body {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 2;
  letter-spacing: 0.05em;
}
