:root {
  --bg: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --field: #f5f5f7;
  --field-hover: #ececf0;
  --line: transparent;
  --focus: #0071e3;
  --btn: #1d1d1f;
  --btn-text: #ffffff;
  --err: #d70015;
  --ok: #248a3d;
  color-scheme: light;
}

/* Dark: follows the system unless the visitor picked a theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --field: #1c1c1e;
    --field-hover: #242426;
    --line: #2c2c2e;
    --focus: #2997ff;
    --btn: #f5f5f7;
    --btn-text: #000000;
    --err: #ff453a;
    --ok: #30d158;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --field: #1c1c1e;
  --field-hover: #242426;
  --line: #2c2c2e;
  --focus: #2997ff;
  --btn: #f5f5f7;
  --btn-text: #000000;
  --err: #ff453a;
  --ok: #30d158;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.015em;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 4rem 16px;
}

#contact { width: 100%; }

h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.25rem, 6vw, 3.75rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

#contact > p {
  margin: 0 0 2.75rem;
  max-width: 34rem;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.2rem);
}

/* Fields with floating labels ----------------------------------- */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  position: relative;
  margin-bottom: 12px;
}

.field input,
.field textarea {
  display: block;
  width: 100%;
  padding: 1.6rem 1rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.field textarea { resize: vertical; min-height: 11rem; line-height: 1.5; }

.field input:hover,
.field textarea:hover { background: var(--field-hover); }

.field input:focus,
.field textarea:focus {
  outline: none;
  background: var(--bg);
  border-color: var(--focus);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 20%, transparent);
}

.field label {
  position: absolute;
  left: calc(1rem + 1px);
  top: 1.1rem;
  color: var(--muted);
  font-size: 1.05rem;
  pointer-events: none;
  transform-origin: left top;
  transition: transform 0.18s ease, color 0.18s ease;
}

/* Float the label up when focused or filled */
.field input:focus + label,
.field input:not(:placeholder-shown) + label,
.field textarea:focus + label,
.field textarea:not(:placeholder-shown) + label {
  transform: translateY(-0.6rem) scale(0.75);
}
.field input:focus + label,
.field textarea:focus + label { color: var(--focus); }

/* Errors: from the server, or after the visitor has interacted */
.field [aria-invalid="true"],
.field :user-invalid {
  border-color: var(--err);
}
.field [aria-invalid="true"] + label,
.field :user-invalid + label { color: var(--err); }

/* Actions -------------------------------------------------------- */
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 1.25rem;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

button {
  flex-shrink: 0;
  padding: 0.95rem 2rem;
  border: 0;
  border-radius: 980px;
  background: var(--btn);
  color: var(--btn-text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease;
}
button:hover { opacity: 0.85; }
button:active { transform: scale(0.97); }
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 35%, transparent);
}

/* Messages ------------------------------------------------------- */
#contact > .flash {
  max-width: none;
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--err) 10%, transparent);
  color: var(--err);
  font-size: 0.95rem;
}

.sent {
  padding: 1rem 0;
  animation: rise 0.5s ease both;
}
.sent h2 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.sent p { margin: 0 0 1.75rem; color: var(--muted); max-width: 30rem; }
.sent a {
  color: var(--focus);
  text-decoration: none;
  font-weight: 500;
}
.sent a:hover { text-decoration: underline; }

.check {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ok);
}
.check::after {
  content: "";
  width: 22px;
  height: 11px;
  margin-top: -5px;
  border-left: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: rotate(-45deg);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sent { animation: none; }
  .field label, button { transition: none; }
}

/* Honeypot: off-screen, not display:none (some bots skip hidden fields) */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

footer {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 600px) {
  .row { grid-template-columns: 1fr; gap: 0; }
  .actions { flex-direction: column-reverse; align-items: stretch; text-align: center; }
  .actions button { width: 100%; }
}

[hidden] { display: none !important; }

.cf-turnstile { margin-top: 12px; }

button:disabled { opacity: 0.5; cursor: progress; transform: none; }

/* Language + theme controls -------------------------------------- */
.controls {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 1;
}

.controls button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}
.controls button:hover { color: var(--text); opacity: 1; }
.controls button:active { transform: none; }
.controls button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent);
}

.lang {
  display: flex;
  padding: 3px;
  border-radius: 980px;
  background: var(--field);
}
.lang button {
  min-width: 2.5rem;
  height: 30px;
  padding: 0 0.6rem;
  border-radius: 980px;
}
.lang button[aria-pressed="true"] {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.controls .theme {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
}
.controls .theme:hover { background: var(--field); }
.theme svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Show the moon in light mode (go dark), the sun in dark mode (go light) */
.theme .i-sun,
.theme[data-mode="dark"] .i-moon { display: none; }
.theme[data-mode="dark"] .i-sun { display: block; }
