/* ============================================================
   MERCÚRIO CASA 9 — Identidade, cabeçalho, sumário lateral
   ============================================================ */

/* — Marca — */
.masthead {
  position: relative;
  z-index: 2;
  padding: clamp(2.5rem, 6vw, 4.5rem) var(--gutter) clamp(1.75rem, 4vw, 2.5rem);
  text-align: center;
}

.masthead__glyph {
  width: 30px;
  height: 30px;
  margin: 0 auto 1.1rem;
  opacity: 0.82;
}

.masthead__glyph svg { width: 100%; height: 100%; display: block; }

.masthead__title {
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1;
}

.masthead__title .casa9 {
  display: block;
  font-size: 0.32em;
  letter-spacing: 0.5em;
  margin-top: 0.85rem;
  font-weight: 600;
  font-family: var(--face-body);
}

.masthead__tagline {
  margin-top: 1.1rem;
  font-family: var(--face-display);
  font-style: italic;
  font-size: 1.02rem;
  color: var(--ink-faint);
  letter-spacing: 0.01em;
}

.masthead__rule {
  margin: 1.75rem auto 0;
  width: 64px;
  height: 1px;
  background: var(--rule-strong);
  position: relative;
}
.masthead__rule::before {
  content: "✦";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--paper);
  padding: 0 0.6em;
  font-size: 0.55rem;
  color: var(--ink-faint);
}

/* — Navegação utilitária (topo direito) — */
.utility-nav {
  position: absolute;
  top: clamp(1.5rem, 4vw, 2.25rem);
  right: var(--gutter);
  display: flex;
  gap: 1.6rem;
  align-items: center;
  z-index: 3;
}

.utility-nav a {
  font-family: var(--face-body);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-faint);
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.utility-nav a:hover,
.utility-nav a:focus-visible {
  color: var(--ink);
  border-color: var(--ink);
}

/* ============================================================
   SUMÁRIO LATERAL — desliza da margem esquerda
   A "orelha" de um livro: sempre ali, raramente vista.
   ============================================================ */

.toc-trigger {
  position: fixed;
  left: 0;
  top: 0;
  width: 22px;
  height: 100vh;
  z-index: 40;
}

@media (hover: none), (pointer: coarse) {
  .toc-trigger { display: none; }
}

.toc {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: min(340px, 86vw);
  background: var(--paper);
  border-right: 1px solid var(--rule-strong);
  box-shadow: 0 0 0 rgba(0,0,0,0);
  transform: translateX(calc(-100% + 4px));
  transition: transform 0.55s var(--ease), box-shadow 0.55s var(--ease);
  z-index: 41;
  display: flex;
  flex-direction: column;
  padding: 0;
}

@media (hover: hover) and (pointer: fine) {
  .toc-trigger:hover ~ .toc,
  .toc:hover,
  .toc:focus-within {
    transform: translateX(0);
    box-shadow: 6px 0 24px rgba(24,22,15,0.10);
  }
}

/* Em ecrãs táteis, o sumário abre por toque na aba (classe aplicada via JS) */
.toc.is-open {
  transform: translateX(0);
  box-shadow: 6px 0 24px rgba(24,22,15,0.10);
}

.toc::after {
  /* fio de borda como lombada de livro, sempre visível na aba */
  content: "";
  position: absolute;
  right: -1px;
  top: 0;
  bottom: 0;
  width: 1px;
}

.toc__tab {
  position: absolute;
  right: -27px;
  top: 50%;
  transform: translateY(-50%);
  width: 27px;
  height: 92px;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-left: none;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.toc__tab span {
  font-family: var(--face-body);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--ink-faint);
}

.toc__head {
  padding: 2.25rem 1.75rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

.toc__head h2 {
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

.toc__head p {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-style: italic;
  font-family: var(--face-display);
}

.toc__list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0 2rem;
  overflow-y: auto;
  flex: 1;
}

.toc__item a {
  display: block;
  padding: 0.85rem 1.75rem;
  border-bottom: 1px solid var(--rule);
  transition: background 0.2s var(--ease), padding-left 0.2s var(--ease);
}

.toc__item a:hover,
.toc__item a:focus-visible {
  background: var(--wash);
  padding-left: 2.05rem;
}

.toc__item-num {
  display: block;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  margin-bottom: 0.2rem;
  font-family: var(--face-body);
}

.toc__item-title {
  display: block;
  font-family: var(--face-display);
  font-size: 1.08rem;
  line-height: 1.25;
  color: var(--ink);
}

.toc__item-date {
  display: block;
  font-size: 0.7rem;
  color: var(--ink-faint);
  margin-top: 0.3rem;
  letter-spacing: 0.03em;
}

.toc__empty {
  padding: 1.75rem;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--ink-faint);
}

/* Overlay sutil quando sumário aberto, clique fora fecha (mobile) */
.toc-scrim {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: transparent;
  pointer-events: none;
}

@media (hover: none), (pointer: coarse) {
  .toc-scrim.is-open {
    pointer-events: auto;
    background: rgba(24,22,15,0.18);
  }
  /* Em touch, a aba precisa de alvo de toque confortável */
  .toc__tab { cursor: pointer; }
}
