:root {
  --green-deep: #10271f;
  --green: #173c31;
  --gold: #c6a45a;
  --gold-soft: #ecd48b;
  --ink: #231a12;

  /* Papel mais claro e amarelado, menos marrom */
  --paper: #f1dfb7;
  --paper-light: #f8edcf;
  --paper-edge: #c89f5b;
  --paper-shadow: #9f7339;

  --shadow: rgba(0, 0, 0, .42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(198,164,90,.18), transparent 32%),
    radial-gradient(circle at 80% 80%, rgba(65, 98, 71, .22), transparent 34%),
    linear-gradient(135deg, #07100d 0%, #0b1612 50%, #020403 100%);
  font-family: 'IM Fell English', Georgia, serif;
}

.stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.hidden {
  display: none !important;
}

/* LOGIN / CAPA MENOR */

.login-screen {
  width: min(480px, 100%);
}

.cover-card,
.book-cover {
  position: relative;
  overflow: hidden;
  color: var(--gold-soft);
  background:
    linear-gradient(90deg, rgba(255,255,255,.04), transparent 12%, transparent 88%, rgba(0,0,0,.22)),
    radial-gradient(circle at center, rgba(198,164,90,.12), transparent 42%),
    linear-gradient(145deg, #173f33, #07140f 72%);
  border: 2px solid rgba(198,164,90,.72);
  box-shadow:
    0 28px 70px var(--shadow),
    inset 0 0 0 8px rgba(198,164,90,.12);
}

.cover-card::before,
.book-cover::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(236,212,139,.58);
  border-radius: 22px;
  pointer-events: none;
}

.cover-card::after,
.book-cover::after {
  content: "✥   ❦   ✥";
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  letter-spacing: .5rem;
  opacity: .72;
}

.small-cover {
  min-height: 640px;
  padding: 46px 44px;
  border-radius: 28px;
  text-align: center;
}

.cover-logo {
  width: 112px;
  height: 112px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid rgba(236,212,139,.55);
  filter: sepia(.35) saturate(.75) contrast(1.08);
  mix-blend-mode: screen;
  opacity: .86;
}

.sigil {
  font-size: 34px;
  margin: 18px 0 6px;
}

h1,
h2,
button,
.recipe-index {
  font-family: 'Cinzel', serif;
}

h1 {
  margin: 0;
  font-size: clamp(2.3rem, 8vw, 4rem);
  line-height: .94;
  letter-spacing: .08em;
  /* text-transform: uppercase; */
}

.subtitle {
  font-size: 1.1rem;
  color: #f1e6bd;
}

.password-form {
  position: relative;
  z-index: 1;
  margin-top: 36px;
  display: grid;
  gap: 12px;
}

.password-form label {
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: .8rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(35,26,18,.28);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 249, 224, .72);
  font: 1rem 'IM Fell English', Georgia, serif;
  outline: none;
}

input:focus,
textarea:focus {
  box-shadow: 0 0 0 3px rgba(198,164,90,.32);
}

