/* SharedList. Colours continue the landing page; everything is tuned for one
   hand, a glance, and supermarket lighting. */
@font-face { font-family: 'Atkinson Next'; src: url('/fonts/atkinson-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson Next'; src: url('/fonts/atkinson-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Source Serif'; src: url('/fonts/source-serif-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  color-scheme: light dark;
  --paper: #f7f4ee; --raised: #fffdf9; --ink: #1c2b2a; --muted: #566562; --line: #e2dccf;
  --green: #1f4d38; --green-ink: #fffdf9; --tick: #2e6e4e; --marker: #f3d65f; --marker-ink: #1c2b2a;
  --danger: #a3341f; --shadow: 0 -6px 20px rgb(28 43 42 / 7%);
  --body: 'Atkinson Next', Corbel, 'Segoe UI', sans-serif;
  --head: 'Source Serif', Palatino, Georgia, serif;
  --kb: 0px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141c1b; --raised: #1d2726; --ink: #eef0ea; --muted: #a5b2ae; --line: #2f3c3a;
    --green: #8fd3ae; --green-ink: #10201a; --tick: #8fd3ae; --marker: #6f6118; --marker-ink: #fdf6d8;
    --danger: #f0917c; --shadow: 0 -6px 20px rgb(0 0 0 / 35%);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 1.125rem/1.35 var(--body); overscroll-behavior-y: none; }
h1, h2, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--tick); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.small { font-size: .9rem; color: var(--muted); }
.center { text-align: center; }

/* Buttons */
.primary, .secondary, .danger {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 3.25rem;
  padding: .7rem 1rem; border-radius: .85rem; font-weight: 700; text-decoration: none; text-align: center;
}
.primary { background: var(--green); color: var(--green-ink); }
.primary:disabled { opacity: .45; cursor: default; }
.secondary { border: 1.5px solid var(--line); background: var(--raised); }
.danger { color: var(--danger); }
.primary:active, .secondary:active { transform: scale(.985); }
.link { color: var(--tick); font-weight: 700; min-height: 2.75rem; padding: 0 .25rem; }

/* First run */
.screen { min-height: 100dvh; max-width: 30rem; margin: 0 auto; padding: max(2.5rem, env(safe-area-inset-top)) 1.5rem 2rem; display: flex; flex-direction: column; justify-content: center; gap: 1rem; }
.brand { font-weight: 700; letter-spacing: .01em; color: var(--tick); }
.screen h1 { font: 600 2.35rem/1.1 var(--head); letter-spacing: -.01em; }
.lede { color: var(--muted); }
.screen form { display: grid; gap: .5rem; margin-top: 1rem; }
.screen label, .sheet label { font-weight: 700; font-size: 1rem; }
input[type=text], input:not([type]), select, textarea {
  width: 100%; min-height: 3.25rem; padding: .7rem .9rem; border: 1.5px solid var(--line); border-radius: .85rem;
  background: var(--raised); font-size: 1.125rem;
}
::placeholder { color: var(--muted); opacity: 1; }
.screen .primary { margin-top: .5rem; }

/* Header */
#app { max-width: 34rem; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(6.5rem + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 3; background: var(--paper); padding: max(.9rem, env(safe-area-inset-top)) 1rem .55rem; border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.top h1 { font: 600 1.75rem/1.15 var(--head); letter-spacing: -.01em; }
.top-actions { display: flex; align-items: center; gap: .15rem; }
.pill { display: inline-flex; align-items: center; gap: .35rem; min-height: 2.75rem; padding: 0 .8rem; border-radius: 99px; font-size: 1rem; font-weight: 700; color: var(--tick); }
.icon { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 99px; }
.icon circle { fill: currentColor; stroke: none; }
.status { display: flex; justify-content: space-between; gap: 1rem; font-size: .95rem; color: var(--muted); margin-top: .1rem; }
.sync { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.sync i { width: .55rem; height: .55rem; border-radius: 50%; background: var(--tick); }
.sync.saving i { background: var(--marker); }
.sync.offline { color: var(--ink); font-weight: 700; }
.sync.offline i { background: none; box-shadow: inset 0 0 0 2px var(--ink); }

/* Due soon */
main { padding: 0 1rem; }
.due { margin-top: .75rem; padding: .35rem .9rem .15rem; background: var(--raised); border: 1px solid var(--line); border-radius: 1rem; }
.due-head { display: flex; align-items: center; justify-content: space-between; }
.due h2 { font-size: 1rem; }
mark { background: linear-gradient(transparent 12%, var(--marker) 12%, var(--marker) 88%, transparent 88%); color: var(--marker-ink); padding: 0 .3em; margin-left: -.3em; }
.due li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; column-gap: .1rem; padding: .2rem 0; border-top: 1px solid var(--line); }
.due-name { font-weight: 700; overflow-wrap: anywhere; line-height: 1.25; }
.due-why { font-size: .875rem; color: var(--muted); line-height: 1.2; }
.due .link { font-size: 1rem; }
.due-text { min-width: 0; }
.due li button { min-height: 2.75rem; padding: 0 .5rem; font-size: 1rem; font-weight: 700; white-space: nowrap; }
.due .add { color: var(--tick); }
.due .later { color: var(--muted); font-weight: 400; }

/* Sponsored offer: clearly an ad, never mistaken for a list item */
.offer { margin-top: .75rem; padding: .7rem .9rem .35rem; border: 1px dashed var(--muted); border-radius: 1rem; }
.offer-label { font-size: .8rem; font-weight: 700; letter-spacing: .02em; color: var(--muted); }
.offer-title { font-weight: 700; margin-top: .15rem; }
.offer-body { font-size: .95rem; color: var(--muted); }
.offer-why { font-size: .8rem; color: var(--muted); margin-top: .35rem; }
.offer-actions { display: flex; justify-content: space-between; align-items: center; }
.offer-cta { color: var(--tick); font-weight: 700; text-decoration: none; min-height: 2.75rem; display: inline-flex; align-items: center; }
.offer-hide { color: var(--muted); min-height: 2.75rem; padding: 0 .25rem; font-size: 1rem; }

/* Aisles and rows */
.aisle h2, .trolley h2 { font-size: .95rem; font-weight: 700; color: var(--muted); padding: 1rem 0 .1rem; }
.row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: .8rem; min-height: 3.5rem; padding: .55rem 0; text-align: left; }
.box { flex: none; width: 1.75rem; height: 1.75rem; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; transition: background .15s, border-color .15s; }
.box svg { width: 1.1rem; height: 1.1rem; stroke: var(--paper); stroke-width: 3; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .22s ease-out; }
.row.done .box { background: var(--tick); border-color: var(--tick); }
.row.done .box svg { stroke-dashoffset: 0; }
.row-copy { min-width: 0; overflow-wrap: anywhere; }
.row-text {
  font-size: 1.2rem; line-height: 1.3;
  background: linear-gradient(currentColor, currentColor) no-repeat 0 56% / 0 2px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; transition: background-size .28s ease-out, color .2s;
}
.row-text b { font-weight: 700; }
.row.done .row-text { background-size: 100% 2px; color: var(--muted); }
.row-who { display: block; font-size: .875rem; color: var(--muted); }
.row-more { flex: none; width: 2.75rem; display: grid; place-items: center; color: var(--muted); }
/* Rings sit inside the row so they never spill past its divider */
.row-main:focus-visible, .row-more:focus-visible { outline-offset: -3px; border-radius: .6rem; }
.row-more svg { width: 1.05em; height: 1.05em; }
.row.arrive { animation: arrive .35s ease-out; }
@keyframes arrive { from { background: color-mix(in srgb, var(--marker) 45%, transparent); } }

/* Trolley */
.trolley { margin-top: .75rem; padding-bottom: .5rem; }
.trolley .primary { margin-top: 1rem; }
.trolley .small { margin-top: .5rem; }

/* Empty */
.empty { padding: 3rem .5rem 1rem; text-align: center; }
.empty h2 { font: 600 1.5rem/1.2 var(--head); margin-bottom: .5rem; }
.empty p { color: var(--muted); max-width: 22rem; margin: 0 auto; }
.empty-actions { display: grid; gap: .6rem; max-width: 18rem; margin: 1.25rem auto 0; }

/* Add dock: in the thumb zone, rides above the keyboard */
.dock { position: fixed; z-index: 4; left: 0; right: 0; bottom: var(--kb); max-width: 34rem; margin: 0 auto; background: var(--paper); border-top: 1px solid var(--line); box-shadow: var(--shadow); padding: .6rem 1rem max(.6rem, env(safe-area-inset-bottom)); }
#add { display: flex; gap: .5rem; }
#text { flex: 1; min-width: 0; }
#addBtn { flex: none; width: 3.25rem; height: 3.25rem; border-radius: .85rem; display: grid; place-items: center; background: var(--green); color: var(--green-ink); }
#addBtn svg { stroke-width: 2.6; }
#suggest { margin-bottom: .35rem; }
#suggest button { display: flex; justify-content: space-between; gap: 1rem; width: 100%; min-height: 2.9rem; align-items: center; text-align: left; border-bottom: 1px solid var(--line); }
#suggest small { color: var(--muted); white-space: nowrap; font-size: .875rem; }

/* Finish bar: in reach once something is ticked */
.finish-bar { position: fixed; z-index: 4; left: 0; right: 0; bottom: calc(var(--dock-h, 4.6rem) + var(--kb)); max-width: 34rem; margin: 0 auto; padding: .5rem 1rem; background: linear-gradient(transparent, var(--paper) 35%); }
body.has-finish #app { padding-bottom: calc(10.5rem + env(safe-area-inset-bottom)); }
.finish-bar .primary { min-height: 3rem; box-shadow: var(--shadow); }
.due .more { display: block; width: 100%; text-align: left; min-height: 2.5rem; font-size: 1rem; border-top: 1px solid var(--line); }

/* Toast */
.toast { position: fixed; z-index: 10; left: 1rem; right: 1rem; bottom: calc(var(--toast-b, 4.6rem) + var(--kb) + .6rem); max-width: 32rem; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3rem; padding: .5rem 1rem; border-radius: .85rem; background: var(--ink); color: var(--paper); font-size: 1rem; animation: rise .18s ease-out; }
.toast button { flex: none; font-weight: 700; min-height: 2.75rem; padding: 0 .25rem; color: var(--marker); }
@media (prefers-color-scheme: dark) { .toast button { color: #6d5b05; } }
@keyframes rise { from { transform: translateY(.5rem); } }

/* Sheets */
dialog.sheet { width: 100%; max-width: 34rem; max-height: 88dvh; margin: auto auto 0; padding: 1.25rem 1.25rem max(.75rem, env(safe-area-inset-bottom)); border: 0; border-radius: 1.25rem 1.25rem 0 0; background: var(--raised); color: var(--ink); overflow-y: auto; }
dialog.sheet[open] { display: grid; gap: .75rem; animation: sheet .2s ease-out; }
dialog.sheet.tall { height: 88dvh; grid-template-rows: auto auto 1fr auto auto; }
dialog::backdrop { background: rgb(15 25 24 / 45%); }
@keyframes sheet { from { transform: translateY(1.5rem); } }
.sheet h2 { font: 600 1.5rem/1.2 var(--head); }
.sheet p { color: var(--muted); font-size: 1rem; }
.sheet form { display: grid; gap: .5rem; }
.stack { display: grid; gap: .5rem; margin-top: .25rem; }
.close { min-height: 2.9rem; color: var(--muted); font-weight: 700; }
#shareLink { font-size: .95rem; color: var(--muted); }
.menu > * { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; min-height: 3.25rem; border-bottom: 1px solid var(--line); text-align: left; text-decoration: none; color: inherit; font-weight: 400; font-size: 1.125rem; }
#mNameNow { color: var(--muted); }
.menu label.toggle { font-weight: 400; font-size: 1.125rem; }
.toggle input { width: 1.5rem; height: 1.5rem; accent-color: var(--tick); }
.picks { overflow-y: auto; min-height: 0; margin: 0 -.25rem; }
.picks label { display: flex; align-items: center; gap: .75rem; min-height: 3.25rem; padding: .35rem .25rem; border-bottom: 1px solid var(--line); font-weight: 400; font-size: 1.125rem; }
.picks input { flex: none; width: 1.5rem; height: 1.5rem; accent-color: var(--tick); }
.picks span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.picks small { color: var(--muted); font-size: .875rem; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
