/* Base styles. Mobile-first, one file, no framework.
 *
 * Nothing here hard-codes a colour, radius, border width, shadow or font: they all come from
 * the tokens in receipt.css. Layout styles live in ux.css.
 */

:root {
  /* Content gutters; they also keep things clear of the notch on phones held sideways. */
  --gl: max(1rem, env(safe-area-inset-left));
  --gr: max(1rem, env(safe-area-inset-right));
  font-family: var(--font-body);
  line-height: 1.5;
}

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
  background-image: var(--bg-image, none);
  background-size: var(--bg-size, auto);
  color: var(--text);
  font-size: var(--body-size);
  -webkit-text-size-adjust: 100%;
}

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

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  line-height: 1.2;
  margin: 0 0 0.5rem;
  text-wrap: balance;
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0 0 0.5rem;
  text-wrap: pretty;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 var(--gr) 0 var(--gl);
}

/* No double-tap-to-zoom delay on controls. */
a,
button,
label {
  touch-action: manipulation;
}

main.container {
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
}

.muted {
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.9rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  z-index: 10;
}

.skip-link:focus {
  top: 0.5rem;
}

/* ---- Header ---- */

/* A positioning context for anything pinned to the header's right edge. */
.site-header .container {
  position: relative;
}

.site-header {
  position: relative;
  background: var(--surface);
  border-bottom: var(--header-bw, var(--bw)) var(--border-style) var(--border);
  filter: var(--card-filter, none);
  padding: 0.8rem 0;
  margin-bottom: 1.25rem;
}

.site-name {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 1.5em;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
}

/* The logo: a yellow dot, the same as the favicon. */
.site-name::before {
  content: "";
  flex: none;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: #ffd23f;
}

/* DEMO ONLY (the demo site; never in production): the online demo's label next to the site name. */
.demo-label {
  margin-left: 0.6rem;
  padding: 0.1rem 0.45rem;
  border: 1px dashed var(--muted);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  vertical-align: middle;
}

.page-title {
  font-size: 2rem;
  letter-spacing: -0.01em;
  margin-bottom: calc(0.75rem + var(--edge-h, 0px));
}

.back-link {
  margin-bottom: 0.5rem;
}

.page-status {
  margin: 1rem 0;
}

/* ---- Cards ---- */

.card {
  position: relative;
  background: var(--surface);
  border: var(--card-bw, var(--bw)) var(--border-style) var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  filter: var(--card-filter, none);
  padding: 1.1rem;
  margin-bottom: calc(1rem + var(--edge-h, 0px) * 2);
  --edge-fill: var(--surface);
}

/* Torn paper edges, for themes that set --edge-h (Receipt and its relatives). At the default 0px they draw
   nothing. Each edge is a row of triangles in the card's own colour, sitting just outside its top and bottom. */
.card::before,
.card::after,
.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: var(--edge-h, 0px);
  color: var(--edge-fill, var(--surface)); /* the shapes below paint with currentColor */
  background-repeat: repeat-x;
  background-position: 50% 0;
  background-size: var(--edge-w, calc(var(--edge-h, 0px) * 2)) 100%;
  pointer-events: none;
}

/* Default shape: a sawtooth. A theme can set --edge-top, --edge-bottom and --edge-w for scallops or perforations. */
.card::before {
  bottom: calc(100% - 0.5px);
  background-image: var(--edge-top, conic-gradient(from -45deg at 50% 100%, transparent 90deg, currentColor 0));
}

.card::after,
.site-header::after {
  top: calc(100% - 0.5px);
  background-image: var(--edge-bottom, conic-gradient(from 135deg at 50% 0, transparent 90deg, currentColor 0));
}

.site-header {
  --edge-fill: var(--surface);
}

/* The rating form is the one thing that should stand out. */
.card-vote {
  border: var(--vote-bw, var(--bw-strong)) var(--border-style) var(--vote-border);
  background: var(--vote-bg);
  box-shadow: var(--lift);
  --sticky-bg: var(--vote-bg);
  --edge-fill: var(--vote-bg);
}

.hall-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: calc(1rem + var(--edge-h, 0px) * 2);
}

.hall-list .card {
  margin-bottom: 0;
}

.section-label {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

.hall-intro {
  margin-bottom: calc(1rem + var(--edge-h, 0px));
}

.hall-intro p {
  max-width: 60ch;
}

/* ---- Status badge ---- */

.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.6rem;
  margin: 0.25rem 0 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.7rem 0.2rem 0.55rem;
  border-radius: var(--badge-radius, var(--radius-pill));
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: var(--badge-case, none);
  letter-spacing: var(--badge-track, normal);
  transform: var(--badge-transform, none);
}