button {
  cursor: pointer;
  border: 1px solid rgba(198,164,90,.78);
  border-radius: 999px;
  padding: 12px 22px;
  color: #271d0f;
  background: linear-gradient(180deg, #f4d987, #b88835);
  font-weight: 700;
  letter-spacing: .06em;
  transition: transform .2s ease, filter .2s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.message {
  min-height: 1.2rem;
  color: #ffd6d6;
}

/* APP */

.app-shell {
  width: min(1280px, 100%);
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 14px;
}

.secondary-button,
.ghost-button {
  color: var(--gold-soft);
  background: rgba(16,39,31,.86);
}

/* LIVRO */

.book {
  position: relative;
  min-height: 690px;
  display: grid;
  place-items: center;
  perspective: 2600px;
}

/* 
  Estado inicial:
  a capa fica sozinha no centro, como um livro fechado.
*/
.book-cover {
  position: absolute;
  z-index: 10;

  top: 50%;
  left: 50%;

  width: 500px;
  max-width: 90vw;
  height: 640px;
  min-width: unset;
  min-height: unset;

  border-radius: 18px 28px 28px 18px;
  padding: 44px;
  text-align: center;

  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;

  transform: translate(-50%, -50%) rotateY(0deg);
  transform-origin: left center;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform, opacity;

  transition:
    transform 1.15s cubic-bezier(.22,.75,.14,1),
    opacity .24s linear .9s,
    box-shadow .8s ease;

  color: var(--gold-soft);
  background:
    linear-gradient(90deg, rgba(255,255,255,.04), transparent 12%, transparent 88%, rgba(0,0,0,.22)),
    radial-gradient(circle at center, rgba(198,164,90,.10), transparent 42%),
    linear-gradient(145deg, #173f33, #07140f 72%);
  border: 2px solid rgba(198,164,90,.72);
  box-shadow:
    0 28px 70px var(--shadow),
    inset 0 0 0 8px rgba(198,164,90,.12);
}

.book-cover::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(236,212,139,.58);
  border-radius: 20px;
  pointer-events: none;
}

.book-cover::after {
  content: "✥   ❦   ✥";
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  letter-spacing: .5rem;
  opacity: .72;
}

/* 
  Ao abrir:
  a capa se desloca para a metade esquerda do livro aberto
  e gira para fora, como capa de livro.
*/
.book.open .book-cover {
  transform: translate(-100%, -50%) rotateY(-165deg);
  opacity: 0;
  pointer-events: none;
  box-shadow: -34px 18px 54px rgba(0,0,0,.36);
}

.book-cover h2 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4.4rem);
  line-height: .92;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.book-cover h2 span {
  font-size: .62em;
}

.cover-ornament {
  font-size: 38px;
  color: var(--gold);
}

.cover-button {
  position: relative;
  z-index: 3;
}

/* 
  O miolo do livro começa invisível.
  Ele aparece quando a capa abre.
*/
.pages {
  position: relative;

  width: min(1060px, 100%);
  min-height: 640px;

  display: grid;
  grid-template-columns: 1fr 1fr;

  opacity: 0;
  transform: scale(.96);
  pointer-events: none;

  transition:
    opacity .35s ease .36s,
    transform .45s ease .36s;

  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0,0,0,.38);
}

.book.open .pages {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* dobra central */
.pages::before {
  content: "";
  position: absolute;
  z-index: 5;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 28px;
  transform: translateX(-50%);
  pointer-events: none;

  background:
    linear-gradient(
      90deg,
      rgba(72, 48, 22, .18) 0%,
      rgba(72, 48, 22, .06) 34%,
      rgba(255, 250, 232, .38) 50%,
      rgba(72, 48, 22, .06) 66%,
      rgba(72, 48, 22, .18) 100%
    );
}

/* bordas discretas de folhas */
.pages::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border-radius: 22px;

  box-shadow:
    inset 14px 0 0 rgba(118, 82, 39, .10),
    inset -14px 0 0 rgba(118, 82, 39, .10),
    inset 28px 0 0 rgba(255, 247, 224, .16),
    inset -28px 0 0 rgba(255, 247, 224, .16);
}

/* páginas claras, sem dourado, sem marrom pesado */
.page {
  position: relative;
  padding: 42px clamp(28px, 4vw, 56px);
  overflow: hidden;

  color: #21170d;

  background:
    linear-gradient(
      90deg,
      rgba(120, 85, 42, .08) 0%,
      rgba(255, 250, 233, .24) 8%,
      transparent 20%,
      transparent 80%,
      rgba(120, 85, 42, .07) 100%
    ),
    linear-gradient(
      180deg,
      #fbf4dd 0%,
      #f3e7c9 52%,
      #ead8ad 100%
    );

  border: 1px solid rgba(112, 76, 34, .14);
  box-shadow: inset 0 0 18px rgba(112, 76, 34, .04);
}

.index-page {
  border-radius: 22px 0 0 22px;
  border-right: none;
}

.recipe-page {
  border-radius: 0 22px 22px 0;
  border-left: none;
  transform-style: preserve-3d;
}

/* textura bem suave */
.paper-texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .10;

  background:
    radial-gradient(circle at 18% 22%, rgba(76, 48, 19, .13) 0 1px, transparent 1.6px),
    radial-gradient(circle at 70% 58%, rgba(76, 48, 19, .08) 0 1px, transparent 1.8px);
  background-size: 30px 30px, 44px 44px;
}

.page h2 {
  position: relative;
  margin: 0 0 10px;
  font-size: 2.35rem;
  color: #38250f;
}

.page-intro {
  position: relative;
  margin-top: 0;
  font-size: 1.05rem;
}

.recipe-index {
  position: relative;
  margin: 26px 0 0;
  padding-left: 24px;
  display: grid;
  gap: 12px;
}

.recipe-index button {
  width: 100%;
  text-align: left;
  border-radius: 12px;
  border: 1px solid rgba(70,42,18,.18);
  background: rgba(255, 246, 210, .62);
  color: #302010;
  padding: 12px 14px;
}

