/* Mini apps live in Chapter Three. Each one is a card, because each one is interactive. */

.app {
  margin-top: var(--s3);
  border: 2px solid var(--ink);
  border-radius: var(--radius-md);
  background: var(--paper);
  box-shadow: 6px 7px 0 -1px var(--paper), 6px 7px 0 1px var(--chapter-ink);
}

.app__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  min-height: 52px;
  padding: 0.5rem 0.75rem 0.5rem var(--s2);
  border-bottom: 2px solid var(--ink);
  background: radial-gradient(circle at 1px 1px, rgb(27 32 50 / 0.1) 1px, transparent 1.4px) 0 0 / 5px 5px, var(--paper-shade);
  border-radius: calc(var(--radius-md) - 2px) calc(var(--radius-md) - 2px) 0 0;
}

.app__body { padding: var(--s3) var(--s2) var(--s3); }
.app__body > .field:first-child,
.app__grid .field { margin-top: 0; }

.app__nojs { display: none; padding: var(--s3) var(--s2); color: var(--ink-2); }
.no-js .app__body { display: none; }
.no-js .app__nojs { display: block; }
.no-js .app__bar .btn { display: none; }

.app__grid { display: grid; gap: var(--s2); }

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

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 30px;
  padding: 0 0.75rem;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--paper);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.linkish {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ink);
  text-align: left;
  text-decoration: underline 2px var(--chapter-ink);
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.linkish:hover { text-decoration-color: var(--gold); }

.icon-btn { min-width: 48px; padding-inline: 0; justify-content: center; }
.icon-btn[aria-pressed="true"] { background: var(--gold); }
.icon-btn[aria-pressed="true"] .icon { animation: pulse 900ms var(--ease-in-out) infinite; }

@keyframes pulse { 50% { transform: scale(1.18); } }

/* ---------- CV Match ---------- */

.result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s3);
  align-items: start;
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 2px dashed var(--line-strong);
}

.result[hidden] { display: none; }

.score {
  position: relative;
  width: 132px;
  aspect-ratio: 1;
}

.score svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score circle { fill: none; stroke-width: 12; }
.score__track { stroke: var(--paper-shade); }

.score__fill {
  stroke: var(--chapter-ink);
  stroke-linecap: round;
  stroke-dasharray: var(--score) 100;
  transition: stroke-dasharray 900ms var(--ease-out);
}

.score p {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  line-height: 1;
}

.score strong { font-family: var(--font-display); font-weight: 650; font-size: 2.4rem; }
.score .caps { margin-top: 0.3rem; font-size: var(--text-xs); color: var(--ink-3); }

.result__body h3 { font-family: var(--font-display); font-weight: 650; font-size: var(--text-xl); line-height: 1.15; }
.result__body > p { margin-top: 0.35rem; color: var(--ink-2); }
.result__body h4 { margin-top: var(--s2); font-size: var(--text-xs); color: var(--ink-3); }

.chips--have li { border-color: var(--navy); background: radial-gradient(circle at 1px 1px, rgb(47 79 134 / 0.25) 1px, transparent 1.4px) 0 0 / 4px 4px, var(--paper); }
.chips--miss li { border-style: dashed; color: var(--ink-2); }
.chips li.is-empty { border: 0; padding-left: 0; background: none; color: var(--ink-3); }

@media (max-width: 559px) {
  .result { grid-template-columns: 1fr; justify-items: start; }
}

/* ---------- Warung Order ---------- */

.open-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-inline: 0.2rem;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ok);
  vertical-align: 0.05em;
}

.order-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: var(--s1);
}

.order-form .icon-btn[hidden] { display: none; }

.try { margin-top: var(--s2); font-size: var(--text-sm); color: var(--ink-2); line-height: 1.8; }

.warung {
  display: grid;
  gap: var(--s3);
  margin-top: var(--s3);
}

@media (min-width: 1200px) {
  .warung { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
}

.menu h3,
.receipt h3 { font-size: var(--text-xs); color: var(--ink-3); margin-bottom: var(--s1); }

.menu__list { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 11.5rem), 1fr)); column-gap: var(--s2); }

.menu__list button {
  display: flex;
  justify-content: space-between;
  gap: var(--s2);
  width: 100%;
  min-height: 44px;
  padding: 0.4rem 0.25rem;
  border: 0;
  border-bottom: 1px dotted var(--line-strong);
  background: none;
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}

