/* ============ Cores e tipografia ============ */
:root {
  --bg: #12110f;
  --bg-soft: #1a1815;
  --text: #ebe4d4;
  --text-soft: #b9b1a1;
  --muted: #7f7869;
  --line: #2c2924;
  --accent: #c8a86b;
  --select: rgba(200, 168, 107, 0.14);

  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --margin-col: 168px;
  --gap: 48px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4efe4;
  --bg-soft: #ece6d8;
  --text: #24201a;
  --text-soft: #4d463b;
  --muted: #8a8174;
  --line: #dcd3c1;
  --accent: #946a26;
  --select: rgba(148, 106, 38, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
::selection { background: var(--select); }

:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }

/* ============ Estrutura: a "margem" ============ */
.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding-left: max(32px, env(safe-area-inset-left, 0px));
  padding-right: max(32px, env(safe-area-inset-right, 0px));
}

.row {
  display: grid;
  grid-template-columns: var(--margin-col) 1fr;
  gap: var(--gap);
}

/* A linha vertical da margem atravessa o site inteiro */
.margin-rule {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
  left: calc(max(32px, (100vw - 980px) / 2 + 32px) + var(--margin-col) + var(--gap) / 2);
  pointer-events: none;
  z-index: 0;
}

.side {
  text-align: right;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding-top: 0.55em;
}

.side .tema {
  display: block;
  margin-top: 4px;
  font-style: italic;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0;
  color: var(--text-soft);
}

/* ============ Cabeçalho ============ */
header.top {
  position: relative;
  z-index: 1;
  padding: 40px 0 24px;
}

.brand {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.01em;
  text-align: right;
  display: block;
}

.brand .dot { color: var(--accent); font-style: normal; }

nav.menu {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: var(--muted);
}

nav.menu a { transition: color 0.2s; }
nav.menu a:hover, nav.menu a[aria-current="page"] { color: var(--text); }

.theme-toggle {
  margin-left: auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border-radius: 50%;
  transition: color 0.2s;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { width: 17px; height: 17px; }
.icon-sun { display: none; }
:root[data-theme="light"] .icon-sun { display: block; }
:root[data-theme="light"] .icon-moon { display: none; }

/* ============ Conteúdo ============ */
main {
  position: relative;
  z-index: 1;
  min-height: 70vh;
  padding: 72px 0 96px;
}

.view { animation: surgir 0.7s ease both; }

@keyframes surgir {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 18px;
}

/* Poema */
.poem-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(38px, 6vw, 54px);
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin: 0 0 40px;
}

.poem-photo {
  margin: 0 0 56px;
  max-width: min(520px, 100%);
}
.poem-photo img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 2px;
  filter: saturate(0.85);
  transition: filter 0.6s ease;
}
.poem-photo img:hover { filter: none; }

.poem {
  font-family: var(--serif);
  font-size: clamp(21px, 2.6vw, 24px);
  line-height: 1.65;
  color: var(--text);
}

.stanza { margin: 0 0 1.4em; }
.stanza:last-child { margin-bottom: 0; }

.verse {
  display: block;
  width: fit-content;
  border-radius: 3px;
  margin-left: -6px;
  padding: 0 6px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.verse:hover { background: var(--select); }
.verse.is-picked { background: var(--select); color: var(--accent); }

.poem-sign {
  margin-top: 48px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  font-size: 17px;
}

.hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* Navegação entre poemas */
.pager {
  margin-top: 88px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  font-size: 13px;
  color: var(--muted);
}
.pager a { display: grid; gap: 2px; max-width: 48%; transition: color 0.2s; }
.pager a:hover { color: var(--text); }
.pager .dir { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }
.pager .t { font-family: var(--serif); font-size: 20px; color: var(--text); }
.pager .next { text-align: right; margin-left: auto; }

/* Lista de poemas */
.section-title {
  font-family: var(--serif);
  font-weight: 400;
  font-style: italic;
  font-size: 22px;
  color: var(--text-soft);
  margin: 0 0 8px;
}

.list { list-style: none; margin: 0; padding: 0; }

.list li a {
  display: grid;
  grid-template-columns: var(--margin-col) 1fr;
  gap: var(--gap);
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.list li:first-child a { border-top: 1px solid var(--line); }

.list .side { padding-top: 0.5em; }

.list .t {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.2;
  transition: color 0.2s;
}
.list .first {
  display: block;
  margin-top: 4px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  color: var(--muted);
}
.list li a:hover .t { color: var(--accent); }

.more {
  display: inline-block;
  margin-top: 28px;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
  transition: color 0.2s, border-color 0.2s;
}
.more:hover { color: var(--text); border-color: var(--accent); }

.spacer { height: 112px; }

/* Filtros por tema */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 40px; }
.chip {
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  transition: all 0.2s;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip[aria-pressed="true"] { color: var(--bg); background: var(--text); border-color: var(--text); }

/* Sobre */
.prose {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.65;
  color: var(--text-soft);
  max-width: 34em;
}
.prose p { margin: 0 0 1em; }

/* ============ Rodapé ============ */
footer.bottom {
  position: relative;
  z-index: 1;
  padding: 32px 0 48px;
  font-size: 12px;
  color: var(--muted);
}

/* ============ Barra de compartilhar verso ============ */
.share-bar {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 140%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  z-index: 20;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(.2,.8,.2,1), opacity 0.35s;
  max-width: calc(100vw - 32px);
}
.share-bar.is-open { transform: translate(-50%, 0); opacity: 1; }
.share-bar button {
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--text);
  white-space: nowrap;
  transition: background-color 0.2s;
}
.share-bar button:hover { background: var(--select); }
.share-bar .count { font-size: 12px; color: var(--muted); padding: 0 10px 0 12px; white-space: nowrap; }

.toast {
  position: fixed;
  left: 50%;
  top: calc(24px + env(safe-area-inset-top, 0px));
  transform: translate(-50%, -20px);
  font-size: 13px;
  padding: 10px 18px;
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 30;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ============ Celular ============ */
@media (max-width: 720px) {
  .wrap {
    padding-left: max(20px, env(safe-area-inset-left, 0px));
    padding-right: max(20px, env(safe-area-inset-right, 0px));
  }
  .margin-rule { display: none; }

  .row { grid-template-columns: 1fr; gap: 0; }

  header.top .row { grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
  .brand { text-align: left; font-size: 26px; }
  nav.menu { gap: 18px; }

  main { padding: 40px 0 72px; }

  .side {
    text-align: left;
    padding: 0 0 14px;
    display: flex;
    align-items: baseline;
    gap: 10px;
  }
  .side .tema { margin: 0; }
  .side .tema::before { content: "·"; margin-right: 10px; color: var(--muted); font-style: normal; }

  .poem-title { margin-bottom: 28px; }

  .list li a { grid-template-columns: 1fr; gap: 0; padding: 20px 0; }
  .list .side { padding: 0 0 6px; }

  .spacer { height: 72px; }
  .pager .t { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
