/* ============================================================
   Vagner Bastos — Escritos · Design System
   Editorial moderno: serifa para leitura, sem serifa para UI,
   papel quente + tinta + terracota. Tema claro/escuro.
   ============================================================ */

:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f4f0ea;
  --ink: #1b1815;
  --muted: #6f675f;
  --line: #e8e2da;
  --line-strong: #d8d0c5;
  --accent: #b4452c;
  --accent-strong: #96341f;
  --accent-ink: #fffaf7;
  --accent-soft: #f6e3dc;
  --chip-bg: #f1ece5;
  --success: #1d7a4f;
  --danger: #b3261e;
  --shadow-sm: 0 1px 2px rgba(27, 24, 21, .06), 0 2px 8px rgba(27, 24, 21, .05);
  --shadow-md: 0 4px 16px rgba(27, 24, 21, .08), 0 12px 40px rgba(27, 24, 21, .08);
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --container: 1120px;
  --measure: 42rem;
  --radius: 14px;
  --radius-sm: 9px;
  --header-h: 64px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

[data-theme="dark"] {
  --bg: #161412;
  --surface: #1e1b18;
  --surface-2: #26221d;
  --ink: #f2ede6;
  --muted: #a79d91;
  --line: #322c26;
  --line-strong: #453d35;
  --accent: #e08a6a;
  --accent-strong: #f0a485;
  --accent-ink: #241510;
  --accent-soft: #3a241c;
  --chip-bg: #26221d;
  --success: #4cbf87;
  --danger: #f08a82;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .4), 0 12px 40px rgba(0, 0, 0, .35);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  transition: background .3s var(--ease), color .3s var(--ease);
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
h1, h2, h3, h4 { font-family: var(--font-serif); line-height: 1.15; font-weight: 600; text-wrap: balance; margin: 0; }
p { margin: 0 0 1.1em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

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

.container { width: min(var(--container), 100% - 2.5rem); margin-inline: auto; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: -100px; left: 16px; z-index: 200;
  background: var(--accent); color: var(--accent-ink);
  padding: .6rem 1rem; border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { top: 12px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 1rem; height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: var(--accent); display: grid; place-items: center;
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { font-family: var(--font-serif); font-weight: 700; font-size: 1.05rem; line-height: 1.1; display: flex; flex-direction: column; }
.brand-text small { font-family: var(--font-sans); font-weight: 500; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

.site-nav { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.site-nav a {
  padding: .45rem .85rem; border-radius: 999px; color: var(--muted);
  font-weight: 500; font-size: .95rem;
}
.site-nav a:hover { color: var(--ink); background: var(--chip-bg); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.header-actions { display: flex; align-items: center; gap: .35rem; margin-left: .5rem; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
  display: grid; place-items: center; transition: border-color .2s, background .2s;
}
.icon-btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.icon-btn svg { width: 19px; height: 19px; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }
.nav-toggle { display: none; }

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .72rem 1.35rem; border-radius: 999px; font-weight: 600; font-size: .95rem;
  border: 1px solid transparent; cursor: pointer; transition: transform .15s var(--ease), box-shadow .2s, background .2s, border-color .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink); background: var(--surface); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .8rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  letter-spacing: .02em; background: var(--chip-bg); color: var(--muted);
  border: 1px solid transparent; transition: background .2s, color .2s;
}
a.chip:hover { background: var(--accent-soft); color: var(--accent); }
.chip-small { padding: .2rem .6rem; font-size: .72rem; }
.chip[data-cat] { background: var(--accent-soft); color: var(--accent); }
.chip.is-active { background: var(--accent); color: var(--accent-ink); }

/* ---------- Hero (home) ---------- */
.hero { padding: clamp(3rem, 7vw, 5.5rem) 0 2.5rem; }
.hero-inner { display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(2rem, 5vw, 4rem); align-items: center; }
.hero-kicker {
  font-size: .8rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 1.2rem; display: flex; align-items: center; gap: .6rem;
}
.hero-kicker::before { content: ""; width: 2.2rem; height: 2px; background: var(--accent); }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); margin-bottom: 1.2rem; }
.hero h1 em { font-style: italic; color: var(--muted); }
.hero-lede { font-size: clamp(1.05rem, 2vw, 1.2rem); color: var(--muted); max-width: 34rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.8rem; }

.hero-card {
  position: relative; border-radius: 20px; padding: clamp(1.4rem, 3vw, 2rem);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-md);
  overflow: hidden;
}
.hero-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 5px;
  background: linear-gradient(90deg, var(--accent), #e0a060);
}
.hero-card .card-title { font-size: clamp(1.3rem, 2.4vw, 1.7rem); margin: .8rem 0 .6rem; }
.hero-card .card-title a { color: var(--ink); }
.hero-card .card-title a:hover { color: var(--accent); }

/* ---------- Sections ---------- */
.section { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.section-head h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
.section-head .more { font-size: .9rem; font-weight: 600; }

/* ---------- Cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; display: flex; flex-direction: column; gap: .7rem;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.card .chip { align-self: flex-start; }
.card-title { font-size: 1.22rem; }
.card-title a { color: var(--ink); }
.card-title a:hover { color: var(--accent); }
.card-excerpt { color: var(--muted); font-size: .95rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { margin-top: auto; font-size: .8rem; color: var(--muted); display: flex; gap: .5rem; align-items: center; }

/* ---------- Category band ---------- */
.cat-band { display: flex; flex-wrap: wrap; gap: .6rem; }
.cat-band a {
  padding: .6rem 1.1rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-weight: 600; font-size: .9rem;
  display: inline-flex; align-items: center; gap: .45rem;
}
.cat-band a:hover { border-color: var(--accent); color: var(--accent); }
.cat-band .count { font-size: .75rem; opacity: .7; }

/* ---------- Newsletter ---------- */
.newsletter { border-block: 1px solid var(--line); background: var(--surface-2); }
.newsletter-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: center; padding: clamp(2.5rem, 6vw, 4rem) 0; }
.newsletter h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin-bottom: .5rem; }
.newsletter p { color: var(--muted); margin: 0; }
.newsletter-form { display: flex; gap: .6rem; flex-wrap: wrap; }
.newsletter-form input {
  flex: 1 1 220px; min-width: 0; padding: .72rem 1.1rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: .95rem; font-family: var(--font-sans);
}
.newsletter-form input:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
.newsletter-form input::placeholder { color: var(--muted); }
.form-msg { flex-basis: 100%; font-size: .88rem; font-weight: 600; margin: 0; min-height: 1.2em; }
.form-msg.ok { color: var(--success); }
.form-msg.err { color: var(--danger); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 4rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 2rem; padding: 3rem 0 2rem; }
.footer-brand p { color: var(--muted); font-size: .92rem; max-width: 22rem; }
.footer-col h3 { font-family: var(--font-sans); font-size: .78rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: .9rem; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.footer-col a { color: var(--ink); font-size: .93rem; }
.footer-col a:hover { color: var(--accent); }
.footer-bottom {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .6rem;
  border-top: 1px solid var(--line); padding: 1.2rem 0; font-size: .84rem; color: var(--muted);
}
.footer-bottom a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

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

.post-hero { padding: clamp(2.5rem, 6vw, 4.5rem) 0 2rem; }
.post-hero-inner { max-width: var(--measure); }
.post-hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); margin: 1rem 0 1rem; }
.post-excerpt { font-size: clamp(1.05rem, 2vw, 1.2rem); color: var(--muted); font-family: var(--font-serif); font-style: italic; }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: 1.6rem; font-size: .88rem; color: var(--muted); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem; letter-spacing: .02em;
}

