/* cmpnd site styles. Every value comes from tokens.css; load that file first. */

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

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-core);
  font-size: var(--text-body);
  font-weight: var(--fw-body);
  line-height: var(--lh-body);
  letter-spacing: var(--ls-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--text-link);
  text-decoration: underline;
  text-decoration-thickness: var(--border-hair);
  text-underline-offset: 2px;
  transition: color var(--dur-fast) var(--ease-standard);
}
a:hover { color: var(--text-primary); }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: var(--border-heavy) solid var(--focus-ring);
  outline-offset: 2px;
}

::selection { background: var(--sun-adder-100); color: var(--color-ink); }

/* ---- Page frame: header, flexible main, footer ---- */
/* A centred column holds the whole page, header and footer included. */
.page-container {
  width: 65%;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main { flex: 1; min-width: 0; }

/* ---- Header ---- */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-7);
  padding: var(--space-8) 0;
  font-family: var(--font-core);
}

.logo { display: block; line-height: 0; flex: none; }
.logo img { display: block; height: 30px; width: auto; }
/* Keep the logo from being selected, dragged, or tap-highlighted by accident. */
.logo,
.logo img {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
}

.nav { display: flex; gap: 28px; }
.nav a {
  font-size: 15px;
  font-weight: var(--fw-light);
  line-height: var(--lh-ui);
  color: var(--text-secondary);
  text-decoration: none;
}
.nav a:hover { color: var(--text-primary); }

/* ---- Footer ---- */
.footer {
  display: flex;
  justify-content: space-between;
  gap: var(--space-6);
  padding: var(--space-7) 0;
  border-top: var(--border-hair) solid var(--rule);
  font-family: var(--font-core);
  font-size: var(--text-ui-sm);
  font-weight: var(--fw-light);
  line-height: var(--lh-ui);
  color: var(--text-muted);
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .page-container { width: auto; margin: 0 var(--gutter); }
  .header { padding: var(--space-6) 0; }
  .logo img { height: 26px; }
}

@media (max-width: 400px) {
  .nav a[href^="mailto:"] { display: none; }
}

/* ---- Home ---- */
.hero {
  padding: var(--space-8) 0 var(--space-9);
}

.hero-headline {
  max-width: 30ch;
  margin: 0;
  font-size: var(--text-headline-md);
  font-weight: var(--fw-bold);
  line-height: var(--lh-headline-md);
  letter-spacing: var(--ls-headline-md);
}

.posts { padding: 0 0 var(--space-10); }

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.section-label {
  font-size: var(--text-label);
  font-weight: var(--fw-label);
  line-height: var(--lh-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.post-count {
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--text-ui-xs);
  color: var(--ink-500);
}

.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: var(--border-hair) solid var(--rule);
}

.post-item {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 18px 0;
  border-bottom: var(--border-hair) solid var(--rule);
  color: inherit;
  text-decoration: none;
}
.post-item:hover { color: inherit; }

.post-title {
  --marker: 14px;
  --marker-gap: 20px;
  flex: 1;
  min-width: 0;
  padding-left: calc(var(--marker) + var(--marker-gap));
  font-size: 20px;
  font-weight: var(--fw-bold);
  line-height: var(--lh-subhead);
  letter-spacing: var(--ls-subhead);
}

/* The square marker is the title's own background. On hover it grows
   across the title like a highlighter, following each wrapped line.
   The negative margin pulls the first line back over the square, so
   wrapped lines hang aligned with the text. */
.post-title-text {
  margin-left: calc(-1 * (var(--marker) + var(--marker-gap)));
  padding: 0 6px 0 calc(var(--marker) + var(--marker-gap));
  background-image: linear-gradient(var(--color-pine-needle), var(--color-pine-needle));
  background-repeat: no-repeat;
  background-position: 0 50%;
  background-size: var(--marker) var(--marker);
  transition: background-size 200ms var(--ease-in), color 200ms var(--ease-in);
}
.post-item:hover .post-title-text,
.post-item:focus-visible .post-title-text {
  background-size: 100% 100%;
  color: var(--text-on-brand);
}

.post-date {
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--text-ui-sm);
  line-height: var(--lh-ui);
  white-space: nowrap;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .hero-headline { font-size: 32px; }
  .post-item { gap: var(--space-4); padding: var(--space-5) 0; }
  .post-title { --marker: 12px; --marker-gap: var(--space-4); font-size: 17px; }
}

