/*
 * greenfield.css — opt-in stylesheet for pages migrated from the
 * blog-base-template prototype. Loaded when a page sets
 * `useGreenfield: true` in frontmatter (see base.njk).
 *
 * Design tokens live in tokens.css (loaded before this file).
 * @font-face declarations duplicate bbs.css's but kept here so this
 * file is self-contained when applied to non-bbs pages later.
 */

/* --- Fonts (self-hosted IBM Plex) --------------------------------- */
@font-face {
  font-family: 'IBM Plex Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-serif-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-serif-latin-400-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Serif';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-serif-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-latin-700-normal.woff2') format('woff2');
}

/* --- Visually-hidden utility (accessibility, screen-reader only) - */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Images: responsive ------------------------------------------- */
article img {
  max-width: 100%;
  height: auto;
}

/* --- Post meta (date + reading time) ------------------------------ */
article > header > p {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin: 0;
}
article > header > p svg {
  vertical-align: -0.15em;
  margin-right: 0.25em;
  margin-left: 0.5em;
}
article > header > p svg:first-of-type {
  margin-left: 0;
}

/* --- End-of-article separator (3-mark "wind rose") --------------- */
svg[role="separator"] {
  display: block;
  margin: 2.5rem auto;
  width: 2rem;
  height: auto;
  color: var(--color-muted);
}

/* --- Tag nav (post page "filed under" tags) ---------------------- */
nav[aria-label="Tags"] {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin: 1.5rem 0 0;
}
nav[aria-label="Tags"] > svg {
  font-size: 1.5em;
  color: var(--color-accent);
  vertical-align: -0.25em;
  margin-right: 0.5em;
}
nav[aria-label="Tags"] a {
  color: var(--color-accent);
  text-decoration: none;
  margin-right: 0.6rem;
}
nav[aria-label="Tags"] a::before {
  content: "#";
}
nav[aria-label="Tags"] a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}
nav[aria-label="Tags"] a:last-of-type {
  margin-right: 0;
}

/* --- Skip link (uses base.njk's class="skip-link") --------------- */
.skip-link {
  position: absolute;
  top: -3rem;
  left: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid var(--color-accent);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  z-index: 100;
}
.skip-link:focus {
  top: 0.5rem;
}

/* --- Heading reset (headings inherit body unless overridden) ----- */
h1, h2, h3, h4, h5, h6, p {
  margin: 0;
}
h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

/* --- Body baseline ------------------------------------------------ */
body {
  margin: 0 auto;
  max-width: 68ch;
  padding: 2rem 1.25rem 3rem;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.55;
}
@media (min-width: 700px) {
  body { font-size: var(--text-lg); }
}

p { margin: 0.85rem 0; }

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

/* --- Headings ----------------------------------------------------- */
h1 {
  font-family: var(--font-body);
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0.25rem 0 0.75rem;
}

/* BBS-style section header: `── HEADING ─────────────────` */
h2 {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-accent);
  margin: 2.75rem 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.7em;
}
h2::before { content: "──"; flex: 0 0 auto; }
h2::after {
  content: "";
  flex: 1 1 auto;
  border-top: 1px solid currentColor;
  opacity: 0.35;
}

/* Post-meta-zone h2s (after the article): smaller than content h2s. */
main > article ~ h2 {
  font-size: var(--text-sm);
}

h3 {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
  margin: 0.75rem 0 0.25rem;
}

/* Post body h2: content section header (larger than chrome h2) */
article > div h2 {
  font-size: var(--text-lg);
  letter-spacing: 0.08em;
}

/* Post body code blocks */
article > div pre {
  font-size: var(--text-sm);
  line-height: 1.45;
  margin: 1rem 0;
  overflow-x: auto;
}

/* Post body h3: BBS subsection header, smaller sibling of h2 */
article > div h3 {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-accent-warm);
  margin: 1.75rem 0 0.75rem;
}
article > div h3::before {
  content: "─ ";
}

/* --- Site header + BBS-frame brand ------------------------------- */
body > header {
  border-bottom: 1px solid var(--color-rule);
  padding-bottom: 1rem;
  margin-bottom: 2rem;
}
body > header > p {
  margin: 0;
  font-size: var(--text-base);
  font-weight: normal;
  line-height: 1;
  letter-spacing: 0;
}
body > header > p svg {
  display: block;
  width: 100%;
  max-width: 26rem;
  height: auto;
  color: var(--color-accent);
  font-family: var(--font-mono);
  overflow: visible;
}
.brand-frame {
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
}
.brand-cutout {
  fill: var(--color-bg);
}
.brand-name {
  font-size: 17px;
  font-weight: 500;
  fill: var(--color-accent-loud);
}
body > header > p svg a { cursor: pointer; }
body > header > p svg a:hover .brand-name,
body > header > p svg a:focus-visible .brand-name {
  text-decoration: underline;
}
.brand-tag {
  font-size: 14px;
  fill: currentColor;
}

