/* ============================================================================
   SingPickle
   Singtel red as a single accent on a near-monochrome surface. The court grid
   is the product; everything else gets out of its way.
   ========================================================================= */

:root {
  /* Brand ------------------------------------------------------------------ */
  --red: #ee3124;
  --red-dark: #c8261b;
  --red-tint: #fdeceb;

  /* Greys ------------------------------------------------------------------ */
  --ink: #1d1d1f;
  --ink-2: #424245;
  --ink-3: #6e6e73;
  --ink-4: #86868b;
  --line: #d2d2d7;
  --line-2: #e8e8ed;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #fafafc;

  /* Status ----------------------------------------------------------------- */
  --green: #1d8a4e;
  --green-tint: #e8f5ee;
  --amber: #9a6700;
  --amber-tint: #fff4e0;

  /* Type ------------------------------------------------------------------- */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Space ------------------------------------------------------------------ */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-pill: 980px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 3px rgba(0, 0, 0, .06);
  --shadow: 0 4px 16px rgba(0, 0, 0, .08);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, .16);

  --ease: cubic-bezier(.4, 0, .2, 1);
  --fast: 150ms var(--ease);
  --med: 220ms var(--ease);

  --header-h: 56px;
  --wrap: 1120px;
}

/* Reset --------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* Layout -------------------------------------------------------------------- */

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.wrap--narrow { max-width: 460px; }
.page { padding: 28px 0 64px; }

.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: 12px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

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

.header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line-2);
}
.header__inner { display: flex; align-items: center; gap: 8px; height: var(--header-h); }

.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 600; letter-spacing: -.02em;
  text-decoration: none; margin-right: 12px; white-space: nowrap;
}
.brand__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--red); flex: none;
}

.nav { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 6px 11px; border-radius: var(--r-pill);
  font-size: 13.5px; color: var(--ink-3); text-decoration: none;
  white-space: nowrap; transition: color var(--fast), background var(--fast);
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 500; background: var(--surface-2); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--ink); color: #fff;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  text-decoration: none;
}

/* Type ---------------------------------------------------------------------- */

.title { font-size: 30px; font-weight: 600; letter-spacing: -.025em; line-height: 1.1; }
.title--lg { font-size: 38px; }
.subtitle { font-size: 15px; color: var(--ink-3); margin-top: 6px; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-4); }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tabular { font-variant-numeric: tabular-nums; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px; border: 1px solid transparent; border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 500; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  transition: background var(--fast), border-color var(--fast), transform var(--fast), opacity var(--fast);
  border-color: var(--line);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

.btn--primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn--primary:hover { background: var(--red-dark); border-color: var(--red-dark); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-3); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn--danger { color: var(--red); border-color: var(--line); background: var(--surface); }
.btn--danger:hover { background: var(--red-tint); border-color: var(--red); }

.btn--block { width: 100%; }
.btn--sm { padding: 6px 13px; font-size: 13px; }
.btn--lg { padding: 12px 26px; font-size: 15px; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card__body { padding: 22px; }
.card__head {
  padding: 18px 22px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card__foot { padding: 16px 22px; border-top: 1px solid var(--line-2); background: var(--surface-3); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* Forms --------------------------------------------------------------------- */

.field { display: block; }
.field + .field { margin-top: 16px; }
.label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.hint { font-size: 12.5px; color: var(--ink-4); margin-top: 6px; line-height: 1.45; }

.input, .select, .textarea {
  width: 100%; padding: 10px 13px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  font-size: 15px; color: var(--ink);
  transition: border-color var(--fast), box-shadow var(--fast);
  appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-tint);
}
.input::placeholder { color: var(--ink-4); }
.textarea { min-height: 76px; resize: vertical; }

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236e6e73' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  padding-right: 34px;
}

.check { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--red); flex: none; }

/* PIN input ----------------------------------------------------------------- */

.pin {
  width: 100%; padding: 16px;
  font-family: var(--mono); font-size: 30px; font-weight: 600;
  letter-spacing: 14px; text-indent: 14px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); transition: border-color var(--fast), box-shadow var(--fast);
}
.pin:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-tint); }

