/* =================================================================
   CODEX KINGDOM — codex.css
   Tokens + base + componentes-assinatura
   ================================================================= */

:root {
  /* CORES */
  --pergaminho:        #F4E8D0;
  --pergaminho-claro:  #FAF3E2;
  --pergaminho-escuro: #E8D9B8;
  --nanquim:           #1A1410;
  --nanquim-suave:     #3D2F24;
  --cera-vermelha:     #8B1A1A;
  --cera-vermelha-dark:#6B1414;
  --ouro-velho:        #B8860B;
  --ouro-claro:        #D4A82C;
  --cobalto:           #1B3A6B;
  --cobalto-claro:     #2D5490;
  --sangue-seco:       #5C1E1E;

  /* TIPOGRAFIA */
  --font-titulo:       'Cinzel', 'Trajan Pro', serif;
  --font-corpo:        'EB Garamond', Georgia, serif;
  --font-manuscrito:   'IM Fell English', cursive;
  --font-runas:        'Noto Sans Runic', sans-serif;

  /* ESPAÇAMENTO */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  13px;
  --space-4:  21px;
  --space-5:  34px;
  --space-6:  55px;
  --space-7:  89px;

  /* SOMBRAS */
  --shadow-pergaminho: 0 2px 8px rgba(60, 40, 20, 0.12);
  --shadow-elevado:    0 8px 24px rgba(60, 40, 20, 0.18);
  --shadow-cera:       0 4px 12px rgba(139, 26, 26, 0.35);

  /* BORDAS */
  --border-pergaminho: 1px solid var(--pergaminho-escuro);
  --border-ouro:       1px solid var(--ouro-velho);
  --radius-sm: 2px;
  --radius-md: 4px;
}

/* RESET REFINADO ----------------------------------------------- */

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

html {
  font-size: 18px; /* Garamond pede um pouco mais */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-corpo);
  color: var(--nanquim);
  background-color: var(--pergaminho);
  background-image:
    /* mancha sutil de envelhecimento nos cantos */
    radial-gradient(circle at 0% 0%, rgba(139, 90, 43, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(139, 90, 43, 0.06) 0%, transparent 40%),
    /* textura granulada */
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.4 0 0 0 0 0.3 0 0 0 0 0.2 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  line-height: 1.65;
  min-height: 100vh;
}

/* TIPOGRAFIA --------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-titulo);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--nanquim);
  line-height: 1.2;
}

h1 {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h2 {
  font-size: 1.8rem;
  letter-spacing: 0.05em;
}

h3 { font-size: 1.4rem; }

p {
  font-size: 1.05rem;
  margin-bottom: var(--space-4);
}

a {
  color: var(--cobalto);
  text-decoration: none;
  border-bottom: 1px solid rgba(27, 58, 107, 0.3);
  transition: border-color 0.2s ease, color 0.2s ease;
}

a:hover {
  color: var(--cobalto-claro);
  border-bottom-color: var(--cobalto);
}

::selection {
  background-color: var(--cera-vermelha);
  color: var(--pergaminho);
}

/* CAPITULAR ILUMINADA ----------------------------------------- */

.capitular::first-letter {
  font-family: var(--font-titulo);
  font-weight: 900;
  font-size: 4.5em;
  float: left;
  line-height: 0.85;
  margin: 0.05em 0.12em 0 0;
  color: var(--ouro-velho);
  text-shadow: 1px 1px 0 var(--pergaminho-escuro);
  font-feature-settings: "smcp" off;
}

/* SELO DE CERA ------------------------------------------------ */

.selo-cera {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle at 30% 30%,
    var(--cera-vermelha) 0%,
    var(--cera-vermelha-dark) 60%,
    #4A0E0E 100%);
  border-radius: 50%;
  box-shadow:
    var(--shadow-cera),
    inset -4px -6px 8px rgba(0, 0, 0, 0.3),
    inset 3px 3px 6px rgba(255, 200, 200, 0.15);
  font-family: var(--font-titulo);
  font-weight: 700;
  color: var(--pergaminho);
  font-size: 1.6rem;
  letter-spacing: 0.05em;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
  /* bordas irregulares como cera derretida */
  clip-path: polygon(
    50% 0%, 60% 5%, 70% 2%, 82% 10%, 92% 18%, 95% 30%,
    100% 42%, 98% 55%, 100% 68%, 92% 80%, 82% 88%, 70% 95%,
    58% 98%, 45% 100%, 32% 95%, 20% 88%, 10% 78%, 4% 65%,
    2% 52%, 5% 38%, 12% 25%, 22% 12%, 35% 5%, 48% 2%
  );
}

.selo-cera--pequeno { width: 48px; height: 48px; font-size: 1rem; }
.selo-cera--grande { width: 120px; height: 120px; font-size: 2.4rem; }

