/* ============================================================
   gcblog — editorial theme for business & product essays
   Fraunces + Newsreader + JetBrains Mono · warm paper · lime marker
   ============================================================ */

:root {
  /* warm paper palette */
  --paper:    #faf9f5;
  --paper-2:  #f3f1e9;
  --paper-3:  #ece9dd;
  --ink:      #17170f;
  --ink-2:    #55534a;
  --ink-3:    #8b897d;

  /* alf-code lime — used as marker/highlight, plus a deep readable variant for text */
  --lime:      #aaff00;
  --lime-ink:  #2f6b3d;   /* refined forest green — links, brand, nav */
  --accent-green: #2f6b3d;
  --lime-soft: #e9f6c8;
  --lime-line: #cfe89a;

  --line:      #e4e1d4;
  --line-strong: #d3cfbe;

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body:    'Newsreader', Georgia, serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --wrap:        1160px;
  --wrap-narrow: 700px;
  --wrap-wide:   940px;

  --radius: 4px;
  --shadow: 0 18px 40px -24px rgba(23,23,15,0.35), 0 4px 12px -8px rgba(23,23,15,0.12);
}

*, *::before, *::after { 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(--font-body);
  font-size: 20px;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--lime-ink); text-decoration: none; transition: color .16s ease; }
img { max-width: 100%; height: auto; display: block; }
::selection { background: var(--lime); color: var(--ink); }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 28px; }
.wrap-narrow { max-width: var(--wrap-narrow); }
.wrap-wide { max-width: var(--wrap-wide); }

.meta-sep { color: var(--line-strong); margin: 0 .1rem; }

/* grain overlay for paper texture */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
}

/* skip link */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper); padding: .6rem 1rem; font-family: var(--font-mono); font-size: .8rem;
}
.skip-link:focus { left: 12px; top: 12px; }

.site { position: relative; z-index: 2; display: flex; flex-direction: column; min-height: 100vh; }
.site-main { flex: 1 0 auto; padding-bottom: 6rem; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; min-height: 64px; }
.site-brand {
  display: inline-flex; align-items: baseline; white-space: nowrap; color: var(--ink);
  transition: opacity .16s ease;
}
.site-brand:hover { opacity: .66; }
.brand-gc { font-family: var(--font-display); font-weight: 700; font-size: 1.62rem; letter-spacing: -.045em; }
.brand-ext {
  font-family: var(--font-mono); font-weight: 500; font-size: .8rem; letter-spacing: -.01em;
  color: var(--accent-green); margin-left: .1em; position: relative; bottom: .01em;
}

/* Ghost built-in navigation markup: ul.nav > li.nav-{slug}[.nav-current] > a */
.site-header .nav { list-style: none; margin: 0; padding: 0; display: flex; gap: 1.9rem; align-items: center; flex-wrap: nowrap; }
.site-header .nav li { margin: 0; }
.site-header .nav li a {
  font-family: var(--font-mono); font-size: .82rem; letter-spacing: .01em; color: var(--ink-2);
  text-transform: lowercase; position: relative; padding: .25rem 0; display: inline-block;
}
.site-header .nav li a:hover { color: var(--ink); }
.site-header .nav li a::after { content: ""; position: absolute; left: 0; bottom: -2px; height: 2px; width: 0; background: var(--accent-green); transition: width .2s ease; }
.site-header .nav li a:hover::after { width: 100%; }
.site-header .nav-current a { color: var(--ink); }
.site-header .nav-current a::after { width: 100%; }

