/* Readspresso — blog.
   Laid out like Medium (narrow column, large serif body, byline under the
   title, a bare top bar), coloured and set like the app: the --rs-* values below are copied
   from src/index.css (light and dark), and blog.test.ts fails if they drift.
   The pages have no JavaScript, so they cannot read the theme chosen in the
   app's Settings; they follow the OS instead, and sepia is not offered.
   Every style lives in this file: the CSP is style-src 'self'. */

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/fonts/fraunces-latin-ext-1.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/fonts/fraunces-latin-2.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --rs-canvas: #fbf8f4;
  --rs-surface: #ffffff;
  --rs-sunken: #f3ede4;
  --rs-fg: #1f1712;
  --rs-muted: #5b4c3f;
  --rs-subtle: #786759;
  --rs-line: #e8decf;
  --rs-line-strong: #d8c9b4;
  --rs-accent: #a8551e;
  --rs-accent-hover: #8f441c;
  --rs-accent-soft: #f5e7da;
  --rs-on-accent: #ffffff;
  --rs-focus-ring: #2f6fed;
  --rs-shadow-sm: 0 1px 2px rgb(61 41 26 / 0.06);

  --font-display: 'Fraunces', ui-serif, Georgia, 'Times New Roman', serif;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  /* Medium's reading column and body face: a 680px measure, set in Charter
     where the OS has it (macOS, iOS) and Georgia elsewhere. No web font: the
     body is the bulk of the page and system serifs render instantly. */
  --measure: 680px;
  --font-serif: Charter, 'Bitstream Charter', 'Iowan Old Style', 'Sitka Text', Cambria, Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --rs-canvas: #14120f;
    --rs-surface: #1d1a16;
    --rs-sunken: #100e0c;
    --rs-fg: #f2ece3;
    --rs-muted: #b0a397;
    --rs-subtle: #8f8377;
    --rs-line: #2e2820;
    --rs-line-strong: #413931;
    --rs-accent: #e4a15e;
    --rs-accent-hover: #efb47a;
    --rs-accent-soft: #2a2118;
    --rs-on-accent: #1f1712;
    --rs-focus-ring: #7fa8ff;
    --rs-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  /* The top bar is sticky: keep it from covering a focused link or an anchor
     target (WCAG 2.2 focus-not-obscured). Bar + tabs + breathing room. */
  scroll-padding-top: 120px;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

