/* ==================================================================
   CỔNG VÀO — màn hình nhập mã truy cập
   Gợi hình cổng tam quan: hoành phi trên, câu đối hai bên.
   ================================================================== */

body.cong {
  background-color: #2b0f0c;
  background-image:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(201, 162, 39, 0.22), transparent 70%),
    radial-gradient(ellipse 70% 50% at 50% 110%, rgba(158, 43, 37, 0.5), transparent 70%),
    linear-gradient(170deg, #3c1512 0%, #2b0f0c 45%, #1c0908 100%);
  background-attachment: fixed;
  color: #f3e6cd;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: clamp(1rem, 4vw, 3rem) 1rem;
  overflow-x: hidden;
}

body.cong::before {
  /* thớ sơn mài */
  opacity: 0.35;
  background-image:
    repeating-linear-gradient(97deg, rgba(255, 226, 160, 0.05) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(3deg, rgba(255, 226, 160, 0.035) 0 1px, transparent 1px 13px);
}

/* Trống đồng khổng lồ mờ phía sau */
.trong-dong-nen {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(150vh, 150vw);
  height: min(150vh, 150vw);
  transform: translate(-50%, -50%);
  opacity: 0.055;
  color: #e6c766;
  pointer-events: none;
  z-index: 0;
  animation: xoay-cham 240s linear infinite;
}

@keyframes xoay-cham { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* ------------------------- Bố cục cổng ------------------------ */

.cong-khung {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(1rem, 4vw, 3rem);
  width: 100%;
  max-width: 1080px;
}

/* Câu đối dọc hai bên — nét đặc trưng của cổng nhà thờ họ */
.cau-doi-doc {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: var(--font-title);
  font-size: clamp(0.95rem, 1.5vw, 1.28rem);
  font-weight: 600;
  letter-spacing: 0.3em;
  line-height: 1.35;
  color: #e6c766;
  padding: 1.6rem 0.75rem;
  border: 1px solid rgba(230, 199, 102, 0.32);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(158, 43, 37, 0.42), rgba(90, 20, 16, 0.5));
  box-shadow: inset 0 0 0 4px rgba(230, 199, 102, 0.1), 0 12px 40px rgba(0, 0, 0, 0.42);
  max-height: 74vh;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  animation: hien-len 1s ease-out both;
}

.cau-doi-doc.trai { animation-delay: 0.25s; }
.cau-doi-doc.phai { animation-delay: 0.4s; transform: scaleX(-1); }
.cau-doi-doc.phai > span { display: inline-block; transform: scaleX(-1); }

@keyframes hien-len {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; }
}

.cau-doi-doc.phai {
  animation-name: hien-len-phai;
}

@keyframes hien-len-phai {
  from { opacity: 0; transform: scaleX(-1) translateY(20px); }
  to { opacity: 1; transform: scaleX(-1); }
}

/* ------------------------- Tấm giấy dó ------------------------ */

