/* ============================================================
   Tiga M — sistem visual
   Nada: tenang, mesra, jelas. Warm carried by amber + Nunito.
   ============================================================ */

:root {
  /* Neutrals & surface */
  --canvas:      oklch(0.985 0.005 80);
  --surface:     oklch(1 0 0);
  --surface-2:   oklch(0.975 0.006 80);
  --ink:         oklch(0.24 0.012 65);
  --ink-soft:    oklch(0.45 0.018 65);
  --ink-faint:   oklch(0.60 0.018 65);
  --line:        oklch(0.91 0.008 70);
  --line-strong: oklch(0.85 0.01 70);

  /* Brand — amber / honey */
  --primary:      oklch(0.78 0.12 78);
  --primary-soft: oklch(0.93 0.05 80);
  --primary-deep: oklch(0.52 0.12 65);
  --primary-ink:  oklch(0.30 0.07 60);

  /* Skill tints (meaningful) */
  --read:   oklch(0.83 0.085 82);
  --read-ink:  oklch(0.42 0.08 70);
  --write:  oklch(0.84 0.07 30);
  --write-ink: oklch(0.45 0.10 32);
  --count:  oklch(0.85 0.055 178);
  --count-ink: oklch(0.42 0.06 195);

  /* Feedback */
  --star:    oklch(0.79 0.14 78);
  --success: oklch(0.62 0.11 150);
  --focus:   oklch(0.55 0.13 65);
  --locked:  oklch(0.80 0.004 80);

  /* Radii */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Shadows — soft, low */
  --shadow-sm: 0 1px 2px oklch(0.4 0.02 70 / 0.06), 0 2px 6px oklch(0.4 0.02 70 / 0.05);
  --shadow-md: 0 2px 6px oklch(0.4 0.02 70 / 0.07), 0 10px 24px oklch(0.4 0.02 70 / 0.08);
  --shadow-lg: 0 4px 12px oklch(0.4 0.02 70 / 0.08), 0 18px 50px oklch(0.4 0.02 70 / 0.12);

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 220ms;

  /* z-scale */
  --z-tabbar: 100;
  --z-overlay: 200;
  --z-sheet: 210;
  --z-toast: 300;

  --tab-h: 76px;
  --top-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; min-width: 0; }

html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; max-width: 100%; }

body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }

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

/* ===================== App shell ===================== */

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky; top: 0; z-index: var(--z-tabbar);
  height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(1rem, 4vw, 2rem);
  padding-top: env(safe-area-inset-top);
  background: oklch(0.985 0.005 80 / 0.82);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 0.55rem; }
.brand__mark {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  background: var(--primary);
  color: var(--primary-ink);
  font-weight: 800; font-size: 0.85rem; letter-spacing: -0.02em;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
}
.brand__name { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; }

.topbar__stat {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-weight: 800; font-size: 1.05rem;
  background: var(--primary-soft);
  color: var(--primary-ink);
  padding: 0.3rem 0.7rem;
  border-radius: var(--r-pill);
}
.topbar__stat .star { color: var(--star); }

.screen {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(1.25rem, 5vw, 2.25rem) clamp(1rem, 4vw, 2rem) calc(var(--tab-h) + 2rem);
  outline: none;
  min-width: 0;
}

/* ===================== Tab bar ===================== */

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: var(--z-tabbar);
  display: flex;
  background: oklch(1 0 0 / 0.9);
  backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 0.6rem 0.25rem 0.7rem;
  color: var(--ink-faint);
  font-size: 0.78rem; font-weight: 700;
  transition: color var(--dur) var(--ease);
}
.tab__icon { font-size: 1.4rem; line-height: 1; filter: grayscale(0.4); transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease); }
.tab[aria-current="page"] { color: var(--primary-deep); }
.tab[aria-current="page"] .tab__icon { filter: grayscale(0); transform: translateY(-2px) scale(1.08); }
.tab:active .tab__icon { transform: scale(0.92); }

/* ===================== Typography helpers ===================== */

.h-greet { font-size: 1rem; font-weight: 700; color: var(--ink-soft); }
.h-title {
  font-size: clamp(1.65rem, 6vw, 2.1rem); font-weight: 800;
  letter-spacing: -0.02em; line-height: 1.12; text-wrap: balance;
  margin-top: 0.15rem;
}
.h-section {
  font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em;
  margin: 2rem 0 0.9rem;
}
.muted { color: var(--ink-soft); }
.lede { font-size: 1.05rem; color: var(--ink-soft); max-width: 60ch; }

