/* alextneil.com — ink on paper, living Arkansas Valley topo behind the mark. */

:root {
  --paper: #f6f5f2;          /* warm paper — the chosen default */
  --ink: #0b0b0c;
  --muted: rgba(11, 11, 12, 0.46);
  --hair: rgba(11, 11, 12, 0.14);
  --accent: #d24e00;         /* International Orange — Fed Std 595 #12197 */
  --logo-invert: 0;
  --logo-w: 34vmin;
}

/* Resolve the visitor's theme before first paint to avoid a flash. */
:root.dark {
  --paper: #0c0c0d;
  --ink: #f3f2ef;
  --muted: rgba(243, 242, 239, 0.5);
  --hair: rgba(243, 242, 239, 0.16);
  --accent: #ee6a1a;         /* same orange, lifted for contrast on near-black */
  --logo-invert: 1;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  transition: background 0.6s ease, color 0.6s ease;
}
a { color: inherit; text-decoration: none; }

/* Ink-on-paper selection, in keeping with the palette */
::selection { background: var(--ink); color: var(--paper); }

/* Living contours: the topo backdrop is drawn on canvas, breathing slowly.
   Colors are chosen per-frame in JS so they follow the theme exactly.
   Visibility never depends on CSS animations — the fade-in is done in JS. */
#topoCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Visitor-facing theme toggle */
.theme-toggle {
  position: fixed;
  top: clamp(18px, 3vmin, 34px);
  right: clamp(18px, 3.4vmin, 40px);
  z-index: 3;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle .disc {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.6px solid var(--ink);
  background: linear-gradient(90deg, var(--ink) 0 50%, transparent 50% 100%);
  opacity: 0.45;
  transition: opacity 0.3s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.6s ease, background 0.6s ease;
}
.theme-toggle.is-dark .disc { transform: rotate(180deg); }
.theme-toggle:hover .disc { opacity: 1; }
.theme-toggle:focus-visible { outline: none; }
.theme-toggle:focus-visible .disc { opacity: 1; box-shadow: 0 0 0 4px var(--hair); }

/* ---- Layout ---- */
.page {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(20px, 3.4vmin, 40px) clamp(22px, 4vmin, 52px);
}
.mono {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: clamp(10px, 1.05vmin, 12px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(34px, 6vmin, 68px);
  min-height: 0;
}

/* ---- Logo: independently-moving tonal layers ---- */
.logo-stage {
  position: relative;
  aspect-ratio: 2400 / 1738;
  width: var(--logo-w);
  max-width: 86vw;
  cursor: pointer;
  will-change: transform;
}
.logo-wrap {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}
.logo-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-select: none;
  user-select: none;
  will-change: transform, clip-path;
  filter: invert(var(--logo-invert));
  transition: filter 0.6s ease;
}
/* entrance reveal (default, non-assemble motion) */
.logo-layer.reveal {
  animation: revealUp 1s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.layer-black.reveal { animation-delay: 0.14s; }
@keyframes revealUp {
  from { opacity: 0; clip-path: inset(22% 0 0 0); }
  to   { opacity: 1; clip-path: inset(0 0 0 0); }
}
/* assemble: peaks grow up from the ground (gray range first, then black) —
   used for the click-to-restack replay */
.logo-layer.assemble {
  animation: growUp 1.15s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.a-gray  { animation-delay: 0.05s; }
.a-black { animation-delay: 0.42s; }
@keyframes growUp {
  from { opacity: 0; clip-path: inset(100% 0 0 0); }
  60%  { opacity: 1; }
  to   { opacity: 1; clip-path: inset(0 0 0 0); }
}

/* ---- Identity ---- */
.identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(18px, 2.6vmin, 28px);
}
.wordmark {
  margin: 0;
  font-weight: 500;
  font-size: clamp(20px, 3vmin, 34px);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink);
}
.wordmark .ch {
  display: inline-block;
  opacity: 0;
  animation: chIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes chIn {
  from { opacity: 0; transform: translateY(0.5em); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Connect row: International Orange icon links ---- */
.connect {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(6px, 1.4vmin, 14px) clamp(22px, 3.4vmin, 40px);
}
.link {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  padding: 4px 2px;
  opacity: 0;
  animation: linkIn 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: color 0.6s ease;
}
.link.l1 { animation-delay: 1.1s; }
.link.l2 { animation-delay: 1.24s; }
.link.l3 { animation-delay: 1.38s; }
@keyframes linkIn {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}
.link .icon {
  width: clamp(16px, 1.9vmin, 19px);
  height: clamp(16px, 1.9vmin, 19px);
  display: block;
  fill: currentColor;
  opacity: 0.72;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.link .icon-mail {                     /* line-drawn envelope, matching the hairlines */
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.link:hover .icon { opacity: 1; transform: translateY(-1.5px); }
.link:focus-visible { outline: none; box-shadow: 0 1px 0 0 var(--accent); }
.link:focus-visible .icon { opacity: 1; }

/* ---- Footer: instrument bar — Mountain Time clock · geodata divider · Leadville wx ---- */
.botbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(10px, 1.8vmin, 16px);
  opacity: 0;
  animation: linkIn 0.9s cubic-bezier(0.22, 1, 0.36, 1) 1.55s both;
}
.botbar .inst { flex: 1 1 0; white-space: nowrap; }
.botbar .inst-right { text-align: right; }
.botbar .divider {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.8vmin, 16px);
}
.hair-line {
  height: 1px;
  width: clamp(28px, 10vmin, 130px);
  background: var(--hair);
}
.botbar .peak { color: var(--accent); font-size: 9px; letter-spacing: 0; transition: color 0.6s ease; }
.botbar .geo { white-space: nowrap; }

@media (max-width: 640px) {
  /* small screens: time + temperature drop out, coordinates + elevation stay */
  .botbar { justify-content: center; }
  .botbar .inst, .botbar .hair-line { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .logo-layer.reveal, .logo-layer.assemble { animation-duration: 0.4s; }
  .wordmark .ch { animation-duration: 0.3s; }
  .link, .botbar { animation-duration: 0.3s; }
}
