/* Feelings Quest / Misi Perasaan - style.css
   Calm pastel palette, AA contrast, tablet-first, one task per screen.
   Touch targets at least 120px. Slow animations (<= 1 Hz), fades around 300ms. */

:root {
  --bg: #F7F4EE;
  --ink: #1F2C36;
  --muted: #4C5D69;
  --card: #FFFFFF;
  --line: #C9D3D9;
  --accent: #2F6E80;
  --accent-soft: #DCEAEE;
  --plum: #6B4E8E;
  --plum-soft: #E8E1F1;
  --star: #C9922A;
  --star-soft: #FBEFD0;
  --ok: #2B6B4F;
  --ok-soft: #DDEFE4;
  --warn: #8A5A2B;
  --shadow: 0 2px 8px rgba(31, 44, 54, 0.10);
  --radius: 22px;
  --tap: 120px;
  --fade: 300ms;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 20px;
  line-height: 1.35;
  overscroll-behavior: none;
}

body { touch-action: manipulation; }

#app { min-height: 100%; display: flex; flex-direction: column; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px clamp(14px, 3vw, 34px) 26px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  animation: fadein var(--fade) ease both;
}

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

h1, h2, h3 { margin: 0 0 6px; line-height: 1.2; font-weight: 700; }
h1 { font-size: clamp(30px, 5vw, 46px); }
h2 { font-size: clamp(24px, 3.6vw, 34px); }
h3 { font-size: clamp(20px, 2.6vw, 26px); }
p { margin: 0 0 8px; }

.muted { color: var(--muted); }
.center { text-align: center; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.wrap { display: flex; flex-wrap: wrap; gap: 12px; }
.grow { flex: 1 1 auto; }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding-bottom: 6px; border-bottom: 2px solid var(--line);
  padding-left: clamp(104px, 12vw, 150px); /* keeps controls clear of the hidden exit corner */
}

/* ------------------------------------------------------------- buttons */
button {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 20px;
  cursor: pointer;
  transition: transform 140ms ease, background var(--fade) ease;
}
button:active { transform: scale(0.98); }
button:focus-visible { outline: 4px solid var(--accent); outline-offset: 2px; }

.btn {
  min-height: var(--tap);
  min-width: var(--tap);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 21px; font-weight: 600;
}
.btn-primary { background: var(--accent); color: #FFFFFF; border-color: var(--accent); }
.btn-plum { background: var(--plum); color: #FFFFFF; border-color: var(--plum); }
.btn-star { background: var(--star-soft); border-color: var(--star); color: var(--ink); }
.btn-quiet { background: var(--accent-soft); border-color: var(--accent); }
.btn-danger { background: #FBE9E7; border-color: #B5544A; color: #7A2E26; }
.btn[disabled], button[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn-huge {
  min-height: 160px;
  font-size: clamp(26px, 4vw, 38px);
  border-radius: 30px;
  padding: 20px 46px;
}

/* --------------------------------------------------------------- cards */
.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card-title { font-weight: 700; margin-bottom: 8px; }

/* choice cards, at least 120px tall, tap only */
.choices { display: grid; gap: 18px; width: 100%; }
.choices.recognition { grid-template-columns: repeat(4, 1fr); }
.choices.response { grid-template-columns: repeat(3, 1fr); }
.choice {
  min-height: var(--tap);
  min-width: var(--tap);
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 14px;
  cursor: pointer;
  transition: transform 140ms ease, border-color var(--fade) ease, background var(--fade) ease;
  user-select: none;
  text-align: center;
}
.choice:active { transform: scale(0.98); }
.choice .face-svg { width: clamp(78px, 12vw, 132px); height: auto; }
.choice .choice-label { font-size: clamp(17px, 2.2vw, 24px); font-weight: 700; }
.choice .choice-icon { font-size: clamp(46px, 8vw, 76px); line-height: 1; }
.choice .choice-text { font-size: clamp(16px, 2vw, 22px); font-weight: 600; }
.choice.pulse { animation: pulse 900ms ease-in-out infinite alternate; border-color: var(--star); background: var(--star-soft); }
.choice.chosen { border-color: var(--accent); background: var(--accent-soft); }

@keyframes pulse {
  from { transform: scale(1); box-shadow: 0 0 0 rgba(201, 146, 42, 0.0); }
  to { transform: scale(1.04); box-shadow: 0 0 0 10px rgba(201, 146, 42, 0.16); }
}

/* ------------------------------------------------------------ child view */
.scene { font-size: clamp(72px, 16vw, 170px); line-height: 1.05; text-align: center; }
.caption { font-size: clamp(22px, 3.4vw, 34px); font-weight: 700; text-align: center; }
.prompt { font-size: clamp(24px, 3.6vw, 36px); font-weight: 800; text-align: center; color: var(--accent); }
.face-cue { display: flex; justify-content: center; }
.face-cue .face-svg { width: clamp(96px, 15vw, 170px); }

.stars-row { display: flex; gap: 6px; font-size: 30px; flex-wrap: wrap; min-height: 40px; }
.star-pop { animation: starpop 600ms ease both; }
@keyframes starpop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ------------------------------------------------------- schedule bar */
.schedule { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.schedule .step {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--card); border: 2px solid var(--line);
  font-weight: 700; font-size: 17px;
}
.schedule .step.done { background: var(--ok-soft); border-color: var(--ok); }
.schedule .step.active { background: var(--accent-soft); border-color: var(--accent); }
.schedule .arrow { color: var(--muted); font-weight: 700; }

.progressbar { height: 20px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; border: 2px solid var(--line); }
.progressbar > span { display: block; height: 100%; background: var(--accent); transition: width var(--fade) ease; }

/* -------------------------------------------------------------- buddy */
.buddy { display: flex; align-items: center; gap: 12px; }
.buddy-svg { width: clamp(64px, 9vw, 108px); height: auto; }
.buddy-svg.big { width: clamp(120px, 18vw, 210px); }

.ai-badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: var(--plum-soft); border: 2px solid var(--plum);
  color: var(--plum); font-size: 15px; font-weight: 700;
}

/* ---------------------------------------------------------- overlays */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(247, 244, 238, 0.97);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; padding: 24px; text-align: center;
  animation: fadein var(--fade) ease both;
}
.breathe-circle {
  width: clamp(160px, 30vw, 320px); height: clamp(160px, 30vw, 320px);
  border-radius: 50%;
  background: var(--accent-soft);
  border: 6px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: var(--accent);
  animation: breathe 7s ease-in-out infinite;
}
@keyframes breathe {
  0% { transform: scale(0.62); }
  50% { transform: scale(1); }
  100% { transform: scale(0.62); }
}
.help-card {
  min-height: 190px; min-width: 240px;
  border: 4px dashed var(--plum); border-radius: 26px;
  background: var(--plum-soft); color: var(--plum);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  font-size: 30px; font-weight: 800; padding: 24px; cursor: pointer;
}
.wait-stars { font-size: clamp(50px, 9vw, 96px); letter-spacing: 12px; animation: twinkle 5s ease-in-out infinite; }
@keyframes twinkle { 0% { opacity: 0.55; } 50% { opacity: 1; } 100% { opacity: 0.55; } }

/* --------------------------------------------------------- teacher bits */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-weight: 700; font-size: 18px; }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  font: inherit; padding: 12px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  min-height: 56px; width: 100%;
}
textarea { min-height: 96px; resize: vertical; }