.badge::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
  display: var(--badge-dot, block);
}

.badge-open {
  background: var(--badge-open-bg, var(--good-soft));
  color: var(--badge-open-fg, var(--good));
}

.badge-closed {
  background: var(--badge-closed-bg, var(--neutral-soft));
  color: var(--badge-closed-fg, var(--muted));
}

.badge-closed::before {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px currentColor;
}

/* ---- Ratings ---- */

.rating {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.55rem;
  margin: 0;
}

/* Two stacked rows of stars; the filled row is clipped to the average. */
.stars {
  position: relative;
  display: inline-block;
  font-size: 1.3rem;
  line-height: 1;
  white-space: nowrap;
}

.stars-empty {
  color: var(--star-empty);
}

.stars-fill {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  color: var(--star);
}

.rating-avg {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 1.9rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.rating-detail {
  color: var(--muted);
  font-size: 0.95rem;
}

.rating-empty {
  color: var(--muted);
}

/* Larger version for the hall page's current meal. */
.rating-hero .rating-avg {
  font-size: 3rem;
}

.rating-hero .stars {
  font-size: 1.7rem;
}

/* Blocks inside the combined Ratings card. */
.ratings-block + .ratings-block {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: var(--bw) var(--border-style) var(--divider);
}

.lifetime-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lifetime-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.2rem 0.75rem;
  padding: 0.6rem 0;
}

/* Line the averages, stars and counts up in columns down the list. */
.lifetime-item .rating {
  flex-wrap: nowrap;
}

.lifetime-item .rating-detail {
  min-width: 13ch;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 23rem) {
  .lifetime-item .rating {
    flex-wrap: wrap;
  }

  .lifetime-item .rating-detail {
    min-width: 0;
  }
}

.lifetime-item:first-child {
  padding-top: 0;
}

.lifetime-item + .lifetime-item {
  border-top: 1px dashed var(--divider);
}

.lifetime-meal {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
}

.lifetime-item .rating-avg {
  font-size: 1.3rem;
}

.lifetime-item .stars {
  font-size: 1.05rem;
}

/* ---- Tags ---- */

.tag-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  display: inline-flex;
  gap: 0.4rem;
  align-items: baseline;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  font-size: 0.92rem;
}

.tag-count {
  display: var(--tag-count-display, inline);
  color: var(--muted);
  font-size: 0.8rem;
}

/* Vote counts matter most in the Ratings block, so they show there whatever the theme hides elsewhere. */
.ratings-block .tag-count {
  display: inline;
}

/* ---- Buttons ---- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-btn);
  border: var(--btn-bw, 2px) var(--btn-style, solid) var(--btn-border);
  box-shadow: var(--btn-shadow);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.button-primary:hover {
  filter: brightness(1.1);
}

.button-secondary {
  background: transparent;
  color: var(--link);
  border-color: var(--border);
}

.button-secondary:hover {
  border-color: var(--link);
}

.button:active {
  transform: translate(1px, 1px);
}

.button-block {
  width: 100%;
  min-height: 52px;
  margin-top: 0.5rem;
  font-size: 1.05rem;
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.link-button {
  background: none;
  border: none;
  min-height: 44px;
  padding: 0.4rem 0;
  margin-top: 0.25rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--link);
  text-decoration: underline;
  cursor: pointer;
}

.link-button:disabled {
  color: var(--muted);
  text-decoration: none;
  cursor: default;
  opacity: 0.6;
}

/* ---- Vote form ---- */

.vote-form fieldset {
  border: none;
  margin: 0 0 1.1rem;
  padding: 0;
  min-width: 0;
}

.vote-form legend {
  font-weight: 700;
  margin-bottom: 0.5rem;
  padding: 0;
}

/* Native radios/checkboxes stay in the page (keyboard + screen readers) but are visually replaced. */
.star-option input,
.chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.star-input {
  display: flex;
  gap: 0.3rem;
}

.star-option {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: 4.5rem;
  cursor: pointer;
}

/* Empty stars are outlined (not just paler), so the state is clear without relying on colour. */
.star-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 3.4rem;
  border-radius: var(--radius-sm);
  font-size: 2.7rem;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 2px var(--star-line);
  user-select: none;
}

