/* 巷口團購（示範）— Growing DNA
   Paper slips on a pale celadon board: white tickets with a perforated stub,
   a yellow price sticker, and one red seal for 已成團. */

:root {
  --paper: #e6ede5;
  --card: #ffffff;
  --ink: #1d2a36;
  --ink-soft: #3f4d5a;
  --muted: #5a6672;
  --line: #c3cfc4;
  --sticker: #ffd84d;
  --leaf: #2e7d57;
  --leaf-deep: #1f5f40;
  --leaf-soft: #d6e9dd;
  --track: #dde5dd;
  --stamp: #c23b35;
  --closed: #8a949e;
  --closed-soft: #e4e7ea;
  --focus: #1d5fd1;

  --font: "Noto Sans TC", system-ui, -apple-system, "PingFang TC", "Heiti TC", "Microsoft JhengHei", sans-serif;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.7;
  overflow-wrap: break-word;
}

a {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -200px;
  z-index: 30;
  padding: 8px 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  border-radius: 8px;
  text-decoration: none;
}

.skip-link:focus {
  top: 48px;
}

/* ---------- Demo notice: always visible ---------- */

.demo-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0;
  padding: 8px 16px;
  background: var(--sticker);
  border-bottom: 2px solid var(--ink);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

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

.site-header,
.page {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.site-header {
  padding-top: 20px;
  padding-bottom: 4px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  border-radius: 8px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: none;
}

.brand-name {
  display: block;
  font-size: 1.125rem;
  font-weight: 900;
  line-height: 1.3;
  letter-spacing: 0.04em;
}

.brand-sub {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.3;
}

.page {
  flex: 1;
  padding-bottom: 56px;
}

.site-footer {
  padding: 24px 16px 32px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--ink);
  font-weight: 700;
  text-underline-offset: 3px;
}

/* ---------- Home intro ---------- */

.intro {
  max-width: 30em;
  padding: 28px 0 36px;
}

.intro h1 {
  margin: 0 0 14px;
  font-size: clamp(2.125rem, 9vw, 3.5rem);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.intro p {
  margin: 0;
  max-width: 26em;
  color: var(--ink-soft);
  font-size: 1.0625rem;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 900;
}

.section-head p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---------- Ticket (campaign slip) ---------- */

.tickets {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

@media (min-width: 720px) {
  .tickets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
  }
}

.ticket {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--card);
  border-radius: 18px;
  overflow: hidden;
}

.ticket-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 18px 18px;
}

.ticket-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}

.emoji {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 50%;
  background: var(--leaf-soft);
  font-size: 30px;
  line-height: 1;
}

.ticket-title {
  margin: 2px 0 0;
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1.45;
}

.ticket-link {
  text-decoration: none;
}

/* Whole slip is clickable; the link stays the only focus target. */
.ticket-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.ticket-link:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

@supports selector(:has(a)) {
  .ticket-link:focus-visible {
    outline: none;
  }

  .ticket:has(.ticket-link:focus-visible) {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
  }
}

.price {
  display: inline-flex;
  align-self: flex-start;
  align-items: baseline;
  gap: 2px;
  margin: 0;
  padding: 1px 10px 2px;
  border-radius: 6px;
  background: var(--sticker);
  font-size: 1.0625rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  transform: rotate(-1.5deg);
}

.price .per {
  font-size: 0.8125rem;
  font-weight: 500;
}

.desc {
  margin: 0;
  color: var(--ink-soft);
}

.tickets .desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* Perforation with two punched notches at the slip edges */
.perf {
  position: relative;
  margin: 0 22px;
  border-top: 2px dashed var(--line);
}

.perf::before,
.perf::after {
  content: "";
  position: absolute;
  top: -12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--paper);
}

.perf::before {
  left: -33px;
}

.perf::after {
  right: -33px;
}

.ticket-stub {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px 18px;
}

.progress-row,
.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
}

.count {
  margin: 0;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.count strong {
  color: var(--ink);
  font-size: 1.625rem;
  font-weight: 900;
  line-height: 1.2;
}

.gap-note {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--leaf-deep);
}