/* --- Site nav (top header nav + theme toggle) -------------------- */
nav[aria-label="Site"] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.5rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  margin-top: 1rem;
}
nav[aria-label="Site"] > ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
nav[aria-label="Site"] a,
nav[aria-label="Site"] button {
  color: var(--color-text);
  text-decoration: none;
  padding: 0.15rem 0;
  border-bottom: 1px dotted transparent;
}
nav[aria-label="Site"] a:hover,
nav[aria-label="Site"] button:hover {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}
nav[aria-label="Site"] button {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  background: transparent;
  border: 0;
  border-bottom: 1px dotted transparent;
  font: inherit;
  cursor: pointer;
  border-radius: 0;
}
nav[aria-label="Site"] kbd {
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: var(--color-accent-warm);
  font-weight: 700;
}
nav[aria-label="Site"] svg[data-icon] {
  color: var(--color-accent-warm);
  flex: 0 0 auto;
}

/* Theme toggle: show the icon + label for the theme you can SWITCH TO. */
button [data-icon="sun"],
button [data-theme-label="light"] { display: none; }

:root[data-theme="dark"] button [data-icon="moon"],
:root[data-theme="dark"] button [data-theme-label="dark"] { display: none; }
:root[data-theme="dark"] button [data-icon="sun"],
:root[data-theme="dark"] button [data-theme-label="light"] { display: revert; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) button [data-icon="moon"],
  :root:not([data-theme="light"]) button [data-theme-label="dark"] { display: none; }
  :root:not([data-theme="light"]) button [data-icon="sun"],
  :root:not([data-theme="light"]) button [data-theme-label="light"] { display: revert; }
}

