/* ---------------------------------------------------------------
   Papers for Dummies
   A programmer's notebook, typeset properly. One narrow column,
   one family (IBM Plex), ink-coloured links, no chrome.
   Cayman's blue-green survives as the brand: the masthead gradient,
   the headings, the rails. Everything else is ink or grey.
   Signal colour carries information or it isn't used:
     red   = this is broken      green = this works
   Light only. No build step.
   --------------------------------------------------------------- */

:root {
  --paper:        #ffffff;
  --paper-2:      #f5f6f8;   /* code, callouts */
  --ink:          #1b2a3a;   /* headings, links, wordmark */
  --text:         #33424f;   /* body */
  --muted:        #5f6c79;   /* meta, secondary nav */
  --rule:         #e3e7eb;
  --rule-strong:  #c9d0d6;
  --brand:        #159957;   /* Cayman green: headings, rails, active tab */
  --brand-2:      #155799;   /* Cayman blue: far end of the masthead gradient */
  --accent:       #1e6bb8;   /* Cayman link blue: hover, focus */
  --broke:        #b8321a;   /* evidence: this failed */
  --works:        #1f7a3f;   /* evidence: this held */

  --sans:  "IBM Plex Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --tamil: "Noto Sans Tamil", "Nirmala UI", "Latha", "Tamil Sangam MN", sans-serif;
  --deva:  "IBM Plex Sans Devanagari", "Noto Sans Devanagari", "Nirmala UI", "Kohinoor Devanagari", "Devanagari Sangam MN", sans-serif;

  --measure: 42rem;
  --gutter: 1.25rem;
}

* { box-sizing: border-box; }

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  line-height: 1.6;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* ---------- links ---------- */
a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: .18em;
  transition: color .12s, text-decoration-color .12s;
}
a:hover { color: var(--accent); text-decoration-color: currentColor; }

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

