/* Calcuwater — trang giới thiệu tĩnh, phục vụ tại /calcuwater.
   Nét vẽ của bộ asset là viền nâu dày + mảng màu phẳng, nên giao diện cũng dùng
   viền nâu và bóng cứng (không blur) thay cho bóng mờ. */

:root {
  --ink: #4a2a12;        /* nét viền nâu của tranh */
  --deep: #0c4a5e;       /* chữ chính, nước sâu */
  --teal: #16a3b7;       /* nút chính */
  --teal-dark: #0e7f92;
  --aqua: #dff4f7;       /* nền trang */
  --foam: #f5fcfd;
  --sand: #fff1d2;
  --coin: #ffc531;
  --rose: #f6b3aa;
  --line: 2.5px solid var(--ink);
  --drop: 0 5px 0 var(--ink);
  --display: "Baloo 2", "Be Vietnam Pro", system-ui, sans-serif;
  --body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--aqua);
  color: var(--deep);
  font: 400 1.0625rem/1.65 var(--body);
}
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); line-height: 1.12; color: var(--ink); text-wrap: balance; }
h1 { font-size: clamp(2.5rem, 6.2vw, 4.25rem); font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.85rem, 3.6vw, 2.6rem); font-weight: 800; }
h3 { font-size: 1.3rem; font-weight: 700; }
:focus-visible { outline: 3px solid var(--deep); outline-offset: 3px; border-radius: 8px; }

