/*
 * HyperLocal Student Marketplace -- browser and Android client.
 *
 * Built phone-first, in the shape Indian quick-commerce apps have taught
 * everyone to expect: a search bar pinned to the top, category chips under
 * it, a two-across card grid, tabs along the bottom, and the number that
 * matters riding in a bar above them.
 *
 * Two things are deliberately not borrowed from those apps. There is no cart,
 * because nothing here is bought on the spot -- shops bid and the student
 * chooses. And there are no product photographs, because the API has none;
 * instead each category owns a saturated colour and a glyph, which is an
 * honest answer rather than a grey box where a photo failed to load.
 *
 * Green appears in exactly one place: the cheapest offer. Nothing else is
 * allowed to use it, so it never has to compete for attention.
 */

/* ---------------------------------------------------------------- tokens */

:root {
  color-scheme: light dark;

  --brand: #6c2bd9; /* actions, active tab, brand */
  --brand-ink: #ffffff;
  --brand-wash: #f1eafe;

  --accent: #ff8a00; /* badges and anything about speed */
  --best: #0e9f6e; /* the cheapest offer, and nothing else */
  --best-wash: #e6f6f0;
  --danger: #d92d20;

  --ink: #1a1523;
  --ink-soft: #6b6479;
  --ink-faint: #9992a6;

  --page: #f6f4fb;
  --surface: #ffffff;
  --rule: #e8e4f0;

  /* Category colours. One family, same saturation and lightness, so a grid
     of them reads as a set rather than a paint chart. */
  --cat-electronics: #6c2bd9;
  --cat-stationery: #e8740c;
  --cat-lab: #0d9488;
  --cat-books: #d6336c;
  --cat-computer: #2563eb;
  --cat-tools: #5b6478;
  --cat-other: #7a6a55;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;

  --shadow: 0 1px 2px rgb(26 21 35 / 0.06), 0 8px 24px -12px rgb(26 21 35 / 0.18);

  --max: 72rem;
  --gutter: 1rem;
  --tabbar: 4.25rem;

  --sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  /* Prices sit in columns and have to line up digit for digit. */
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #a78bfa;
    --brand-ink: #1a1523;
    --brand-wash: #2a2140;

    --accent: #fbbf24;
    --best: #34d399;
    --best-wash: #10322a;
    --danger: #fca5a5;

    --ink: #ece9f3;
    --ink-soft: #a49db5;
    --ink-faint: #7d7590;

    --page: #121019;
    --surface: #1c1827;
    --rule: #2e2840;

    --cat-electronics: #8b5cf6;
    --cat-stationery: #f59e0b;
    --cat-lab: #14b8a6;
    --cat-books: #f06595;
    --cat-computer: #3b82f6;
    --cat-tools: #7c8699;
    --cat-other: #a08a6e;

    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px -12px rgb(0 0 0 / 0.6);
  }
}

:root[data-theme="dark"] {
  --brand: #a78bfa;
  --brand-ink: #1a1523;
  --brand-wash: #2a2140;
  --accent: #fbbf24;
  --best: #34d399;
  --best-wash: #10322a;
  --danger: #fca5a5;
  --ink: #ece9f3;
  --ink-soft: #a49db5;
  --ink-faint: #7d7590;
  --page: #121019;
  --surface: #1c1827;
  --rule: #2e2840;
  --cat-electronics: #8b5cf6;
  --cat-stationery: #f59e0b;
  --cat-lab: #14b8a6;
  --cat-books: #f06595;
  --cat-computer: #3b82f6;
  --cat-tools: #7c8699;
  --cat-other: #a08a6e;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px -12px rgb(0 0 0 / 0.6);
}

/* ------------------------------------------------------------------ base */

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

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

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  /* Room for the tab bar, plus the home indicator on a notched phone. */
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

p {
  margin: 0 0 0.75rem;
  max-width: 60ch;
}

a {
  color: var(--brand);
}

:where(button, input, select, textarea, a):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap {
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}

