/* ============================================================
 *  SHOJIKI Contact Form  ―  Apple-style design
 *  lp-apple-style.html と統一されたデザイントークン
 * ============================================================ */

.shojiki-contact {
  --shj-bg: #f6f4ef;
  --shj-ink: #111111;
  --shj-paper: #ffffff;
  --shj-muted: rgba(17, 17, 17, 0.56);
  --shj-line: rgba(17, 17, 17, 0.18);
  --shj-line-strong: rgba(17, 17, 17, 0.42);
  --shj-radius: 14px;
  --shj-radius-pill: 999px;
  --shj-shadow-hover: 0 12px 28px -12px rgba(0, 0, 0, 0.5);
  font-family: 'Inter', 'Noto Sans JP', 'Hiragino Sans', system-ui, -apple-system, sans-serif;
  color: var(--shj-ink);
  letter-spacing: 0.01em;
}

.shojiki-contact img {
  max-width: 100%;
}

.shojiki-contact-form {
  max-width: 640px;
  margin-inline: auto;
}

/* ============================================================
 *  Dawn の疑似要素枠を完全に無効化（二重枠の元凶）
 * ============================================================ */
.shojiki-contact .field::before,
.shojiki-contact .field::after,
.shojiki-contact .select::before,
.shojiki-contact .select::after,
.shojiki-contact .text-area::before,
.shojiki-contact .text-area::after {
  display: none !important;
  content: none !important;
  box-shadow: none !important;
  border: 0 !important;
}

/* ============================================================
 *  フィールド共通（フローティングラベル）
 * ============================================================ */
.shojiki-contact .field {
  position: relative;
  margin-bottom: 1.25rem;
  display: block;
}

@media screen and (min-width: 750px) {
  .shojiki-contact .field {
    margin-bottom: 1.5rem;
  }
}

.shojiki-contact .field__input,
.shojiki-contact .text-area {
  width: 100%;
  height: auto !important;
  min-height: 64px !important;
  padding: 26px 18px 10px !important;
  margin: 0 !important;
  background: var(--shj-paper) !important;
  border: 1px solid var(--shj-line) !important;
  border-radius: var(--shj-radius) !important;
  font-family: inherit !important;
  font-size: 16px !important;
  font-weight: 400;
  line-height: 1.5;
  color: var(--shj-ink) !important;
  letter-spacing: 0.01em;
  box-shadow: none !important;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  -webkit-appearance: none;
  appearance: none;
}

.shojiki-contact .text-area {
  min-height: 180px !important;
  resize: vertical;
  line-height: 1.7;
  padding-top: 32px !important;
}

.shojiki-contact .field__input:hover,
.shojiki-contact .text-area:hover {
  border-color: var(--shj-line-strong) !important;
}

.shojiki-contact .field__input:focus,
.shojiki-contact .text-area:focus {
  outline: none !important;
  border-color: var(--shj-ink) !important;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08) !important;
}

/* プレースホルダーは常に透明（フローティングラベルが見出しを担当） */
.shojiki-contact .field__input::placeholder,
.shojiki-contact .text-area::placeholder {
  color: transparent !important;
  transition: color 0.18s ease;
}

.shojiki-contact .field__input:focus::placeholder,
.shojiki-contact .text-area:focus::placeholder {
  color: rgba(17, 17, 17, 0.32) !important;
}

/* ============================================================
 *  フローティングラベル
 *  - 通常状態は中央付近で 16px
 *  - 入力 or focus で上に上がって 14px
 * ============================================================ */
.shojiki-contact .field__label {
  position: absolute;
  top: 22px !important;
  left: 18px !important;
  font-family: inherit;
  font-size: 16px !important;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--shj-muted);
  pointer-events: none;
  transform-origin: left top;
  transition: top 0.18s ease, font-size 0.18s ease, color 0.18s ease;
  background: transparent;
  margin: 0;
}

/* テキスト入力 / textarea: 値があるか focus で上に */
.shojiki-contact input.field__input:focus ~ .field__label,
.shojiki-contact input.field__input:not(:placeholder-shown) ~ .field__label,
.shojiki-contact textarea.field__input:focus ~ .field__label,
.shojiki-contact textarea.field__input:not(:placeholder-shown) ~ .field__label,
.shojiki-contact .text-area:focus ~ .field__label,
.shojiki-contact .text-area:not(:placeholder-shown) ~ .field__label {
  top: 8px !important;
  font-size: 12px !important;
  color: var(--shj-muted);
}

