/* nightglow.io — "Almanac Sky". Colours are set live from the sun by
   src/main.ts; the values here are the night fallback before JS runs. */

:root {
  --sky-top: #04050d;
  --sky-bottom: #0b1029;
  --paper: #0b0d1c;
  --ink: #eee4d2;
  --muted: #a9a3b8;
  --accent: #ffb35c;
  --hero-ink: #f3ead9;
  --darkness: 1;
  --tint: rgb(255 255 255);

  --display: 'Gloock', 'Iowan Old Style', Georgia, serif;
  --body: 'Hanken Grotesk', 'Avenir Next', 'Segoe UI', sans-serif;
  --mono: 'Fragment Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --gutter: clamp(16px, 4vw, 56px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --slow: 1.6s;
}

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

/* Component display rules (e.g. .button's inline-flex) would otherwise
   override the hidden attribute. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(16px, 1.05vw + 10px, 18px);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background-color var(--slow) var(--ease), color var(--slow) var(--ease);
}

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
a:hover {
  color: var(--accent);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* The page runs Nightglow on itself: a multiply layer holding the same
   per-channel gains the app writes into the display gamma table. */
.tint {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background: var(--tint);
  mix-blend-mode: multiply;
  transition: background-color var(--slow) linear;
}

/* ---- top bar ---------------------------------------------------------- */

.topbar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  /* Leave room for the GitHub corner. */
  padding: 22px calc(var(--gutter) + clamp(52px, 5vw, 72px)) 22px var(--gutter);
  color: var(--hero-ink);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.wordmark__mark {
  width: 26px;
  height: 26px;
  color: var(--accent);
}
.topbar__nav {
  display: flex;
  gap: clamp(0.9rem, 2.4vw, 2rem);
  font-size: 0.92rem;
  font-weight: 500;
}
.topbar__nav a {
  text-decoration: none;
  opacity: 0.85;
}
.topbar__nav a:hover {
  opacity: 1;
  color: inherit;
  text-decoration: underline;
}

/* GitHub corner: accent triangle, octocat in the page colour, waves on hover. */
.github-corner {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 20;
  width: clamp(64px, 6vw, 84px);
  aspect-ratio: 1;
}
.github-corner svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 18px rgb(0 0 0 / 0.25));
}
.github-corner__bg {
  fill: var(--accent);
  transition: fill var(--slow) var(--ease);
}
.github-corner__arm,
.github-corner__body {
  fill: var(--paper);
  transition: fill var(--slow) var(--ease);
}
.github-corner__arm {
  transform-origin: 130px 106px;
}
.github-corner:hover .github-corner__arm {
  animation: octocat-wave 560ms ease-in-out;
}
.github-corner:focus-visible {
  outline-offset: -6px;
}
@keyframes octocat-wave {
  0%, 100% { transform: rotate(0); }
  20%, 60% { transform: rotate(-25deg); }
  40%, 80% { transform: rotate(10deg); }
}

/* ---- hero -------------------------------------------------------------- */

