@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@100..900&display=swap');
@import './tokens.css';

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/inter/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'FC Iconic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/fc-iconic/FCIconic-Regular.otf') format('opentype');
  unicode-range: U+0E00-0E7F;
}

@font-face {
  font-family: 'FC Iconic';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/fc-iconic/FCIconic-Medium.otf') format('opentype');
  unicode-range: U+0E00-0E7F;
}

@font-face {
  font-family: 'FC Iconic';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/fc-iconic/FCIconic-Bold.otf') format('opentype');
  unicode-range: U+0E00-0E7F;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--color-white);
  font-family: var(--font-family-base);
  font-size: var(--font-size-body-md);
  line-height: var(--line-height-body-md);
  font-weight: var(--font-weight-medium);
  color: var(--color-neutral-900);
}

/* ── Layout ── */
.wrap { display: grid; place-items: start center; min-height: 100dvh; }

.card { width: 100%; background: var(--color-white); border-radius: var(--radius-16); }

/* ── Header ── */
.card-hd {
  padding: 0;
  border-bottom: 1px solid var(--color-neutral-300);
  display: flex;
  gap: var(--space-12);
  height: var(--space-64);
  justify-content: center;
  align-items: center;
  position: fixed;
  width: 100%;
  background: var(--color-white);
  z-index: 10;
}

.brand img { height: 28px; }

.card-hd .brand {
  display: flex;
  align-items: center;
}

/* ── Progress bar ── */
.progress {
  padding: 18px var(--space-24) 0;
  max-width: 500px;
  margin: auto;
  padding-top: 90px;
  display: flex;
  align-items: center;
  gap: var(--space-16);
  margin-bottom: 0;
  transition: padding-top 0.3s ease;
}

.has-error .progress { padding-top: 170px; }

.bar {
  display: flex;
  gap: 0;
  width: 100%;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.bar-seg {
  flex: 1;
  height: var(--space-4);
  background: var(--color-primary-500-10-on-white);
}

.bar-seg.is-filled {
  background: var(--color-primary-500);
}

.step {
  font-size: var(--font-size-body-sm);
  color: var(--color-neutral-700);
  text-align: right;
  width: max-content;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Form body ── */
.body { padding: var(--space-8) var(--space-24) var(--space-24); max-width: 500px; margin: auto; padding-bottom: 80px; }

.upload-field-label {
  font-size: var(--font-size-body-md);
  line-height: var(--line-height-body-md);
  color: var(--color-neutral-800);
  font-weight: 600;
  margin: 0;
}

.doc-examples-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-primary-500);
  font-size: var(--font-size-body-sm);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-family-base);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Document mock illustrations ── */
.doc-examples-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-12); }
.doc-mock-cert {
  aspect-ratio: 3 / 4;
  background: #fff;
  border: 1px solid var(--color-neutral-300);
  border-radius: var(--radius-8);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow: hidden;
}
.doc-mock-boj5 {
  aspect-ratio: 3 / 4;
  background: #fff;
  border: 1px solid var(--color-neutral-300);
  border-radius: var(--radius-8);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}
.cert-emblem { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--color-neutral-300); margin: 0 auto 4px; display: flex; align-items: center; justify-content: center; }
.cert-emblem-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-neutral-300); }
.cert-row { height: 3px; background: var(--color-neutral-300); border-radius: 2px; }
.cert-row.w100 { width: 100%; } .cert-row.w80 { width: 80%; } .cert-row.w65 { width: 65%; } .cert-row.w50 { width: 50%; }
.cert-divider { height: 1px; background: var(--color-neutral-300); margin: 2px 0; }
.cert-sig { height: 12px; width: 55%; border-bottom: 1.5px solid var(--color-neutral-400); margin-top: auto; }
.boj5-header { display: flex; flex-direction: column; gap: 4px; border-bottom: 1px solid var(--color-neutral-300); padding-bottom: 6px; }
.boj5-table { display: flex; flex-direction: column; gap: 4px; flex: 1; margin-top: 4px; }
.boj5-row { display: flex; gap: 4px; align-items: center; border-bottom: 1px dotted var(--color-neutral-300); padding-bottom: 4px; }
.boj5-cell { height: 4px; background: var(--color-neutral-300); border-radius: 2px; }
.boj5-cell.w20 { width: 20%; } .boj5-cell.w25 { width: 25%; } .boj5-cell.w30 { width: 30%; }
.boj5-cell.w55 { width: 55%; } .boj5-cell.w60 { width: 60%; } .boj5-cell.w65 { width: 65%; } .boj5-cell.w70 { width: 70%; }
.doc-img-desc { font-size: var(--font-size-body-xs); color: var(--color-neutral-500); margin: var(--space-4) 0 0; text-align: center; }

