/* The tilde: the way into the app for somebody signed in.
 *
 * The restraint is deliberate. This screen is passed through many times a day,
 * so it has to be quiet at the tenth visit, not impressive at the first. The
 * motion exists to say "this settled just now" and then get out of the way —
 * one short fade with a small stagger, nothing that loops, nothing that moves
 * after the page is still.
 *
 * Everything honours prefers-reduced-motion at the bottom. */

/* This block does its own scrolling, and that is deliberate rather than tidy.
 *
 * The app shell is built for the editor: .page-container is height:100vh with
 * overflow:hidden, and .main-content hides overflow too, because the editor
 * scrolls its own panes inside that frame. A tilde with more items than fit
 * was simply clipped — no scrollbar, and the list stopped part-way down.
 *
 * The fix stays inside .tilde, a class used nowhere else. Relaxing overflow on
 * .page-container or .main-content would have fixed this screen and broken the
 * editor, which is the trade nobody wants.
 *
 * flex:1 claims the height left under the header; min-height:0 is what lets a
 * flex item shrink below its content, without which overflow-y has nothing to
 * do; width:100% matters because .main-content is a flex column, and without
 * it the block shrinks to its content and a 62rem max-width means nothing — it
 * rendered at 408px in a 1440px window. */
.tilde {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  width: 100%;
  max-width: 62rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

/* --- header ------------------------------------------------------------- */

.tilde-header {
  margin-bottom: 3rem;
}

/* The tilde is the title. It is set large because it is the only mark on the
   page, and the eye needs one thing to land on. */
.tilde-mark {
  font-size: 4rem;
  line-height: 1;
  font-weight: 300;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  color: var(--text-primary, #111);
  animation: tilde-settle 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.tilde-subtitle {
  margin: 0;
  color: var(--text-secondary, #666);
  font-size: 1rem;
  animation: tilde-settle 420ms cubic-bezier(0.2, 0.8, 0.2, 1) 60ms both;
}

/* --- counts ------------------------------------------------------------- */

/* Five cards on one line wherever the row is wide enough, and never fewer than
   two — the first version asked for 8.5rem each and broke into three ragged
   rows once the sidebar took its share of the width. */
.tilde-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.625rem;
  margin-bottom: 3rem;
}

.tilde-count {
  padding: 1rem 0.875rem;
  border: 1px solid var(--border-color, #e6e6e6);
  border-radius: 0.75rem;
  background: var(--surface, #fff);
  /* --i is set per card in the view, so the row resolves left to right. */
  animation: tilde-settle 420ms cubic-bezier(0.2, 0.8, 0.2, 1) calc(80ms + var(--i, 0) * 45ms) both;
  transition: border-color 160ms ease, transform 160ms ease;
}

.tilde-count:hover {
  border-color: var(--text-secondary, #999);
  transform: translateY(-1px);
}

.tilde-count strong {
  display: block;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums; /* numbers stop jittering as they change */
  color: var(--text-primary, #111);
}

.tilde-count span {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--text-secondary, #666);
}

/* --- sections and lists -------------------------------------------------- */

.tilde-section {
  margin-bottom: 3rem;
  animation: tilde-settle 420ms cubic-bezier(0.2, 0.8, 0.2, 1) 160ms both;
}

.tilde-section h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary, #666);
  margin: 0 0 0.875rem;
}

.tilde-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border-color, #eee);
}

.tilde-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.25rem;
  border-bottom: 1px solid var(--border-color, #eee);
  animation: tilde-settle 380ms cubic-bezier(0.2, 0.8, 0.2, 1) calc(180ms + var(--i, 0) * 30ms) both;
  transition: background-color 140ms ease, padding-left 140ms ease;
}

/* The row slides a hair on hover — enough to feel live, not enough to reflow
   anything next to it. */
.tilde-list li:hover {
  background: var(--surface-hover, #fafafa);
  padding-left: 0.625rem;
}

.tilde-link {
  color: var(--text-primary, #111);
  text-decoration: none;
  font-size: 0.9375rem;
  overflow-wrap: anywhere; /* paths are long and must not push the date off */
}

.tilde-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.tilde-list time {
  flex: none;
  font-size: 0.8125rem;
  color: var(--text-tertiary, #999);
  font-variant-numeric: tabular-nums;
}

/* --- empty state --------------------------------------------------------- */

.tilde-empty {
  color: var(--text-secondary, #666);
  font-size: 0.9375rem;
  margin: 0;
}

.tilde-cta {
  color: var(--text-primary, #111);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* --- the sweep, shared ---------------------------------------------------- */

/* One definition for every tilde in the product: the 22px mark in the landing
   header and the 4rem mark at the top of this page. They are the same symbol,
   so they must not drift apart — this file is loaded from the layout, which is
   what makes it reachable from the landing page too.
 *
 * Two things make it portable. The base stops are currentColor, so the mark
 * inherits whatever colour its context sets instead of naming one; and the
 * accent carries a literal fallback, because --ntabs-primary is scoped to
 * .home-page and does not resolve anywhere else.
 *
 * background-clip:text paints the gradient through the glyph, so the stroke
 * itself fills rather than a box behind it. The amber band is narrow on
 * purpose: it lights a part at a time, so #f7b500 never has to carry the whole
 * mark at white-background contrast. */
.tilde-sweep {
  /* Not cosmetic — the effect depends on it. The gradient is sized to the
     element's BOX, not to the glyph, so a full-width block makes the band wider
     than the mark and the whole stroke flashes amber at once instead of
     filling. The h1 on this page is 944px wide around a 40px glyph, and that is
     exactly what it looked like before this line. */
  display: inline-block;
  background-image: linear-gradient(
    90deg,
    currentColor 0%,
    currentColor 35%,
    var(--ntabs-primary, #f7b500) 50%,
    currentColor 65%,
    currentColor 100%
  );
  background-size: 300% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: tilde-sweep 7s ease-in-out infinite;
}

/* The cycle is mostly stillness: the fill takes 22% and the rest is the
   resting state. Anything faster reads as a loading spinner. */
@keyframes tilde-sweep {
  0% {
    background-position: 100% 0;
  }
  22% {
    background-position: 0% 0;
  }
  100% {
    background-position: 0% 0;
  }
}

/* The big mark settles once on arrival AND sweeps forever, so both animations
   are named here — the shorthand on .tilde-sweep would otherwise replace the
   settle, and the mark would appear without the page's entrance. */
.tilde-mark.tilde-sweep {
  animation:
    tilde-settle 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both,
    tilde-sweep 7s ease-in-out infinite;
}

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

@keyframes tilde-settle {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Somebody who asked the system for less motion gets none of it, and still
   gets the page — `both` on the animations above would otherwise leave every
   element stuck at opacity 0. */
@media (prefers-reduced-motion: reduce) {
  .tilde-mark,
  .tilde-subtitle,
  .tilde-count,
  .tilde-section,
  .tilde-list li,
  /* .tilde-mark.tilde-sweep is listed on its own because it is more specific
     than .tilde-mark, and would otherwise keep animating right here. */
  .tilde-mark.tilde-sweep,
  .tilde-sweep {
    animation: none;
  }

  /* The gradient has to be undone too, not just the animation — leaving
     text-fill-color:transparent behind would render the mark invisible. */
  .tilde-sweep {
    background-image: none;
    -webkit-text-fill-color: currentColor;
  }

  .tilde-count,
  .tilde-list li {
    transition: none;
  }
}

@media (max-width: 640px) {
  .tilde {
    padding: 2.5rem 1rem 4rem;
  }

  .tilde-mark {
    font-size: 3rem;
  }
}
