/*
 * barycenter.wiki
 *
 * Colour follows bary-blocks/colors.md: a colour is named for its purpose, not
 * its value, and one name resolves to four values across two independent axes —
 * light/dark and default/increased contrast.
 *
 * Two layers, so every value is written exactly once:
 *   1. Palette   Apple's system greys and blues, sRGB. light-dark() carries the
 *                appearance axis; the prefers-contrast block carries the other.
 *   2. Semantic  The names the interface actually uses. These only ever point
 *                at palette tokens, so raising contrast re-points the palette
 *                and every role follows without being restated.
 */

:root {
  /*
   * Dark unless the reader picks otherwise. The system preference is
   * deliberately not consulted, so `light-dark()` resolves dark by default and
   * [data-theme='light'] is the only thing that flips it.
   */
  color-scheme: dark;

  /* ----------------------------------------------------- 1. palette */
  /*                        light      dark    */
  --base: light-dark(#ffffff, #000000);
  --ink: light-dark(#1c1c1e, #f2f2f7);
  --gray-strong: light-dark(#6c6c70, #aeaeb2);
  --gray: light-dark(#8e8e93, #8e8e93);
  --gray-2: light-dark(#aeaeb2, #636366);
  --gray-3: light-dark(#c7c7cc, #48484a);
  --gray-4: light-dark(#d1d1d6, #3a3a3c);
  --gray-5: light-dark(#e5e5ea, #2c2c2e);
  --gray-6: light-dark(#f2f2f7, #1c1c1e);
  --blue: light-dark(#0088ff, #0091ff);
  /*
   * Green and red for the copy result. The light values are darker than
   * Apple's #34c759 and #ff3b30, which measure 1.9:1 and 3.6:1 on white and
   * are unreadable at the 13px the flash is set in. These measure 5.39 and
   * 5.38 — deliberately equal, so neither outcome shouts louder than the
   * other.
   */
  --green: light-dark(#1f7a35, #30d158);
  --red: light-dark(#d70015, #ff453a);

  /* ---------------------------------------------------- 2. semantic */
  --bg: var(--base);
  --surface: var(--gray-6);
  --surface-strong: var(--gray-5);

  --text-primary: var(--ink);
  --text-secondary: var(--gray-strong);
  --text-tertiary: var(--gray);
  --text-quaternary: var(--gray-2);
  --text-placeholder: var(--gray);

  --separator: var(--gray-4);
  --separator-opaque: var(--gray-3);
  --link: var(--blue);
  --success: var(--green);
  --danger: var(--red);

  /* ------------------------------------------------------ 3. metrics */
  --font: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco,
    "Cascadia Mono", "Roboto Mono", Consolas, "Liberation Mono", monospace;
  --text-size: 1rem;
  --text-small: 0.875rem;
  --text-tiny: 0.8125rem;
  --line-height: 1.6;

  /*
   * Every dimension on the page is a multiple of 16px (1rem), with 8px as the
   * only half-step. Line-heights inside fixed-height boxes are given in rem
   * rather than as a ratio, because a ratio on a 13px or 20px font lands off
   * the grid.
   */

  /* The reading column. Change it here and nowhere else. */
  --measure: 60rem;
  --gutter: 2rem;

  /* Listing columns. Date is zero-padded, so the column is a fixed width. */
  --col-size: 5rem;
  --col-date: 10rem;

  --radius: 6px;
  --speed: 0.18s;
}

/* Increased contrast pulls the palette apart. The semantic layer is untouched. */
@media (prefers-contrast: more) {
  :root {
    --ink: light-dark(#000000, #ffffff);
    --gray-strong: light-dark(#48484a, #c7c7cc);
    --gray: light-dark(#6c6c70, #aeaeb2);
    --gray-2: light-dark(#8e8e93, #7c7c80);
    --gray-3: light-dark(#aeaeb2, #545456);
    --gray-4: light-dark(#bcbcc0, #444446);
    --gray-5: light-dark(#d8d8dc, #363638);
    --gray-6: light-dark(#ebebf0, #242426);
    --blue: light-dark(#1e6ef4, #5cb8ff);
    --green: light-dark(#1a6b2e, #30db5b);
    --red: light-dark(#c00011, #ff6961);
  }
}

/* The toggle only pins the appearance axis; light-dark() does the rest. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --speed: 0s;
  }
}

/* ===================================================================== base */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-size);
  line-height: var(--line-height);
  font-variant-ligatures: none;
  -webkit-font-smoothing: antialiased;
}

/* Every region of the page sits on this column. */
.wrap {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

a {
  color: var(--link);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration: underline;
}

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

code,
pre,
input,
button {
  font-family: inherit;
}

[hidden] {
  display: none !important;
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: var(--gutter);
  top: 0.5rem;
  z-index: 10;
  background: var(--surface);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
}

/* =================================================================== header */

.site-header {
  border-bottom: 1px solid var(--separator);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: calc(4rem - 1px);
  flex-wrap: wrap;
}

.brand {
  margin-right: auto;
  color: var(--text-primary);
  font-weight: 600;
}

.brand:hover {
  color: var(--link);
  text-decoration: none;
}

/* The mark: two ellipses sharing a focus, the barycenter at that focus. */
.mark {
  display: block;
  overflow: visible;
  flex: none;
}

.mark .orbit {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  opacity: 0.4;
}

.mark .body {
  fill: currentColor;
}

.mark .center {
  fill: var(--link);
}

.link-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--text-tiny);
  /* The brackets mark it as a control, so it needs no underline as well. */
  text-decoration: none;
  cursor: pointer;
}

.link-button:hover {
  color: var(--text-primary);
}

/* ===================================================================== page */

main {
  padding-block: 3rem 5rem;
}

h1,
h2,
h3 {
  line-height: 1.3;
  font-weight: 600;
}

.page-title {
  font-size: 1.25rem;
  line-height: 2rem;
  letter-spacing: -0.01em;
  margin: 0;
}

.lede,
.hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.hero .page-title {
  margin-bottom: 0.25rem;
}

/* ================================================================== listing */

/* A directory index: name, size, date. The row is the copy button. */
.cell {
  display: grid;
  grid-template-columns: 1fr var(--col-size) var(--col-date);
  gap: 0 1rem;
  /*
   * Centred, not baseline-aligned. The size and date columns are 14px against
   * the name's 16px, and aligning three different baselines inside one row
   * grows it past the 32px the grid asks for.
   */
  align-items: center;
}

.folder {
  margin-top: 2rem;
}

/* The column header used to sit above the first section and carry this gap. */
.folder:first-child {
  margin-top: 0;
}

.folder-name {
  margin: 0 0 0.5rem;
  padding-inline: 0.5rem;
  color: var(--text-secondary);
  font-size: var(--text-small);
  line-height: 1.5rem;
  font-weight: 600;
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--separator);
}

.row {
  border-bottom: 1px solid var(--separator);
}

.row:hover {
  background: var(--surface);
}

.cell {
  width: 100%;
  /* A fixed 2rem band with everything centred in it, rather than a height
   * assembled out of line boxes and padding that three font sizes can push
   * off the grid. */
  height: 2rem;
  padding: 0 0.5rem;
  background: none;
  border: 0;
  border-radius: var(--radius);
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

/* The name is the only elastic column, so it is the one that truncates. */
.col-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dir {
  color: var(--text-tertiary);
}

.file {
  color: var(--link);
}

.row:hover .file {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/*
 * The /backend rows report a value rather than doing something, so they take
 * none of a control's affordances: no hover shading, no underline, no pointer,
 * and the name is body text rather than link blue.
 */
.row-plain:hover {
  background: none;
}

.row-plain .cell {
  cursor: default;
}

.row-plain .file {
  color: var(--text-primary);
}

.row-plain:hover .file {
  text-decoration: none;
}

.col-size,
.col-date {
  color: var(--text-tertiary);
  font-size: var(--text-small);
  white-space: nowrap;
}

.col-size,
.col-date {
  text-align: right;
}

/* `/backend` reports the breakpoint ladder, which is a longer string than any
 * date. The column is widened for that section alone so the file listings keep
 * their proportions; rows still line up with each other within the section. */
.folder-backend {
  --col-date: 15rem;
}

.flash {
  margin-left: 0.5rem;
  color: var(--success);
  font-size: var(--text-tiny);
}

.cell[data-state="error"] .flash {
  color: var(--danger);
}

/* =================================================================== footer */

.site-footer {
  border-top: 1px solid var(--separator);
  color: var(--text-tertiary);
  font-size: var(--text-tiny);
}

.site-footer .wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem 1rem;
  min-height: calc(4rem - 1px);
  flex-wrap: wrap;
}

.site-footer a {
  color: var(--text-tertiary);
}

.site-footer a:hover {
  color: var(--link);
}

/* =================================================================== narrow */

/* Two tiers, 767 and 1200, matching mlot.ai so the numbers are the same across
 * projects. Each one drops a column rather than reflowing: the listing is a
 * table and a wrapped table row is unreadable.
 *
 * Size is the first thing to go: when a block was last touched says more than
 * how many bytes it is. */
@media (max-width: 1200px) {
  .cell {
    grid-template-columns: 1fr var(--col-date);
  }

  .col-size {
    display: none;
  }
}

/* Below 767 only the name is worth the width. */
@media (max-width: 767px) {
  .cell {
    grid-template-columns: 1fr;
  }

  .col-date {
    display: none;
  }
}