/* ---------- masthead ---------- */
.masthead { padding: 6rem 0 3rem; border-bottom: 1px solid var(--line); margin-bottom: 3rem; }
.masthead-sub { padding: 4.5rem 0 2.5rem; }
.masthead-kicker {
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 1.4rem; display: inline-flex; align-items: center; gap: .7rem;
}
.masthead-kicker::before { content: ""; width: 28px; height: 2px; background: var(--ink); display: inline-block; }
.masthead-title {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(2.6rem, 6.4vw, 4.6rem); line-height: 1.02; letter-spacing: -.032em;
  margin: 0; max-width: 15ch; color: var(--ink); font-optical-sizing: auto;
}
.masthead-title-sm { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.masthead-desc { font-size: 1.25rem; color: var(--ink-2); margin: 1.2rem 0 0; max-width: 48ch; }

/* ---------- editorial index ---------- */
.index { list-style: none; margin: 0; padding: 0; counter-reset: entry; }
.index-item { border-top: 1px solid var(--line); }
.index-item:last-child { border-bottom: 1px solid var(--line); }

.entry {
  counter-increment: entry;
  display: grid; grid-template-columns: 3.2rem 1fr; gap: 1.6rem;
  padding: 2.4rem 0; color: var(--ink);
  transition: background .2s ease, padding .2s ease;
}
.entry-num::before {
  content: counter(entry, decimal-leading-zero);
  font-family: var(--font-mono); font-size: .82rem; color: var(--ink-3); font-weight: 500;
  padding-top: .5rem; display: block;
}
.entry:hover { background: linear-gradient(90deg, transparent, var(--paper-2) 30%, var(--paper-2)); }
.entry:hover .entry-num::before { color: var(--lime-ink); }

.entry-main { min-width: 0; }
.entry-meta {
  font-family: var(--font-mono); font-size: .74rem; letter-spacing: .02em; color: var(--ink-3);
  display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; margin-bottom: .7rem; text-transform: uppercase;
}
.entry-tag { color: var(--lime-ink); }
.entry-title {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(1.6rem, 3.2vw, 2.35rem); line-height: 1.08; letter-spacing: -.025em;
  margin: 0 0 .6rem; color: var(--ink);
  display: inline; background-image: linear-gradient(var(--lime), var(--lime));
  background-repeat: no-repeat; background-position: 0 92%; background-size: 0% .28em;
  transition: background-size .28s cubic-bezier(.2,.7,.3,1);
}
.entry:hover .entry-title { background-size: 100% .28em; }
.entry-excerpt { font-size: 1.08rem; color: var(--ink-2); margin: .6rem 0 0; max-width: 62ch; line-height: 1.55; }
.entry-cue { font-family: var(--font-mono); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--lime-ink); display: inline-flex; align-items: center; gap: .4rem; margin-top: 1rem; }
.entry-cue .arrow { transition: transform .18s ease; }
.entry:hover .entry-cue .arrow { transform: translateX(5px); }

.entry-thumb { display: none; }

/* lead (first) entry — larger, with image */
.index-item.is-lead .entry { grid-template-columns: 3.2rem 1fr; padding: 3rem 0 3.2rem; }
@media (min-width: 800px) {
  .index-item.is-lead.has-image .entry { grid-template-columns: 3.2rem 1.15fr .85fr; align-items: center; }
  .index-item.is-lead.has-image .entry-thumb {
    display: block; align-self: stretch; border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--line); box-shadow: var(--shadow); max-height: 320px;
  }
  .index-item.is-lead.has-image .entry-thumb img { width: 100%; height: 100%; object-fit: cover; }
  .index-item.is-lead .entry-title { font-size: clamp(2.2rem, 4vw, 3.1rem); }
  .index-item.is-lead .entry-excerpt { font-size: 1.14rem; }
}

/* staggered reveal */
@media (prefers-reduced-motion: no-preference) {
  .index-item { opacity: 0; transform: translateY(14px); animation: rise .6s cubic-bezier(.2,.7,.3,1) forwards; }
  .index-item:nth-child(1){animation-delay:.04s} .index-item:nth-child(2){animation-delay:.1s}
  .index-item:nth-child(3){animation-delay:.16s} .index-item:nth-child(4){animation-delay:.22s}
  .index-item:nth-child(5){animation-delay:.28s} .index-item:nth-child(n+6){animation-delay:.34s}
  @keyframes rise { to { opacity: 1; transform: none; } }
}