/* ---- Blog post ---- */
.main-article { padding: var(--space-9) 0 var(--space-10); }

article {
  max-width: var(--measure);
  min-width: 0;
  margin: 0 auto;
}

.article-date {
  font-size: var(--text-label);
  font-weight: var(--fw-label);
  line-height: var(--lh-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.article-title {
  margin: var(--space-5) 0 var(--space-4);
  font-size: var(--text-headline-md);
  font-weight: var(--fw-bold);
  line-height: var(--lh-headline-md);
  letter-spacing: var(--ls-headline-md);
}

.article-author {
  margin: 0 0 var(--space-7);
  font-size: var(--text-label);
  font-weight: var(--fw-light);
  color: var(--text-muted);
}
.article-author a { color: var(--text-muted); }
.article-author a:hover { color: var(--text-primary); }

.article-hero {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 699;
  object-fit: cover;
  margin-bottom: var(--space-7);
  background-color: var(--surface-sunken);
}

.article-subtitle {
  margin: 0 0 40px;
  padding-left: 20px;
  border-left: var(--border-heavy) solid var(--color-pine-needle);
  font-size: var(--text-subhead);
  font-weight: var(--fw-light);
  line-height: var(--lh-subhead);
  color: var(--text-secondary);
}

.article-content p { margin: 0 0 20px; }
.article-content em { font-style: italic; }
.article-content strong { font-weight: var(--fw-bold); }

.article-content h2 {
  margin: 40px 0 var(--space-5);
  font-size: var(--text-subhead);
  font-weight: var(--fw-bold);
  line-height: var(--lh-subhead);
  letter-spacing: var(--ls-subhead);
}

.article-content h3 {
  margin: var(--space-7) 0 var(--space-4);
  font-size: 20px;
  font-weight: var(--fw-bold);
  line-height: var(--lh-subhead);
  letter-spacing: var(--ls-subhead);
}

.article-content code {
  font-family: var(--font-mono);
  font-size: 15px;
  background-color: var(--surface-sunken);
  padding: 1px var(--space-2);
  border-radius: var(--radius-none);
}

.article-content h2 code,
.article-content h3 code { font-size: 0.85em; }

.article-content pre {
  margin: 0 0 var(--space-6);
  padding: 20px;
  background-color: var(--surface-inverse);
  color: var(--text-on-inverse);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  border-radius: var(--radius-none);
}
.article-content pre code {
  display: block;
  font-size: 15px;
  line-height: 1.6;
  color: inherit;
  background: none;
  padding: 0;
}

/* Python syntax colours, applied by a small per-post highlighter script. */
.article-content pre .code-line { white-space: pre-wrap; }
.article-content pre .tok-c { color: var(--ink-400); }
.article-content pre .tok-s { color: var(--pine-needle-200); }
.article-content pre .tok-k { color: var(--woad-400); }
.article-content pre .tok-n { color: var(--sun-adder-200); }

.article-content blockquote {
  margin: var(--space-6) 0;
  padding-left: 20px;
  border-left: var(--border-heavy) solid var(--rule);
  color: var(--text-secondary);
}

.article-content ul,
.article-content ol { margin: 0 0 20px; padding-left: var(--space-6); }
.article-content li { margin-bottom: var(--space-3); }
.article-content li > ul,
.article-content li > ol { margin: var(--space-3) 0 0; }

.article-content hr {
  margin: 40px 0;
  border: 0;
  border-top: var(--border-hair) solid var(--rule);
}

.article-content table {
  width: 100%;
  margin: var(--space-6) 0;
  border-collapse: collapse;
  font-size: var(--text-ui);
  line-height: var(--lh-ui);
}
.article-content th {
  padding: var(--space-3) var(--space-4);
  background: var(--surface-table-header);
  font-weight: var(--fw-medium);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  color: var(--text-secondary);
}
.article-content td {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-hair) solid var(--rule);
  vertical-align: top;
}

@media (max-width: 640px) {
  .article-title { font-size: 32px; }
  .article-subtitle { font-size: 22px; }
  .article-content pre { padding: var(--space-5); }
  .article-content table { font-size: var(--text-ui-sm); }
  .article-content th,
  .article-content td { padding: var(--space-2) var(--space-3); }
}

/* ---- Button ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 var(--space-5);
  border: var(--border-hair) solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-core);
  font-size: var(--text-ui);
  font-weight: var(--fw-medium);
  letter-spacing: 0.01em;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition:
    background-color var(--dur-fast) var(--ease-standard),
    color var(--dur-fast) var(--ease-standard),
    border-color var(--dur-fast) var(--ease-standard);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--action-primary-bg); color: var(--action-primary-fg); }
.btn-primary:hover { background: var(--action-primary-bg-hover); color: var(--action-primary-fg); }
.btn-primary:active { background: var(--action-primary-bg-active); }
.btn-primary:disabled { background: var(--action-primary-bg); }

.btn-secondary {
  background: var(--action-secondary-bg);
  color: var(--action-secondary-fg);
  border-color: var(--edge-control);
}
.btn-secondary:hover { background: var(--action-ghost-bg-hover); color: var(--action-secondary-fg); border-color: var(--color-ink); }
.btn-secondary:active { background: var(--ink-200); }

/* ---- Field, input, textarea ---- */
.form-group { display: grid; gap: 6px; }

.form-label {
  font-size: var(--text-ui-sm);
  font-weight: var(--fw-medium);
  line-height: var(--lh-ui);
  letter-spacing: 0.01em;
  color: var(--text-secondary);
}
/* Required fields get a Watermelon asterisk without extra markup. */
.form-group:has(:required) .form-label::after { content: " *"; color: var(--watermelon-600); }

.form-hint,
.form-field-error { font-size: var(--text-ui-xs); line-height: 1.4; }
.form-hint { color: var(--text-muted); }
.form-field-error { color: var(--error-text); }

.form-input,
.form-textarea {
  width: 100%;
  margin: 0;
  background: var(--surface-card);
  border: var(--border-hair) solid var(--edge-control);
  border-radius: var(--radius-sm);
  font-family: var(--font-core);
  font-size: var(--text-ui);
  font-weight: var(--fw-regular);
  color: var(--text-primary);
  transition: border-color var(--dur-fast) var(--ease-standard);
}
.form-input { height: 36px; padding: 0 10px; }
.form-textarea { padding: 10px; line-height: 1.5; resize: vertical; }
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-disabled); }
.form-input:focus,
.form-textarea:focus { border-color: var(--color-ink); }
.form-input:user-invalid,
.form-textarea:user-invalid,
.form-input[aria-invalid="true"],
.form-textarea[aria-invalid="true"] { border-color: var(--error-border); }
.form-input:disabled,
.form-textarea:disabled { background: var(--surface-sunken); opacity: 0.6; }

