/* ------------------------------------------------------------------
   Diaryx — organization site (diaryx.org)
   Shared by the landing page and the per-project pages. Same material
   as the app's own site: neutral grays, system type, one accent.
   --accent is the app's system blue; it is the only color that
   carries meaning here.
------------------------------------------------------------------ */
:root {
  --paper: #f5f5f6;
  --paper-2: #ebebed;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #98989d;
  --line: rgb(0 0 0 / 0.14);
  --line-soft: rgb(0 0 0 / 0.08);
  --accent: #0071e3;
  --accent-soft: rgb(0 113 227 / 0.1);
  --shadow: rgb(0 0 0 / 0.16);

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

  --page: 72rem;
  --measure: 36rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c1c1e;
    --paper-2: #161618;
    --card: #26262a;
    --ink: #ededf0;
    --ink-2: #a3a3ab;
    --ink-3: #77777e;
    --line: rgb(255 255 255 / 0.16);
    --line-soft: rgb(255 255 255 / 0.08);
    --accent: #0a84ff;
    --accent-soft: rgb(10 132 255 / 0.16);
    --shadow: rgb(0 0 0 / 0.5);
  }
}

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

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

body {
  font-family: var(--sans);
  font-size: 1.0313rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: inherit;
}
p a {
  text-decoration-color: var(--ink-3);
  text-underline-offset: 0.2em;
}
p a:hover {
  color: var(--accent);
}

.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}

section {
  padding-block: clamp(3.5rem, 9vw, 6.5rem);
}

h1,
h2,
h3 {
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-wrap: balance;
}

.lede {
  font-size: 1.1563rem;
  color: var(--ink-2);
  max-width: var(--measure);
  text-wrap: pretty;
}
.lede.wide {
  max-width: 44rem;
}

.sec-head {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  margin-bottom: clamp(1.75rem, 4vw, 2.5rem);
}
.sec-head .sec-name {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}

h2.display {
  font-size: clamp(1.875rem, 4.5vw, 2.75rem);
  max-width: 24ch;
}

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--line-soft);
  border-radius: 3px;
  padding: 0.05em 0.35em;
}

/* ------------------------------ nav ------------------------------ */
header.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
header.nav[data-scrolled="true"] {
  border-bottom-color: var(--line);
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 4.25rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
  margin-right: auto;
}
.brand img {
  width: 32px;
  height: 32px;
  display: block;
}
.nav-links {
  display: flex;
  gap: 1.4rem;
  font-size: 0.9063rem;
  color: var(--ink-2);
}
.nav-links a {
  text-decoration: none;
}
.nav-links a:hover {
  color: var(--ink);
}
@media (max-width: 56rem) {
  .nav-links {
    display: none;
  }
}
@media (max-width: 30rem) {
  .nav .btn {
    display: none;
  }
}

/* ---------------------------- buttons ---------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.72rem 1.4rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.9375rem;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform 0.15s ease,
    background-color 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
}
.btn:active {
  transform: scale(0.98);
}
.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--ink) 86%, var(--paper));
}
.btn-ghost {
  border-color: var(--line);
  color: var(--ink);
  background: transparent;
}
.btn-ghost:hover {
  border-color: var(--ink-2);
}
.btn-sm {
  padding: 0.45rem 1rem;
  font-size: 0.875rem;
}

/* ----------------------------- hero ----------------------------- */
.hero {
  padding-block: clamp(3rem, 8vw, 6rem) clamp(3rem, 7vw, 5rem);
}
.hero h1 {
  font-size: clamp(2.5rem, 5.6vw, 3.75rem);
  max-width: 16ch;
}
.hero .lede {
  margin-top: 1.25rem;
  font-size: clamp(1.0938rem, 2vw, 1.2188rem);
  max-width: 44rem;
}
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}
.cta-note {
  margin-top: 0.9rem;
  font-size: 0.8438rem;
  color: var(--ink-3);
}

