/* ==========================================================================
   jaystore.tickets — customer site
   Mobile-first. Min body text 17px, min small text 14px, touch targets 44px+.
   ========================================================================== */

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

:root {
  --green:       #0b7a43;
  --green-ink:   #075c32;
  --green-tint:  #e4f3ea;
  --green-ring:  rgba(11, 122, 67, .22);

  --bg:          #f2f6f3;
  --card:        #ffffff;
  --ink:         #14201a;
  --ink-2:       #46544b;
  --ink-3:       #66736b;
  --line:        #e1e8e3;
  --line-strong: #cdd8d1;

  --amber-tint:  #fff3d1;
  --amber-ink:   #6f4700;
  --red-tint:    #fde8e6;
  --red-ink:     #a12418;
  --grey-tint:   #eceeed;
  --grey-ink:    #4d5651;

  --head-h: 60px;
  --nav-h:  64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }

body {
  margin: 0;
  font: 400 1.0625rem/1.6 'IBM Plex Sans Thai', 'Noto Sans Thai', 'Sarabun', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
}
body.lock { overflow: hidden; }

h1, h2, h3, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: var(--green-ink); }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1040px; margin-inline: auto; padding-inline: 16px; }
.sr   { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ico {
  width: 1.25em; height: 1.25em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.skip { position: absolute; left: -999px; top: 8px; }
.skip:focus { left: 12px; z-index: 200; background: #fff; padding: 10px 14px; border-radius: 10px; }

/* ── Header ───────────────────────────────────────────────────────────── */
.top { position: sticky; top: 0; z-index: 50; background: #fff; border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: var(--head-h); }

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; background: var(--green); color: #fff; display: grid; place-items: center; }
.brand-logo .ico { width: 20px; height: 20px; }

.line-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; background: var(--green); color: #fff; text-decoration: none; font-weight: 600;
}
.line-btn:hover { background: var(--green-ink); }

/* Tab bar: bottom of the screen on phones (thumb reach) */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #fff; border-top: 1px solid var(--line);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-h); color: var(--ink-2); text-decoration: none; font-size: .875rem; font-weight: 600;
}
.tab .ico { width: 26px; height: 26px; }
.tab[aria-current="page"] { color: var(--green); }
.tab[aria-current="page"]::before {
  content: ''; position: absolute; top: -1px; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--green);
}

/* ── Page heading ─────────────────────────────────────────────────────── */
.page-head { padding: 22px 0 16px; }
.page-head h1 { font-size: 1.75rem; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
.page-head p  { margin-top: 4px; color: var(--ink-2); }
.live { display: flex; align-items: flex-start; gap: 10px; }
.live-dot { width: 9px; height: 9px; flex: none; margin-top: .6em; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-ring); }

/* ── Shared pieces ────────────────────────────────────────────────────── */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  min-height: 52px; padding: 8px 22px; border-radius: 14px; border: 2px solid transparent;
  font-weight: 600; font-size: 1.0625rem; line-height: 1.35; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-ink); }
.btn-ghost { background: #fff; color: var(--green-ink); border-color: var(--line-strong); }
.btn-block { width: 100%; }

.notice {
  display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; padding: 12px 14px;
  background: var(--amber-tint); color: var(--amber-ink); border-radius: 12px; font-size: .9375rem; line-height: 1.5;
}
.notice .ico { margin-top: 2px; }
.notice a, .note a { color: inherit; font-weight: 700; }

/* ── Calculator ───────────────────────────────────────────────────────── */
.calc-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

.step { padding: 20px 16px; }
.step + .step { border-top: 1px solid var(--line); }
.step-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 1.0625rem; font-weight: 600; line-height: 1.4; }
.step-no { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--green-tint); color: var(--green-ink); font-size: .875rem; font-weight: 700; }
label.step-title { cursor: pointer; }

