/* ========================================
   FONT DECLARATIONS
   ======================================== */

/* Import dynamically generated fonts based on selected scheme */
@import url("/assets/css/fonts.css");

/* ========================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ======================================== */

:root {
  /* Colors - Theme-based (configured in site.json) */
  --color-primary: var(--theme-primary, #002b36);
  /* Primary text, dividers */
  --color-secondary: var(--theme-secondary, #073642);
  /* Body text */
  --color-muted: var(--theme-muted, #657b83);
  /* Muted text */
  --color-background: var(--theme-background, #eee8d5);
  /* Background */
  --color-accent: var(--theme-accent, #268bd2);
  /* Links, accents */
  --color-accent-text: var(--theme-accent-text, var(--theme-accent, #1d6ca2));
  /* Accent darkened enough for small text to clear WCAG AA 4.5:1 */

  /* Typography - Font-scheme based (configured in site.json) */
  /* Fallback stacks keep a sensible look if web fonts fail */
  --font-name: var(
    --fontscheme-name,
    "Bungee Shade",
    "Bungee",
    "Unbounded",
    "Space Grotesk",
    "Inter",
    system-ui,
    sans-serif
  );
  --font-tagline: var(
    --fontscheme-tagline,
    "Bungee",
    "Unbounded",
    "Space Grotesk",
    "Inter",
    system-ui,
    sans-serif
  );
  --font-heading: var(
    --fontscheme-heading,
    "Bungee",
    "Space Grotesk",
    "Inter",
    system-ui,
    sans-serif
  );
  --font-body: var(--fontscheme-body, "EB Garamond", "Playfair Display", "Georgia", serif);
  --font-link: var(--fontscheme-link, "Quicksand", "Inter", system-ui, sans-serif);
  --font-ui: var(--fontscheme-ui, "Quicksand", "Inter", system-ui, sans-serif);
  /* Bengali face. A grotesque-structured Bengali so the ~2/3 of posts written in
     Bangla sit in the same typographic class as the Latin faces, instead of
     introducing a serif voice the rest of the site never uses. */
  --font-bengali: var(--fontscheme-bengali, "Anek Bangla", "Hind Siliguri", sans-serif);
  /* Code face, single source — the stack was previously repeated verbatim in the
     `pre code` and inline `code` rules. */
  --font-mono: "Go Mono", "JetBrains Mono", "Fira Code", "Cascadia Code", "Courier New", monospace;

  /* Font Sizes - Fluid typography using clamp(min, preferred, max) */
  --size-name: clamp(36px, 6.67vw, 96px);
  /* Scales 36-96px */
  --size-tagline: clamp(18px, 3.33vw, 48px);
  /* Scales 18-48px (half of name) */
  --size-heading: clamp(16px, 1.25vw, 18px);
  /* Scales 16-18px */
  --size-body: clamp(18px, 1.67vw, 24px);
  /* Scales 18-24px */
  --size-link: clamp(16px, 1.25vw, 18px);
  /* Scales 16-18px */
  --size-ui: clamp(16px, 1.25vw, 18px);
  /* Scales 16-18px */
  --size-article: clamp(17px, 1.2vw, 19px);
  /* Long-form reading size. Deliberately smaller than --size-body, which is
     tuned for the short intro/timeline copy on the home page. */
  /* ---- Rail type scale: a strict 2:1 halving ----
     --size-name and --size-tagline are already an exact 2:1 pair (6.67vw /
     3.33vw). These continue that series, giving 96 / 48 / 24 / 12 at full
     width, so the rail's four sizes are one series rather than four guesses. */
  --size-rail-title: clamp(22px, 1.67vw, 24px);
  --size-rail: clamp(11px, 0.83vw, 12px);
  --tracking-rail: 0.04em;
  /* Shared letter-spacing for every rail control */

  /* Single vertical unit for the rail. Every gap in the rail is a whole
     multiple of this, so the column reads as measured rather than nudged. */
  --rail-step: 0.55rem;

  /* ---- The shade ----
     Bungee Shade builds the wordmark from a solid, zero-blur offset shadow on the
     letterforms. Every bordered object on the site carries that same gesture, at
     one of two scales: --shade for navigation and markers, --shade-sm for
     metadata. A red field means "this is the marked one" — the year you are
     looking at, the page you are on — and nothing else. */
  --shade-border: 1px;
  /* Thinner than the 2px letterform stroke on purpose: a closed box 34px tall
     carries far more weight per pixel than a stroke on a 96px letter, so equal
     numbers do not read as equal presence. */
  --shade: 4px 4px 0 var(--color-primary);
  --shade-sm: 2px 2px 0 var(--color-primary);

  /* Layout - Fluid and proportional */
  --canvas-width: 1440px;
  --margin-left: clamp(1rem, 8.33vw, 7.5rem);
  /* Fluid margins: 16px-120px */
  --margin-right: clamp(1rem, 8.33vw, 7.5rem);
  /* Fluid margins: 16px-120px */
  --content-width: clamp(20rem, 44.44vw, 40rem);
  /* Fluid content: 320px-640px */
  --article-width: clamp(20rem, 46vw, 45rem);
  /* Article column: 320px-720px — wider than listing for code readability */
  --gap-section: clamp(2rem, 4.17vw, 3.75rem);
  /* Fluid gap: 32px-60px */
  --gap-small: 0.3125rem;
  /* Fixed small gap */
  --gap-timeline: 1rem;
  /* Must exceed the title's internal line gap (9.6px at 24px/1.4) or a wrapped
     title's second line binds to the next row instead of its own first line. */
  /* Fixed timeline gap */

  /* Positioning - Proportional to viewport */
  --header-top: clamp(2rem, 4.58vw, 5rem);
  /* Fluid: 32px-80px */
  --divider-gap: clamp(0.75rem, 1.04vw, 1.25rem);
  /* Fluid: 12px-20px - symmetric gap around divider */
  --divider-height: 2px;
  /* Matches the measured stroke of Bungee Shade's letterform outline at the
     wordmark's 96px — the rule and the logo are drawn with the same pen. */
  --name-line-height: 1;
  /* No extra spacing - keeps text tight */
  --tagline-line-height: 1;
  /* No extra spacing - keeps text tight */
  --divider-top: calc(
    var(--header-top) + var(--size-name) * 2 * var(--name-line-height) + var(--divider-gap)
  );
  --header-full-height: calc(
    var(--header-top) + var(--size-name) * 2 * var(--name-line-height) + var(--divider-gap) * 2 +
      var(--size-tagline) * 2 * var(--tagline-line-height)
  );
  --initial-bottom-spacing: var(--header-top);
  /* Match header-top for symmetry */

  /* ---- The two rail anchors ----
     Everything positioned in the left rail measures from one of exactly these
     two lines. Adding a third is how the rail lost its grid the first time.

     --matra: the rule under the wordmark. Both columns hang from it — rail
     title/meta and the content column start here, which is what makes the two
     columns read as one page. Named for the headstroke Bengali script hangs
     from, which this site is half written in. */
  --matra: calc(var(--divider-top) + var(--divider-gap));

  /* --rail-floor: the foot group (nav, filters, socials, utility) sits on this,
     offset to mirror --header-top so top and bottom margins match. */
  --rail-floor: var(--initial-bottom-spacing);

  /* Where the content column's first line lands. The rail's nav hangs off the
     same value so "home" and "I'm a tinkerer…" start on one line — that
     alignment is why the original carried a +0.575em nudge here. */
  --content-top: max(
    calc(100vh - var(--initial-bottom-spacing) - 10rem),
    calc(var(--divider-top) + 5rem)
  );
}

/* ========================================
   SKIP LINK
   ======================================== */

/* Offscreen until focused, then it arrives as a chip like the rail nav — the
   one keyboard-only control on the site, so it should look like it belongs. */
.skip-link {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  padding: 6px 10px;
  font-family: var(--font-ui);
  font-size: var(--size-rail);
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: var(--tracking-rail);
  text-decoration: none;
  background: var(--color-accent);
  border: var(--shade-border) solid var(--color-primary);
  transform: translateY(-150%);

  &:focus-visible {
    box-shadow: var(--shade);
    transform: translateY(0);
  }
}

/* ========================================
   RESET & BASE STYLES
   ======================================== */

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  /* Base for rem calculations */
}

/* Hide scrollbar completely - down arrow indicates scrollable content */
html {
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE/Edge */
}

html::-webkit-scrollbar {
  display: none;
  /* Chrome/Safari/Opera */
}

body {
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: 1.5;
  color: var(--color-secondary);
  background-color: var(--color-background);
}

a {
  color: var(--color-accent-text);
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

ul {
  list-style: none;
}

/* The UA stylesheet's [hidden] { display: none } is beaten by any author
   `display` rule, so a flex/grid container with the hidden attribute stays
   visible. The language toggle relies on [hidden]; this makes it hold. */
[hidden] {
  display: none !important;
}

/* ========================================
   FIXED HEADER
   ======================================== */

.site-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 100;
}

.site-header__background {
  position: absolute;
  top: 0;
  right: var(--margin-right);
  left: var(--margin-left);
  height: var(--divider-top);
  background-color: var(--color-background);
  border: 1px solid var(--color-background);
}

.site-header__name {
  position: absolute;
  top: var(--header-top);
  left: var(--margin-left);
  width: 29.75rem;
  /* 476px */
  /* Bungee Shade's cap has a 0.045em left sidebearing; without this the wordmark's
     ink sits ~4px right of the small text below it. In em to hold across the clamp. */
  margin: 0 0 0 -0.045em;
  font-family: var(--font-name);
  font-size: var(--size-name);
  font-weight: normal;
  line-height: var(--name-line-height);
  color: var(--color-primary);
}

.site-header__name a {
  color: inherit;
  text-decoration: none;
}

.site-header__name a:hover {
  text-decoration: none;
}

.site-header__divider {
  position: absolute;
  top: var(--divider-top);
  right: var(--margin-right);
  left: var(--margin-left);
  height: var(--divider-height);
  margin: 0;
  background-color: var(--color-primary);
  border: none;
  border-radius: 10px;
}

/* The single anchored block below the rule. The section label, its filters and
   any page title stack inside it, so the rail keeps one positioning origin
   instead of one per element. */
.site-header__rail {
  position: absolute;
  top: var(--matra);
  left: var(--margin-left);
  display: flex;
  flex-direction: column;
  gap: var(--rail-step);
  align-items: flex-start;
  /* Constrain width to not overlap with the content column */
  max-width: calc(100vw - var(--margin-left) - var(--margin-right) - var(--content-width) - 2rem);
}

/* Article pages run a wider content column (--article-width), so the rail has to
   give up the difference. Without this a long title — the Bengali ones run to
   ~180 characters — overflows the rail and collides with the body text. */
.site-header__rail--article {
  max-width: calc(100vw - var(--margin-left) - var(--margin-right) - var(--article-width) - 2rem);
}

.site-header__tagline {
  /* Same optical correction as the wordmark; Bungee's cap sidebearing is 0.069em */
  margin: 0 0 0 -0.069em;
  font-family: var(--font-tagline);
  font-size: var(--size-tagline);
  font-weight: normal;
  line-height: var(--tagline-line-height);
  color: var(--color-primary);
}

/* Separated from the navigation above it by three steps, so the title and its
   byline group as one block instead of reading as more nav. */
.site-header__meta {
  margin-top: calc(var(--rail-step) * 3);
}

/* A page title is content, not a label, so it takes the middle register — the
   same face as the listing titles it was clicked from. Exactly half
   --size-tagline, continuing the rail's 2:1 series. */
.site-header__page-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--size-rail-title);
  font-weight: normal;
  line-height: 1.2;
  color: var(--color-primary);
  letter-spacing: 0;
  /* Long unbroken strings must not push past the rail's max-width */
  overflow-wrap: anywhere;
}

.site-header__page-title--bn {
  font-family: var(--font-bengali);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0;
}

/* Byline under the article title. Shares the listing's meta treatment exactly,
   so the same fields read the same way in both places. */
/* Byline: same size as the nav line but untracked and lighter, so it reads as
   description rather than a control. */
.site-header__meta-lines {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.35rem;
  font-family: var(--font-ui);
  font-size: var(--size-rail);
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-muted);
  letter-spacing: 0;
}

.site-header__meta-date {
  display: block;
  font: inherit;
  color: inherit;
}

/* ========================================
   FIXED SOCIAL MENU
   ======================================== */

/* The rail's foot group: the only fixed element down here. It sits on
   --rail-floor and grows upward, so the whole nav shares one origin instead of
   the bespoke calc()s this replaced. */
.rail-foot {
  position: fixed;
  /* Top-anchored to the content column's first line, not the viewport floor —
     half-leading added so the chip's top edge meets the text's top, not its
     line box. */
  top: calc(var(--content-top) + var(--size-body) * 0.17);
  left: var(--margin-left);
  z-index: 50;
  display: flex;
  flex-direction: column;
  /* Three steps: consent is not navigation, so the wider gap separates the two
     groups without needing a rule or a box to divide them. */
  gap: calc(var(--rail-step) * 3);
  align-items: flex-start;
}

/* Text nav, one item per line. The type is set here rather than on the link:
   with font-size only on the inline <a>, `line-height` resolved against the
   inherited 24px body size and produced 41px line boxes. */
/* WCAG 2.5.8 wants a 24x24 minimum target. These are ~12px-tall links, so the
   hit area comes from padding rather than the type size. Unscoped on purpose:
   a 1440px viewport can still be a touchscreen. */
.rail-nav__link,
.rail-nav__btn,
.consent-chip__reopen {
  display: inline-block;
  min-height: 24px;
  padding-block: 6px;
}

/* One horizontal nav line. The current section expands in place, so blog-only
   controls sit inside the `blog` item rather than in a separate bar. */
.rail-nav__list {
  /* A single max-content track makes every chip as wide as the widest label, so
     four stacked boxes line up instead of stepping in and out. */
  display: grid;
  grid-template-columns: max-content;
  gap: 0.5rem;
  justify-items: stretch;
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--size-rail);
  font-weight: 600;
  letter-spacing: var(--tracking-rail);
  list-style: none;
}

.rail-nav__item {
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
}

/* The expanded section: same size, but muted and unbolded so it reads as
   subordinate to the section it belongs to. */
.rail-nav__sub {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
  /* Clear of the chip's 4px shade, which the old 0.45rem gap ran into */
  margin-left: 0.5rem;
  font-weight: 400;
  color: var(--color-muted);
}

.rail-nav__langs {
  display: flex;
  gap: 0.3rem;
  align-items: baseline;
}

/* Navigation is the most repeated object on the page, so it carries the shade —
   that is what makes the device a system rather than two exceptions. */
.rail-nav__item > .rail-nav__link {
  /* min-width, not stretch: the <li> is a flex row (the blog item carries the
     sub-run beside its chip), so the chip has to size itself. */
  min-width: 4rem;
  padding: 6px 10px;
  color: var(--color-primary);
  text-decoration: none;
  background: var(--color-background);
  border: var(--shade-border) solid var(--color-primary);
  box-shadow: var(--shade);
  transition:
    transform 0.08s ease-out,
    box-shadow 0.08s ease-out;

  &:hover,
  &:active {
    text-decoration: none;
    box-shadow: 0 0 0 var(--color-primary);
    /* Push down onto its own shadow */
    transform: translate(4px, 4px);
  }
}

/* Marked position, same red field as the year marker. Black on #ff3333 = 5.77:1. */
.rail-nav__item > .rail-nav__link--current {
  color: var(--color-primary);
  background: var(--color-accent);
}

/* Inside this section, but not on this page — a post or a topic. The page you
   are actually on gets a red field; the way back to its index gets a red
   outline. Same colour, different role, and this one stays a link. */
.rail-nav__item > .rail-nav__link--section {
  color: var(--color-accent-text);
  border-color: var(--color-accent-text);
}

/* The section's own controls stay plain text — a second tier under the chip. */
.rail-nav__sub .rail-nav__link {
  padding-block: 6px;
  color: var(--color-muted);
  background: none;
  border: none;
  box-shadow: none;

  &:hover {
    color: var(--color-accent-text);
    text-decoration: underline;
    text-underline-offset: 3px;
    transform: none;
  }
}

.rail-nav__sub .rail-nav__link {
  color: inherit;

  &:hover {
    color: var(--color-accent-text);
  }
}

.rail-nav__btn {
  padding-inline: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  transition: color 0.1s ease;

  &:hover {
    color: var(--color-accent-text);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

.rail-nav__btn--active {
  color: var(--color-primary);
}

/* ========================================
   MAIN CONTENT (Scrollable)
   ======================================== */

.main-content {
  position: relative;
  right: var(--margin-right);
  display: flex;
  flex-direction: column;
  gap: var(--gap-section);
  width: var(--content-width);
  /* Push content down so only intro is visible initially */
  /* Add extra space to clear the fixed header completely */
  padding-top: var(--content-top);
  padding-bottom: var(--initial-bottom-spacing);
  margin-top: 0;
  margin-left: auto;
}

/* ========================================
   CONTENT SECTIONS
   ======================================== */

.content-section {
  display: flex;
  flex-direction: column;
  gap: var(--gap-small);
}

/* Section labels ("TIMELINE", "ABOUT") are labels, not content titles, so they
   keep the display face — same rule as "BLOG" in the rail. --font-heading is the
   content face (Archivo) and would be wrong here. */
.content-section__heading {
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--size-heading);
  font-weight: normal;
  line-height: 1.33;
  /* 24px line height */
  color: var(--color-muted);
}

.content-section__text {
  font-family: var(--font-body);
  font-size: var(--size-body);
  font-weight: normal;
  line-height: 1.5;
  color: var(--color-secondary);
  text-align: left;

  & p {
    margin-bottom: 1.5rem;

    &:last-child {
      margin-bottom: 0;
    }
  }
}

/* ========================================
   INTRO SECTION
   ======================================== */

.intro__text {
  flex: 1;
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: 1.5;
  color: var(--color-secondary);
  /* Ragged right. Justifying without hyphenation stretched the word spaces into
     visible rivers at this measure. */
  text-align: left;
}

.intro__scroll-indicator {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: var(--gap-small);
  font-size: 16px;
  color: var(--color-secondary);
  transition: opacity 0.4s ease;
}

/* Bobbing hint that the page scrolls; stops once the reader scrolls. */
@keyframes scroll-bob {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(0.4rem);
  }
}

.intro__scroll-indicator i {
  animation: scroll-bob 1.5s ease-in-out infinite;
}

.intro__scroll-indicator--hidden {
  opacity: 0;
}

/* The push-down is motion; the colour change is not. Keep the feedback, drop
   the movement. */
@media (prefers-reduced-motion: reduce) {
  .site-header__meta-tag:hover {
    box-shadow: var(--shade-sm);
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .intro__scroll-indicator i {
    animation: none;
  }
}

.content-section--intro {
  display: flex;
  flex-direction: row;
  gap: var(--gap-small);
  align-items: flex-end;
}

/* ========================================
   TIMELINE
   ======================================== */

/* ========================================
   POST ARCHIVE — posts grouped under year subheadings
   ======================================== */

.post-archive {
  display: flex;
  flex-direction: column;
  gap: var(--gap-section);
}

.post-archive__group {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* Same treatment as the home timeline's section headings (TIMELINE / ABOUT):
   the display face, small, muted. A year is a section header, not an object —
   giving it the shade made it read as a second menu button. */
.post-archive__year {
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--size-heading);
  font-weight: normal;
  line-height: 1.33;
  color: var(--color-muted);
}

/* ========================================
   INDEX LIST — one list primitive, three uses
   ======================================== */

/* A row is: label on the left, right-aligned index after an arrow.
     home timeline  → label = prose,     index = year
     post listing   → label = title,     index = date
     tag index      → label = tag,       index = post count
   These were three unrelated treatments (the tag list even had hairline row
   borders used nowhere else on the site); sharing the primitive is what makes
   them read as the same object. */
.index-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-timeline);
}

.index-list__row {
  display: flex;
  gap: var(--gap-section);
  align-items: baseline;
}

.index-list__label {
  flex: 1;
  min-width: 0;
  margin: 0;
}

/* The timeline's label is running prose, not a link */
.index-list__label--prose {
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: 1.5;
  color: var(--color-secondary);
  text-align: left;
}

.timeline__link {
  color: var(--color-accent-text);
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

/* The type is set here, not on the inner <time>, so the arrow's em-based size
   resolves against this row's scale rather than the inherited body size.
   align-items: center puts the arrow on the optical middle of the value it
   points at, rather than on its baseline where it sat low. */
.index-list__index {
  display: flex;
  flex-shrink: 0;
  gap: 0.45em;
  align-items: center;
  justify-content: flex-end;
  /* Mono, so the index reads as a stamp against the title rather than competing
     with it as more prose. */
  font-family: var(--font-mono);
  font-size: calc(var(--size-ui) * 0.8);
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-primary);

  /* The value's width is reserved here, on the primitive, so the arrow column
     lands at the same x on every page. The index is right-aligned with the arrow
     first, so a narrower value ("2025", "4 Mar") pushes the arrow rightwards —
     reserving the width of the longest value ("23 Sept") pins the whole column.
     Reserving it on the container instead does nothing, since the container is
     already sized by its content. */
  & time,
  & span {
    min-width: 3.9em;
    font: inherit;
    font-variant-numeric: tabular-nums;
    color: inherit;
    text-align: right;
  }
}

/* Sized in em so it tracks the index's own font-size, which differs between the
   timeline (--size-ui) and the post/tag rows (--size-rail). */
.index-list__arrow {
  flex-shrink: 0;
  font-size: 0.9em;
  color: var(--color-primary);
  opacity: 0.5;
}

/* Post/tag rows: the label is a link in the content face, and the index steps
   down to the rail scale so the titles lead. */
/* Same treatment as the home timeline's label: body face, body size, regular
   weight, secondary colour. The only addition is a hover affordance, because
   these labels are links and the timeline's are inert prose — without it a
   column of 29 headlines gives no sign it is clickable. */
.index-list__title {
  padding: 0 0.15em;
  margin-left: -0.15em;
  font-family: var(--font-body);
  font-size: var(--size-body);
  font-weight: 700;
  line-height: 1.4;
  color: var(--color-primary);
  text-decoration: none;

  &:hover {
    color: var(--color-accent-text);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
  }
}

/* Bengali reads optically lighter than Latin at the same size and weight, so it
   takes one step up to sit level with the Latin rows; the looser leading gives
   the conjuncts and vowel signs room. */
.index-list__title--bn {
  font-family: var(--font-bengali);
  font-weight: 500;
  line-height: 1.75;
}

/* Post and tag rows keep the timeline's index treatment exactly — same face,
   size, weight, colour, arrow and column position — so the "label → index" row
   is one component across the home page, the listing and the topic pages. */

/* ========================================
   CONTENT LINKS
   ======================================== */

.content-link {
  color: var(--color-accent-text);
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Transition zone - add extra top padding to prevent overlap */
@media (min-width: 1101px) and (max-width: 1300px) {
  .main-content {
    /* Use a safe fixed value that ensures clearance at these widths */
    padding-top: max(calc(100vh - var(--initial-bottom-spacing) - 10rem), 30rem);
  }
}

/* Large screens - center content within max canvas */
@media (min-width: 1600px) {
  :root {
    --margin-left: calc((100vw - var(--canvas-width)) / 2 + 7.5rem);
    --margin-right: calc((100vw - var(--canvas-width)) / 2 + 7.5rem);
  }
}

/* Tablet and below - stack layout instead of side-by-side */
@media (max-width: 1100px) {
  /* Source order is header -> rail foot -> content, which is right for the fixed
     rail but wrong once everything is in flow: nav, rss and the consent controls
     ended up above the article on every page. Push the foot group last. */
  body {
    display: flex;
    flex-direction: column;
  }

  .rail-foot {
    position: relative;
    top: auto;
    order: 3;
  }

  /* Make header static/relative instead of fixed */
  .site-header {
    position: relative;
  }

  .site-header__background {
    position: relative;
    right: 0;
    left: 0;
    height: auto;
    padding: var(--header-top) 0 var(--divider-gap) 0;
  }

  .site-header__name {
    position: relative;
    top: 0;
    left: 0;
    width: calc(100% - var(--margin-left) - var(--margin-right));
    max-width: 100%;
    margin: 0 var(--margin-right) 0 var(--margin-left);
  }

  .site-header__divider {
    position: relative;
    top: 0;
    right: 0;
    left: 0;
    margin: var(--divider-gap) var(--margin-right) var(--divider-gap) var(--margin-left);
  }

  /* The rail block un-anchors as a unit; its children stay in normal flow
     inside it, so they need no overrides of their own. */
  .site-header__rail {
    position: relative;
    top: 0;
    left: 0;
    width: calc(100% - var(--margin-left) - var(--margin-right));
    max-width: 100%;
    margin: 0 var(--margin-right) 0.75rem var(--margin-left);
  }

  /* Nothing to pin against on a scrolling page — the foot group drops into
     flow under the header instead of floating over the content. */
  .rail-foot {
    position: relative;
    bottom: auto;
    left: auto;
    margin: 2rem var(--margin-left) 2rem var(--margin-left);
  }

  /* Make content full width and stack below */
  .main-content {
    position: relative;
    right: auto;
    width: auto;
    max-width: none;
    padding-top: 0;
    margin: 0 var(--margin-right) var(--initial-bottom-spacing) var(--margin-left);
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

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

/* Focus styles for keyboard navigation */
a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  white-space: nowrap;
  border-width: 0;
  clip-path: inset(50%);
}

/* Byline topics. Outlined chips at the metadata scale: the same object as a nav
   chip, one step down — --shade-sm rather than --shade. Previously these were
   bare red text, the only place in the design where red was type rather than a
   marked field. */
.site-header__meta-tag {
  display: inline-block;
  padding: 3px 7px;
  color: var(--color-accent-text);
  text-decoration: none;
  background: var(--color-background);
  border: var(--shade-border) solid var(--color-primary);
  box-shadow: var(--shade-sm);
  transition:
    transform 0.08s ease-out,
    box-shadow 0.08s ease-out;

  &:hover,
  &:focus-visible {
    box-shadow: 0 0 0 var(--color-primary);
    transform: translate(2px, 2px);
  }
}

.site-header__meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  font: inherit;
  color: inherit;
}

/* Outlined chip, restoring the original /* ========================================
   RAIL UTILITY ROW (rss | analytics)
   ======================================== */

/* Shared divider glyph — between EN and BN, and before the feed link */
.rail-sep {
  user-select: none;
  opacity: 0.4;
}

/* Utility row in the rail foot: rss and the consent control, neither of which
   is navigation. In flow inside .rail-foot, so no positioning of its own. */
.rail-utility {
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
  /* No indent: this row starts on --margin-left, the same line as the wordmark,
     the rule, the section label and the chips' own left edges. Matching the
     chips' inner text padding instead would align it to nothing else on the page. */
  font-family: var(--font-ui);
  font-size: var(--size-rail);
  font-weight: 400;
  color: var(--color-muted);
  letter-spacing: var(--tracking-rail);
}

.rail-utility__link {
  color: inherit;
  text-decoration: none;
  transition: color 0.12s ease;

  &:hover {
    color: var(--color-accent-text);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

/* ========================================
   CONSENT CHIP
   ======================================== */

/* Sits below the nav in the quietest tier, so it takes the sub-run's weight
   (topics / rss), not the nav chips' 600. Only state-specific behaviour here. */
.consent-chip {
  font-family: var(--font-ui);
  font-size: var(--size-rail);
  font-weight: 400;
  color: var(--color-muted);
  letter-spacing: var(--tracking-rail);
}

.consent-chip__question {
  display: inline-flex;
  gap: 0.3rem;
  align-items: baseline;
}

/* No flex gap here: the brackets are flex items too, so a gap would space them
   off the Y/N as "( Y / N )". Spacing is applied to the separator alone. */
.consent-chip__actions {
  display: inline-flex;
  gap: 0;
  align-items: baseline;

  &::before {
    content: "(";
  }

  &::after {
    content: ")";
  }
}

.consent-chip__question--hidden {
  display: none;
}

.consent-chip__sep {
  margin: 0 0.25rem;
}

/* Y / N keep their underline: they sit inside the prose question and need a
   click affordance to read as actions rather than label text. */
/* Inline in the "analytics? (y / n)" sentence, so WCAG 2.5.8's inline exception
   applies to the height — but 6.6px wide is still a mean target, hence the
   horizontal padding. */
.consent-chip__btn {
  padding: 0 0.8em;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  background: none;
  border: none;

  &:hover {
    color: var(--color-accent);
  }
}

/* Collapsed state is a plain rail item, so it matches the rss link beside it */
.consent-chip__reopen {
  padding: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  transition: color 0.12s ease;

  &:hover {
    color: var(--color-accent-text);
  }
}

.consent-chip__reopen--hidden {
  display: none;
}

/* ========================================
   BLOG CONTENT WRAPPER
   Shared by listing page and article page
   ======================================== */

.blog-content {
  position: relative;
  right: var(--margin-right);
  display: flex;
  flex-direction: column;
  gap: var(--gap-section);
  width: var(--content-width);
  min-width: 0;
  /* Start the list at the hr / rail level (the lang bar lives in the rail). */
  padding-top: var(--matra);
  padding-bottom: var(--initial-bottom-spacing);
  margin-top: 0;
  margin-left: auto;
}

/* Article pages get a wider column; listing keeps --content-width */
/* Also start content just under the divider (not pushed to menu level) */
.blog-content--article {
  width: var(--article-width);
  /* Align the body's first line with the masthead title on the left rail
     (both start at divider-top + divider-gap). */
  padding-top: var(--matra);
}

.blog-tags-link {
  margin-top: -0.5rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;

  & a {
    color: var(--color-muted);
    text-decoration: none;

    &:hover {
      color: var(--color-accent);
    }
  }
}

@media (max-width: 1100px) {
  .blog-content,
  .blog-content--article {
    position: relative;
    right: auto;
    width: auto;
    max-width: none;
    padding-top: 0;
    margin: 0 var(--margin-right) var(--initial-bottom-spacing) var(--margin-left);
  }
}

/* ========================================
   BLOG INDEX — language bar + post cards
   ======================================== */

/* No-JS fallback language subheadings */
.blog-lang-heading {
  margin: 1.5rem 0 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ========================================
   BLOG POST — article template
   ======================================== */

.article {
  min-width: 0;
}

/* The measure lives here, not on .article: `ch` resolves against the element's
   own font-size, and .article inherits the 24px body size, so the old
   `max-width: 66ch` computed to ~917px and never bound at all. Here it resolves
   against --size-article. 59ch reads as ~70 characters, since `ch` is the width
   of "0" (10.03px in Go) against an average lowercase glyph of 8.39px. */
.article-body {
  max-width: 59ch;
}

/* Body */
.article-body {

  /* Headings inside article.
     Three levels distinguished by family, size, case and space, not size alone:
     only h2 takes the display face, h3 and h4 are the body face at 700. Space
     above steps down with the level (2.75 / 1.9 / 1.4rem), so the gap alone
     tells you which level you are looking at. */
  /* The column top is a fixed line — it sits with the section label in the rail.
     flow-root keeps child margins inside this box; without it a leading heading's
     margin-top collapses out and drags the whole column down, so the article
     started on a different line depending on whether the post happened to open
     with a heading. The second selector covers a leading image, which markdown
     wraps in a paragraph and which carries its own top margin. */
  display: flow-root;
  font-family: var(--font-body);
  font-size: var(--size-article);
  line-height: 1.7;
  color: var(--color-secondary);
  overflow-wrap: break-word;

  & p {
    margin: 0 0 1.25rem;

    &:last-child {
      margin-bottom: 0;
    }
  }

  /* Links: accent underlined */
  & a {
    color: var(--color-accent-text);
    text-decoration: underline;
    text-underline-offset: 2px;

    &:hover {
      text-decoration: none;
    }
  }

  & > :first-child,
  & > :first-child > :first-child {
    margin-top: 0;
  }

  & h2,
  & h3,
  & h4 {
    color: var(--color-primary);
  }

  /* The section break. Bungee is caps-only in effect and heavy, so it stays
     above ~24px, where it is still legible at sentence length. */
  & h2 {
    margin: 2.75rem 0 0.7rem;
    font-family: var(--font-heading);
    font-size: calc(var(--size-article) * 1.6);
    font-weight: normal;
    line-height: 1.15;
    letter-spacing: 0;
  }

  /* Subordinate to h2 by family, not by size: the body face at 700 so
     sentence-length subheadings stay readable. */
  & h3 {
    margin: 1.9rem 0 0.45rem;
    font-family: var(--font-body);
    font-size: calc(var(--size-article) * 1.25);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0;
  }

  /* Label tier: body size, so it separates from h3 by case and tracking only. */
  & h4 {
    margin: 1.4rem 0 0.35rem;
    font-family: var(--font-body);
    font-size: var(--size-article);
    font-weight: 700;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  /* No post currently uses one; this only guarantees a deliberate mark instead of
     the browser's default groove if one ever appears. Same 2px pen as
     .site-header__divider, but a fraction of the column and left-aligned to the
     text, so it cannot be mistaken for the masthead rule. The shade is not used
     here: it marks objects, and a break is a gap, not an object. */
  & hr {
    width: 4rem;
    height: var(--divider-height);
    margin: 2.75rem 0;
    background: var(--color-primary);
    border: 0;
  }

  /* Blockquote: 2px accent left rule */
  & blockquote {
    padding: 0.5rem 0 0.5rem 1.25rem;
    margin: 1.25rem 0;
    font-style: italic;
    color: var(--color-muted);
    border-left: 2px solid var(--color-accent);

    & p {
      margin: 0;
    }
  }

  /* Code: light-gray bg + hairline border + mono */
  & pre {
    max-width: 100%;
    padding: 0.9rem 1rem;
    margin: 1.25rem 0;
    overflow-x: auto;
    font-size: 0.85em;
    line-height: 1.5;
    word-break: normal;
    overflow-wrap: normal;
    white-space: pre;
    background: #f6f6f6;
    border: 1px solid rgb(0 0 0 / 10%);
    border-radius: 3px;
  }

  & pre code {
    padding: 0;
    font-family: var(--font-mono);
    background: none;
    border: none;
    border-radius: 0;
  }

  & :not(pre) > code {
    padding: 0.1em 0.35em;
    font-family: var(--font-mono);
    font-size: 0.85em;
    overflow-wrap: break-word;
    background: #f0f0f0;
    border-radius: 2px;
  }

  /* Images: full column width */
  & img {
    display: block;
    width: 100%;
    height: auto;
    margin: 1.25rem 0 0.25rem;
  }

  /* Image captions */
  & figcaption,
  & .caption {
    margin-bottom: 1.25rem;
    font-family: var(--font-ui);
    font-size: 0.72rem;
    color: var(--color-muted);
  }

  /* figure */
  & figure {
    margin: 1.25rem 0;
  }

  /* Lists */
  & ul,
  & ol {
    margin: 0 0 1.25rem 1.5rem;
    list-style: revert;
  }
}

/* Bengali post body */
/* Same reading scale as English posts (--size-article, not the old --size-body),
   nudged up slightly because Bengali runs optically smaller at equal size. The
   looser leading gives the conjuncts and vowel signs room. */
.article-body--bn {
  font-family: var(--font-bengali);
  font-size: calc(var(--size-article) * 1.08);
  line-height: 1.8;
}

/* The descendant `.article-body h2` rule out-specifies the block above, so
   Bengali headings were resolving to Bungee — which has no Bengali coverage — and
   falling back to a system sans, visibly different from the body. Same escape
   hatch as .site-header__page-title--bn. */
.article-body--bn :is(h2, h3, h4) {
  font-family: var(--font-bengali);
  font-weight: 600;
  line-height: 1.4;
  /* Anek Bangla covers the whole scale, so the Latin h2/h3 family split has no
     Bengali equivalent; weight carries the top level instead. */
  text-transform: none;
  letter-spacing: 0;
}

.article-body--bn h2 {
  font-weight: 700;
}

/* Article footer */
.article-footer {
  margin-top: 2.5rem;
}

.article-footer__rule {
  height: 1px;
  margin: 0 0 1.25rem;
  background-color: rgb(0 0 0 / 12%);
  border: none;
}

.article-footer__back {
  display: inline-flex;
  gap: 0.45em;
  align-items: center;
  font-family: var(--font-ui);
  font-size: var(--size-rail);
  font-weight: 600;
  color: var(--color-accent-text);
  letter-spacing: var(--tracking-rail);
  text-decoration: none;

  &:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

.article-footer__arrow {
  flex-shrink: 0;
  font-size: 0.9em;
}

@media (max-width: 1100px) {
  .article-body {
    max-width: none;
  }

  /* Slightly smaller code font on mobile for readability */
  .article-body pre {
    font-size: 0.75em;
  }
}

/* ========================================
   PRISM SYNTAX HIGHLIGHTING
   Minimal light theme — muted, no loud rainbow
   ======================================== */

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  font-style: italic;
  color: #8a9099;
}

.token.punctuation {
  color: #5a6069;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: #8a5f3b;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #3b7a57;
}

.token.operator,
.token.entity,
.token.url {
  color: #5a6069;
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: #3b5f8a;
}

.token.function,
.token.class-name {
  color: #6b3b8a;
}

.token.regex,
.token.important,
.token.variable {
  color: #7a5a3b;
}

.token.important,
.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}

/* Line numbers (if enabled) */
.line-numbers .line-numbers-rows {
  border-right: 1px solid rgb(0 0 0 / 10%);
}

.line-numbers-rows > span::before {
  color: #b0b8c0;
}