/* ===================== Buttons ===================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-weight: 800; font-size: 1.05rem;
  padding: 0.9rem 1.4rem;
  border-radius: var(--r-md);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn--primary {
  background: var(--primary); color: var(--primary-ink);
  box-shadow: var(--shadow-md);
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn--primary:active { transform: translateY(0) scale(0.98); }
.btn--ghost {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn--ghost:hover { background: var(--surface-2); border-color: var(--ink-faint); }
.btn--block { width: 100%; }
.btn--lg { padding: 1.1rem 1.6rem; font-size: 1.15rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ===================== Cards ===================== */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

/* Today's session — the hero */
.today {
  position: relative; overflow: hidden;
  padding: clamp(1.4rem, 5vw, 1.9rem);
  border-radius: var(--r-xl);
  background:
    radial-gradient(120% 140% at 100% 0%, var(--primary-soft) 0%, transparent 55%),
    var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.today__eyebrow { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; color: var(--ink-soft); font-size: 0.95rem; }
.today__tahap { margin-top: 0.6rem; font-size: 0.9rem; font-weight: 800; color: var(--primary-deep); }
.today__name { margin-top: 0.2rem; font-size: clamp(1.5rem, 6vw, 1.95rem); font-weight: 800; letter-spacing: -0.02em; text-wrap: balance; }
.today__goal { margin-top: 0.5rem; color: var(--ink-soft); }
.today__cta { margin-top: 1.3rem; }

/* Mini journey strip */
.strip { display: flex; align-items: center; gap: 0.4rem; margin-top: 1.1rem; }
.strip__dot {
  flex: 1; height: 8px; border-radius: var(--r-pill);
  background: var(--line);
  transition: background var(--dur) var(--ease);
}
.strip__dot.is-done { background: var(--primary); }
.strip__dot.is-current { background: var(--primary-deep); position: relative; }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.82rem; font-weight: 800;
  padding: 0.28rem 0.7rem; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--ink-soft);
}
.chip--baca  { background: var(--read);  color: var(--read-ink); }
.chip--tulis { background: var(--write); color: var(--write-ink); }
.chip--kira  { background: var(--count); color: var(--count-ink); }
.chip--campur{ background: var(--primary-soft); color: var(--primary-ink); }

/* ===================== Journey (Perjalanan) ===================== */