.money {
  display: flex; align-items: center; gap: 8px; height: 68px; padding: 0 18px;
  background: #fff; border: 2px solid var(--line-strong); border-radius: 14px;
}
.money:focus-within { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-ring); }
.money input {
  flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent;
  font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.money input::placeholder { color: #a9b5ad; }
.money .unit { color: var(--ink-2); font-weight: 500; }
.hint { margin-top: 8px; font-size: .9375rem; color: var(--ink-3); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--bg); border-radius: 14px; }
.seg label { position: relative; display: block; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span { display: grid; place-items: center; min-height: 50px; padding: 0 4px; border-radius: 11px; font-weight: 600; color: var(--ink-2); text-align: center; }
.seg input:checked + span { background: var(--green); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--green); outline-offset: 2px; }

.note {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 12px 14px;
  background: var(--amber-tint); color: var(--amber-ink); border-radius: 12px; font-size: .9375rem; line-height: 1.5;
}
.note .ico { margin-top: 2px; }

.plans { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 10px; padding-top: 6px; }
.plan { position: relative; display: block; }
.plan input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.plan-body { display: block; height: 100%; padding: 14px; background: #fff; border: 2px solid var(--line-strong); border-radius: 14px; }
.plan-main { display: block; font-size: 1.25rem; font-weight: 700; line-height: 1.3; }
.plan-sub  { display: block; font-size: .9375rem; color: var(--ink-2); }
.plan-amt  { display: block; margin-top: 8px; min-height: 1.6em; font-weight: 600; font-size: 1rem; color: var(--green-ink); font-variant-numeric: tabular-nums; }
.plan-check {
  position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; padding: 3px; display: none;
  border-radius: 50%; background: var(--green); color: #fff; stroke-width: 3;
}
.plan-tag {
  position: absolute; top: -11px; left: 12px; z-index: 2; padding: 0 10px; border-radius: 999px;
  background: var(--amber-tint); color: var(--amber-ink); border: 1px solid #ecd48a; font-size: .8125rem; font-weight: 700; line-height: 20px;
}
.plan input:checked ~ .plan-body  { border-color: var(--green); background: var(--green-tint); }
.plan input:checked ~ .plan-check { display: block; }
.plan input:focus-visible ~ .plan-body { outline: 3px solid var(--green); outline-offset: 2px; }
.plan-sk { height: 104px; border-radius: 14px; background: var(--bg); }

/* Summary — a ticket stub with a tear-off line */
.empty-stub {
  display: grid; justify-items: center; gap: 8px; padding: 28px 20px; text-align: center; color: var(--ink-2);
  border: 2px dashed var(--line-strong); border-radius: 20px;
}
.empty-stub .ico { width: 32px; height: 32px; color: var(--ink-3); }

.stub { filter: drop-shadow(0 12px 24px rgba(8, 56, 33, .14)) drop-shadow(0 1px 2px rgba(8, 56, 33, .12)); }
.stub-top, .stub-bottom { background: #fff; }
.stub-top {
  padding: 20px 20px 24px; background: var(--green); color: #fff; border-radius: 20px 20px 0 0;
  -webkit-mask: radial-gradient(13px at 0 100%, #0000 97%, #000) left / 51% 100% no-repeat,
                radial-gradient(13px at 100% 100%, #0000 97%, #000) right / 51% 100% no-repeat;
          mask: radial-gradient(13px at 0 100%, #0000 97%, #000) left / 51% 100% no-repeat,
                radial-gradient(13px at 100% 100%, #0000 97%, #000) right / 51% 100% no-repeat;
}
.stub-top h2 { font-size: 1.0625rem; font-weight: 600; }
.stub-sub { margin: 2px 0 12px; font-size: .9375rem; opacity: .92; }
.pay { padding: 12px 0 4px; }
.pay + .pay { margin-top: 8px; border-top: 1px solid rgba(255, 255, 255, .28); }
.pay-label { font-size: 1.0625rem; opacity: .95; }
.pay-val { display: flex; align-items: baseline; gap: 8px; }
.pay-num { font-size: 2.5rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.pay-unit { font-size: 1.0625rem; font-weight: 500; }
.pay-note { font-size: .9375rem; opacity: .92; }

.stub-bottom {
  position: relative; padding: 24px 20px 20px; border-radius: 0 0 20px 20px;
  -webkit-mask: radial-gradient(13px at 0 0, #0000 97%, #000) left / 51% 100% no-repeat,
                radial-gradient(13px at 100% 0, #0000 97%, #000) right / 51% 100% no-repeat;
          mask: radial-gradient(13px at 0 0, #0000 97%, #000) left / 51% 100% no-repeat,
                radial-gradient(13px at 100% 0, #0000 97%, #000) right / 51% 100% no-repeat;
}
.stub-bottom::before { content: ''; position: absolute; top: 0; left: 24px; right: 24px; border-top: 2px dashed var(--line-strong); }

.rows { display: grid; gap: 10px; }
.rows > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.rows dt { color: var(--ink-2); }
.rows dd { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.rows .row-total { margin-top: 2px; padding-top: 12px; border-top: 1px solid var(--line); }
.rows .row-total dt { color: var(--ink); font-weight: 600; }
.rows .row-total dd { font-size: 1.25rem; font-weight: 700; white-space: nowrap; }
.fine { margin: 12px 0 16px; font-size: .875rem; color: var(--ink-3); line-height: 1.5; }

.docs { padding: 20px 16px; }
.docs h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 1.1875rem; font-weight: 700; }
.docs h2 .ico { color: var(--green); }
.docs li { display: grid; grid-template-columns: 24px 1fr; gap: 12px; padding: 10px 0; }
.docs li + li { border-top: 1px solid var(--line); }
.docs li .ico { width: 24px; height: 24px; padding: 4px; border-radius: 50%; background: var(--green-tint); color: var(--green-ink); stroke-width: 3; margin-top: 2px; }
.docs b { display: block; font-weight: 600; }
.docs span { color: var(--ink-2); font-size: .9375rem; }

/* Floating answer bar (phones only) */
.minibar {
  position: fixed; left: 12px; right: 12px; z-index: 55;
  bottom: calc(var(--nav-h) + var(--safe-b) + 10px);
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px;
  background: var(--ink); color: #fff; border-radius: 16px; box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}
.minibar-text { flex: 1; min-width: 0; font-size: .9375rem; line-height: 1.4; }
.minibar-text b { font-size: 1.0625rem; font-variant-numeric: tabular-nums; }
.minibar button { min-height: 44px; padding: 0 16px; border: 0; border-radius: 10px; background: #fff; color: var(--ink); font-weight: 600; cursor: pointer; }

/* ── Queue lists ──────────────────────────────────────────────────────── */
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.chips { display: flex; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 16px; border-radius: 999px; background: #fff; color: var(--ink-2);
  border: 1.5px solid var(--line-strong); font-weight: 600; font-size: .9375rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.search { position: relative; flex: 1 1 220px; display: block; }
.search .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; min-height: 44px; padding: 0 14px 0 42px; background: #fff;
  border: 1.5px solid var(--line-strong); border-radius: 999px; outline: 0;
}
.search input:focus { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-ring); }

.list-sum { margin: 4px 0 12px; font-size: .9375rem; color: var(--ink-2); min-height: 1.5em; }

.ev-list { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.ev {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 0 14px; align-items: start;
  width: 100%; height: 100%; padding: 14px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
}
button.ev { cursor: pointer; }
button.ev:hover { border-color: var(--green); }
button.ev:active { background: var(--green-tint); }

.ev-thumb { width: 64px; height: 64px; border-radius: 12px; overflow: hidden; display: grid; place-items: center; background: var(--green-tint); font-size: 1.75rem; }
.ev-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ev-title { display: block; font-size: 1.0625rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.ev-new { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; vertical-align: 1px; background: var(--amber-tint); color: var(--amber-ink); font-size: .8125rem; font-weight: 700; line-height: 20px; }
.ev-meta { display: flex; align-items: flex-start; gap: 6px; margin-top: 2px; color: var(--ink-2); font-size: .9375rem; line-height: 1.45; }
.ev-meta .ico { width: 16px; height: 16px; margin-top: 3px; }
.ev-added { display: block; margin-top: 4px; font-size: .875rem; color: var(--ink-3); }
body.hide-added-queue  #page-queue  .ev-added,
body.hide-added-events #page-events .ev-added { display: none; }

.ev-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 3px 12px; border-radius: 999px; font-size: .9375rem; font-weight: 600; line-height: 1.5; }
.badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.open    { background: var(--green-tint); color: var(--green-ink); }
.badge.limited { background: var(--amber-tint); color: var(--amber-ink); }
.badge.full    { background: var(--red-tint);   color: var(--red-ink); }
.badge.closed  { background: var(--grey-tint);  color: var(--grey-ink); }
.slots { font-size: .9375rem; font-weight: 600; }
.more  { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; color: var(--green-ink); font-size: .9375rem; font-weight: 600; }
.more .ico { width: 18px; height: 18px; }

.sk { height: 132px; border-radius: 16px; background: linear-gradient(90deg, #e6ece8 25%, #f2f6f3 40%, #e6ece8 60%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.state { padding: 28px 20px; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.state-icon { width: 52px; height: 52px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%; background: var(--green-tint); color: var(--green); }
.state-icon.warn { background: var(--amber-tint); color: var(--amber-ink); }
.state h2 { font-size: 1.25rem; line-height: 1.4; }
.state p  { margin: 6px auto 0; max-width: 34ch; color: var(--ink-2); }
.state-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }

.cross { margin-top: 20px; text-align: center; color: var(--ink-2); }
.cross a { font-weight: 600; }

.cta-strip {
  display: flex; flex-direction: column; align-items: stretch; gap: 14px; margin-top: 20px; padding: 18px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
}
.cta-strip strong { display: block; font-size: 1.125rem; }
.cta-strip span { color: var(--ink-2); }

.site-foot { padding-top: 28px; padding-bottom: 12px; text-align: center; color: var(--ink-2); font-size: .9375rem; }

/* ── Detail sheet (bottom sheet on phones, dialog on larger screens) ──── */
dialog { width: 100%; max-width: 100%; margin: auto 0 0; padding: 0; border: 0; background: transparent; color: var(--ink); overflow: visible; }
dialog::backdrop { background: rgba(10, 25, 17, .55); }
dialog[open] { animation: sheet-in .22s ease-out; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet { display: flex; flex-direction: column; max-height: 90dvh; background: #fff; border-radius: 22px 22px 0 0; overflow: hidden; }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 16px 12px 20px; }
.sheet-head-main { flex: 1; min-width: 0; }
.sheet-head h2 { margin-top: 8px; font-size: 1.375rem; line-height: 1.35; overflow-wrap: anywhere; }
.sheet-head p  { margin-top: 2px; color: var(--ink-2); }
.icon-btn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--bg); color: var(--ink); cursor: pointer; }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 20px 20px; display: grid; gap: 20px; align-content: start; overscroll-behavior: contain; }
.sheet-body h3 { margin-bottom: 8px; font-size: 1rem; font-weight: 700; }
.sheet-body #d-desc { white-space: pre-line; line-height: 1.7; }
.sheet-foot { padding: 12px 20px calc(12px + var(--safe-b)); background: #fff; border-top: 1px solid var(--line); }

.ptable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ptable th { padding: 10px 14px; background: var(--green-tint); color: var(--green-ink); font-size: .9375rem; font-weight: 600; text-align: left; }
.ptable th:last-child:not(:first-child), .ptable td:last-child:not(:first-child) { text-align: right; }
.ptable td { padding: 11px 14px; border-top: 1px solid var(--line); font-weight: 600; }

/* ── Larger screens ───────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .wrap { padding-inline: 24px; }
  .ev-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cta-strip { flex-direction: row; align-items: center; justify-content: space-between; }
  dialog { max-width: 500px; margin: auto; }
  .sheet { border-radius: 22px; max-height: 86dvh; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
}

@media (min-width: 900px) {
  body { padding-bottom: 24px; }
  .page-head { padding: 36px 0 22px; }
  .page-head h1 { font-size: 2.125rem; }

  .tabs {
    position: static; display: flex; gap: 2px; height: auto; padding: 4px; background: var(--bg);
    border: 0; border-radius: 999px;
  }
  .tab { flex-direction: row; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 999px; font-size: 1rem; }
  .tab .ico { width: 20px; height: 20px; }
  .tab[aria-current="page"] { background: var(--green); color: #fff; }
  .tab[aria-current="page"]::before { display: none; }

  .calc-grid {
    grid-template-columns: minmax(0, 1fr) 400px; gap: 20px 24px; align-items: start;
    grid-template-areas: "form summary" "docs summary";
  }
  .form { grid-area: form; }
  .docs { grid-area: docs; }
  .summary { grid-area: summary; position: sticky; top: 84px; }
  .step { padding: 24px; }
  .docs { padding: 24px; }
  .ev-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .minibar { display: none !important; }
}

@media (max-width: 359px) {
  .pay-num { font-size: 2.125rem; }
  .plan-body { padding: 12px 10px; }
  .plan-amt { font-size: .9375rem; }
  .seg span { font-size: .9375rem; }
  .rows dd { white-space: nowrap; }
  .brand-name { font-size: .9375rem; }
  .line-btn span { display: none; }
  .line-btn { padding: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