.toggle { display: flex; align-items: center; gap: 12px; padding: 10px 0; font-weight: 600; }
.toggle input { width: 30px; height: 30px; }

.child-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px; border: 2px solid var(--line); border-radius: 18px; background: var(--card);
  margin-bottom: 10px;
}
.child-row.active { border-color: var(--accent); background: var(--accent-soft); }
.child-row .code { font-weight: 800; font-size: 22px; }

.pinpad { display: grid; grid-template-columns: repeat(3, minmax(var(--tap), 1fr)); gap: 14px; max-width: 520px; margin: 0 auto; }
.pinpad button { min-height: var(--tap); font-size: 34px; font-weight: 800; }
.pin-dots { display: flex; gap: 16px; justify-content: center; margin: 10px 0; }
.pin-dots span { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent); }
.pin-dots span.on { background: var(--accent); }

/* ------------------------------------------------------------- tables */
table { border-collapse: collapse; width: 100%; background: var(--card); border-radius: 14px; overflow: hidden; }
th, td { border: 1px solid var(--line); padding: 10px 12px; text-align: center; font-size: 18px; }
th { background: var(--accent-soft); font-weight: 700; }
td.left, th.left { text-align: left; }

.grid-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.cell { border: 2px solid var(--line); border-radius: 12px; padding: 8px; text-align: center; font-weight: 700; font-size: 16px; }
.cell.ok { background: var(--ok-soft); border-color: var(--ok); }
.cell.no { background: #F6E7E4; border-color: #B5544A; }

/* simple CSS bar chart */
.chart { display: flex; gap: 26px; align-items: flex-end; min-height: 240px; padding: 12px; border: 2px solid var(--line); border-radius: 18px; background: var(--card); }
.chart .bar-group { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; }
.chart .bars { display: flex; gap: 10px; align-items: flex-end; height: 180px; }
.chart .bar { width: clamp(30px, 6vw, 56px); border-radius: 10px 10px 0 0; background: var(--accent); transition: height var(--fade) ease; }
.chart .bar.post { background: var(--plum); }
.chart .bar-label { font-size: 15px; font-weight: 700; }

.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px; }
.sticker { border: 3px solid var(--line); border-radius: 18px; padding: 12px; text-align: center; background: var(--card); }
.sticker.locked { opacity: 0.45; filter: grayscale(1); }
.sticker .icon { font-size: 46px; }
.sticker .name { font-size: 15px; font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #FFFFFF; padding: 14px 22px; border-radius: 999px;
  font-weight: 700; z-index: 60; animation: fadein var(--fade) ease both;
}

/* hidden teacher exit: top-left corner, hold 3 seconds */
#exitzone {
  position: fixed; top: 0; left: 0; width: 96px; height: 96px; z-index: 90;
  opacity: 0;
}
#exitzone.arming { opacity: 1; background: rgba(47, 110, 128, 0.35); border-bottom-right-radius: 24px; }

/* ---------------------------------------------------- calm mode + motion */
body.calm { --fade: 400ms; }
body.calm, body.calm .screen { animation: none; }
body.calm .choice.pulse { animation: none; border-color: var(--muted); }
body.calm .breathe-circle { animation-duration: 10s; }
body.calm .wait-stars { animation: none; opacity: 0.9; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* --------------------------------------------------------- responsive */
@media (orientation: portrait) and (max-width: 900px) {
  .choices.recognition { grid-template-columns: repeat(2, 1fr); }
  .choices.response { grid-template-columns: repeat(1, 1fr); }
  .choice { min-height: 132px; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .scene { font-size: clamp(54px, 11vw, 110px); }
  .choices.response { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
  html, body { font-size: 18px; }
  .btn { min-height: var(--tap); font-size: 19px; }
}

/* -------------------------------------------------------------- print */
@media print {
  .no-print, #exitzone, .toast { display: none !important; }
  body { background: #FFFFFF; font-size: 12pt; }
  .screen { box-shadow: none; }
  .card, table { box-shadow: none; }
  .chart { break-inside: avoid; }
}