.topbar__row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-block: 0.7rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.0625rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9px;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 0.95rem;
  font-weight: 800;
}

/* The promise, in the position Instamart puts "delivery in 10 minutes". */
.pitch {
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
  margin-left: auto;
}

.pitch b {
  color: var(--accent);
}

/* --------------------------------------------------------------- search */

.search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--page);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 0.1rem 0.75rem;
  margin-bottom: 0.7rem;
}

.search:focus-within {
  border-color: var(--brand);
}

.search svg {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  color: var(--ink-faint);
}

.search input {
  flex: 1;
  border: 0;
  background: none;
  padding: 0.6rem 0;
  font: inherit;
  color: inherit;
  min-width: 0;
}

.search input:focus {
  outline: none;
}

/* ----------------------------------------------------------------- chips */

.chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.7rem;
  margin-inline: calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

/* --------------------------------------------------------------- buttons */

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  padding: 0.6rem 1rem;
  border-radius: var(--r-sm);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.btn:hover {
  border-color: var(--ink-faint);
}

.btn--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.btn--primary:hover {
  filter: brightness(1.08);
}

.btn--block {
  width: 100%;
}

.btn--sm {
  padding: 0.38rem 0.7rem;
  font-size: 0.8125rem;
  border-radius: 8px;
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--brand);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ------------------------------------------------------------------ hero */

.hero {
  padding: 1.25rem 0 0.5rem;
}

.hero h1 {
  font-size: clamp(1.6rem, 6.5vw, 2.6rem);
  max-width: 14ch;
}

.hero p {
  margin-top: 0.5rem;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  max-width: 44ch;
}

/* ---------------------------------------------------------------- panels */

.section {
  margin-bottom: 1.5rem;
}

.section__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.section__head h2 {
  font-size: 1.0625rem;
}

.section__head .side {
  margin-left: auto;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 1rem;
  margin-bottom: 1rem;
}

/* ------------------------------------------------------------------ grid */

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 40rem) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 60rem) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.tile {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/*
 * The coloured block that stands in for a product photo. Flat and saturated
 * on purpose: a tinted grey rectangle would read as a picture that failed to
 * load, whereas this reads as a decision.
 */
.tile__art {
  aspect-ratio: 5 / 3;
  display: grid;
  place-items: center;
  background: var(--cat, var(--cat-other));
  position: relative;
}

/*
 * Taken out of flow like the photograph that may replace it. Left in flow the
 * glyph counts as content and the block sizes around it, while a block
 * holding an absolutely positioned photo has no content at all -- so the two
 * resolved to different heights and the grid went ragged. Neither contributes
 * now, and aspect-ratio alone decides, identically for both.
 */
.tile__art svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 38%;
  max-width: 3.25rem;
  height: auto;
  color: #fff;
  opacity: 0.92;
}

.tile__badge {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  background: rgb(255 255 255 / 0.92);
  color: #1a1523;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
}

