/* The companion shopping app (SW-REQ-317): the values of the app's theme
   (lib/core/theme/app_theme.dart): warm ground, flat white cards of radius
   22, green #2E7D5B, Plus Jakarta Sans, spacing 4/8/12/16/24/32, 48 px tap
   targets, the type scale 20/16/14/13/12. */

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/PlusJakartaSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/PlusJakartaSans-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/PlusJakartaSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --ground: #F6F3EE;
  --card: #FFFFFF;
  --ink: #1D2320;
  --muted: #5D6661;
  --outline: #DCD6CC;
  --field: #EEEAE3;
  --primary: #2E7D5B;
  --on-primary: #FFFFFF;
  --done: #8C948F;
  --error: #B4441B;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r-md: 12px;
  --r-card: 22px;
  --r-pill: 999px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #141715;
    --card: #1F2422;
    --ink: #E3E7E4;
    --muted: #A3ABA6;
    --outline: #39413D;
    --field: #2A302D;
    --primary: #7FD3A0;
    --on-primary: #0E2A1C;
    --done: #78807B;
    --error: #FF9C78;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

h1 { font-size: 20px; font-weight: 700; margin: 0; }

.muted { color: var(--muted); }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

button { font: inherit; color: inherit; cursor: pointer; }

button:focus-visible, input:focus-visible, .line:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round; }

input {
  font: inherit;
  color: var(--ink);
  min-height: 48px;
  width: 100%;
  padding: 0 var(--s4);
  border-radius: var(--r-md);
  border: 1px solid var(--outline);
  background: var(--field);
}

.primary {
  min-height: 48px;
  padding: 0 var(--s5);
  border: 0;
  border-radius: var(--r-md);
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  font-size: 14px;
}
.primary:disabled { opacity: .6; cursor: default; }

.text {
  min-height: 48px;
  padding: 0 var(--s2);
  border: 0;
  background: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

.icon {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-pill);
  background: none;
}
.icon:hover { background: var(--field); }

.error { color: var(--error); font-size: 14px; margin: 0; }

/* Signing in */
.login {
  max-width: 420px;
  margin: 0 auto;
  padding: var(--s6) var(--s4);
  display: flex; flex-direction: column; gap: var(--s3);
}
.login-icon { border-radius: var(--r-card); }
.login h1 { font-size: 28px; }
.login form { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s3); }
.login label { font-size: 13px; font-weight: 600; margin-top: var(--s2); }
.login .primary { margin-top: var(--s4); }

/* The list */
.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.top {
  position: sticky; top: 0; z-index: 2;
  background: var(--ground);
  padding: calc(var(--s3) + env(safe-area-inset-top)) var(--s4) var(--s3);
}
.top-row { display: flex; align-items: center; justify-content: space-between; }

.week {
  display: flex; align-items: center; gap: var(--s2);
  margin-top: var(--s2);
  background: var(--card);
  border-radius: var(--r-card);
  padding: var(--s1);
}
.week-text { flex: 1; display: flex; flex-direction: column; align-items: center; }
.week-text strong { font-size: 16px; font-weight: 600; }
.week-text span { font-size: 13px; }

.progress { margin-top: var(--s3); font-size: 13px; color: var(--muted); }
.bar { height: 6px; border-radius: var(--r-pill); background: var(--field); margin-top: var(--s1); overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--primary); border-radius: var(--r-pill);
  transition: width .25s ease; }

.list { padding: 0 var(--s4); }

.aisle-name {
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: var(--s4) var(--s4) var(--s1);
}

.card {
  background: var(--card);
  border-radius: var(--r-card);
  overflow: hidden;
}

.line {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%;
  min-height: 56px;
  padding: var(--s2) var(--s2) var(--s2) var(--s4);
  border: 0;
  background: none;
  text-align: left;
  user-select: none;
}
.line + .line { border-top: 1px solid var(--outline); }
.line:active { background: var(--field); }

.check {
  flex: none;
  width: 24px; height: 24px;
  border-radius: var(--r-pill);
  border: 2px solid var(--muted);
  display: grid; place-items: center;
  transition: background .15s ease, border-color .15s ease;
}
.check svg { width: 16px; height: 16px; stroke: var(--on-primary); stroke-width: 3; opacity: 0; }
.line[aria-checked="true"] .check { background: var(--primary); border-color: var(--primary); }
.line[aria-checked="true"] .check svg { opacity: 1; }

.line-text { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: var(--s1) 0; }
.line-label { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.line-qty { font-size: 13px; color: var(--muted); }
.line[aria-checked="true"] .line-label { color: var(--done); text-decoration: line-through; font-weight: 400; }

.remove { color: var(--muted); }

.empty {
  margin: var(--s5) var(--s4);
  color: var(--muted);
  text-align: center;
}

/* Adding a line, at the thumb */
.add {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; gap: var(--s2);
  max-width: 640px; margin: 0 auto;
  padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom));
  background: var(--ground);
  border-top: 1px solid var(--outline);
}
.icon-button { padding: 0; width: 48px; flex: none; display: grid; place-items: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: var(--ink); color: var(--ground);
  font-size: 14px; z-index: 4;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
