/* Menu flipbook viewer (menu.php). Page-curl engine adapted from the chongmatcha.com menu book.
   Served as-is (not part of the Vite/Tailwind builds); css/input.css excludes this folder. */
:root {
  --tm-red: #FF0000;
  --tm-dark-red: #B40000;
  --tm-yellow: #FFCB00;
  --tm-cream: #FFFCEB;
  --tm-ink: #0B0B0B;
  --tm-paper: #F4EFE3;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #0B0B0B;
  color: #FFFFFF;
  font-family: Kanit, 'Noto Sans Thai', Tahoma, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
.tm {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 14px max(10px, env(safe-area-inset-bottom));
  background-color: #0B0B0B;
  background-image: radial-gradient(rgba(255, 0, 0, 0.16) 1.4px, transparent 2px);
  background-size: 22px 22px;
}
.tm-ui { position: relative; z-index: 5; }
.tm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tm-title { min-width: 0; display: flex; align-items: baseline; gap: 2px 10px; flex-wrap: wrap; }
.tm-title h1 { margin: 0; }
.tm-brand { font-family: 'Archivo Black', Kanit, sans-serif; font-size: 20px; letter-spacing: 0.02em; color: var(--tm-yellow); line-height: 1.1; white-space: nowrap; }
.tm-brand span { color: var(--tm-red); }
.tm-close {
  flex: none; width: 44px; height: 44px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--tm-red); color: #FFFFFF; font-size: 28px; line-height: 1; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 14px rgba(255, 0, 0, 0.45);
}
.tm-close:hover { background: var(--tm-yellow); color: #000000; }
.tm-tools { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.tm-branches { display: inline-flex; padding: 3px; gap: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18); }
.tm-branch {
  height: 34px; padding: 0 14px; border-radius: 999px; border: 0; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; font-family: inherit; font-size: 14px; font-weight: 600;
  background: transparent; color: rgba(255, 255, 255, 0.75); white-space: nowrap;
}
.tm-branch:hover { color: #FFFFFF; }
.tm-branch[aria-current="true"] { background: var(--tm-yellow); color: #000000; }
.tm-jump {
  height: 44px; min-width: 0; flex: 0 1 340px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.25); padding: 0 14px;
  background: #1A1A1A; color: #FFFFFF; font-family: inherit; font-size: 15px;
}
.tm-btn {
  height: 40px; padding: 0 14px; border-radius: 999px; border: 0; cursor: pointer; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px; font-family: inherit; font-weight: 600; font-size: 15px;
  background: var(--tm-yellow); color: #000000;
}
.tm-btn:hover { background: #FFFFFF; color: #000000; }
.tm-share { position: relative; }
.tm-sharemenu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; min-width: 210px; padding: 6px;
  display: flex; flex-direction: column; gap: 4px; border-radius: 14px;
  background: #1A1A1A; border: 1px solid rgba(255, 255, 255, 0.18); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}
.tm-sharemenu[hidden], .tm-shareitem[hidden], .tm-sharepage[hidden] { display: none; }
.tm-sharepage {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 12px 10px; margin-bottom: 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12); font-size: 14px; font-weight: 600; color: #FFFFFF; cursor: pointer;
}
.tm-sharepage input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tm-sharepage small { display: block; font-size: 12px; font-weight: 400; color: rgba(255, 255, 255, 0.6); }
.tm-switch { flex: none; position: relative; width: 38px; height: 22px; border-radius: 999px; background: #444444; transition: background 0.15s; }
.tm-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #FFFFFF; transition: transform 0.15s; }
.tm-sharepage input:checked + .tm-switch { background: var(--tm-yellow); }
.tm-sharepage input:checked + .tm-switch::after { transform: translateX(16px); background: #000000; }
.tm-sharepage input:focus-visible + .tm-switch { outline: 3px solid var(--tm-yellow); outline-offset: 2px; }
.tm-shareitem {
  height: 42px; padding: 0 12px; border-radius: 10px; border: 0; cursor: pointer; text-decoration: none; white-space: nowrap;
  display: flex; align-items: center; gap: 10px; font-family: inherit; font-size: 15px; font-weight: 600;
  background: transparent; color: #FFFFFF; text-align: left;
}
.tm-shareitem:hover { background: rgba(255, 255, 255, 0.08); color: #FFFFFF; }
.tm-shareitem.tm-line, .tm-shareitem.tm-line:hover { background: #06C755; color: #FFFFFF; }
.tm-zoomctl { display: inline-flex; align-items: center; height: 40px; border-radius: 999px; background: #1A1A1A; border: 1px solid rgba(255, 255, 255, 0.25); overflow: hidden; }
.tm-zoomctl button { height: 100%; border: 0; background: transparent; color: #FFFFFF; cursor: pointer; font-family: inherit; font-weight: 600; }
.tm-zoomctl #tmZoomOut, .tm-zoomctl #tmZoomIn { width: 40px; font-size: 22px; }
.tm-zoomval { min-width: 60px; font-size: 14px; border-left: 1px solid rgba(255, 255, 255, 0.2) !important; border-right: 1px solid rgba(255, 255, 255, 0.2) !important; }
.tm-stage { position: relative; z-index: 1; isolation: isolate; flex: 1; min-height: 0; margin: 12px 0 10px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.tm-stage[aria-busy="true"] { cursor: progress; }
.tm-stage[aria-busy="true"]::after {
  content: "กำลังโหลดหน้าเมนู…"; position: absolute; z-index: 4; bottom: 12px; left: 50%; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px; background: var(--tm-yellow); color: #000000; font-size: 14px; white-space: nowrap;
}
.tm-book { position: absolute; left: 0; top: 0; will-change: transform; }
.tm-book .pg, .tm-book .flap { position: absolute; top: 0; overflow: hidden; background: var(--tm-paper); }
.tm-book img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; }
.tm-book img.fit-contain { object-fit: contain; }
.tm-book .pg[hidden], .tm-book .fx[hidden], .tm-book .fx-flapwrap[hidden] { display: none; }
.tm-book .pg-left, .tm-book .pg-right { box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55); }
.tm-book .pg-left::after { content: ""; position: absolute; inset: 0; background: linear-gradient(270deg, rgba(0,0,0,0.22), rgba(0,0,0,0) 7%); pointer-events: none; }
.tm-book .pg-right::after, .tm-book .pg-flat::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,0.22), rgba(0,0,0,0) 7%); pointer-events: none; }
.tm-book.single .pg-right::after, .tm-book.single .pg-flat::after { background: linear-gradient(90deg, rgba(0,0,0,0.12), rgba(0,0,0,0) 3%); }
.tm-book .fx-flapwrap { position: absolute; left: 0; top: 0; width: 0; height: 0; filter: drop-shadow(0 0 14px rgba(0,0,0,0.35)); pointer-events: none; }
.tm-book .flap { left: 0; transform-origin: 0 0; }
.tm-book .flap::after { content: ""; position: absolute; inset: 0; background: linear-gradient(270deg, rgba(0,0,0,0.18), rgba(0,0,0,0) 7%); pointer-events: none; }
.tm-book .flap.blank { background: linear-gradient(90deg, #E5DFD1, #F6F1E7 60%, #ECE5D7); }
.tm-book .flap.blank img { display: none; }
.tm-book .fx { position: absolute; top: 0; overflow: hidden; pointer-events: none; }
.tm-book .band { position: absolute; transform-origin: 0 50%; }
.tm-zoom { position: absolute; inset: 0; z-index: 3; background: #0B0B0B; cursor: grab; }
.tm-zoom[hidden] { display: none; }
.tm-zoom.grabbing { cursor: grabbing; }
.tm-zc { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; display: flex; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.tm-zc img { display: block; height: 100%; background: var(--tm-paper); pointer-events: none; -webkit-user-drag: none; object-fit: cover; }
.tm-zc img.fit-contain { object-fit: contain; }
.tm-foot { display: flex; align-items: center; justify-content: center; gap: 12px; }
.tm-nav {
  width: 48px; height: 48px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--tm-red); color: #FFFFFF; font-size: 30px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.tm-nav:hover { background: var(--tm-yellow); color: #000000; }
.tm-nav:disabled { opacity: 0.3; cursor: default; background: var(--tm-red); color: #FFFFFF; }
.tm-count { flex: none; min-width: 64px; text-align: center; font-weight: 600; font-size: 16px; color: #FFFFFF; white-space: nowrap; }
.tm-toast {
  position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 8;
  background: var(--tm-yellow); color: #000000; border-radius: 999px; padding: 9px 18px;
  font-weight: 600; font-size: 15px; white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.tm-toast[hidden] { display: none; }
.tm :focus-visible { outline: 3px solid var(--tm-yellow); outline-offset: 3px; }
.tm-empty { margin: auto; max-width: 420px; text-align: center; color: var(--tm-cream); font-size: 16px; line-height: 1.6; }
.tm-empty a { color: var(--tm-yellow); }
@media (max-width: 560px) {
  .tm { padding-left: 8px; padding-right: 8px; }
  .tm-brand { font-size: 17px; }
  .tm-tools { gap: 6px; }
  .tm-btn { padding: 0 11px; font-size: 14px; }
  .tm-foot { gap: 8px; }
  .tm-nav { width: 44px; height: 44px; flex: none; }
  .tm-jump { flex: 1 1 auto; font-size: 16px; }
  .tm-count { min-width: 52px; font-size: 15px; }
  .tm-book .fx-flapwrap { filter: none; }
}
/* Phones pinch to zoom: the zoom buttons would only push the book down. */
@media (max-width: 560px) and (pointer: coarse) {
  .tm-zoomctl { display: none; }
}