.recipe-index button.active {
  outline: 2px solid rgba(116,79,24,.44);
  background: rgba(238, 221, 168, .50);
}

.recipe-view {
  position: relative;
  z-index: 2;
  max-width: 570px;
  margin-inline: auto;
}

/* camada da folha virando */
.page-turn-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;

  background:
    linear-gradient(
      90deg,
      rgba(120, 85, 42, .10) 0%,
      rgba(255, 250, 233, .22) 8%,
      transparent 20%,
      transparent 80%,
      rgba(120, 85, 42, .07) 100%
    ),
    linear-gradient(
      180deg,
      #fcf6e4 0%,
      #f1e4c3 100%
    );

  border-left: 1px solid rgba(112, 76, 34, .16);

  transform-origin: left center;
  transform: rotateY(0deg);
  backface-visibility: hidden;
  will-change: transform, opacity;

  box-shadow:
    inset -22px 0 22px rgba(0,0,0,.06),
    10px 0 24px rgba(0,0,0,.10);
}

.page-turn-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .42;
  background:
    linear-gradient(
      90deg,
      rgba(0,0,0,.12) 0%,
      rgba(0,0,0,0) 22%,
      rgba(255,255,255,.14) 50%,
      rgba(0,0,0,0) 78%,
      rgba(0,0,0,.10) 100%
    );
}

.recipe-page.turning .page-turn-layer {
  opacity: 1;
  animation: rightPageTurn .82s cubic-bezier(.45,.05,.18,1) forwards;
}

.recipe-page.turning .recipe-view {
  animation: recipeContentSwap .82s ease;
}

@keyframes rightPageTurn {
  0% {
    transform: rotateY(0deg);
    opacity: 1;
  }

  35% {
    transform: rotateY(-34deg);
    opacity: 1;
  }

  68% {
    transform: rotateY(-105deg);
    opacity: 1;
  }

  100% {
    transform: rotateY(-180deg);
    opacity: 0;
  }
}

@keyframes recipeContentSwap {
  0%, 36% {
    opacity: 1;
  }

  48% {
    opacity: .08;
  }

  100% {
    opacity: 1;
  }
}

/* conteúdo da receita */

.recipe-title {
  font-family: 'Parisienne', cursive;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: .88;
  margin: 0 0 8px;
  color: #20170e;
}

.recipe-meta {
  font-family: 'Cinzel', serif;
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #68451c;
  border-bottom: 1px solid rgba(85,54,18,.28);
  padding-bottom: 14px;
  margin-bottom: 18px;
}

.recipe-section {
  margin: 13px 0;
  padding: 12px 15px;
  border-left: 3px solid rgba(104,69,28,.48);
  background: rgba(255,250,226,.42);
}

.recipe-section h3 {
  margin: 0 0 5px;
  font-family: 'Cinzel', serif;
  font-size: .86rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.recipe-section p {
  margin: 0;
  white-space: pre-line;
  font-size: 1.04rem;
}

.recipe-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* MODAL */

.recipe-dialog {
  width: min(780px, calc(100% - 24px));
  border: 2px solid rgba(94,61,23,.4);
  border-radius: 24px;
  padding: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 35% 20%, rgba(255,255,255,.4), transparent 35%),
    var(--paper);
  box-shadow: 0 32px 110px rgba(0,0,0,.58);
}

.recipe-dialog::backdrop {
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(4px);
}

.recipe-dialog form {
  padding: 28px;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.dialog-heading h2 {
  margin: 0;
  font-family: 'Cinzel', serif;
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  margin: 24px 0 0;
}

.danger-button {
  color: #ffe9e9;
  background: linear-gradient(180deg, #7d2323, #3f1111);
  margin-right: auto;
}

/* RESPONSIVO */

@media (max-width: 860px) {
  .stage {
    padding: 14px;
  }

  .app-shell {
    width: 100%;
  }

  .top-actions {
    justify-content: center;
    flex-wrap: wrap;
  }

  .book {
    min-height: 620px;
  }

  .book-cover {
    width: min(92vw, 500px);
    height: 560px;
  }

  .book.open .book-cover {
    display: none;
  }

  .pages {
    width: 100%;
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .pages::before,
  .pages::after {
    display: none;
  }

  .page,
  .index-page,
  .recipe-page {
    border-radius: 0;
    border: 1px solid rgba(112, 76, 34, .14);
  }

  .recipe-page {
    min-height: 560px;
  }

  .page-turn-layer {
    display: none;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}