/* 自動補樣式：js/screens/me.js（_build/style.py） */
/* ==========================================================================
   js/screens/me.js 專用樣式（我的頁）
   - 只使用 tokens.css 變數，淺色與深色模式自動切換
   - 手機單欄；容器 ≥ 560px 起，卡片排成 2 欄
   - 未列入需求的 u-* 與 c-privacy-notes 僅在 .s-me 範圍內補樣式，避免影響其他畫面
   ========================================================================== */

/* ---------- 範圍內的文字工具 ---------- */
.s-me .u-strong {
  font-weight: 600;
  color: var(--text);
}

.s-me .u-text-2 {
  color: var(--text-2);
}

.s-me .u-text-3 {
  color: var(--text-3);
}

.s-me .u-footnote {
  font-size: var(--fs-footnote);
  line-height: var(--lh-footnote);
}

.s-me .c-card p {
  font-size: var(--fs-callout);
  line-height: var(--lh-callout);
}

.s-me .c-card p + p,
.s-me .c-card p + .s-me__details,
.s-me .c-card .s-me__details + .s-me__row,
.s-me .c-card .c-privacy-line + .s-me__details {
  margin-top: var(--sp-3);
}

/* ---------- 版面：卡片格線 ---------- */
.s-me {
  display: block;
  width: 100%;
  min-width: 0;
}

.s-more-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-3);
  align-items: start;
}

.s-more-grid > .c-card {
  height: 100%;
}

@container view (min-width: 560px) {
  .s-more-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-4);
    align-items: stretch;
  }
}

/* ---------- 資料與備份卡 ---------- */
.s-me__backup-time {
  margin: 0;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-variant-numeric: var(--num-feature);
  color: var(--text);
}

.s-me__backup-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  margin-top: var(--sp-3);
}

.s-me__backup-actions > .c-btn--primary {
  flex: 1 1 160px;
}

.s-me__backup-actions > .c-btn--ghost {
  flex: 0 1 auto;
}

.s-me__backup-note {
  margin: var(--sp-3) 0 0;
  color: var(--text-3);
}

/* ---------- 列（連結列） ---------- */
.s-me__list {
  display: flex;
  flex-direction: column;
}

.s-me__row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 48px;
  margin-inline: calc(-1 * var(--sp-2));
  padding: var(--sp-2) var(--sp-2);
  border-radius: var(--r-sm);
  color: var(--text);
  text-decoration: none;
  transition: background var(--dur-1) var(--ease);
}

.s-me__row > svg:first-child {
  flex: none;
  color: var(--primary);
}

.s-me__row > svg:last-child {
  flex: none;
  color: var(--text-3);
}

.s-me__row-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  overflow-wrap: anywhere;
}

.s-me__row > .u-text-3 {
  flex: none;
  font-size: var(--fs-footnote);
  line-height: var(--lh-footnote);
}

.s-me__row + .s-me__row {
  border-top: 1px solid var(--divider);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.s-me__row:active {
  background: var(--surface-2);
}

.s-me__row:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 1px;
  border-radius: var(--r-sm);
}

@container view (max-width: 420px) {
  .s-me__row > .u-text-3 {
    display: none;
  }
}

/* ---------- 收合區 ---------- */
.s-me__details {
  border-radius: var(--r-input);
}

.s-me__details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: var(--tap);
  padding: 0 var(--sp-1);
  color: var(--primary);
  font-size: var(--fs-callout);
  font-weight: 600;
  line-height: var(--lh-callout);
  list-style: none;
  cursor: pointer;
  user-select: none;
  border-radius: var(--r-sm);
}

.s-me__details > summary::-webkit-details-marker {
  display: none;
}

.s-me__details > summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--dur-2) var(--ease);
}

.s-me__details[open] > summary::after {
  transform: rotate(-135deg) translateY(-2px);
}

.s-me__details > summary:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.s-me__details[open] > summary {
  margin-bottom: var(--sp-2);
}

/* 隱私補充說明 */
.s-me .c-privacy-notes {
  margin: 0;
  padding: var(--sp-3) var(--sp-4) var(--sp-3) var(--sp-8);
  border-radius: var(--r-input);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-footnote);
  line-height: 1.6;
}

.s-me .c-privacy-notes li + li {
  margin-top: var(--sp-2);
}

