/* ===========================================================================
   Abhishek Salla — personal site
   One stylesheet, no build step, no external requests.

   The look is borrowed from the documents this subject actually produces:
   a component datasheet and a schematic. Hence the title block, the numbered
   sections, the hairline rules with a pad at the left end (a trace leaving a
   via), and the faint reticle grid behind the masthead.

   The accent is the amber of a photolithography bay. Fabs light those rooms
   yellow because photoresist is blind to long wavelengths — it is the one
   colour you are allowed to have near an unexposed wafer. That is a more
   honest reason to pick a colour than "it looked nice".

   Every colour pair below was measured against WCAG 2.1, not eyeballed.
   Ratios are recorded in the comments; see README.md for the full table.
   =========================================================================== */

/* --- Palette ------------------------------------------------------------ */

:root {
  color-scheme: light dark;

  /* Light: warm paper, ink, deep amber. */
  --bg:       #FAF7F0;  /* warm paper                                        */
  --surface:  #F2EDE2;  /* blocks and tables                                 */
  --ink:      #1B1A16;  /* body text          16.28:1 on bg, 14.92:1 on surf */
  --muted:    #5A564B;  /* metadata            6.84:1 on bg,  6.27:1 on surf */
  --link:     #8C5A00;  /* links, focus ring   5.49:1 on bg,  5.03:1 on surf */
  --accent:   #B07508;  /* pads, marks, rails  3.64:1 on bg,  3.33:1 on surf */
  --rule:     #8A8375;  /* meaningful borders  3.51:1 on bg,  3.22:1 on surf */
  --hair:     #D8D0BF;  /* decorative rules and the reticle grid only        */
  --select:   #F5E3B8;

  /* Type. System stacks only — nothing here waits on a font server. */
  --font-text: "Iowan Old Style", "Charter", "Bitstream Charter",
               "Palatino Linotype", Palatino, "Book Antiqua",
               "Noto Serif", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "SF Mono",
               Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;

  --measure: 60ch;      /* prose line length                                 */
  --rail: 6.5rem;       /* width of the section-number rail                  */
  --gutter: clamp(1.25rem, 4vw, 3rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark: unlit silicon, warm off-white, brighter amber. Not pure black —
       #000 against a bright serif is harsh and makes the stems bloom. */
    --bg:      #121310;
    --surface: #1B1C18;
    --ink:     #EAE6DB;  /* 14.95:1 on bg, 13.74:1 on surface */
    --muted:   #A6A192;  /*  7.22:1 on bg,  6.64:1 on surface */
    --link:    #F2B53C;  /* 10.17:1 on bg,  9.34:1 on surface */
    --accent:  #F2B53C;  /* 10.17:1 on bg,  9.34:1 on surface */
    --rule:    #7C8077;  /*  4.63:1 on bg,  4.25:1 on surface */
    --hair:    #2E302A;
    --select:  #43370F;
  }
}

/* --- Reset -------------------------------------------------------------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1.0625rem;          /* 17px — serif needs a shade more than 16 */
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;

  /* The supply rail across the top of the page. Decorative. */
  border-top: 3px solid var(--accent);
}

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

::selection { background: var(--select); color: var(--ink); }

/* --- Skip link ---------------------------------------------------------- */

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.6rem 1rem;
  background: var(--bg);
  color: var(--link);
  border: 2px solid var(--link);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  z-index: 10;
}
.skip:focus { left: var(--gutter); top: 0.5rem; }

/* --- Shell -------------------------------------------------------------- */

.wrap {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* --- Masthead ----------------------------------------------------------- */

.masthead {
  padding: 1.5rem 0 0;
  border-bottom: 1px solid var(--hair);
}

.masthead .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 1rem;
}

.wordmark {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark:hover { color: var(--link); }

/* Nav is monospaced and lower-case-free: it reads as a set of labels rather
   than a sentence, which keeps it from competing with the serif headings. */
.nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.nav a {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid transparent;
  transition: color 120ms ease, border-color 120ms ease;
}
.nav a:hover { color: var(--ink); border-bottom-color: var(--rule); }
.nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* --- Hero --------------------------------------------------------------- */

.hero {
  position: relative;
  padding: clamp(2.5rem, 7vw, 4.5rem) 0 clamp(2rem, 5vw, 3rem);
  overflow: hidden;
}

/* A faint reticle field — the grid of identical dies stepped across a wafer.
   Hairline weight only; it must never fight the text sitting on top of it. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(to right,  var(--hair) 0 1px, transparent 1px 96px),
    repeating-linear-gradient(to bottom, var(--hair) 0 1px, transparent 1px 96px);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent 78%);
          mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent 78%);
  pointer-events: none;
}
.hero > * { position: relative; }

h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(2.2rem, 1.4rem + 3.2vw, 3.5rem);
  line-height: 1.03;
  letter-spacing: -0.021em;
  font-weight: 600;
}

.standfirst {
  max-width: var(--measure);
  margin: 0;
  font-size: clamp(1.05rem, 1rem + 0.35vw, 1.2rem);
  color: var(--ink);
}

.kicker {
  margin: 0 0 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --- Title block -------------------------------------------------------- */
/* Every schematic sheet carries one in the corner: who, what, which revision.
   This is the same idea — the facts that do not change often, boxed off. */

.titleblock {
  margin: 2.25rem 0 0;
  max-width: 40rem;
  border: 1px solid var(--rule);
  background: var(--surface);
}
.titleblock > div {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.15rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--hair);
}
.titleblock > div:last-child { border-bottom: 0; }
.titleblock dt {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}
.titleblock dd { margin: 0; }