/* Fill the chosen star and every star before it. */
.star-option input:checked + .star-glyph,
.star-option:has(~ .star-option input:checked) .star-glyph {
  color: var(--star);
  -webkit-text-stroke-color: var(--star-edge);
}

/* Mouse users get a preview of the rating they're about to give. */
@media (hover: hover) {
  .star-input:hover .star-option .star-glyph {
    color: transparent;
    -webkit-text-stroke-color: var(--star-line);
  }

  .star-input:hover .star-option:hover .star-glyph,
  .star-input:hover .star-option:has(~ .star-option:hover) .star-glyph {
    color: var(--star);
    -webkit-text-stroke-color: var(--star-edge);
  }
}

.star-caption {
  margin: 0.25rem 0 0;
  min-height: 1.5em;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Once a star is chosen, the caption is its word ("Good"): the answer, so it reads like one. */
.star-caption.is-set {
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.star-option input:focus-visible + .star-glyph {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.chip input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  position: relative;
  cursor: pointer;
}

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem 0.95rem;
  border: var(--chip-bw, max(1.5px, var(--bw))) var(--border-style) var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  user-select: none;
}

.chip:hover span {
  border-color: var(--link);
}

.chip input:checked + span {
  border-color: var(--link);
  background: var(--accent-soft);
  font-weight: 600;
}

.hp-field {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.vote-message {
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.vote-message:empty {
  display: none;
}

.vote-message-success {
  background: var(--good-soft);
  color: var(--good);
}

.vote-message-success::before {
  content: "✓ ";
}

.vote-message-error {
  background: var(--bad-soft);
  color: var(--bad);
}

.closed-message {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--neutral-soft);
}

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

.closed-title {
  font-weight: 700;
}

.error-state {
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--bad-soft);
}

.error-state .button {
  margin-top: 0.5rem;
}

/* ---- Specials and hours ---- */

/* Set like a menu board. */
.menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu-list li {
  padding: 0.5rem 0;
}

.menu-list li:first-child {
  padding-top: 0.15rem;
}

.menu-list li + li {
  border-top: var(--bw) var(--border-style) var(--divider);
}

.menu-item-name {
  display: block;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
}

.menu-item-note {
  display: block;
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.menu-source {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
}

.hours-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.hours-table th,
.hours-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.5rem;
  border-bottom: var(--bw) var(--border-style) var(--divider);
}

.hours-table tbody tr:last-child th,
.hours-table tbody tr:last-child td {
  border-bottom: none;
}

.hours-table thead th {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.hours-table tbody th {
  white-space: nowrap;
  font-weight: 600;
}

.hours-table tr.is-today {
  background: var(--accent-soft);
}

.about-name {
  margin: 0 0 0.25rem;
  font-weight: 700;
}

.hours-note {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
}

.day-short {
  display: none;
}

/* Narrow phones: "Wed" instead of "Wednesday" (screen readers still get the full name). */
@media (max-width: 26rem) {
  .day-long {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .day-short {
    display: inline;
  }
}

.today-pill {
  display: block;
  width: fit-content;
  margin-top: 0.2rem;
  padding: 0 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 700;
}

.hours-meals {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hours-meals li {
  display: flex;
  flex-wrap: wrap; /* on very narrow phones the time drops under the meal name */
  justify-content: space-between;
  column-gap: 0.5rem;
}

.hours-meals li + li {
  margin-top: 0.15rem;
}

.hours-time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---- Loading placeholders ---- */

.skeleton {
  pointer-events: none;
}

/* Loading placeholders stay invisible for their first 0.3 s, so a page that renders from stored data right away
   never flashes "Loading…". A slow first load still shows them. */
.load-wait {
  animation: load-wait 300ms steps(1, end);
}

@keyframes load-wait {
  from {
    visibility: hidden;
  }
  to {
    visibility: visible;
  }
}

.skeleton-line {
  height: 1rem;
  margin: 0.6rem 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--skeleton) 0%, var(--skeleton-hi) 50%, var(--skeleton) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton-line.is-title {
  width: 55%;
  height: 1.5rem;
}

.skeleton-line.is-short {
  width: 35%;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

/* ---- Larger screens ---- */

@media (min-width: 40rem) {
  .hall-list {
    grid-template-columns: 1fr 1fr;
  }

  .page-title {
    font-size: 2.3rem;
  }
}

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

  /* Not motion: just "don't show the placeholder for the first moment". */
  .load-wait {
    animation: load-wait 300ms steps(1, end) !important;
  }
}