/* Alerts -------------------------------------------------------------------- */

.alert {
  padding: 12px 15px; border-radius: var(--r);
  font-size: 14px; line-height: 1.5;
  border: 1px solid var(--line-2); background: var(--surface-3); color: var(--ink-2);
}
.alert--error { background: var(--red-tint); border-color: #f6c7c3; color: #8f1c13; }
.alert--ok { background: var(--green-tint); border-color: #bfe3cf; color: #14653a; }
.alert--info { background: var(--amber-tint); border-color: #f0dcb4; color: #7a5200; }

/* Badges -------------------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  background: var(--surface-2); color: var(--ink-3); white-space: nowrap;
}
.badge--open { background: var(--green-tint); color: var(--green); }
.badge--full { background: var(--surface-2); color: var(--ink-3); }
.badge--mine { background: var(--red-tint); color: var(--red-dark); }
.badge--admin { background: var(--ink); color: #fff; }
.badge--super { background: var(--red); color: #fff; }
.badge--cancelled { background: var(--surface-2); color: var(--ink-4); text-decoration: line-through; }

/* Date strip ---------------------------------------------------------------- */

.datestrip {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 4px 0 12px; scrollbar-width: none; scroll-snap-type: x proximity;
}
.datestrip::-webkit-scrollbar { display: none; }

.dpill {
  flex: none; width: 62px; padding: 9px 0 10px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); text-align: center; text-decoration: none;
  scroll-snap-align: start;
  transition: border-color var(--fast), background var(--fast), transform var(--fast);
}
.dpill:hover { border-color: var(--line); transform: translateY(-1px); }
.dpill__dow { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-4); }
.dpill__num { display: block; font-size: 19px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; }
.dpill[aria-current="date"] { background: var(--ink); border-color: var(--ink); }
.dpill[aria-current="date"] .dpill__dow { color: rgba(255, 255, 255, .62); }
.dpill[aria-current="date"] .dpill__num { color: #fff; }
.dpill--today .dpill__num { color: var(--red); }
.dpill--today[aria-current="date"] .dpill__num { color: #fff; }
.dpill--closed { opacity: .4; }

/* Segmented control --------------------------------------------------------- */

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: var(--r-pill);
}
.segmented a {
  padding: 6px 15px; border-radius: var(--r-pill);
  font-size: 13.5px; color: var(--ink-3); text-decoration: none;
  transition: background var(--fast), color var(--fast);
}
.segmented a:hover { color: var(--ink); }
.segmented a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: var(--shadow-sm); }

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

.grid-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; scrollbar-width: thin; }

.courts {
  display: grid; gap: 12px; min-width: min-content;
  grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr);
  align-items: start;
}

.court { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); overflow: hidden; }
.court__head { padding: 13px 15px; border-bottom: 1px solid var(--line-2); background: var(--surface-3); }
.court__name { font-size: 14.5px; font-weight: 600; letter-spacing: -.01em; }
.court__meta { font-size: 12px; color: var(--ink-4); margin-top: 1px; }
.court__slots { padding: 7px; display: flex; flex-direction: column; gap: 5px; }