.tile__body {
  padding: 0.65rem 0.7rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.tile__name {
  font-weight: 700;
  font-size: 0.9375rem;
  letter-spacing: -0.015em;
  line-height: 1.25;
  /* Two lines, then ellipsis -- otherwise one long name makes its card
     taller than everything beside it and the grid goes ragged. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile__meta {
  font-size: 0.75rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile__foot {
  margin-top: auto;
  padding-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---------------------------------------------------------------- prices */

.price {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.price--lg {
  font-size: 1.5rem;
}

.price--best {
  color: var(--best);
}

.delta {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ rows */

/* Requests and offers are read down a column, not scanned across a grid, so
   they stay as rows rather than becoming more cards. */
.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.rows > li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem;
  border-top: 1px solid var(--rule);
}

.rows > li:first-child {
  border-top: 0;
}

.row__art {
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--cat, var(--cat-other));
}

.row__art svg {
  width: 1.4rem;
  height: 1.4rem;
  color: #fff;
}

.row__main {
  flex: 1;
  min-width: 0;
}

.row__name {
  font-weight: 700;
  letter-spacing: -0.015em;
}

.row__meta {
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.row__side {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

/* ------------------------------------------- the cheapest offer, once */

.best-card {
  background: var(--best-wash);
  border: 1.5px solid var(--best);
  border-radius: var(--r-lg);
  padding: 1rem;
  margin-bottom: 0.75rem;
  position: relative;
  animation: rise 360ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .best-card {
    animation: none;
  }
}

.best-card__tag {
  display: inline-block;
  background: var(--best);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.best-card__shop {
  font-weight: 800;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
}

.best-card__meta {
  font-size: 0.8125rem;
  color: var(--ink-soft);
  margin-top: 0.1rem;
}

.best-card__price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.6rem;
}

.saving {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--best);
}

/* --------------------------------------------------------------- scanner */

.scan-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  border-color: var(--brand);
  color: var(--brand);
}

.scan-btn svg {
  width: 1.4rem;
  height: 1.4rem;
}

.scanner {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  background: #000;
  margin-bottom: 0.5rem;
  aspect-ratio: 4 / 3;
}

.scanner video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* A line that sweeps, so it is obvious the camera is live and looking --
   a still picture of a shelf gives no sign anything is happening. */
.scanner__line {
  position: absolute;
  left: 8%;
  right: 8%;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  animation: sweep 2s ease-in-out infinite alternate;
}

@keyframes sweep {
  from {
    top: 22%;
  }
  to {
    top: 78%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scanner__line {
    animation: none;
    top: 50%;
  }
}

.scanner__stop {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
}

/* ----------------------------------------------------------------- stars */

.stars {
  display: flex;
  gap: 0.2rem;
}

.star {
  border: 0;
  background: none;
  padding: 0.1rem;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--rule);
  cursor: pointer;
}

.star[aria-checked="true"],
.star.star--on {
  color: var(--accent);
}

/* A rating shown rather than chosen: smaller, and not a control. */
.rating {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 0.875rem;
}

.rating__stars {
  color: var(--accent);
  letter-spacing: -0.05em;
}

.rating__count {
  color: var(--ink-soft);
  font-weight: 600;
}

/* ------------------------------------------------------------- suspended */

/*
 * A suspended account stays visible to the owner and reads as withdrawn
 * rather than deleted, since the whole point is that it can be let back in.
 */
.row--blocked {
  opacity: 0.55;
}

.badge-off {
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
}

.badge-owner {
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
}

/* Amber, not red: an account belonging to someone under 18 is a fact to
   notice, not a fault to fix. */
.badge-minor {
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
}

/* ------------------------------------------------- catalogue entry */

/*
 * Everything a shopkeeper touches is bigger than the rest of the app. The
 * person entering thirty items is often doing it one-handed behind a counter,
 * sometimes in reading glasses, and the cost of a mis-tap is a wrong price on
 * a shelf.
 */
.btn--big {
  padding: 0.95rem 1.2rem;
  font-size: 1.0625rem;
  border-radius: var(--r-md);
}

.btn--danger {
  color: var(--danger);
}

.field--big > span {
  font-size: 0.9375rem;
  color: var(--ink);
}

.field--big input {
  padding: 0.85rem 0.8rem;
  font-size: 1.125rem;
}

/* Rupee sign welded to the box, so the number needs no label to be read. */
.money {
  display: flex;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  background: var(--surface);
  padding-left: 0.7rem;
  font-size: 1.125rem;
  font-weight: 700;
}

.money:focus-within {
  border-color: var(--brand);
}

.money input {
  border: 0;
  background: none;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--mono);
  padding: 0.8rem 0.6rem;
}

.money input:focus {
  outline: none;
}

/* Category as pictures. A dropdown of English words is a wall; seven
   coloured tiles with a glyph can be chosen without reading at all. */
.pickgrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.pick {
  border: 1.5px solid var(--rule);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 0.5rem 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  min-height: 4.25rem;
}

.pick__art {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--cat, var(--cat-other));
  position: relative;
}

.pick__art svg {
  width: 1.1rem;
  height: 1.1rem;
  color: #fff;
}

