/* onuohasilver.github.io — one page, set as carefully as a printed page. */

:root {
  --bg:      #fcfbf9;
  --ink:     #1a1917;
  --muted:   #6b6762;
  --rule:    #e4e0d8;
  --accent:  #a8431f;

  --serif: "Newsreader", ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --measure: 33rem;
  --step:    1.6em;

  /* Behind product names. Not an underline — underlined prose reads as a
     link, and these aren't clickable. */
  --wash: rgba(168, 67, 31, 0.12);
  --wash-press: rgba(168, 67, 31, 0.26);

  --surface: #ffffff;
  --shadow:  0 1px 2px rgba(26, 25, 23, 0.05),
             0 10px 28px -8px rgba(26, 25, 23, 0.16);

  /* The built-in curves are too weak to read as deliberate. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:     #121110;
    --ink:    #ecebe7;
    --muted:  #918c84;
    --rule:   #2b2926;
    --accent: #e08a62;
    --wash:       rgba(224, 138, 98, 0.17);
    --wash-press: rgba(224, 138, 98, 0.34);
    --surface: #1d1c1a;
    --shadow:  0 1px 2px rgba(0, 0, 0, 0.45),
               0 12px 32px -10px rgba(0, 0, 0, 0.7);
  }
  body { font-weight: 380; }
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: clamp(3.5rem, 9vw, 8rem) 1.5rem clamp(5rem, 12vw, 9rem);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: clamp(1.0625rem, 0.95rem + 0.4vw, 1.1875rem);
  font-weight: 350;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  max-width: var(--measure);
  margin-inline: auto;
}

/* ── Header ─────────────────────────────────────────────── */

header { margin-bottom: calc(var(--step) * 1.75); }

h1 {
  margin: 0;
  width: fit-content;
  max-width: 100%;
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 1.9rem);
  font-weight: 400;
  letter-spacing: -0.012em;
  line-height: 1.2;
  text-wrap: balance;
}

.meta {
  margin: 0.7em 0 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Prose ──────────────────────────────────────────────── */

p {
  margin: 0 0 var(--step);
  text-wrap: pretty;
}

.lede {
  font-size: 1.22em;
  line-height: 1.5;
  letter-spacing: -0.006em;
}

/* Product names. Weight, not bluster — over a wash that wipes itself in. */
b, a[data-proj] {
  position: relative;
  z-index: 0;
  font-weight: 500;
  letter-spacing: 0.002em;
}

b::after, a[data-proj]::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -0.08em -0.1em -0.02em;
  border-radius: 2px;
  background: var(--wash);
  transform-origin: 0 50%;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 0.055em;
  text-underline-offset: 0.2em;
  transition:
    color 180ms ease,
    opacity 180ms ease,
    text-decoration-color 180ms ease,
    text-underline-offset 200ms var(--ease-out);
}

/* Touch fires a false hover on tap, so motion stays behind a real pointer. */
@media (hover: hover) and (pointer: fine) {
  a:hover {
    color: var(--accent);
    text-decoration-color: currentColor;
    text-underline-offset: 0.26em;
  }
}

a:active {
  color: var(--accent);
  opacity: 0.6;
  transition-duration: 80ms;
}

a:focus-visible {
  color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 0.25em;
  border-radius: 1px;
}

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

/* ── Footer ─────────────────────────────────────────────── */

footer {
  margin-top: calc(var(--step) * 1.5);
  padding-top: var(--step);
  border-top: 1px solid var(--rule);
  color: var(--muted);
}

footer p {
  margin: 0;
  font-size: 0.95em;
}

footer a { color: var(--ink); }

/* ── Scroll rail ────────────────────────────────────────── */
/* Pure CSS scroll-driven, so it runs off the main thread. Where
   animation-timeline isn't supported it stays at scaleX(0) — invisible,
   which is the right failure. */

.progress {
  position: fixed;
  inset: 0 0 auto;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 10;
}

@supports (animation-timeline: scroll()) {
  .progress {
    animation: progress linear both;
    animation-timeline: scroll(root block);
  }
}

@keyframes progress {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ── Arrival ────────────────────────────────────────────── */
/* Hidden only while JS is confirmed live: the head script sets .js and
   clears it again if motion.js never checks in, so a failed script can
   never leave the page blank. */

.js main > *:not(.lede) { opacity: 0; }

.js main > *.in:not(.lede) {
  animation: rise 640ms var(--ease-out) both;
  animation-delay: var(--delay, 0ms);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(0.6rem); }
  to   { opacity: 1; transform: none; }
}

