/* Kalkulator Diskaun Hukuman - styles. Mobile first. */

:root {
  --bg: #F4F1E8;
  --surface: #FFFDF7;
  --surface-2: #ECE7DA;
  --ink: #1C1A16;
  --muted: #5F594E;
  --line: #DCD4C3;
  --line-strong: #B9AF9A;
  --accent: #B3261E;
  --accent-hover: #951F18;
  --accent-ink: #FFFFFF;
  --accent-soft: #F5E0DB;
  --sticker: #F4C542;
  --sticker-ink: #1C1A16;
  --focus: #1C1A16;
  --backdrop: rgba(20, 18, 14, 0.5);
  --shadow: 0 1px 2px rgba(28, 26, 22, 0.06), 0 6px 20px rgba(28, 26, 22, 0.06);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --radius: 10px;
  --radius-lg: 14px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12110E;
    --surface: #1B1A16;
    --surface-2: #26241E;
    --ink: #F2EEE5;
    --muted: #ADA695;
    --line: #34312A;
    --line-strong: #514C41;
    --accent: #F2685B;
    --accent-hover: #FF8476;
    --accent-ink: #1A0806;
    --accent-soft: #3A1D19;
    --sticker: #E9B934;
    --sticker-ink: #1C1A16;
    --focus: #F2EEE5;
    --backdrop: rgba(0, 0, 0, 0.6);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #12110E;
  --surface: #1B1A16;
  --surface-2: #26241E;
  --ink: #F2EEE5;
  --muted: #ADA695;
  --line: #34312A;
  --line-strong: #514C41;
  --accent: #F2685B;
  --accent-hover: #FF8476;
  --accent-ink: #1A0806;
  --accent-soft: #3A1D19;
  --sticker: #E9B934;
  --sticker-ink: #1C1A16;
  --focus: #F2EEE5;
  --backdrop: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, p, dl, dd, blockquote { margin: 0; }
button, input { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.icon { width: 20px; height: 20px; flex: none; }

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

.skip-link {
  position: absolute;
  left: 16px; top: -60px;
  background: var(--ink); color: var(--bg);
  padding: 10px 14px; border-radius: var(--radius);
  z-index: 50; text-decoration: none; font-weight: 700;
}
.skip-link:focus { top: 12px; }

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

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.muted { color: var(--muted); }

/* ---------- Header ---------- */
.site-header { padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: 20px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 8px; margin-bottom: 18px;
}

.edition {
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
}

h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 8.4vw, 3.25rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144;
}

.tagline {
  margin-top: 10px;
  font-size: clamp(1rem, 3.6vw, 1.2rem);
  color: var(--muted);
  font-weight: 500;
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-strong); }

/* ---------- Section labels ---------- */
.section-label {
  font-size: 0.75rem; font-weight: 800;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.sub-label {
  font-size: 0.75rem; font-weight: 800;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
  margin: 26px 0 8px;
}

/* ---------- Layout ---------- */
.layout { display: grid; gap: 28px; padding-bottom: 32px; }
.output { display: grid; gap: 32px; min-width: 0; }

@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 48px; align-items: start; }
  .inputs { position: sticky; top: 20px; }
}

/* ---------- Inputs ---------- */
.inputs {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 16px 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.field + .field { margin-top: 20px; }

.label {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 8px;
}

.hint { font-size: 0.875rem; color: var(--muted); margin-top: 6px; }

.text-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 1rem;
}
.text-input:focus-visible { outline-offset: 1px; }
.text-input::placeholder { color: var(--muted); opacity: 0.85; }

.select-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 60px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg);
  text-align: left; cursor: pointer;
}
.select-btn:hover { border-color: var(--ink); }
.select-emoji { font-size: 1.75rem; line-height: 1; width: 34px; text-align: center; }
.select-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.select-name { font-weight: 700; overflow-wrap: anywhere; }
.select-sub { font-size: 0.8125rem; color: var(--muted); }
.select-chevron { color: var(--muted); }

.money-input { position: relative; }
.money-prefix {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-weight: 700; color: var(--muted); pointer-events: none;
}
.money-input .text-input {
  padding-left: 46px;
  font-size: 1.375rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-height: 56px;
}
.money-input.is-invalid .text-input { border-color: var(--accent); border-width: 2px; }

.error {
  display: flex; gap: 6px; align-items: flex-start;
  margin-top: 8px;
  color: var(--accent);
  font-weight: 600; font-size: 0.9375rem;
}
.error::before {
  content: "!";
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin-top: 1px;
  border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-size: 0.8125rem; font-weight: 800;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: transparent;
  font-size: 0.9375rem; font-weight: 600;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.actions { display: grid; gap: 10px; margin-top: 22px; }
.actions .hint { margin-top: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 700; font-size: 1rem; line-height: 1.2;
  text-align: center; text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink); }
