/* ---------------------------------------------------------------
   xhkairos.xyz — shared stylesheet
   Base tokens and layout are shared by every page; the .post-*
   rules are used by the blog index and the article pages.
   --------------------------------------------------------------- */

/* Registering the tokens as <color> makes them animatable, so switching
   theme cross-fades everything that reads them — text, rules, buttons,
   card hairlines and the currentColor diagrams — from one declaration. */
@property --ground {
  syntax: '<color>';
  inherits: true;
  initial-value: #F5F1E8;
}
@property --figure {
  syntax: '<color>';
  inherits: true;
  initial-value: #0A0A0A;
}
@property --rule {
  syntax: '<color>';
  inherits: true;
  initial-value: rgba(10, 10, 10, 0.18);
}
@property --tint {
  syntax: '<color>';
  inherits: true;
  initial-value: rgba(10, 10, 10, 0.05);
}

:root {
  --ground: #F5F1E8;
  --figure: #0A0A0A;
  --rule: rgba(10, 10, 10, 0.18);
  --tint: rgba(10, 10, 10, 0.05);
  --theme-fade: 450ms;
}
html[data-theme="dark"] {
  --ground: #0A0A0A;
  --figure: #F5F1E8;
  --rule: rgba(245, 241, 232, 0.22);
  --tint: rgba(245, 241, 232, 0.07);
}

html {
  transition:
    --ground var(--theme-fade) ease,
    --figure var(--theme-fade) ease,
    --rule var(--theme-fade) ease,
    --tint var(--theme-fade) ease;
}

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

/* Views below set display on list items, so [hidden] needs the last word. */
[hidden] { display: none !important; }

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

body {
  background: var(--ground);
  color: var(--figure);
  font-family: 'Jost', sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  font-weight: 400;
}

.wrap {
  max-width: 40rem;
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6em;
}
.brand .logo {
  height: 1.15em;
  width: auto;
  flex: none;
  color: var(--figure);
}
.brand a {
  display: flex;
  align-items: center;
  gap: 0.6em;
  text-decoration: none;
}

h1 {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
h2 {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 3rem 0 1rem;
}
p { margin-bottom: 1rem; }
a {
  color: var(--figure);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
ul { list-style: none; }
li { margin-bottom: 0.5rem; }
.meta { opacity: 0.6; }
.placeholder { opacity: 0.45; }

#theme-toggle {
  background: none;
  border: 1px solid var(--figure);
  color: var(--figure);
  font-family: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--figure);
  outline-offset: 2px;
}

footer {
  margin-top: 4rem;
  font-size: 0.875rem;
  opacity: 0.6;
}

/* --- contact dialog (home page) --------------------------------- */

dialog#contact-dialog {
  background: var(--ground);
  color: var(--figure);
  border: 1px solid var(--figure);
  max-width: 28rem;
  width: calc(100% - 3rem);
  padding: 2rem;
  margin: auto;
  font-family: inherit;
}
dialog#contact-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog#contact-dialog h2 { margin: 0 0 0.25rem; }
.form-intro {
  font-size: 0.875rem;
  opacity: 0.6;
  margin-bottom: 1.25rem;
}
.form-field { display: block; margin-bottom: 1rem; }
.form-field span {
  display: block;
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}
.form-field input,
.form-field textarea {
  width: 100%;
  background: var(--ground);
  color: var(--figure);
  border: 1px solid var(--figure);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.65rem;
}
.form-field textarea { min-height: 6rem; resize: vertical; }
.form-field input:focus-visible,
.form-field textarea:focus-visible {
  outline: 2px solid var(--figure);
  outline-offset: 1px;
}
.hidden-field { position: absolute; left: -9999px; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.form-actions button {
  background: none;
  border: 1px solid var(--figure);
  color: var(--figure);
  font-family: inherit;
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}
.form-actions button[type="submit"] {
  background: var(--figure);
  color: var(--ground);
}
.form-actions button[type="submit"]:disabled {
  background: none;
  color: var(--figure);
  border-color: var(--figure);
  opacity: 0.4;
  cursor: default;
}

/* --- shared small pieces ---------------------------------------- */

.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.6;
}
.back-link {
  display: inline-block;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  opacity: 0.6;
  margin-bottom: 2.5rem;
}
.back-link:hover { opacity: 1; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.tag {
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid var(--rule);
  padding: 0.15rem 0.5rem;
  text-decoration: none;
  opacity: 0.7;
}
.tag:hover { opacity: 1; border-color: var(--figure); }

/* --- blog index -------------------------------------------------- */

/* The blog index runs edge to edge; article pages keep the reading measure. */
.wrap.wide {
  max-width: none;
  padding-left: 3rem;
  padding-right: 3rem;
}
@media (max-width: 48rem) {
  .wrap.wide { padding-left: 1.5rem; padding-right: 1.5rem; }
}

.masthead {
  border-top: 1px solid var(--figure);
  padding: 2rem 0 1.75rem;
}
.masthead .wordmark {
  font-size: 2rem;
  line-height: 1.15;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: 0.6rem;
}
.masthead .tagline {
  max-width: 34rem;
  opacity: 0.7;
  margin-bottom: 1.25rem;
}
.masthead-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
}
.btn {
  display: inline-block;
  background: var(--figure);
  color: var(--ground);
  border: 1px solid var(--figure);
  font-family: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.4rem 0.9rem;
  text-decoration: none;
  cursor: pointer;
}
.btn-ghost {
  background: none;
  color: var(--figure);
}