/* -------------------------- ledger strip ------------------------- */
.ledger {
  border-block: 1px solid var(--line);
  background: var(--paper-2);
}
.ledger-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}
.ledger-inner > div {
  padding: 1.1rem 1.5rem;
  border-left: 1px solid var(--line-soft);
}
.ledger-inner > div:first-child {
  border-left: 0;
  padding-left: 0;
}
.ledger .label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ledger .val {
  font-size: 0.9688rem;
  color: var(--ink);
}
@media (max-width: 46rem) {
  .ledger-inner > div {
    border-left: 0;
    border-top: 1px solid var(--line-soft);
    padding-inline: 0;
  }
  .ledger-inner > div:first-child {
    border-top: 0;
  }
}

/* ------------------------ project grid --------------------------- */
.proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: 1.25rem;
  margin-top: 2.5rem;
}
.proj-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  box-shadow:
    0 1px 2px var(--shadow),
    0 14px 34px -16px var(--shadow);
  padding: 1.4rem 1.5rem 1.5rem;
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.proj-card:hover {
  transform: translateY(-2px);
  border-color: var(--ink-3);
}
.proj-card .p-name {
  font-family: var(--mono);
  font-size: 1.125rem;
  font-weight: 650;
}
.proj-card .p-lang {
  float: right;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.proj-card p {
  margin-top: 0.55rem;
  font-size: 0.9063rem;
  color: var(--ink-2);
  flex: 1;
}
.proj-card .p-more {
  margin-top: 1rem;
  font-size: 0.8438rem;
  font-weight: 600;
  color: var(--accent);
}

/* ------------------------- principle list ------------------------ */
.principles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 2rem 3rem;
  margin-top: 2.5rem;
  max-width: 60rem;
}
.principle h3 {
  font-size: 1.1875rem;
  margin-bottom: 0.4rem;
}
.principle p {
  color: var(--ink-2);
  font-size: 0.9531rem;
}

/* --------------------------- cta / final -------------------------- */
.final {
  text-align: center;
  border-top: 1px solid var(--line);
}
.final h2 {
  font-size: clamp(2rem, 5vw, 3rem);
  max-width: 18ch;
  margin-inline: auto;
}
.final .cta-row {
  justify-content: center;
}
.final .lede {
  margin: 1.25rem auto 0;
}

/* ------------------------------ footer ---------------------------- */
footer {
  border-top: 1px solid var(--line);
  padding-block: 2.5rem 3rem;
  font-size: 0.875rem;
  color: var(--ink-2);
}
.foot-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: center;
}
.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-left: auto;
  align-items: center;
}
.foot-links a {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.foot-links a:hover {
  color: var(--ink);
}

/* --------------------------- project page ------------------------- */
.crumb {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--ink-3);
  text-decoration: none;
}
.crumb:hover {
  color: var(--accent);
}
.pj-head {
  padding-block: clamp(2.75rem, 6vw, 4.5rem) clamp(2rem, 5vw, 3rem);
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
}
.pj-title {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.pj-title h1 {
  font-family: var(--mono);
  font-size: clamp(2.25rem, 5vw, 3.25rem);
}
.pj-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.tag-chip {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 100px;
  padding: 0.22rem 0.7rem;
  white-space: nowrap;
}
.pj-tagline {
  margin-top: 1rem;
  font-size: clamp(1.1563rem, 2.4vw, 1.375rem);
  color: var(--ink-2);
  max-width: 40rem;
  text-wrap: pretty;
}
/* Prose left, a sticky rail of install commands and facts right. The rail
   holds everything a returning visitor came for, so it stays on screen. */
.pj-main {
  padding-block: clamp(2.5rem, 6vw, 4rem);
}
.pj-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21rem;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}
.pj-aside {
  position: sticky;
  top: 5.5rem;
  display: grid;
  gap: 1.25rem;
}
@media (max-width: 56rem) {
  .pj-layout {
    grid-template-columns: 1fr;
  }
  .pj-aside {
    position: static;
  }
}
.install {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  overflow: hidden;
  box-shadow: 0 1px 2px var(--shadow);
}
.install-head {
  display: block;
  padding: 0.65rem 1rem 0.55rem;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--paper-2) 55%, var(--card));
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.cmd {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 0.8125rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  overflow-x: auto;
  white-space: nowrap;
}
.cmd:last-child {
  border-bottom: 0;
}
.cmd::before {
  content: "$";
  color: var(--ink-3);
  flex: none;
}
.cmd small {
  margin-left: auto;
  padding-left: 1rem;
  font-family: var(--sans);
  font-size: 0.6875rem;
  color: var(--ink-3);
}

