/* Seri Aurelia — shared tokens & primitives (website + staff app) */
@import url('https://fonts.googleapis.com/css2?family=Marcellus&family=Hanken+Grotesk:wght@400;500;600;700&display=swap');

:root {
  /* Zamrud — the brand emerald, from the logo ground */
  --zamrud-950: #041C15;
  --zamrud-900: #06291F;
  --zamrud-800: #0B3628;
  --zamrud-700: #114636;
  --zamrud-600: #1A5A46;
  --zamrud-200: #C9DACF;
  --zamrud-100: #E1EBE3;

  /* Emas — leaf gold, from the logo strokes */
  --emas-700: #8E6D25;
  --emas-600: #A9852F;
  --emas-500: #C9A24A;
  --emas-300: #E6CC8A;
  --emas-100: #F6EDD3;

  /* Songket — the maroon kain in the banner; used for buyback, warnings, destructive */
  --songket-700: #5E1522;
  --songket-500: #8A2536;
  --songket-100: #F4E1E3;

  /* Kabus — jade mist surfaces for the app */
  --kabus: #ECEFE8;
  --kertas: #FAFBF7;
  --garis: #D6DDD2;
  --garis-kuat: #B9C4B6;

  --dakwat: #12251E;
  --dakwat-2: #4A5C54;
  --dakwat-3: #7A8A82;

  --ok: #2E7A55;
  --ok-100: #DDEFE4;
  --amaran: #A86A12;
  --amaran-100: #F7EBD3;

  --font-display: 'Marcellus', 'Cinzel', 'Times New Roman', serif;
  --font-ui: 'Hanken Grotesk', 'Segoe UI', system-ui, sans-serif;

  /* Type scale — 1.25 modular, 16px base */
  --t-xs: 0.75rem;
  --t-sm: 0.875rem;
  --t-md: 1rem;
  --t-lg: 1.25rem;
  --t-xl: 1.5625rem;
  --t-2xl: 1.953rem;
  --t-3xl: 2.441rem;
  --t-4xl: 3.052rem;
  --t-5xl: 3.815rem;

  /* Radius by hierarchy: controls < panels < sheets */
  --r-ctl: 10px;
  --r-panel: 16px;
  --r-sheet: 24px;
  --r-pill: 999px;

  --shadow-1: 0 1px 0 rgba(6, 41, 31, .04), 0 2px 6px -2px rgba(6, 41, 31, .10);
  --shadow-2: 0 18px 40px -18px rgba(6, 41, 31, .35);
  --shadow-gold: 0 0 0 1px rgba(201, 162, 74, .5), 0 10px 30px -10px rgba(201, 162, 74, .55);

  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --dur-1: 160ms;
  --dur-2: 320ms;
  --dur-3: 640ms;

  --gold-ink: linear-gradient(100deg, #8E6D25 0%, #E6CC8A 30%, #C9A24A 50%, #F4E3AF 68%, #A9852F 100%);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--t-md);
  line-height: 1.55;
  color: var(--dakwat);
  font-feature-settings: 'tnum' 1, 'cv11' 1;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--emas-500);
  outline-offset: 3px;
  border-radius: 6px;
}

