/* MakanApa: kopitiam signboard. Cream table-top page, one jade enamel sign, chilli red only for the main action
   and the pointer, enamel tints on the wheel, a striped shop awning over the counter where the result appears.
   Type is Archivo in three roles: condensed sign capitals, semi-condensed button capitals, small spaced labels;
   everything you read stays in sentence case. Shapes use three radii and 1px lines. */
:root {
  color-scheme: light dark;
  --bg: #F4EBDA;
  --surface: #FFFAF0;
  --ink: #1D2620;
  --muted: #5F6559;
  --hair: #E6D9C1;
  --fill: #EFE4CF;            /* quiet fields and chips */
  --accent: #C3301D;          /* chilli: 5.3:1 with the cream text on it */
  --on-accent: #FFF7E8;
  --accent-ink: #B02B1A;      /* chilli as text on cream */
  --jade: #0E5A44;            /* the sign */
  --on-jade: #F8EED9;
  --jade-ink: #0E5A44;        /* jade as text and lines */
  --shadow: rgb(70 45 10 / .16);
  /* wheel: enamel tints with cream gaps; app.js reads these */
  --gap: #FFFAF0;
  --slice-ink: #1D2620;
  --s1: #C3DFCF;
  --s2: #F5CFBD;
  --s3: #F3DA96;
  --s4: #C8DEE7;
  --s5: #EACDAC;
  --font: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --wheel-font: var(--font);
  --edge: 18px;
  --r-lg: 16px;               /* sign, cards, sheets */
  --r-md: 10px;               /* buttons, inputs, chips */
  --r-sm: 6px;                /* tags */
  --dock: calc(100px + env(safe-area-inset-bottom));
  /* one jade and one cream stripe, each ending in a scallop, with a soft shadow under the edge */
  --awning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='20'%3E%3Cpath d='M0 0h44v9.5a11 9 0 0 1-22 0a11 9 0 0 1-22 0z' fill='%23463214' fill-opacity='.18'/%3E%3Cpath d='M0 0h22v8a11 9 0 0 1-22 0z' fill='%230E5A44'/%3E%3Cpath d='M22 0h22v8a11 9 0 0 1-22 0z' fill='%23F8EED9'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15120E;
    --surface: #211C16;
    --ink: #F4EBDA;
    --muted: #B5AA95;
    --hair: #362E25;
    --fill: #2C251D;
    --accent-ink: #F2826C;
    --jade-ink: #86CBAE;
    --shadow: rgb(0 0 0 / .55);
    --gap: #15120E;
    --slice-ink: #F4EBDA;
    --s1: #23493A;
    --s2: #5B261B;
    --s3: #5A4515;
    --s4: #1F3D4B;
    --s5: #4D3524;
  }
}

/* Wheel and bill are two pages that move like one app: the browser keeps the old page on screen until the new one
   is ready, then cross-fades, while the jade sign and the counter glide into place (view-transition-name below).
   Browsers without cross-page view transitions just switch pages. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--font);
  letter-spacing: -0.006em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.muted { color: var(--muted); }
/* the browser's own surfaces in the palette: scrollbars, selected text, the text cursor */
:root { scrollbar-color: color-mix(in srgb, var(--ink) 24%, transparent) transparent; caret-color: var(--jade-ink); }
::selection { background: color-mix(in srgb, var(--jade-ink) 24%, transparent); }

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto; /* no overflow clip: on wide screens the counter's shadow fades out instead of ending in a hard edge */
}

/* Sign capitals: big, condensed and tight. text-box trims the title to its capitals, so padding round it is exact. */
h1 {
  font-size: 33px;
  font-stretch: 70%;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
  text-box: trim-both cap alphabetic;
}

