/*
 * Skald, the public blog.
 *
 * Hand-written, and a deliberate port rather than a fresh design. fireballz.ai
 * is hand-written HTML and one style.css per page, and a reader who clicks
 * Blog in that nav should not be able to tell they changed application. The
 * type scale, the fully-round pill buttons, the 16px cards, the 0.16em-tracked
 * micro-labels and the 1160px shell all come from that site's own
 * site/src/styles/tokens.css and global.css.
 *
 * Every colour is a token from brand.css, which is generated from
 * tools/brand/config.go. There are no literal hex colour values below, on
 * purpose: the moment one appears, rebranding stops being a one-file edit.
 * Spacing is the one exception: fireballz.ai's own scale (4, 8, 12, 16, 24,
 * 32, 48, 72, 112px) is applied directly as literal numbers rather than piped
 * through another dozen custom properties, because unlike colour it never
 * needs to change without a design decision to go with it.
 */

/*
 * Nunito Sans, self-hosted, four weights, latin subset: the body face.
 * Fira Sans, self-hosted, four weights, latin subset: the heading, label and
 * button face. Both are fireballz.ai's own pairing
 * (site/src/layouts/Base.astro imports the same eight files), self-hosted for
 * the same reason: fireballz.ai pulls them from Google and @fontsource, which
 * is a third-party request on every pageview of our own blog, and the
 * Industrial Dashboard makes the opposite mistake, naming a face in its
 * templates with no @font-face and no link anywhere, so it has silently
 * rendered 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 download rather than
 * invisible. The fallback stacks are 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/nunito-sans
 * and @fontsource/fira-sans, 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');
}

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

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

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

@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/static/fonts/fira-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;
  }
}

/*
 * display: flex on the body, with main taking the remaining space, is
 * fireballz.ai's own structure (site/src/styles/global.css) and it is what
 * makes .foot's margin-top: auto below actually push the footer to the
 * bottom of a short page instead of sitting wherever the content ends.
 */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 17px;
  line-height: 1.65;
  font-weight: 400;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  flex: 1;
}

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

a {
  color: inherit;
  text-decoration: none;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.2s ease;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  line-height: 1.18;
  letter-spacing: -0.01em;
  font-weight: 700;
  color: var(--text);
  text-wrap: balance;
}

/* Sizes verbatim from fireballz.ai's --fb-fs-* scale. */
h1 {
  font-size: clamp(2.4rem, 4vw + 1.2rem, 4rem);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.02em;
}
h2 {
  font-size: clamp(1.85rem, 2vw + 1.3rem, 2.75rem);
  font-weight: 800;
}
h3 {
  font-size: clamp(1.375rem, 0.8vw + 1.2rem, 1.75rem);
}
h4 {
  font-size: 1.1875rem;
}
/* h5/h6 have no fireballz.ai equivalent (that site's scale stops at h4); sized
   as the next two steps down its own scale so the kitchen-sink post's full
   heading run (h1 through h6) still reads as one consistent ladder. */
h5 {
  font-size: 1.0625rem;
}
h6 {
  font-size: 0.9375rem;
}

/* Keyboard users get a visible focus ring everywhere, in one rule.
   --accent-text, not --accent: fireballz.ai's own --fb-focus is --fb-red-dark,
   the same darker red it uses for link text, not the brand ink. */
:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
  border-radius: var(--radius-input);
}

::selection {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

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

/*
 * The strongest type signature on the marketing site. Carried across exactly,
 * including the short red rule in front of the text (fireballz.ai's
 * .label::before, from the Figma's section tags).
 */
.micro-label {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.micro-label::before {
  content: '';
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  flex: none;
}

/* --- Buttons. fireballz.ai has four variants; these are the two the blog
       needs, and the other two arrive when a page needs them. --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.85em 1.6em;
  border-radius: var(--radius-pill);
  border: 2px solid var(--accent);
  background: var(--surface);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  /* fireballz.ai's --fb-sh-red, the one shadow its primary button always
     carries, scaled down slightly: skald's button runs a touch smaller than
     the marketing site's own CTA. */
  box-shadow: 0 14px 30px -12px var(--accent-glow);
}

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

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

.btn--outline:hover {
  background: var(--accent);
  border-color: 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: 78px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  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);
}

/*
 * fireballz.ai's own nav.primary a: a pill-shaped hit target, not a bare
 * link, with a tinted background rather than a colour swap on hover (its
 * nav.primary a:hover { background: fb-red-tint; color: fb-red-dark; }). A
 * tint keeps this compliant everywhere color-swapping an accent onto text
 * would not: the same background works on both grounds, in both themes,
 * because it is only ever read as colour, never as body text.
 */
.nav__links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  font-size: 15px;
  font-weight: 600;
}

.nav__links a {
  padding: 0.5em 0.85em;
  border-radius: var(--radius-pill);
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

.nav__links a:hover,
.nav__links a[aria-current='page'] {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent-text);
}