.journey { list-style: none; display: flex; flex-direction: column; gap: 0; margin-top: 1.25rem; }
.node {
  position: relative;
  display: flex; gap: 1rem;
  padding-bottom: 1.4rem;
}
.node:not(:last-child) .node__rail::after {
  content: ""; position: absolute; left: 50%; top: 44px; bottom: -2px;
  width: 3px; transform: translateX(-50%);
  background: var(--line);
}
.node.is-done .node__rail::after { background: var(--primary); }
.node__rail { position: relative; flex: 0 0 44px; }
.node__badge {
  width: 44px; height: 44px; border-radius: var(--r-pill);
  display: grid; place-items: center;
  font-weight: 800; font-size: 1.1rem;
  background: var(--surface); border: 2px solid var(--line-strong); color: var(--ink-faint);
  box-shadow: var(--shadow-sm);
}
.node.is-done .node__badge { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.node.is-current .node__badge { background: var(--surface); border-color: var(--primary-deep); color: var(--primary-deep); box-shadow: 0 0 0 4px var(--primary-soft); }

.node__body { flex: 1; min-width: 0; }
.tahap-card {
  width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tahap-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.node.is-locked .tahap-card { background: var(--surface-2); box-shadow: none; cursor: not-allowed; opacity: 0.75; }
.node.is-locked .tahap-card:hover { transform: none; box-shadow: none; border-color: var(--line); }
.tahap-card__top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.tahap-card__name { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.01em; }
.tahap-card__motif { color: var(--ink-soft); font-size: 0.95rem; margin-top: 0.15rem; }
.tahap-card__meta { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.8rem; font-size: 0.85rem; font-weight: 700; color: var(--ink-faint); }
.tahap-card__bar { height: 7px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; margin-top: 0.7rem; }
.tahap-card__bar > span { display: block; height: 100%; background: var(--primary); border-radius: var(--r-pill); transition: width 0.5s var(--ease); }
.lock { font-size: 1.1rem; opacity: 0.6; }

/* ===================== Session list (within tahap) ===================== */

.backlink {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-weight: 800; color: var(--ink-soft);
  padding: 0.4rem 0; margin-bottom: 0.5rem;
}
.backlink:hover { color: var(--ink); }

.sesi-list { list-style: none; display: flex; flex-direction: column; gap: 0.7rem; margin-top: 1.1rem; }
.sesi-item {
  display: flex; align-items: center; gap: 0.9rem;
  width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.sesi-item:hover { transform: translateX(3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.sesi-item__check {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: var(--r-pill);
  display: grid; place-items: center;
  border: 2px solid var(--line-strong); color: transparent; font-size: 0.9rem; font-weight: 800;
  transition: all var(--dur) var(--ease);
}
.sesi-item.is-done .sesi-item__check { background: var(--success); border-color: var(--success); color: white; }
.sesi-item__main { flex: 1; min-width: 0; }
.sesi-item__title { font-weight: 800; font-size: 1.05rem; }
.sesi-item.is-done .sesi-item__title { color: var(--ink-soft); }
.sesi-item__sub { font-size: 0.82rem; color: var(--ink-faint); font-weight: 700; margin-top: 0.1rem; }
.sesi-item__go { color: var(--ink-faint); font-size: 1.2rem; }
.sesi-item.is-special { border-color: var(--primary); background: var(--primary-soft); }

/* Pintu naik callout */
.pintu {
  margin-top: 1.6rem; padding: 1.15rem 1.3rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.pintu__title { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; }
.pintu__list { list-style: none; margin-top: 0.8rem; display: flex; flex-direction: column; gap: 0.55rem; }
.pintu__list li { display: flex; gap: 0.6rem; color: var(--ink-soft); }
.pintu__list li::before { content: "✓"; color: var(--primary-deep); font-weight: 800; flex: 0 0 auto; }

/* ===================== Session player (Sesi) ===================== */

.player__head { margin-bottom: 1.3rem; }
.player__title { font-size: clamp(1.5rem, 6vw, 1.9rem); font-weight: 800; letter-spacing: -0.02em; text-wrap: balance; }
.player__progress { display: flex; gap: 0.35rem; margin-top: 1rem; }
.player__progress span { flex: 1; height: 6px; border-radius: var(--r-pill); background: var(--line); transition: background var(--dur) var(--ease); }
.player__progress span.is-active { background: var(--primary-deep); }
.player__progress span.is-past { background: var(--primary); }

.step {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: clamp(1.5rem, 6vw, 2.2rem);
  min-height: 240px;
  display: flex; flex-direction: column;
}
.step__phase {
  align-self: flex-start;
  font-size: 0.9rem; font-weight: 800;
  padding: 0.35rem 0.85rem; border-radius: var(--r-pill);
  background: var(--primary-soft); color: var(--primary-ink);
}
.step__num { margin-top: 1.1rem; font-size: 0.85rem; font-weight: 800; color: var(--ink-faint); letter-spacing: 0.02em; }
.step__text { margin-top: 0.5rem; font-size: clamp(1.25rem, 5vw, 1.5rem); line-height: 1.45; font-weight: 700; letter-spacing: -0.01em; text-wrap: pretty; }
.step__hint { margin-top: auto; padding-top: 1.3rem; color: var(--ink-faint); font-size: 0.95rem; }

.player__actions { display: flex; gap: 0.8rem; margin-top: 1.4rem; }
.player__actions .btn { flex: 1; }

/* Animated step transition */
.step-enter { animation: stepIn 320ms var(--ease) both; }
@keyframes stepIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===================== Progress (Kemajuan) ===================== */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.8rem; margin-top: 1.25rem; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.2rem; box-shadow: var(--shadow-sm);
}
.stat__num { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.stat__num .star { color: var(--star); }
.stat__label { margin-top: 0.4rem; color: var(--ink-soft); font-weight: 700; font-size: 0.9rem; }

.skill-prog { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1.1rem; }
.skill-row { display: flex; align-items: center; gap: 0.9rem; }
.skill-row__icon {
  flex: 0 0 46px; width: 46px; height: 46px; border-radius: var(--r-md);
  display: grid; place-items: center; font-size: 1.4rem;
}
.skill-row__icon.baca { background: var(--read); }
.skill-row__icon.tulis { background: var(--write); }
.skill-row__icon.kira { background: var(--count); }
.skill-row__main { flex: 1; min-width: 0; }
.skill-row__top { display: flex; justify-content: space-between; font-weight: 800; }
.skill-row__top small { color: var(--ink-faint); font-weight: 700; }
.skill-row__bar { height: 8px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; margin-top: 0.4rem; }
.skill-row__bar > span { display: block; height: 100%; border-radius: var(--r-pill); transition: width 0.6s var(--ease); }
.skill-row__bar.baca > span { background: var(--read-ink); }
.skill-row__bar.tulis > span { background: var(--write-ink); }
.skill-row__bar.kira > span { background: var(--count-ink); }

.empty {
  text-align: center; padding: 2.5rem 1rem;
  color: var(--ink-soft);
}
.empty__icon { font-size: 2.8rem; }

/* ===================== Cloud sync card ===================== */

.cloud {
  margin-top: 2rem;
  padding: 1.3rem 1.4rem;
  background: var(--surface-2);
}
.cloud__head { display: flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 1.15rem; }
.cloud__on {
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.02em;
  color: var(--success); background: oklch(0.62 0.11 150 / 0.12);
  padding: 0.15rem 0.5rem; border-radius: var(--r-pill);
}
.cloud .muted { margin-top: 0.5rem; }
.cloud__actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.1rem; }
.cloud__code {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  margin-top: 1rem; padding: 0.7rem 0.5rem 0.7rem 1rem;
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-md);
}
.cloud__code > span { font-size: 1.5rem; font-weight: 800; letter-spacing: 0.06em; color: var(--primary-deep); }
.cloud__copy { padding: 0.55rem 1rem; font-size: 0.95rem; }
.cloud__status { margin-top: 0.8rem; font-weight: 700; color: var(--ink-soft); font-size: 0.95rem; min-height: 1.2em; }
.cloud__unlink {
  margin-top: 1rem; font-weight: 700; color: var(--ink-faint);
  text-decoration: underline; text-underline-offset: 3px;
}
.cloud__unlink:hover { color: var(--write-ink); }
.cloud__join { margin-top: 1.1rem; }
.cloud__label { display: block; font-weight: 700; font-size: 0.9rem; color: var(--ink-soft); margin-bottom: 0.45rem; }
.cloud__joinrow { display: flex; gap: 0.6rem; }
.cloud__input {
  flex: 1; min-width: 0;
  font: inherit; font-weight: 800; letter-spacing: 0.05em;
  padding: 0.8rem 1rem; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  text-transform: uppercase;
}
.cloud__input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--primary-deep); }
.cloud__input::placeholder { color: var(--ink-faint); }

/* ===================== Toast / celebrate ===================== */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 1rem); z-index: var(--z-toast);
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--surface);
  font-weight: 800; padding: 0.8rem 1.3rem; border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  display: flex; align-items: center; gap: 0.5rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .star { color: var(--star); font-size: 1.2rem; }