/* Header: one full-width enamel sign; Split bill is a cream plate fixed to it */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(var(--edge), env(safe-area-inset-right)) 0 max(var(--edge), env(safe-area-inset-left));
}
.top p { white-space: nowrap; }
.sign {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 20px 16px 20px 20px; /* the same space round the type on every side */
  border-radius: var(--r-lg);
  background: var(--jade);
  color: var(--on-jade);
  box-shadow: inset 0 0 0 4px var(--jade), inset 0 0 0 5px rgb(248 238 217 / .5); /* the fine line inside an enamel sign's edge */
  view-transition-name: sign; /* becomes the bill page's title sign */
}
.sign__text { min-width: 0; }
.sign__sub { margin-top: 11px; font-size: 15px; font-weight: 500; color: rgb(248 238 217 / .8); text-box: trim-both cap alphabetic; }
.sign__btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px 0 11px;
  border-radius: var(--r-md);
  background: var(--on-jade);
  color: var(--jade);
  font-size: 15px;
  font-stretch: 88%;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .025em;
  text-decoration: none;
  touch-action: manipulation;
  transition: transform .15s ease, background-color .15s ease;
}
.sign__btn:active { transform: scale(.96); }
.sign__btn:focus-visible { outline: 3px solid var(--on-jade); outline-offset: 2px; }
/* Add to Home Screen: a small link in the sign. 44px to tap, laid out as its text; block-level, so no line box adds space under it */
.install {
  display: flex;
  align-items: center;
  gap: 5px;
  width: max-content;
  margin: -6px 0 -17px -2px;
  padding: 12px 2px;
  border: 0;
  background: none;
  color: var(--on-jade);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  touch-action: manipulation;
}
.install[hidden] { display: none; }
.install:active { opacity: .5; }
.install:focus-visible { outline: 3px solid var(--on-jade); outline-offset: -8px; border-radius: 12px; }
.steps { display: grid; gap: 12px; padding: 8px var(--edge) 18px calc(var(--edge) + 22px); font-size: 17px; }
.steps li::marker { color: var(--accent-ink); font-weight: 700; }

/* Wheel: a jade rim, and a chilli pin that rests on the rim instead of covering the winner's name */
.stage { position: relative; flex: 1; min-height: 0; }
.fit {
  position: absolute;
  inset: 30px max(calc(var(--edge) + 6px), env(safe-area-inset-right)) calc(var(--dock) + 26px) max(calc(var(--edge) + 6px), env(safe-area-inset-left));
  display: grid;
  justify-items: center;
  align-items: center;
}
.wheel { position: relative; line-height: 0; filter: drop-shadow(0 12px 20px var(--shadow)); }
.wheel canvas { display: block; border-radius: 50%; box-shadow: 0 0 0 6px var(--jade); cursor: pointer; touch-action: manipulation; }
.wheel canvas[aria-disabled="true"] { cursor: default; } /* one option: nothing to spin */
.pointer {
  position: absolute;
  top: -21px;
  left: 50%;
  translate: -50% 0;
  rotate: 45deg;
  z-index: 1;
  width: 21px;
  height: 21px;
  border-radius: 50% 50% 3px 50%; /* turned 45deg, the sharp corner points down */
  background: var(--accent);
  box-shadow: 0 0 0 2.5px var(--surface);
}
.msg {
  align-self: center;
  max-width: 28ch;
  text-align: center;
  font-size: 24px;
  font-stretch: 70%;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
  text-wrap: balance;
}

