/* ==========================================================================
   BẢNG HÀNH LỄ CHO KHÁCH (BẢN WEBSITE)
   Bảng màu sơn mài: đỏ son, gỗ mun, vàng lá, giấy dó.
   Điểm nhấn duy nhất: lá sớ màu giấy dó với con dấu son.
   ========================================================================== */
:root {
  --lac: #7a1a12;
  --lac-deep: #2b0a07;
  --wood: #170806;
  --wood-2: #22100b;
  --leaf: #c9973a;
  --leaf-hi: #ecc66f;
  --paper: #f0e2c2;
  --ink: #2e1a0e;
  --smoke: #a89a86;
  --line: rgba(201, 151, 58, 0.34);
  --f-head: 'Bai Jamjuree', 'Be Vietnam Pro', sans-serif;
  --f-ui: 'Lexend', 'Be Vietnam Pro', sans-serif;
  --f-body: 'Roboto', 'Be Vietnam Pro', sans-serif;
  --bar-h: 152px;
}

/* Chế độ hiển thị */
.pilgrim-panel { display: none; }
body.web-mode .pilgrim-panel { display: flex; }
body.web-mode .quick-dock { display: none !important; }
body.obs-mode .pilgrim-panel { display: none !important; }
body.dock-mode .temple-gate,
body.obs-mode .temple-gate { display: none; }

body.web-mode .co-temple {
  background:
    radial-gradient(120% 70% at 30% 0%, rgba(122, 26, 18, 0.35), transparent 60%),
    var(--wood);
}
body.web-mode .co-temple {
  height: calc(100svh - var(--co-head-h, 60px));
  min-height: 560px;
}
.admin-bar.web-mode .co-temple { height: calc(100svh - var(--co-head-h, 60px) - 32px); }
body.web-mode .app-workspace { gap: 28px; padding: 2vh 2vw; }
body.web-mode .stage-wrapper {
  height: 100%;
  border-radius: 2px;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
body.web-mode .pilgrim-panel *,
body.web-mode .temple-gate * { user-select: text; }

body.web-mode .hud-panel-kicker { display: none; }

/* --------------------------------------------------------------- cổng vào */
.temple-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(23, 8, 6, 0.82), rgba(23, 8, 6, 0.94)),
    url('../img/amitabha_stage.jpg') center 30% / cover no-repeat;
  transition: opacity 0.6s ease, visibility 0.6s;
}
.temple-gate.is-gone { opacity: 0; visibility: hidden; }
.gate-inner {
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.gate-mark {
  width: 64px;
  height: 64px;
  fill: none;
  stroke: var(--leaf-hi);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.gate-kicker {
  font-family: var(--f-head);
  font-weight: 700;
  font-size: clamp(30px, 6vw, 44px);
  line-height: 1.1;
  color: var(--paper);
  letter-spacing: 0.01em;
}
.gate-line {
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--smoke);
  max-width: 34ch;
}
.gate-enter {
  margin-top: 10px;
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 17px;
  color: var(--lac-deep);
  background: var(--leaf-hi);
  border: 0;
  border-radius: 2px;
  padding: 15px 34px;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--leaf), 0 10px 40px rgba(236, 198, 111, 0.25);
}
.gate-enter:hover { background: #f4d78f; }
.gate-quiet {
  font-family: var(--f-ui);
  font-size: 14px;
  color: var(--smoke);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 6px;
}

/* --------------------------------------------------------------- bảng hành lễ */
.pilgrim-panel {
  position: relative;
  width: 380px;
  max-height: 100%;
  overflow-y: auto;
  flex-direction: column;
  gap: 18px;
  padding: 22px 22px 18px;
  background: linear-gradient(180deg, var(--wood-2), var(--wood));
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--f-body);
  color: var(--paper);
  scrollbar-width: thin;
  scrollbar-color: var(--lac) transparent;
}

.pp-title {
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.15;
  color: var(--leaf-hi);
}
.pp-presence {
  margin-top: 6px;
  font-size: 14px;
  color: var(--smoke);
  display: flex;
  align-items: center;
  gap: 8px;
}
.pp-presence strong, #ppOnline { color: var(--paper); font-weight: 500; }
.pp-dot {
  width: 7px;
  height: 7px;
  background: #e0503a;
  box-shadow: 0 0 0 3px rgba(224, 80, 58, 0.22);
}