.hero {
  position: relative;
  min-height: max(640px, 100svh);
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 0 var(--gutter) 28px;
  color: var(--hero-ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 72%, var(--sky-bottom) 100%);
  transition: color var(--slow) var(--ease);
  isolation: isolate;
  overflow: hidden;
}
/* Gradients can't transition, so cross-fade a copy on the pseudo-element. */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background: radial-gradient(120% 55% at var(--sun-x, 50%) calc(var(--horizon, 0.72) * 100%), color-mix(in srgb, var(--sky-bottom) 55%, #fff5) 0%, transparent 60%);
  opacity: calc(1 - var(--darkness));
  transition: opacity var(--slow) linear;
}
.hero__stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: var(--darkness);
  transition: opacity var(--slow) linear;
}
.hero__arc {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: visible;
}
.hero__path {
  fill: none;
  stroke: var(--hero-ink);
  stroke-opacity: 0.28;
  stroke-width: 1.25;
  stroke-dasharray: 2 7;
  vector-effect: non-scaling-stroke;
}
.hero__sun {
  position: absolute;
  z-index: 1;
  width: clamp(56px, 7vw, 96px);
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle at 42% 38%, #fffaf0 0%, #ffe3a8 38%, #ffb35c 70%, #ff8a3d 100%);
  box-shadow:
    0 0 40px 12px color-mix(in srgb, #ffb35c 55%, transparent),
    0 0 160px 60px color-mix(in srgb, #ff9a4a 22%, transparent);
  transition: left 0.9s var(--ease), top 0.9s var(--ease), opacity 0.9s linear;
}
.hero__sun[data-below='true'] {
  opacity: 0.55;
}
.hero__ground {
  position: absolute;
  inset: calc(var(--horizon, 0.72) * 100%) 0 0;
  z-index: 2;
  /* Fade from the horizon glow into the page colour so hero text always
     sits on a palette the contrast tests cover. */
  background: linear-gradient(180deg, var(--sky-bottom) 0%, var(--paper) 55%);
  transition: background-color var(--slow) linear;
}
.hero__horizon {
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: color-mix(in srgb, var(--hero-ink) 45%, transparent);
}
/* Sextant ticks along the horizon every 1/24 of the day. */
.hero__horizon::after {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 7px;
  background: repeating-linear-gradient(90deg, color-mix(in srgb, var(--hero-ink) 45%, transparent) 0 1px, transparent 1px calc(100% / 24));
}

.hero__copy {
  position: relative;
  z-index: 3;
  align-self: end;
  max-width: 44rem;
  /* Guarantees a band of open sky; main.ts puts the horizon just above
     the eyebrow so no text is ever crossed by it. */
  padding-top: max(150px, 34svh);
  padding-bottom: clamp(20px, 5vh, 56px);
}
.eyebrow {
  margin: 0 0 0.8rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.8;
}
.hero__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(4rem, 12vw, 10.5rem);
  line-height: 0.86;
  letter-spacing: -0.035em;
}
.hero__title span {
  color: var(--accent);
  text-shadow: 0 0 0.35em color-mix(in srgb, var(--accent) 55%, transparent);
  transition: color var(--slow) var(--ease);
}
.hero__lede {
  max-width: 33rem;
  /* Clear Gloock's deep g descenders at display size. */
  margin: clamp(1.4rem, 3.2vw, 3.1rem) 0 1.8rem;
  font-size: clamp(1.05rem, 0.9vw + 0.8rem, 1.3rem);
  line-height: 1.5;
}
.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1.35rem;
  border: 1.5px solid transparent;
  border-radius: 999px;
  font: 600 1rem/1 var(--body);
  text-decoration: none;
  cursor: pointer;
  /* No colour transition: buttons inherit the hero's already-transitioning
     colour, and a second transition on top made them lag behind. */
  transition: transform 0.25s var(--ease), background-color 0.3s;
}
.button:hover {
  transform: translateY(-2px);
}
.button--primary {
  background: var(--accent);
  color: #1a0f07;
}
.button--primary:hover {
  color: #1a0f07;
  background: color-mix(in srgb, var(--accent) 85%, #fff);
}
.button--ghost {
  border-color: color-mix(in srgb, currentColor 45%, transparent);
  background: transparent;
  color: inherit;
}
.button--small {
  min-height: 40px;
  padding: 0 1.1rem;
  font-size: 0.92rem;
  background: var(--accent);
  color: #1a0f07;
}
.button--small.button--ghost {
  background: transparent;
  color: var(--ink);
}

/* The almanac line: a ruled readout across the foot of the hero. */
.almanac {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  color: color-mix(in srgb, var(--hero-ink) 92%, transparent);
}
.almanac__cell {
  padding: 14px 16px 0 0;
  min-width: 0;
}
.almanac__cell + .almanac__cell {
  padding-left: 16px;
  border-left: 1px solid color-mix(in srgb, currentColor 18%, transparent);
}
.almanac dt {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.7;
}
.almanac dd {
  margin: 0.25rem 0 0;
  font-family: var(--display);
  font-size: clamp(1.2rem, 1.6vw, 1.6rem);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.almanac .almanac__note {
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.4;
  opacity: 0.75;
}
.almanac__note[data-state='asking']::after {
  content: ' · locating…';
}
.linkish {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---- sections -------------------------------------------------------------- */

main > section:not(.hero) {
  padding: clamp(72px, 12vw, 150px) var(--gutter) 0;
}
.section-head {
  max-width: 50rem;
  margin-bottom: clamp(32px, 5vw, 56px);
}
.kicker {
  margin: 0 0 1rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.3rem, 5.6vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: -0.025em;
}
h3 {
  margin: 0 0 0.5rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.55rem;
  line-height: 1.1;
}
.section-lede {
  max-width: 38rem;
  margin: 1.2rem 0 0;
  color: var(--muted);
  font-size: 1.12rem;
}

/* ---- the day strip -------------------------------------------------------- */

.strip-wrap {
  max-width: 1200px;
}
.strip {
  position: relative;
  height: 120px;
  border-radius: 14px;
  overflow: hidden;
  cursor: ew-resize;
  touch-action: none;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 18%, transparent), 0 24px 60px -30px rgb(0 0 0 / 0.6);
}
.strip__band {
  height: 50%;
}
.strip__band--warm {
  border-top: 1px solid rgb(0 0 0 / 0.25);
}
.strip__now {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 3px;
  translate: -50% 0;
  background: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--paper) 70%, transparent);
}
.strip__now::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  translate: -50% -50%;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--ink);
}
.strip__marks {
  position: relative;
  height: 2.2rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
}
.strip__mark {
  position: absolute;
  top: 0.5rem;
  translate: -50% 0;
  white-space: nowrap;
}
.strip__mark::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  height: 0.5rem;
  border-left: 1px solid currentColor;
}
.strip__hours {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.strip__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.6rem;
  margin-top: 1.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.swatch {
  display: inline-block;
  width: 26px;
  height: 10px;
  margin-right: 0.5rem;
  border-radius: 3px;
  vertical-align: 0.05em;
}
.swatch--sky {
  background: linear-gradient(90deg, #0b1029, #e0704f, #c4e2f8);
}
.swatch--warm {
  background: linear-gradient(90deg, #db9a63, #fff);
}
.strip__controls {
  display: flex;
  gap: 0.7rem;
  margin-top: 1.4rem;
}

/* ---- features ------------------------------------------------------------- */

.features__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: clamp(28px, 4vw, 56px);
  margin: 0;
  padding: 0;
  list-style: none;
}
.feature {
  padding-top: 1.1rem;
  border-top: 1px solid color-mix(in srgb, var(--ink) 25%, transparent);
}
.feature__num {
  display: block;
  margin-bottom: 1.4rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
}
.feature p {
  margin: 0;
  color: var(--muted);
}
.feature a {
  color: var(--ink);
}

/* ---- screenshots ---------------------------------------------------------- */

.shots {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(28px, 6vw, 90px);
}
.shot {
  margin: 0;
}
.shot img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 40px 80px -30px rgb(0 0 0 / 0.55), 0 0 0 1px color-mix(in srgb, var(--ink) 12%, transparent);
}
.shot--menu {
  rotate: -2deg;
}
.shot--menu img {
  width: min(360px, 100%);
}
.shot--settings img {
  width: min(340px, 100%);
}
.shot figcaption {
  margin-top: 1rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---- install -------------------------------------------------------------- */

.install__steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: clamp(28px, 4vw, 48px);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.install__steps li {
  counter-increment: step;
  min-width: 0;
}
.install__steps h3::before {
  content: counter(step, upper-roman) '. ';
  color: var(--accent);
}
.install__steps p {
  color: var(--muted);
}
.install__steps b {
  color: var(--ink);
  font-weight: 600;
}
pre {
  margin: 0.8rem 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ink) 8%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---- footer --------------------------------------------------------------- */

.footer {
  margin-top: clamp(80px, 12vw, 160px);
  padding: 28px var(--gutter) 40px;
  border-top: 1px solid color-mix(in srgb, var(--ink) 16%, transparent);
  font-size: 0.9rem;
  color: var(--muted);
}
.footer p {
  margin: 0.3rem 0;
}
.footer__fine {
  font-size: 0.8rem;
}

/* ---- motion ---------------------------------------------------------------- */

.reveal {
  opacity: 0;
  translate: 0 18px;
}
.is-ready .reveal {
  opacity: 1;
  translate: 0 0;
  transition: opacity 1.1s var(--ease), translate 1.1s var(--ease);
  transition-delay: calc(var(--d, 0) * 110ms + 150ms);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
  .reveal {
    opacity: 1;
    translate: none;
  }
  html {
    scroll-behavior: auto;
  }
}

/* ---- small screens ---------------------------------------------------------- */

@media (max-width: 860px) {
  .almanac {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .almanac__cell {
    padding: 12px 12px 12px 0;
    border-bottom: 1px solid color-mix(in srgb, currentColor 14%, transparent);
  }
  .almanac__cell + .almanac__cell {
    padding-left: 0;
    border-left: 0;
  }
  .almanac__cell:nth-child(even) {
    padding-left: 12px;
    border-left: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  }
  .almanac__cell--time {
    grid-column: 1 / -1;
  }
}
@media (max-width: 560px) {
  .topbar__nav a:not(.topbar__gh) {
    display: none;
  }
  .strip {
    height: 96px;
  }
  .strip__mark {
    font-size: 0.66rem;
  }
  .shot--menu {
    rotate: none;
  }
}
