/* ============================================================
   PANTRY DEPOT — thermal-receipt shopping list
   Aesthetic: warm cream paper on an espresso counter, ink mono
   type, dashed rules, rubber-stamp print action, CSS barcode.
   ============================================================ */

:root {
  --paper:      #f4efe2;
  --paper-edge: #e9e2d0;
  --ink:        #20191322;   /* used for shadows */
  --ink-solid:  #221b14;
  --ink-fade:   #7c7263;
  --ink-faint:  #b8ad97;
  --stamp:      #b5342a;
  --stamp-deep: #8f261e;
  --counter-1:  #211c18;
  --counter-2:  #15110e;
  --ok:         #3f7d52;
  --line:       #c9bfa8;
  --radius:     3px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  font-family: "Space Mono", ui-monospace, monospace;
  color: var(--ink-solid);
  background:
    radial-gradient(120% 80% at 50% -10%, #2c251f 0%, var(--counter-1) 40%, var(--counter-2) 100%);
  background-attachment: fixed;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(12px, 4vw, 56px) 12px 80px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* film-grain overlay over everything --------------------------------------- */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.05;
  mix-blend-mode: multiply;
  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='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ===========================  THE RECEIPT  ============================== */
.receipt {
  position: relative;
  width: min(440px, 100%);
  background: var(--paper);
  background-image:
    repeating-linear-gradient(0deg,
      transparent 0 26px, #00000005 26px 27px);    /* faint thermal banding */
  padding: 30px clamp(18px, 6vw, 34px) 26px;
  color: var(--ink-solid);
  box-shadow:
    0 1px 0 #fff8 inset,
    0 30px 60px -20px #000a,
    0 10px 26px -12px #0009;
  /* torn top + perforated bottom via mask */
  -webkit-mask:
    radial-gradient(7px at 7px 8px, #0000 98%, #000) -7px 0/14px 14px repeat-x,
    radial-gradient(7px at 7px calc(100% - 8px), #0000 98%, #000) -7px 100%/14px 14px repeat-x,
    linear-gradient(#000 0 0) 0 14px/100% calc(100% - 28px) no-repeat;
          mask:
    radial-gradient(7px at 7px 8px, #0000 98%, #000) -7px 0/14px 14px repeat-x,
    radial-gradient(7px at 7px calc(100% - 8px), #0000 98%, #000) -7px 100%/14px 14px repeat-x,
    linear-gradient(#000 0 0) 0 14px/100% calc(100% - 28px) no-repeat;
  animation: drop-in 0.7s cubic-bezier(.16,1,.3,1) both;
}

@keyframes drop-in {
  from { transform: translateY(-22px) rotate(-.4deg); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* a strip of "tape" holding the receipt to the counter */
.tape {
  position: absolute;
  top: -12px; left: 50%;
  width: 120px; height: 30px;
  transform: translateX(-50%) rotate(-1.5deg);
  background: linear-gradient(180deg, #d9cdaecc, #cdbf9acc);
  box-shadow: 0 2px 6px #0004;
  z-index: 2;
  opacity: .55;
}
.tape::before, .tape::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 6px;
  background: repeating-linear-gradient(90deg,#0000 0 2px,#0002 2px 4px);
}
.tape::before { left: 0; } .tape::after { right: 0; }

/* ---- masthead ---- */
.masthead { text-align: center; }

.status-row {
  display: flex; justify-content: center; gap: 14px;
  font-size: 9px; letter-spacing: .12em; color: var(--ink-faint);
  margin-bottom: 14px; text-transform: uppercase;
}
.dot { display: inline-flex; align-items: center; gap: 5px; }
.dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-faint);
  box-shadow: 0 0 0 0 #0000; transition: .3s;
}
.dot[data-on="true"]::before {
  background: var(--ok);
  box-shadow: 0 0 8px 1px #3f7d5288;
  animation: pulse 2s infinite;
}
.dot#dotLive { font-size: 0; }            /* show only the bulb for live */
.dot#dotLive::before { width: 8px; height: 8px; }
@keyframes pulse { 50% { opacity: .55; } }

.brand {
  font-family: "Big Shoulders Stencil Display", "Space Mono", sans-serif;
  font-weight: 900;
  font-size: clamp(34px, 11vw, 52px);
  line-height: .92;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.subtitle {
  font-size: 11px; letter-spacing: .42em; text-transform: uppercase;
  color: var(--ink-fade); margin-top: 4px; padding-left: .42em;
}
.meta {
  margin-top: 10px; font-size: 11px; color: var(--ink-fade);
  letter-spacing: .05em;
}

.rule {
  font-size: 13px; color: var(--ink-faint); text-align: center;
  overflow: hidden; white-space: nowrap; letter-spacing: .08em;
  margin: 14px 0; user-select: none;
}
.rule.dashed { color: var(--ink-fade); }

/* ---- composer (add item) ---- */
.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: stretch;
}
.qty-field {
  display: grid; grid-template-columns: 26px 34px 26px;
  align-items: stretch;
  border: 1.5px solid var(--ink-solid);
  border-radius: var(--radius);
}
.qstep {
  font-family: inherit; font-size: 18px; line-height: 1;
  background: none; border: none; color: var(--ink-solid);
  cursor: pointer; touch-action: manipulation;
}
.qstep:active { background: var(--ink-solid); color: var(--paper); }
.qty-input {
  width: 100%; text-align: center; border: none; background: none;
  font-family: inherit; font-size: 15px; color: var(--ink-solid);
  border-left: 1.5px solid var(--line); border-right: 1.5px solid var(--line);
  -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.name-input {
  font-family: inherit; font-size: 16px;       /* >=16px stops iOS zoom */
  background: none; border: none;
  border-bottom: 1.5px dashed var(--line);
  color: var(--ink-solid); padding: 6px 4px;
}
.name-input::placeholder { color: var(--ink-faint); font-style: italic; }
.name-input:focus { outline: none; border-bottom-color: var(--stamp); }

.add-btn {
  font-family: inherit; font-weight: 700; font-size: 13px;
  letter-spacing: .12em;
  background: var(--ink-solid); color: var(--paper);
  border: none; border-radius: var(--radius);
  padding: 0 16px; cursor: pointer; touch-action: manipulation;
  transition: transform .08s, background .2s;
}
.add-btn:active { transform: scale(.94); }
.add-btn:hover { background: var(--stamp); }

/* ---- list ---- */
.items { list-style: none; }

.item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dotted var(--line);
  animation: print-line .35s ease both;
}
@keyframes print-line {
  from { opacity: 0; clip-path: inset(0 0 100% 0); transform: translateY(-3px); }
  to   { opacity: 1; clip-path: inset(0 0 0 0);   transform: none; }
}
.item.removing {
  animation: tear-off .3s ease forwards;
}
@keyframes tear-off {
  to { opacity: 0; transform: translateX(36px) rotate(2deg); height: 0;
       padding: 0; margin: 0; }
}

.item-qty {
  font-weight: 700; font-size: 14px; min-width: 2.4ch; text-align: right;
  color: var(--ink-solid); font-variant-numeric: tabular-nums;
}
.item-body { display: flex; flex-direction: column; min-width: 0; }
.item-name {
  font-size: 16px; cursor: pointer; word-break: break-word;
  line-height: 1.25;
}
.item-cat {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint); margin-top: 2px;
}
.item.checked .item-name { color: var(--ink-faint); text-decoration: line-through; }
.item.checked .item-qty { color: var(--ink-faint); }

.item-tick {
  width: 20px; height: 20px; border: 1.5px solid var(--ink-solid);
  border-radius: 50%; background: none; cursor: pointer; position: relative;
  flex-shrink: 0; touch-action: manipulation; transition: .15s;
}
.item.checked .item-tick { background: var(--stamp); border-color: var(--stamp); }
.item.checked .item-tick::after {
  content: "✓"; position: absolute; inset: 0; color: #fff;
  font-size: 12px; display: grid; place-items: center; line-height: 1;
}

.item-del {
  background: none; border: none; color: var(--ink-faint);
  font-size: 17px; cursor: pointer; line-height: 1; padding: 2px 4px;
  touch-action: manipulation; transition: color .15s, transform .1s;
}
.item-del:hover { color: var(--stamp); }
.item-del:active { transform: scale(.8); }

.empty-note {
  text-align: center; color: var(--ink-faint); font-style: italic;
  font-size: 13px; padding: 22px 0;
}

/* ---- totals ---- */
.totals {
  display: flex; justify-content: space-between;
  font-size: 13px; letter-spacing: .1em; font-weight: 700;
}
.totals b { font-size: 16px; }

/* ---- the rubber stamp print button ---- */
.stamp {
  display: block; width: 100%;
  margin: 22px auto 6px;
  background: none; border: none; cursor: pointer;
  padding: 6px; touch-action: manipulation;
}
.stamp-inner {
  display: block;
  font-family: "Big Shoulders Stencil Display", monospace;
  font-weight: 900; font-size: clamp(22px, 7vw, 30px);
  letter-spacing: .05em;
  color: var(--stamp);
  border: 3px solid var(--stamp);
  border-radius: 6px;
  padding: 12px 10px;
  text-align: center;
  transform: rotate(-2deg);
  position: relative;
  box-shadow: inset 0 0 0 2px #b5342a22;
  transition: transform .12s ease, color .15s, background .15s;
  /* roughen the stamp edge with a noisy mask */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='80'%3E%3Cfilter id='r'%3E%3CfeTurbulence baseFrequency='0.04' numOctaves='2' result='t'/%3E%3CfeColorMatrix in='t' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 -8'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' fill='%23fff'/%3E%3Crect width='100%25' height='100%25' filter='url(%23r)' opacity='0.12'/%3E%3C/svg%3E");
}
.stamp:hover .stamp-inner { transform: rotate(-2deg) scale(1.02); }
.stamp:active .stamp-inner {
  transform: rotate(-2deg) scale(.97);
  background: var(--stamp); color: var(--paper);
}
.stamp:disabled { cursor: not-allowed; }
.stamp:disabled .stamp-inner { color: var(--ink-faint); border-color: var(--ink-faint); }

.stamp-hint {
  text-align: center; font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 4px;
}

/* ---- barcode ---- */
.barcode {
  height: 52px; margin: 4px auto 6px; width: 82%;
  background-image: repeating-linear-gradient(90deg,
    var(--ink-solid) 0 2px, transparent 2px 4px,
    var(--ink-solid) 4px 5px, transparent 5px 9px,
    var(--ink-solid) 9px 12px, transparent 12px 14px,
    var(--ink-solid) 14px 15px, transparent 15px 18px);
}
.barcode-id {
  text-align: center; font-size: 12px; letter-spacing: .42em;
  color: var(--ink-fade); padding-left: .42em;
}

.archive-toggle {
  display: block; margin: 14px auto 0;
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 12px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-fade);
  border-bottom: 1px dashed var(--line); padding-bottom: 2px;
}
.archive-toggle:hover { color: var(--stamp); }

.footer-actions {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin-top: 14px;
}
.footer-actions .archive-toggle { margin: 0; }
.signout { color: var(--ink-faint); }
.signout:hover { color: var(--stamp); }

.perf { height: 6px; }

/* ---- login ---- */
.login-receipt { padding-top: 36px; }
.login-form { display: flex; flex-direction: column; gap: 16px; margin: 8px 0 18px; }
.field { display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 10px; }
.field span {
  font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--ink-fade);
}
.field input {
  font-family: inherit; font-size: 16px; color: var(--ink-solid);
  background: none; border: none; border-bottom: 1.5px dashed var(--line);
  padding: 8px 4px;
}
.field input:focus { outline: none; border-bottom-color: var(--stamp); }
.login-error {
  min-height: 16px; text-align: center; color: var(--stamp);
  font-size: 12px; letter-spacing: .04em;
}
.login-form.shake { animation: shake .4s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* ===========================  DRAWER  ================================= */
.drawer {
  position: fixed; inset: 0; z-index: 60;
  background: #000a; backdrop-filter: blur(3px);
  display: flex; justify-content: flex-end;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.drawer.open { opacity: 1; pointer-events: auto; }
.drawer-sheet {
  width: min(380px, 90vw); height: 100%;
  background: var(--paper);
  padding: 26px 22px; overflow-y: auto;
  transform: translateX(100%); transition: transform .3s cubic-bezier(.16,1,.3,1);
  box-shadow: -20px 0 50px #000a;
}
.drawer.open .drawer-sheet { transform: none; }
.drawer-close {
  position: absolute; top: 18px; right: 18px;
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--ink-fade);
}
.drawer-sheet h2 {
  font-family: "Big Shoulders Stencil Display", monospace;
  font-weight: 900; font-size: 26px; letter-spacing: .02em;
}
.drawer-sub { font-size: 11px; color: var(--ink-fade); letter-spacing: .1em;
  text-transform: uppercase; margin-bottom: 18px; }

.archive-list { list-style: none; }
.archive-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 12px 0; border-bottom: 1px dotted var(--line);
}
.archive-item a {
  color: var(--ink-solid); text-decoration: none; font-size: 14px;
  word-break: break-all;
}
.archive-item a:hover { color: var(--stamp); }
.archive-date { font-size: 11px; color: var(--ink-fade); }
.archive-size { font-size: 10px; color: var(--ink-faint); white-space: nowrap; }
.archive-empty { color: var(--ink-faint); font-style: italic; font-size: 13px;
  padding: 20px 0; text-align: center; }

/* ===========================  PRINT FEED  ============================= */
.feed {
  position: fixed; inset: 0; z-index: 70;
  display: none; place-items: start center;
  background: #0e0b09e6; padding-top: 8vh;
}
.feed.show { display: grid; }
.feed-paper {
  width: min(320px, 86vw);
  background: var(--paper); padding: 18px 22px 26px;
  box-shadow: 0 24px 60px #000c;
  animation: feed-out 1.6s ease;
}
@keyframes feed-out {
  from { transform: translateY(-100%); } to { transform: translateY(0); }
}
.feed-head {
  font-family: "Big Shoulders Stencil Display", monospace; font-weight: 900;
  font-size: 22px; text-align: center; color: var(--stamp);
  letter-spacing: .1em; margin-bottom: 12px;
}
.feed-lines { font-size: 13px; }
.feed-lines div {
  white-space: nowrap; overflow: hidden;
  border-right: 2px solid var(--ink-solid);
  width: 0; animation: type .35s steps(24) forwards;
}
@keyframes type { to { width: 100%; border-color: transparent; } }

/* ===========================  TOAST  ================================= */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 30px);
  background: var(--ink-solid); color: var(--paper);
  font-size: 13px; letter-spacing: .04em;
  padding: 12px 20px; border-radius: 4px; z-index: 80;
  opacity: 0; pointer-events: none; transition: .3s;
  max-width: 90vw; text-align: center;
  box-shadow: 0 12px 30px #0008;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--stamp-deep); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; }
}

/* tablet / desktop comfort */
@media (min-width: 760px) {
  .receipt { width: 480px; }
  .name-input { font-size: 17px; }
}
