/*
Theme Name: Milo Crackers
Description: Sivakasi crackers price list with a client-side estimate cart. Built for shared hosting: every public page is fully cacheable.
Version: 1.0.0
Author: MML Software Solution
Text Domain: milo
*/

:root {
  --red: #c8102e;
  --red-deep: #9a0b22;
  --marigold: #f2b01e;
  --marigold-wash: #fff3d6;
  --paper: #fffdf8;
  --paper-2: #f6efe0;
  --ink: #201a17;
  --ink-2: #5b524c;
  --ink-3: #8f857d;
  --line: #e7dfd0;
  --green: #1e7b4f;
  --white: #fff;
  --r-sm: 6px;
  --r: 10px;
  --shadow: 0 8px 28px rgba(60, 30, 10, 0.16);
  --bar-h: 64px;
  --font: "Anek Tamil", "Noto Sans Tamil", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--hdr-h, 60px) + var(--tools-h, 70px) + 8px); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom));
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--red); }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- header */
.hdr {
  position: sticky; top: 0; z-index: 30;
  background: var(--red);
  color: var(--white);
}
.hdr__in {
  max-width: 1120px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.hdr__brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: inherit; }
.hdr__logo { height: 40px; width: auto; border-radius: 4px; }
.hdr__name { font-weight: 800; font-size: 1.15rem; line-height: 1.1; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr__sub { font-size: 0.78rem; opacity: 0.85; line-height: 1.2; }
.hdr__call {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  background: var(--white); color: var(--red); text-decoration: none;
  font-weight: 700; font-size: 0.9rem; padding: 8px 12px; border-radius: 999px; white-space: nowrap;
}
.hdr__call svg { width: 18px; height: 18px; }
.hdr__call span { display: none; }
@media (min-width: 480px) { .hdr__call span { display: inline; } }

.announce {
  background: var(--marigold); color: var(--ink);
  font-weight: 600; font-size: 0.9rem; text-align: center; padding: 7px 16px;
}

/* ---------------------------------------------------------------- filters */
.tools {
  position: sticky; top: var(--hdr-h, 60px); z-index: 20;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.tools__in { max-width: 1120px; margin: 0 auto; padding: 8px 16px 0; }
.search { position: relative; }
.search input {
  width: 100%; padding: 10px 12px 10px 40px; border: 1.5px solid var(--line); border-radius: var(--r);
  background: var(--white); font-size: 1rem;
}
.search input:focus { border-color: var(--red); outline: none; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--ink-3); }
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1.5px solid var(--line); background: var(--white); border-radius: 999px;
  padding: 6px 12px; font-weight: 600; font-size: 0.9rem; color: var(--ink-2); white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--white); }

/* ---------------------------------------------------------------- layout */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
  body { padding-bottom: 40px; }
}

/* ---------------------------------------------------------------- ledger */
.cat { margin: 22px 0 6px; }
.cat__h {
  display: flex; align-items: baseline; gap: 10px; margin: 0 0 6px;
  font-size: 1.05rem; font-weight: 800;
}
.cat__n { font-size: 0.85rem; font-weight: 600; color: var(--ink-3); }
.ledger { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--white); overflow: hidden; }
.row {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 10px 12px 10px 10px; border-top: 1px solid var(--line); position: relative;
}
.row:first-child { border-top: 0; }
.row.is-picked { background: var(--marigold-wash); }
.row.is-picked::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--red); }
.row.is-hidden { display: none; }
.row__img { width: 52px; height: 52px; border-radius: var(--r-sm); object-fit: cover; background: var(--paper-2); }
.row__img--ph { display: grid; place-items: center; color: var(--ink-3); }
.row__img--ph svg { width: 26px; height: 26px; }
.row__body { min-width: 0; }
.row__name { font-weight: 700; line-height: 1.25; margin: 0; }
.row__meta { display: flex; gap: 8px; align-items: baseline; margin-top: 2px; font-size: 0.85rem; color: var(--ink-2); flex-wrap: wrap; }
.row__price { font-weight: 800; color: var(--ink); }
.row__mrp { text-decoration: line-through; color: var(--ink-3); }
.row__unit { color: var(--ink-3); }
.row__oos { color: var(--red); font-weight: 600; }

.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 999px; background: var(--white); height: 38px; }
.row.is-picked .qty { border-color: var(--red); }
.qty button {
  width: 38px; height: 100%; border: 0; background: none; font-size: 1.35rem; line-height: 1; font-weight: 600; color: var(--red);
  display: grid; place-items: center; border-radius: 999px;
}
.qty button:disabled { color: var(--ink-3); cursor: default; }
.qty input {
  width: 40px; height: 100%; border: 0; background: none; text-align: center; font-weight: 800; font-size: 1rem; -moz-appearance: textfield; padding: 0;
}
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.row__add { height: 38px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--red); background: var(--white); color: var(--red); font-weight: 700; }
.row.is-picked .row__add { display: none; }
.row:not(.is-picked) .qty { display: none; }
.row.is-oos .row__add, .row.is-oos .qty { display: none; }