body {
  margin: 0;
  background-color: var(--rs-surface);
  color: var(--rs-fg);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

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

a:focus-visible {
  outline: 2px solid var(--rs-focus-ring);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 3;
  padding: 0.6rem 1rem;
  background: var(--rs-fg);
  color: var(--rs-surface);
  border-radius: var(--radius-sm);
  font-weight: 500;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.5rem;
}

@media (max-width: 639px) {
  .hide-sm,
  .topbar-links a.hide-sm {
    display: none;
  }
}

/* --- Top bar: brand row + topic tabs ------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--rs-surface);
  border-bottom: 1px solid var(--rs-line);
}

.topbar-inner,
.tabs-inner,
.footer-inner {
  max-width: 1192px;
  margin: 0 auto;
  padding: 0 1rem;
}

@media (min-width: 728px) {
  .topbar-inner,
  .tabs-inner,
  .footer-inner {
    padding: 0 1.5rem;
  }
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 57px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  color: var(--rs-fg);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.logo img {
  border-radius: 7px;
}

.logo-sub {
  color: var(--rs-subtle);
}

/* At phone width the brand row holds the logo, the language switch and the
   button, and nothing else: "Blog" goes (the tabs below already say where you
   are) and the spacing tightens, so the row fits a 320px screen. */
@media (max-width: 639px) {
  .logo {
    font-size: 1.125rem;
    min-width: 0;
  }

  .logo-sub {
    display: none;
  }

  .topbar-links a:not(.topbar-cta) {
    padding: 0 0.6rem;
  }

  .topbar-cta {
    padding: 0 0.9rem;
  }
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.topbar-links a:not(.topbar-cta) {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--rs-muted);
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
  transition: color 150ms ease-out, background-color 150ms ease-out;
}

.topbar-links a:not(.topbar-cta):hover {
  color: var(--rs-fg);
  background: var(--rs-sunken);
}

.topbar-links .lang {
  gap: 0.4em;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.lang .hide-sm {
  font-weight: 400;
  letter-spacing: 0;
}

.topbar-cta {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-left: 0.25rem;
  padding: 0 1.1rem;
  border-radius: 999px;
  background: var(--rs-accent);
  color: var(--rs-on-accent);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease-out;
}

.topbar-cta:hover {
  background: var(--rs-accent-hover);
}

/* Topic tabs, Medium-style: one row, scrolls sideways on a narrow phone
   instead of wrapping. The scroll stays inside the row; the page never
   scrolls sideways. */
.tabs-inner {
  display: flex;
  gap: 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs-inner::-webkit-scrollbar {
  display: none;
}

.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border-bottom: 2px solid transparent;
  color: var(--rs-muted);
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
  transition: color 150ms ease-out, border-color 150ms ease-out;
}

.tabs a:hover {
  color: var(--rs-fg);
}

.tabs a[aria-current='page'] {
  color: var(--rs-fg);
  border-bottom-color: var(--rs-fg);
  font-weight: 500;
}

/* --- Shared bits --------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 0.7rem;
  border-radius: 999px;
  background: var(--rs-accent-soft);
  color: var(--rs-accent);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}

.chip:hover {
  background: var(--rs-accent);
  color: var(--rs-on-accent);
}

.title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.016em;
}

@media (min-width: 728px) {
  .title {
    font-size: 2.625rem;
    line-height: 1.25;
  }
}

.lede {
  margin: 0.75rem 0 0;
  color: var(--rs-muted);
  font-size: 1.25rem;
  line-height: 1.4;
}

@media (min-width: 728px) {
  .lede {
    font-size: 1.375rem;
  }
}

a.cta-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1.4rem;
  border-radius: 999px;
  background: var(--rs-accent);
  color: var(--rs-on-accent);
  font-weight: 500;
  font-size: 0.9375rem;
  text-decoration: none;
  transition: background-color 150ms ease-out;
}

a.cta-button:hover {
  background: var(--rs-accent-hover);
}

/* --- Article ------------------------------------------------------------- */

.article {
  max-width: calc(var(--measure) + 3rem);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

@media (max-width: 727px) {
  .article {
    padding: 1.5rem 1rem 3rem;
  }
}

@media (min-width: 728px) {
  .article {
    padding-top: 3rem;
  }
}

.kicker {
  margin: 0 0 1rem;
}

.byline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 2rem 0 0;
  padding: 0.85rem 0;
  border-top: 1px solid var(--rs-line);
  border-bottom: 1px solid var(--rs-line);
}

.avatar {
  border-radius: 50%;
  flex: none;
}

.byline p {
  margin: 0;
}

.byline-name {
  font-weight: 500;
}

.byline-meta {
  color: var(--rs-subtle);
  font-size: 0.875rem;
}

.byline-lang {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-left: auto;
  color: var(--rs-muted);
  font-size: 0.875rem;
  text-align: right;
  transition: color 150ms ease-out;
}

.byline-lang:hover {
  color: var(--rs-accent);
}

/* The cover runs a little wider than the text column on desktop, as on
   Medium, and edge to edge on a phone. */
.cover {
  margin: 2rem -1rem 0;
}

.cover img {
  display: block;
  width: 100%;
}

@media (min-width: 728px) {
  .cover {
    margin: 2.5rem -2rem 0;
  }

  .cover img {
    border-radius: var(--radius-md);
  }
}

.post {
  margin-top: 2.5rem;
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.58;
  letter-spacing: -0.003em;
}

@media (min-width: 728px) {
  .post {
    font-size: 1.25rem;
    line-height: 1.6;
  }
}

.post > :first-child {
  margin-top: 0;
}

.post p,
.post ul,
.post ol {
  margin: 1.8em 0 0;
}

.post h2,
.post h3 {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: -0.014em;
  color: var(--rs-fg);
}

.post h2 {
  margin: 2.1em 0 0;
  font-size: 1.3em;
  line-height: 1.25;
}

.post h2 + p,
.post h3 + p,
.post h2 + ul,
.post h2 + ol {
  margin-top: 0.6em;
}

.post h3 {
  margin: 1.8em 0 0;
  font-size: 1.1em;
  line-height: 1.3;
}

.post ul,
.post ol {
  padding-left: 1.6em;
}

.post li {
  margin-top: 0.7em;
  padding-left: 0.2em;
}

.post a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rs-subtle);
  text-underline-offset: 3px;
  transition: color 150ms ease-out, text-decoration-color 150ms ease-out;
}

.post a:hover {
  color: var(--rs-accent);
  text-decoration-color: currentColor;
}

.post strong {
  font-weight: 700;
}

.post figure {
  margin: 2.2em 0 0;
}

.post figure img,
.post > p > img {
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
}

.post figure.chart {
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.post figcaption {
  margin-top: 0.75rem;
  color: var(--rs-subtle);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.45;
  text-align: center;
}

.post blockquote {
  margin: 1.8em 0 0;
  padding: 0 0 0 1.2em;
  border-left: 3px solid var(--rs-fg);
  font-style: italic;
}

.post blockquote p:first-child {
  margin-top: 0;
}

.post code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8em;
  background: var(--rs-sunken);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}