.bar {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: var(--leaf);
  transition: width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.meta-row {
  font-size: 0.875rem;
  color: var(--muted);
}

.meta-row p {
  margin: 0;
}

.meta-row strong {
  color: var(--ink);
  font-weight: 700;
}

/* ---------- Status: pill, or the red seal for 已成團 ---------- */

.pill {
  flex: none;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill-open {
  background: var(--leaf-soft);
  color: var(--leaf-deep);
}

.pill-closed {
  background: var(--closed-soft);
  color: #4d5761;
}

.stamp {
  flex: none;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: -8px -6px -12px 0;
  border: 3px solid var(--stamp);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--card), inset 0 0 0 4px var(--stamp);
  color: var(--stamp);
  font-size: 0.9375rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  transform: rotate(-14deg);
}

.stamp-land {
  animation: stamp-land 0.55s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}

@keyframes stamp-land {
  from {
    opacity: 0;
    transform: rotate(-28deg) scale(1.9);
  }
  to {
    opacity: 1;
    transform: rotate(-14deg) scale(1);
  }
}

.ticket.is-reached .gap-note {
  color: var(--stamp);
}

.ticket.is-closed .emoji {
  background: var(--closed-soft);
  filter: grayscale(1);
}

.ticket.is-closed .price {
  background: var(--closed-soft);
}

.ticket.is-closed .bar-fill {
  background: var(--closed);
}

.ticket.is-closed .gap-note {
  color: var(--muted);
}

.list-message {
  margin: 0;
  padding: 24px 18px;
  background: var(--card);
  border-radius: 18px;
  color: var(--ink-soft);
}

/* ---------- Detail page ---------- */

.back-link {
  display: inline-block;
  margin: 20px 0 16px;
  font-weight: 700;
  text-decoration: none;
  border-radius: 6px;
}

.back-link:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}

@media (min-width: 880px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    align-items: start;
    gap: 32px;
  }
}

.detail-ticket .emoji {
  width: 72px;
  height: 72px;
  font-size: 40px;
}

.detail-ticket .ticket-top {
  min-height: 72px;
}

.detail-ticket .ticket-title {
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 900;
  line-height: 1.35;
}

.detail-ticket .desc {
  margin-top: 6px;
  white-space: pre-line;
}

.detail-side {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

/* Join form: an order slip with an ink border */
.join {
  padding: 20px 18px 22px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
}

.join h2 {
  margin: 0 0 2px;
  font-size: 1.25rem;
  font-weight: 900;
}

.join .form-note {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.field {
  margin-top: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.hint {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.text-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #8f9ca8;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}

.text-input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--ink);
}

.text-input[aria-invalid="true"] {
  border-color: var(--stamp);
}

.stepper {
  display: flex;
  gap: 8px;
  max-width: 220px;
}

.stepper .text-input {
  min-width: 0;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}

.stepper .text-input::-webkit-inner-spin-button,
.stepper .text-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.step-btn {
  flex: none;
  width: 48px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.step-btn:hover {
  background: var(--leaf-soft);
}

.step-btn:disabled {
  border-color: var(--line);
  color: var(--closed);
  background: var(--card);
  cursor: not-allowed;
}

.subtotal {
  margin: 16px 0 0;
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

.subtotal strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.btn-primary {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 12px 16px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--sticker);
  box-shadow: 0 3px 0 var(--ink);
  color: var(--ink);
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.btn-primary:hover {
  background: #ffe174;
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

.form-message {
  margin: 14px 0 0;
  font-weight: 700;
}

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

.form-message.is-error {
  color: var(--stamp);
}

.form-message.is-success {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--leaf-soft);
  color: var(--leaf-deep);
}

.closed-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--closed-soft);
  color: #3f4952;
  font-weight: 700;
}

/* 接龍 roster: ruled list straight on the board */
.roster h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 900;
}

.roster .roster-sub {
  margin: 0 0 8px;
  font-size: 0.875rem;
  color: var(--muted);
}

.roster ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--ink);
}

.roster li {
  display: grid;
  grid-template-columns: 3em minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0 10px;
  padding: 10px 4px;
  border-bottom: 1px dashed var(--line);
}

.roster .no {
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.roster .nick {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.roster .qty {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.roster time {
  grid-column: 2 / -1;
  font-size: 0.8125rem;
  color: var(--muted);
}

.roster li.is-new {
  animation: row-flash 1.6s ease-out;
}

@keyframes row-flash {
  from {
    background: var(--sticker);
  }
  to {
    background: transparent;
  }
}

.roster .empty {
  display: block;
  padding: 14px 4px;
  color: var(--ink-soft);
}

.not-found {
  max-width: 30em;
  padding: 24px 18px;
  background: var(--card);
  border-radius: 18px;
}

.not-found h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 900;
}

.not-found p {
  margin: 0;
}

.not-found p + p {
  margin-top: 12px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.not-found-page {
  margin-top: 24px;
}