.empty-search { padding: 40px 16px; text-align: center; color: var(--ink-2); display: none; }
.empty-search.is-on { display: block; }

/* ---------------------------------------------------------------- bottom bar */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--ink); color: var(--white);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
  transform: translateY(100%); transition: transform 0.25s ease;
}
.bar.is-on { transform: none; }
.bar__count { font-size: 0.8rem; opacity: 0.8; }
.bar__total { font-size: 1.3rem; font-weight: 800; line-height: 1.1; }
.bar__btn {
  margin-left: auto; background: var(--marigold); color: var(--ink); border: 0; border-radius: 999px;
  padding: 12px 20px; font-weight: 800; font-size: 1rem;
}
@media (min-width: 900px) { .bar { display: none; } }
@media (prefers-reduced-motion: reduce) { .bar { transition: none; } }

/* ---------------------------------------------------------------- cart panel / sheet */
.sheet {
  position: fixed; inset: 0; z-index: 50; display: none;
}
.sheet.is-open { display: block; }
.sheet__bg { position: absolute; inset: 0; background: rgba(32, 26, 23, 0.55); }
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh;
  background: var(--paper); border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.sheet__hd { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet__hd h2 { margin: 0; font-size: 1.15rem; font-weight: 800; flex: 1; }
.sheet__x { border: 0; background: var(--paper-2); width: 36px; height: 36px; border-radius: 999px; font-size: 1.2rem; }
.sheet__scroll { overflow-y: auto; padding: 0 16px 16px; -webkit-overflow-scrolling: touch; }

@media (min-width: 900px) {
  .sheet { position: sticky; top: calc(var(--hdr-h, 60px) + var(--tools-h, 70px) + 12px); display: block; inset: auto; }
  .sheet__bg { display: none; }
  .sheet__panel { position: static; max-height: calc(100vh - var(--hdr-h, 60px) - var(--tools-h, 70px) - 32px); border-radius: var(--r); border: 1px solid var(--line); box-shadow: none; }
  .sheet__x { display: none; }
}

.cart-list { list-style: none; margin: 0; padding: 0; }
.cart-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-item__name { font-weight: 700; margin: 0; line-height: 1.25; }
.cart-item__calc { font-size: 0.85rem; color: var(--ink-2); }
.cart-item__line { font-weight: 800; text-align: right; }
.cart-item .qty { height: 34px; }
.cart-item .qty button { width: 34px; }
.cart-item__rm { border: 0; background: none; color: var(--ink-3); font-size: 0.8rem; padding: 2px 0; text-decoration: underline; }
.cart-empty { padding: 28px 0; text-align: center; color: var(--ink-2); }

.tot { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0 6px; }
.tot__l { color: var(--ink-2); font-weight: 600; }
.tot__v { font-size: 1.45rem; font-weight: 800; }
.tot__note { font-size: 0.8rem; color: var(--ink-3); margin: 0 0 10px; }

.form { display: grid; gap: 10px; margin-top: 6px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: 0.9rem; }
.form input, .form textarea {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--white); font-size: 1rem;
}
.form input:focus, .form textarea:focus { border-color: var(--red); outline: none; }
.form textarea { resize: vertical; min-height: 64px; }
.form .hp { position: absolute; left: -9999px; }
.form__err { color: var(--red); font-weight: 600; font-size: 0.9rem; min-height: 1.2em; margin: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 14px 20px; font-weight: 800; font-size: 1.05rem; text-decoration: none;
  background: var(--red); color: var(--white); width: 100%;
}
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn--wa { background: #1fa855; }
.btn--ghost { background: var(--paper-2); color: var(--ink); }
.btn svg { width: 20px; height: 20px; }

.done { text-align: center; padding: 20px 0 8px; }
.done__ico { width: 64px; height: 64px; border-radius: 999px; background: var(--green); color: var(--white); display: grid; place-items: center; margin: 0 auto 12px; }
.done__ico svg { width: 32px; height: 32px; }
.done h3 { margin: 0 0 4px; font-size: 1.3rem; }
.done p { margin: 0 0 6px; color: var(--ink-2); }
.done .btn { margin-top: 10px; }

.closed { background: var(--paper-2); border-radius: var(--r-sm); padding: 14px; color: var(--ink-2); font-weight: 600; text-align: center; }

/* ---------------------------------------------------------------- footer */
.ftr { margin: 40px 0 0; padding: 24px 0 30px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 0.9rem; }
.ftr__in { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: grid; gap: 6px; }
.ftr strong { color: var(--ink); }
.ftr__legal { font-size: 0.8rem; color: var(--ink-3); margin-top: 8px; }