.btn:disabled, .btn.is-disabled {
  opacity: 0.5; cursor: not-allowed; transform: none;
}
.btn.is-disabled { pointer-events: none; }

/* ---------- Results ---------- */
.results { min-width: 0; scroll-margin-top: 16px; }
.results:focus { outline: none; }

.result-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 6vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.result-crime { margin-top: 6px; color: var(--muted); font-weight: 600; overflow-wrap: anywhere; }

.empty-state {
  margin-top: 18px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
}
.empty-title { font-weight: 700; color: var(--ink); margin-bottom: 4px; }

.receipt {
  position: relative;
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 16px 18px;
  box-shadow: var(--shadow);
}

.receipt-head {
  display: flex; justify-content: space-between; gap: 12px;
  padding-right: 78px;
  font-family: var(--font-mono);
  font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line-strong);
}

.sticker {
  position: absolute; top: -14px; right: 12px;
  width: 76px; height: 76px;
  border-radius: 50%;
  background: var(--sticker); color: var(--sticker-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transform: rotate(10deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  line-height: 1;
}
.sticker span { font-size: 0.625rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.sticker b { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; margin-top: 2px; }

.receipt-lines { margin-top: 6px; }
.rline {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.rline dt { color: var(--muted); font-size: 0.9375rem; }
.rline dd {
  font-weight: 700; text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere; min-width: 0;
}
.rline s { color: var(--muted); text-decoration-thickness: 2px; text-decoration-color: var(--accent); }
.rline-discount dd { color: var(--accent); }

.bar {
  margin-top: 14px;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.bar-fill {
  display: block; height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.5s ease;
}

.total {
  display: flex; flex-direction: column; gap: 2px;
  margin-top: 16px; padding-top: 14px;
  border-top: 2px solid var(--ink);
}
.total-label { font-size: 0.8125rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.total-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 9vw, 2.75rem);
  line-height: 1.05;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.total-value.is-updated { animation: pop 0.35s ease; }
@keyframes pop { from { opacity: 0.35; } to { opacity: 1; } }

.sentence { display: grid; gap: 0; border-top: 1px solid var(--line); }
.srow {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.srow dt { color: var(--muted); font-size: 0.9375rem; }
.srow dd { font-weight: 700; text-align: right; white-space: nowrap; }

.tag {
  display: inline-block;
  padding: 1px 7px; margin-left: 4px;
  border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.8125rem; font-weight: 800;
}

.note { margin-top: 8px; font-size: 0.875rem; color: var(--muted); }

.police {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 2px solid var(--ink);
}
.police-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; }
.police-title { font-family: var(--font-display); font-size: 1.375rem; font-weight: 800; }
.police-count { font-weight: 800; font-size: 1.125rem; }
.police-count .muted { font-weight: 500; font-size: 0.875rem; }
.officers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; min-height: 36px; color: var(--ink); }
.officers svg { width: 24px; height: 32px; }
.officers .is-empty { color: var(--line-strong); }
.police-caption { margin-top: 10px; font-weight: 600; font-size: 1.0625rem; }

.disclaimer-inline {
  margin-top: 22px;
  padding: 12px 14px;
  border-left: 3px solid var(--sticker);
  background: var(--surface-2);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.875rem;
}

/* ---------- Joke ---------- */
.joke { border-top: 1px solid var(--line); padding-top: 20px; }
.joke-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.25rem, 4.8vw, 1.6rem);
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.joke-text::before { content: "\201C"; color: var(--accent); margin-right: 2px; }
.joke-text::after { content: "\201D"; color: var(--accent); margin-left: 2px; }
.joke-text.is-updated { animation: pop 0.35s ease; }
.joke-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 16px; }
.joke-foot .hint { margin-top: 0; }

/* ---------- Share ---------- */
.share { border-top: 1px solid var(--line); padding-top: 20px; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share-grid .btn { padding-left: 10px; padding-right: 10px; font-size: 0.9375rem; }
.share-grid .btn-primary, .share-grid .btn:last-child { grid-column: 1 / -1; }
@media (min-width: 600px) {
  .share-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .share-grid .btn-primary, .share-grid .btn:last-child { grid-column: auto; }
}

/* ---------- Explain ---------- */
.explain { padding-bottom: 8px; }
.explain details { border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); }
.explain summary {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px; padding: 8px 0;
  cursor: pointer; list-style: none;
  font-family: var(--font-display); font-weight: 800; font-size: 1.375rem;
}
.explain summary::-webkit-details-marker { display: none; }
.summary-chevron { transition: transform 0.2s ease; }
.explain details[open] .summary-chevron { transform: rotate(180deg); }
.explain-body { padding: 4px 0 22px; display: grid; gap: 22px; }
.explain-body h3 { font-size: 1rem; font-weight: 800; margin-bottom: 6px; }
.explain-body p { color: var(--ink); }
.explain-body p + p { margin-top: 6px; }
.explain-body .muted { color: var(--muted); font-size: 0.9375rem; }
.formula {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}
.table-wrap { overflow-x: auto; }
.explain table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.explain th, .explain td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.explain th { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.explain td:last-child, .explain th:last-child { text-align: right; padding-right: 0; }

@media (min-width: 960px) {
  .explain-body { grid-template-columns: 1fr 1fr; column-gap: 48px; }
  .explain-body .span-2 { grid-column: 1 / -1; }
}

/* ---------- Footer ---------- */
.site-footer { padding-top: 24px; padding-bottom: 96px; }
.site-footer p { max-width: 70ch; font-size: 0.9375rem; }
.site-footer p + p { margin-top: 8px; }
@media (min-width: 960px) { .site-footer { padding-bottom: 48px; } }

/* ---------- Sticky bar (mobile only) ---------- */
.sticky-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}
.sticky-bar .btn { width: 100%; }
@media (min-width: 960px) { .sticky-bar { display: none !important; } }

/* ---------- Dialogs ---------- */
dialog {
  border: 0; padding: 0;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: var(--backdrop); }

.sheet[open], .modal[open] { display: flex; flex-direction: column; }

.sheet {
  width: 100%; max-width: 100%;
  height: 88vh; height: 88dvh; max-height: 88dvh;
  margin: auto 0 0;
  border-radius: 16px 16px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet[open] { animation: sheet-in 0.2s ease; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (min-width: 640px) {
  .sheet {
    width: min(620px, 92vw);
    height: min(760px, 86vh);
    margin: auto;
    border-radius: var(--radius-lg);
  }
}

.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 8px 16px;
}
.sheet-head h2 { font-family: var(--font-display); font-weight: 800; font-size: 1.375rem; }

.sheet-search { position: relative; padding: 0 16px; }
.sheet-search .text-input { padding-left: 42px; }
.search-icon { position: absolute; left: 28px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.cat-chips {
  display: flex; gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: thin;
  flex: none;
}
.cat-chips .chip { white-space: nowrap; flex: none; }

.crime-list {
  list-style: none; margin: 0; padding: 0 8px 8px;
  overflow-y: auto; overscroll-behavior: contain;
  scroll-padding-top: 44px; /* keep the active row clear of the sticky group header */
  flex: 1; min-height: 0;
  border-top: 1px solid var(--line);
}
.crime-group {
  position: sticky; top: 0;
  background: var(--surface);
  padding: 12px 8px 6px;
  font-size: 0.75rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
  z-index: 1;
}
.crime-option {
  display: flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}
.crime-option .opt-emoji { font-size: 1.375rem; width: 30px; text-align: center; flex: none; }
.crime-option .opt-name { flex: 1; min-width: 0; }
.crime-option .opt-check { color: var(--accent); visibility: hidden; }
.crime-option[aria-selected="true"] { font-weight: 700; }
.crime-option[aria-selected="true"] .opt-check { visibility: visible; }
.crime-option:hover, .crime-option.is-active { background: var(--surface-2); }
.crime-option.is-active { box-shadow: inset 3px 0 0 var(--accent); }

.crime-empty { padding: 24px 16px; display: grid; gap: 12px; justify-items: start; color: var(--muted); }
.crime-empty-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.sheet-count { padding: 8px 16px 12px; font-size: 0.8125rem; color: var(--muted); border-top: 1px solid var(--line); }

.modal {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  border-radius: var(--radius-lg);
  padding-bottom: 16px;
  overflow: auto;
}
.modal .hint { padding: 0 16px; }
.poster-preview {
  margin: 4px 16px 0;
  aspect-ratio: 9 / 16;
  max-height: 60dvh;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
}
.poster-preview img { width: 100%; height: 100%; object-fit: contain; }
.poster-status { color: var(--muted); padding: 16px; text-align: center; }
.poster-actions { display: grid; gap: 10px; padding: 14px 16px 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--bg);
  padding: 12px 16px; border-radius: var(--radius);
  font-weight: 600; font-size: 0.9375rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 960px) { .toast { bottom: 32px; } }

/* ---------- Wider screens ---------- */
@media (min-width: 600px) {
  :root { --gutter: 24px; }
  .inputs { padding: 22px 22px 20px; }
  .receipt { padding: 20px 22px 22px; }
}

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