.post table {
  display: block;
  overflow-x: auto;
  margin: 1.8em 0 0;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.8em;
}

.post th,
.post td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rs-line);
  text-align: left;
}

/* Medium's section break: three spaced dots. */
.post hr {
  border: 0;
  margin: 2.5em 0 0;
  text-align: center;
}

.post hr::before {
  content: '...';
  letter-spacing: 0.6em;
  font-size: 1.5em;
  color: var(--rs-fg);
}

.post-cta {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin: 3.5rem 0 0;
  padding: 1.5rem;
  background: var(--rs-sunken);
  border-radius: var(--radius-md);
}

.post-cta > img {
  flex: none;
  border-radius: 10px;
}

.post-cta p {
  margin: 0 0 1rem;
  color: var(--rs-muted);
}

.post-cta p:last-child {
  margin: 0;
}

/* Related posts: a full-width band under the article, as on Medium. */
.related {
  background: var(--rs-canvas);
  border-top: 1px solid var(--rs-line);
}

.related-inner {
  max-width: calc(var(--measure) + 3rem);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

@media (max-width: 727px) {
  .related-inner {
    padding: 2rem 1rem 2.5rem;
  }
}

.related h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
}

.post-back {
  margin: 1.5rem 0 0;
  font-size: 0.9375rem;
}

.post-back a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--rs-muted);
  text-decoration: none;
  transition: color 150ms ease-out;
}

.post-back a:hover {
  color: var(--rs-fg);
}

/* --- Blog home and topic pages ------------------------------------------- */

.home {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 4rem;
  max-width: 1192px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

@media (min-width: 728px) {
  .home {
    padding: 3rem 1.5rem 5rem;
  }
}

@media (min-width: 1024px) {
  .home {
    grid-template-columns: minmax(0, 1fr) 300px;
  }

  .home-head {
    grid-column: 1 / -1;
  }
}

.home-head {
  max-width: 44rem;
  padding-bottom: 2rem;
}

.home-main {
  min-width: 0;
}

.featured {
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--rs-line);
}

.featured-link {
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-md);
}

.featured-img {
  display: block;
  width: 100%;
  margin-bottom: 1.25rem;
  border-radius: var(--radius-md);
}

.featured h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.625rem;
  line-height: 1.25;
  letter-spacing: -0.012em;
  transition: color 200ms ease-out;
}

@media (min-width: 728px) {
  .featured h2 {
    font-size: 2rem;
  }
}

.featured-link:hover h2 {
  color: var(--rs-accent);
}

.featured .story-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.section-label {
  margin: 2.5rem 0 0;
  color: var(--rs-subtle);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.story {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--rs-line);
}

.story-text {
  flex: 1;
  min-width: 0;
}

.story-topic {
  margin: 0 0 0.6rem;
}

.story-link {
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.story h3 {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.125rem;
  line-height: 1.3;
  letter-spacing: -0.014em;
  transition: color 200ms ease-out;
}

@media (min-width: 728px) {
  .story h3 {
    font-size: 1.375rem;
  }
}

.story-link:hover h3 {
  color: var(--rs-accent);
}

.story-lede {
  margin: 0.5rem 0 0;
  color: var(--rs-muted);
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.5;
}

.story-meta {
  margin: 0.85rem 0 0;
  color: var(--rs-subtle);
  font-size: 0.8125rem;
}

/* Medium's list thumbnail: fixed box to the right, cropped to fill. */
.story-thumb {
  flex: none;
  width: 96px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

@media (min-width: 728px) {
  .story-thumb {
    width: 160px;
    height: 107px;
  }
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-top: 3rem;
}

@media (min-width: 1024px) {
  .sidebar {
    margin-top: 0;
    position: sticky;
    top: 140px;
    align-self: start;
  }
}

.sidebar h2 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.85rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
}

.sidebar h2 img {
  border-radius: 8px;
}

.side-card {
  padding: 1.25rem;
  background: var(--rs-canvas);
  border: 1px solid var(--rs-line);
  border-radius: var(--radius-md);
}

.side-card p {
  margin: 0 0 1rem;
  color: var(--rs-muted);
  font-size: 0.9375rem;
}

.side-card p:last-child {
  margin: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* --- Footer -------------------------------------------------------------- */

.site-footer {
  background: var(--rs-canvas);
  border-top: 1px solid var(--rs-line);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
}

.footer-brand img {
  border-radius: 6px;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
}

.site-footer nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--rs-muted);
  font-size: 0.875rem;
  text-decoration: none;
  transition: color 150ms ease-out;
}

.site-footer nav a:hover {
  color: var(--rs-fg);
}

.footer-legal {
  width: 100%;
  margin: 0;
  color: var(--rs-subtle);
  font-size: 0.8125rem;
}