.pick__label {
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  color: var(--ink-soft);
}

.pick[aria-checked="true"] {
  border-color: var(--brand);
  background: var(--brand-wash);
}

.pick[aria-checked="true"] .pick__label {
  color: var(--brand);
}

/* The photo button is the first thing in the sheet and looks like a place a
   picture goes, rather than a file input nobody recognises. */
.photo-drop {
  width: 100%;
  border: 1.5px dashed var(--rule);
  background: var(--page);
  border-radius: var(--r-md);
  padding: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--ink-soft);
  margin-bottom: 1rem;
  cursor: pointer;
}

.photo-drop__icon {
  flex: none;
  width: 3rem;
  height: 3rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--rule);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  color: var(--ink-faint);
  overflow: hidden;
  position: relative;
}

.photo-drop__icon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

details#item-more {
  border: 0;
  padding: 0;
  margin: 0 0 0.9rem;
}

details#item-more summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand);
  padding: 0.4rem 0;
}

.sheet__actions {
  display: grid;
  gap: 0.5rem;
}

/* A listing in the shop's own catalogue carries its controls. */
.tile__manage {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.tile__manage .btn {
  flex: 1;
  padding: 0.38rem 0.3rem;
  font-size: 0.8125rem;
}

/* ---------------------------------------------------------------- avatar */

/*
 * Falls back to an initial on the brand colour rather than a grey silhouette,
 * so an account with no picture still looks like somebody rather than like a
 * gap. The initial is set from script as a data attribute.
 */
.avatar {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 800;
  font-size: 0.9375rem;
  overflow: hidden;
  position: relative;
  text-transform: uppercase;
}

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--lg {
  width: 4.5rem;
  height: 4.5rem;
  font-size: 1.75rem;
}

.avatar-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.avatar-row .btn {
  margin-right: 0.3rem;
}

/* ------------------------------------------------------------ shopfront */

.shopfront {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1.25rem 0 0.75rem;
}

.shopfront__text {
  min-width: 0;
}

.shopfront h1 {
  font-size: clamp(1.4rem, 5.5vw, 2rem);
}

.shopfront p {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-size: 0.875rem;
}

.shop-about {
  color: var(--ink-soft);
  font-size: 0.9375rem;
  margin-bottom: 1rem;
}

/* A shop's name is a way in to its page, so it should look like one. */
.shoplink {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
  cursor: pointer;
}

.shoplink:hover {
  text-decoration-color: var(--brand);
}

/* A row that carries a face sets it beside the text. */
.row__who {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ------------------------------------------------------------------ bell */

.bell {
  position: relative;
  flex: none;
  border: 0;
  background: none;
  color: var(--ink);
  padding: 0.3rem;
  line-height: 0;
  margin-left: auto;
}

.bell svg {
  width: 1.4rem;
  height: 1.4rem;
}

/* A dot, not a number: the count is on the screen the bell opens, and a
   figure this small is read as "something new" either way. */
.bell__dot {
  position: absolute;
  top: 0.15rem;
  right: 0.1rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid var(--surface);
}

/* The pitch gives up its place once there is a bell to sit there. */
.bell:not([hidden]) ~ .pitch,
.pitch:has(~ .bell:not([hidden])) {
  margin-left: 0;
}

/* --------------------------------------------------------------- unread */

.alert--unread {
  background: var(--brand-wash);
}

.alert__kind {
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--brand);
}

/* ---------------------------------------------------------------- toasts */

/*
 * Messages used to appear as a line of text under whichever form produced
 * them, which on a phone is often below the fold. A toast is seen.
 */
.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 0.75rem);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: calc(100% - 2rem);
  max-width: 26rem;
  pointer-events: none;
}

