/* Hitung Toko: shared styles for every page. Inter everywhere, one type scale.
   Each theme swaps color, radius, border, a background ornament, and one small
   ornament per input (top right). Ornament paths are root-absolute so every page depth works. */

:root {
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-sm: 13px; --fs-base: 15px; --fs-lg: 17px; --fs-xl: 22px; --fs-hero: clamp(20px, 5.6vw, 24px);
  --gap: 12px;
  color-scheme: light;
}

body[data-tema="bersih"] {
  --bg: #f5f7fa; --surface: #ffffff; --ink: #111827; --muted: #5b6472;
  --line: #e2e6ec; --accent: #2563eb; --accent-ink: #ffffff; --soft: #e8effd;
  --r: 12px; --r-sm: 8px; --border: 1px solid var(--line); --shadow: 0 1px 2px rgba(17,24,39,.06);
  --deco: none; --o1: none; --o2: none; --o3: none;
}
body[data-tema="imut"] {
  --bg: #fff5f9; --surface: #ffffff; --ink: #4a2a3f; --muted: #8a6478;
  --line: #f6d3e4; --accent: #ff5c9a; --accent-ink: #ffffff; --soft: #ffe4ef;
  --r: 24px; --r-sm: 16px; --border: 2px solid #f6d3e4; --shadow: 0 6px 0 #f6d3e4;
  --deco: radial-gradient(circle at 12% 18%, #ffd1e4 0 6px, transparent 7px),
          radial-gradient(circle at 88% 8%, #cfeeff 0 9px, transparent 10px),
          radial-gradient(circle at 92% 62%, #ffe7a8 0 5px, transparent 6px),
          radial-gradient(circle at 6% 78%, #d6f5e3 0 8px, transparent 9px);
  --o1: url("/ornamen/imut-1.png"); --o2: url("/ornamen/imut-2.png"); --o3: url("/ornamen/imut-3.png");
}
body[data-tema="kebun"] {
  --bg: #eef5e8; --surface: #fbfdf8; --ink: #203a25; --muted: #5a6e5c;
  --line: #cfe0c4; --accent: #3f8f4f; --accent-ink: #ffffff; --soft: #e1efd6;
  --r: 16px; --r-sm: 10px; --border: 1px solid var(--line); --shadow: 0 1px 2px rgba(32,58,37,.06);
  --deco: none;
  --o1: url("/ornamen/kebun-1.png"); --o2: url("/ornamen/kebun-2.png"); --o3: url("/ornamen/kebun-3.png");
}
body[data-tema="laut"] {
  --bg: #e8f4fb; --surface: #fbfeff; --ink: #0e3550; --muted: #4f6f85;
  --line: #c6e0ef; --accent: #1d7fb8; --accent-ink: #ffffff; --soft: #d8edf8;
  --r: 16px; --r-sm: 10px; --border: 1px solid var(--line); --shadow: 0 1px 2px rgba(14,53,80,.06);
  --deco: none;
  --o1: url("/ornamen/laut-1.png"); --o2: url("/ornamen/laut-2.png"); --o3: url("/ornamen/laut-3.png");
}
body[data-tema="kopi"] {
  --bg: #f6efe6; --surface: #fffaf4; --ink: #3b2a1e; --muted: #7a6556;
  --line: #e5d5c2; --accent: #8a5a34; --accent-ink: #ffffff; --soft: #efe2d1;
  --r: 14px; --r-sm: 10px; --border: 1px solid var(--line); --shadow: 0 1px 2px rgba(59,42,30,.06);
  --deco: none;
  --o1: url("/ornamen/kopi-1.png"); --o2: url("/ornamen/kopi-2.png"); --o3: url("/ornamen/kopi-3.png");
}

* { box-sizing: border-box; }

/* Colors ease between themes. Ornament images swap through the View Transition API in script. */
body, body * {
  transition-property: background-color, color, border-color, box-shadow;
  transition-duration: .4s;
  transition-timing-function: ease;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: var(--deco);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.6;
  padding-inline: 16px;
  padding-block: 0 24px;
}
.wrap { max-width: 640px; margin-inline: auto; display: grid; gap: var(--gap); min-width: 0; }
#sentinel { height: 1px; margin: 0; }

/* Top bar: brand and theme picker on one row. Sticks to the top and shrinks when stuck. */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  margin-inline: -16px;
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background-color: transparent;
  box-shadow: none;
  transition: padding .3s ease, background-color .4s ease, box-shadow .3s ease;
}
.topbar.is-stuck {
  background-color: var(--surface);
  box-shadow: 0 2px 14px rgba(0,0,0,.08);
  padding-block: 6px;
}
.brand {
  margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); min-width: 0; overflow-wrap: anywhere; text-decoration: none;
}
body[data-tema="imut"] .brand { color: #d6336c; }
.tema-wrap { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tema-wrap label { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.tema-select {
  font: inherit; font-size: var(--fs-sm); font-weight: 600;
  min-height: 40px; padding: 6px 10px; min-width: 110px;
  color: var(--ink); background: var(--surface);
  border: var(--border); border-radius: var(--r-sm);
}

/* Page header and content */
header { display: grid; gap: 6px; }
h1 { margin: 0; font-size: var(--fs-hero); font-weight: 800; line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance; }
h2 { margin: 0; font-size: var(--fs-lg); font-weight: 700; line-height: 1.3; text-wrap: balance; }
.lead { margin: 0; color: var(--muted); font-size: var(--fs-sm); text-wrap: pretty; }
.article { display: grid; gap: 10px; }
.article p, .article li { margin: 0; color: var(--ink); text-wrap: pretty; }
.article ul, .article ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.example {
  background: var(--soft); border-radius: var(--r-sm); padding: 12px 14px; border: var(--border);
  font-size: var(--fs-sm); display: grid; gap: 4px; font-variant-numeric: tabular-nums;
}
.formula {
  font-weight: 700; font-size: var(--fs-sm); padding: 10px 12px;
  background: var(--bg); border-radius: var(--r-sm); border: var(--border); overflow-wrap: anywhere;
}
.related { display: grid; gap: 8px; }
.related a {
  color: var(--accent); font-weight: 600; text-decoration: none;
  padding: 10px 12px; border-radius: var(--r-sm); border: var(--border); background: var(--surface);
  min-height: 44px; display: flex; align-items: center;
}

.calc {
  background: var(--surface); border: var(--border); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 14px; display: grid; gap: 10px; min-width: 0;
}
.calc > p { margin: 0; color: var(--muted); font-size: var(--fs-sm); }

.fields { display: grid; gap: 10px; grid-template-columns: 1fr; align-items: start; }
.field { display: grid; gap: 4px; min-width: 0; position: relative; align-content: start; }
/* Label has a fixed 20px row, so the input starts exactly 24px from the top of the field. */
.field label { font-size: var(--fs-sm); font-weight: 600; height: 20px; line-height: 20px; padding-right: 44px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field input, .field textarea {
  width: 100%; min-width: 0; min-height: 40px; padding: 8px 12px;
  font: inherit; font-size: 15px; font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--bg); border: var(--border); border-radius: var(--r-sm);
}
.field textarea { resize: vertical; min-height: 110px; }
.hint { font-size: 12px; color: var(--muted); }

/* One small ornament per input, centred on the input's top right corner. Empty in Bersih. */
.field::after {
  content: ""; position: absolute; top: 4px; right: 0; z-index: 1;
  width: 40px; height: 40px; pointer-events: none;
  background-repeat: no-repeat; background-position: center; background-size: contain;
}
.field[data-o="1"]::after { background-image: var(--o1); }
.field[data-o="2"]::after { background-image: var(--o2); }
.field[data-o="3"]::after { background-image: var(--o3); }

.result {
  background: var(--soft); border-radius: var(--r-sm); padding: 10px 12px; border: var(--border);
  display: grid; gap: 2px; min-width: 0;
}
.result .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.result .value { font-size: var(--fs-xl); font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--ink); }
.result .detail { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }

.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  font: inherit; font-size: var(--fs-sm); font-weight: 600; text-decoration: none;
  min-height: 44px; padding: 10px 16px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent-ink); background: var(--accent); border: 0; border-radius: var(--r-sm); cursor: pointer;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); border: var(--border); }

footer { font-size: var(--fs-sm); color: var(--muted); text-align: center; padding-top: 8px; border-top: var(--border); }
footer a { color: var(--accent); font-weight: 700; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
[hidden] { display: none !important; }

/* Follow-up box shown after a result: links to the related article and the cashier app. */
.next { display: grid; gap: 8px; padding-top: 12px; border-top: var(--border); }
.next .btn { width: 100%; }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

/* Answer toggles for practice questions (native details, works without script). */
details { margin-top: 6px; }
details summary {
  cursor: pointer; font-weight: 600; color: var(--accent);
  min-height: 44px; display: flex; align-items: center;
}
details[open] summary { margin-bottom: 4px; }
details span { display: block; margin-top: 4px; }

/* Request sheet: slides up over the page, closed with Kembali, Escape, or browser back. */
.req-sheet {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto;
  background-color: var(--bg); color: var(--ink);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
  transform: translateY(24px); opacity: 0; visibility: hidden;
  transition: transform .35s ease, opacity .35s ease, visibility 0s linear .35s, background-color .4s ease;
}
.req-sheet.open {
  transform: none; opacity: 1; visibility: visible;
  transition: transform .35s ease, opacity .35s ease, visibility 0s, background-color .4s ease;
}
.req-top { max-width: 640px; margin: 0 auto 12px; }
.req-body { max-width: 640px; margin-inline: auto; display: grid; gap: 12px; }
.req-body h2 { font-size: var(--fs-hero); font-weight: 800; line-height: 1.2; }

/* Form and success view share one grid cell so they cross-fade in place. */
.req-stage { display: grid; }
.req-stage > * { grid-area: 1 / 1; }
.req-form {
  display: grid; gap: 12px; min-width: 0;
  transition: opacity .3s ease, transform .3s ease;
}
.req-success {
  display: grid; justify-items: center; align-content: center; gap: 10px; text-align: center;
  padding: 28px 8px; min-height: 320px; position: relative;
  opacity: 0; transform: scale(.94); pointer-events: none;
  transition: opacity .4s ease .15s, transform .4s ease .15s;
}
.req-stage.is-sent .req-form { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.req-stage.is-sent .req-success { opacity: 1; transform: none; pointer-events: auto; }

.tick { width: 72px; height: 72px; overflow: visible; }
.tick .ring, .tick .check {
  fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 100; stroke-dashoffset: 100;
}
.req-stage.is-sent .tick .ring { animation: draw .7s ease .25s forwards; }
.req-stage.is-sent .tick .check { animation: draw .5s ease .8s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.req-success h3 { margin: 0; font-size: var(--fs-lg); font-weight: 800; }
.req-success p { margin: 0; color: var(--muted); font-size: var(--fs-sm); max-width: 36ch; }

/* Small ornaments that pop out around the tick after sending. */
.pop {
  position: absolute; width: 44px; height: 44px; pointer-events: none;
  background-repeat: no-repeat; background-position: center; background-size: contain;
  opacity: 0; transform: scale(.2);
}
.req-stage.is-sent .pop { animation: pop .6s cubic-bezier(.2,1.4,.4,1) forwards; }
.pop.p1 { background-image: var(--o1); top: 6px; left: 18%; }
.pop.p2 { background-image: var(--o2); top: 0; right: 16%; animation-delay: .1s !important; }
.pop.p3 { background-image: var(--o3); bottom: 12px; right: 22%; animation-delay: .2s !important; }
@keyframes pop { to { opacity: 1; transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .req-stage.is-sent .tick .ring, .req-stage.is-sent .tick .check { stroke-dashoffset: 0; }
  .req-stage.is-sent .pop { opacity: 1; transform: none; }
}

@media (min-width: 560px) {
  .fields { grid-template-columns: 1fr 1fr; }
}

/* Search under the page header. Results come from /assets/search.json. */
.cari { display: grid; gap: 6px; position: relative; }
.cari-label { font-size: var(--fs-sm); font-weight: 600; }
.cari input {
  width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px;
  font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: var(--border); border-radius: var(--r-sm);
}
.cari-hasil {
  display: grid; gap: 4px; padding: 6px; background: var(--surface);
  border: var(--border); border-radius: var(--r-sm); box-shadow: var(--shadow);
}
.cari-item {
  display: grid; gap: 2px; min-height: 44px; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--ink); text-decoration: none;
}
.cari-item:hover, .cari-item:focus-visible { background: var(--soft); }
.cari-item strong { color: var(--accent); font-weight: 700; font-size: var(--fs-sm); }
.cari-item span { color: var(--muted); font-size: 12px; }
.cari-kosong { margin: 0; padding: 10px 12px; color: var(--muted); font-size: var(--fs-sm); }

/* Form inside the request sheet: fields keep their own height. */
.req-again { margin-top: 6px; }

/* Search opens from an icon in the top bar. The panel sits between the bar and the page header. */
/* Panel opens by growing from 0 rows to 1fr, so the page below slides down smoothly. */
.cari {
  display: grid; grid-template-rows: 0fr; opacity: 0; visibility: hidden;
  transition: grid-template-rows .32s ease, opacity .24s ease, visibility 0s linear .32s;
}
.cari.is-open {
  grid-template-rows: 1fr; opacity: 1; visibility: visible;
  transition: grid-template-rows .32s ease, opacity .24s ease, visibility 0s;
}
.cari-isi { min-height: 0; overflow: hidden; display: grid; gap: 8px; padding-block: 4px; }
.cari.is-open .cari-isi { padding-bottom: 8px; }
.cari-item, .cari-kosong { animation: cari-muncul .28s ease both; }
@keyframes cari-muncul {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cari, .cari.is-open { transition: none; }
  .cari-item, .cari-kosong { animation: none; }
}
.cari-baris { display: flex; gap: 8px; min-width: 0; }
.cari-baris input { flex: 1; min-width: 0; }
.cari-tutup { min-height: 44px; flex-shrink: 0; }
.cari-hasil { max-height: 60vh; overflow-y: auto; }
.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center;
  color: var(--ink); background: var(--surface); border: var(--border); border-radius: var(--r-sm); cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }

/* Hasil pencarian: kolom biasa dengan tinggi baris jelas, tidak lagi bertumpuk. */
.cari-hasil {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 60vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 6px; background: var(--surface); border: var(--border);
  border-radius: var(--r-sm); box-shadow: var(--shadow);
  animation: cari-turun .26s ease both;
}
@keyframes cari-turun {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.cari-item {
  display: block; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--ink); text-decoration: none; line-height: 1.4;
}
.cari-item strong {
  display: block; margin: 0 0 2px; font-size: 14px; font-weight: 700;
  color: var(--accent); line-height: 1.35;
}
.cari-item span {
  display: block; margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45;
}
.cari-item:hover, .cari-item:focus-visible { background: var(--soft); }
.cari-kosong { margin: 0; padding: 10px 12px; font-size: 14px; line-height: 1.5; color: var(--muted); }

/* Formulir permintaan: nama di atas, isi permintaan di bawah. */
.req-form .fields { grid-template-columns: 1fr; }

@media (prefers-reduced-motion: reduce) {
  .cari-hasil { animation: none; }
}

/* Perbaikan susunan: hasil berupa blok biasa (flex mengecilkan item dan membuat tumpang tindih). */
.cari-hasil { display: block; }
.cari-item { min-height: 0; margin: 0 0 2px; }
.cari-item:last-child { margin-bottom: 0; }
/* Ruang di dalam panel supaya outline fokus input tidak terpotong oleh overflow. */
.cari-isi, .cari.is-open .cari-isi { padding: 6px; }
.cari input, .cari-baris input { min-height: 40px; }
.cari-tutup { min-height: 40px; }

footer .logo-sk { height: 22px; width: auto; vertical-align: middle; margin-left: 4px; }

/* Bilah atas: merek di kiri, tema berupa titik warna dan ikon cari di kanan. */
.kanan { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.tema-dots { display: flex; align-items: center; gap: 0; }
.tema-dots button { width: 28px; height: 40px; padding: 0; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.tema-dots button::before { content: ""; width: 20px; height: 20px; border-radius: 999px; background: var(--c); box-shadow: 0 0 0 1px var(--line); }
.tema-dots button[aria-pressed="true"]::before { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.tema-dots button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.topbar .icon-btn { width: 40px; height: 40px; }

/* Tambahan Hitung Produksi */
.crumb{font-size:13px;color:var(--muted);margin:0 0 6px}.crumb a{color:inherit}
.hasil{margin-top:16px}
.tema-dots button{width:28px}
[hidden]{display:none!important}
.glosarium{margin:0;display:grid;gap:0}
.istilah{padding:14px 0;border-bottom:var(--border)}
.istilah dt{font-weight:700;color:var(--ink)}
.istilah dd{margin:4px 0 0;color:var(--muted);font-size:var(--fs-sm)}
footer .logo-sk{height:22px;width:auto;vertical-align:middle;margin-left:4px}
.hasil .result+.result{margin-top:12px}