.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-text);
  border-color: var(--accent-text);
}

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

/* --- Hero ---
   fireballz.ai's PageHero.astro: a faint grid and a red glow over the page
   ground, bordered off from what follows. Reproduced as backgrounds rather
   than new markup, since no template here gains an element to carry them. */

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(48px, 6vw, 72px) 0 32px;
  background:
    radial-gradient(1100px 520px at 90% -10%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%),
    var(--bg);
  border-bottom: 1px solid var(--border);
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 30% 30%, #000 10%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 30% 30%, #000 10%, transparent 70%);
  opacity: 0.7;
}

.hero .shell,
.hero .author-head {
  position: relative;
}

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

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

/* --- Author header ---
   Unstyled until now: index.html has always rendered these classes when a
   page has an Author, the avatar, name, role, bio and link list simply had
   no rules to pick them up. */

.author-head {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.author-head__avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  flex: none;
}

.author-head__text {
  flex: 1 1 320px;
}

.author-head__role {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 15px;
}

.author-head__links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
}

.author-head__links a {
  color: var(--accent-text);
  font-weight: 600;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

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

.cards {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  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(-3px);
  box-shadow: var(--shadow-card-hover);
  /* fireballz.ai's --fb-red-line: color-mix(in srgb, --fb-red 30%, transparent). */
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

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

.card__body {
  padding: 32px;
}

.card__title {
  /* fireballz.ai's .card h3: 700, not the 800 the shared h1-h6 rule above
     gives a bare h2. The markup stays an h2 (card__title inherited its tag
     from the index before this pass and keeps it); only the weight and size
     are pulled back down to match how the card itself is meant to read. */
  font-weight: 700;
  font-size: 1.1875rem;
  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: clamp(48px, 6vw, 72px) 0 24px;
  max-width: 780px;
}

.post__head .micro-label a:hover {
  text-decoration: underline;
}

.post__meta {
  margin-top: 20px;
  font-size: 15px;
  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 own Lexical-to-HTML converter
 * (studio/internal/lexical/html.go), which always wraps the post body in one
 * <div class="payload-richtext">. The vertical-rhythm rule below targets that
 * wrapper's children, not .prose's own (.prose's only child is always that
 * one div), which is the one selector below allowed to name a class the
 * converter owns rather than one this file defines, because without it there
 * is no rule that puts space between two paragraphs at all.
 *
 * overflow-wrap because a reference list is a column of 100-character URLs
 * with nowhere to break, and on a phone the first one pushes the whole page
 * 400px sideways. Found on the two whitepaper posts, whose references are
 * bare URLs. Ordinary words never reach the edge, so this only ever breaks
 * the ones that would.
 */
.prose {
  max-width: 70ch;
  margin: 0 auto;
  padding: 32px 24px 72px;
  font-size: 18px;
  line-height: 1.75;
  overflow-wrap: break-word;
}

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

.prose h1 {
  margin-top: 2.2em;
  font-size: 2rem;
}

.prose h2 {
  margin-top: 2em;
  font-size: 1.75rem;
}

.prose h3 {
  margin-top: 1.6em;
  font-size: 1.375rem;
}

.prose h4 {
  margin-top: 1.4em;
}

.prose h5,
.prose h6 {
  margin-top: 1.2em;
}

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

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

.prose a:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

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

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

/*
 * Checklists: the converter emits a real <input type="checkbox">, readonly,
 * plus a <label>, inside an <li style="list-style-type: none">. Unstyled,
 * the browser's own checkbox and the list's own left padding leave the box
 * floating in dead space to the label's left with nothing lining them up;
 * this turns the pair into one row instead.
 */
.prose li.list-item-checkbox {
  list-style: none;
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
}

.prose li.list-item-checkbox input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin-top: 0.3em;
  accent-color: var(--accent);
  flex: none;
}

.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;
}

/*
 * fireballz.ai's table.data: an uppercase, tracked header row on the page
 * ground, the same treatment this gives .micro-label, for the same reason:
 * it is that site's one signature for "this is a label, not content".
 */
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}

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

.prose th {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  white-space: nowrap;
}

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

/* --- Closing call to action, after every post --- */

.post__cta {
  max-width: calc(70ch + 48px);
  margin: 0 auto 72px;
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.post__cta h2 {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.25;
}

.post__cta p {
  margin: 10px 0 20px;
  color: var(--text-muted);
}

.post__cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* --- Tags ---
   fireballz.ai's .chip: a small dot, uppercase, tracked. */

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

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

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tag::before {
  content: '';
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* --- Pager --- */

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

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

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

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

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

/* --- Footer ---
   fireballz.ai's own footer.site sits on --fb-paper, not its white card
   ground; var(--bg), not var(--surface), matches that, and reads the same
   way here: separated from the page above it by the hairline border alone,
   the way fireballz.ai separates two same-background sections in a row
   (section.block + section.block:not(.alt):not(.band)). */

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

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

.foot__brand {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
}

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

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

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

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

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