/* ==========================================================================
   Popwork blog — screen.css
   Plain CSS, no build step required. assets/built/screen.css is a copy.
   ========================================================================== */

/* 1. Tokens
   -------------------------------------------------------------------------- */
:root {
  --paper: #fefaf7;
  --surface: #f6efe7;
  --ink: #111111;
  --ink-2: #4a4540;
  --ink-3: #6e675f;
  --line: #e8dfd4;
  --accent: var(--ghost-accent-color, #111111);

  --font-sans: var(--gh-font-heading, "Bricolage Grotesque"), ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: var(--gh-font-body, "Source Serif 4"), Georgia, "Times New Roman", serif;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: clamp(1.75rem, 1.4rem + 1.4vw, 2.25rem);
  --step-4: clamp(2.25rem, 1.6rem + 2.6vw, 3.5rem);
  --step-5: clamp(2.75rem, 1.6rem + 5vw, 5.5rem);

  --container: 1180px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --radius-sm: 6px;
  --radius: 14px;
  --header-h: 64px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 3rem);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg, video, iframe { display: block; max-width: 100%; }
img { height: auto; }

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection { background: #f2e4d3; color: var(--ink); }

.site {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-main { flex: 1; }

.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: 1rem; }

/* 3. Shared pieces
   -------------------------------------------------------------------------- */
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: var(--step--1);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color 150ms ease;
}
.button:hover { background: #2e2a26; }
.button--primary { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset; }

.button--light { background: var(--paper); color: var(--ink); }
.button--light:hover { background: #fff; }

.kicker {
  display: inline-block;
  margin-bottom: 0.6rem;
  color: var(--ink-2);
  font-size: var(--step--1);
  font-weight: 600;
}
.kicker:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  color: var(--ink-3);
  font-size: var(--step--1);
}

.section-title {
  margin-bottom: 1.75rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: 0;
}

/* 4. Header
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(254, 250, 247, 0.92);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
  transition: transform 250ms ease;
}
.site-header.is-hidden { transform: translateY(-100%); }

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: var(--header-h);
}

.site-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: var(--step-1);
}
.site-logo img { height: 26px; width: auto; }

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 240px;
  padding: 0.6rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-3);
  font: inherit;
  font-size: var(--step--1);
  cursor: pointer;
  transition: border-color 150ms ease;
}
.search-trigger:hover { border-color: #cfc3b5; color: var(--ink-2); }

.topic-nav { border-top: 1px solid var(--line); }

.topic-nav__list {
  display: flex;
  gap: 1.75rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.topic-nav__list::-webkit-scrollbar { display: none; }

.topic-nav__list a {
  display: block;
  padding: 0.8rem 0 0.75rem;
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  font-size: var(--step--1);
  font-weight: 500;
  white-space: nowrap;
  transition: color 150ms ease, border-color 150ms ease;
}
.topic-nav__list a:hover { color: var(--ink); }
.topic-nav__list a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

@media (max-width: 720px) {
  .search-trigger { min-width: 0; padding: 0.55rem; }
  .search-trigger__label { display: none; }
  .site-header__actions .button { padding: 0.55rem 0.9rem; font-size: 0.8125rem; }
}

/* 5. Hero (home, tag, author)
   -------------------------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  align-items: end;
  gap: 1.5rem 4rem;
  padding-block: clamp(3rem, 8vw, 6.5rem) clamp(2.5rem, 5vw, 4rem);
}

.hero__title {
  font-size: var(--step-5);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.hero__lede {
  max-width: 34ch;
  color: var(--ink-2);
  font-size: var(--step-1);
  line-height: 1.5;
}

.hero--archive {
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  padding-bottom: clamp(2rem, 4vw, 3rem);
}
.hero--archive .hero__title { font-size: var(--step-4); }
.hero--archive .hero__lede { max-width: 60ch; }

.hero__count {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  color: var(--ink-3);
  font-size: var(--step--1);
}
.hero__count a { text-decoration: underline; text-underline-offset: 3px; }

.hero__avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
}

@media (max-width: 820px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
}

/* 6. Featured
   -------------------------------------------------------------------------- */
.featured { padding-bottom: clamp(3rem, 6vw, 5rem); }

.featured__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  gap: 1.75rem 3rem;
}

.lead { grid-row: 1 / span 3; }

.lead__media {
  display: block;
  margin-bottom: 1.25rem;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  aspect-ratio: 16 / 10;
}
.lead__media img { width: 100%; height: 100%; object-fit: cover; }

.lead__title {
  margin-bottom: 0.9rem;
  font-size: var(--step-3);
  line-height: 1.1;
}
.lead__title a:hover,
.side-story__title a:hover,
.card__title a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }

.lead__excerpt {
  max-width: 60ch;
  margin-bottom: 1rem;
  color: var(--ink-2);
  font-size: var(--step-1);
}

.side-story {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--line);
}
.side-story:last-child { border-bottom: 0; }

.side-story__media {
  display: block;
  overflow: hidden;
  border-radius: var(--radius-sm);
  aspect-ratio: 1;
  background: var(--surface);
}
.side-story__media img { width: 100%; height: 100%; object-fit: cover; }

.side-story__title {
  margin-bottom: 0.5rem;
  font-size: var(--step-1);
  line-height: 1.25;
}

@media (max-width: 900px) {
  .featured__grid { grid-template-columns: minmax(0, 1fr); }
  .lead { grid-row: auto; padding-bottom: 1.75rem; border-bottom: 1px solid var(--line); }
}

@media (max-width: 480px) {
  .side-story { grid-template-columns: 88px minmax(0, 1fr); gap: 1rem; }
}

/* 7. Post grid & cards
   -------------------------------------------------------------------------- */
.feed { padding-bottom: clamp(3rem, 6vw, 5rem); }

.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3rem 2rem;
}

@media (max-width: 1000px) { .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .post-grid { grid-template-columns: minmax(0, 1fr); gap: 2.5rem; } }

.card { display: flex; flex-direction: column; }

.card__media {
  display: block;
  margin-bottom: 1.1rem;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  aspect-ratio: 16 / 10;
}
.card__media img { width: 100%; height: 100%; object-fit: cover; }

.card__title {
  margin-bottom: 0.6rem;
  font-size: 1.3rem;
  line-height: 1.25;
}

.card__excerpt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  margin-bottom: 0.9rem;
  color: var(--ink-2);
}

.card .meta { margin-top: auto; }

/* 8. Pagination
   -------------------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: var(--step--1);
}
.pagination:has(.is-disabled + .pagination__status + .is-disabled) { display: none; }

.pagination__link {
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 600;
  transition: border-color 150ms ease;
}
a.pagination__link:hover { border-color: var(--ink); }
.pagination__link.is-disabled { visibility: hidden; }
.pagination__status { color: var(--ink-3); }

/* 9. Article
   -------------------------------------------------------------------------- */
.article__header {
  width: 100%;
  max-width: calc(42rem + var(--gutter) * 2);
  margin-inline: auto;
  padding: clamp(2.5rem, 7vw, 5rem) var(--gutter) 2.5rem;
}