.shojiki-contact input.field__input:focus ~ .field__label,
.shojiki-contact textarea.field__input:focus ~ .field__label,
.shojiki-contact .text-area:focus ~ .field__label {
  color: var(--shj-ink);
}

/* ============================================================
 *  セレクト（プルダウン）
 *  - select は :placeholder-shown が常に false なので
 *    Dawn のフローティング規則を打ち消し、is-filled / focus でだけ浮かす
 * ============================================================ */
.shojiki-contact .shojiki-field--select {
  position: relative;
}

.shojiki-contact .shojiki-select {
  cursor: pointer;
  padding-right: 52px !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='10' viewBox='0 0 14 10' fill='none'><path d='M1 1.5L7 7.5L13 1.5' stroke='%23111' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>") !important;
  background-repeat: no-repeat !important;
  background-position: right 22px center !important;
  background-size: 14px 10px !important;
}

.shojiki-contact .shojiki-select::-ms-expand {
  display: none;
}

/* select は :placeholder-shown が無いため、Dawn の自動フローティングを上書きで無効化 */
.shojiki-contact select.field__input:not(:placeholder-shown) ~ .field__label,
.shojiki-contact select.shojiki-select:not(:placeholder-shown) ~ .field__label {
  top: 22px !important;
  font-size: 16px !important;
  color: var(--shj-muted) !important;
}

/* select 専用のフロート条件: focus または値が入ったとき (is-filled) のみ */
.shojiki-contact select.shojiki-select:focus ~ .field__label,
.shojiki-contact select.shojiki-select.is-filled ~ .field__label {
  top: 8px !important;
  font-size: 12px !important;
  color: var(--shj-muted) !important;
}

.shojiki-contact select.shojiki-select:focus ~ .field__label {
  color: var(--shj-ink) !important;
}

/* 未選択 select の文字色（disabled 初期値の透明）*/
.shojiki-contact .shojiki-select:invalid {
  color: transparent;
}
.shojiki-contact .shojiki-select:focus:invalid,
.shojiki-contact .shojiki-select.is-filled,
.shojiki-contact .shojiki-select:not(:invalid) {
  color: var(--shj-ink) !important;
}

/* 「その他」自由記述欄のフェードイン */
.shojiki-contact .shojiki-other-field {
  animation: shj-fade-down 0.28s ease both;
}

@keyframes shj-fade-down {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.shojiki-contact .shojiki-other-field[hidden] {
  display: none;
}

/* ============================================================
 *  PCグリッド（名前・メールを横並び）
 * ============================================================ */
@media screen and (min-width: 750px) {
  .shojiki-contact .contact__fields {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-column-gap: 1.5rem;
  }
}

/* ============================================================
 *  ファイルアップローダー
 * ============================================================ */
.shojiki-contact .shojiki-uploader {
  margin: 1.75rem 0;
  padding: 24px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px dashed var(--shj-line-strong);
  border-radius: var(--shj-radius);
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.shojiki-contact .shojiki-uploader:hover {
  border-color: var(--shj-ink);
  background: var(--shj-paper);
}

.shojiki-contact .shojiki-uploader__head {
  margin-bottom: 16px;
}

.shojiki-contact .shojiki-uploader__title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 500;
  color: var(--shj-ink);
}

.shojiki-contact .shojiki-uploader__hint {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--shj-muted);
}

.shojiki-contact .shojiki-uploader__button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
  background: var(--shj-paper);
  color: var(--shj-ink);
  border: 1px solid var(--shj-ink);
  border-radius: var(--shj-radius-pill);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.shojiki-contact .shojiki-uploader__button:hover {
  background: var(--shj-ink);
  color: var(--shj-paper);
  transform: translateY(-1px);
  box-shadow: var(--shj-shadow-hover);
}

.shojiki-contact .shojiki-uploader__list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

.shojiki-contact .shojiki-uploader__list:empty {
  display: none;
}

.shojiki-contact .shojiki-uploader__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  margin-top: 8px;
  background: var(--shj-paper);
  border: 1px solid var(--shj-line);
  border-radius: 10px;
  font-size: 14px;
}

.shojiki-contact .shojiki-uploader__item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--shj-ink);
}

.shojiki-contact .shojiki-uploader__item-status {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--shj-muted);
}

.shojiki-contact .shojiki-uploader__item.is-success {
  border-color: rgba(0, 128, 64, 0.32);
  background: rgba(0, 128, 64, 0.04);
}

