/* 基礎：重設、字、色場、版框、按鈕、表單欄位、出場動態 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--mist);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-dark);
  font-family: var(--font);
  font-size: var(--step-body);
  line-height: 1.6;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

h1,
h2,
h3,
p,
ol,
ul,
dl,
dd,
figure,
fieldset,
blockquote {
  margin: 0;
  padding: 0;
}

ol,
ul {
  list-style: none;
}

h1,
h2,
h3 {
  font-weight: 600;
  text-wrap: balance;
  hyphens: none;
}

p {
  text-wrap: pretty;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

table {
  border-collapse: collapse;
}

::selection {
  background: var(--accent, var(--blue));
  color: var(--accent-ink, #fff);
}

:focus-visible {
  outline: 2px solid var(--focus, var(--blue));
  outline-offset: 3px;
}

/* 色場 */
.field-mist,
.field-paper,
.field-char {
  background: var(--bg);
  color: var(--ink);
}

/* 版框：一組左右邊界，12 欄 */
.frame {
  width: 100%;
  max-width: 1600px;
  margin-inline: auto;
  padding-inline: max(var(--margin), env(safe-area-inset-left, 0px)) max(var(--margin), env(safe-area-inset-right, 0px));
}

/* 字 */
.statement {
  font-size: var(--step-statement);
  line-height: 1.4;
  letter-spacing: -0.005em;
  font-weight: 400;
}

.head {
  font-size: var(--step-head);
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.display {
  font-size: var(--step-display);
  line-height: 1.04;
  letter-spacing: -0.03em;
  font-weight: 600;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--margin);
  top: -80px;
  z-index: 200;
  padding: 12px 18px;
  background: #fff;
  color: var(--blue-text);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

/* 連結與按鈕 */
.link {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.2em;
  transition: text-decoration-color var(--t-hover) ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 26px;
  border: 0;
  border-radius: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--step-body);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-hover) ease;
}

.button:active {
  transform: scale(0.97);
}

.button--small {
  min-height: 44px;
  padding: 0 18px;
  font-size: var(--step-small);
}

.button--light {
  background: var(--accent);
  color: var(--accent-ink);
}

.button--block {
  width: 100%;
}

.text-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.22em;
}

.text-button:disabled {
  color: var(--soft);
  text-decoration: none;
  cursor: default;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
}

@media (hover: hover) and (pointer: fine) {
  .button:hover {
    background: #0077ed;
  }

  .button--light:hover {
    background: #0077ed;
  }

  .text-button:not(:disabled):hover,
  .link:hover {
    text-decoration-thickness: 0.12em;
  }
}

/* 表單欄位：以底色區分，不畫框線 */
.field {
  display: grid;
  gap: 8px;
}

.field label,
.field__label {
  font-weight: 500;
  line-height: 1.4;
}

.field input:not([type="radio"]),
.field select,
.field textarea {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font-size: max(16px, 1em);
  line-height: 1.4;
  transition: border-color var(--t-hover) ease;
}

.field textarea {
  min-height: 112px;
  resize: vertical;
}

.field select {
  appearance: none;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23888' stroke-width='2'/%3E%3C/svg%3E");
  background-position: calc(100% - 16px) 50%;
  background-size: 12px 8px;
  background-repeat: no-repeat;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

.field [aria-invalid="true"] {
  border-bottom-color: var(--accent);
}

.field__help {
  font-size: var(--step-small);
  color: var(--soft);
}

.field__error {
  font-size: var(--step-small);
  font-weight: 600;
  color: var(--ink);
}

.field__error::before {
  content: "！ ";
  color: var(--accent);
}

.req {
  margin-left: 6px;
  font-size: var(--step-small);
  font-weight: 500;
  color: var(--soft);
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio {
  position: relative;
  display: inline-flex;
}

.radio input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.radio span {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 20px;
  background: var(--surface);
  font-weight: 500;
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease;
}

.radio input:checked + span {
  background: var(--ink);
  color: var(--bg);
}

.radio input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* 提示訊息 */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  z-index: var(--z-toast);
  transform: translateX(-50%);
  padding: 14px 22px;
  background: var(--ink-dark);
  color: var(--paper);
  font-weight: 500;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.2); /* taste-skill-ignore：提示訊息浮在內容上 */
}

/* 出場：只在 JS 有載入、且使用者沒有要求減少動態時才先藏起來 */
@media (prefers-reduced-motion: no-preference) {
  .js [data-reveal] {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 700ms var(--ease-out), transform 900ms var(--ease-expo);
    transition-delay: calc(var(--i, 0) * var(--stagger-item));
  }

  .js [data-reveal].is-in {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