.cong-the {
  background:
    linear-gradient(165deg, #fdf9ef 0%, #f6efdd 42%, #efe4c8 100%);
  color: #2a2118;
  border-radius: 10px;
  padding: clamp(1.8rem, 4vw, 3rem) clamp(1.4rem, 4vw, 3.2rem) clamp(1.6rem, 3.5vw, 2.4rem);
  box-shadow:
    0 0 0 1px #96741a,
    0 0 0 7px rgba(43, 15, 12, 0.85),
    0 0 0 8px #96741a,
    0 30px 80px rgba(0, 0, 0, 0.6);
  text-align: center;
  position: relative;
  animation: hien-len 0.85s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

/* Hoa văn hồi văn viền trong tấm giấy */
.cong-the::before {
  content: '';
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(150, 116, 26, 0.35);
  border-radius: 4px;
  pointer-events: none;
}

.cong-mai {
  /* Mái ngói cong cách điệu phía trên tấm giấy */
  display: block;
  width: min(100%, 520px);
  margin: 0 auto -14px;
  color: #9e2b25;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45));
  position: relative;
  z-index: 3;
}

.cong-hoanh-phi {
  font-family: var(--font-title);
  font-size: clamp(0.8rem, 1.8vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: #96741a;
  margin-bottom: 1.1rem;
  text-indent: 0.42em;
}

.cong-sao {
  width: 62px;
  height: 62px;
  margin: 0 auto 0.9rem;
  color: #9e2b25;
}

.cong-ten {
  font-family: var(--font-title);
  font-size: clamp(1.55rem, 4.6vw, 2.65rem);
  font-weight: 800;
  line-height: 1.28;
  color: #74190f;
  margin: 0 0 0.3rem;
  letter-spacing: 0.02em;
}

.cong-chi {
  font-family: var(--font-title);
  font-style: italic;
  font-size: clamp(1rem, 2.2vw, 1.22rem);
  color: #6b4423;
  margin-bottom: 0.35rem;
}

.cong-que {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: #8a7a66;
  margin-bottom: 1.5rem;
}

.cong-cau-doi-ngang {
  font-family: var(--font-title);
  font-style: italic;
  color: #6b4423;
  font-size: 0.98rem;
  line-height: 1.85;
  margin: 0 auto 1.6rem;
  max-width: 34ch;
}

/* -------------------------- Ô nhập mã ------------------------- */

.cong-form { display: grid; gap: 0.85rem; max-width: 400px; margin: 0 auto; text-align: left; }

.cong-form label {
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #9e2b25;
  display: block;
  margin-bottom: 0.3rem;
  text-align: center;
}

#ma-truy-cap {
  font-family: var(--font-ui);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-align: center;
  text-transform: uppercase;
  padding: 0.72em 0.6em;
  background: #fffdf7;
  border: 1.5px solid rgba(150, 116, 26, 0.55);
  border-radius: 8px;
  color: #2a2118;
  box-shadow: inset 0 2px 5px rgba(107, 68, 35, 0.1);
  width: 100%;
}

#ma-truy-cap::placeholder { color: #c3b493; letter-spacing: 0.18em; font-weight: 400; }

#ma-truy-cap:focus {
  outline: none;
  border-color: #c9a227;
  box-shadow: inset 0 2px 5px rgba(107, 68, 35, 0.08), 0 0 0 4px rgba(201, 162, 39, 0.28);
}

#ten-nguoi-xem {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  text-align: center;
  padding: 0.55em 0.7em;
  background: #fffdf7;
  border: 1px solid rgba(150, 116, 26, 0.38);
  border-radius: 8px;
  color: #2a2118;
  width: 100%;
}

.cong-nut {
  font-family: var(--font-ui);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.85em 1.5em;
  width: 100%;
  border-radius: 8px;
  border: 1px solid #74190f;
  background: linear-gradient(175deg, #c0392b, #9e2b25 55%, #74190f);
  color: #fff5e8;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(116, 25, 15, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.12s, box-shadow 0.18s, filter 0.18s;
}

.cong-nut:hover:not(:disabled) { filter: brightness(1.08); box-shadow: 0 6px 20px rgba(116, 25, 15, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.cong-nut:active:not(:disabled) { transform: translateY(1px); }
.cong-nut:disabled { opacity: 0.6; cursor: wait; }

.cong-loi {
  background: rgba(158, 43, 37, 0.1);
  border: 1px solid rgba(158, 43, 37, 0.45);
  border-radius: 8px;
  color: #74190f;
  font-size: 0.9rem;
  padding: 0.65rem 0.9rem;
  text-align: center;
  animation: rung 0.32s;
}

@keyframes rung {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-7px); }
  44% { transform: translateX(6px); }
  66% { transform: translateX(-4px); }
  88% { transform: translateX(2px); }
}

.cong-goi-y {
  font-size: 0.85rem;
  color: #8a7a66;
  line-height: 1.65;
  text-align: center;
  margin-top: 0.3rem;
}

.cong-chan {
  margin-top: 1.7rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(150, 116, 26, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.cong-lien-ket {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: #6b4423;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0.25rem;
}

.cong-lien-ket:hover { color: #9e2b25; }

/* Con dấu son góc dưới phải */
.cong-dau {
  position: absolute;
  right: clamp(0.9rem, 3vw, 2rem);
  bottom: clamp(0.9rem, 3vw, 1.6rem);
  width: 68px;
  height: 68px;
  border: 2.5px solid #9e2b25;
  border-radius: 5px;
  color: #9e2b25;
  display: grid;
  place-items: center;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.7rem;
  line-height: 1.2;
  text-align: center;
  transform: rotate(-8deg);
  opacity: 0.5;
  box-shadow: inset 0 0 0 1.5px #9e2b25;
  pointer-events: none;
}

.cong-loi-nhac {
  position: relative;
  z-index: 2;
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.82rem;
  color: rgba(230, 199, 102, 0.62);
  font-family: var(--font-ui);
  letter-spacing: 0.05em;
}

/* --------------------------- Màn nhỏ -------------------------- */

@media (max-width: 900px) {
  .cong-khung { grid-template-columns: minmax(0, 1fr); }
  .cau-doi-doc { display: none; }
}

@media (max-width: 480px) {
  .cong-dau { display: none; }
  .cong-the { padding-inline: 1.15rem; }
}
