:root {
  --fg: #0f2a3d;
  --btn-bg: #0f2a3d;
  --btn-fg: #fdfaf4;
  --btn-hover: #1f4a66;

  --sky-top: #a9d8f0;
  --sky-bottom: #fdf1e2;
  --sun: #ffe3a8;
  --wave-back: #8ccbe2;
  --wave-mid: #4a9fc4;
  --wave-front: #236f98;
  --sail: #fffdf8;
  --hull: #8a3b2e;
  --mast: #3b2a20;
  --flag: #e0574a;
  --field-bg: color-mix(in srgb, var(--sky-bottom) 60%, white);
}

/* Night: follows the device setting unless the switch has picked a theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fg: #eef3f8;
    --btn-bg: #eef3f8;
    --btn-fg: #0b1630;
    --btn-hover: #c9d6e4;

    --sky-top: #070f24;
    --sky-bottom: #1f2f55;
    --sun: #e9e6d8;
    --wave-back: #233f68;
    --wave-mid: #183257;
    --wave-front: #0e2342;
    --sail: #d9dde4;
    --hull: #5a2a24;
    --mast: #c9c2b8;
    --flag: #b8483e;
    --field-bg: color-mix(in srgb, var(--sky-bottom) 70%, black);
  }
}

:root[data-theme="dark"] {
  --fg: #eef3f8;
  --btn-bg: #eef3f8;
  --btn-fg: #0b1630;
  --btn-hover: #c9d6e4;

  --sky-top: #070f24;
  --sky-bottom: #1f2f55;
  --sun: #e9e6d8;
  --wave-back: #233f68;
  --wave-mid: #183257;
  --wave-front: #0e2342;
  --sail: #d9dde4;
  --hull: #5a2a24;
  --mast: #c9c2b8;
  --flag: #b8483e;
  --field-bg: color-mix(in srgb, var(--sky-bottom) 70%, black);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--sky-bottom);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Ocean scene ---------- */

.scene {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(to bottom, var(--sky-top), var(--sky-bottom) 70%);
}

.sun {
  position: absolute;
  top: 12vh;
  right: 14vw;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 60px 20px color-mix(in srgb, var(--sun) 45%, transparent);
}

/* Each wave is two identical stretches side by side; sliding it by half loops seamlessly. */
.wave {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 200%;
  animation: swell linear infinite;
  transition: fill 0.6s ease;
}

.wave-back  { height: 32vh; fill: var(--wave-back);  animation-duration: 38s; animation-direction: reverse; }
.wave-mid   { height: 24vh; fill: var(--wave-mid);   animation-duration: 26s; }
.wave-front { height: 15vh; fill: var(--wave-front); animation-duration: 18s; }

@keyframes swell {
  to { transform: translateX(-50%); }
}

/* The boat sits between the back and middle waves so the swell laps at its hull. */
.boat-track {
  position: absolute;
  left: 0;
  bottom: 11.5vh;
  animation: drift 90s linear infinite;
  animation-delay: -35s; /* start partway across instead of off-screen */
}

.boat {
  display: block;
  width: 90px;
  height: 90px;
  transform-origin: 50% 85%;
  animation: bob 5s ease-in-out infinite;
}

.boat .mast { stroke: var(--mast); stroke-width: 2.5; stroke-linecap: round; }
.boat .flag { fill: var(--flag); }
.boat .sail { fill: var(--sail); }
.boat .sail-jib { opacity: 0.9; }
.boat .hull { fill: var(--hull); }

@keyframes drift {
  from { transform: translateX(-120px); }
  to   { transform: translateX(calc(100vw + 20px)); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(6px) rotate(3deg); }
}

@media (prefers-reduced-motion: reduce) {
  .wave, .boat, .boat-track { animation: none; }
  .boat-track { left: 12vw; }
}

/* ---------- Content ---------- */

.card {
  width: 100%;
  max-width: 360px;
  text-align: center;
  /* Lift the content into the sky, above the waves. */
  margin-bottom: 18vh;
}

h1 {
  margin: 0;
  font-size: 2.5rem;
  letter-spacing: -0.02em;
}

.links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.button {
  display: block;
  padding: 14px 20px;
  border-radius: 10px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.12);
  transition: background 0.15s ease;
}

.button:hover { background: var(--btn-hover); }

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

/* ---------- Contact dialog ---------- */

button.button {
  width: 100%;
  border: 0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.button:disabled { opacity: 0.6; cursor: progress; }

.button-quiet {
  background: transparent;
  color: var(--fg);
  box-shadow: inset 0 0 0 1.5px var(--fg);
}

.button-quiet:hover { background: color-mix(in srgb, var(--fg) 10%, transparent); }

.contact {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 0;
  border-radius: 14px;
  background: var(--sky-bottom);
  color: var(--fg);
  box-shadow: 0 20px 50px rgb(0 0 0 / 0.3);
}

.contact::backdrop {
  background: rgb(5 15 30 / 0.45);
  backdrop-filter: blur(2px);
}

.contact h2 {
  margin: 0 0 16px;
  font-size: 1.4rem;
}

.contact textarea,
.contact input[type="text"] {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1.5px solid color-mix(in srgb, var(--fg) 30%, transparent);
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--fg);
  font: inherit;
}

.contact textarea { resize: vertical; }

.field-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
}

.contact textarea:focus-visible,
.contact input[type="text"]:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.contact-status {
  min-height: 1.4em;
  margin: 10px 0;
  font-size: 0.95rem;
}

.contact-actions {
  display: flex;
  gap: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Day / night switch ---------- */

.theme-switch {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-switch .track {
  position: relative;
  width: 64px;
  height: 34px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 18%, transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--fg) 35%, transparent);
  transition: background 0.3s ease;
}

.theme-switch .knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 26px;
  height: 26px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 10px 2px color-mix(in srgb, var(--sun) 60%, transparent);
  transition: transform 0.3s ease, background 0.3s ease;
}

.theme-switch[aria-checked="true"] .knob { transform: translateX(30px); }

/* A bite out of the knob turns the sun into a crescent moon at night. */
.theme-switch .knob::after {
  content: "";
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--sky-top);
  transform: scale(0);
  transition: transform 0.3s ease;
}

.theme-switch[aria-checked="true"] .knob::after { transform: scale(1); }

.theme-switch:focus-visible .track {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .theme-switch .knob, .theme-switch .knob::after, .wave { transition: none; }
}
