@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Mono:wght@400;500&display=swap');

/* RESET */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* =========================
   VARIÁVEIS
   ========================= */
:root {
  --black: #1a1a1a;
  --white: #ffffff;
  --off-white: #f7f7f5;
  --gray-light: #e8e8e4;
  --gray-mid: #9b9b97;
  --gray-dark: #4a4a47;

  --text: #1a1a1a;
  --border-subtle: rgba(0, 0, 0, 0.1);
  --input-bg: #ffffff;

  --font-display: 'DM Serif Display', Georgia, serif;
  --font-mono: 'DM Mono', 'Courier New', monospace;

  --sidebar-width: 240px;

  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 3rem;
}

/* DARK MODE */
html[data-theme="dark"] {
  --black: #f2f2f0;
  --white: #1a1a1a;
  --off-white: #232320;
  --gray-light: #34342f;
  --gray-mid: #8a8a86;
  --gray-dark: #c9c9c4;

  --text: #e4e2dd;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --input-bg: #232128;
}

/* =========================
   BASE
   ========================= */
html {
  background: var(--white);
  color: var(--black);
  font-family: var(--font-mono);
  font-size: 19px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--white);
  overflow-x: hidden;
}

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

a {
  color: var(--black);
}

p {
  font-size: 0.875rem;
  line-height: 1.8;
  color: var(--gray-dark);
}

/* =========================
   LAYOUT PRINCIPAL
   ========================= */
.layout {
  display: flex;
  min-height: 100vh;
}

/* =========================
   SIDEBAR
   ========================= */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding: var(--space-lg) 1.75rem;
  border-right: 0.5px solid var(--border-subtle);
  background: var(--white);
  display: flex;
  flex-direction: column;
  position: relative;
}

.sidebar-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.8rem;
  color: var(--black);
  margin-bottom: 0.4rem;
  text-decoration: none;
  display: block;
}

.sidebar-tagline {
  font-size: 0.68rem;
  color: var(--gray-mid);
  margin-bottom: var(--space-lg);
  line-height: 1.55;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: var(--space-md);
}

.sidebar-nav a {
  font-size: 0.78rem;
  color: var(--gray-dark);
  text-decoration: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0.2rem 0;
  transition: color 0.15s ease;
}

.sidebar-nav a:hover {
  color: var(--black);
}

.sidebar-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-mid);
  margin-bottom: 0.6rem;
}

.sidebar-categories {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: var(--space-md);
}

.sidebar-categories a {
  font-size: 0.75rem;
  color: var(--gray-dark);
  text-decoration: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0.15rem 0;
  transition: color 0.15s ease;
}

.sidebar-categories a:hover {
  color: var(--black);
}

.sidebar-theme-toggle {
  margin-top: auto;
  padding-top: 2rem;
}

/* =========================
   OVERLAY (FIXED)
   ========================= */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 15;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  will-change: opacity;
}

.sidebar-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

/* =========================
   CONTENT
   ========================= */
.content {
  flex: 1;
  min-width: 0;
  padding: var(--space-xl) 4rem;
}

/* =========================
   MOBILE HEADER
   ========================= */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 1.25rem;
  border-bottom: 0.5px solid var(--border-subtle);
  background: var(--white);
  position: sticky;
  top: 0;
  z-index: 30;
}

.mobile-header-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.4rem;
  color: var(--black);
  text-decoration: none;
}

/* =========================
   HAMBURGER
   ========================= */
.hamburger {
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gray-dark);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.hamburger svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
}

/* =========================
   THEME TOGGLE
   ========================= */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-mid);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--black);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

.icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: block; }

/* =========================
   LISTA DE POSTS
   ========================= */
.post-list {
  display: flex;
  flex-direction: column;
}

.post-item {
  display: grid;
  grid-template-columns: 88px 1fr;
  column-gap: 2rem;
  padding: 1.85rem 0;
  border-bottom: 0.5px solid var(--border-subtle);
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s ease;
}

.post-item:first-child {
  border-top: 0.5px solid var(--border-subtle);
}

.post-item:hover .post-title {
  opacity: 0.65;
}

.post-date {
  font-size: 0.75rem;
  color: var(--gray-mid);
  line-height: 1.4;
  padding-top: 0.25rem;
  white-space: nowrap;
}