.selo-cera--ouro {
  background: radial-gradient(circle at 30% 30%,
    var(--ouro-claro) 0%,
    var(--ouro-velho) 60%,
    #6B5009 100%);
  color: var(--nanquim);
}

/* animação de carimbar */
@keyframes carimbar {
  0%   { transform: scale(2.2) rotate(-15deg); opacity: 0; }
  60%  { transform: scale(0.9) rotate(2deg);   opacity: 0.95; }
  80%  { transform: scale(1.05) rotate(-1deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

.selo-cera--carimbar {
  animation: carimbar 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* RUNAS COMO ÍCONES ------------------------------------------- */

.runa {
  font-family: var(--font-runas);
  font-size: 2rem;
  color: var(--nanquim);
  display: inline-block;
  line-height: 1;
}

.runa--ouro { color: var(--ouro-velho); }
.runa--cera { color: var(--cera-vermelha); }
.runa--cobalto { color: var(--cobalto); }

/* CARDS DE CAPÍTULO ------------------------------------------- */

.capitulo-card {
  background: var(--pergaminho-claro);
  border: var(--border-pergaminho);
  padding: var(--space-5);
  position: relative;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: var(--shadow-pergaminho);
}

.capitulo-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-elevado);
}

.capitulo-card--bloqueado {
  opacity: 0.6;
  filter: sepia(0.3);
  cursor: not-allowed;
}

.capitulo-card--bloqueado::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent 0,
    transparent 10px,
    rgba(60, 40, 20, 0.03) 10px,
    rgba(60, 40, 20, 0.03) 20px
  );
  pointer-events: none;
}

.capitulo-card__numero {
  font-family: var(--font-titulo);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--ouro-velho);
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.capitulo-card__titulo {
  font-family: var(--font-titulo);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-3);
}

.capitulo-card__descricao {
  font-family: var(--font-manuscrito);
  font-size: 1.1rem;
  color: var(--nanquim-suave);
  font-style: italic;
}

/* RISCO DE PENA (DIVISOR) ------------------------------------- */

.risco-pena {
  width: 100%;
  height: 12px;
  margin: var(--space-5) 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 12'%3E%3Cpath d='M0 6 Q40 2 80 6 T160 7 T240 5 T320 6 T400 6' stroke='%231A1410' stroke-width='1' fill='none' stroke-dasharray='1,2,3,1'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  opacity: 0.5;
}

.risco-pena--ouro {
  filter: sepia(1) saturate(2) hue-rotate(10deg);
}

/* BOTÃO ESTILO CERA ------------------------------------------- */

.btn-cera {
  font-family: var(--font-titulo);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: var(--space-3) var(--space-5);
  background: linear-gradient(180deg, var(--cera-vermelha) 0%, var(--cera-vermelha-dark) 100%);
  color: var(--pergaminho);
  border: 1px solid var(--cera-vermelha-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow:
    var(--shadow-cera),
    inset 0 1px 0 rgba(255, 200, 200, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-cera:hover {
  transform: translateY(-1px);
  box-shadow:
    0 6px 16px rgba(139, 26, 26, 0.45),
    inset 0 1px 0 rgba(255, 200, 200, 0.3);
}

.btn-cera:active {
  transform: translateY(0);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
}

.btn-cera--ouro {
  background: linear-gradient(180deg, var(--ouro-claro) 0%, var(--ouro-velho) 100%);
  color: var(--nanquim);
  border-color: var(--ouro-velho);
}

/* INPUT MANUSCRITO -------------------------------------------- */

.input-manuscrito {
  font-family: var(--font-corpo);
  font-size: 1.1rem;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--nanquim);
  color: var(--nanquim);
  width: 100%;
  outline: none;
  transition: border-color 0.2s ease;
}

.input-manuscrito:focus {
  border-bottom-color: var(--cobalto);
}

.input-manuscrito::placeholder {
  font-family: var(--font-manuscrito);
  font-style: italic;
  color: var(--nanquim-suave);
  opacity: 0.6;
}

/* CITAÇÃO FILOSÓFICA ------------------------------------------ */

.citacao {
  font-family: var(--font-manuscrito);
  font-size: 1.3rem;
  font-style: italic;
  text-align: center;
  color: var(--nanquim-suave);
  padding: var(--space-5) var(--space-6);
  position: relative;
  max-width: 700px;
  margin: 0 auto;
}

.citacao::before,
.citacao::after {
  font-family: var(--font-titulo);
  font-size: 4rem;
  color: var(--ouro-velho);
  position: absolute;
  opacity: 0.5;
  line-height: 1;
}

.citacao::before { content: '"'; top: 0; left: 0; }
.citacao::after  { content: '"'; bottom: -20px; right: 0; }

.citacao__autor {
  display: block;
  margin-top: var(--space-3);
  font-family: var(--font-titulo);
  font-size: 0.85rem;
  font-style: normal;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ouro-velho);
}

/* TÍTULO DO MEMBRO -------------------------------------------- */

.titulo-membro {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: rgba(184, 134, 11, 0.1);
  border: 1px solid var(--ouro-velho);
  font-family: var(--font-titulo);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ouro-velho);
}

/* SKELETON LOADER (PERGAMINHO) -------------------------------- */

@keyframes pergaminho-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--pergaminho-escuro) 0%,
    var(--pergaminho-claro) 50%,
    var(--pergaminho-escuro) 100%
  );
  background-size: 200% 100%;
  animation: pergaminho-shimmer 1.8s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* CONTAINER PRINCIPAL ----------------------------------------- */

.codex-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
}

/* HEADER ------------------------------------------------------ */

.codex-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) 0;
  border-bottom: var(--border-pergaminho);
  margin-bottom: var(--space-6);
}

.codex-header__brasao {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.codex-header__brasao img {
  width: 48px;
  height: 48px;
}

.codex-header__nome {
  font-family: var(--font-titulo);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--nanquim);
}

/* RESPONSIVO -------------------------------------------------- */

@media (max-width: 768px) {
  html { font-size: 16px; }
  h1   { font-size: 2rem; }
  .selo-cera--grande { width: 80px; height: 80px; font-size: 1.6rem; }
  .codex-header { flex-direction: column; gap: var(--space-3); }
}
