/* ============================================================
   forms.css
   フォーム共通スタイル（select / input / textarea）
   .td-select-wrap / .td-select / .td-input / .td-textarea
   ============================================================ */


/* ── Select (dropdown) ──────────────────── */
.td-select-wrap {
  position: relative;
  display: inline-block;
  width: clamp(200px, 33vw, 480px);
}

.td-select {
  width: 100%;
  height: 64px;
  padding: 0 44px 0 20px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  background-color: var(--color-bg-white);
  background-image: url('/assets/images/common/icon/icon_arrow_down.svg');
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 11px 8px;
  font-family: var(--font-base);
  font-size: clamp(0.9375rem, 1.5vw, 1.1875rem);
  color: var(--color-text-sub);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.td-select:focus {
  outline: none;
  border: 2px solid var(--color-primary);
  color: var(--color-text-dark);
}


/* ── Input ──────────────────── */
.td-input {
  flex: 1;
  height: 64px;
  padding: 0 20px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  background: var(--color-bg-white);
  font-family: var(--font-base);
  font-size: clamp(0.9375rem, 1.5vw, 1.1875rem);
  font-weight: var(--font-regular);
  color: var(--color-text);
  width: 100%;
}

.td-input::placeholder {
  color: var(--color-text-sub);
  font-weight: var(--font-light);
}

.td-input:focus {
  outline: none;
  border: 2px solid var(--color-primary);
}


/* ── Textarea ──────────────────── */
.td-textarea {
  width: 100%;
  min-height: 196px;
  padding: 16px 20px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  background: var(--color-bg-white);
  font-family: var(--font-base);
  font-size: clamp(0.9375rem, 1.5vw, 1.1875rem);
  color: var(--color-text);
  resize: vertical;
  align-self: flex-start;
}

.td-textarea::placeholder {
  color: var(--color-text-sub);
  font-weight: var(--font-light);
}

.td-textarea:focus {
  outline: none;
  border: 2px solid var(--color-primary);
}


/* ── Form structure ──────────────────── */
.td-form {
  width: 100%;
}

.td-form__field {
  display: flex;
  gap: 10px;
  margin-bottom: var(--space-sm);
}

.td-required-label {
  font-size: 13px;
  color: var(--color-error);
  flex-shrink: 0;
  white-space: nowrap;
  width: 68px;
}

/* ラベルなしフィールドにも同量の右余白を確保 */
.td-form__field:not(:has(.td-required-label)) {
  padding-right: calc(68px + 10px);
}

.td-form__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-md);
}

.td-form__actions .wp-block-button__link.outline-btn {
  min-width: 200px;
}


/* ── Form Card ──────────────────── */
.td-form-card {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  padding: var(--space-lg) var(--space-xl) var(--space-xl);
}

.td-form-card:has(+ .td-form__actions) {
  margin-bottom: var(--space-lg);
}

* + .td-form-card {
  margin-top: var(--space-md);
}

.td-form-card .wp-block-separator {
  margin-top: var(--space-lg);
  margin-bottom: var(--space-lg);
}


/* ── Consent block (scrollable notice + agree checkbox) ──────────────────── */
.td-consent {
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: var(--space-lg) var(--space-lg);
  margin-top: var(--space-lg);
}

.td-consent__scroll {
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-light);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--font-light);
  color: var(--color-text);
  line-height: var(--leading-normal);
  scrollbar-color: var(--color-primary) var(--color-bg-light);
}

.td-consent__scroll::-webkit-scrollbar {
  width: 8px;
}

.td-consent__scroll::-webkit-scrollbar-track {
  background: var(--color-bg-light);
}

.td-consent__scroll::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: var(--radius-full);
}

.td-consent__scroll p {
  margin: 0 0 var(--space-sm);
}

.td-consent__scroll p:last-child {
  margin-bottom: 0;
}

.td-consent__subhead {
  color: var(--color-text-dark);
  font-weight: var(--font-regular);
  font-size: var(--text-md);
  margin-bottom: var(--space-xs) !important;
}

/* ── Agree checkbox ──────────────────── */
.td-agree {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
}

.td-agree input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.td-agree__box {
  position: relative;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background: var(--color-bg-white);
  border: 1px solid var(--color-text-muted);
  border-radius: var(--radius-sm);
}

.td-agree input:checked ~ .wpcf7-list-item-label .td-agree__box,
.td-agree input:checked ~ .td-agree__item__label .td-agree__box {
  background: linear-gradient(180deg, var(--color-primary) 0%, #007AB7 100%);
  border-color: var(--color-primary);
}

.td-agree input:checked ~ .wpcf7-list-item-label .td-agree__box::after,
.td-agree input:checked ~ .td-agree__item__label .td-agree__box::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 10.5px;
  transform: translate(-50%, -50%);
  background-color: #fff;
  mask: url('/assets/images/common/icon/icon_checkbox.svg') center / contain no-repeat;
  -webkit-mask: url('/assets/images/common/icon/icon_checkbox.svg') center / contain no-repeat;
}

.td-agree .wpcf7-list-item-label,
.td-agree .td-agree__item__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.td-agree .wpcf7-list-item label,
.td-agree .td-agree__item label {
  cursor: pointer;
}

.td-agree__label {
  font-size: var(--text-md);
  color: var(--color-text-dark);
}


/* ── Form intro text ──────────────────── */
.td-form-intro {
  color: var(--color-text);
  font-size: var(--text-body);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-md);
}

/* ── Required note (*Fields marked…) ──────────────────── */
.td-form-required-note {
  font-size: 15px;
  color: var(--color-error);
  margin: var(--space-sm) 0;
}

/* ── Textarea field: top-align required label ──────────────────── */
.td-form__field--textarea {
  align-items: flex-start;
}

.td-form__field--textarea .td-required-label {
  margin-top: 20px;
}

/* ── Select inside form card: cap at half-width ──────────────────── */
.td-form-card .td-select-wrap {
  width: min(480px, 100%);
}

/* ── Consent section heading ──────────────────── */
.td-consent__heading {
  font-size: var(--text-lg);
  font-weight: var(--font-medium);
  color: var(--color-text-dark);
  text-align: center;
  margin-bottom: var(--space-md);
  margin-top: 0;
}


/* ── Responsive ──────────────────── */
@media (max-width: 767px) {
  .td-select-wrap {
    width: 100%;
  }

  .td-form-card .td-select-wrap {
    width: 100%;
  }

  .td-form-card {
    padding: var(--space-md);
  }

  .td-consent {
    padding: var(--space-md);
  }

  .td-required-label {
  font-size: 13px;
  white-space: nowrap;
  width: 100%;
  margin-bottom: var(--space-sm);
  }

  .td-form__field {
    gap: 3px 10px;
  }

  .td-form__field--textarea .td-required-label {
    margin-top: 0;
  }

  /* ラベルなしフィールドの同量の右余白を解除 */
  .td-form__field:not(:has(.td-required-label)) {
    padding-right: 0;
    padding-bottom: var(--space-sm);
  }
}

@media (max-width: 767px) {
  .td-form__field {
    flex-wrap: wrap;
  }

  .td-textarea {
    flex: 1;
  }
}

/* ── Thanks message ──────────────────── */
.td-form-thanks-message {
  font-size: var(--text-lg);
  color: var(--color-text-dark);
  margin: 0;
}