/* ---------- 療程狀態單選卡 ---------- */
.s-me__radio-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.s-me__radio {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 64px;
  padding: var(--sp-3) var(--sp-4);
  border: 2px solid var(--border);
  border-radius: var(--r-input);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition:
    background var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease);
}

.s-me__radio:active {
  transform: scale(.99);
}

.s-me__radio.is-selected,
.s-me__radio[aria-checked="true"] {
  border-color: var(--primary);
  background: var(--primary-tint);
}

.s-me__radio[aria-disabled="true"] {
  opacity: .6;
  cursor: progress;
  pointer-events: none;
}

.s-me__radio:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.s-me__radio-check {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--text-3);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}

.s-me__radio-check svg {
  width: 16px;
  height: 16px;
}

.s-me__radio.is-selected .s-me__radio-check,
.s-me__radio[aria-checked="true"] .s-me__radio-check {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--text-on-primary);
}

.s-me__radio-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.s-me__radio-title {
  font-size: var(--fs-body);
  line-height: 1.35;
  font-weight: 600;
  color: var(--text);
}

.s-me__radio-desc {
  font-size: var(--fs-footnote);
  line-height: var(--lh-footnote);
  color: var(--text-2);
}

.s-me__radio.is-selected .s-me__radio-title,
.s-me__radio[aria-checked="true"] .s-me__radio-title {
  color: var(--primary);
}

/* ---------- 裝置能力（進階） ---------- */
.s-me__caps-details {
  margin: calc(-1 * var(--sp-1)) 0;
}

.s-me__cap-summary {
  margin: 0 0 var(--sp-3);
}

.s-me__cap-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-3);
  border-radius: var(--r-chip);
  background: var(--surface-2);
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  letter-spacing: var(--ls-caption);
  font-variant-numeric: var(--num-feature);
}

.s-me__cap-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}

.s-me__cap-chip.is-verified::before {
  background: var(--down);
}

.s-me__cap-chip.is-notVerified::before {
  background: transparent;
  border: 2px solid var(--text-3);
}

.s-me__cap-chip.is-unsupported::before {
  background: var(--surface-3);
  border: 2px solid var(--text-3);
}

.s-me__caps {
  list-style: none;
  margin: 0;
  padding: 0;
  border-radius: var(--r-input);
  background: var(--surface-2);
  overflow: hidden;
}

.s-me__cap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 40px;
  padding: var(--sp-2) var(--sp-4);
}

.s-me__cap + .s-me__cap {
  border-top: 1px solid var(--divider);
}

.s-me__cap-name {
  min-width: 0;
  font-size: var(--fs-callout);
  line-height: var(--lh-callout);
  color: var(--text);
}

.s-me__cap-status {
  flex: none;
  font-size: var(--fs-footnote);
  line-height: var(--lh-footnote);
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-3);
}

.s-me__cap.is-verified .s-me__cap-status {
  color: var(--down);
}

.s-me__cap.is-notVerified .s-me__cap-status {
  color: var(--text-2);
  font-weight: 500;
}

.s-me__cap.is-unsupported .s-me__cap-name {
  color: var(--text-2);
}

.s-me__cap.is-unsupported .s-me__cap-status {
  color: var(--text-3);
  font-weight: 500;
}

/* ---------- 滑鼠 hover ---------- */
@media (hover: hover) and (pointer: fine) {
  .s-me__row:hover {
    background: var(--surface-2);
  }

  .s-me__radio:not(.is-selected):hover {
    border-color: var(--text-3);
    background: var(--surface-2);
  }

  .s-me__details > summary:hover {
    background: var(--primary-tint);
  }
}

/* ---------- 觸控與滑鼠的點擊區 ---------- */
@media (pointer: coarse) {
  .s-me__row {
    min-height: var(--tap);
  }

  .s-me__radio {
    min-height: 64px;
  }
}

@media (pointer: fine) {
  .s-me__radio {
    min-height: 60px;
  }
}

/* ---------- 矮螢幕（手機橫式） ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  .s-me__radio {
    min-height: 52px;
    padding-block: var(--sp-2);
  }

  .s-more-grid {
    gap: var(--sp-2);
  }
}

/* ---------- 減少動態 ---------- */
@media (prefers-reduced-motion: reduce) {
  .s-me__row,
  .s-me__radio,
  .s-me__radio-check,
  .s-me__details > summary::after {
    transition-duration: 0.01ms !important;
  }

  .s-me__radio:active {
    transform: none;
  }
}