/* The lede resolves word by word, so the block itself must not also move. */
.js .lede .w {
  display: inline-block;
  opacity: 0;
}

.js .lede.in .w {
  animation: word 480ms var(--ease-out) both;
  animation-delay: calc(var(--delay, 0ms) + var(--i) * 16ms);
}

@keyframes word {
  from { opacity: 0; transform: translateY(0.42em); }
  to   { opacity: 1; transform: none; }
}

/* The wash is drawn across a product name once its paragraph has landed. */
.js b::after,
.js a[data-proj]::after { transform: scaleX(0); }

.js .in b::after,
.js .in a[data-proj]::after {
  animation: draw 520ms var(--ease-out) both;
  animation-delay: var(--delay, 0ms);
}

@keyframes draw {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ── Project previews ───────────────────────────────────── */
/* A name is only interactive once JS has wired it up, so the cursor and
   focus ring are scoped to the attribute the script looks for. */

b[data-proj] { cursor: help; }

/* Touch has no hover, so the press itself has to answer. Applies to any
   tagged name, linked or not. */
b[data-proj]::after,
a[data-proj]::after { transition: background-color 120ms ease; }

b[data-proj]:active::after,
a[data-proj]:active::after { background: var(--wash-press); }

/* A project with a public home is a real link: it keeps the underline, so
   the wash alone never promises something clickable. */
a[data-proj] { cursor: pointer; }

b[data-proj]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0.2em;
  border-radius: 2px;
}

.peek {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  width: min(19rem, calc(100vw - 24px));
  pointer-events: none;   /* never let the card block the prose under it */
}

/* Only a move between names glides; a fresh open appears where it belongs. */
.peek.glide { transition: transform 220ms var(--ease-out); }

.peek-inner {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 7px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(4px) scale(0.975);
  transform-origin: var(--anchor, 50%) 100%;
  transition: opacity 120ms ease, transform 120ms var(--ease-out);
}

.peek.below .peek-inner {
  transform: translateY(-4px) scale(0.975);
  transform-origin: var(--anchor, 50%) 0;
}

.peek.on .peek-inner {
  opacity: 1;
  transform: none;
  transition-duration: 190ms;
}

/* Content changing under a sliding card would hard-cut, so it dips. */
.peek.swap .peek-shot,
.peek.swap .peek-body {
  animation: swapfade 200ms var(--ease-out) both;
}

@keyframes swapfade {
  from { opacity: 0.15; }
  to   { opacity: 1; }
}

.peek-shot {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px 6px 0 0;
  border-bottom: 1px solid var(--rule);
  background: var(--rule);   /* a quiet placeholder before it decodes */
  opacity: 0;
  transition: opacity 200ms ease;
}

.peek-shot.ready { opacity: 1; }

.peek-body { padding: 0.8rem 0.95rem 0.9rem; }

/* The notch points back at the name the card belongs to. */
.peek-inner::after {
  content: "";
  position: absolute;
  left: var(--anchor, 50%);
  bottom: -5px;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  transform: rotate(45deg);
}

.peek.below .peek-inner::after {
  bottom: auto;
  top: -5px;
  border: 0;
  border-left: 1px solid var(--rule);
  border-top: 1px solid var(--rule);
}

