/* lonelybytes.com
 *
 * Monospace is the display voice — this is an Apple developer's site, so
 * ui-monospace and system-ui resolve to SF Mono and SF Pro with no webfont,
 * no CDN, and no flash of fallback text. Cool neutrals against a deep teal;
 * Ångström is a unit of length, and the archive is drawn as a ruler.
 */

:root {
  --bg: #F4F7F7;
  --surface: #FFFFFF;
  --ink: #14181A;
  --muted: #4E5A5D;
  --faint: #79868A;
  --rule: #DCE4E4;
  --accent: #0F6E64;
  --accent-soft: #0F6E6414;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --col: 68ch;
  --rail: 4.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1214;
    --surface: #161B1D;
    --ink: #E4EAE9;
    --muted: #9AA6A9;
    --faint: #6B787B;
    --rule: #242D30;
    --accent: #45B8A6;
    --accent-soft: #45B8A61A;
  }
}

/* ---- reset ---------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, h1, h2, h3, h4, p, figure, blockquote, ul, ol, pre { margin: 0; }
ul, ol { padding: 0; }
img { max-width: 100%; height: auto; display: block; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

.shell {
  max-width: 62rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

/* ---- masthead ------------------------------------------------------- */

.masthead {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 3.5rem;
}

.wordmark {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  display: inline-flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  align-self: flex-start;
}
.wordmark .tick { color: var(--accent); }
.wordmark .sub { color: var(--faint); }

.nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.nav a {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 0.15rem;
  border-bottom: 1px solid transparent;
}
.nav a:hover { color: var(--ink); border-bottom-color: var(--accent); }
.nav a[aria-current] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---- lede ----------------------------------------------------------- */

.lede { max-width: var(--col); display: flex; flex-direction: column; gap: 1.25rem; }
.lede h1 {
  font-family: var(--mono);
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.lede p { color: var(--muted); }
/* Home only. The source is 224px of pixel art shown at 112, so `pixelated`
 * keeps the halving exact on 1x screens instead of smearing the blocks; on a
 * retina display it is 1:1 anyway. Radius matches the app icons (20/88). */
.avatar {
  width: 112px;
  height: 112px;
  border-radius: 26px;
  image-rendering: pixelated;
}
.lede a { color: var(--accent); text-decoration-color: var(--accent-soft); text-underline-offset: 3px; }
.lede a:hover { text-decoration-color: var(--accent); }

/* The standfirst Jiva made every TouchDev article carry. */
.article-abstract {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
  padding-left: 1rem;
  border-left: 2px solid var(--rule);
  margin-bottom: 1.75rem;
}

/* Tables come from the archive only, and one of them is a 30-row list of
 * Objective-C type encodings — so it scrolls rather than squeezing the page. */
.table-scroll { overflow-x: auto; margin: 1.75rem 0; }
.table-scroll table { border-collapse: collapse; font-size: 0.9rem; min-width: 100%; }
.table-scroll th, .table-scroll td {
  text-align: left;
  padding: 0.45rem 0.9rem 0.45rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.table-scroll th { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.04em; color: var(--faint); }
.table-scroll td { white-space: normal; }

.section-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 3.5rem 0 1.5rem;
}

/* ---- the measurement rail ------------------------------------------- */

.rail { display: flex; flex-direction: column; max-width: var(--col); }

.year {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  align-items: start;
  border-top: 1px solid var(--rule);
}

.year-num {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  padding: 1.1rem 0;
}

.year-posts { display: flex; flex-direction: column; }

.post-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: baseline;
  padding: 1.1rem 0;
  text-decoration: none;
}
.post-row:hover .post-title { color: var(--accent); }

.post-title { font-size: 0.95rem; line-height: 1.4; text-wrap: balance; }
.post-date {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The silent years, drawn as real space rather than hidden by pagination. */
.gap {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  align-items: center;
  border-top: 1px solid var(--rule);
  min-height: 6rem;
  background-image: repeating-linear-gradient(to bottom, var(--rule) 0 1px, transparent 1px 12px);
  background-size: 1px 100%;
  background-repeat: no-repeat;
  background-position: 1.4rem 0;
}
.gap-note {
  grid-column: 2;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--faint);
  letter-spacing: 0.04em;
}

.more { margin-top: 2rem; }
.more a {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
}
.more a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- article / prose ------------------------------------------------ */

.article, .prose { max-width: var(--col); }

.article-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--faint);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.article h1, .prose h1 {
  font-family: var(--mono);
  font-size: clamp(1.6rem, 4.5vw, 2.3rem);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.025em;
  text-wrap: balance;
  margin-bottom: 2rem;
}

.article h2, .prose h2 {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin: 2.75rem 0 1rem;
  text-wrap: balance;
}

.article h3, .prose h3,
.article h4, .prose h4 {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
  margin: 2rem 0 0.75rem;
  color: var(--ink);
}

.article p, .prose p { color: var(--muted); margin: 1.15rem 0; }

.article a, .prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 3px;
}
.article a:hover, .prose a:hover { text-decoration-color: var(--accent); }

.article ul, .prose ul, .article ol, .prose ol {
  color: var(--muted);
  margin: 1.15rem 0;
  padding-left: 1.25rem;
}
.article li, .prose li { margin: 0.4rem 0; }

.article strong, .prose strong { color: var(--ink); font-weight: 600; }