/* --- controls: topics, sort, view -------------------------------- */

.controls {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 1rem 0;
}
.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--rule);
}
.controls-row .spacer { flex: 1 1 auto; }

.filters,
.seg-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.seg-label {
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.5;
}
.filters button,
.seg-group button {
  background: none;
  border: 1px solid var(--rule);
  color: var(--figure);
  font-family: inherit;
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  opacity: 0.65;
}
.filters button:hover,
.seg-group button:hover { opacity: 1; }
.filters button[aria-pressed="true"],
.seg-group button[aria-pressed="true"] {
  background: var(--figure);
  color: var(--ground);
  border-color: var(--figure);
  opacity: 1;
}

/* --- post list: shared ------------------------------------------- */

.post-list { list-style: none; }
.post-list > li { margin: 0; }
.post-item {
  display: block;
  text-decoration: none;
}
.post-item:hover .post-title {
  text-decoration: underline;
  text-underline-offset: 4px;
}
.post-meta {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.55;
  margin-bottom: 0.6rem;
}
.post-title {
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0.01em;
  margin-bottom: 0.5rem;
}
.post-dek {
  opacity: 0.75;
  margin-bottom: 0;
}
.post-item .tags { margin-top: 0.85rem; }
.empty-note {
  padding: 2rem 0;
  opacity: 0.55;
}

/* --- view: grid (default) ---------------------------------------- */

.view-grid {
  display: grid;
  /* min() keeps the track from ever exceeding the container, so narrow
     phones collapse to one column instead of overflowing sideways. */
  grid-template-columns: repeat(auto-fill, minmax(min(20rem, 100%), 1fr));
  gap: 1px;
  margin-top: 1px;
}
/* Each cell carries its own hairline; neighbouring shadows meet in the 1px
   gap and read as a single rule, and unfilled tracks stay empty. */
.view-grid > li {
  display: flex;
  box-shadow: 0 0 0 1px var(--rule);
}
.view-grid .post-item {
  flex: 1;
  padding: 1.75rem;
}
.view-grid .post-dek {
  font-size: 0.9375rem;
}

/* --- view: list --------------------------------------------------- */

.view-list > li { border-bottom: 1px solid var(--rule); }
.view-list .post-item {
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr);
  gap: 0 2rem;
  padding: 2rem 0;
}
.view-list .post-meta { margin-bottom: 0; }
.view-list .post-dek { max-width: 46rem; }
.view-list .is-lead .post-title,
.view-list .post-item.is-lead .post-title { font-size: 1.875rem; }
@media (max-width: 42rem) {
  .view-list .post-item { grid-template-columns: 1fr; }
  .view-list .post-meta { margin-bottom: 0.6rem; }
}

/* --- view: compact ------------------------------------------------ */

.view-compact > li { border-bottom: 1px solid var(--rule); }
.view-compact .post-item {
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr);
  gap: 0 2rem;
  padding: 0.7rem 0;
  align-items: baseline;
}
.view-compact .post-meta { margin-bottom: 0; }
.view-compact .post-title {
  font-size: 1.0625rem;
  margin-bottom: 0;
}
.view-compact .post-dek,
.view-compact .post-item .tags { display: none; }
@media (max-width: 42rem) {
  .view-compact .post-item { grid-template-columns: 1fr; }
  .view-compact .post-meta { margin-bottom: 0.2rem; }
}

/* --- blog index: phones ------------------------------------------ */