.post-body {}

.post-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--black);
  margin-bottom: 0.35rem;
  line-height: 1.35;
  transition: opacity 0.15s ease;
}

.post-excerpt {
  font-size: 0.75rem;
  color: var(--gray-mid);
  line-height: 1.75;
  margin-bottom: 0.6rem;
}

.post-tags {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.post-tag {
  font-size: 0.64rem;
  color: var(--gray-mid);
  text-decoration: none;
}

.post-tag::before {
  content: "#";
}

.post-tag:hover {
  color: var(--gray-dark);
}

/* =========================
   PÁGINA DE POST INDIVIDUAL
   ========================= */
.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 0.5px solid var(--border-subtle);
}

.post-header-meta {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.post-header-date {
  font-size: 0.68rem;
  color: var(--gray-mid);
}

.post-header-category {
  font-size: 0.68rem;
  color: var(--gray-mid);
  text-decoration: none;
}

.post-header-category::before {
  content: "#";
}

.post-header-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 400;
  color: var(--black);
  line-height: 1.25;
}

/* Conteúdo do post */
.post-content {
  font-size: 0.9rem;
  line-height: 1.9;
  color: var(--gray-dark);
}

.post-content p { margin-bottom: 1.4rem; }
.post-content h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--black);
  margin: 2.5rem 0 0.75rem;
}
.post-content h3 {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--black);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 2rem 0 0.6rem;
}
.post-content a {
  color: var(--black);
  text-decoration-thickness: 0.5px;
  text-underline-offset: 3px;
}
.post-content blockquote {
  border-left: 0.5px solid var(--gray-mid);
  padding-left: 1.25rem;
  color: var(--gray-mid);
  margin: 1.75rem 0;
}
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--off-white);
  padding: 0.15em 0.4em;
  border-radius: 2px;
}
html[data-theme="dark"] .post-content code {
  background: var(--gray-light);
}
.post-content pre {
  background: var(--off-white);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.8rem;
  line-height: 1.7;
  border-radius: 2px;
}
html[data-theme="dark"] .post-content pre {
  background: var(--gray-light);
}
.post-content pre code {
  background: none;
  padding: 0;
}

/* =========================
   CABEÇALHO DE PÁGINA (índice, categoria)
   ========================= */
.page-heading {
  margin-bottom: 2.5rem;
}

.page-heading-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-mid);
  margin-bottom: 0.4rem;
}

.page-heading-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--black);
}

/* =========================
   FOOTER
   ========================= */
.site-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 0.5px solid var(--border-subtle);
}

.site-footer p {
  font-size: 0.68rem;
  color: var(--gray-mid);
}

/* =========================
   SEÇÃO DE COMENTÁRIOS
   ========================= */
.comments-section {
  margin-top: 5rem;
  padding-top: 3rem;
  border-top: 0.5px solid var(--border-subtle);
}

.comments-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.4rem;
  color: var(--black);
  margin-bottom: 2.5rem;
  font-weight: 400;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 3.5rem;
}

.comment {
  padding: 1.5rem 0;
  border-bottom: 0.5px solid var(--border-subtle);
}

.comment:first-child {
  border-top: 0.5px solid var(--border-subtle);
}

.comment-meta {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.comment-author {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--black);
  font-family: var(--font-mono);
}

.comment-date {
  font-size: 0.68rem;
  color: var(--gray-mid);
  font-family: var(--font-mono);
}

.comment-date::before {
  content: "—";
  margin-right: 0.4rem;
}

.comment-body {
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--gray-dark);
}

/* Formulário de comentário */
.comment-form-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray-mid);
  margin-bottom: 1.5rem;
  font-family: var(--font-mono);
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 500px;
}

.comment-form input[type="text"],
.comment-form textarea,
#id_author,
#id_body {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--black);
  background: transparent;
  border: none;
  border-bottom: 0.5px solid var(--gray-light);
  border-radius: 0;
  padding: 0.6rem 0;
  outline: none;
  transition: border-color 0.15s ease;
  resize: none;
  -webkit-appearance: none;
  appearance: none;
}

.comment-form input[type="text"]::placeholder,
.comment-form textarea::placeholder,
#id_author::placeholder,
#id_body::placeholder {
  color: var(--gray-mid);
}

