/* ==========================================================================
   Perfect Line — Customer Intake (kiosk)
   Light, refined PMU aesthetic. Tablet/iPad optimized — large touch targets,
   serif display + clean sans body, gentle gold accent.
   ========================================================================== */

:root {
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --ink: #1A1A1A;
  --muted: #6B6B6B;
  --hairline: rgba(26, 26, 26, 0.08);
  --accent: #C9A961;
  --accent-soft: rgba(201, 169, 97, 0.12);
  --danger: #B23A3A;
  --success: #4F7A4F;

  --font-display: "DM Serif Display", "Noto Serif KR", Georgia, serif;
  --font-sans: "Outfit", "Noto Sans KR", system-ui, sans-serif;

  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 20px;
  --r-xl: 28px;

  --shadow-soft: 0 1px 2px rgba(26, 26, 26, 0.04), 0 8px 32px rgba(26, 26, 26, 0.06);
  --shadow-pop: 0 2px 4px rgba(26, 26, 26, 0.06), 0 12px 40px rgba(26, 26, 26, 0.10);

  --tap: 56px; /* min tap target */
  --max-w: 920px;
}

/* Korean word break: never split mid-syllable (HV rule) */
:root[lang="ko"], html[data-lang="ko"], [data-lang="ko"] {
  word-break: keep-all;
  line-break: strict;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 17px; /* >=16px prevents iOS input zoom */
  line-height: 1.5;
}

body.kiosk-mode {
  min-height: 100dvh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

input, textarea, [contenteditable] { user-select: text; -webkit-user-select: text; }

/* ============= Topbar ============= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  background: rgba(250, 247, 242, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--hairline);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand__mark {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 0.16em;
  color: var(--ink);
}
.brand__text { display: flex; flex-direction: column; line-height: 1; }
.brand__name {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.32em;
  color: var(--ink);
}
.brand__sub {
  font-size: 9.5px;
  letter-spacing: 0.36em;
  color: var(--muted);
  margin-top: 4px;
}

.topbar__right { display: flex; align-items: center; gap: 16px; }
.step-indicator {
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ============= Stage / panels ============= */
.stage {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 36px 28px 60px;
}

.stage__panel { animation: fadeIn 240ms ease-out both; }
.stage__panel[hidden] { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.stage__panel--center {
  min-height: calc(100dvh - 220px);
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translate3d(0, 12px, 0); }
  to { opacity: 1; transform: none; }
}

/* ============= Typography ============= */
.display {
  font-family: var(--font-display);
  font-size: clamp(34px, 5.2vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  color: var(--ink);
}

.lede {
  font-size: 19px;
  color: var(--muted);
  margin: 0 0 36px;
  line-height: 1.5;
  max-width: 64ch;
}

.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ============= Service picker ============= */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.service-card {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  text-align: left;
  cursor: pointer;
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1),
              border-color 200ms;
  font-family: inherit;
  color: inherit;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.service-card:hover, .service-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop);
  border-color: var(--accent);
  outline: none;
}
.service-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  font-size: 20px;
}
.service-card__title {
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.15;
  color: var(--ink);
}
.service-card__sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

/* ============= Form ============= */
.form-header { margin-bottom: 28px; }
.form-header .display { font-size: clamp(28px, 4vw, 40px); }
.form-header .muted { font-size: 16px; margin-top: 4px; }

.step {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-soft);
}

.field {
  margin-bottom: 22px;
}
.field:last-child { margin-bottom: 0; }

.field__label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.field__label .req { color: var(--danger); margin-left: 4px; }

.field__hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

.input,
.textarea,
.select {
  appearance: none;
  width: 100%;
  font-family: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 14px 16px;
  min-height: var(--tap);
  transition: border-color 160ms, box-shadow 160ms;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }

/* ============= Choices (radio/checkbox tiles) ============= */
.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  min-height: var(--tap);
  font-size: 16px;
  transition: border-color 160ms, background-color 160ms;
}
.choice:hover { border-color: var(--accent); }
.choice input[type="radio"],
.choice input[type="checkbox"] {
  appearance: none;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--hairline);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  transition: border-color 160ms, background-color 160ms;
}
.choice input[type="checkbox"] { border-radius: 6px; }
.choice input:checked {
  border-color: var(--accent);
  background: var(--accent);
}
.choice input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--surface);
}
.choice input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 3px; left: 7px;
  width: 5px; height: 10px;
  border: solid var(--surface);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Yes/No two-button variant */
.yesno {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 320px;
}

/* ============= Health checklist row ============= */
.hq-list { display: flex; flex-direction: column; gap: 14px; }
.hq-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--hairline);
}
.hq-row:last-child { border-bottom: none; }
.hq-row__q { font-size: 16px; line-height: 1.45; }

/* ============= Initial-required statements ============= */
.consent-list { display: flex; flex-direction: column; gap: 12px; }
.consent-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms, background-color 160ms;
}
.consent-row:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.consent-row input[type="checkbox"] {
  appearance: none;
  width: 24px; height: 24px;
  border: 1.5px solid var(--hairline);
  border-radius: 6px;
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
}
.consent-row input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent);
}
.consent-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 4px; left: 8px;
  width: 6px; height: 11px;
  border: solid var(--surface);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.consent-row__text { font-size: 15px; line-height: 1.5; }

/* ============= Long consent paragraph ============= */
.consent-para {
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 20px 22px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-line;
  margin-bottom: 22px;
}

/* ============= Signature pad ============= */
.signature-wrap {
  border: 1.5px dashed var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.signature-wrap.is-signed { border-style: solid; border-color: var(--accent); }
.signature-canvas {
  display: block;
  width: 100%;
  height: 220px;
  background: var(--surface);
  touch-action: none;
}
.signature-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid var(--hairline);
  background: var(--bg);
}

/* ============= Buttons ============= */
.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0 28px;
  min-height: var(--tap);
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 120ms, box-shadow 160ms, background-color 160ms;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--ink);
  color: var(--surface);
}
.btn--primary:hover { background: #2a2a2a; }
.btn--primary:disabled {
  background: rgba(26, 26, 26, 0.2);
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--hairline);
}
.btn--ghost:hover { border-color: var(--ink); }

.btn--accent {
  background: var(--accent);
  color: var(--surface);
}

.btn--sm {
  min-height: 40px;
  padding: 0 16px;
  font-size: 14px;
}

/* ============= Step nav (sticky bottom) ============= */
.step-nav {
  margin-top: 32px;
  padding: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.step-nav .btn--primary { min-width: 180px; }

/* ============= Thank you / spinner ============= */
.thanks { text-align: center; max-width: 480px; }
.thanks__check {
  color: var(--accent);
  margin-bottom: 24px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--hairline);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
  margin: 0 auto 24px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============= Footer ============= */
.footer {
  position: fixed;
  bottom: 88px; /* above step-nav */
  left: 0; right: 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0.6;
}

body[data-stage="picker"] .footer,
body[data-stage="thanks"] .footer,
body[data-stage="submitting"] .footer,
body[data-stage="error"] .footer {
  bottom: 24px;
}

body[data-stage="picker"] .step-nav,
body[data-stage="thanks"] .step-nav,
body[data-stage="submitting"] .step-nav,
body[data-stage="error"] .step-nav {
  display: none;
}

body[data-stage="form"] .footer { display: none; }

/* ============= Responsive (iPad portrait + landscape) ============= */
@media (max-width: 768px) {
  .topbar { padding: 14px 18px; }
  .stage { padding: 24px 18px 60px; }
  .step { padding: 24px 18px; }
  .display { font-size: clamp(28px, 7vw, 38px); }
  .step-nav .btn--primary { min-width: 140px; }
  .footer { font-size: 10px; }
}

/* ============= Validation ============= */
.field--error .input,
.field--error .textarea,
.field--error .select { border-color: var(--danger); }
.error-text { color: var(--danger); font-size: 13px; margin-top: 6px; }