/* --- Sections nav (homepage main menu panel) --------------------- */
nav[aria-labelledby] {
  background: var(--color-bg-alt);
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
nav[aria-labelledby] > ul {
  counter-reset: menu;
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}
nav[aria-labelledby] > ul > li {
  counter-increment: menu;
}
nav[aria-labelledby] a {
  color: var(--color-text);
  text-decoration: none;
}
nav[aria-labelledby] a:hover {
  color: var(--color-accent);
}
nav[aria-labelledby] a::before {
  content: "[" counter(menu) "] ";
  color: var(--color-accent-warm);
  font-weight: 700;
}
nav[aria-labelledby] small {
  font-size: inherit;
  color: var(--color-muted);
  margin-left: 0.4rem;
}

/* --- h-feed list (cards: homepage Recent Posts + archives) ------- */
.h-feed {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 1rem;
}
.h-feed > .h-entry {
  position: relative;
  background: var(--color-bg-alt);
  padding: 1rem 1.25rem;
  cursor: pointer;
}
.h-feed > .h-entry:hover :is(h2, h3) a {
  color: var(--color-accent);
}
.h-feed > .h-entry:has(:focus-visible) {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
.h-feed > .h-entry > :is(h2, h3) {
  margin: 0;
}
.h-feed > .h-entry > :is(h2, h3) a {
  color: var(--color-text);
  text-decoration: none;
}
.h-feed > .h-entry > :is(h2, h3) a:hover {
  color: var(--color-accent);
}
.h-feed > .h-entry > :is(h2, h3) a::after {
  content: "";
  position: absolute;
  inset: 0;
}
.h-feed > .h-entry > p {
  margin: 0.35rem 0 0;
}
.h-feed > .h-entry > p + p {
  margin-top: 0.5rem;
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.h-feed > .h-entry > p time {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.h-feed > .h-entry > p > svg {
  color: var(--color-muted);
  vertical-align: -0.15em;
  margin-right: 0.25em;
}

/* --- Photo grid override (photos archive) ------------------------ */
.photo-feed {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: 0.75rem;
}
.photo-feed > .h-entry {
  background: transparent;
  padding: 0;
  cursor: default;
}
.photo-feed > .h-entry > a {
  display: block;
  background: var(--color-bg-alt);
  padding: 0.4rem;
  text-decoration: none;
  color: inherit;
}
.photo-feed > .h-entry > a img,
.photo-feed > .h-entry > a picture {
  display: block;
  width: 100%;
  height: auto;
}
.photo-feed > .h-entry > a::after { content: none; }
.photo-feed > .h-entry > p {
  margin: 0.4rem 0 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.photo-feed > .h-entry > p time { color: inherit; }

/* --- Book grid (books archive) ----------------------------------- */
.book-feed {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: 1rem;
}
.book-feed > .h-entry {
  background: transparent;
  padding: 0;
  cursor: default;
}
.book-feed > .h-entry > a {
  display: block;
  text-decoration: none;
  color: inherit;
}
.book-feed > .h-entry > a img,
.book-feed > .h-entry > a picture {
  display: block;
  width: 100%;
  height: auto;
  background: var(--color-bg-alt);
}
.book-feed > .h-entry > a::after { content: none; }
.book-feed > .h-entry > a:hover {
  outline: 2px solid var(--color-accent);
}
.book-feed > .h-entry .book-no-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 2 / 3;
  background: var(--color-bg-alt);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-align: center;
  color: var(--color-muted);
}
.book-feed > .h-entry > p {
  margin: 0.5rem 0 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.book-feed > .h-entry > p strong {
  color: var(--color-text);
  font-weight: 600;
}

/* --- Book detail page ------------------------------------------- */
.book-detail-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(0, 200px) 1fr;
  align-items: start;
  margin: 1rem 0 2rem;
}
@media (max-width: 32rem) {
  .book-detail-grid { grid-template-columns: 1fr; }
}
.book-detail-grid .book-cover {
  margin: 0;
  background: var(--color-bg-alt);
}
.book-detail-grid .book-cover img,
.book-detail-grid .book-cover picture {
  display: block;
  width: 100%;
  height: auto;
}
.book-detail-grid .book-info > header h1 {
  margin: 0 0 0.25rem;
}
.book-detail-grid .book-info > header p {
  margin: 0;
  color: var(--color-muted);
}

/* --- Breadcrumb -------------------------------------------------- */
nav[aria-label="Breadcrumb"] {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin-bottom: 1rem;
}
nav[aria-label="Breadcrumb"] a {
  color: var(--color-accent);
}
nav[aria-label="Breadcrumb"] [aria-current="page"] {
  color: var(--color-text);
}

/* --- Article figure (photo posts, inline article images) --------- */
article > figure,
article .e-content figure {
  margin: 1.5rem 0;
}
article > figure img,
article > figure picture,
article .e-content figure img,
article .e-content figure picture {
  display: block;
  width: 100%;
  height: auto;
}
article > figure figcaption,
article .e-content figcaption {
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-muted);
  text-align: center;
}
/* "All posts" link below the feed */
main > section > p {
  margin-top: 1.5rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-align: right;
}
main > section > p > a > svg {
  vertical-align: -0.15em;
  margin-left: 0.15em;
}

/* --- Meta-zone panels (Signal, Comments) ------------------------- */
section[aria-labelledby] {
  margin: 0.5rem 0 1rem;
  background: var(--color-bg-alt);
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  display: grid;
  gap: 0.5rem;
}

/* --- Webmention-send form (panel chrome details) ----------------- */
main > details {
  margin: 0.5rem 0 1rem;
  background: var(--color-bg-alt);
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* --- Shared details marker treatment (BBS [+]/[-]) --------------- */
details > summary {
  cursor: pointer;
  color: var(--color-text);
  list-style: none;
  padding: 0.2rem 0;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: "[+] ";
  color: var(--color-accent-warm);
  font-weight: 700;
}
details[open] > summary::before {
  content: "[-] ";
}
details > summary:hover {
  color: var(--color-accent);
}

/* --- Comments article (Signal/Comments section content) ---------- */
section[aria-labelledby] > article > p:first-child {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin: 0 0 0.5rem;
  line-height: 1.6;
}
section[aria-labelledby] > article > p:last-child {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  margin: 0;
}
section[aria-labelledby] > article + article {
  margin-top: 1.5rem;
  border-top: 1px solid var(--color-rule);
  padding-top: 1.5rem;
}
main > details > form {
  margin-top: 0.75rem;
  padding-left: 2ch;
  display: grid;
  gap: 0.75rem;
}
main > details > form > p {
  color: var(--color-muted);
  margin: 0;
}
main > details > form > label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--color-muted);
}
main > details > form input[type="url"] {
  font: inherit;
  font-size: var(--text-base);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-accent);
  background: var(--color-bg-alt);
  color: var(--color-text);
  max-width: 32em;
}
main > details > form input[type="url"]:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
main > details > form button {
  font: inherit;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--color-accent);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  justify-self: start;
}
main > details > form button:hover {
  background: var(--color-bg);
  border-color: var(--color-accent-loud);
  color: var(--color-accent-loud);
}

/* --- Footer ------------------------------------------------------- */
footer {
  margin-top: 3.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-rule);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-muted);
}
footer p {
  margin: 0.35rem 0;
}
footer a {
  color: inherit;
  text-decoration: none;
}
footer a:hover {
  color: var(--color-accent);
}
footer nav ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
}
footer nav svg {
  vertical-align: -0.15em;
  margin-right: 0.25em;
}