.pj-body {
  max-width: 44rem;
}
.pj-body > * + * {
  margin-top: 1.25rem;
}
.pj-body h2 {
  font-size: 1.375rem;
  margin-top: 2.5rem;
}
.pj-body ul {
  list-style: none;
  display: grid;
  gap: 0.55rem;
}
.pj-body li {
  position: relative;
  padding-left: 1.5rem;
  color: var(--ink-2);
  font-size: 0.9844rem;
}
.pj-body li::before {
  content: "—";
  color: var(--accent);
  position: absolute;
  left: 0;
}
.pj-body li strong {
  color: var(--ink);
  font-weight: 600;
}
.pj-aside .facts {
  margin-top: 0;
}
.facts {
  margin-top: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  overflow: hidden;
  box-shadow: 0 1px 2px var(--shadow);
}
.facts .row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.875rem;
}
.facts .row:last-child {
  border-bottom: 0;
}
.facts .k {
  font-size: 0.6563rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  flex: none;
  width: 6.5rem;
}
.facts .v {
  font-family: var(--mono);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}
.facts .v a {
  color: var(--accent);
  text-decoration: none;
}
.facts .v a:hover {
  text-decoration: underline;
}

/* --------------------------- about page --------------------------- */
.eyebrow {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 1.1rem;
}

/* The stack: labelled tiers of linked boxes, app on top. Drawn with
   boxes rather than arrows — the layering IS the dependency story. */
.tiers {
  margin-top: 2.5rem;
  display: grid;
  gap: 0.9rem;
  max-width: 56rem;
}
.tier {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 1.25rem;
}
.tier-name {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: right;
  padding-top: 1rem;
}
.tier-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0.9rem;
}
.tier-box {
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 1px 2px var(--shadow);
  padding: 0.8rem 1rem 0.9rem;
  text-decoration: none;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease;
}
.tier-box:hover {
  transform: translateY(-2px);
  border-color: var(--ink-3);
}
.tier-box .t-name {
  display: block;
  font-family: var(--mono);
  font-size: 0.9688rem;
  font-weight: 650;
}
.tier-box .t-desc {
  display: block;
  font-size: 0.8125rem;
  color: var(--ink-2);
  margin-top: 0.15rem;
}
.tier-app {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent),
    0 1px 2px var(--shadow);
}
.tier-app .t-name {
  font-family: var(--sans);
}
.tiers-note {
  margin-top: 1.25rem;
  font-size: 0.9063rem;
  color: var(--ink-2);
  max-width: 44rem;
}
@media (max-width: 46rem) {
  .tier {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .tier-name {
    text-align: left;
    padding-top: 0;
  }
  .tier-row {
    grid-auto-flow: row;
  }
}

/* ------------------------------ misc ------------------------------ */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.6s ease,
    transform 0.6s ease;
}
.reveal.in {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ==================================================================
   Appended for diaryx_render — everything below this line is new.

   `SiteStyle::custom_css` REPLACES the bundled stylesheet outright
   (crates/diaryx_render/src/html.rs:21-28, `HtmlRenderer::css`), so
   none of html_format_css.css comes along. This block covers the
   markup the renderer emits that org.css never had to think about.
   Nothing above this line was touched.
================================================================== */

/* ---- content fallback ------------------------------------------
   `{{{content}}}` is dropped straight into `<main id="top">` with no
   wrapper of its own. The migrated pages open with their own
   `<section>` + `.wrap`, so they are already handled; this is for a
   page that is plain markdown all the way down, which would
   otherwise run edge to edge. Anything that brings its own .wrap
   opts out.
----------------------------------------------------------------- */
main > :not(section):not(.ledger) {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}
main > :not(section):not(.ledger) + :not(section):not(.ledger) {
  margin-top: 1.25rem;
}
main > h1:not(.wrap) {
  padding-top: clamp(2.5rem, 6vw, 4rem);
}

/* ---- prose elements org.css never carried ----------------------- */
main p,
main li {
  text-wrap: pretty;
}
main h2 {
  font-size: 1.625rem;
  margin-top: 2.5rem;
}
main h3 {
  font-size: 1.25rem;
  margin-top: 2rem;
}
main ol,
main ul {
  padding-left: 1.5rem;
}
main ol li + li,
main ul li + li {
  margin-top: 0.35rem;
}
main hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin-block: 2.5rem;
}
main img,
main video {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}
main blockquote {
  border-left: 2px solid var(--line);
  padding-left: 1.1rem;
  color: var(--ink-2);
}
main pre {
  overflow-x: auto;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.55;
}
main pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}
main table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9375rem;
}
main th,
main td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
}
main th {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}
/* comrak/twig task lists */
main ul.task-list {
  list-style: none;
  padding-left: 0.25rem;
}