.menu__list button:hover .menu__name { text-decoration: underline 2px var(--gold); text-underline-offset: 0.2em; }
.menu__list .menu__price { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

.receipt {
  position: relative;
  padding: var(--s3) var(--s2);
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: #fff;
  /* torn bottom edge */
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 90deg, #0000 91deg) bottom / 20px 10px repeat-x;
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 90deg, #0000 91deg) bottom / 20px 10px repeat-x;
  padding-bottom: calc(var(--s3) + 10px);
}

.receipt__heard { font-size: var(--text-sm); color: var(--ink-3); font-style: italic; }

.receipt__lines { list-style: none; display: grid; gap: 0.35rem; margin-top: var(--s2); }

.receipt__lines li {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: baseline;
  font-size: var(--text-sm);
  animation: line-in 320ms var(--ease-out) both;
}

.receipt__lines .qty { font-weight: 700; font-variant-numeric: tabular-nums; }
.receipt__lines .note { display: block; color: var(--ink-3); font-size: var(--text-xs); }
.receipt__lines .sum { font-variant-numeric: tabular-nums; }

@keyframes line-in { from { opacity: 0; transform: translateY(4px); } }

.receipt__total {
  display: flex;
  justify-content: space-between;
  margin: var(--s2) 0 var(--s2);
  padding-top: var(--s1);
  border-top: 2px dashed var(--ink);
  font-weight: 600;
}

.receipt__total strong { font-family: var(--font-display); font-weight: 650; font-size: var(--text-xl); }

/* ---------- Charge Sim ---------- */

.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
  margin-bottom: var(--s3);
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  display: grid;
  justify-items: center;
  gap: 0.3rem;
  font-size: var(--text-xs);
  color: var(--ink-3);
  text-align: center;
}

.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--paper);
  font-weight: 700;
}

.steps li.is-done { color: var(--ink-2); }
.steps li.is-done::before { content: "\2713"; border-color: var(--ink); background: var(--ink); color: var(--paper); }
.steps li[aria-current="step"] { color: var(--ink); font-weight: 600; }
.steps li[aria-current="step"]::before { border-color: var(--ink); background: var(--gold); }

.sim { min-height: 320px; }

.sim h3 { font-family: var(--font-display); font-weight: 650; font-size: var(--text-xl); line-height: 1.15; }
.sim > p, .sim .sim__lede { margin-top: 0.35rem; color: var(--ink-2); }
.sim .form-actions { margin-top: var(--s3); }

.chargers { list-style: none; display: grid; gap: var(--s1); margin-top: var(--s2); }

.charger {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--s2);
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 0.6rem var(--s2);
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}

.charger:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 3px 3px 0 var(--ink); }
.charger:disabled { cursor: not-allowed; border-style: dashed; color: var(--ink-3); }
.charger .icon { width: 28px; height: 28px; }
.charger strong { display: block; line-height: 1.3; }
.charger small { display: block; margin-top: 0.15rem; line-height: 1.35; color: var(--ink-3); }
.charger .status { font-size: var(--text-xs); font-weight: 600; }
.charger .status::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 0.35rem; border-radius: 50%; background: var(--ok); }
.charger:disabled .status::before { background: var(--line-strong); }

.scanner {
  position: relative;
  display: grid;
  place-items: center;
  width: min(240px, 100%);
  aspect-ratio: 1;
  margin: var(--s2) auto 0;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: var(--ink);
  overflow: hidden;
}

.scanner svg { width: 62%; height: 62%; }

.scanner::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  height: 3px;
  background: var(--gold-light);
  box-shadow: 0 0 12px var(--gold);
  animation: scan 1.1s var(--ease-in-out) infinite alternate;
}

@keyframes scan { from { top: 12%; } to { top: 86%; } }

.amounts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s1); margin-top: var(--s2); }

.amount {
  display: grid;
  gap: 0.15rem;
  min-height: 72px;
  padding: 0.6rem;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.amount strong { font-variant-numeric: tabular-nums; }
.amount small { color: var(--ink-3); font-size: var(--text-xs); }
.amount[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.amount[aria-pressed="true"] small { color: rgb(247 247 244 / 0.75); }

.qris {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s3);
  align-items: center;
  margin-top: var(--s2);
}

.qris__code {
  width: 148px;
  padding: 10px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fff;
}

.qris__code svg { display: block; width: 100%; height: auto; }
.qris dl { display: grid; gap: 0.35rem; margin: 0; }
.qris dt { font-size: var(--text-xs); color: var(--ink-3); }
.qris dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.countdown {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s2);
  align-items: center;
  margin-top: var(--s2);
}

.countdown__ring { --p: 100; position: relative; width: 96px; aspect-ratio: 1; }
.countdown__ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.countdown__ring circle { fill: none; stroke-width: 10; }
.countdown__ring .track { stroke: var(--paper-shade); }
.countdown__ring .fill { stroke: var(--ink); stroke-dasharray: var(--p) 100; transition: stroke-dasharray 250ms linear; }
.countdown__ring strong { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 650; font-size: 1.6rem; }