.wrap { width: min(100% - 2.5rem, 1120px); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .6rem 1rem; z-index: 20; }
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- Thanh trên ---------- */
.top { padding: 1rem 0 0; }
.top-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand {
  display: inline-flex; align-items: center; gap: .6rem;
  font: 800 1.35rem/1 var(--display); color: var(--ink); text-decoration: none;
}
.brand img { border-radius: 11px; border: 2px solid var(--ink); }
.top-links { display: flex; align-items: center; gap: 1.5rem; font-weight: 500; font-size: .98rem; }
.top-links a { text-decoration: none; }
.top-links a:hover { text-decoration: underline; text-underline-offset: 4px; }
.link-pill {
  display: inline-block; padding: .4rem .95rem; background: var(--sand);
  border: var(--line); border-radius: 999px; box-shadow: 0 3px 0 var(--ink);
}
.wide-only { display: none; }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  font: 700 1.2rem/1 var(--display); text-decoration: none; cursor: pointer;
  padding: .9rem 1.5rem; border: var(--line); border-radius: 18px; box-shadow: var(--drop);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn-main { width: 100%; background: var(--teal); color: #fff; }
.btn-main:hover { background: var(--teal-dark); }
.btn-light { background: var(--sand); color: var(--ink); }

/* ---------- Hero ---------- */
.hero { padding: clamp(2rem, 5vw, 4rem) 0 clamp(3rem, 7vw, 5.5rem); }
.hero-grid { display: grid; gap: 2.5rem; align-items: center; }
.lead { margin-top: 1.25rem; font-size: 1.2rem; max-width: 34em; }
.try-hint {
  display: flex; gap: .6rem; align-items: flex-start; margin-top: 1.5rem;
  max-width: 30em; font-size: .98rem; font-weight: 500; color: var(--ink);
}
.try-hint img { flex: none; margin-top: .2rem; }

.demo { width: 100%; max-width: 540px; margin-inline: auto; }
.stage { position: relative; padding: 0 12px; }

.tank {
  position: relative; aspect-ratio: 5 / 3.3; overflow: hidden;
  container-type: inline-size;
  background: linear-gradient(#fbfeff, #eaf8fa);
  border: 3px solid var(--ink); border-radius: 26px 26px 12px 12px;
}
.water {
  position: absolute; inset: auto 0 0 0; height: calc(var(--level) * 1%);
  background: url(/calcuwater/assets/img/tank/blue-wash.webp) center bottom / cover #9fdcf2;
  border-top: 4px solid rgba(255, 255, 255, .95);
  transition: height 1.3s cubic-bezier(.3, 1.35, .5, 1);
}
.pebbles {
  position: absolute; inset: auto 0 0 0; height: 17%;
  background: url(/calcuwater/assets/img/tank/pebbles.webp) center bottom / auto 100% repeat-x;
}
.plant { position: absolute; bottom: 8%; width: auto; }
.plant-l { left: 5%; height: 44%; }
.plant-r { left: 31%; height: 30%; }

.fish, .stage-fish, .sprite, .capy { background-repeat: no-repeat; }
.fish {
  position: absolute; left: 0; top: var(--y);
  width: var(--s); aspect-ratio: 1;
  background-image: var(--sheet); background-size: 800% 400%;
  background-position: 0 var(--row);
  animation: frames .9s steps(8, jump-none) infinite, swim var(--t) linear var(--d) infinite;
}
@keyframes frames { from { background-position-x: 0%; } to { background-position-x: 100%; } }
@keyframes swim {
  0%   { transform: translateX(-2cqw) scaleX(1); }
  48%  { transform: translateX(80cqw) scaleX(1); }
  50%  { transform: translateX(80cqw) scaleX(-1); }
  98%  { transform: translateX(-2cqw) scaleX(-1); }
  100% { transform: translateX(-2cqw) scaleX(1); }
}

.pop {
  position: absolute; left: 50%; top: 18%; translate: -50% 0;
  font: 800 clamp(1.6rem, 8cqw, 2.6rem)/1 var(--display); color: #fff;
  -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill;
  opacity: 0; pointer-events: none;
}
.demo.splash .pop { animation: pop 1.5s ease-out; }
@keyframes pop {
  0% { opacity: 0; transform: translateY(40%) scale(.7); }
  20% { opacity: 1; transform: translateY(0) scale(1.08); }
  75% { opacity: 1; transform: translateY(-20%) scale(1); }
  100% { opacity: 0; transform: translateY(-60%) scale(1); }
}

.shelf {
  height: 26px; margin: 0 -12px;
  background: url(/calcuwater/assets/img/tank/shelf.webp) center / 100% 100%;
  border: var(--line); border-radius: 6px;
}

.sign {
  position: absolute; left: 0; bottom: 20px; width: 27%; aspect-ratio: 4 / 3;
  background: url(/calcuwater/assets/img/tank/sign.webp) center / contain no-repeat;
}
.sign span {
  position: absolute; inset: 14% 12% 34% 10%; display: grid; place-content: center;
  text-align: center; color: var(--ink); font: 500 clamp(.5rem, 1.85vw, .68rem)/1.25 var(--body);
  rotate: -2deg;
}
.sign b { display: block; font: 800 1.6em/1.1 var(--display); }

/* Capy: lưới 8 cột x 9 hàng, mỗi hàng là một trạng thái. */
.capy, .sprite {
  aspect-ratio: 1;
  background-image: url(/calcuwater/assets/img/capy/capy.webp);
  background-size: 800% 900%;
  background-position: 0 var(--row, 0%);
  animation: frames 1.1s steps(8, jump-none) infinite;
}
.capy { position: absolute; right: -8px; bottom: 2px; width: 40%; --row: 12.5%; }
.demo[data-state="remind"] .capy { --row: 25%; }
.demo[data-state="urgent"] .capy { --row: 37.5%; animation-duration: .7s; }
.demo[data-state="faint"]  .capy { --row: 50%; animation: frames-once-a 1.3s steps(8, jump-none) forwards; }
.demo[data-state="pour"]   .capy { --row: 62.5%; animation: frames-once-b 1.2s steps(8, jump-none) forwards; }
.demo[data-state="cheer"]  .capy { --row: 75%; animation: frames-once-a 1.1s steps(8, jump-none) forwards; }
.demo[data-state="rest"]   .capy { --row: 87.5%; animation-duration: 1.6s; }
.demo[data-state="done"]   .capy { --row: 87.5%; animation-duration: 1.6s; }
@keyframes frames-once-a { from { background-position-x: 0%; } to { background-position-x: 100%; } }
@keyframes frames-once-b { from { background-position-x: 0%; } to { background-position-x: 100%; } }

.bubble {
  position: absolute; right: 22px; top: 12px; max-width: 58%;
  padding: .55rem .9rem; background: #fff; color: var(--ink);
  border: var(--line); border-radius: 18px;
  font: 600 clamp(.82rem, 2.6vw, .98rem)/1.35 var(--body); text-align: center;
}
.bubble::after {
  content: ""; position: absolute; right: 26%; bottom: -11px; width: 18px; height: 18px;
  background: #fff; border-right: var(--line); border-bottom: var(--line);
  transform: rotate(45deg) skew(8deg, 8deg);
}
.demo[data-state="urgent"] .bubble { background: #fff2ef; font-weight: 600; animation: shake .45s 3; }
@keyframes shake { 25% { transform: translateX(-3px) rotate(-1deg); } 75% { transform: translateX(3px) rotate(1deg); } }
.demo[data-state="urgent"] .bubble::after { background: #fff2ef; }

.panel {
  margin-top: 1.4rem; padding: 1.1rem 1.2rem 1rem;
  background: #fff; border: var(--line); border-radius: 22px; box-shadow: var(--drop);
}
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.count { font: 700 1.2rem/1.2 var(--display); color: var(--ink); }
.count b { font-weight: 800; font-size: 1.5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .7rem;
  background: var(--aqua); border-radius: 999px; font-weight: 600; font-size: .9rem;
}
.pills { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: .8rem 0 1rem; }
.pills li { height: 12px; border-radius: 999px; background: #dbe7ea; transition: background .4s; }
.pills li.on { background: var(--teal); }
.fine { margin-top: .7rem; text-align: center; font-size: .82rem; color: #4d7684; }

/* ---------- Dải nội dung ---------- */
.band { padding: clamp(3.5rem, 8vw, 6rem) 0; }
.band-foam { background: var(--foam); border-block: var(--line); }
.band-sand { background: var(--sand); border-block: var(--line); }
.band-deep { background: var(--deep); color: #e9f9fc; border-top: var(--line); }
.head { max-width: 40em; margin-bottom: 2.5rem; }
.head p { margin-top: .8rem; font-size: 1.1rem; }

/* Một ngày của Capy — đúng là một trình tự, nên đánh số. */
.day { display: grid; gap: 1.75rem; counter-reset: step; }
.day li {
  counter-increment: step; display: grid; grid-template-columns: 112px 1fr;
  column-gap: 1rem; align-items: start;
}
.day .sprite { grid-row: span 2; width: 112px; }
.day h3 { align-self: end; padding-top: .6rem; }
.day h3::before {
  content: counter(step); display: inline-grid; place-content: center;
  width: 1.6em; height: 1.6em; margin-right: .45rem; vertical-align: .05em;
  background: var(--coin); border: 2px solid var(--ink); border-radius: 50%;
  font-size: .8em; line-height: 1;
}
.day p { font-size: .98rem; margin-top: .3rem; }

/* Trứng + cá */
.eggs { display: flex; flex-wrap: wrap; gap: 1rem 2rem; margin-bottom: 2.5rem; }
.eggs li { display: grid; justify-items: center; gap: .2rem; font: 700 1.05rem/1.2 var(--display); color: var(--ink); }
.eggs img { width: 84px; }

.grow {
  padding: 1.25rem; border: var(--line); border-radius: 26px; box-shadow: var(--drop);
  background: url(/calcuwater/assets/img/tank/blue-wash.webp) center / cover #9fdcf2;
}
.grow-name { font: 800 1.6rem/1 var(--display); color: var(--ink); }
.stages { display: grid; grid-template-columns: repeat(4, 1fr); gap: .25rem; align-items: end; margin: .5rem 0 1rem; }
.stages li { display: grid; justify-items: center; }
.stages span { font-weight: 600; font-size: .85rem; color: var(--ink); text-align: center; }
.stage-fish {
  width: min(100%, 190px); aspect-ratio: 1;
  background-image: var(--sheet); background-size: 800% 400%;
  background-position: 0 var(--row);
  animation: frames .9s steps(8, jump-none) infinite;
}
.picker { display: flex; flex-wrap: wrap; gap: .5rem; }
.picker button {
  padding: 3px; background: rgba(255, 255, 255, .7); cursor: pointer;
  border: 2px solid transparent; border-radius: 16px;
}
.picker button:hover { background: #fff; }
.picker button[aria-pressed="true"] { background: #fff; border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.picker img { width: 52px; height: 52px; }

/* Trang trí */
.decor-grid { display: grid; gap: 2.5rem; align-items: center; }
.decor-copy p { margin-top: .9rem; max-width: 30em; }
.backdrops { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1.5rem; }
.backdrops li { display: grid; gap: .35rem; font-size: .82rem; font-weight: 600; color: var(--ink); }
.backdrops img { width: 84px; height: 84px; object-fit: cover; border: var(--line); border-radius: 18px; }
.display { position: relative; padding: 0 12px; }
.display-items { display: flex; align-items: flex-end; justify-content: space-around; gap: 2%; padding: 0 3% 0 24%; }
.display-items img { width: auto; height: clamp(64px, 15vw, 130px); min-width: 0; flex: 0 1 auto; object-fit: contain; }
.display-coin { position: absolute; left: 4%; bottom: 18px; width: 20%; }

/* Việc khác của Capy */
.extras { display: grid; gap: 1.5rem; }
.extras article {
  display: grid; grid-template-columns: 96px 1fr; gap: 1rem; align-items: center;
  padding: 1rem 1.25rem; background: #fff; border: var(--line); border-radius: 22px;
}
.extras p { margin-top: .3rem; font-size: .98rem; }

/* Ra mắt */
.launch { display: grid; gap: 1.5rem; justify-items: center; text-align: center; }
.launch img { width: min(60%, 260px); }
.launch h2 { color: #fff; }
.launch p { margin: .8rem auto 1.6rem; max-width: 30em; font-size: 1.1rem; }

/* Chân trang */
.foot { background: var(--deep); color: #cfeaf0; padding: 0 0 2.5rem; font-size: .92rem; }
.foot-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
  padding-top: 1.75rem; border-top: 1px solid rgba(255, 255, 255, .2);
}
.foot .brand { color: #fff; font-size: 1.15rem; }
.foot ul { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.foot-note { margin-top: 1.25rem; max-width: 1120px; color: #a9d3dc; font-size: .84rem; }

/* ---------- Màn rộng ---------- */
@media (min-width: 720px) {
  .wide-only { display: block; }
  .day { grid-template-columns: repeat(5, 1fr); gap: 1.25rem; }
  .day li { grid-template-columns: 1fr; align-content: start; }
  .day .sprite { grid-row: auto; width: min(100%, 170px); }
  .day h3 { font-size: 1.15rem; align-self: start; }
  .extras { grid-template-columns: repeat(3, 1fr); }
  .extras article { grid-template-columns: 1fr; justify-items: start; align-items: start; }
  .extras img { width: 120px; }
  .grow { padding: 2rem; }
  .launch { grid-template-columns: auto 1fr; justify-items: start; text-align: left; gap: 3rem; align-items: center; }
  .launch img { width: 260px; }
  .launch p { margin-inline: 0; }
}
@media (min-width: 960px) {
  .hero-grid { grid-template-columns: 1fr minmax(0, 540px); gap: 3.5rem; }
  .decor-grid { grid-template-columns: 5fr 7fr; gap: 3.5rem; }
  .sign span { font-size: .68rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fish, .stage-fish, .sprite, .capy, .bubble, .demo.splash .pop { animation: none !important; }
  .fish { left: var(--rest, 20%); }
  .fish:nth-of-type(3) { --rest: 45%; }
  .fish:nth-of-type(4) { --rest: 8%; }
  .fish:nth-of-type(5) { --rest: 60%; }
  .water { transition: none; }
  /* Không chạy frame thì chọn sẵn frame “đẹp” của các hàng một-lần. */
  .demo[data-state="faint"] .capy, .demo[data-state="pour"] .capy { background-position-x: 57.143%; }
  .demo[data-state="cheer"] .capy { background-position-x: 42.857%; }
}

/* ---------- Trang văn bản: privacy + support ---------- */
.top-links a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2.5px; text-underline-offset: 5px; }
.doc { padding: clamp(2rem, 5vw, 3.5rem) 0 clamp(3.5rem, 8vw, 6rem); }
.doc .wrap { width: min(100% - 2.5rem, 760px); }
.doc-head { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: end; margin-bottom: 2rem; }
.doc-head h1 { font-size: clamp(2.2rem, 5.5vw, 3.25rem); }
.doc-head .meta { grid-column: 1; margin-top: .6rem; font-size: .98rem; }
.doc-head img { grid-column: 2; grid-row: 1 / span 2; width: clamp(84px, 22vw, 140px); }
.doc h2 { font-size: 1.55rem; margin: 2.4rem 0 .7rem; scroll-margin-top: 1rem; }
.doc h3 { font-size: 1.15rem; margin: 1.4rem 0 .4rem; }
.doc p { margin-bottom: .9rem; }
.doc main a, .doc a { text-decoration-thickness: 2px; text-underline-offset: 3px; }
.doc ul { list-style: disc; padding-left: 1.3rem; margin-bottom: 1rem; }
.doc li { margin-bottom: .4rem; }
.doc li::marker { color: var(--teal); }
.note-card {
  padding: 1.25rem 1.4rem; background: #fff;
  border: var(--line); border-radius: 22px; box-shadow: var(--drop);
}
.note-card h2 { margin-top: 0; }
.note-card > :last-child { margin-bottom: 0; }
.toc { list-style: decimal; padding-left: 1.5rem; margin: 2rem 0 0; columns: 2 16rem; column-gap: 2.5rem; font-weight: 500; }
.toc li { margin-bottom: .35rem; break-inside: avoid; }
.doc table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.2rem; font-size: .96rem; background: #fff; border: var(--line); }
.doc th, .doc td { padding: .7rem .9rem; text-align: left; vertical-align: top; border-bottom: 1px solid #cfe3e7; }
.doc th { font: 700 1rem/1.3 var(--display); color: var(--ink); background: var(--sand); border-bottom: var(--line); }
.doc tr:last-child td { border-bottom: 0; }
.faq details { background: #fff; border: var(--line); border-radius: 16px; margin-bottom: .7rem; }
.faq summary {
  cursor: pointer; padding: .85rem 1.1rem; list-style-position: outside;
  font: 700 1.1rem/1.3 var(--display); color: var(--ink); margin-left: 1.4rem; padding-left: .2rem;
}
.faq details[open] summary { padding-bottom: .4rem; }
.faq details p { padding: 0 1.1rem .5rem; margin-bottom: .5rem; }
@media (max-width: 560px) {
  .doc th, .doc td { padding: .6rem .65rem; }
}
