/* nevermind.dev */

@font-face {
  font-family: "Instrument Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/instrument-serif-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/fonts/geist-mono.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #11171e;
  --fg: #ece7da;
  --muted: #8f969e;
  --faint: #ece7da5e; /* crossed-out text */
  --rule: #ece7da1f;
  --accent: #cfdb5f; /* strokes, caret */
  --accent-ink: #cfdb5f; /* accent as text */
  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter: clamp(1.25rem, 5vw, 4.5rem);
}

/* Light, when picked with the switch (data-theme on <html>, set by theme.js before the first paint) … */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f0e8;
  --fg: #141c25;
  --muted: #5c636b;
  --faint: #141c2566;
  --rule: #141c2521;
  --accent: #a9b625;
  --accent-ink: #646e0a;
}

/* … or when the system is light and dark wasn't picked. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f3f0e8;
    --fg: #141c25;
    --muted: #5c636b;
    --faint: #141c2566;
    --rule: #141c2521;
    --accent: #a9b625;
    --accent-ink: #646e0a;
  }
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 400 0.9375rem/1.6 var(--mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  flex: 1;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
  transition: text-decoration-color 0.2s ease, color 0.2s ease;
}

a:hover {
  text-decoration-color: var(--accent);
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.wrap {
  width: 100%;
  max-width: 80rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---- Colour scheme switch (shown once theme.js has run) ------------------ */

.top {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  padding-block: clamp(0.75rem, 2.5vh, 1.5rem);
}

.theme {
  display: none;
  margin-inline-end: -0.45rem;
  font-size: 0.8125rem;
}

.can-theme .theme {
  display: flex;
}

.theme button {
  padding: 0.4rem 0.45rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  transition: color 0.2s ease;
}

.theme button:hover {
  color: var(--fg);
}

/* The current choice gets the full stop. Decided, for now. */
.theme button::after {
  content: ".";
  content: "." / "";
  color: var(--accent-ink);
  visibility: hidden;
}

:root:not([data-theme]) [data-theme-choice="auto"],
:root[data-theme="light"] [data-theme-choice="light"],
:root[data-theme="dark"] [data-theme-choice="dark"] {
  color: var(--fg);
}

:root:not([data-theme]) [data-theme-choice="auto"]::after,
:root[data-theme="light"] [data-theme-choice="light"]::after,
:root[data-theme="dark"] [data-theme-choice="dark"]::after {
  visibility: visible;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.35s;
}

/* ---- The first screen: a thought, crossed out, taken back ---------------- */

.intro {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 2.5rem;
  padding-block: clamp(3rem, 10vh, 7rem) clamp(1.25rem, 4vh, 2.5rem);
}

.hero {
  align-self: center;
  margin-bottom: 4vh; /* a little above the middle looks centred */
}