@media (max-width: 34rem) {
  .wrap.wide {
    padding: 2.5rem 1.25rem 4rem;
  }
  .wrap.wide header { margin-bottom: 2rem; }

  .masthead { padding: 1.5rem 0; }
  .masthead .wordmark { font-size: 1.625rem; }
  .masthead .tagline { margin-bottom: 1rem; }
  /* Two buttons split the row evenly rather than leaving a ragged edge. */
  .masthead-actions .btn {
    flex: 1 1 auto;
    text-align: center;
  }

  /* Both control groups sit left; the desktop right-alignment reads as a
     stray orphan once the row wraps. */
  .controls-row {
    gap: 0.75rem;
    align-items: flex-start;
  }
  .controls-row .spacer { display: none; }

  /* Desktop pills are ~24px tall — too small to hit reliably on a phone.
     min-height sets the touch target independently of the font metrics. */
  .filters button,
  .seg-group button,
  .masthead-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    padding: 0.35rem 0.8rem;
  }

  .view-grid .post-item { padding: 1.25rem; }
  .post-title { font-size: 1.1875rem; }
  .view-list .post-item.is-lead .post-title { font-size: 1.375rem; }
}

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

#progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--figure);
  z-index: 10;
}

.post-header {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1.75rem;
  margin-bottom: 2.5rem;
}
.post-header h1 {
  font-size: 2.125rem;
  line-height: 1.15;
  letter-spacing: 0;
  margin: 0.75rem 0;
}
.post-header .dek {
  font-size: 1.125rem;
  opacity: 0.75;
  margin-bottom: 1.25rem;
}
.byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  opacity: 0.65;
  margin-bottom: 1rem;
}
.byline .sep { opacity: 0.5; }

.toc {
  border: 1px solid var(--rule);
  padding: 1rem 1.25rem;
  margin-bottom: 2.5rem;
}
.toc summary {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0.7;
}
.toc ol {
  list-style: none;
  counter-reset: toc;
  margin-top: 0.9rem;
}
.toc li {
  counter-increment: toc;
  margin-bottom: 0.35rem;
  font-size: 0.9375rem;
}
.toc li::before {
  content: counter(toc, decimal-leading-zero) "  ";
  opacity: 0.45;
  font-variant-numeric: tabular-nums;
}
.toc li.sub { padding-left: 1.5rem; }
.toc a { text-decoration: none; opacity: 0.8; }
.toc a:hover { opacity: 1; text-decoration: underline; }

.post-body { font-size: 1.09375rem; line-height: 1.75; }
.post-body > p { margin-bottom: 1.35rem; }
.post-body h2 {
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  margin: 3rem 0 1rem;
  scroll-margin-top: 2rem;
}
.post-body h3 {
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin: 2rem 0 0.75rem;
  scroll-margin-top: 2rem;
}
.anchor {
  text-decoration: none;
  opacity: 0;
  margin-left: 0.4rem;
  font-weight: 400;
}
h2:hover .anchor,
h3:hover .anchor,
.anchor:focus-visible { opacity: 0.4; }

.lede { margin-bottom: 1.5rem; }
.lede::first-letter {
  float: left;
  font-size: 3.4rem;
  line-height: 0.82;
  padding: 0.14em 0.12em 0 0;
  font-weight: 500;
}

.post-body ul,
.post-body ol { margin: 0 0 1.35rem 1.25rem; }
.post-body ul { list-style: none; }
.post-body ul > li { position: relative; margin-bottom: 0.5rem; }
.post-body ul > li::before {
  content: "—";
  position: absolute;
  left: -1.25rem;
  opacity: 0.45;
}
.post-body ol { list-style: decimal; }
.post-body ol > li { margin-bottom: 0.5rem; padding-left: 0.25rem; }
.post-body li > ul,
.post-body li > ol { margin: 0.5rem 0 0.5rem 1.25rem; }

blockquote {
  border-left: 1px solid var(--figure);
  padding-left: 1.25rem;
  margin: 2rem 0;
  opacity: 0.85;
}
blockquote p:last-child { margin-bottom: 0; }
blockquote cite {
  display: block;
  font-style: normal;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.6;
  margin-top: 0.75rem;
}

.pullquote {
  border-top: 1px solid var(--figure);
  border-bottom: 1px solid var(--figure);
  padding: 1.5rem 0;
  margin: 2.5rem 0;
  font-size: 1.375rem;
  line-height: 1.4;
  text-align: center;
  letter-spacing: 0.01em;
}

.callout {
  border: 1px solid var(--rule);
  background: var(--tint);
  padding: 1.25rem 1.35rem;
  margin: 2rem 0;
  font-size: 1rem;
}
.callout .callout-label {
  display: block;
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.6;
  margin-bottom: 0.5rem;
}
.callout p:last-child { margin-bottom: 0; }

.takeaways {
  border: 1px solid var(--figure);
  padding: 1.35rem 1.5rem;
  margin: 2.5rem 0;
}
.takeaways h3 {
  margin: 0 0 0.85rem;
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
}
.takeaways ol { margin: 0 0 0 1.1rem; list-style: decimal; }
.takeaways li:last-child { margin-bottom: 0; }

