/* หลังร้าน (demo admin) for พายช้า: the café's own linen, roast and canal palette,
   printed-menu cards, Taviraj for headings and Anuphan for everything you tap or type. Mobile first. */

:root {
  --linen: #F3EEE6;
  --paper: #FAF7F1;
  --sand: #EAE2D6;
  --roast: #2C1E16;
  --roast-2: #46332A;
  --roast-deep: #1F1510;
  --muted: #6A5546;
  --clay: #A47E5B;
  --clay-ink: #7E5D40;
  --clay-light: #D2B597;
  --sage: #7D8B74;
  --sage-ink: #55624E;
  --canal: #46523F;
  --on-canal-muted: #CDCCC1;
  --error: #9A3B26;

  --serif: "Taviraj", "Noto Serif Thai", Georgia, serif;
  --sans: "Anuphan", "Noto Sans Thai", "Thonburi", system-ui, sans-serif;

  --fs-xs: 0.8125rem;
  --fs-sm: 0.9063rem;
  --fs-base: 1.0625rem;
  --fs-lg: 1.1875rem;
  --fs-xl: clamp(1.375rem, 1.25rem + 0.6vw, 1.625rem);
  --fs-2xl: clamp(2rem, 1.6rem + 2vw, 2.75rem);

  --gutter: max(1rem, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --col: 40rem;
  --radius: 0.5rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --bar-h: 4.5rem;
  --line: rgb(44 30 22 / 0.14);
  --field-border: rgb(44 30 22 / 0.26);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgb(125 139 116 / 0.18);
  background: var(--linen);
  scroll-padding-top: 4.5rem;
  scroll-padding-bottom: calc(var(--bar-h) + 1.5rem);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--linen);
  color: var(--roast);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.7;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px) + 2rem);
  -webkit-font-smoothing: antialiased;
}
/* the café's paper grain */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .17 0 0 0 0 .12 0 0 0 0 .09 0 0 0 1.1 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

a, button, label, summary, input, textarea { touch-action: manipulation; }
a { color: inherit; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 400; line-height: 1.35; text-wrap: balance; }
p { text-wrap: pretty; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

::selection { background: rgb(125 139 116 / 0.35); color: var(--roast); }
:focus-visible { outline: 2px solid var(--roast); outline-offset: 3px; border-radius: 4px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.15em; height: 1.15em; flex: none; }

.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: fixed;
  left: 1rem; top: 0.75rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--roast);
  color: var(--linen);
  border-radius: 6px;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.4s var(--ease);
}
.skip:focus { transform: none; }

/* ---------- Top bar ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgb(243 238 230 / 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 var(--line);
}
.top__in {
  width: min(100% - 2 * var(--gutter), var(--col));
  margin-inline: auto;
  min-height: 3.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1;
}
.logo span { padding-top: 0.15em; }
.top__tag {
  padding: 0.15rem 0.65rem;
  border: 1px solid rgb(164 126 91 / 0.5);
  border-radius: 999px;
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--clay-ink);
}
.top__view {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2.75rem;
  font-size: var(--fs-sm);
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 calc(100% - 0.55rem) / 100% 1px no-repeat;
}

/* ---------- Page ---------- */
.page {
  width: min(100% - 2 * var(--gutter), var(--col));
  margin-inline: auto;
  padding-top: 1.25rem;
}

/* demo banner: the café's canal band */
.trial {
  position: relative;
  padding: 1.1rem 1.25rem 1.15rem;
  border-radius: var(--radius);
  background: var(--canal);
  color: var(--linen);
  font-size: var(--fs-sm);
  line-height: 1.7;
}
.trial__title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.35rem;
  font-size: var(--fs-lg);
  font-weight: 400;
}
.trial__dot {
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  background: var(--clay-light);
  box-shadow: 0 0 0 0.25rem rgb(210 181 151 / 0.22);
}
.trial p { color: rgb(243 238 230 / 0.88); }
.trial__meta {
  margin-top: 0.85rem !important;
  padding-top: 0.75rem;
  border-top: 1px solid rgb(243 238 230 / 0.2);
  font-size: var(--fs-xs);
  color: var(--on-canal-muted) !important;
}
@media (prefers-reduced-motion: no-preference) {
  .trial__dot { animation: breathe 2.8s var(--ease) infinite; }
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0.2rem rgb(210 181 151 / 0.25); }
  50% { box-shadow: 0 0 0 0.45rem rgb(210 181 151 / 0.05); }
}

