/* Cofelty Core UI: token + komponen bersama kasir dan menu QR.
   Design system: docs/design/design-system.md. Brand: docs/brand/style-tokens.css (web Cofelty).
   Font lokal (offline): Orbitron + Tektur dari brand book, Saira + Share Tech Mono dari Google Fonts (OFL). */

@font-face { font-family: "Orbitron"; src: url("fonts/Orbitron-VariableFont_wght.ttf") format("truetype"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Tektur"; src: url("fonts/Tektur-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Tektur"; src: url("fonts/Tektur-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Tektur"; src: url("fonts/Tektur-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Saira"; src: url("fonts/Saira.woff2") format("woff2"); font-weight: 300 600; font-display: swap; }
@font-face { font-family: "Share Tech Mono"; src: url("fonts/ShareTechMono.woff2") format("woff2"); font-weight: 400; font-display: swap; }

/* Palet "Night · Crema · Copper" (disetujui Rhede 04.12.2026, spek: Rhede OS/Cofelty/Output/cofelty-pos/palet-identitas/).
   Peran, bukan warna: dua tema memakai nama token yang sama. Night = night 60 / crema 30 / copper 8, Day = crema 60 / night 30 / copper 8.
   Satu tombol isi copper per layar (--act). Pilihan aktif = --sel. Status proses = --stat (mist). Sinyal = --sig (ember). Hijau hanya logo resmi.
   Kertas (struk, tiket, docket, invoice) sama di dua tema. Tema dipilih lewat <html data-theme="night|day">. */
:root, [data-theme="night"] {
  color-scheme: dark;
  --bg: #121512; --bg-2: #1B1F1B; --panel: #252A25; --panel-2: #2E342E;
  --ink: #F6ECDF; --ink-2: #C9C0B5; --ink-3: #A9A298;          /* crema 15.7:1, stone 10.6:1, label 7.2:1 di night */
  --line: rgba(246, 236, 223, .12); --line-2: rgba(246, 236, 223, .24);
  --tint: rgba(246, 236, 223, .05); --tint-2: rgba(246, 236, 223, .09);
  --act: #D4904A; --act-hover: #E0A262; --act-ink: #121512;    /* night di copper 6.9:1 */
  --money: #E8B07A;                                            /* copper text 9.6:1 */
  --sel: #F6ECDF; --sel-ink: #121512;
  --stat: #8A9AAD;                                             /* mist 6.6:1 */
  --sig: #FF5A22; --sig-ink: #FF6A36;                          /* ember: titik/isi; teks 6.3:1 */
  --ring: #E0A262;
  --glass: rgba(18, 21, 18, .72);
  --glow: rgba(212, 144, 74, .10);
  --grain-op: .05; --grain-blend: overlay;

}
[data-theme="day"] {
  color-scheme: light;
  --bg: #F6ECDF; --bg-2: #FBF6EF; --panel: #EADFCF; --panel-2: #E1D4C1;
  --ink: #121512; --ink-2: #5B5348; --ink-3: #6B6257;          /* night 15.7:1, 6.5:1, 5.2:1 di crema */
  --line: rgba(18, 21, 18, .12); --line-2: rgba(18, 21, 18, .26);
  --tint: rgba(18, 21, 18, .04); --tint-2: rgba(18, 21, 18, .08);
  --act: #D4904A; --act-hover: #C78039; --act-ink: #121512;
  --money: #8F4A03;                                            /* copper ink 5.7:1 */
  --sel: #121512; --sel-ink: #F6ECDF;
  --stat: #4F6275;                                             /* mist ink 5.6:1 */
  --sig: #FF5A22; --sig-ink: #B23A0E;                          /* ember ink 5.1:1 */
  --ring: #8F4A03;
  --glass: rgba(246, 236, 223, .78);
  --glow: rgba(212, 144, 74, .12);
  --grain-op: .16; --grain-blend: overlay;

}
:root {
  /* Blok angka kunci (kembalian, total, selisih): night di dua tema, angka crema, label copper text. */
  --key: var(--panel); --key-ink: #F6ECDF; --key-label: #E8B07A;
  /* Kertas: tidak ikut tema. */
  --paper: #F6ECDF; --paper-2: #EADFCF; --paper-ink: #121512; --paper-ink-2: #5B5348; --caramel: #A55704;
}
html[data-theme="day"] { --key: #121512; --shadow: 0 8px 24px rgba(60, 40, 20, .14); }
:root {
  --f-display: "Orbitron", "Arial Black", sans-serif;
  --f-head: "Tektur", "Arial Narrow", sans-serif;
  --f-body: "Saira", system-ui, sans-serif;
  --f-data: "Share Tech Mono", ui-monospace, monospace;

  --r: 2px; --r-sheet: 14px;
  --hit: 48px;
  --t-fast: 120ms; --t-mid: 220ms; --t-slow: 360ms;
  --ease: cubic-bezier(.2, .7, .1, 1); --ease-out: cubic-bezier(.4, 0, .2, 1);
  --shadow: 0 10px 30px rgba(0, 0, 0, .38);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; background: var(--bg); }
body {
  margin: 0; color: var(--ink); font: 400 16px/1.5 var(--f-body); font-synthesis: none;
  background: radial-gradient(60% 560px at 100% 0, var(--glow), transparent 70%), linear-gradient(180deg, var(--bg-2), var(--bg) 900px) fixed;
  min-height: 100dvh; overflow-x: clip;
}
body::after { content: ""; position: fixed; inset: 0; background: var(--grain); opacity: var(--grain-op); pointer-events: none; z-index: 100; mix-blend-mode: var(--grain-blend); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
::selection { background: var(--act); color: var(--act-ink); }

/* Tipe */
.display { font: 800 28px/1.05 var(--f-display); letter-spacing: -.01em; margin: 0; }
.head { font: 600 16px/1.25 var(--f-head); margin: 0; }
.mono { font-family: var(--f-data); font-variant-numeric: tabular-nums; }
.micro { font: 12px/1.3 var(--f-data); text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); }
.muted { color: var(--ink-2); }

/* Tombol */
.btn { text-decoration: none; color: inherit;
  min-height: var(--hit); padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid var(--line-2); border-radius: var(--r); font: 600 15px/1 var(--f-head); letter-spacing: .02em;
  transition: transform var(--t-fast) var(--ease), background var(--t-mid), border-color var(--t-mid), color var(--t-mid), opacity var(--t-mid);
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-primary { background: var(--act); color: var(--act-ink); border-color: var(--act); }
.btn-primary:hover:not(:disabled) { background: var(--act-hover); border-color: var(--act-hover); }
.btn-ghost { border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); background: var(--tint); }
.btn-line:hover:not(:disabled) { border-color: var(--act); }
.btn-danger { border-color: var(--sig); color: var(--sig-ink); }
.btn-paper { background: var(--paper); color: var(--paper-ink); border-color: var(--paper); }
.btn-block { width: 100%; }
.btn-big { min-height: 60px; font-size: 17px; }
.btn .kbd { font: 12px var(--f-data); opacity: .7; }

/* Chip + segmented */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r);
  font: 500 14px/1 var(--f-head); color: var(--ink-2); transition: all var(--t-mid) var(--ease);
}
.chip[aria-pressed="true"] { background: var(--sel); color: var(--sel-ink); border-color: var(--sel); }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r); padding: 3px; gap: 3px; position: relative; }
.seg button { flex: 1; min-height: 42px; padding: 0 10px; font: 500 14px/1 var(--f-head); color: var(--ink-2); border-radius: 1px; position: relative; z-index: 1; transition: color var(--t-mid); white-space: nowrap; }
.seg button[aria-pressed="true"] { color: var(--sel-ink); }
.seg .seg-thumb { position: absolute; top: 3px; bottom: 3px; left: 0; background: var(--sel); border-radius: 1px; transition: transform var(--t-slow) var(--ease), width var(--t-slow) var(--ease); }