/* ---- Contact ---- */
.main-contact { padding: var(--space-9) 0 var(--space-10); }

.page-title {
  margin: 0 0 var(--space-4);
  font-size: var(--text-headline-md);
  font-weight: var(--fw-bold);
  line-height: var(--lh-headline-md);
  letter-spacing: var(--ls-headline-md);
}

.page-intro {
  max-width: 60ch;
  margin: 0 0 var(--space-8);
  color: var(--text-secondary);
}

/* Email list signup: label, then the field and button on one row. */
.subscribe-lede { margin: 0 0 var(--space-5); color: var(--text-secondary); }
/* On posts, the signup closes the article below a hairline. */
.post-subscribe {
  margin-top: var(--space-8);
  padding-top: var(--space-7);
  border-top: var(--border-hair) solid var(--rule);
}
.subscribe-form { display: grid; gap: 6px; }
/* On the contact page, the form matches the intro's width. */
.main-contact .subscribe-form { max-width: 60ch; }
.post-subscribe .subscribe-form { max-width: 480px; }
.subscribe-row { display: flex; gap: var(--space-3); }
.subscribe-row .form-input { flex: 1; min-width: 0; }
.subscribe-row .btn { flex: none; }
.subscribe-credit {
  margin: var(--space-2) 0 0;
  font-size: var(--text-ui-xs);
  line-height: 1.4;
  color: var(--text-muted);
}
.subscribe-credit a { color: var(--text-muted); }
.subscribe-credit a:hover { color: var(--text-primary); }

/* ---- 404 ---- */
.main-404 {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: var(--space-6);
  padding: var(--space-9) 0;
}

.not-found-code {
  margin: 0;
  font-size: var(--text-headline-lg);
  font-weight: var(--fw-headline-lg);
  line-height: 0.92;
  letter-spacing: var(--ls-headline-lg);
  text-transform: uppercase;
}

.not-found-text { margin: 0; color: var(--text-secondary); }

@media (max-width: 640px) {
  .page-title { font-size: 32px; }
  .not-found-code { font-size: 88px; }
}
