/*
 * Skald, the public blog.
 *
 * Hand-written, and a deliberate port rather than a fresh design. embernet.ai
 * is thirteen pages of hand-written HTML and one style.css, and a reader who
 * clicks Blog in that nav should not be able to tell they changed application.
 * The type scale, the 25px pill buttons, the 12px cards, the 3px-tracked
 * micro-labels and the 1200px shell all come from that file.
 *
 * Every colour is a token from brand.css, which is generated from
 * brand.config.ts. There are no literal hex values below, on purpose: the
 * moment one appears, rebranding stops being a one-file edit.
 */

/*
 * Inter, self-hosted, four weights, latin subset.
 *
 * embernet.ai pulls this from fonts.googleapis.com, which is a third-party
 * request on every pageview of our own blog. The Industrial Dashboard makes the
 * opposite mistake: it names Inter in all five templates with no @font-face and
 * no link anywhere, so it has been silently rendering in Segoe UI since it
 * shipped. This does neither. The files are embedded in the binary.
 *
 * font-display: swap so text is readable during the ~24KB download rather than
 * invisible. The fallback stack is metrically close enough that the reflow is
 * not the jarring kind.
 *
 * SIL Open Font License 1.1; the licence travels with the files in
 * web/internal/assets/files/fonts/LICENSE. Sourced from @fontsource/inter,
 * copied at build time by nothing: they are committed, because a font that
 * downloads during a build is a build that fails when npm is unreachable.
 */

@font-face {
  font-family: 'Nunito Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/nunito-sans-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/nunito-sans-600.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/static/fonts/nunito-sans-700.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito Sans';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/static/fonts/nunito-sans-800.woff2') format('woff2');
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
}

h1 {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 800;
  letter-spacing: -0.02em;
}
h2 {
  font-size: clamp(24px, 3.5vw, 40px);
}
h3 {
  font-size: 24px;
}
h4 {
  font-size: 20px;
}

/* Keyboard users get a visible focus ring everywhere, in one rule. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.shell {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* The strongest type signature on the marketing site. Carried across exactly. */
.micro-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
}

/* --- Buttons. All four variants exist on embernet.ai; these are two of them,
       and the other two arrive when a page needs them. --- */

.btn {
  display: inline-block;
  padding: 14px 32px;
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--outline {
  border-color: var(--accent);
  color: var(--accent);
}

.btn--outline:hover {
  background: var(--accent);
  color: #ffffff;
}

/* --- Preview banner --- */

.preview-bar {
  background: var(--accent);
  color: #ffffff;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* --- Nav --- */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-nav);
}

.nav__inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 72px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

/*
 * The mark is a raster and it is PORTRAIT (828x1095), so it cannot go in a
 * square box. Height is fixed and width follows the aspect ratio; object-fit
 * keeps it honest if the artwork is ever swapped for something wider.
 */
.wordmark__mark {
  height: 26px;
  width: auto;
  object-fit: contain;
  flex: none;
}

.wordmark__accent {
  color: var(--accent);
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-left: auto;
  font-size: 15px;
  font-weight: 600;
}

.nav__links a:hover,
.nav__links a[aria-current='page'] {
  color: var(--accent);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-input);
  width: 38px;
  height: 38px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex: none;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 768px) {
  .nav__links {
    display: none;
  }
}

/* --- Hero --- */

.hero {
  padding: 72px 0 40px;
}

.hero .micro-label {
  margin-bottom: 12px;
}

.hero__sub {
  margin-top: 16px;
  max-width: 60ch;
  font-size: 18px;
  color: var(--text-muted);
}

/* --- Index cards --- */

.cards {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 28px;
  padding: 24px 0 64px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--accent);
}

.card__img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.card__body {
  padding: 24px;
}

.card__title {
  font-size: 21px;
  margin: 10px 0;
}

.card__excerpt {
  color: var(--text-muted);
  font-size: 15px;
}

.card__meta {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.empty {
  padding: 48px 0 96px;
  color: var(--text-muted);
  font-size: 18px;
}

/* --- Post --- */

.post__head {
  padding: 64px 0 24px;
  max-width: 780px;
}

.post__head .micro-label a:hover {
  color: var(--accent-hover);
}

.post__meta {
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-muted);
}

.post__author {
  font-weight: 700;
  color: var(--text);
}

.post__role::before {
  content: ', ';
}

.post__hero {
  max-width: 1080px;
  margin: 24px auto 8px;
  padding: 0 24px;
}

.post__hero img {
  width: 100%;
  border-radius: var(--radius-card);
}

.post__hero figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

/*
 * The body.
 *
 * Everything below is scoped under .prose because it styles markup this file
 * does not control: it comes out of Payload's Lexical converter. Scoping it
 * means an unexpected element gets sensible defaults instead of leaking styles
 * into the chrome.
 */

.prose {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  font-size: 18px;
  line-height: 1.75;
}

.prose > * + * {
  margin-top: 1.2em;
}

.prose h2 {
  margin-top: 2em;
  font-size: 30px;
}

.prose h3 {
  margin-top: 1.6em;
  font-size: 22px;
}

.prose p {
  color: var(--text);
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose a:hover {
  color: var(--accent-hover);
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li + li {
  margin-top: 0.4em;
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 20px;
  color: var(--text-muted);
  font-style: italic;
}

.prose img {
  border-radius: var(--radius-card);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

/*
 * Code blocks scroll inside themselves. Without the min-width:0, a long
 * unbroken line in a shell transcript stretches the grid and gives the whole
 * page a horizontal scrollbar.
 */
.prose pre {
  min-width: 0;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 18px 20px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
}

.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
}

/* --- Tags --- */

.post__tags {
  max-width: 780px;
  padding-bottom: 64px;
}

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag {
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

/* --- Pager --- */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding-bottom: 80px;
}

.pager__count {
  font-size: 14px;
  color: var(--text-muted);
}

/* --- Error page --- */

.error-page {
  padding: 96px 24px 128px;
  max-width: 720px;
}

.error-page h1 {
  margin: 12px 0 32px;
}

/* --- Footer --- */

.foot {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 48px 0;
  margin-top: auto;
}

.foot__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.foot__brand {
  font-size: 20px;
  font-weight: 800;
}

.foot__line {
  color: var(--text-muted);
  font-size: 14px;
}

.foot__line a:hover {
  color: var(--accent);
}

.foot__meta {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
}

.foot__meta a:hover {
  color: var(--accent);
}

@media (max-width: 768px) {
  .foot__meta {
    margin-left: 0;
  }
}