.pp-sheet { display: flex; flex-direction: column; gap: 14px; }
.pp-field { display: flex; flex-direction: column; gap: 6px; }
.pp-label {
  font-family: var(--f-ui);
  font-size: 13px;
  color: var(--smoke);
}
.pp-field input {
  font-family: var(--f-head);
  font-size: 17px;
  font-weight: 500;
  color: var(--paper);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 10px 12px;
}

/* Lá sớ — điểm nhấn */
.pp-slip {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  padding: 14px 16px 12px 16px;
  border-left: 5px solid var(--lac);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 14px 30px rgba(0, 0, 0, 0.35);
}
.pp-slip-label {
  display: block;
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 15px;
  color: var(--lac);
  margin-bottom: 4px;
  padding-right: 48px;
}
.pp-slip textarea {
  width: 100%;
  resize: none;
  border: 0;
  background: repeating-linear-gradient(180deg, transparent 0 31px, rgba(122, 26, 18, 0.18) 31px 32px);
  background-attachment: local;
  font-family: var(--f-head);
  font-size: 18px;
  line-height: 32px;
  padding: 0 44px 0 0;
  height: 96px;
  color: var(--ink);
  outline: none;
}
.pp-slip textarea::placeholder { color: rgba(46, 26, 14, 0.45); }
.pp-slip-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: rgba(46, 26, 14, 0.62);
  margin-top: 4px;
}
.pp-seal {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 16px;
  color: #f7e6c4;
  background: var(--lac);
  border: 2px solid #f0e2c2;
  outline: 1px solid var(--lac);
  transform: rotate(-4deg);
}