.article blockquote, .prose blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 1.25rem;
  margin: 1.75rem 0;
  color: var(--faint);
}
.article blockquote p, .prose blockquote p { color: inherit; }

.article code, .prose code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--accent-soft);
  color: var(--ink);
  /* Negative horizontal margin offsets the padding, so a following period sits
     against the chip instead of drifting away from it. */
  padding: 0.1em 0.3em;
  margin: 0 -0.15em;
  border-radius: 3px;
}

.article pre, .prose pre {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 1.75rem 0;
  line-height: 1.55;
}
.article pre code, .prose pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.8rem;
  color: var(--ink);
}

.article figure, .prose figure { margin: 2rem 0; }
.article figure img, .prose figure img {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
}
/* TouchDev floated some images and let the text wrap; below 34rem there is no
 * room to wrap around anything, so they go back to being full-width. */
.article figure.figure-left, .article figure.figure-right { max-width: 50%; margin: 0.4rem 0 1rem; }
.article figure.figure-left { float: left; margin-right: 1.75rem; }
.article figure.figure-right { float: right; margin-left: 1.75rem; }
.article h2, .article h3, .article hr { clear: both; }

@media (max-width: 34rem) {
  .article figure.figure-left, .article figure.figure-right {
    float: none;
    max-width: 100%;
    margin: 2rem 0;
  }
}

.article figcaption, .prose figcaption {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--faint);
  margin-top: 0.6rem;
  line-height: 1.5;
}

.article hr, .prose hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

.article table, .prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1.75rem 0;
}
.article th, .prose th, .article td, .prose td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}
.article th, .prose th { font-family: var(--mono); font-size: 0.75rem; color: var(--faint); font-weight: 500; }

.tags { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 2.5rem; }
.tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
}

.pager {
  max-width: var(--col);
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.pager a {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
}
.pager a:hover { color: var(--accent); }

/* ---- mail ----------------------------------------------------------- */

.mail-line { margin: 1.5rem 0; }
.mail {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
}
.mail:hover { border-bottom-color: var(--accent); }
noscript { font-family: var(--mono); font-size: 0.9rem; color: var(--muted); }

/* ---- downloads ------------------------------------------------------ */

.files { display: flex; flex-direction: column; max-width: var(--col); margin: 1.75rem 0; }
.file {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1.25rem;
  align-items: baseline;
  padding: 0.9rem 0;
  border-bottom: 1px dotted var(--rule);
  text-decoration: none;
}
.file:hover .file-name { color: var(--accent); }
.file-name { font-size: 0.9rem; color: var(--ink); }
.file-ver, .file-size {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ---- apps ----------------------------------------------------------- */

/* Each app carries its own brand colour. --app-fill (icon-sampled) is the solid
   hue; --app-light / --app-dark are text-legible on each theme's ground. --accent
   is rebound to the theme-correct one so links, buttons and hovers pick it up. */
.app, .app-card { --accent: var(--app-light); }
@media (prefers-color-scheme: dark) {
  .app, .app-card { --accent: var(--app-dark); }
}
:root[data-theme="light"] .app, :root[data-theme="light"] .app-card { --accent: var(--app-light); }
:root[data-theme="dark"] .app, :root[data-theme="dark"] .app-card { --accent: var(--app-dark); }

.app { max-width: var(--col); }

.app-hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.app-icon {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  flex-shrink: 0;
}
.app-headline { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.app-headline h1 {
  font-family: var(--mono);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.app-tagline { color: var(--muted); font-size: 0.95rem; text-wrap: balance; }

.app-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 1.75rem 0 0.5rem;
}
.app-cta {
  font-family: var(--mono);
  font-size: 0.8rem;
  text-decoration: none;
  color: #fff;
  background: var(--accent);
  padding: 0.55rem 1rem;
  border-radius: 7px;
}
.app-cta:hover { filter: brightness(1.08); }
.app-link {
  font-family: var(--mono);
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--accent);
  padding: 0.55rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--rule));
  border-radius: 7px;
}
.app-link:hover { border-color: var(--accent); }

.app-body { margin-top: 1.5rem; }
.app-support, .app-role { max-width: var(--col); font-size: 0.85rem; color: var(--muted); }
.app-support { margin-top: 1.5rem; }
.app-role {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--faint);
  margin-top: 2rem;
}

/* ---- apps index ----------------------------------------------------- */

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.app-card {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 0;
  text-decoration: none;
  transition: transform 0.15s;
}
.app-card:hover { transform: translateY(-2px); }
.app-card:hover .app-card-name { color: var(--accent); }
.app-card-icon { width: 56px; height: 56px; border-radius: 13px; flex-shrink: 0; }
.app-card-text { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.app-card-name { font-family: var(--mono); font-size: 0.95rem; font-weight: 500; color: var(--ink); }
.app-card-tagline { font-size: 0.82rem; color: var(--muted); line-height: 1.45; }

@media (max-width: 34rem) {
  .app-hero { flex-direction: column; text-align: center; }
}

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

.foot {
  max-width: var(--col);
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--faint);
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--accent); }

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

@media (max-width: 34rem) {
  :root { --rail: 3rem; }
  .shell { padding: 2rem 1.15rem 4rem; }
  .post-row { grid-template-columns: 1fr; gap: 0.3rem; }
  .file { grid-template-columns: 1fr auto; }
  .file-ver { display: none; }
  .gap { min-height: 4.5rem; background-position: 0.9rem 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