.hello { padding: 2.25rem 0 0.5rem; }
.hello__title {
  font-size: var(--fs-2xl);
  font-weight: 300;
  line-height: 1.3;
  letter-spacing: -0.005em;
}
.hello__lede { margin-top: 0.9rem; max-width: 30em; color: var(--muted); }

.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.4rem;
}
.jump a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.3rem 1rem;
  border: 1px solid rgb(44 30 22 / 0.2);
  border-radius: 999px;
  font-size: var(--fs-sm);
  text-decoration: none;
  transition: background-color 0.5s var(--ease), border-color 0.5s var(--ease);
}
.jump a:hover { border-color: var(--roast); background: rgb(44 30 22 / 0.04); }

.notice {
  margin-top: 1.5rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid rgb(154 59 38 / 0.35);
  background: rgb(154 59 38 / 0.06);
  color: var(--error);
  font-size: var(--fs-sm);
}

.loading {
  display: grid;
  justify-items: center;
  gap: 0.9rem;
  padding: 4rem 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.loading__wave {
  width: 4rem; height: 0.6rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 8'%3E%3Cpath d='M1 4c3.8 0 3.8-2.6 7.6-2.6S12.4 4 16.2 4 20 1.4 23.8 1.4 27.6 4 31.4 4s3.8-2.6 7.6-2.6S42.8 4 47 4' fill='none' stroke='%237D8B74' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
@media (prefers-reduced-motion: no-preference) {
  .loading__wave { animation: drift 1.6s ease-in-out infinite alternate; }
}
@keyframes drift { from { transform: translateX(-0.6rem); opacity: 0.5; } to { transform: translateX(0.6rem); opacity: 1; } }

/* ---------- Sections ---------- */
.sect { margin-top: 3.25rem; }
.sect__head {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.85rem;
  align-items: baseline;
  margin-bottom: 1.25rem;
}
.sect__num {
  font-family: var(--serif);
  font-weight: 300;
  font-size: var(--fs-xl);
  color: var(--clay-ink);
  font-variant-numeric: lining-nums;
}
.sect__title { font-size: var(--fs-xl); font-weight: 400; }
.sect__hint { grid-column: 2; margin-top: 0.25rem; font-size: var(--fs-sm); color: var(--muted); }
.sect__body { display: grid; gap: 1rem; }

/* ---------- Printed cards ---------- */
.card {
  background: var(--paper);
  border: 1px solid rgb(164 126 91 / 0.28);
  border-radius: 3px;
  padding: 0.35rem;
  box-shadow:
    0 0.7px 0.7px -0.67px rgb(44 30 22 / 0.03),
    0 1.8px 1.8px -1.3px rgb(44 30 22 / 0.04),
    0 3.6px 3.6px -2px rgb(44 30 22 / 0.04),
    0 6.9px 6.9px -2.7px rgb(44 30 22 / 0.05),
    0 13px 13px -3.3px rgb(44 30 22 / 0.05);
}
.card__in {
  border: 1px solid rgb(164 126 91 / 0.42);
  border-radius: 2px;
  padding: 1.15rem 1rem 1.25rem;
}
.card__title { font-size: var(--fs-lg); font-weight: 400; line-height: 1.4; }
.card__hint { margin-top: 0.2rem; font-size: var(--fs-sm); line-height: 1.65; color: var(--muted); }
.card__body { display: grid; gap: 1.1rem; margin-top: 1rem; }

/* photo + name + price side by side (recommended dishes) */
.card--split .card__body {
  grid-template-columns: minmax(7rem, 38%) minmax(0, 1fr);
  align-items: start;
  column-gap: 1rem;
}
.card--split .card__fields { display: grid; gap: 0.9rem; }
@media (max-width: 359px) {
  .card--split .card__body { grid-template-columns: 1fr; }
}

/* the menu card: a centred title with the café's wave, rows like the printed list */
.card--menu .card__in { padding-top: 1.4rem; }
.card--menu .card__title {
  text-align: center;
  font-size: var(--fs-xl);
  padding-bottom: 1.1rem;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 8'%3E%3Cpath d='M1 4c3.8 0 3.8-2.6 7.6-2.6S12.4 4 16.2 4 20 1.4 23.8 1.4 27.6 4 31.4 4s3.8-2.6 7.6-2.6S42.8 4 47 4' fill='none' stroke='%23A47E5B' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E")
    center bottom / 2.5rem 0.45rem no-repeat;
}
.mhead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6.75rem;
  gap: 0.6rem;
  margin-top: 1.1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-xs);
  color: var(--muted);
}
.mhead span:last-child { text-align: right; padding-right: 0.25rem; }
.mrows { display: grid; }
.mrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6.75rem;
  gap: 0.25rem 0.6rem;
  padding: 0.7rem 0;
  border-bottom: 1px dotted rgb(164 126 91 / 0.55);
}
.mrow:last-child { border-bottom: 0; padding-bottom: 0; }
.mrow .field__err, .mrow .was { grid-column: 1 / -1; }
.mrow .was { text-align: right; }