/* ---------- pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 2rem; padding: 3rem 0 1rem; font-family: var(--font-mono); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.pagination a { color: var(--lime-ink); }
.pagination .page-number { color: var(--ink-3); }

/* ---------- article ---------- */
.article { padding-top: 4rem; }
.article-header { padding-bottom: 1rem; }
.article-meta { font-family: var(--font-mono); font-size: .76rem; letter-spacing: .03em; color: var(--ink-3); display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; margin-bottom: 1.6rem; text-transform: uppercase; }
.article-tag { color: var(--lime-ink); }
.article-tag:hover { text-decoration: underline; text-underline-offset: 3px; }
.article-title {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(2.4rem, 5.6vw, 4rem); line-height: 1.03; letter-spacing: -.032em; margin: 0 0 1rem; color: var(--ink);
}
.article-standfirst { font-family: var(--font-body); font-size: 1.4rem; line-height: 1.45; color: var(--ink-2); margin: 0 0 1.5rem; font-weight: 400; }
.article-byline { font-family: var(--font-mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.byline-name::before { content: "Por "; color: var(--ink-3); }
.byline-name { color: var(--ink-2); }

.article-feature { margin: 3rem 0; }
.article-feature-image { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.article-feature figcaption { text-align: center; font-family: var(--font-mono); font-size: .74rem; color: var(--ink-3); margin-top: .9rem; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- content typography ---------- */
.gh-content { font-size: 1.22rem; line-height: 1.72; color: var(--ink); }
.gh-content > * { margin: 0 0 1.7rem; }
.gh-content > *:first-child { margin-top: 0; }

/* drop cap on opening paragraph */
.gh-content > p:first-of-type::first-letter {
  font-family: var(--font-display); font-weight: 600; font-size: 3.9em; line-height: .78;
  float: left; margin: .05em .12em 0 0; color: var(--ink);
  background: linear-gradient(var(--lime), var(--lime)); background-repeat: no-repeat; background-position: 0 88%; background-size: 100% .18em;
}

.gh-content h2, .gh-content h3, .gh-content h4 { font-family: var(--font-display); color: var(--ink); font-weight: 600; line-height: 1.16; letter-spacing: -.02em; scroll-margin-top: 92px; }
.gh-content h2 { font-size: 2rem; margin: 3.2rem 0 1.1rem; }
.gh-content h3 { font-size: 1.5rem; margin: 2.6rem 0 .9rem; }
.gh-content h4 { font-size: 1.2rem; font-weight: 700; margin: 2.2rem 0 .8rem; }

.gh-content p { color: var(--ink); }
.gh-content a {
  color: var(--ink); text-decoration: none;
  background-image: linear-gradient(var(--lime), var(--lime)); background-repeat: no-repeat;
  background-position: 0 100%; background-size: 100% .18em; transition: background-size .2s ease;
  padding-bottom: .02em;
}
.gh-content a:hover { background-size: 100% 100%; }
.gh-content strong { font-weight: 700; }
.gh-content em { font-style: italic; }

.gh-content ul, .gh-content ol { padding-left: 1.5rem; }
.gh-content li { margin-bottom: .55rem; }
.gh-content ul li::marker { color: var(--lime-ink); }
.gh-content ol li::marker { color: var(--lime-ink); font-family: var(--font-mono); font-size: .85em; }

.gh-content blockquote {
  margin: 2.4rem 0; padding: .3rem 0 .3rem 1.8rem; border-left: 4px solid var(--lime);
  font-family: var(--font-display); font-weight: 500; font-style: italic; font-size: 1.55rem; line-height: 1.35; color: var(--ink);
}

.gh-content :not(pre) > code { font-family: var(--font-mono); font-size: .82em; background: var(--paper-3); color: var(--ink); padding: .12em .4em; border-radius: 4px; border: 1px solid var(--line); }
.gh-content pre { background: #17170f; color: #f2f0e6; border-radius: var(--radius); padding: 1.2rem 1.35rem; overflow-x: auto; font-family: var(--font-mono); font-size: .86rem; line-height: 1.66; }
.gh-content pre code { color: inherit; background: none; border: 0; padding: 0; font-size: inherit; }

.gh-content img { border-radius: var(--radius); border: 1px solid var(--line); margin-left: auto; margin-right: auto; }
.gh-content figcaption { text-align: center; font-family: var(--font-mono); font-size: .74rem; color: var(--ink-3); margin-top: .7rem; text-transform: uppercase; letter-spacing: .03em; }
.gh-content hr { border: 0; text-align: center; margin: 3.2rem 0; }
.gh-content hr::before { content: "* * *"; letter-spacing: .6em; color: var(--ink-3); font-family: var(--font-mono); }

.gh-content .kg-width-wide { max-width: var(--wrap-wide); margin-left: 50%; transform: translateX(-50%); }
.gh-content .kg-width-full { max-width: 100vw; margin-left: 50%; transform: translateX(-50%); }
.gh-content table { width: 100%; border-collapse: collapse; font-family: var(--font-body); font-size: 1rem; }
.gh-content th, .gh-content td { border: 1px solid var(--line); padding: .7rem .9rem; text-align: left; }
.gh-content th { background: var(--paper-2); font-family: var(--font-mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); }

.article-tags { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; margin: 3.5rem 0 1rem; padding-top: 2rem; border-top: 1px solid var(--line); }
.tags-label { font-family: var(--font-mono); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.article-tags .article-tag { font-family: var(--font-mono); font-size: .82rem; }
.article-comments { margin-top: 3.5rem; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 3rem 0; margin-top: auto; background: var(--paper-2); }
.site-footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer-brand { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; color: var(--ink); }
.footer-meta { font-family: var(--font-mono); font-size: .74rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; }
.footer-mono a { color: var(--ink-2); }
.footer-mono a:hover { color: var(--lime-ink); }

/* ---------- back to top ---------- */
.to-top { position: fixed; right: 22px; bottom: 22px; z-index: 40; width: 46px; height: 46px; border-radius: 50%; background: var(--paper); border: 1px solid var(--line-strong); color: var(--ink); font-size: 1.1rem; cursor: pointer; display: grid; place-items: center; box-shadow: var(--shadow); transition: border-color .15s ease, transform .15s ease; }
.to-top:hover { border-color: var(--lime-ink); transform: translateY(-2px); }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  body { font-size: 18px; }
  .site-header-inner { min-height: 62px; gap: 1rem; }
  .site-nav { gap: 1rem; }
  .masthead { padding: 3.5rem 0 2rem; margin-bottom: 2rem; }
  .entry { grid-template-columns: 1fr; gap: 0; padding: 2rem 0; }
  .entry-num::before { padding-top: 0; margin-bottom: .5rem; }
  .gh-content { font-size: 1.12rem; }
  .gh-content > p:first-of-type::first-letter { font-size: 3.2em; }
}

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

/* ============================================================
   FEATURES — actions, progress, toc, share, related, hljs, dark
   ============================================================ */

/* header actions (search + theme toggle) */
.site-actions { display: flex; align-items: center; gap: 1.15rem; flex-wrap: nowrap; }
.icon-btn {
  background: none; border: 0; padding: .35rem; margin: 0; color: var(--ink-2); cursor: pointer;
  display: grid; place-items: center; border-radius: 7px; line-height: 0;
  transition: color .15s ease, background .15s ease;
}
.icon-btn:hover { color: var(--ink); background: var(--paper-2); }
.theme-toggle .ico-moon { display: none; }
html[data-theme="dark"] .theme-toggle .ico-sun { display: none; }
html[data-theme="dark"] .theme-toggle .ico-moon { display: block; }

/* reading progress */
.reading-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; background: transparent; pointer-events: none; }
.reading-progress > span { display: block; height: 100%; width: 0; background: var(--accent-green); }

/* article layout + TOC */
.article-layout { max-width: var(--wrap-narrow); margin: 0 auto; padding: 0 28px; }
.post-toc { display: none; }
@media (min-width: 1120px) {
  .article-layout { max-width: 1060px; display: grid; grid-template-columns: 220px minmax(0, 680px); gap: 56px; justify-content: center; }
  .article-content { max-width: 680px; }
  .post-toc { display: block; position: sticky; top: 96px; align-self: start; max-height: calc(100vh - 130px); overflow-y: auto; }
}
.toc-label { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 .85rem; }
.post-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.post-toc li { margin: 0; }
.post-toc a { display: block; font-family: var(--font-mono); font-size: .76rem; line-height: 1.35; color: var(--ink-3); padding: .35rem 0 .35rem .95rem; margin-left: -1px; border-left: 2px solid transparent; transition: color .15s ease, border-color .15s ease; }
.post-toc a:hover { color: var(--ink); }
.post-toc .toc-h3 a { padding-left: 1.75rem; font-size: .72rem; }
.post-toc a.is-active { color: var(--accent-green); border-left-color: var(--accent-green); }

/* share */
.share { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; margin: 3rem 0 0; padding-top: 2rem; border-top: 1px solid var(--line); }
.share-label { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin-right: .35rem; }
.share-btn { font-family: var(--font-mono); font-size: .76rem; color: var(--ink-2); background: var(--paper-2); border: 1px solid var(--line); padding: .4rem .75rem; border-radius: 7px; cursor: pointer; text-transform: lowercase; transition: color .15s ease, border-color .15s ease; }
.share-btn:hover { color: var(--ink); border-color: var(--accent-green); }

/* related */
.related { margin: 3.5rem 0 1rem; padding-top: 2.2rem; border-top: 1px solid var(--line); }
.related-title { font-family: var(--font-display); font-weight: 600; font-size: 1.45rem; margin: 0 0 1.1rem; letter-spacing: -.02em; }
.related-list { list-style: none; margin: 0; padding: 0; }
.related-item { border-top: 1px solid var(--line); }
.related-item:first-child { border-top: 0; }
.related-item a { display: flex; flex-direction: column; gap: .3rem; padding: 1.05rem 0; }
.related-meta { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); }
.related-name { font-family: var(--font-display); font-weight: 500; font-size: 1.28rem; letter-spacing: -.02em; color: var(--ink); line-height: 1.2; }
.related-item a:hover .related-name { color: var(--accent-green); }

/* syntax highlight tokens (on dark code block) */
.gh-content pre code.hljs { color: #e6e6ef; background: none; padding: 0; }
.hljs-comment, .hljs-quote { color: #6f7360; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-name, .hljs-tag { color: #aaff00; }
.hljs-string, .hljs-attr, .hljs-template-tag, .hljs-addition { color: #cfe89a; }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: #e6c15a; }
.hljs-title, .hljs-section, .hljs-selector-id { color: #bfe06a; }
.hljs-type, .hljs-class .hljs-title, .hljs-attribute { color: #8fd6b0; }
.hljs-variable, .hljs-params, .hljs-meta { color: #b9b7a6; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ---------- dark theme ---------- */
html[data-theme="dark"] {
  --paper:    #16150f;
  --paper-2:  #1f1d15;
  --paper-3:  #29271c;
  --ink:      #efeee3;
  --ink-2:    #b1afa2;
  --ink-3:    #7d7b6e;
  --lime-ink:     #a6e06a;
  --accent-green: #a6e06a;
  --lime-soft: #2b3a12;
  --lime-line: #405c19;
  --line:        rgba(255,255,255,0.10);
  --line-strong: rgba(255,255,255,0.17);
  --shadow: 0 18px 44px -22px rgba(0,0,0,0.72), 0 4px 14px -8px rgba(0,0,0,0.5);
}
html[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: .3; }
html[data-theme="dark"] ::selection { background: var(--lime); color: #16150f; }
html[data-theme="dark"] .gh-content a {
  color: var(--accent-green); background-image: none;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(166,224,106,0.4); padding-bottom: 0;
}
html[data-theme="dark"] .gh-content a:hover { text-decoration-color: var(--accent-green); background-size: 0 0; }
html[data-theme="dark"] .masthead-kicker::before { background: var(--ink); }

/* ---------- mobile header ---------- */
@media (max-width: 640px) {
  .site-header-inner { min-height: 56px; gap: .55rem; }
  .brand-gc { font-size: 1.34rem; }
  .brand-ext { font-size: .72rem; }
  .site-actions { gap: .5rem; }
  .site-header .nav { gap: .9rem; }
  .site-header .nav li a { font-size: .76rem; padding: .2rem 0; }
  .icon-btn { padding: .25rem; }
}
@media (max-width: 380px) {
  .site-header .nav { gap: .7rem; }
  .site-header .nav li a { font-size: .72rem; }
  .brand-gc { font-size: 1.24rem; }
}