@media (min-width: 34rem) {
  .titleblock > div {
    grid-template-columns: 9.5rem 1fr;
    gap: 1rem;
    align-items: baseline;
  }
  .titleblock dt { padding-top: 0.15rem; }
}

/* --- Sections ----------------------------------------------------------- */

.sec {
  position: relative;
  padding: clamp(2.25rem, 5vw, 3.25rem) 0;
  border-top: 1px solid var(--hair);
}

/* A trace leaving a via: the pad sits on the rule at the left margin. */
.sec::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 0;
  width: 26px;
  height: 5px;
  background: var(--accent);
}

.sec-index {
  margin: 0 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.sec-body > :first-child { margin-top: 0; }
.sec-body > * { max-width: var(--measure); }
.sec-body > .wide { max-width: none; }
.sec-body > .titleblock { max-width: 40rem; }

h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.4rem, 1.2rem + 0.85vw, 1.8rem);
  line-height: 1.15;
  letter-spacing: -0.012em;
  font-weight: 600;
}

h3 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  line-height: 1.3;
  font-weight: 600;
}

p { margin: 0 0 1.05rem; }
p:last-child { margin-bottom: 0; }

/* On a wide screen the section number moves out into its own rail, so the
   prose keeps a single hard left edge all the way down the page. Nothing is
   centred — a centred column of short paragraphs reads as a template. */
@media (min-width: 60rem) {
  .sec {
    display: grid;
    grid-template-columns: var(--rail) minmax(0, 1fr);
    gap: 0 2rem;
  }
  .sec-index { margin: 0; padding-top: 0.42rem; }
  .hero { padding-left: calc(var(--rail) + 2rem); }
}

/* --- Prose bits --------------------------------------------------------- */

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}
a:hover { text-decoration-thickness: 2px; }

.lede { font-size: 1.1rem; }

ul.plain, ol.plain { padding-left: 1.15rem; margin: 0 0 1.05rem; }
ul.plain li, ol.plain li { margin-bottom: 0.5rem; }
ul.plain li::marker { color: var(--accent); }

.note {
  margin: 1.5rem 0 0;
  padding-left: 1rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
  font-size: 0.95rem;
}

.mono { font-family: var(--font-mono); font-size: 0.9em; }

.backlink {
  margin-top: 2.25rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

/* --- Table -------------------------------------------------------------- */

.scroller {
  max-width: none;
  overflow-x: auto;
  margin: 0 0 1.25rem;
  border: 1px solid var(--rule);
}
.scroller:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  background: var(--surface);
}
caption {
  text-align: left;
  padding: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--hair);
  vertical-align: top;
}
thead th {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
td.code { font-family: var(--font-mono); font-size: 0.85rem; white-space: nowrap; }
td.num  { font-family: var(--font-mono); font-size: 0.85rem; text-align: right; }

/* --- Entries (projects, posts) ------------------------------------------ */

.entries { margin: 0; padding: 0; list-style: none; max-width: var(--measure); }

.entry {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--hair);
}
.entry:first-child { padding-top: 0; }
.entry:last-child { border-bottom: 0; }

.entry-meta {
  margin: 0 0 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.entry h3 a { color: var(--ink); text-decoration-color: var(--rule); }
.entry h3 a:hover { color: var(--link); text-decoration-color: currentColor; }
.entry p { margin: 0; color: var(--ink); }

/* --- Empty state -------------------------------------------------------- */
/* Deliberately not styled as an error or a shrug. It is a labelled blank on
   a form that has not been filled in yet, which is exactly what it is. */

.empty {
  max-width: var(--measure);
  margin: 0;
  padding: 1.4rem 1.5rem;
  background: var(--surface);
  border: 1px dashed var(--rule);
}
.empty-label {
  margin: 0 0 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.empty p:last-child { margin-bottom: 0; }

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

.foot {
  margin-top: 1rem;
  padding: 1.75rem 0 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.7;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.foot p { margin: 0 0 0.3rem; max-width: none; }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--link); }

/* --- Focus -------------------------------------------------------------- */
/* One ring, everywhere, in the link colour — measured at 5.49:1 on light and
   10.17:1 on dark, so it clears the 3:1 required of a UI indicator twice over.
   Never remove the outline without putting something equally visible back. */

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

/* --- Motion ------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Print -------------------------------------------------------------- */

@media print {
  body { background: #fff; color: #000; border-top: 0; font-size: 11pt; }
  .nav, .skip, .hero::before { display: none; }
  .sec { break-inside: avoid; border-top: 1px solid #999; }
  .sec::before { display: none; }
  a { color: #000; }
  /* Print the destination, since a printed link is otherwise a dead end. */
  .sec-body a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; }
}