/* Input */
.field { display: grid; gap: 6px; }
.field label { font: 12px var(--f-data); text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); }
.input {
  min-height: var(--hit); width: 100%; padding: 0 14px; background: var(--tint); border: 1px solid var(--line-2);
  border-radius: var(--r); font-size: 16px; transition: border-color var(--t-mid), background var(--t-mid);
}
.input:focus { outline: none; border-color: var(--ring); background: var(--tint-2); }
textarea.input { padding: 12px 14px; min-height: 80px; resize: vertical; }
.field .err { color: var(--sig-ink); font-size: 13px; }

/* Panel dengan tanda HUD di sudut */
.hud { position: relative; }
.hud::before, .hud::after { content: ""; position: absolute; width: 9px; height: 9px; border: 0 solid var(--ink-3); pointer-events: none; }
.hud::before { top: -1px; left: -1px; border-top-width: 1px; border-left-width: 1px; }
.hud::after { bottom: -1px; right: -1px; border-bottom-width: 1px; border-right-width: 1px; }

/* Bintang empat sudut (elemen tanda tangan, brand/cofelty-context.md) */
.star { width: 14px; height: 14px; flex: none; fill: var(--sig); }

/* Harga */
.price { font: 15px var(--f-data); font-variant-numeric: tabular-nums; white-space: nowrap; }
.price s { opacity: .5; margin-right: 6px; }
.price .disc { color: var(--money); }