.article__title {
  font-size: var(--step-4);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.article__dek {
  margin-top: 1.25rem;
  color: var(--ink-2);
  font-family: var(--font-serif);
  font-size: 1.3rem;
  line-height: 1.5;
}

.byline {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.byline__avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.byline__name { font-weight: 600; }
.byline__name a:hover { text-decoration: underline; text-underline-offset: 3px; }

.article__image {
  max-width: calc(1100px + var(--gutter) * 2);
  margin: 0 auto clamp(2.5rem, 5vw, 3.5rem);
  padding-inline: var(--gutter);
}
.article__image img { width: 100%; border-radius: var(--radius); }
.article__image figcaption,
.gh-content figcaption {
  margin-top: 0.75rem;
  color: var(--ink-3);
  font-size: var(--step--1);
  text-align: center;
}

/* Content grid: main column with room for Koenig wide/full cards */
.gh-content {
  display: grid;
  grid-template-columns:
    [full-start] minmax(var(--gutter), 1fr)
    [wide-start] minmax(0, 7rem)
    [main-start] min(42rem, 100% - var(--gutter) * 2)
    [main-end] minmax(0, 7rem)
    [wide-end] minmax(var(--gutter), 1fr)
    [full-end];
  font-family: var(--font-serif);
  font-size: var(--step-1);
  line-height: 1.7;
  color: #1f1c19;
}

.gh-content > * { grid-column: main-start / main-end; }
.gh-content > * + * { margin-top: 1.5em; }

.gh-content .kg-width-wide { grid-column: wide-start / wide-end; }
.gh-content .kg-width-full { grid-column: full-start / full-end; }
.gh-content .kg-width-full img { width: 100%; border-radius: 0; }

.gh-content > h2,
.gh-content > h3,
.gh-content > h4 { margin-top: 2.2em; }
.gh-content > h2 + *,
.gh-content > h3 + *,
.gh-content > h4 + * { margin-top: 0.75em; }

.gh-content h2 { font-size: var(--step-3); line-height: 1.15; }
.gh-content h3 { font-size: var(--step-2); line-height: 1.25; }
.gh-content h4 { font-size: var(--step-1); }

.gh-content a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
.gh-content a:hover { text-decoration-thickness: 2.5px; }

.gh-content strong { font-weight: 700; }

.gh-content ul,
.gh-content ol { padding-left: 1.3em; }
.gh-content ul { list-style: disc; }
.gh-content ol { list-style: decimal; }
.gh-content li + li { margin-top: 0.5em; }
.gh-content li::marker { color: var(--ink-3); }

.gh-content blockquote:not([class]) {
  margin: 2em 0 0;
  padding-left: 1.25em;
  border-left: 3px solid var(--accent);
  font-style: italic;
}

.gh-content blockquote.kg-blockquote-alt {
  font-family: var(--font-sans);
  font-size: var(--step-2);
  font-style: normal;
  line-height: 1.35;
  text-align: center;
}

.gh-content hr {
  width: 100%;
  height: 1px;
  margin: 2.5em 0;
  border: 0;
  background: var(--line);
}

.gh-content img { border-radius: var(--radius-sm); }

.gh-content code {
  padding: 0.12em 0.35em;
  border-radius: 4px;
  background: var(--surface);
  font-size: 0.85em;
}

.gh-content pre {
  overflow-x: auto;
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.85rem;
  line-height: 1.6;
}
.gh-content pre code { padding: 0; background: none; font-size: inherit; }

.gh-content table:not(.gist table) {
  display: block;
  overflow-x: auto;
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: var(--step--1);
}
.gh-content th,
.gh-content td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.gh-content th { font-weight: 600; }

.gh-content iframe { width: 100%; border: 0; }

/* Koenig cards that should read as UI rather than prose */
.gh-content .kg-callout-card,
.gh-content .kg-toggle-card,
.gh-content .kg-product-card,
.gh-content .kg-bookmark-card,
.gh-content .kg-button-card,
.gh-content .kg-header-card,
.gh-content .kg-signup-card { font-family: var(--font-sans); }

.gh-content .kg-callout-card { border-radius: var(--radius-sm); }
.gh-content .kg-bookmark-container { border-radius: var(--radius-sm); }

/* Article footer */
.article__footer {
  width: 100%;
  max-width: calc(42rem + var(--gutter) * 2);
  margin: 3.5rem auto 0;
  padding-inline: var(--gutter);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tag-list a {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: var(--step--1);
  transition: border-color 150ms ease;
}
.tag-list a:hover { border-color: var(--ink); color: var(--ink); }

.author-box {
  display: flex;
  gap: 1.25rem;
  margin-top: 2.5rem;
  padding: 1.5rem;
  border-radius: var(--radius);
  background: var(--surface);
}
.author-box__avatar { width: 64px; height: 64px; flex-shrink: 0; border-radius: 50%; object-fit: cover; }
.author-box__label { color: var(--ink-3); font-size: var(--step--1); }
.author-box__name { margin: 0.15rem 0 0.5rem; font-size: var(--step-1); }
.author-box__name a:hover { text-decoration: underline; text-underline-offset: 3px; }
.author-box__bio { color: var(--ink-2); font-size: 0.95rem; }

/* Call to action after an article */
.cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem 3rem;
  margin-block: clamp(3.5rem, 7vw, 5rem);
  padding-block: 2.25rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  padding-inline: clamp(1.5rem, 4vw, 3rem);
}
.cta__text {
  max-width: 40ch;
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

@media (max-width: 720px) {
  .cta { flex-direction: column; align-items: flex-start; }
}

.feed--related { padding-top: 1rem; }

/* 10. Footer
   -------------------------------------------------------------------------- */
.site-footer {
  margin-top: 2rem;
  background: var(--ink);
  color: #d9d2ca;
  font-size: var(--step--1);
}

.site-footer__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
  gap: 2.5rem;
  padding-block: 4rem 3rem;
}

.site-footer__logo {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--paper);
  font-size: var(--step-1);
  font-weight: 800;
}
.site-footer__logo img { max-width: 150px; }

.site-footer__brand p { max-width: 32ch; line-height: 1.5; }

.site-footer__col h2 {
  margin-bottom: 1rem;
  color: var(--paper);
  font-size: var(--step-0);
  font-weight: 600;
  letter-spacing: 0;
}

.footer-links li + li { margin-top: 0.7rem; }
.footer-links a { line-height: 1.4; transition: color 150ms ease; }
.footer-links a:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }

.social { display: flex; gap: 0.5rem; margin-top: 1.5rem; }
.social a {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #3a3632;
  border-radius: 50%;
  transition: border-color 150ms ease, color 150ms ease;
}
.social a:hover { border-color: var(--paper); color: #fff; }

.site-footer__legal {
  padding-block: 1.5rem;
  border-top: 1px solid #2a2724;
  color: #9a928a;
}

@media (max-width: 900px) {
  .site-footer__inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-footer__brand { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .site-footer__inner { grid-template-columns: minmax(0, 1fr); }
}

/* 11. Error page
   -------------------------------------------------------------------------- */
.error-page {
  padding-block: clamp(4rem, 12vw, 9rem);
}
.error-page__code {
  font-size: var(--step-5);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}
.error-page__title {
  margin: 1rem 0 2rem;
  color: var(--ink-2);
  font-size: var(--step-2);
  font-weight: 500;
}
.error-page__stack { margin-top: 3rem; font-size: var(--step--1); }
.error-page__stack h2 { margin-bottom: 1rem; font-size: var(--step-1); }
.error-page__stack li { margin-top: 0.5rem; color: var(--ink-2); }

/* 12. Motion preferences
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  .site-header.is-hidden { transform: none; }
}

/* 13. Language switcher (markup injected via Ghost code injection)
   -------------------------------------------------------------------------- */
.language_switch {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  font-family: var(--font-sans);
  font-size: var(--step--1);
  font-weight: 500;
}

.language_switch > div {
  background: #fff;
  border: 1px solid var(--line);
}

.language_switch > div:first-child {
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(17, 17, 17, 0.08);
}

/* The theme renders its own switcher: hide any older copy injected via Code injection */
.language_switch:not([data-theme-switch]) { display: none; }

.language_switch > div > a,
.language_switch > div > button {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  height: 40px;
  padding: 0 1rem 0 0.75rem;
  color: var(--ink);
  white-space: nowrap;
}

.language_switch > div:first-child > :is(a, button) { padding-right: 2.1rem; }

.language_switch > div:first-child > :is(a, button)::after {
  content: "";
  position: absolute;
  right: 0.9rem;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-30%) rotate(-135deg);
  transition: transform 150ms ease;
}

.language_switch img {
  width: 20px;
  height: 20px;
  margin: 0;
  border-radius: 50%;
  object-fit: cover;
}

.language_switch > div:not(:first-child) {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.4rem);
  min-width: 100%;
  display: none;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(17, 17, 17, 0.12);
}

.language_switch > div:not(:first-child) > a:hover { background: var(--surface); }

.language_switch.is-open > div:not(:first-child) { display: block; }
.language_switch.is-open > div:first-child > :is(a, button)::after { transform: translateY(-70%) rotate(45deg); }

@media (max-width: 640px) {
  .language_switch { right: 0.75rem; bottom: 0.75rem; }
  .site-footer__legal { padding-bottom: 4.5rem; }
}

@media print {
  .language_switch { display: none; }
}
