/* Detektif Data — Math Tech Week SNISHOP
   Direction: toko data / case-file ledger. Warm paper, teal awning, coral stamp.
   Not a generic kid-game template. */

:root {
  --paper: #F3EBDA;
  --paper-2: #E8DCC6;
  --ink: #1C1712;
  --ink-soft: #5C5348;
  --ink-faint: rgba(28, 23, 18, 0.55);
  --teal: #0C6560;
  --teal-deep: #084440;
  --teal-bright: #178F88;
  --coral: #E14B36;
  --coral-deep: #BE3424;
  --sun: #E3A81C;
  --sun-soft: #F5D56A;
  --leaf: #2B8A5C;
  --cream: #FFF8EC;
  --rule: rgba(28, 23, 18, 0.09);
  --shadow: 0 12px 28px rgba(28, 23, 18, 0.14);
  --radius: 8px;
  --font-display: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --font-body: "Lexend", "Segoe UI", "Source Sans 3", sans-serif;
  --ebook: #0C6560;
  --template: #E3A81C;
  --turnitin: #E14B36;
  --skill: #355A57;
  --kasir: #2B8A5C;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent 0 27px,
      var(--rule) 27px 28px
    ),
    linear-gradient(180deg, rgba(12, 101, 96, 0.06), transparent 220px);
  background-attachment: fixed;
}

img { max-width: 100%; height: auto; display: block; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
}
.skip:focus {
  left: 8px;
  z-index: 20;
  background: var(--cream);
  padding: 8px 12px;
}

/* Scalloped toko awning */
.awning {
  height: 22px;
  background:
    radial-gradient(circle at 50% 100%, transparent 56%, var(--teal-deep) 57%) 0 0 / 22px 16px,
    linear-gradient(var(--teal), var(--teal-deep));
  box-shadow: inset 0 -2px 0 var(--sun);
}
.brand-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 8px;
  background: var(--teal);
  color: var(--cream);
}
.brand-bar a {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.brand-bar img.logo {
  height: 28px;
  width: auto;
  filter: brightness(0) invert(1);
}
.brand-mark {
  width: 32px;
  height: 32px;
  flex: none;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.brand-meta {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
  text-align: right;
}

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 12px calc(28px + var(--safe-bottom));
}

/* Ledger / case-file sheet */
.sheet {
  background: var(--cream);
  border: 1px solid rgba(28, 23, 18, 0.16);
  box-shadow: var(--shadow);
  position: relative;
  padding: 22px 18px 24px;
  max-width: 100%;
}
.sheet::before {
  content: "";
  position: absolute;
  inset: 8px auto auto 8px;
  width: 18px;
  height: 18px;
  border-top: 2px solid var(--teal);
  border-left: 2px solid var(--teal);
}
.sheet::after {
  content: "";
  position: absolute;
  inset: auto 8px 8px auto;
  width: 18px;
  height: 18px;
  border-bottom: 2px solid var(--coral);
  border-right: 2px solid var(--coral);
}

.kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin: 0 0 8px;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal-deep);
  font-weight: 600;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(2rem, 8vw, 3.4rem); line-height: 0.95; color: var(--teal-deep); }
.sheet.has-stamp .kicker,
.sheet.has-stamp h1 { padding-right: 96px; }
.stamp-inline { display: inline-block; margin: 0 0 8px 0; transform: rotate(-6deg); }
h2 { font-size: clamp(1.4rem, 5vw, 2rem); line-height: 1.1; }
.lede {
  margin: 12px 0 0;
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 36rem;
}

.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 2px solid var(--coral);
  color: var(--coral-deep);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.68rem;
  transform: rotate(-8deg);
  background: rgba(225, 75, 54, 0.06);
  user-select: none;
}
.stamp-wrap {
  position: absolute;
  top: 16px;
  right: 14px;
  z-index: 2;
  pointer-events: none;
}

/* Forms */
.field { margin: 18px 0 0; }
.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}
.field .hint { display: block; color: var(--ink-soft); font-size: 0.85rem; margin-top: 6px; }
input[type="text"], input[type="number"] {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 2px solid var(--ink);
  background: var(--paper);
  border-radius: 6px;
  font-size: 1.1rem;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
.groups {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.group-btn {
  min-height: 52px;
  border: 2px solid var(--ink);
  background: var(--paper);
  border-radius: 6px;
  font-weight: 600;
  padding: 8px 10px;
}
.group-btn[aria-pressed="true"] {
  background: var(--teal);
  color: var(--cream);
  border-color: var(--teal-deep);
}
.group-btn:hover { background: var(--paper-2); }
.group-btn[aria-pressed="true"]:hover { background: var(--teal-deep); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 20px;
  border: 2px solid var(--teal-deep);
  background: var(--teal);
  color: var(--cream);
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.btn:hover { background: var(--teal-deep); }
.btn[disabled], .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--teal-deep);
  border-color: var(--teal);
}
.btn-ghost:hover { background: rgba(12, 101, 96, 0.08); }
.btn-coral {
  background: var(--coral);
  border-color: var(--coral-deep);
  color: #fff;
}
.btn-coral:hover { background: var(--coral-deep); }
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
  position: relative;
  z-index: 3;
}
.actions .btn { flex: 1 1 180px; }