/* ---------- Fields ---------- */
.field { display: grid; gap: 0.35rem; min-width: 0; }
.field__label { font-size: var(--fs-sm); font-weight: 500; color: var(--roast-2); }
.field__foot { display: flex; justify-content: space-between; gap: 1rem; min-height: 0; }
.field__err { color: var(--error); font-size: var(--fs-xs); line-height: 1.5; }
.field__err:empty { display: none; }
.field__count { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.field__count:empty { display: none; }

.input {
  width: 100%;
  min-height: 3rem;
  margin: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--field-border);
  border-radius: 6px;
  background: #FFFDF9;
  color: var(--roast);
  font: inherit;
  font-size: 1.0625rem;          /* >= 16 px: no iOS zoom on focus */
  line-height: 1.55;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.4s var(--ease), box-shadow 0.4s var(--ease), background-color 0.4s var(--ease);
}
.input:hover { border-color: rgb(44 30 22 / 0.42); }
.input:focus { outline: none; border-color: var(--sage-ink); box-shadow: 0 0 0 3px rgb(125 139 116 / 0.28); background: #fff; }
textarea.input { resize: none; overflow: hidden; display: block; }

/* edited but not saved yet: a clay ribbon on the left edge */
.is-dirty .input { box-shadow: inset 3px 0 0 var(--clay); }
.is-dirty .input:focus { box-shadow: inset 3px 0 0 var(--clay), 0 0 0 3px rgb(125 139 116 / 0.28); }
.is-invalid .input { border-color: var(--error); }

.price { position: relative; }
.price .input {
  padding-right: 2.6rem;
  text-align: right;
  font-variant-numeric: lining-nums tabular-nums;
}
.price__unit {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--fs-xs);
  color: var(--muted);
  pointer-events: none;
}
.was { font-size: var(--fs-xs); color: var(--muted); line-height: 1.5; }
.was s { text-decoration-color: var(--clay); }
.was:empty { display: none; }

/* ---------- Photo fields ---------- */
.photo { display: grid; gap: 0.6rem; min-width: 0; }
.photo__frame {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  background: var(--sand);
  cursor: pointer;
}
.photo--wide .photo__frame { aspect-ratio: 4 / 3; }
.photo__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.82) contrast(0.96) sepia(0.06);
  transition: opacity 0.5s var(--ease), transform 1.2s var(--ease);
}
.photo__frame:hover .photo__img { transform: scale(1.02); }
.photo__btn {
  position: absolute;
  left: 0.6rem;
  bottom: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.3rem 0.85rem 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgb(250 247 241 / 0.94);
  color: var(--roast);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.2;
  box-shadow: 0 2px 10px rgb(31 21 16 / 0.18);
}
.photo__input:focus-visible + .photo__frame { outline: 2px solid var(--roast); outline-offset: 3px; }
.photo__veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(31 21 16 / 0.45);
  color: var(--linen);
  font-family: var(--serif);
  font-size: var(--fs-xl);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
  pointer-events: none;
}
.photo__bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgb(243 238 230 / 0.35);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}
.photo__bar span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--sage);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.3s linear;
}
.is-busy .photo__veil, .is-busy .photo__bar { opacity: 1; }
.is-busy .photo__btn { opacity: 0; }
.is-busy .photo__frame { cursor: progress; }
.photo__msg { font-size: var(--fs-xs); line-height: 1.55; color: var(--sage-ink); }
.photo__msg:empty { display: none; }
.photo__msg.is-error { color: var(--error); }
.is-dirty .photo__frame { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--clay); }