.display { font-family: var(--font-display); font-weight: 400; letter-spacing: .01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--dakwat-2); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Gold leaf text with a slow light sweep */
.gold-text {
  background: var(--gold-ink);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: leaf-sweep 7s ease-in-out infinite;
}
@keyframes leaf-sweep {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Diamond mark — stroked so it can draw itself */
.mark { display: block; overflow: visible; }
.mark path, .mark polyline, .mark polygon {
  fill: none;
  stroke: url(#leaf);
  stroke-linejoin: miter;
  stroke-linecap: square;
}
.mark.draw path, .mark.draw polyline, .mark.draw polygon {
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  animation: draw-in 1.8s var(--ease-out) forwards;
}
.mark.draw :nth-child(2) { animation-delay: .25s; }
.mark.draw :nth-child(3) { animation-delay: .4s; }
.mark.draw :nth-child(4) { animation-delay: .7s; }
.mark.draw :nth-child(5) { animation-delay: .95s; }
@keyframes draw-in { to { stroke-dashoffset: 0; } }

/* ---------- Buttons ---------- */
.btn {
  --bg: var(--zamrud-800);
  --fg: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px;
  padding: .625rem 1.125rem;
  border: 1px solid transparent;
  border-radius: var(--r-ctl);
  background: var(--bg);
  color: var(--fg);
  font-weight: 600;
  font-size: var(--t-sm);
  text-decoration: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--dur-1) var(--ease-out), background var(--dur-2), box-shadow var(--dur-2);
}
.btn:hover { background: var(--zamrud-700); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn--gold {
  --bg: var(--emas-500);
  --fg: var(--zamrud-950);
  background: linear-gradient(180deg, #E2C478, var(--emas-500) 55%, #B89039);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
}
.btn--gold:hover { background: linear-gradient(180deg, #EBD08C, #CFA954 55%, #BF973F); box-shadow: var(--shadow-gold); }
/* Light glint that crosses gold buttons on hover */
.btn--gold::after {
  content: '';
  position: absolute; inset: -40% auto -40% -60%;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.65), transparent);
  transform: skewX(-20deg);
  transition: left 700ms var(--ease-out);
}
.btn--gold:hover::after { left: 130%; }

.btn--ghost { --bg: transparent; --fg: var(--dakwat); border-color: var(--garis-kuat); }
.btn--ghost:hover { background: var(--kertas); border-color: var(--zamrud-600); }
.btn--danger { --bg: var(--songket-500); }
.btn--danger:hover { background: var(--songket-700); }
.btn--sm { min-height: 34px; padding: .375rem .75rem; font-size: var(--t-xs); }
.btn--block { width: 100%; }

/* ---------- Form fields ---------- */
.field { display: grid; gap: .375rem; }
.field > span, .field > label { font-size: var(--t-sm); font-weight: 600; color: var(--dakwat); }
.field small { color: var(--dakwat-3); font-size: var(--t-xs); }
.input, .select {
  width: 100%;
  min-height: 46px;
  padding: .625rem .875rem;
  background: #fff;
  border: 1px solid var(--garis-kuat);
  border-radius: var(--r-ctl);
  transition: border-color var(--dur-1), box-shadow var(--dur-2);
  font-variant-numeric: tabular-nums;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--emas-500);
  box-shadow: 0 0 0 4px rgba(201, 162, 74, .2);
}
.input[readonly] { background: var(--kabus); color: var(--dakwat-2); }
.input-unit { position: relative; }
.input-unit .input { padding-right: 3.25rem; }
.input-unit i {
  position: absolute; right: .875rem; top: 50%; translate: 0 -50%;
  font-style: normal; font-size: var(--t-sm); color: var(--dakwat-3); pointer-events: none;
}
.input-unit--pre .input { padding-left: 2.75rem; padding-right: .875rem; }
.input-unit--pre i { left: .875rem; right: auto; }

/* ---------- Chips & tags ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .25rem .625rem;
  border-radius: var(--r-pill);
  font-size: var(--t-xs);
  font-weight: 600;
  background: var(--zamrud-100);
  color: var(--zamrud-700);
  white-space: nowrap;
}
.chip--gold { background: var(--emas-100); color: var(--emas-700); }
.chip--songket { background: var(--songket-100); color: var(--songket-500); }
.chip--amaran { background: var(--amaran-100); color: var(--amaran); }
.chip--ok { background: var(--ok-100); color: var(--ok); }
.chip--dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.purity {
  display: inline-grid; place-items: center;
  min-width: 44px; height: 26px; padding: 0 .5rem;
  border-radius: 6px;
  font-weight: 700; font-size: var(--t-xs);
  letter-spacing: .02em;
}
.purity--999 { background: linear-gradient(135deg, #F4E3AF, #D9B860); color: #4A3A10; }
.purity--916 { background: linear-gradient(135deg, #EED493, #C9A24A); color: #3E300C; }
.purity--750 { background: linear-gradient(135deg, #E8D3B0, #B9925E); color: #3B2A14; }

/* ---------- Toast ---------- */
.toasts {
  position: fixed; z-index: 100;
  right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  display: grid; gap: .5rem;
  width: min(380px, calc(100vw - 2rem));
}
.toast {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .875rem 1rem;
  background: var(--zamrud-900);
  color: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  border-left: 3px solid var(--emas-500);
  animation: toast-in var(--dur-2) var(--ease-spring);
  font-size: var(--t-sm);
}
.toast.out { animation: toast-out var(--dur-2) var(--ease-out) forwards; }
.toast--songket { border-left-color: #E07A8A; }
.toast b { display: block; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

/* ---------- Dialog ---------- */
dialog.sheet {
  border: 0; padding: 0;
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  border-radius: var(--r-sheet);
  background: var(--kertas);
  color: var(--dakwat);
  box-shadow: 0 40px 80px -30px rgba(4, 28, 21, .6);
}
dialog.sheet[open] { animation: sheet-in var(--dur-2) var(--ease-spring); }
dialog.sheet::backdrop { background: rgba(4, 28, 21, .55); backdrop-filter: blur(4px); animation: fade-in var(--dur-2); }
dialog.sheet.closing { animation: sheet-out 200ms var(--ease-out) forwards; }
.sheet__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.5rem 1.5rem .75rem; }
.sheet__head h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: var(--t-xl); }
.sheet__body { padding: .5rem 1.5rem 1.5rem; overflow: auto; }
.sheet__foot { display: flex; gap: .75rem; justify-content: flex-end; padding: 1rem 1.5rem 1.5rem; border-top: 1px solid var(--garis); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--garis);
  background: transparent;
  cursor: pointer;
  transition: background var(--dur-1), transform var(--dur-1);
}
.icon-btn:hover { background: var(--kabus); transform: rotate(90deg); }
.icon-btn svg { width: 18px; height: 18px; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(.97); } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }

/* Reveal-on-scroll primitive (JS adds .in) */
[data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out); }
[data-reveal].in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
  .mark.draw * { stroke-dashoffset: 0 !important; }
}