h2 {
  font-size: var(--font-size-h5);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-h5);
  text-align: center;
  margin: var(--space-8) 0 var(--space-32);
}

.step-subtitle {
  font-size: var(--font-size-body-md);
  line-height: var(--line-height-body-md);
  color: var(--color-neutral-700);
  text-align: center;
  margin: calc(-1 * var(--space-24)) 0 var(--space-32);
}

/* ── Field group ── */
.group { display: grid; gap: 6px; margin: var(--space-24) 0; }
.group[hidden] { display: none; }

label {
  font-size: var(--font-size-body-md);
  line-height: var(--line-height-body-md);
  color: var(--color-neutral-800);
  font-weight: 600;
}

.req { color: var(--color-error-500); }

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-8);
}

.field-counter {
  font-size: var(--font-size-body-sm);
  line-height: var(--line-height-body-sm);
  color: var(--color-neutral-500);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
}

.field-counter.is-over { color: var(--color-error-500); }

.field-desc {
  font-size: var(--font-size-body-sm);
  line-height: var(--line-height-body-sm);
  color: var(--color-neutral-500);
  margin: 0;
}

/* ── Input / Textarea ── */
.inp {
  width: 100%;
  padding: var(--space-12) var(--space-16);
  border: 1.5px solid var(--color-neutral-300);
  border-radius: var(--radius-8);
  background: var(--color-white);
  font-family: var(--font-family-base);
  font-size: var(--font-size-body-md);
  line-height: var(--line-height-body-md);
  font-weight: 400;
  color: var(--color-neutral-900);
  transition: border .18s, box-shadow .18s;
  box-sizing: border-box;
  resize: vertical;
}

input.inp {
  height: var(--control-height);
  padding: 0 var(--space-16);
}

.input-wrap { position: relative; display: flex; align-items: center; }

.inp.has-icon { padding-right: var(--space-48); }

.input-prefix {
  flex-shrink: 0;
  height: var(--control-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-12);
  background: var(--color-neutral-100);
  border: 1.5px solid var(--color-neutral-300);
  border-right: 0;
  border-radius: var(--radius-8) 0 0 var(--radius-8);
  font-size: var(--font-size-body-md);
  color: var(--color-neutral-900);
  white-space: nowrap;
  pointer-events: none;
  transition: border .18s;
}

.input-wrap:has(.inp.is-invalid) .input-prefix {
  border-color: var(--color-error-500);
}

.inp.has-prefix {
  border-radius: 0 var(--radius-8) var(--radius-8) 0;
  flex: 1;
  min-width: 0;
}

.callout {
  padding: var(--space-8) var(--space-12);
  border-radius: var(--radius-8);
  font-size: var(--font-size-body-sm);
  line-height: 1.55;
  margin-bottom: var(--space-24);
}

.callout--purple {
  background: #f3f0ff;
  border: 1.5px solid #c4b5fd;
  color: #3b1fa8;
}

.callout-list {
  margin: 0;
  padding-left: 18px;
}

.callout-list li + li {
  margin-top: 4px;
}

.field-icon {
  position: absolute;
  top: 50%;
  right: var(--space-16);
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--color-neutral-500);
  pointer-events: none;
}

.inp::placeholder { color: var(--color-neutral-500); }

.inp:hover { border-color: var(--color-primary-500); }

.inp:focus-visible { outline: 0; border-color: var(--color-primary-500); }

.inp.is-invalid { border-color: var(--color-error-500); }

.inp.is-invalid:focus-visible {
  outline: 2px solid var(--color-pink-500-40);
}

/* ── Inline error ── */
.error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  font-size: var(--font-size-body-sm);
  line-height: var(--line-height-body-sm);
  color: var(--color-error-500);
  margin-top: var(--space-4);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-4);
}

.error[hidden] { display: none; }

.error .dot {
  width: var(--space-16);
  height: var(--space-16);
  border-radius: var(--radius-pill);
  background: var(--color-error-500-20-on-white);
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 2px;
  flex: 0 0 var(--space-16);
}

