/* Kindle-inspired minimalist blog
   Restraint is the identity: one narrow column, warm paper, serif reading type.
   The single flourish is the e-reader reading affordances (progress line, min-read). */

:root {
  --paper:   #faf7f0;
  --ink:     #2b2724;
  --muted:   #6b645c;
  --accent:  #2f4a3f;
  --hair:    #e7dfd2;
  --sel:     #e9e0cf;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans:  ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --measure: 40rem;
  --pad: clamp(1.25rem, 5vw, 2rem);

  color-scheme: light; /* always the warm paper look — no dark mode */
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.18rem;
  line-height: 1.72;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

::selection { background: var(--sel); }

/* ---- reading progress line (article pages only) ---- */
#progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0;
  background: var(--accent);
  z-index: 50;
  transition: width 0.1s linear;
}

/* ---- shell ---- */
.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--pad);
}

/* ---- top bar ---- */
.masthead {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2.4rem var(--pad) 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.masthead a.brand {
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.masthead nav {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  display: flex;
  gap: 1.1rem;
  align-items: center;
}
.masthead nav a { color: var(--muted); text-decoration: none; }
.masthead nav a:hover { color: var(--accent); }

.brand { user-select: none; }

/* ---- homepage intro ---- */
.intro { padding: 3.2rem 0 1rem; }
.eyebrow {
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.6rem;
}
.intro h1 {
  font-weight: 400;
  font-size: clamp(2.1rem, 7vw, 2.9rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}
.intro .lede {
  color: var(--muted);
  margin: 1rem 0 0;
  font-size: 1.1rem;
}

/* ---- quote card (the 12-years-old exchange) ---- */
.quote-card {
  border-left: 4px solid var(--accent);
  padding: 0.4rem 0 0.4rem 1.4rem;
  margin: 2.8rem 0 1rem;
  font-family: var(--sans);
}
.quote-card .lead {
  font-weight: 800;
  font-size: clamp(1.35rem, 4.5vw, 1.7rem);
  line-height: 1.28;
  letter-spacing: -0.01em;
  margin: 0;
}
.quote-card .line {
  font-weight: 800;
  font-size: clamp(1.35rem, 4.5vw, 1.7rem);
  line-height: 1.28;
  letter-spacing: -0.01em;
  margin: 0.15rem 0 0 1.1rem;
}
.quote-card .attrib {
  font-style: italic;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 1rem 0 0;
  text-align: right;
}

/* ---- name easter egg: "Zeshan" reads like a dictionary entry ---- */
/* Subtle dashed underline hints there's a definition; hover/tap reveals the card. */
.dfn {
  position: relative;
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: #cbb999;
  text-decoration-thickness: 2px;
  text-underline-offset: 8px;
  transition: text-decoration-color 0.2s ease;
}
.dfn:hover,
.dfn:focus-visible,
.dfn.is-open { text-decoration-color: var(--accent); outline: none; }

.dfn-pop {
  position: absolute;
  top: calc(100% + 1.1rem);
  left: 0;
  z-index: 40;
  width: max-content;
  max-width: min(30rem, 86vw);
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 1.4rem 1.6rem 1.2rem;
  box-shadow: 0 20px 55px rgba(43, 39, 36, 0.28);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s;
  pointer-events: none;
}
.dfn.is-open .dfn-pop {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}
/* desktop bonus: reveal on hover (hover-capable pointers only) */
@media (hover: hover) {
  .dfn:hover .dfn-pop {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
  }
}
.dfn-lemma {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.9rem;
}
.dfn-lemma em { font-style: italic; text-transform: none; letter-spacing: 0.02em; }
/* the popover lives inside an <h1>, so its parts are spans forced to block */
.dfn-lemma,
.dfn-pop .quote-card,
.dfn-pop .lead,
.dfn-pop .line,
.dfn-pop .attrib { display: block; }
.dfn-pop .quote-card { margin: 0; }
.dfn-pop .lead,
.dfn-pop .line { font-size: 1.12rem; line-height: 1.35; }
.dfn-pop .line { margin-left: 0.8rem; }

/* Dimmed backdrop behind the mobile "definition" card (created in reader.js).
   It's a real element so it can absorb the dismiss tap — otherwise a tap to
   close could fall through onto an article link. Hidden on desktop. */
.egg-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(43, 39, 36, 0.34);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s;
}

/* On narrow screens the word sits mid-line, so anchoring the popover to it
   overflows the viewport. Center it as a fixed card over the backdrop. */
@media (max-width: 33rem) {
  .dfn-pop {
    position: fixed;
    left: 1rem;
    right: 1rem;
    top: 50%;
    width: auto;
    max-width: none;
    transform: translateY(-46%);
  }
  .dfn.is-open .dfn-pop { transform: translateY(-50%); }
  .egg-backdrop.show { opacity: 1; visibility: visible; pointer-events: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .dfn-pop { transition: opacity 0.28s ease, visibility 0.28s; transform: none; }
}

/* ---- library (article list) ---- */
.library { padding: 2.4rem 0 4rem; }
.library-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--hair);
  padding-bottom: 0.8rem;
  margin-bottom: 0.4rem;
}
.library-label {
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.filter {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.filter:hover { color: var(--ink); border-color: var(--muted); }
.filter[aria-pressed="true"] {
  color: var(--paper);
  background: var(--accent);
  border-color: var(--accent);
}
.post {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--hair);
}
.post:hover .post-title { color: var(--accent); }
.post-title {
  font-size: 1.4rem;
  line-height: 1.25;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: color 0.2s ease;
}
.post-excerpt {
  color: var(--muted);
  margin: 0.4rem 0 0.7rem;
  font-size: 1.02rem;
}
.meta {
  font-family: var(--sans);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.meta .dot { opacity: 0.5; margin: 0 0.15rem; }

/* inline reaction icons (LinkedIn popularity) — monoline, inherit text color */
.stat { display: inline-flex; align-items: center; gap: 0.3rem; }
.ic {
  width: 0.92em;
  height: 0.92em;
  vertical-align: -0.14em;
  display: inline-block;
  opacity: 0.85;
}
.stat.like .ic { color: var(--accent); opacity: 1; }

/* ---- article page ---- */
article { padding: 3rem 0 2rem; }
.article-head { margin-bottom: 2.4rem; }
.article-head h1 {
  font-weight: 400;
  font-size: clamp(2rem, 6vw, 2.7rem);
  line-height: 1.16;
  letter-spacing: -0.015em;
  margin: 0.4rem 0 0.9rem;
}
.article-head .meta { font-size: 0.8rem; }

article p { margin: 1.3rem 0; }
article h2 {
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  margin: 2.6rem 0 0.4rem;
}
article h3 { font-weight: 600; font-size: 1.25rem; margin: 2rem 0 0.4rem; }
article a { color: var(--accent); text-underline-offset: 2px; }
article ul, article ol { padding-left: 1.4rem; }
article li { margin: 0.4rem 0; }
article blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.6rem 0;
  padding: 0.2rem 0 0.2rem 1.2rem;
  color: var(--muted);
  font-style: italic;
}
article code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: var(--sel);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
article pre {
  background: var(--sel);
  padding: 1rem 1.1rem;
  border-radius: 6px;
  overflow-x: auto;
}
article pre code { background: none; padding: 0; }
article hr { border: none; border-top: 1px solid var(--hair); margin: 2.4rem 0; }

/* LinkedIn popularity strip inside an article */
.linkedin {
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  display: inline-flex;
  gap: 0.9rem;
  align-items: center;
  text-decoration: none;
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  margin-top: 0.4rem;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.linkedin:hover { border-color: var(--accent); color: var(--accent); }

.article-foot {
  margin: 3rem 0 4rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--hair);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.article-foot a {
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-decoration: none;
}
.article-foot a:hover { color: var(--accent); }

/* ---- global footer ---- */
.site-foot {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem var(--pad) 3rem;
  border-top: 1px solid var(--hair);
  font-family: var(--sans);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--accent); }

/* ---- focus + motion ---- */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  #progress { transition: none; }
  html { scroll-behavior: auto; }
}