.comment-form input[type="text"]:focus,
.comment-form textarea:focus,
#id_author:focus,
#id_body:focus {
  border-bottom-color: var(--black);
}

.comment-form textarea,
#id_body {
  min-height: 100px;
  line-height: 1.7;
  display: block;
}

html[data-theme="dark"] .comment-form input[type="text"],
html[data-theme="dark"] .comment-form textarea,
html[data-theme="dark"] #id_author,
html[data-theme="dark"] #id_body {
  color: var(--black);
  border-bottom-color: var(--gray-light);
}

html[data-theme="dark"] .comment-form input[type="text"]:focus,
html[data-theme="dark"] .comment-form textarea:focus,
html[data-theme="dark"] #id_author:focus,
html[data-theme="dark"] #id_body:focus {
  border-bottom-color: var(--black);
}

.comment-form-submit {
  align-self: flex-start;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--black);
  background: transparent;
  border: 0.5px solid var(--gray-dark);
  border-radius: 0;
  padding: 0.55rem 1.4rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.comment-form-submit:hover {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

/* =========================
   RESPONSIVIDADE
   ========================= */

/* ── TABLET GRANDE / LAPTOP PEQUENO (861px–1100px) ── */
@media (min-width: 861px) and (max-width: 1100px) {
  :root {
    --sidebar-width: 200px;
  }

  .sidebar {
    padding: 2rem 1.25rem;
  }

  .sidebar-title {
    font-size: 1.5rem;
  }

  .content {
    padding: 2rem 2.5rem;
  }
}

/* ── DESKTOP: sidebar fixa ── */
@media (min-width: 861px) {
  .sidebar {
    position: relative;
    transform: none !important;
  }

  .sidebar-overlay {
    display: none !important;
  }
}

/* ── TABLET / MOBILE (≤860px) — drawer lateral ── */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: min(260px, 80vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 20;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-right: 0.5px solid var(--border-subtle);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .content {
    margin-left: 0;
    padding: var(--space-md) 1.75rem;
  }

  .mobile-header {
    display: flex;
  }

  .layout {
    flex-direction: column;
  }

  /* Posts: colapsa para coluna única, date acima do título */
  .post-item {
    grid-template-columns: 1fr;
    row-gap: 0.4rem;
    padding: 1.25rem 0;
  }

  .post-date {
    padding-top: 0;
  }

  .comment-form {
    max-width: 100%;
  }
}

/* ── CELULAR PEQUENO (≤480px) ── */
@media (max-width: 480px) {
  html {
    font-size: 18px;
  }

  .content {
    padding: var(--space-sm) 1rem;
  }

  .sidebar-title {
    font-size: 1.6rem;
  }

  .mobile-header {
    padding: 0.75rem 1rem;
  }

  p {
    font-size: 0.9rem;
  }

  .post-title {
    font-size: 1rem;
  }

  .post-header-title {
    font-size: 1.5rem;
  }

  .comment-form-submit {
    width: 100%;
    text-align: center;
  }

  .comments-section {
    margin-top: 3.5rem;
    padding-top: 2rem;
  }

  .comments-title {
    font-size: 1.2rem;
    margin-bottom: 2rem;
  }
}

/* ── CELULAR MUITO PEQUENO (≤320px) ── */
@media (max-width: 320px) {
  html {
    font-size: 15px;
  }

  .content {
    padding: var(--space-sm) 0.75rem;
  }
}

/* ── LANDSCAPE MOBILE (altura pequena) ── */
@media (max-height: 500px) and (max-width: 860px) {
  .sidebar {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  .sidebar-tagline {
    margin-bottom: 1rem;
  }

  .sidebar-nav {
    gap: 0.3rem;
  }
}

/* ── IMPRESSÃO ── */
@media print {
  .sidebar,
  .mobile-header,
  .hamburger,
  .theme-toggle,
  .sidebar-overlay {
    display: none !important;
  }

  .content {
    margin: 0;
    padding: 0;
    max-width: 100%;
  }

  .layout {
    display: block;
  }
}

/* =========================
   ACESSIBILIDADE
   ========================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 1px solid var(--gray-mid);
  outline-offset: 2px;
}