/* ── Top error banner ── */
.top-alert {
  position: fixed;
  top: var(--space-64);
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--color-error-700);
  color: var(--color-white);
  font-weight: var(--font-weight-bold);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-8) var(--space-16);
  font-size: var(--font-size-body-md);
  font-family: var(--font-family-base);
}

.top-alert[hidden] { display: none; }

.top-alert .badge {
  background: var(--color-white);
  color: var(--color-error-700);
  border-radius: var(--radius-pill);
  min-width: var(--space-16);
  height: 19px;
  padding: 0 var(--space-8);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-weight: var(--font-weight-extrabold);
  margin-right: var(--space-4);
}

.top-alert .cta {
  background: var(--color-white);
  color: var(--color-error-700);
  border: 0;
  border-radius: var(--radius-4);
  padding: 0 var(--space-12);
  font-weight: var(--font-weight-extrabold);
  font-family: var(--font-family-base);
  cursor: pointer;
  width: max-content;
  white-space: nowrap;
  height: var(--space-40);
}

.top-alert .cta:focus-visible { outline: 3px solid var(--color-pink-500-40); }

/* ── Bottom actions ── */
.actions {
  display: flex;
  justify-content: space-between;
  gap: var(--space-8);
  border-top: 1px solid var(--color-neutral-300);
  padding: var(--space-16) var(--space-24);
  background: var(--color-white);
  position: fixed;
  bottom: 0;
  width: 100%;
  left: 0;
  z-index: 50;
}

.btn-wp { width: 500px; display: flex; justify-content: space-between; align-items: center; margin: auto; }

.btn {
  border: 0;
  border-radius: var(--radius-8);
  padding: var(--space-12) var(--space-16);
  font-family: var(--font-family-base);
  font-size: var(--font-size-body-md);
  font-weight: var(--font-weight-bold);
  text-align: center;
  cursor: pointer;
}

.btn.secondary { background: var(--color-white); color: var(--color-primary-700); }
.btn.primary   { background: var(--color-primary-500); color: var(--color-white); }

.btn:focus-visible { outline: 3px solid var(--color-blue-500-40); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Bottom sheet modal ── */
.bank-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  visibility: hidden;
  opacity: 0;
  transition: opacity .25s ease, visibility .25s ease;
}
.bank-modal.is-open { visibility: visible; opacity: 1; }
.bank-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.bank-modal-sheet {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--color-white);
  border-radius: var(--radius-16, 16px) var(--radius-16, 16px) 0 0;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32,.72,0,1);
}
.bank-modal.is-open .bank-modal-sheet { transform: translateY(0); }
.bank-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-16) var(--space-16) var(--space-12);
  flex-shrink: 0;
  border-bottom: 1px solid var(--color-neutral-300);
}
.bank-modal-title { font-size: var(--font-size-body-lg); font-weight: var(--font-weight-bold); color: var(--color-neutral-900); margin: 0; }
.bank-modal-close {
  background: none; border: none;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--color-neutral-500);
  border-radius: var(--radius-pill); flex-shrink: 0;
}
.bank-modal-close:hover { background: var(--color-neutral-100); color: var(--color-neutral-900); }
.bank-modal-list { overflow-y: auto; padding: var(--space-8) 0 var(--space-24); flex: 1; }
.bank-modal-item { padding: var(--space-12) var(--space-16); font-size: var(--font-size-body-md); color: var(--color-neutral-800); border-bottom: 1px solid var(--color-neutral-100, #f4f4f5); }
.bank-modal-item:last-child { border-bottom: none; }

/* ── FAB visibility toggle ── */
.fab-item { display: none !important; }
body.fabs-visible .fab-item { display: flex !important; }

.fab-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 202;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: rgba(42, 48, 73, 0.12);
  border: 0;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-neutral-700);
  transition: background .2s;
  opacity: 1;
}
.fab-toggle:hover { background: rgba(42, 48, 73, 0.25); }
body.fabs-visible .fab-toggle { background: rgba(42, 48, 73, 0.35); color: var(--color-neutral-900); }

/* ── Accessibility ── */
.visually-hidden {
  position: absolute !important;
  clip: rect(1px,1px,1px,1px);
  clip-path: inset(50%);
  height: 1px; width: 1px;
  overflow: hidden;
  white-space: nowrap;
  border: 0; padding: 0; margin: -1px;
}

/* ── Shake animation ── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(3px); }
}

.shake { animation: shake .38s ease both; }

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