/* Shared contact page. No external fonts, libraries, or CDNs. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c1f23;
  --text-muted: #5b636d;
  --border: #c5cbd3;
  --border-strong: #8a929c;
  --accent: #1a5fb4;
  --accent-text: #ffffff;
  --accent-hover: #154c91;
  --focus: #1a5fb4;
  --required: #c62828;
  --error: #b3261e;
  --error-bg: #fdecea;
  --error-border: #e8a8a3;
  --success: #1b6b3a;
  --success-bg: #e8f5ec;
  --success-border: #9fceb1;
  --notice-bg: #eef4fb;
  --notice-border: #b9d0ea;
  --notice-icon: #2a64a6;
  --radius: 0.75rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --surface: #1b1e22;
    --text: #e8eaed;
    --text-muted: #a6adb6;
    --border: #3d434b;
    --border-strong: #6b737d;
    --accent: #6ea8ff;
    --accent-text: #0b1a2e;
    --accent-hover: #93bfff;
    --focus: #8fbcff;
    --required: #ff8a80;
    --error: #ffb4ab;
    --error-bg: #3a1a18;
    --error-border: #7a3530;
    --success: #8fd6a8;
    --success-bg: #14291c;
    --success-border: #2f5e40;
    --notice-bg: #172433;
    --notice-border: #2f4a68;
    --notice-icon: #8cc0ff;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* iOS (Safari / WKWebView / SFSafariViewController): follow the system
   text size setting (Dynamic Type). Every size below is in rem/em. */
@supports (font: -apple-system-body) and (-webkit-touch-callout: none) {
  html {
    font: -apple-system-body;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.page {
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem max(1rem, env(safe-area-inset-right)) 3rem max(1rem, env(safe-area-inset-left));
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1.25rem;
}

.page-title {
  margin: 0;
  font-size: 1.5em;
  line-height: 1.35;
}

.language-switcher {
  flex: 0 0 auto;
}

.language-select {
  min-height: 2.75rem;
  margin: 0;
  padding: 0.45rem 2rem 0.45rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: max(1rem, 16px);
}

@media (max-width: 22rem) {
  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .language-select {
    width: 100%;
  }
}

.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;
}

[hidden] {
  display: none !important;
}

/* Page-level messages (JavaScript required, invalid URL). */
.page-message {
  margin: 0 0 1.25rem;
  padding: 1rem 1.125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.page-message p {
  margin: 0;
}

.page-message:empty {
  display: none;
}

/* Form */
.contact-form {
  margin: 0;
}

.form-fields {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field {
  margin: 0 0 1.375rem;
}

.field-label {
  display: block;
  margin: 0 0 0.375rem;
  font-weight: 600;
}

.required {
  margin-left: 0.25em;
  color: var(--required);
  font-weight: 700;
}

.optional {
  display: inline-block;
  margin-left: 0.5em;
  padding: 0 0.5em;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.8em;
  font-weight: 500;
  line-height: 1.6;
  vertical-align: 0.1em;
}

.input {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  margin: 0;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  /* At least 16px keeps iOS from zooming the page on focus. */
  font-size: max(1rem, 16px);
  line-height: 1.5;
}

.textarea {
  min-height: 10rem;
  resize: vertical;
}

.select-wrap {
  position: relative;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.5rem;
}

.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1rem;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.input[aria-invalid="true"] {
  border-color: var(--error);
  border-width: 2px;
}

.input:disabled,
.submit:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

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

.input:focus-visible {
  outline-offset: 1px;
}

.field-hint {
  margin: 0.375rem 0 0;
  color: var(--text-muted);
  font-size: 0.875em;
}

.counter {
  text-align: right;
}

.field-error {
  margin: 0.375rem 0 0;
  color: var(--error);
  font-size: 0.9375em;
  font-weight: 600;
}

.field-error::before {
  content: "！ ";
}

/* Honeypot: off-screen, not reachable by keyboard or screen readers. */
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Notice box shown right before the submit button. */
.notice {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin: 0.5rem 0 1.5rem;
  padding: 1rem 1.125rem;
  border: 1px solid var(--notice-border);
  border-radius: var(--radius);
  background: var(--notice-bg);
}

.notice-icon {
  flex: 0 0 auto;
  width: 1.5em;
  height: 1.5em;
  margin-top: 0.1em;
  color: var(--notice-icon);
}

.notice-body {
  min-width: 0;
}

.notice-title {
  margin: 0 0 0.25rem;
  font-size: 1em;
  font-weight: 700;
  line-height: 1.5;
}

.notice-body p {
  margin: 0;
  font-size: 0.9375em;
}

/* Submit */
.submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem 1.5rem;
  border: 0;
  border-radius: 0.625rem;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.submit:hover:not(:disabled) {
  background: var(--accent-hover);
}

@media (min-width: 40em) {
  .submit {
    width: auto;
    min-width: 12rem;
  }
}

.spinner {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

/* Status (sending / slow) */
.status {
  margin: 1rem 0 0;
  color: var(--text-muted);
}

.status:focus {
  outline: none;
}

/* Errors */
.form-error {
  margin: 1rem 0 0;
  padding: 1rem 1.125rem;
  border: 1px solid var(--error-border);
  border-radius: var(--radius);
  background: var(--error-bg);
  color: var(--text);
}

.form-error:empty {
  display: none;
}

.form-error p {
  margin: 0;
  color: var(--error);
  font-weight: 700;
}

.form-error .reference {
  margin-top: 0.375rem;
  color: var(--text-muted);
  font-size: 0.75em;
  font-weight: 400;
}

/* Success */
.result {
  margin: 0 0 1.5rem;
  padding: 1rem 1.125rem;
  border: 1px solid var(--success-border);
  border-radius: var(--radius);
  background: var(--success-bg);
}

.result:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.result-title {
  margin: 0 0 0.25rem;
  color: var(--success);
  font-size: 1.125em;
}

.result p {
  margin: 0;
}

.inquiry-id {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 700;
  letter-spacing: 0.02em;
  word-break: break-all;
}

.result-note {
  margin-top: 0.25rem !important;
  color: var(--text-muted);
  font-size: 0.875em;
}

@media (forced-colors: active) {
  .notice,
  .form-error,
  .result,
  .page-message {
    border: 1px solid CanvasText;
  }
  .required {
    color: CanvasText;
  }
}