/* Nghi thức */
.pp-rites {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.pp-rite {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  text-align: left;
  padding: 12px 10px;
  background: var(--wood);
  color: var(--paper);
  border: 0;
  border-radius: 0;
  cursor: pointer;
  font-family: var(--f-ui);
  transition: background 0.15s ease;
}
.pp-rite svg {
  grid-row: 1 / 3;
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--leaf-hi);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.pp-rite-name { font-size: 13.5px; font-weight: 500; line-height: 1.2; }
.pp-rite-meta { font-size: 12px; color: var(--leaf); }
.pp-rite:hover:not(:disabled) { background: #3a120c; }
.pp-rite:active:not(:disabled) { background: var(--lac); }
.pp-rite-main { background: var(--lac); }
.pp-rite-main:hover:not(:disabled) { background: #8f2016; }
.pp-rite:disabled { cursor: wait; color: var(--smoke); }
.pp-rite:disabled svg { stroke: var(--smoke); }
.pp-cool {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--leaf-hi);
  transform: scaleX(0);
  transform-origin: left;
}

.pp-me {
  font-size: 14px;
  line-height: 1.55;
  color: var(--smoke);
  border-left: 2px solid var(--leaf);
  padding-left: 10px;
}

/* Lời khấn vừa gửi */
.pp-wall-title {
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 17px;
  color: var(--paper);
  margin-bottom: 8px;
}
.pp-wall-list { list-style: none; display: flex; flex-direction: column; }
.pp-wish {
  position: relative;
  padding: 10px 70px 10px 0;
  border-top: 1px solid rgba(201, 151, 58, 0.16);
}
.pp-wish.is-mine .pp-wish-who { color: var(--leaf-hi); }
.pp-wish-who { font-family: var(--f-ui); font-size: 12.5px; color: var(--leaf); }
.pp-wish-text { font-size: 15px; line-height: 1.5; color: var(--paper); margin-top: 2px; }
.pp-wall-empty { font-size: 14px; color: var(--smoke); padding: 8px 0; }
.pp-report {
  position: absolute;
  top: 10px;
  right: 0;
  font-family: var(--f-ui);
  font-size: 12px;
  color: var(--smoke);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pp-report:hover { color: var(--paper); }

.pp-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.pp-toggle {
  font-family: var(--f-ui);
  font-size: 12.5px;
  color: var(--smoke);
  background: transparent;
  border: 1px solid rgba(201, 151, 58, 0.25);
  border-radius: 2px;
  padding: 7px 10px;
  cursor: pointer;
}
.pp-toggle[aria-pressed='true'] { color: var(--paper); border-color: var(--line); }
.pp-mobile-only { display: none; }

.pp-toast {
  position: sticky;
  bottom: 0;
  font-family: var(--f-ui);
  font-size: 14px;
  line-height: 1.45;
  padding: 11px 13px;
  background: var(--paper);
  color: var(--ink);
  border-left: 4px solid var(--leaf);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.pp-toast.is-on { opacity: 1; transform: none; }
.pp-toast[data-tone='warn'] { border-left-color: var(--lac); }
.pp-toast[data-tone='ok'] { border-left-color: #5d8a3a; }

.pilgrim-panel :focus-visible,
.temple-gate :focus-visible {
  outline: 2px solid var(--leaf-hi);
  outline-offset: 2px;
}

/* --------------------------------------------------------------- PC hẹp */
@media (max-width: 1100px) and (min-width: 901px) {
  .pilgrim-panel { width: 330px; }
}

/* --------------------------------------------------------------- điện thoại */
@media (max-width: 900px) {
  body.web-mode .co-temple { height: auto; min-height: 0; }
  .admin-bar.web-mode .co-temple { height: auto; }
  body.web-mode .app-workspace {
    flex-direction: column;
    justify-content: flex-start;
    padding: 0;
    gap: 0;
    height: auto;
  }
  body.web-mode .stage-wrapper {
    height: min(calc(100svh - var(--co-head-h, 60px) - var(--bar-h)), calc(100vw * 16 / 9));
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .pilgrim-panel {
    position: relative;
    width: 100%;
    max-height: none;
    overflow: visible;
    padding: 10px 10px 12px;
    gap: 8px;
    border-width: 1px 0;
  }
  .pp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .pp-title { font-size: 17px; }
  .pp-presence { margin: 0; font-size: 12.5px; }
  .pp-sheet, .pp-wall, .pp-me { display: none; }
  .pp-rites { grid-template-columns: repeat(6, 1fr); order: 3; }
  .pp-rite {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    padding: 8px 2px 7px;
    row-gap: 3px;
  }
  .pp-rite svg { grid-row: auto; width: 22px; height: 22px; }
  .pp-rite-name { font-size: 11px; }
  .pp-rite-meta { display: none; }
  .pp-tools { order: 4; flex-wrap: nowrap; }
  .pp-toggle { flex: 1; font-size: 11.5px; padding: 6px 4px; }
  #ppHear { display: none; }
  .pp-mobile-only { display: block; color: var(--lac-deep); background: var(--leaf-hi); border-color: var(--leaf-hi); font-weight: 600; }
  .pp-toast { position: fixed; left: 10px; right: 10px; bottom: 12px; z-index: 60; }

  .pilgrim-panel.is-open .pp-sheet,
  .pilgrim-panel.is-open .pp-wall { display: flex; }
  .pilgrim-panel.is-open .pp-me { display: block; }
  .pilgrim-panel.is-open .pp-wall { flex-direction: column; }
  .pilgrim-panel.is-open .pp-sheet { order: 1; }
  .pilgrim-panel.is-open #ppHear { display: block; }
  .pilgrim-panel.is-open .pp-me { order: 5; }
  .pilgrim-panel.is-open .pp-wall { order: 6; }
}

@media (prefers-reduced-motion: reduce) {
  .temple-gate, .pp-toast, .pilgrim-panel { transition: none; }
}

/* lối vào Chùa 3D */
.gate-3d { display: inline-block; margin-top: 14px; padding: 10px 16px; border: 1px solid rgba(240, 196, 106, .6); color: #f0c46a; font-family: "Bai Jamjuree", sans-serif; font-weight: 600; font-size: 15px; text-decoration: none; }
.gate-3d:hover, .gate-3d:focus-visible { background: rgba(240, 196, 106, .12); }