.post-layout { display: grid; grid-template-columns: minmax(0, var(--measure)) 13rem; gap: clamp(2rem, 5vw, 3.5rem); padding: 1rem 0 3rem; align-items: start; }

/* ---------- Prose ---------- */
.prose { font-family: var(--font-serif); font-size: clamp(1.06rem, 1.7vw, 1.17rem); line-height: 1.78; }
.prose p { margin-bottom: 1.45em; }
.prose h2 { font-size: 1.55em; margin: 1.9em 0 .7em; font-family: var(--font-serif); }
.prose h3 { font-size: 1.25em; margin: 1.6em 0 .6em; }
.prose a { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.prose strong { font-weight: 700; }
.prose blockquote {
  margin: 1.8em 0; padding: .2em 0 .2em 1.4em; border-left: 3px solid var(--accent);
  font-style: italic; font-size: 1.08em; color: var(--muted);
}
.prose blockquote p { margin-bottom: .5em; }
.prose ul, .prose ol { margin: 0 0 1.45em; padding-left: 1.4em; }
.prose li { margin-bottom: .45em; }
.prose li::marker { color: var(--accent); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.prose .lead { font-size: 1.14em; color: var(--muted); }

/* ---------- Post aside ---------- */
.post-aside { position: sticky; top: calc(var(--header-h) + 1.5rem); display: grid; gap: 1.6rem; font-size: .86rem; }
.post-aside h3 { font-family: var(--font-sans); font-size: .75rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: .7rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag-list a { font-size: .78rem; padding: .25rem .7rem; border-radius: 999px; background: var(--chip-bg); color: var(--muted); }
.tag-list a:hover { background: var(--accent-soft); color: var(--accent); }
.share-list { display: grid; gap: .4rem; }
.share-list button, .share-list a {
  display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: .84rem; cursor: pointer; transition: border-color .2s, background .2s;
}
.share-list button:hover, .share-list a:hover { border-color: var(--accent); color: var(--accent); }
.share-list svg { width: 15px; height: 15px; }

/* ---------- Author box ---------- */
.author-box {
  margin-top: 2.5rem; padding: 1.6rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  display: grid; grid-template-columns: auto 1fr; gap: 1.1rem; align-items: center;
}
.author-box .avatar { width: 54px; height: 54px; font-size: 1rem; }
.author-box h3 { font-size: 1.15rem; margin-bottom: .25rem; }
.author-box p { margin: 0; color: var(--muted); font-size: .92rem; }
.author-box .btn { margin-top: .8rem; }

/* ---------- Archive ---------- */
.archive-toolbar { display: grid; gap: 1.2rem; margin: 2rem 0 2.4rem; }
.search-box { position: relative; max-width: 34rem; }
.search-box svg { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search-box input {
  width: 100%; padding: .85rem 1.1rem .85rem 2.8rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: 1rem; font-family: var(--font-sans);
}
.search-box input:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
.filter-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.result-count { font-size: .88rem; color: var(--muted); margin-bottom: 1.2rem; }
.empty-state { text-align: center; padding: 3.5rem 1rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }
.empty-state .big { font-size: 2.4rem; margin-bottom: .6rem; }

/* ---------- Books ---------- */
.book-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; }
.book-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 1.8rem; display: flex; flex-direction: column; gap: .9rem; position: relative; overflow: hidden;
}
.book-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--book-color, var(--accent)); }
.book-number { font-family: var(--font-serif); font-size: 3.2rem; font-weight: 700; line-height: 1; color: var(--line-strong); }
[data-theme="dark"] .book-number { color: #3a332c; }
.book-card h3 { font-size: 1.35rem; }
.book-card .book-sub { font-family: var(--font-serif); font-style: italic; color: var(--muted); margin: 0; }
.book-card p { color: var(--muted); font-size: .95rem; margin: 0; }
.badge {
  align-self: flex-start; font-size: .74rem; font-weight: 700; letter-spacing: .05em;
  padding: .3rem .8rem; border-radius: 999px; text-transform: uppercase;
}
.badge-writing { background: var(--accent-soft); color: var(--accent); }
.badge-soon { background: var(--chip-bg); color: var(--muted); }
.badge-draft { background: #e8ecf4; color: #3b4f7a; }
[data-theme="dark"] .badge-draft { background: #232c40; color: #9db4e0; }
.book-card .btn { margin-top: auto; align-self: flex-start; }

/* ---------- About ---------- */
.about-hero { display: grid; grid-template-columns: auto 1fr; gap: 2rem; align-items: center; }
.about-avatar {
  width: clamp(120px, 22vw, 170px); aspect-ratio: 1; border-radius: 50%;
  background: linear-gradient(145deg, var(--accent-soft), var(--chip-bg));
  display: grid; place-items: center; font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; color: var(--accent);
  border: 1px solid var(--line);
}
.about-body { max-width: 46rem; }
.about-body h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); margin-bottom: .8rem; }
.about-body .lead { font-size: 1.15rem; color: var(--muted); font-family: var(--font-serif); font-style: italic; }
.about-list { list-style: none; padding: 0; margin: 1.6rem 0; display: grid; gap: .9rem; }
.about-list li { display: flex; gap: .8rem; align-items: flex-start; }
.about-list .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: .55em; flex: none; }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: clamp(4rem, 12vw, 8rem) 1rem; }
.notfound .code { font-family: var(--font-serif); font-size: clamp(5rem, 18vw, 9rem); font-weight: 700; line-height: 1; color: var(--line-strong); }
.notfound h1 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); margin: 1rem 0 .6rem; }
.notfound p { color: var(--muted); max-width: 30rem; margin: 0 auto 1.8rem; }
.notfound .actions { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .card-grid, .book-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-inner { grid-template-columns: 1fr; }
  .hero-card { max-width: 34rem; }
  .newsletter-inner { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .post-layout { grid-template-columns: minmax(0, 1fr); }
  .post-aside { position: static; grid-template-columns: repeat(3, 1fr); align-items: start; }
}

@media (max-width: 720px) {
  .card-grid, .book-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 1.6rem; }
  .about-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .about-list li { text-align: left; }
  .nav-toggle { display: grid; }
  .site-nav {
    position: fixed; inset: var(--header-h) 0 auto 0; background: var(--surface);
    flex-direction: column; align-items: stretch; padding: 1rem 1.25rem 1.4rem;
    border-bottom: 1px solid var(--line); gap: .35rem;
    transform: translateY(-8px); opacity: 0; visibility: hidden;
    transition: transform .25s var(--ease), opacity .25s, visibility .25s;
  }
  .site-nav.is-open { transform: none; opacity: 1; visibility: visible; }
  .site-nav a { padding: .8rem 1rem; border-radius: 10px; font-size: 1.02rem; }
  .post-aside { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .reveal { opacity: 1; transform: none; }
}