.thought-line {
  position: relative;
  font: italic 400 clamp(3rem, 1.4rem + 7vw, 8rem) / 1.02 var(--serif);
  letter-spacing: -0.015em;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.thought {
  color: var(--faint);
  text-decoration-line: line-through;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 0.06em;
  text-decoration-skip-ink: none;
}

.strike {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.strike path {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
}

.nvm-line {
  display: flex;
  margin: 0.14em 0 0;
  /* 13ch plus caret must fit next to the gutters, even at 320px: 8.4 ≈ 14ch × 0.6em */
  font: 500 min(clamp(2.5rem, 1rem + 5vw, 5.5rem), (100vw - 2 * var(--gutter)) / 8.4) / 1.1 var(--mono);
  letter-spacing: 0;
}

/* Monospace, so the typing is just a width in ch: "nevermind." is 10, ".dev" makes 13. */
.nvm {
  flex: none;
  width: 13ch;
  overflow: hidden;
  white-space: nowrap;
}

.dot {
  color: var(--accent-ink);
}

.tld {
  color: var(--muted);
}

.caret {
  flex: none;
  width: 0.5ch;
  height: 0.78em;
  margin: 0.19em 0 0 0.1em;
  background: var(--accent);
  border-radius: 1px;
  animation: blink 1.1s steps(1) infinite;
}

/* main.js takes over: hidden until it is ready, shown as-is if it never shows up. */
@media (scripting: enabled) {
  [data-hero]:not(.live) {
    animation: wait-for-js 0s 1.5s backwards;
  }
}

.live .thought {
  color: var(--fg);
  text-decoration-line: none;
  transition: color 0.6s ease;
}

.live.struck .thought {
  color: var(--faint);
}

.live .thought-line {
  opacity: 0;
  translate: 0 0.14em;
  filter: blur(0.08em);
}

.live.shown .thought-line {
  opacity: 1;
  translate: none;
  filter: none;
  transition: opacity 0.6s ease, translate 0.9s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.7s ease;
}

.live:not(.typed) .nvm {
  width: 0;
}

.live.typed .nvm {
  animation: type 1.15s;
}

/* Solid while typing, a few blinks, then still. Its own name, so it restarts instead of carrying on mid-blink. */
.live.typed .caret {
  animation: settle 1.1s steps(1) 1.4s 4;
}

.live.undo .nvm {
  animation: untype 0.45s steps(13, end) forwards;
}

.live.out .thought-line,
.live.out .nvm-line {
  opacity: 0;
  transition: opacity 0.22s ease-in;
}

@keyframes type {
  0% { width: 0; animation-timing-function: steps(10, end); }
  50% { width: 10ch; animation-timing-function: step-end; }
  80% { width: 10ch; animation-timing-function: steps(3, end); }
  100% { width: 13ch; }
}

@keyframes untype {
  from { width: 13ch; }
  to { width: 0; }
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes settle {
  50% { opacity: 0; }
}

@keyframes wait-for-js {
  from { opacity: 0; }
}

/* ---- Bottom bar of the first screen -------------------------------------- */

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.again-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.again {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.15rem 0.65rem 0.95rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.again:hover {
  border-color: var(--accent);
}

.again svg {
  width: 1.05em;
  height: 1.05em;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: rotate 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.again:hover svg {
  rotate: 180deg;
}

.count {
  font-variant-numeric: tabular-nums;
}

.cue {
  color: var(--muted);
  text-decoration: none;
}

.cue:hover {
  color: var(--fg);
}

/* ---- dev.nevermind.* ------------------------------------------------------ */

.apps {
  padding-block: clamp(4rem, 12vh, 8rem) clamp(3rem, 8vh, 5rem);
}

.apps-head {
  display: grid;
  gap: 0.75rem;
  margin-bottom: clamp(2rem, 5vh, 3rem);
}

.kicker {
  color: var(--accent-ink);
  font-size: 0.8125rem;
}

.apps h2 {
  margin: 0;
  font: italic 400 clamp(2.75rem, 1.75rem + 3.2vw, 4.5rem) / 1 var(--serif);
  letter-spacing: -0.01em;
}

.app-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 25rem), 1fr));
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 1.25rem;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
  align-items: center;
  column-gap: 1.25rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--bg);
}

/* Icon and name side by side, everything else gets the full width. */
.app > :not(.app-icon, .app-head) {
  grid-column: 1 / -1;
}

.app-icon,
.app-icon img {
  display: block;
  width: 3.5rem;
  height: 3.5rem;
}

.app-id {
  color: var(--muted);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.app h3 {
  margin: 0.15rem 0 0;
  font-size: 1.125rem;
  font-weight: 500;
}

.app h3 a {
  text-decoration: none;
}

.app h3 a:hover {
  color: var(--accent-ink);
}

.app h3 a::after {
  content: "↗";
  content: "↗" / "";
  margin-left: 0.4em;
  color: var(--muted);
  font-weight: 400;
}

.app-desc {
  margin-top: 1rem;
  max-width: 48ch;
  text-wrap: pretty;
}

.app-meta {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.cmd {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding: 0.5rem 0.5rem 0.5rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 0.75rem;
  font-size: 0.8125rem;
}

.cmd code {
  flex: 1;
  min-width: 0;
  font: inherit;
}

.cmd code::before {
  content: "$ ";
  content: "$ " / "";
  color: var(--muted);
}

.copy {
  flex: none;
  align-self: flex-start;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 0.5rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.copy:hover {
  color: var(--fg);
  border-color: var(--accent);
}

/* ---- Footer --------------------------------------------------------------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-block: 1.75rem 2.25rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.8125rem;
}

.foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
}

.foot a {
  color: var(--fg);
}

/* ---- Less motion: same page, no choreography ------------------------------ */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .live .thought,
  .live.shown .thought-line,
  .live.out .thought-line,
  .live.out .nvm-line,
  .again svg {
    transition: none;
  }

  .caret,
  .live.typed .caret,
  .live.typed .nvm {
    animation: none;
  }
}