/* HUD */
.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.hud-who { font-weight: 600; }
.hud-score {
  font-variant-numeric: tabular-nums;
  background: var(--sun-soft);
  border: 1px solid rgba(28, 23, 18, 0.16);
  padding: 6px 10px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  font-weight: 700;
}
.levels {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.lvl {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 8px;
  border: 1px dashed var(--ink-soft);
  color: var(--ink-soft);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}
.lvl.is-on {
  border-style: solid;
  border-color: var(--teal);
  color: var(--teal-deep);
  background: rgba(12, 101, 96, 0.08);
  font-weight: 700;
}
.progress {
  height: 8px;
  background: var(--paper-2);
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0 16px;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--teal);
  transition: width 0.4s ease;
}

/* Data table */
.layout-data {
  display: grid;
  gap: 18px;
  min-width: 0;
  max-width: 100%;
}
@media (min-width: 860px) {
  .layout-data { grid-template-columns: 1.15fr 0.85fr; align-items: start; }
}
.ledger {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid rgba(28, 23, 18, 0.16);
  background: var(--paper);
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
  padding: 8px 7px;
  text-align: right;
  border-bottom: 1px solid var(--rule);
}
table.data th {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--teal);
  color: var(--cream);
  text-align: center;
}
table.data th:first-child, table.data td.prod {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--paper);
  font-weight: 600;
  min-width: 132px;
}
table.data th:first-child { background: var(--teal-deep); }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: rgba(227, 168, 28, 0.12); }
table.data tbody tr:hover td.prod { background: #F6E9C2; }
table.data tbody tr.is-on td { background: rgba(12, 101, 96, 0.12); }
table.data tbody tr.is-on td.prod { background: rgba(12, 101, 96, 0.16); }
table.data .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: middle;
}
table.data .sub {
  display: block;
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--ink-soft);
}
table.data tfoot td {
  font-weight: 700;
  background: var(--paper-2);
}
.caption-note {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* Chart */
.chart-panel { padding: 4px 0 0; }
#chart { width: 100%; max-width: 100%; overflow: hidden; }
.chart-caption {
  min-height: 3.2em;
  margin: 0 0 8px;
  color: var(--ink-soft);
}
.chart-panel { overflow: hidden; position: relative; z-index: 1; }
.chart-svg { width: 100%; height: auto; aspect-ratio: 400 / 280; display: block; overflow: hidden; }
.bar-hit { cursor: pointer; }
.bar-rect { transition: opacity 0.2s ease; }
.bar-hit:hover .bar-rect, .bar-hit.is-on .bar-rect { filter: brightness(1.05); }
.bar-hit:not(.is-on):not(:hover) .bar-rect { opacity: 0.82; }
.bar-label { font-family: var(--font-body); font-size: 11px; fill: var(--ink); text-anchor: middle; }
.bar-value { font-family: var(--font-body); font-size: 12px; font-weight: 700; fill: var(--ink); text-anchor: middle; }
.axis { stroke: rgba(28,23,18,0.25); stroke-width: 1; }
.grid-line { stroke: rgba(28,23,18,0.12); stroke-width: 1; }
.grid-text { font-size: 10px; fill: var(--ink-soft); font-family: var(--font-body); }

/* Questions */
.q-head { margin-bottom: 8px; color: var(--teal-deep); font-weight: 600; font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; }
.q-text { font-family: var(--font-display); font-size: clamp(1.25rem, 4.5vw, 1.8rem); line-height: 1.2; margin: 0 0 16px; }
.choices { display: grid; gap: 8px; }
@media (min-width: 640px) { .choices.cols-2 { grid-template-columns: 1fr 1fr; } }
.choice {
  min-height: 52px;
  text-align: left;
  padding: 10px 14px;
  border: 2px solid var(--ink);
  background: var(--paper);
  border-radius: 6px;
  font-weight: 600;
}
.choice:hover { background: var(--paper-2); }
.choice.is-on { border-color: var(--teal); background: rgba(12,101,96,0.1); }
.choice.is-right { border-color: var(--leaf); background: rgba(43,138,92,0.16); }
.choice.is-wrong { border-color: var(--coral); background: rgba(225,75,54,0.12); }
.choice:disabled { cursor: default; }

.answer-row { display: flex; gap: 8px; flex-wrap: wrap; }
.answer-row input { flex: 1 1 160px; }
.answer-row .btn { flex: 0 0 auto; }

.feedback {
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--teal);
  background: rgba(12, 101, 96, 0.08);
}
.feedback.is-wrong { border-color: var(--coral); background: rgba(225,75,54,0.08); }
.feedback.is-ok { border-color: var(--leaf); background: rgba(43,138,92,0.1); }
.formula {
  display: inline-block;
  margin-top: 6px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.92rem;
  background: var(--ink);
  color: var(--sun-soft);
  padding: 4px 8px;
}