.peek-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.peek-mark > * {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.peek.on .peek-mark > * {
  animation: drawmark 340ms var(--ease-out) both;
  animation-delay: calc(var(--k, 0) * 45ms);
}

@keyframes drawmark {
  to { stroke-dashoffset: 0; }
}

.peek-mark {
  flex: none;
  width: 30px;
  height: 30px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.peek-id { display: flex; flex-direction: column; }

.peek-title {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.25;
}

.peek-kind {
  margin-top: 0.2em;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.peek-desc {
  margin: 0.65rem 0 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
}

.peek-link {
  display: block;
  margin-top: 0.4em;
  color: var(--accent);
}

.peek-stack {
  margin: 0.62rem 0 0;
  padding-top: 0.55rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* ── The cat ────────────────────────────────────────────── */
/* Sleeps in the corner, sits up when you scroll, dozes off again. */

.cat {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 64px;
  height: 64px;
  z-index: 15;
  cursor: pointer;
  opacity: 0;
  transition: opacity 600ms var(--ease-out);
}

.cat.ready { opacity: 1; }

.cat svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cat-sleep,
.cat-wake,
.cat-z { transition: opacity 280ms var(--ease-out); }

.cat-wake { opacity: 0; }
.cat.awake .cat-wake { opacity: 1; }
.cat.awake .cat-sleep,
.cat.awake .cat-z { opacity: 0; }

.cat-pupil {
  fill: var(--accent);
  stroke: none;
  transition: transform 200ms var(--ease-out);
}

.cat-z text {
  fill: var(--accent);
  stroke: none;
  font-family: var(--mono);
  font-size: 13px;
}

@media (prefers-reduced-motion: no-preference) {
  .cat:not(.awake) .cat-sleep {
    animation: breathe 3.8s ease-in-out infinite;
    transform-box: fill-box;
    transform-origin: 50% 100%;
  }

  .cat.awake .cat-tail {
    animation: sway 2.6s ease-in-out infinite alternate;
    transform-box: fill-box;
    transform-origin: 0% 100%;
  }

  .cat-z .z1 { animation: zfloat 3.2s ease-out infinite; }
  .cat-z .z2 { animation: zfloat 3.2s ease-out infinite 1.05s; }
  .cat-z .z3 { animation: zfloat 3.2s ease-out infinite 2.1s; }

  .cat.boop .cat-wake {
    animation: boop 420ms var(--ease-out);
    transform-box: fill-box;
    transform-origin: 50% 100%;
  }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.035); }
}

@keyframes sway {
  from { transform: rotate(-7deg); }
  to   { transform: rotate(7deg); }
}

@keyframes zfloat {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.8); }
  22%  { opacity: 1; }
  100% { opacity: 0; transform: translate(4px, -15px) scale(1.1); }
}

@keyframes boop {
  0%   { transform: scale(1); }
  35%  { transform: scale(0.9) translateY(3px); }
  100% { transform: scale(1); }
}

@media (max-width: 520px) {
  .cat { width: 52px; height: 52px; right: 12px; bottom: 12px; }
}

/* ── The name, on hover ─────────────────────────────────── */
/* A single accent wipe across the text. One element, no letter spans,
   so selection and screen readers are untouched. */

@media (hover: hover) and (pointer: fine) {
  h1 {
    background-image: linear-gradient(
      100deg,
      var(--accent) 0 46%,
      var(--ink)   54% 100%
    );
    background-size: 200% 100%;
    background-position: 100% 0;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    transition: background-position 560ms var(--ease-out);
  }

  h1:hover { background-position: 0 0; }
}

/* Never let the clip trick swallow the name. */
@media (forced-colors: active) {
  h1 {
    background: none;
    color: CanvasText;
    -webkit-text-fill-color: CanvasText;
  }
  b::after { display: none; }
}

/* ── Reduced motion ─────────────────────────────────────── */
/* Fewer and gentler, not none: the page still resolves, it just doesn't
   travel. Declared in CSS as well as JS so it holds even in the gap
   before the script runs. */

@media (prefers-reduced-motion: reduce) {
  .js main > *,
  .js .lede .w {
    opacity: 1 !important;
    animation: none !important;
    transform: none !important;
  }

  .js b::after,
  .js a[data-proj]::after,
  .js .in b::after,
  .js .in a[data-proj]::after {
    animation: none !important;
    transform: scaleX(1) !important;
  }

  .progress { animation: none; }

  a { transition: color 120ms ease, opacity 120ms ease; }
  h1 { transition: none; }

  .peek.glide { transition: none; }

  .peek-inner,
  .peek.below .peek-inner,
  .peek.on .peek-inner {
    transform: none;
    transition: opacity 120ms ease;
  }

  .peek.swap .peek-shot,
  .peek.swap .peek-body { animation: none; }

  .peek-mark > *,
  .peek.on .peek-mark > * {
    stroke-dashoffset: 0;
    animation: none;
  }
}

/* ── Print ──────────────────────────────────────────────── */

@media print {
  :root { --bg: #fff; --ink: #000; --muted: #444; --rule: #bbb; --accent: #000; }
  body { padding: 0; font-size: 11pt; }
  .progress, .peek, .cat { display: none; }

  .js main > *,
  .js .lede .w {
    opacity: 1 !important;
    animation: none !important;
    transform: none !important;
  }

  .js b::after,
  .js a[data-proj]::after { transform: scaleX(1) !important; animation: none !important; }

  h1 { background: none; color: #000; -webkit-text-fill-color: #000; }
  a { text-decoration-color: var(--rule); }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: var(--muted); }
}