/* ---------- masthead ---------- */
.masthead {
  background-color: var(--brand);
  background-image: linear-gradient(120deg, var(--brand-2), var(--brand));
  color: #fff;
}
.masthead .inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1rem var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
}
.masthead-name {
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.masthead-name:hover { color: #fff; }
.masthead-nav { display: flex; gap: 1.25rem; font-size: .95rem; }
.masthead-nav a { color: rgba(255,255,255,.78); text-decoration: none; }
.masthead-nav a:hover,
.masthead-nav a[aria-current] { color: #fff; }
.masthead :focus-visible { outline-color: #fff; }

/* ---------- column ---------- */
.main-content {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter) 2rem;
}

.title-block { padding: 3rem 0 1rem; }
.title-block h1 { max-width: 34rem; }

h1, h2, h3, h4 {
  color: var(--brand);
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
}
h1 {
  font-size: 2.35rem;
  line-height: 1.12;
  letter-spacing: -.012em;
  margin-bottom: .8rem;
}
h2 { font-size: 1.45rem; margin: 2.75rem 0 .9rem; }
h3 { font-size: 1.12rem; margin: 2rem 0 .7rem; }

p { margin: 0 0 1.1rem; }

.lede {
  font-size: 1.2rem;
  line-height: 1.5;
  max-width: 36rem;
  margin-bottom: .9rem;
}
.paper-meta,
.muted { color: var(--muted); }
.title-block .paper-meta { font-size: 1rem; margin-bottom: .5rem; }
small, .small { font-size: .9rem; }

ul, ol { margin: 0 0 1.1rem; padding-left: 1.4rem; }
li { margin-bottom: .35rem; }

blockquote {
  margin: 1.75rem 0;
  padding: .1rem 0 .1rem 1.1rem;
  border-left: 3px solid var(--rule-strong);
}
blockquote > :last-child { margin-bottom: 0; }
blockquote strong { color: var(--ink); }

hr {
  height: 1px;
  margin: 2.5rem 0;
  border: 0;
  background: var(--rule);
}

strong { color: var(--ink); font-weight: 600; }

/* ---------- code ---------- */
code {
  font-family: var(--mono);
  font-size: .9em;
  color: var(--ink);
  background: var(--paper-2);
  padding: .1em .35em;
  border-radius: 3px;
}
pre {
  font-family: var(--mono);
  font-size: .8rem;   /* an 85-char line fits the widened box on wide screens */
  line-height: 1.55;
  color: var(--text);
  background: var(--paper-2);
  padding: 1rem 1.2rem;
  margin: 1.25rem 0;
  border-radius: 4px;
  overflow-x: auto;
}
pre code {
  font-size: inherit;
  color: inherit;
  background: none;
  padding: 0;
  border-radius: 0;
}
/* evidence from the running code */
pre .hl { color: var(--broke); font-weight: 600; }
pre .ok { color: var(--works); font-weight: 600; }

/* the homepage opens on the site's subject: a function */
.hero-code {
  font-size: .95rem;
  padding: 1.25rem 1.4rem;
  margin: 1.5rem 0 1.25rem;
  border-left: 3px solid var(--brand);
  border-radius: 0 4px 4px 0;
  color: var(--ink);
}

.formula {
  font-family: var(--mono);
  font-size: 1.15rem;
  text-align: center;
  color: var(--ink);
  background: var(--paper-2);
  padding: 1.2rem 1rem;
  margin: 1.5rem 0;
  border-radius: 4px;
  overflow-x: auto;
}

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; margin: 1.25rem 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
  line-height: 1.45;
}
th {
  text-align: left;
  font-weight: 600;
  color: var(--ink);
  padding: .5rem 1rem .5rem 0;
  border-bottom: 2px solid var(--rule-strong);
  vertical-align: bottom;
}
td {
  padding: .6rem 1rem .6rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th:last-child, td:last-child { padding-right: 0; }
/* "break this on purpose": the sabotage column is marked as such */
.breaks td:first-child {
  border-left: 3px solid var(--broke);
  padding-left: .75rem;
}
.breaks th:first-child {
  border-left: 3px solid transparent;
  padding-left: .75rem;
}

/* ---------- callout ---------- */
.note {
  background: var(--paper-2);
  border-left: 3px solid var(--brand);
  border-radius: 0 4px 4px 0;
  padding: .9rem 1.1rem;
  margin: 1.5rem 0;
}
.note > :last-child { margin-bottom: 0; }
.note strong:first-child { color: var(--ink); }

/* ---------- the paper list ---------- */
.papers-group {
  font-family: var(--mono);
  font-weight: 500;
  font-size: .9rem;
  color: var(--muted);
  margin: 2.75rem 0 0;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--rule);
}
.paper-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.paper {
  margin: 0;
  padding: 1.35rem 0;
  border-bottom: 1px solid var(--rule);
}
.paper-link { display: block; text-decoration: none; }
.paper-title {
  display: block;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  transition: color .12s;
}
.paper-link:hover .paper-title { color: var(--accent); }
.paper .paper-meta { display: block; font-size: .92rem; margin-top: .2rem; }
.paper-pitch { margin: .6rem 0 0; max-width: 36rem; }
.paper-langs {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  margin: .65rem 0 0;
  font-size: .92rem;
}
.paper.soon .paper-title { color: var(--muted); font-weight: 500; }
.paper.soon .paper-pitch { color: var(--muted); }

/* ---------- language tabs ---------- */
.langbar {
  display: flex;
  flex-wrap: wrap;
  margin: .75rem 0 2.25rem;
  border-bottom: 1px solid var(--rule);
}
.langbar button {
  font: inherit;
  font-size: .95rem;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: .5rem 1rem .6rem;
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.langbar button:first-child { padding-left: 0; }
/* the reset above outranks the [lang] rules below; restate the scripts */
.langbar button[lang="ta"] { font-family: var(--tamil); }
.langbar button[lang="hi"] { font-family: var(--deva); }
.langbar button:hover { color: var(--ink); }
.langbar button[aria-selected="true"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--brand);
}

/* ---------- scripts ---------- */
[lang="ta"] { font-family: var(--tamil); }
[lang="hi"] { font-family: var(--deva); }
[data-panel][lang="ta"] { line-height: 1.85; }
[data-panel][lang="hi"] { line-height: 1.8; }
[lang="ta"] code, [lang="hi"] code,
[lang="ta"] pre,  [lang="hi"] pre { font-family: var(--mono); }

.thanglish {
  font-style: italic;
  color: var(--muted);
  border-left: 3px solid var(--rule-strong);
  padding-left: 1rem;
  margin: .6rem 0 1.2rem;
}

/* ---------- footer ---------- */
.site-footer {
  margin-top: 4rem;
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--rule);
  font-size: .92rem;
  color: var(--muted);
}
.site-footer-owner { display: block; color: var(--text); margin-bottom: .3rem; }
.site-footer a { color: var(--text); }
.site-footer a:hover { color: var(--accent); }

/* ---------- wide screens: boxes and rails hang into the gutter ----------
   The text inside every block stays on the prose margin; only the box
   or the rail steps left. Code gains ~40px, enough for an 83-char line. */
@media (min-width: 48em) {
  :root { --bleed: 2.25rem; }   /* 38px; side space at 48em is ~51px */
  pre, .formula, .note, .hero-code {
    margin-left: calc(-1 * var(--bleed));
    margin-right: calc(-1 * var(--bleed));
    padding-left: var(--bleed);
    padding-right: var(--bleed);
  }
  .note, .hero-code { padding-left: calc(var(--bleed) - 3px); }
  /* code keeps its left edge on the margin but uses the right-hand hang
     for room: +21px is what an 83-char line needs at .8rem */
  pre { padding-right: 1rem; }
  blockquote, .thanglish {
    margin-left: calc(-1 * var(--bleed));
    padding-left: calc(var(--bleed) - 3px);
  }
}

/* ---------- small screens ---------- */
@media (max-width: 40em) {
  html { font-size: 16px; }
  .title-block { padding-top: 2rem; }
  h1 { font-size: 1.9rem; }
  h2 { font-size: 1.3rem; }
  .lede { font-size: 1.1rem; }
  .masthead .inner { padding: .85rem var(--gutter); }
  .masthead-nav { gap: 1rem; }
  pre, .hero-code { padding: .9rem 1rem; }
}

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