/* Font. To switch, comment out the active line and uncomment an alternative. */
:root {
  --font: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  /* --font: Georgia, "Times New Roman", serif; */
  /* --font: "Times New Roman", Times, serif; */
}

/* Colours. Registered so they can animate between themes. */
@property --sky-top    { syntax: "<color>"; inherits: true; initial-value: #f9f6f1; }
@property --sky-bottom { syntax: "<color>"; inherits: true; initial-value: #f4e8e2; }
@property --sea-top    { syntax: "<color>"; inherits: true; initial-value: #e6ecec; }
@property --sea-bottom { syntax: "<color>"; inherits: true; initial-value: #d8e2e4; }
@property --line       { syntax: "<color>"; inherits: true; initial-value: #dad6d4; }
@property --text       { syntax: "<color>"; inherits: true; initial-value: #2a2b2d; }
@property --muted      { syntax: "<color>"; inherits: true; initial-value: #595c60; }
@property --sun        { syntax: "<color>"; inherits: true; initial-value: #f5d98b; }
@property --wave       { syntax: "<color>"; inherits: true; initial-value: #88a2ab; }
@property --path-x     { syntax: "<length-percentage>"; inherits: true; initial-value: 70%; }

/* Day (default). Each colour mixes the original cream palette with a warmer one (peach-pink horizon,
   faded teal sea). --day-warmth: 0% = original cream, 100% = warm (~25% toward dusk), 50% ≈ 12%. */
:root {
  --day-warmth: 50%;
  --sky-top: color-mix(in srgb, #fafaf8, #f8f2ea var(--day-warmth));
  --sky-bottom: color-mix(in srgb, #f5f4ef, #f3ddd5 var(--day-warmth));
  --sea-top: color-mix(in srgb, #eef1f2, #dde6e7 var(--day-warmth));
  --sea-bottom: color-mix(in srgb, #e7ecee, #c8d8db var(--day-warmth));
  --line: color-mix(in srgb, #d8dcde, #dccfcb var(--day-warmth));
  --text: #2a2b2d;
  --muted: color-mix(in srgb, #5c5f63, #56595d var(--day-warmth));
  --sun: #f5d98b;
  --wave: color-mix(in srgb, #93a8b5, #7c9ba1 var(--day-warmth));
  --moon: #e6e3d6;
  --glint: #fff;
  --glint-o: 0.8;
  --path-x: calc(70% + 1.375rem); /* under the sun */
  --sun-y: 0;
  --moon-y: 4rem;
  --ease: ease-out;
  transition-property: --sky-top, --sky-bottom, --sea-top, --sea-bottom, --line, --text, --muted, --sun, --wave, --path-x;
  transition-duration: 1s;
  transition-timing-function: var(--ease);
}

/* Halfway state during the toggle: sunset going down, sunrise coming up */
[data-theme="dusk"] {
  --sky-top: #ddcbd3;
  --sky-bottom: #f4cdb0;
  --sea-top: #e8c3b6;
  --sea-bottom: #b9a9b6;
  --line: #d9ab99;
  --text: #463b44;
  --muted: #5e4e57;
  --sun: #f2a877;
  --wave: #c49a92;
  --glint-o: 0;
  --sun-y: 2rem;
  --ease: ease-in;
}

[data-theme="night"] {
  --sky-top: #1d2536;
  --sky-bottom: #28324b;
  --sea-top: #222c40;
  --sea-bottom: #1a2232;
  --line: #3b4761;
  --text: #dfe3ea;
  --muted: #aab3c2;
  --sun: #f2a877;
  --wave: #5b6a86;
  --glint: #d9dfea;
  --glint-o: 0.6;
  --path-x: calc(22% + 1rem); /* under the moon */
  --sun-y: 4rem;
  --moon-y: 0;
}

* { box-sizing: border-box; }

html { background: var(--sea-bottom); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font: 300 1.125rem/1.6 var(--font);
  text-align: center;
}

/* Sky: everything above the horizon. Only the name is in flow, so it and the horizon never move. */
.sky {
  position: relative;
  min-height: 60vh;
  min-height: 60svh;
  padding: 20vh 1.25rem 5.5rem; /* bottom padding keeps text clear of the sun */
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
  border-bottom: 1px solid var(--line);
}

/* Night stars */
.stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: #fff;
  opacity: 0;
  transition: opacity 1s;
  pointer-events: none;
}
[data-theme="night"] .stars { opacity: 1; }

/* Sea: waves behind; the boat's area on top; the links zone at the bottom */
.sea {
  position: relative;
  overflow-x: clip; /* the far-off boat's sail may still poke above the horizon */
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(var(--sea-top), var(--sea-bottom));
}

/* The boat only moves inside .boat-area, which ends where .links-zone (the exclusion box) begins */
.boat-area { position: relative; flex: 1; min-height: 7rem; }
.links-zone { position: relative; padding: 1rem 1.25rem 2.5rem; }

main {
  position: relative;
  z-index: 2; /* the bio sits on top of the sun if it has to */
  max-width: 880px;
  margin: 0 auto;
}

h1 {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 300;
  line-height: 1.2;
  letter-spacing: 0.025em;
}

p { margin: 0; }

/* Bio: out of flow under the name; shrinks on short or narrow screens (14px min, 17px max) */
.bio {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 1.5rem;
  font-size: clamp(0.875rem, min(2.1vh, 4.3vw), 1.0625rem);
  line-height: 1.55;
  transition: opacity 0.3s;
}
.bio p + p { margin-top: 0.7em; }
.bio:not([hidden]) { animation: fade-in 0.3s; }
.bio.fading { opacity: 0; }
@keyframes fade-in { from { opacity: 0; } }

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 2rem;
}

.email { margin-top: 0.75rem; }

a, .links button {
  color: inherit;
  text-decoration: underline 1px;
  text-underline-offset: 4px;
}
.links button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
}
.email a { text-decoration: none; }
a:hover, .links button:hover { color: var(--muted); }

/* Sun and moon: one toggle button. Only the visible body is clickable;
   the other one is below the horizon, clipped by .sky. */
.bodies {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5rem;
  padding: 0;
  border: 0;
  background: none;
  overflow: hidden; /* hides the sun/moon below the horizon */
  pointer-events: none;
}
.bodies:focus { outline: none; }

.bodies svg {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  border-radius: 50%;
  fill: currentColor;
  transition: transform 1s var(--ease), scale 0.2s, filter 0.2s;
}
.bodies svg:hover { scale: 1.05; filter: drop-shadow(0 0 0.4rem currentColor); }
.bodies:focus-visible svg { outline: 2px solid var(--text); outline-offset: 4px; }

.sun {
  left: 70%;
  bottom: 0.75rem;
  width: 2.75rem;
  height: 2.75rem;
  color: var(--sun);
  transform: translateY(var(--sun-y));
}

.moon {
  left: 22%;
  bottom: 1.5rem;
  width: 2rem;
  height: 2rem;
  color: var(--moon);
  transform: translateY(var(--moon-y));
}

/* Waves: 4 layers built by script.js, far (small, faint, slow) to near.
   Each layer drifts left by one tile width per loop. */
.waves {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: var(--wave);
  pointer-events: none;
}
.waves svg {
  position: absolute;
  left: 0;
  width: calc(100% + var(--tile));
  animation: drift linear infinite;
}
.waves svg:nth-child(1) { top: 0;   height: 22%; opacity: 0.45; animation-duration: 240s; }
.waves svg:nth-child(2) { top: 18%; height: 24%; opacity: 0.5;  animation-duration: 180s; }
.waves svg:nth-child(3) { top: 38%; height: 30%; opacity: 0.55; animation-duration: 130s; }
.waves svg:nth-child(4) { top: 64%; height: 36%; opacity: 0.6;  animation-duration: 95s; }
.waves path { fill: none; stroke: currentColor; stroke-linecap: round; }

/* Light path: the same waves, brighter, only in a strip under the sun (day) or moon (night) */
.glints {
  color: var(--glint);
  opacity: var(--glint-o);
  transition: opacity 1s;
  mask-image: radial-gradient(ellipse 3.5rem 100% at var(--path-x) 0, #000 15%, transparent);
}
@keyframes drift { to { transform: translateX(calc(-1 * var(--tile))); } }
.paused .waves svg { animation-play-state: paused; } /* tab hidden */

/* Boat: an svg over .boat-area, moved and tacked by script.js. Click the boat to tack. */
.boat {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 2s;
}
[data-theme="night"] .boat { opacity: 0.4; }
.boat-body { pointer-events: visiblePainted; cursor: pointer; }
.boat .detail { opacity: var(--detail, 0); } /* fades in as the boat comes closer */

@media (prefers-reduced-motion: reduce) {
  :root, .bodies svg, .bio { transition: none; animation: none; }
  .waves svg { animation: none; }
  .boat-body { cursor: default; }
}

@media (min-width: 40em) {
  h1 { font-size: 3rem; }
}