.note {
  font-size: 0.875rem;
  opacity: 0.65;
  border-left: 1px solid var(--rule);
  padding-left: 1rem;
  margin: 1.75rem 0;
}

figure { margin: 2.5rem 0; }
figure img,
figure svg {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
}
figcaption {
  font-size: 0.8125rem;
  opacity: 0.6;
  margin-top: 0.65rem;
  line-height: 1.5;
}

.figure-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.figure-grid figcaption { grid-column: 1 / -1; margin-top: 0; }
@media (max-width: 30rem) {
  .figure-grid { grid-template-columns: 1fr; }
}

.table-wrap { overflow-x: auto; margin: 2rem 0; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9375rem;
  min-width: 26rem;
}
caption {
  caption-side: bottom;
  font-size: 0.8125rem;
  opacity: 0.6;
  text-align: left;
  padding-top: 0.65rem;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
thead th {
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  border-bottom: 1px solid var(--figure);
}
tbody tr:hover { background: var(--tint); }

code, kbd, pre, samp {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}
:not(pre) > code {
  font-size: 0.875em;
  background: var(--tint);
  border: 1px solid var(--rule);
  padding: 0.05em 0.35em;
}
kbd {
  font-size: 0.75em;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  padding: 0.1em 0.4em;
}
.code-block {
  margin: 2rem 0;
  border: 1px solid var(--rule);
}
.code-block .code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--rule);
  padding: 0.4rem 0.75rem;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.6;
}
.code-block .copy {
  background: none;
  border: 1px solid var(--rule);
  color: var(--figure);
  font-family: inherit;
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.1rem 0.5rem;
  cursor: pointer;
}
.code-block pre {
  overflow-x: auto;
  padding: 0.9rem 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.6;
}

mark {
  background: var(--tint);
  color: var(--figure);
  box-shadow: inset 0 -1px 0 var(--rule);
  padding: 0 0.15em;
}
abbr[title] { text-decoration: underline dotted; cursor: help; }

dl { margin: 2rem 0; }
dt {
  font-weight: 500;
  letter-spacing: 0.02em;
  border-top: 1px solid var(--rule);
  padding-top: 0.75rem;
}
dd { margin: 0.25rem 0 1rem; opacity: 0.75; }

.accordion {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 0.9rem 0;
  margin: 2rem 0;
}
.accordion summary { cursor: pointer; font-weight: 500; }
.accordion[open] summary { margin-bottom: 0.75rem; }

.rule-glyph {
  border: 0;
  text-align: center;
  margin: 2.75rem 0;
  overflow: visible;
}
.rule-glyph::after {
  content: "Λ";
  display: inline-block;
  font-size: 0.875rem;
  letter-spacing: 0.5em;
  opacity: 0.4;
}

.endmark::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  background: var(--figure);
  margin-left: 0.4em;
}

.footnotes {
  margin-top: 3.5rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.25rem;
  font-size: 0.875rem;
  opacity: 0.8;
}
.footnotes h2 { margin: 0 0 0.75rem; }
.footnotes ol { list-style: decimal; margin-left: 1.1rem; }
.footnotes li { margin-bottom: 0.5rem; scroll-margin-top: 3rem; }
sup a { text-decoration: none; padding: 0 0.1em; }
sup a:hover { text-decoration: underline; }

.post-footer {
  margin-top: 3.5rem;
  border-top: 1px solid var(--figure);
  padding-top: 1.75rem;
}
.share {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 2.5rem;
}
.share .label {
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.55;
  margin-right: 0.25rem;
}
.share a,
.share button {
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid var(--rule);
  background: none;
  color: var(--figure);
  font-family: inherit;
  padding: 0.2rem 0.6rem;
  text-decoration: none;
  cursor: pointer;
}
.share a:hover,
.share button:hover { border-color: var(--figure); }

.author-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  border: 1px solid var(--rule);
  padding: 1.25rem;
  margin-bottom: 2.5rem;
}
.author-card .logo {
  height: 2rem;
  width: auto;
  flex: none;
  color: var(--figure);
  opacity: 0.8;
}
.author-card p { margin: 0; font-size: 0.9375rem; }
.author-card .name { font-weight: 500; margin-bottom: 0.25rem; }

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  font-size: 0.9375rem;
}
.post-nav a { text-decoration: none; max-width: 48%; }
.post-nav a:hover .pn-title { text-decoration: underline; }
.post-nav .pn-label {
  display: block;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.5;
  margin-bottom: 0.2rem;
}
.post-nav .next { text-align: right; margin-left: auto; }