.toast {
  background: var(--ink);
  color: var(--page);
  border-radius: var(--r-md);
  padding: 0.7rem 0.9rem;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toast-in 220ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.toast--ok {
  background: var(--best);
  color: #fff;
}

.toast--bad {
  background: var(--danger);
  color: #fff;
}

.toast--warn {
  background: var(--accent);
  color: #1a1523;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }
}

@media (min-width: 48rem) {
  .toasts {
    bottom: 1rem;
  }
}

/* --------------------------------------------------------------- preview */

.preview {
  display: block;
  width: 100%;
  max-height: 11rem;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 1px solid var(--rule);
  margin-bottom: 0.8rem;
}

/*
 * A real photograph replaces the category block and fills it exactly, so a
 * card with a picture and one without are the same shape and the grid stays
 * even. Positioned rather than sized: the block centres its contents for the
 * glyph's sake, and a centred image keeps its own proportions instead of
 * filling the space.
 */
.tile__art img,
.row__art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.row__art {
  position: relative;
  overflow: hidden;
}

/* ---------------------------------------------------------------- contact */

/* How a student actually reaches a shop once the price is agreed. */
.contact {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

.contact .btn {
  padding: 0.4rem 0.7rem;
  font-size: 0.8125rem;
  border-radius: 999px;
  text-decoration: none;
}

/* ------------------------------------------------------------------ chat */

.chat {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.bubble {
  max-width: 85%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--rule);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

/* Yours on the right, in brand colour: the oldest convention in messaging,
   and the one that needs no explaining. */
.bubble--mine {
  align-self: flex-end;
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.bubble__when {
  display: block;
  font-size: 0.6875rem;
  opacity: 0.7;
  margin-top: 0.2rem;
}

.chat-compose {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.chat-compose input {
  flex: 1;
}

.chat-compose .btn {
  flex: none;
}

/* An unread count beside a conversation in the list. */
.count {
  background: var(--accent);
  color: #1a1523;
  font-size: 0.6875rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}

/* A count of what is waiting, on the tab that leads to it. */
.tab__badge {
  position: absolute;
  top: 0.35rem;
  left: 50%;
  margin-left: 0.3rem;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--accent);
  color: #1a1523;
  font-size: 0.625rem;
  font-weight: 800;
  line-height: 1.05rem;
  text-align: center;
}

.tab {
  position: relative;
}

@media (min-width: 48rem) {
  .tab__badge {
    position: static;
    margin-left: 0.1rem;
  }
}

/* --------------------------------------------------------------- summary */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.stats > div {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 0.6rem 0.7rem;
}

.stats dt {
  font-size: 0.6875rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.stats dd {
  margin: 0.15rem 0 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.03em;
}

/* ----------------------------------------------------------------- forms */

.field {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
}

.field > span {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ink-soft);
}

input,
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 0.65rem 0.7rem;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-faint);
}

.row2 {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

.actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

fieldset {
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.8rem 0.8rem;
  margin: 0 0 0.8rem;
}

legend {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ink-soft);
  padding-inline: 0.3rem;
}

/* A consent tick, not a setting: the label is the target, and the whole row
   is big enough to hit with a thumb on a phone. */
.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.25rem 0 1rem;
  font-size: 0.9375rem;
  line-height: 1.4;
  cursor: pointer;
}

/* hidden on an element that display:flex would otherwise force visible */
.check[hidden] {
  display: none;
}

.check input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  flex: none;
  accent-color: var(--brand);
}

/* "Forgot your password?" -- a button, because it does something, styled as
   the link people expect to find under a sign-in form. */
.auth-alt {
  margin-top: 0.75rem;
  text-align: center;
}

.linkish {
  background: none;
  border: 0;
  padding: 0.25rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--brand);
  text-decoration: underline;
  cursor: pointer;
}

.linkish:hover {
  opacity: 0.8;
}

.choice {
  display: flex;
  gap: 0.75rem;
}

/* Role picker: two big targets rather than small radio dots. */
.choice label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1.5px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 0.6rem;
  font-weight: 700;
  font-size: 0.9375rem;
  cursor: pointer;
}

.choice label:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-wash);
  color: var(--brand);
}

.choice input {
  width: auto;
  margin: 0;
}

.hint-line {
  font-size: 0.8125rem;
  color: var(--ink-soft);
  min-height: 1.2em;
}