/* ---- renderer breadcrumbs --------------------------------------
   Unused today: each migrated page keeps its own hand-written
   `.crumb` inside the tinted `.pj-head` band, which the shell cannot
   reach into. Styled anyway so switching to the renderer's slot is a
   template edit rather than a design job.
----------------------------------------------------------------- */
.breadcrumbs {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--ink-3);
}
.breadcrumbs a {
  text-decoration: none;
}
.breadcrumbs a:hover {
  color: var(--accent);
}
.breadcrumb-sep {
  color: var(--ink-3);
}
.breadcrumbs [aria-current="page"] {
  color: var(--ink-2);
}

/* ---- a link whose target is not in this render set --------------
   `links::transform_links` turns an unresolved document link into a
   span rather than a 404. Make it visibly inert instead of silently
   ordinary text.
----------------------------------------------------------------- */
.unpublished-link {
  color: var(--ink-3);
  text-decoration: underline dotted;
  cursor: help;
}

/* ---- twig could not parse the body ------------------------------ */
.diaryx-unrendered {
  white-space: pre-wrap;
  color: var(--ink-2);
}

/* ---- an embedded HTML attachment -------------------------------- */
iframe.diaryx-island {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

/* ---- ==highlight== ---------------------------------------------- */
.highlight-mark {
  border-radius: 3px;
  padding: 0.05em 0.15em;
  color: inherit;
  background: var(--accent-soft);
}
.highlight-yellow {
  background: rgb(255 214 10 / 0.28);
}
.highlight-orange {
  background: rgb(255 159 10 / 0.28);
}
.highlight-red {
  background: rgb(255 69 58 / 0.24);
}
.highlight-pink {
  background: rgb(255 55 95 / 0.22);
}
.highlight-violet {
  background: rgb(191 90 242 / 0.24);
}
.highlight-blue {
  background: rgb(10 132 255 / 0.22);
}
.highlight-cyan {
  background: rgb(100 210 255 / 0.28);
}
.highlight-green {
  background: rgb(48 209 88 / 0.24);
}
.highlight-brown {
  background: rgb(172 142 104 / 0.28);
}
.highlight-grey {
  background: var(--line-soft);
}

/* ---- ||spoiler|| ------------------------------------------------ */
.spoiler-mark {
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.spoiler-hidden {
  color: transparent;
  background: var(--ink-3);
  text-shadow: none;
}
.spoiler-revealed {
  color: inherit;
  background: var(--line-soft);
}

/* ---- footnotes -------------------------------------------------- */
.footnote-ref {
  text-decoration: none;
  font-size: 0.75em;
  vertical-align: super;
  color: var(--accent);
}
.footnotes {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.9063rem;
  color: var(--ink-2);
}

/* ---- generated index / nav bits, if ever switched on ------------- */
.entry-description {
  color: var(--ink-2);
  font-size: 0.9063rem;
}
