/*
 * PREMIUM UI PHASE 11
 * 全站試營運前可用性、無障礙與互動狀態收尾。
 */

:root {
  --phase11-focus: #f97316;
  --phase11-focus-soft: rgba(249, 115, 22, 0.24);
  --phase11-danger: #dc2626;
  --phase11-muted: #64748b;
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  min-width: 0;
  overflow-x: clip;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
}

button,
a,
input,
select,
textarea,
[tabindex] {
  -webkit-tap-highlight-color: transparent;
}

button,
[role="button"],
a.btn,
a[class*="button"] {
  touch-action: manipulation;
}

:where(
  button,
  a,
  input,
  select,
  textarea,
  summary,
  [role="button"],
  [role="radio"],
  [role="tab"],
  [tabindex]
):focus-visible {
  outline: 3px solid var(--phase11-focus) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 5px var(--phase11-focus-soft) !important;
}

:where(input, select, textarea).is-invalid,
:where(input, select, textarea)[aria-invalid="true"] {
  border-color: var(--phase11-danger) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14) !important;
}

.phase11-field-error {
  margin-top: 6px;
  color: #b91c1c;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.45;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
[aria-disabled="true"] {
  cursor: not-allowed !important;
  filter: grayscale(0.12);
  opacity: 0.58 !important;
}

button.phase11-processing,
[role="button"].phase11-processing {
  cursor: wait !important;
  pointer-events: none;
  position: relative;
}

button.phase11-processing::after,
[role="button"].phase11-processing::after {
  width: 14px;
  height: 14px;
  margin-left: 8px;
  display: inline-block;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  content: "";
  animation: phase11-spin 0.72s linear infinite;
}

@keyframes phase11-spin {
  to { transform: rotate(360deg); }
}

.phase11-live-region {
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  position: fixed !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.phase11-empty-state,
.empty-state,
[class*="empty-state"] {
  text-align: center;
}

[aria-busy="true"] {
  cursor: wait;
}

/* 彈窗與抽屜在小螢幕上不得超出可視範圍。 */
:where(.modal, .modal-card, .drawer, .drawer-panel, .tutorial-card) {
  max-width: calc(100vw - 24px);
}

/* 管理員客服對話不再產生第二條小捲軸，由整個彈窗負責。 */
body.admin-premium-page #supportTicketModal {
  align-items: flex-start;
  overflow-y: auto;
  overscroll-behavior: contain;
}

body.admin-premium-page #supportTicketModal .admin-support-modal {
  max-height: none !important;
  margin-block: 16px;
  overflow: visible !important;
}

body.admin-premium-page #adminSupportMessages {
  max-height: none !important;
  overflow: visible !important;
  overscroll-behavior: auto !important;
}

/* 註冊身分卡與身分選擇卡補齊鍵盤狀態。 */
.role-btn[role="radio"],
.role-card[role="radio"],
.role-option[role="radio"] {
  cursor: pointer;
}

.role-btn[aria-checked="true"],
.role-card[aria-checked="true"],
.role-option[aria-checked="true"] {
  box-shadow: 0 0 0 3px var(--phase11-focus-soft);
}

/* 手機操作範圍與單欄穩定性。 */
@media (max-width: 700px) {
  :where(
    button:not(.password-toggle):not(.modal-close):not(.customer-announcement-close),
    a.btn,
    a.btn-header,
    [role="button"]
  ) {
    min-height: 44px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .modal-overlay,
  [class*="modal-overlay"] {
    padding: 12px !important;
  }

  table {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