.gauge { margin-top: var(--s2); }

.battery {
  position: relative;
  height: 56px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  overflow: hidden;
}

.battery::after {
  content: "";
  position: absolute;
  right: -10px;
  top: 16px;
  width: 7px;
  height: 18px;
  border-radius: 0 4px 4px 0;
  background: var(--ink);
}

.battery__fill {
  position: absolute;
  inset: 4px auto 4px 4px;
  width: calc((100% - 8px) * var(--soc, 0) / 100);
  border-radius: 7px;
  background:
    repeating-linear-gradient(-45deg, transparent 0 8px, rgb(255 255 255 / 0.22) 8px 16px),
    var(--ok);
  transition: width 240ms linear;
}

.battery__fill.is-live { animation: flow 800ms linear infinite; }
@keyframes flow { to { background-position: 22px 0, 0 0; } }

.battery__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
}

.readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s1);
  margin: var(--s2) 0 0;
}

.readout div { padding: 0.6rem 0.75rem; border: 1.5px solid var(--line-strong); border-radius: 10px; }
.readout dt { font-size: var(--text-xs); color: var(--ink-3); }
.readout dd { margin: 0.1rem 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.quota { position: relative; height: 10px; margin-top: var(--s2); border-radius: 999px; background: var(--paper-shade); overflow: hidden; }
.quota i { position: absolute; inset: 0 auto 0 0; width: calc(var(--q, 0) * 1%); background: var(--chapter-ink); transition: width 240ms linear; }

.receipt-card {
  margin-top: var(--s2);
  padding: var(--s2);
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: radial-gradient(circle at 1px 1px, rgb(27 32 50 / 0.1) 1px, transparent 1.4px) 0 0 / 6px 6px, var(--paper);
}

.receipt-card dl { display: grid; grid-template-columns: 1fr auto; gap: 0.35rem var(--s2); margin: 0; }
.receipt-card dt { color: var(--ink-2); }
.receipt-card dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.receipt-card .is-total { padding-top: 0.5rem; border-top: 2px dashed var(--ink); font-weight: 700; color: var(--ink); }

@media (max-width: 559px) {
  .steps li { font-size: 0; gap: 0; }
  .qris { grid-template-columns: 1fr; justify-items: start; }
  .readout { grid-template-columns: 1fr 1fr; }
  .amounts { grid-template-columns: 1fr; }
}

/* ---------- Glen Pet ---------- */

.meters { list-style: none; display: grid; gap: var(--s2); }

.meters li {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) 2.5rem;
  gap: var(--s2);
  align-items: center;
}

.meters__k { font-weight: 600; font-size: var(--text-sm); }
.meters__v { text-align: right; font-size: var(--text-sm); color: var(--ink-2); }

.meter {
  position: relative;
  height: 18px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  overflow: hidden;
}

.meter i {
  position: absolute;
  inset: 2px auto 2px 2px;
  width: calc((100% - 4px) * var(--v, 0.8));
  border-radius: 999px;
  background: radial-gradient(circle at 1px 1px, rgb(27 32 50 / 0.35) 1px, transparent 1.4px) 0 0 / 4px 4px, var(--chapter-ink);
  transition: width 500ms var(--ease-out);
}

.meter.is-low i { background: radial-gradient(circle at 1px 1px, rgb(27 32 50 / 0.35) 1px, transparent 1.4px) 0 0 / 4px 4px, var(--terracotta); }

.pet-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s1);
  margin-top: var(--s3);
}

.pet-btn {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  min-height: 84px;
  padding: 0.75rem 0.25rem;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}

.pet-btn .icon { width: 28px; height: 28px; }
.pet-btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.pet-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.pet-btn:disabled { cursor: wait; opacity: 0.55; transform: none; box-shadow: 3px 3px 0 var(--ink); }

@media (max-width: 559px) {
  .pet-actions { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .scanner::after, .battery__fill.is-live, .icon-btn[aria-pressed="true"] .icon { animation: none; }
}

.game__stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 400px);
  aspect-ratio: 9 / 16;
  margin-inline: auto;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  overflow: hidden;
  text-align: center;
}

.game__stage--wide { width: 100%; aspect-ratio: 16 / 10; }
.game__poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.7; }
.game__stage .btn { position: relative; }
.game__frame { display: block; width: 100%; height: 100%; border: 0; background: var(--ink); }

.sim h3:focus { outline: none; }
.sim h3:focus-visible { outline: none; text-decoration: underline 3px var(--gold); text-underline-offset: 0.2em; }