.linkbtn {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.75rem;
  margin: -0.5rem 0;
  padding: 0;
  border: 0;
  background: none;
  font-size: var(--fs-xs);
  color: var(--clay-ink);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.55rem 1.4rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: var(--fs-sm);
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.5s var(--ease), color 0.5s var(--ease), border-color 0.5s var(--ease), opacity 0.4s var(--ease);
}
.btn:disabled { cursor: not-allowed; opacity: 0.45; }
.btn--line { border-color: rgb(44 30 22 / 0.5); background: transparent; }
.btn--line:hover:not(:disabled) { border-color: var(--roast); background: rgb(44 30 22 / 0.04); }
.btn--clay { background: var(--clay-ink); color: var(--paper); }
.btn--clay:hover:not(:disabled) { background: #6B4E35; }
.btn--quiet { background: transparent; padding-inline: 1rem; text-decoration: underline; text-underline-offset: 0.25em; text-decoration-thickness: 1px; }
.btn--paper { background: var(--linen); color: var(--roast); }
.btn--paper:hover:not(:disabled) { background: #fff; }

/* ---------- Reset ---------- */
.reset {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.reset__title { font-size: var(--fs-lg); }
.reset__text { margin: 0.3rem 0 1rem; font-size: var(--fs-sm); color: var(--muted); }
.confirm {
  margin-top: 1rem;
  padding: 1.1rem 1.15rem 1rem;
  border: 1px solid rgb(164 126 91 / 0.5);
  border-radius: var(--radius);
  background: rgb(164 126 91 / 0.1);
}
.confirm__q { font-family: var(--serif); font-size: var(--fs-lg); line-height: 1.45; }
.confirm__q:focus { outline: none; }
.confirm__text { margin-top: 0.3rem; font-size: var(--fs-sm); color: var(--roast-2); }
.confirm__btns { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1rem; }
@media (prefers-reduced-motion: no-preference) {
  .confirm:not([hidden]) { animation: rise 0.6s var(--ease) both; }
}
@keyframes rise { from { opacity: 0; transform: translateY(-0.4rem); } to { opacity: 1; transform: none; } }

/* ---------- Save bar (the café's dock) ---------- */
.savebar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  background: var(--roast);
  color: var(--linen);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -1px 0 rgb(243 238 230 / 0.06), 0 -8px 24px rgb(31 21 16 / 0.12);
}
.savebar__in {
  width: min(100% - 2 * var(--gutter), var(--col));
  margin-inline: auto;
  min-height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.savebar__state {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: rgb(243 238 230 / 0.8);
}
.savebar__state.is-dirty { color: var(--clay-light); }
.savebar__btn { min-width: 8.5rem; font-size: var(--fs-base); }
.savebar :focus-visible { outline-color: var(--clay-light); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px) + 0.85rem);
  z-index: 70;
  max-width: calc(100% - 2 * var(--gutter));
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  background: var(--roast-deep);
  color: var(--linen);
  font-size: var(--fs-sm);
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 10px 30px rgb(31 21 16 / 0.25);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 0.75rem);
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease), visibility 0s linear 0.45s;
}
.toast.is-on {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease), visibility 0s;
}
.toast.is-error { background: var(--error); }
.toast a {
  display: inline-block;
  padding-block: 0.35rem;
  color: var(--clay-light);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}
.toast :focus-visible { outline-color: var(--clay-light); }

.foot {
  margin-top: 3rem;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.foot a { display: inline-block; padding-block: 0.6rem; color: var(--clay-ink); text-underline-offset: 0.25em; }

/* ---------- Wider screens ---------- */
@media (min-width: 640px) {
  .card__in { padding: 1.5rem 1.6rem 1.6rem; }
  .card--menu .card__in { padding-top: 1.8rem; }
  .mhead, .mrow { grid-template-columns: minmax(0, 1fr) 7.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