.slot {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 11px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: var(--surface-2); text-align: left; text-decoration: none;
  color: var(--ink); cursor: pointer; position: relative;
  transition: background var(--fast), border-color var(--fast), transform var(--fast);
}
.slot__time { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-3); flex: none; width: 42px; }
.slot__body { min-width: 0; flex: 1; }
.slot__label { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot__sub { font-size: 11.5px; color: var(--ink-4); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.slot--free { background: var(--surface); border-color: var(--line-2); }
.slot--free:hover { border-color: var(--red); background: var(--red-tint); transform: translateY(-1px); }
.slot--free .slot__label { color: var(--ink-4); font-weight: 400; }
.slot--free:hover .slot__label { color: var(--red-dark); }

.slot--booked { background: var(--surface-2); cursor: default; }
.slot--open { background: var(--green-tint); border-color: #cfe9db; }
.slot--open:hover { border-color: var(--green); }
.slot--mine { background: var(--red-tint); border-color: #f6cdc9; }
.slot--past, .slot--closed { background: transparent; border-color: var(--line-2); border-style: dashed; opacity: .5; cursor: default; }
.slot--past .slot__label, .slot--closed .slot__label { color: var(--ink-4); font-weight: 400; }
.slot--cont { opacity: .999; margin-top: -5px; border-top-left-radius: 0; border-top-right-radius: 0; border-top: 0; }
.slot--cont .slot__body, .slot--cont .slot__time { visibility: hidden; }
.slot--cont { padding-top: 4px; padding-bottom: 10px; min-height: 0; }

/* Lists --------------------------------------------------------------------- */

.list { display: flex; flex-direction: column; }
.list__item { padding: 15px 0; border-top: 1px solid var(--line-2); display: flex; align-items: center; gap: 14px; }
.list__item:first-child { border-top: 0; }
.list__main { min-width: 0; flex: 1; }
.list__title { font-size: 15px; font-weight: 500; letter-spacing: -.01em; }
.list__sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

.when { flex: none; width: 92px; }
.when__day { font-size: 13px; font-weight: 600; }
.when__time { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Table --------------------------------------------------------------------- */

.table-scroll { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: 0 12px 10px; font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--ink-4); white-space: nowrap;
}
.table td { padding: 12px; border-top: 1px solid var(--line-2); vertical-align: middle; }
.table tr:hover td { background: var(--surface-3); }
.table td:first-child, .table th:first-child { padding-left: 0; }
.table td:last-child, .table th:last-child { padding-right: 0; text-align: right; }

/* Empty state --------------------------------------------------------------- */

.empty { padding: 52px 20px; text-align: center; }
.empty__title { font-size: 16px; font-weight: 500; }
.empty__text { font-size: 14px; color: var(--ink-3); margin-top: 5px; }

/* Dialog -------------------------------------------------------------------- */

dialog.sheet {
  width: min(460px, calc(100vw - 32px));
  padding: 0; border: 0; border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-lg);
  color: var(--ink);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, .32); backdrop-filter: blur(3px); }
dialog.sheet[open] { animation: sheet-in var(--med); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px) scale(.99); } }

.sheet__head { padding: 20px 22px 0; }
.sheet__body { padding: 18px 22px; }
.sheet__foot { padding: 16px 22px 20px; display: flex; gap: 10px; }
.sheet__foot .btn { flex: 1; }

/* Stepper ------------------------------------------------------------------- */

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper__btn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); font-size: 17px; cursor: pointer; color: var(--ink-2);
  transition: background var(--fast), border-color var(--fast);
}
.stepper__btn:hover { background: var(--surface-2); border-color: var(--ink-4); }
.stepper__value {
  min-width: 52px; text-align: center;
  font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.stepper__note { font-size: 12.5px; color: var(--ink-4); margin-left: 6px; }

/* Chips --------------------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 7px 13px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); font-size: 13.5px; cursor: pointer;
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}
.chip:hover { border-color: var(--ink-4); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip:has(input:focus-visible) { outline: 2px solid var(--red); outline-offset: 2px; }

/* Footer -------------------------------------------------------------------- */

.footer { padding: 28px 0 40px; text-align: center; font-size: 12.5px; color: var(--ink-4); }

/* Responsive ---------------------------------------------------------------- */

@media (max-width: 720px) {
  .title { font-size: 25px; }
  .title--lg { font-size: 30px; }
  .page { padding: 20px 0 48px; }
  .wrap { padding: 0 16px; }
  .grid-scroll { margin: 0 -16px; padding: 0 16px; }
  .courts { grid-auto-columns: minmax(190px, 82vw); }
  .card__body, .card__head { padding: 18px; }
  .table-scroll { margin: 0 -18px; padding: 0 18px; }
  .when { width: 78px; }
  .list__item { gap: 10px; }
  dialog.sheet {
    width: 100vw; max-width: 100vw; margin: auto 0 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(24px); } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  .slot--free:hover, .dpill:hover { transform: none; }
}

@media print {
  .header, .btn, .datestrip { display: none; }
  body { background: #fff; }
}