/* Sort trays */
.sort-board {
  display: grid;
  gap: 12px;
}
@media (min-width: 700px) {
  .sort-board { grid-template-columns: 1fr 1fr 1fr; }
}
.pile, .tray {
  border: 2px dashed rgba(28,23,18,0.28);
  min-height: 120px;
  padding: 10px;
  background: var(--paper);
}
.tray { border-style: solid; }
.tray-laris { border-color: var(--leaf); }
.tray-promosi { border-color: var(--coral); }
.pile h3, .tray h3 { font-size: 1rem; margin-bottom: 8px; }
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  background: var(--cream);
  text-align: left;
  font-weight: 600;
  border-radius: 6px;
}
.chip .swatch { width: 12px; height: 12px; flex: none; }
.chip:hover { background: var(--paper-2); }

/* End / certificate */
.cert {
  border: 3px solid var(--teal-deep);
  background:
    linear-gradient(var(--cream), var(--cream)) padding-box,
    repeating-linear-gradient(45deg, var(--teal) 0 8px, var(--sun) 8px 12px, var(--coral) 12px 16px, var(--cream) 16px 22px) border-box;
  padding: 22px 18px 20px;
  text-align: center;
  position: relative;
}
.cert-kicker { letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.75rem; color: var(--teal-deep); font-weight: 700; margin: 0 0 8px; }
.cert h2 { font-size: clamp(1.6rem, 6vw, 2.4rem); }
.cert .who {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  margin: 10px 0 4px;
  color: var(--coral-deep);
}
.stars { display: flex; justify-content: center; gap: 8px; margin: 12px 0; }
.star { width: 36px; height: 36px; }
.star.on { fill: var(--sun); stroke: var(--ink); }
.star.off { fill: var(--paper-2); stroke: var(--ink-soft); }
.cert p { margin: 6px 0; }
.score-big { font-size: 1.3rem; font-weight: 700; }

/* Papan */
body.papan { background-attachment: scroll; }
.papan-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: end; margin-bottom: 16px; }
.live-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--leaf); display: inline-block; margin-right: 6px;
  box-shadow: 0 0 0 0 rgba(43,138,92,0.6);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(43,138,92,0.55); }
  70% { box-shadow: 0 0 0 8px rgba(43,138,92,0); }
  100% { box-shadow: 0 0 0 0 rgba(43,138,92,0); }
}
.group-row {
  display: grid;
  grid-template-columns: 140px 1fr 88px;
  gap: 10px;
  align-items: center;
  margin: 0 0 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
  font-size: clamp(1rem, 2.2vw, 1.35rem);
}
.group-row .bar {
  height: 22px;
  background: var(--paper-2);
  position: relative;
}
.group-row .bar > i {
  display: block;
  height: 100%;
  background: var(--teal);
  width: 0;
  transition: width 0.5s ease;
}
.group-row.is-1 .bar > i { background: var(--sun); }
.group-row.is-2 .bar > i { background: var(--coral); }
.top-list { list-style: none; margin: 0; padding: 0; }
.top-list li {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-variant-numeric: tabular-nums;
}
.rank { font-weight: 700; color: var(--teal-deep); }
.offline { color: var(--coral-deep); font-weight: 600; }

/* Confetti / motion */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 40;
}
.confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 12px;
  animation: fall 900ms ease-in forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(220deg); opacity: 0.2; }
}
@keyframes bounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  70% { transform: scale(0.98); }
  100% { transform: scale(1); }
}
.is-bounce { animation: bounce 0.45s ease; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.hidden { display: none !important; }

@media (max-width: 420px) {
  .brand-meta { display: none; }
  .sheet { padding: 18px 14px 20px; }
  .groups { grid-template-columns: 1fr 1fr; }
  .group-row { grid-template-columns: 108px 1fr 64px; font-size: 0.95rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .bar-rect { transform: none !important; }
}

@media print {
  .awning, .brand-bar, .actions, .hud { display: none !important; }
  body { background: white; }
  .cert { box-shadow: none; }
}