/* Confetti-free celebration: a gentle star burst overlay */
.burst { position: fixed; inset: 0; z-index: var(--z-overlay); pointer-events: none; overflow: hidden; }
.burst span {
  position: absolute; top: 50%; left: 50%; font-size: 1.6rem;
  animation: burst 900ms var(--ease) forwards;
}
@keyframes burst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--bx)), calc(-50% + var(--by))) scale(1) rotate(var(--br)); }
}

/* ===================== View transition ===================== */

.view-enter { animation: viewIn 280ms var(--ease) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stagger > * { animation: viewIn 360ms var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: 40ms; }
.stagger > *:nth-child(2) { animation-delay: 90ms; }
.stagger > *:nth-child(3) { animation-delay: 140ms; }
.stagger > *:nth-child(4) { animation-delay: 190ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 290ms; }

/* ===================== Desktop: left rail ===================== */

@media (min-width: 860px) {
  :root { --tab-h: 0px; }
  .app {
    grid-template-columns: 248px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "top top"
      "nav main";
    min-height: 100dvh;
  }
  .topbar { grid-area: top; }
  .screen { grid-area: main; padding-bottom: clamp(2rem, 5vw, 3rem); }
  .tabbar {
    position: sticky; top: var(--top-h); align-self: start;
    grid-area: nav;
    flex-direction: column;
    height: calc(100dvh - var(--top-h));
    border-top: none; border-right: 1px solid var(--line);
    padding: 1.2rem 0.9rem;
    gap: 0.35rem;
    background: var(--surface-2);
  }
  .tab {
    flex: 0; flex-direction: row; justify-content: flex-start; gap: 0.8rem;
    padding: 0.85rem 1rem; border-radius: var(--r-md);
    font-size: 1rem;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .tab__icon { font-size: 1.3rem; }
  .tab[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow-sm); }
  .tab[aria-current="page"] .tab__icon { transform: none; }
  .tab:hover { background: var(--surface); }
}

/* ===================== Reduced motion ===================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .btn--primary:hover, .sesi-item:hover, .tahap-card:hover { transform: none; }
}