.shojiki-contact .shojiki-uploader__item.is-success .shojiki-uploader__item-status a {
  color: rgb(0, 102, 51);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.shojiki-contact .shojiki-uploader__item.is-error {
  border-color: rgba(180, 0, 0, 0.32);
  background: rgba(180, 0, 0, 0.04);
}

.shojiki-contact .shojiki-uploader__item.is-error .shojiki-uploader__item-status {
  color: rgb(150, 0, 0);
}

/* ============================================================
 *  送信ボタン
 * ============================================================ */
.shojiki-contact .contact__button {
  margin-top: 2.5rem;
  text-align: center;
}

@media screen and (min-width: 750px) {
  .shojiki-contact .contact__button {
    margin-top: 3rem;
  }
}

.shojiki-contact .shojiki-contact-form__submit,
.shojiki-contact .contact__button .button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 240px;
  min-height: 56px;
  padding: 18px 48px;
  background: var(--shj-ink);
  color: var(--shj-paper);
  border: none;
  border-radius: var(--shj-radius-pill);
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 4px 12px -6px rgba(0, 0, 0, 0.4);
}

.shojiki-contact .shojiki-contact-form__submit::before,
.shojiki-contact .shojiki-contact-form__submit::after,
.shojiki-contact .contact__button .button::before,
.shojiki-contact .contact__button .button::after {
  display: none !important;
  content: none !important;
}

.shojiki-contact .shojiki-contact-form__submit:hover,
.shojiki-contact .contact__button .button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shj-shadow-hover);
}

.shojiki-contact .shojiki-contact-form__submit:active {
  transform: translateY(0);
}

.shojiki-contact .shojiki-contact-form__submit:disabled,
.shojiki-contact .shojiki-contact-form__submit.is-loading {
  opacity: 0.7;
  cursor: progress;
  pointer-events: none;
}

.shojiki-contact .shojiki-contact-form__submit.is-loading .shojiki-contact-form__submit-label::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 10px;
  vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--shj-paper);
  border-radius: 50%;
  animation: shj-spin 0.6s linear infinite;
}

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

.shojiki-contact-form__legal {
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--shj-muted);
  line-height: 1.7;
}

.shojiki-contact-form__legal a {
  color: var(--shj-ink);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

/* ============================================================
 *  完了ステート（シームレス切替）
 * ============================================================ */
.shojiki-contact-form__success {
  text-align: center;
  padding: clamp(48px, 10vw, 96px) 24px;
  animation: shj-fade-up 0.6s ease both;
  outline: none;
}

@keyframes shj-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.shojiki-contact-form__success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 24px;
  background: var(--shj-ink);
  color: var(--shj-paper);
  border-radius: 50%;
  animation: shj-pop 0.5s 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.shojiki-contact-form__success-icon svg {
  width: 28px;
  height: 28px;
  fill: var(--shj-paper);
}

@keyframes shj-pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.shojiki-contact-form__success-title {
  margin: 0 0 16px;
  font-size: clamp(22px, 3.6vw, 28px);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--shj-ink);
}

.shojiki-contact-form__success-text {
  margin: 0 0 32px;
  font-size: 15px;
  line-height: 1.85;
  color: var(--shj-muted);
}

.shojiki-contact-form__success-link {
  display: inline-block;
  padding: 14px 36px;
  background: var(--shj-paper);
  color: var(--shj-ink);
  border: 1px solid var(--shj-ink);
  border-radius: var(--shj-radius-pill);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.shojiki-contact-form__success-link:hover {
  background: var(--shj-ink);
  color: var(--shj-paper);
  transform: translateY(-2px);
  box-shadow: var(--shj-shadow-hover);
}

/* ============================================================
 *  honeypot（完全非表示）
 * ============================================================ */
.shojiki-honeypot {
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ============================================================
 *  エラーメッセージ
 * ============================================================ */
.shojiki-contact .form__message {
  align-items: flex-start;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: rgba(180, 0, 0, 0.04);
  border-radius: var(--shj-radius);
  font-size: 14px;
}

.shojiki-contact .icon-success {
  margin-top: 0.2rem;
}

.shojiki-contact .contact__field-error {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: rgb(150, 0, 0);
}

/* ============================================================
 *  モバイル
 * ============================================================ */
@media screen and (max-width: 749px) {
  .shojiki-contact-form {
    padding-inline: 4px;
  }

  .shojiki-contact .shojiki-contact-form__submit,
  .shojiki-contact .contact__button .button {
    width: 100%;
    min-width: 0;
    padding: 18px 32px;
  }

  .shojiki-contact .shojiki-uploader {
    padding: 20px 18px;
  }
}

/* prefers-reduced-motion 対応 */
@media (prefers-reduced-motion: reduce) {
  .shojiki-contact *,
  .shojiki-contact *::before,
  .shojiki-contact *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