.hint-line--warn {
  color: var(--accent);
}

.hint-line--ok {
  color: var(--best);
}

.msg {
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.msg--bad {
  color: var(--danger);
}

.msg--ok {
  color: var(--best);
}

.msg--warn {
  color: var(--accent);
}

/* ------------------------------------------------------- empty and notes */

.empty {
  background: var(--surface);
  border: 1px dashed var(--rule);
  border-radius: var(--r-lg);
  padding: 1.5rem 1.1rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.empty strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.note {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-md);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}

.note--bad {
  border-left-color: var(--danger);
}

.note p:last-child {
  margin-bottom: 0;
}

.waking {
  font-size: 0.8125rem;
  color: var(--ink-soft);
  padding: 0.6rem 0;
}

/* ------------------------------------------------------- sticky best bar */

/*
 * Where a grocery app keeps the cart total, this keeps the number the student
 * actually came for. It sits above the tabs and only appears when there is a
 * price worth reporting.
 */
.bestbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
  z-index: 25;
  background: var(--best);
  color: #fff;
  box-shadow: 0 -6px 20px -10px rgb(26 21 35 / 0.4);
}

.bestbar__inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem var(--gutter);
  max-width: var(--max);
  margin-inline: auto;
}

.bestbar__label {
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.9;
}

.bestbar__shop {
  font-weight: 800;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bestbar__price {
  margin-left: auto;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.04em;
}

/* ------------------------------------------------------------ tab bar */

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab {
  flex: 1;
  border: 0;
  background: none;
  color: var(--ink-faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.5rem 0.25rem;
  min-height: var(--tabbar);
  font-size: 0.6875rem;
  font-weight: 700;
}

.tab svg {
  width: 1.4rem;
  height: 1.4rem;
}

.tab[aria-current="page"] {
  color: var(--brand);
}

/* --------------------------------------------------------------- footer */

footer {
  padding: 1.25rem 0 2rem;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  text-align: center;
}

/* --------------------------------------------------------------- dialog */

dialog {
  border: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  width: 100%;
  max-width: 34rem;
  margin: auto auto 0; /* a sheet rising from the bottom, as on a phone */
}

dialog::backdrop {
  background: rgb(26 21 35 / 0.5);
}

.sheet {
  padding: 1.1rem var(--gutter) calc(1.1rem + env(safe-area-inset-bottom, 0px));
}

.sheet h2 {
  font-size: 1.125rem;
  margin-bottom: 0.3rem;
}

.sheet > p {
  font-size: 0.875rem;
  color: var(--ink-soft);
  margin-bottom: 0.9rem;
}

/* Grab handle, so the sheet reads as something that came up from below. */
.sheet::before {
  content: "";
  display: block;
  width: 2.25rem;
  height: 0.25rem;
  border-radius: 999px;
  background: var(--rule);
  margin: -0.4rem auto 0.8rem;
}

@media (min-width: 40rem) {
  dialog {
    border-radius: var(--r-lg);
    margin: auto;
  }

  .sheet::before {
    display: none;
  }
}

/* ------------------------------------------------------- desktop layout */

/*
 * Tabs along the bottom are right on a phone and odd on a laptop, so above
 * this width they move into the header as ordinary navigation.
 */
@media (min-width: 48rem) {
  body {
    padding-bottom: 0;
  }

  /* The pitch earns its place on a phone, where the header is otherwise
     bare. On a laptop the navigation is the better use of that space. */
  .pitch {
    display: none;
  }

  .tabs {
    position: static;
    border-top: 0;
    background: none;
    padding-bottom: 0;
    gap: 0.25rem;
    margin-left: auto;
  }

  .tab {
    flex: none;
    flex-direction: row;
    gap: 0.4rem;
    min-height: 0;
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    font-size: 0.875rem;
  }

  .tab svg {
    width: 1.1rem;
    height: 1.1rem;
  }

  .tab[aria-current="page"] {
    background: var(--brand-wash);
  }

  .bestbar {
    bottom: 0;
  }
}