/* Badge status */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 999px; font: 12px/1 var(--f-data); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); white-space: nowrap; }
.badge-sig { border-color: var(--sig); color: var(--sig-ink); }
.badge-ok { border-color: var(--money); color: var(--money); }
.badge-stat { border-color: var(--stat); color: var(--stat); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

/* Sheet (opsi, bayar). Tablet: panel tengah; HP: dari bawah. */
.scrim { position: fixed; inset: 0; background: rgba(8, 10, 8, .62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 50; opacity: 0; transition: opacity var(--t-slow) var(--ease-out); }
.scrim.on { opacity: 1; }
/* Sheet bertumpuk (mis. PIN manager di atas diskon): scrim kedua menutup sheet pertama. */
.sheet ~ .scrim { z-index: 52; }
.sheet ~ .sheet { z-index: 53; }
.sheet {
  position: fixed; z-index: 51; left: 50%; bottom: 0; width: min(560px, 100%); max-height: min(88dvh, 860px);
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--bg-2); border: 1px solid var(--line-2); border-bottom: 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .5); transform: translate(-50%, 104%); transition: transform var(--t-slow) var(--ease);
}
.sheet.on { transform: translate(-50%, 0); }
.sheet-head { padding: 18px 20px 12px; display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.sheet-body { overflow: auto; padding: 16px 20px; overscroll-behavior: contain; }
.sheet-foot { padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg-2); }
.sheet .grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 8px auto 0; }
@media (min-width: 900px) {
  .sheet.center { top: 50%; bottom: auto; border-radius: var(--r); border-bottom: 1px solid var(--line-2); transform: translate(-50%, -46%) scale(.98); opacity: 0; transition: transform var(--t-slow) var(--ease), opacity var(--t-mid); }
  .sheet.center.on { transform: translate(-50%, -50%); opacity: 1; }
  .sheet.center .grip { display: none; }
  .sheet.center { grid-template-rows: auto minmax(0, 1fr) auto; max-height: min(92dvh, 860px); } /* tanpa grip: 3 baris */
}
.x { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r); color: var(--ink-2); flex: none; }
.x:hover { color: var(--ink); border-color: var(--ink-2); }

/* Tombol tema Night / Day */
.theme-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r); color: var(--ink-2); flex: none; transition: color var(--t-mid), border-color var(--t-mid); }
.theme-btn:hover { color: var(--ink); border-color: var(--act); }

/* Grup opsi */
.opt-group + .opt-group { margin-top: 18px; }
.opt-group h4 { margin: 0 0 8px; display: flex; justify-content: space-between; font: 12px var(--f-data); text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.opt {
  min-height: 52px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--r); text-align: left;
  display: grid; gap: 2px; align-content: center; transition: all var(--t-mid) var(--ease); position: relative;
}
.opt b { font: 600 15px/1.2 var(--f-head); }
.opt small { font: 12px var(--f-data); color: var(--ink-3); }
.opt[aria-pressed="true"] { border-color: var(--sel); background: var(--sel); color: var(--sel-ink); }
.opt[aria-pressed="true"] small { color: inherit; opacity: .75; }
.opt[aria-pressed="true"]::after { content: ""; position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; background: var(--act); }
.opt:disabled { opacity: .35; text-decoration: line-through; cursor: not-allowed; }

/* Stepper qty */
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: var(--r); }
.qty button { width: var(--hit); height: var(--hit); display: grid; place-items: center; font: 600 22px/1 var(--f-head); color: var(--ink-2); }
.qty button:active { background: var(--tint-2); }
.qty output { min-width: 36px; text-align: center; font: 18px var(--f-data); }

/* Tiket kertas (order) dengan perforasi */
.ticket {
  --perf: 10px; background: var(--paper); color: var(--paper-ink); border-radius: var(--r); box-shadow: var(--shadow); position: relative;
  -webkit-mask: radial-gradient(circle 5px at 0 var(--perf-y, 64px), #0000 98%, #000) left / 51% 100% no-repeat, radial-gradient(circle 5px at 100% var(--perf-y, 64px), #0000 98%, #000) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 5px at 0 var(--perf-y, 64px), #0000 98%, #000) left / 51% 100% no-repeat, radial-gradient(circle 5px at 100% var(--perf-y, 64px), #0000 98%, #000) right / 51% 100% no-repeat;
}
/* Day: kertas crema di atas latar crema perlu dipisah; pakai kertas 2 + bayangan hangat. */
html[data-theme="day"] .ticket { background: var(--paper-2); box-shadow: 0 10px 28px rgba(60, 40, 20, .18); }
.ticket .perf { height: 0; border-top: 1.5px dashed rgba(18, 21, 18, .28); margin: 0 10px; }
.ticket .micro { color: var(--paper-ink-2); }

/* Toast */
.toasts { position: fixed; z-index: 80; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: min(460px, calc(100% - 32px)); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--sel); color: var(--sel-ink);
  border-radius: var(--r); font: 500 15px/1.35 var(--f-head); box-shadow: var(--shadow); animation: toast-in var(--t-slow) var(--ease) both;
}
.toast.err { background: var(--sig); color: var(--paper-ink); } /* teks gelap di oranye 5.6:1 (putih hanya 3.1:1) */
.toast.out { animation: toast-out var(--t-mid) var(--ease-out) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* Numpad (PIN, kas) */
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.numpad button {
  height: 68px; border: 1px solid var(--line); border-radius: var(--r); font: 600 26px/1 var(--f-display); color: var(--ink);
  transition: background var(--t-fast), transform var(--t-fast) var(--ease), border-color var(--t-fast);
}
.numpad button:active { background: var(--tint-2); border-color: var(--act); transform: scale(.96); }
.numpad .fn { font: 500 14px/1 var(--f-head); color: var(--ink-2); }

/* Gerak umum */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); } }
@keyframes blink { 50% { opacity: .25; } }
@keyframes spin { to { transform: rotate(360deg); } }
.rise { animation: rise var(--t-slow) var(--ease) both; }
.spin { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

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