/* Buttons: semi-condensed capitals; red for the main action, a jade line for the rest */
.btn {
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--r-md);
  font: inherit;
  font-size: 16px;
  font-stretch: 88%;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .025em;
  color: var(--ink);
  background: var(--fill);
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, opacity .15s ease;
}
.btn:active:not(:disabled) { transform: scale(.97); opacity: .75; }
.btn:disabled { opacity: .4; cursor: default; }
.btn:focus-visible, .chip:focus-visible { outline: 3px solid var(--jade-ink); outline-offset: 2px; }
.btn--main { background: var(--accent); color: var(--on-accent); box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 60%, #000); }
.btn--main:active:not(:disabled) { transform: translateY(2px); opacity: 1; box-shadow: 0 0 0 color-mix(in srgb, var(--accent) 60%, #000); }
.btn--quiet { background: none; color: var(--jade-ink); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--jade-ink) 65%, transparent); }
.btn--text {
  min-height: 48px;
  padding: 0 2px;
  background: none;
  color: var(--accent-ink);
  font-stretch: 100%;
  font-weight: 600;
  text-transform: none;
  letter-spacing: -0.006em;
}
.btn--wide { width: 100%; }
@media (hover: hover) {
  .btn--main:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 90%, #000); }
  .btn--quiet:hover:not(:disabled) { background: color-mix(in srgb, var(--jade-ink) 7%, transparent); }
  .chip[data-state="off"]:hover { background: color-mix(in srgb, var(--fill) 88%, var(--ink)); }
  .btn--text:hover:not(:disabled) { opacity: .75; }
  .sign__btn:hover { background: #FFFFFF; }
}

/* Dock: the counter, solid cream under a striped awning. The result grows out of the action bar, the wheel never moves */
.dock {
  position: absolute;
  inset: auto 0 0 0;
  padding: 34px max(var(--edge), env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(var(--edge), env(safe-area-inset-left));
  background: var(--surface);
  box-shadow: 0 -10px 30px var(--shadow);
  view-transition-name: dock; /* the same counter on both pages */
}
.dock::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 20px;
  background: var(--awning) 50% 0 / 44px 20px repeat-x;
}
.dock__row { display: flex; gap: 10px; }
.dock__row .btn--main { flex: 1; }
.result { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .4s cubic-bezier(.2, .9, .25, 1); }
.result.open { grid-template-rows: 1fr; }
.result__in { overflow: hidden; min-height: 0; }
/* the result reads like the shop's own sign */
#resultLabel, .group h3 {      /* small labels: full width, spaced capitals */
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
}
#resultLabel { color: var(--accent-ink); }
.result h2 {
  font-size: clamp(38px, 12vw, 50px);
  font-stretch: 70%;
  font-weight: 800;
  line-height: .92;
  text-transform: uppercase;
  letter-spacing: 0;
  text-wrap: balance;
  overflow-wrap: anywhere;
  margin: 6px 0 8px;
}
.result__acts { display: flex; gap: 10px; margin: 16px 0 10px; }
.result__acts #remove { flex: 1; }
.btn--icon { display: inline-grid; place-items: center; width: 52px; padding: 0; flex: none; }
.btn--icon.is-done { background: var(--jade-ink); color: var(--surface); } /* link copied */
.meta { color: var(--muted); font-weight: 500; margin-bottom: 12px; }
.meta span + span::before { content: "·"; margin: 0 7px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 4px 10px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--jade) 7%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--jade-ink) 45%, transparent);
  color: var(--jade-ink);
  font-weight: 600;
  line-height: 1.3;
}
#remove[hidden] { display: none; }
.result__acts:has(#remove[hidden]) { justify-content: flex-end; }

/* Sheets */
.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: rise .35s cubic-bezier(.2, .9, .25, 1); }
.sheet::before { content: ""; align-self: center; flex: none; width: 36px; height: 5px; margin-top: 8px; border-radius: 3px; background: var(--hair); }
.sheet::backdrop { background: rgb(0 0 0 / .35); }
@keyframes rise { from { transform: translateY(100%); } }
.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px var(--edge) 0;
}
.sheet__head h2 { font-size: 30px; font-stretch: 70%; font-weight: 800; text-transform: uppercase; letter-spacing: 0; }
.hint { padding: 0 var(--edge); }
.sheet__body { overflow-y: auto; padding: 6px 0 14px; }
.sheet__foot { padding: 14px var(--edge) max(16px, env(safe-area-inset-bottom)); box-shadow: 0 -0.5px 0 var(--hair); }
.group h3 { color: var(--muted); padding: 18px var(--edge) 8px; }
/* chips wrap, so every option is visible without sideways scrolling */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 var(--edge); }
.chip {
  flex: none;
  min-height: 48px;
  padding: 0 15px;
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  background: var(--fill);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-stretch: 94%;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.chip:active { transform: scale(.96); }
.chip__n { margin-left: 7px; font-size: 14px; font-weight: 500; opacity: .6; }
/* include is jade, exclude is struck through and dashed */
.chip[data-state="in"] { background: var(--jade); color: var(--on-jade); }
.chip[data-state="out"] { background: none; border-style: dashed; border-color: var(--muted); color: var(--muted); text-decoration: line-through; }

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