/* ==========================================================================
   kidstarter.dev — vỏ tối giản
   Ý tưởng thị giác: một trang vở ô ly. Nền là lưới ô ly xanh nhạt, có lề đỏ
   dọc bên trái làm trục của cả trang. Chế độ tối không đảo màu suông mà đổi
   ẩn dụ: từ trang vở sang bảng đen, chữ phấn.
   ========================================================================== */

/* --------------------------------------------------------------- tokens -- */
:root {
  --paper:      #fdfcf8;  /* giấy vở, trắng ngả ấm                */
  --grid:       #cfdff1;  /* nét ô ly xanh nhạt                   */
  --ink:        #1f3a5f;  /* mực bút bi xanh đen                  */
  --pencil:     #5b6b7f;  /* chữ phụ, xám xanh                    */
  --marker:     #e4572e;  /* bút đỏ của cô giáo — nhấn, dùng ít   */
  --sticker:    #f2b705;  /* vàng phiếu bé ngoan                  */
  --card:       #ffffff;
  --card-edge:  #e6e0d2;
  --shadow:     18px 18px 40px -24px rgb(31 58 95 / 0.45);

  --grid-size: 24px;
  --measure: 62ch;
  --radius: 14px;

  --font-display: "Bricolage Grotesque", "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  --font-body: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:     #16201c;  /* bảng đen ngả xanh rêu */
    --grid:      #2f4038;
    --ink:       #f0ede4;  /* phấn trắng            */
    --pencil:    #a3b3a8;
    --marker:    #f0866b;  /* phấn đỏ               */
    --sticker:   #f5c95a;
    --card:      #1d2925;
    --card-edge: #33453c;
    --shadow:    18px 18px 40px -24px rgb(0 0 0 / 0.6);
  }
}

/* ---------------------------------------------------------------- reset -- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--paper);
  /* Lưới ô ly. Vẽ bằng gradient nên không tốn một request nào. */
  background-image:
    linear-gradient(to right,  var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  background-position: center top;
}

img { max-width: 100%; display: block; }

a {
  color: inherit;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

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

/* ------------------------------------------------------- khung + lề đỏ -- */
/* Cả trang treo vào một đường lề đỏ dọc, đúng như trang vở ô ly.           */
.sheet {
  --pad-left: clamp(1.5rem, 7vw, 5.5rem);
  position: relative;
  max-width: 68rem;
  margin-inline: auto;
  padding: clamp(2rem, 6vw, 4.5rem) clamp(1.25rem, 5vw, 3.5rem)
           clamp(3rem, 8vw, 6rem) var(--pad-left);
}

/* Đường lề. Vẽ tới đâu trang "được viết" tới đó khi tải xong. */
.sheet::before {
  content: "";
  position: absolute;
  inset-block: 0;
  left: calc(var(--pad-left) - clamp(0.75rem, 2.5vw, 1.75rem));
  width: 2px;
  background: var(--marker);
  opacity: 0.55;
  transform-origin: top;
  animation: rule-draw 900ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rule-draw {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}

/* --------------------------------------------------------------- nhịp -- */
/* Nội dung hiện dần từng dòng, như chữ được viết ra.                       */
.line {
  animation: line-in 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(180ms + var(--i, 0) * 90ms);
}

@keyframes line-in {
  from { opacity: 0; transform: translateY(0.5rem); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet::before,
  .line { animation: none; }
}

/* --------------------------------------------------------------- đầu trang */
.masthead {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: clamp(2.5rem, 7vw, 4rem);
}

.masthead__mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.masthead__dot { color: var(--marker); }

.masthead__tag {
  font-size: 0.8125rem;
  color: var(--pencil);
}

/* ---------------------------------------------------------------- hero -- */
.hero { max-width: var(--measure); }

.hero__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.15rem, 1.4rem + 3.6vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin: 0 0 1.25rem;
  text-wrap: balance;
}

.hero__title em {
  font-style: normal;
  /* Gạch chân kiểu bút dạ, nằm dưới chữ chứ không cắt ngang nét. */
  background: linear-gradient(transparent 62%, color-mix(in srgb, var(--sticker) 55%, transparent) 0);
}

.hero__body {
  margin: 0 0 1.5rem;
  font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.1875rem);
  color: var(--pencil);
  text-wrap: pretty;
}

/* Ba lời hứa với phụ huynh. Đây là thứ quyết định họ có đưa máy cho con không. */
.promises {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  margin: 0 0 clamp(2.75rem, 8vw, 4.25rem);
  padding: 0;
  list-style: none;
}

.promises li {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
}

/* ----------------------------------------------------------- kệ app --- */
.shelf__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--card-edge);
}

.shelf__heading h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  margin: 0;
}

.shelf__count {
  font-size: 0.8125rem;
  color: var(--pencil);
}

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16.5rem), 1fr));
  gap: clamp(0.9rem, 2.5vw, 1.25rem);
  margin: 0 0 clamp(3rem, 8vw, 4.5rem);
  padding: 0;
  list-style: none;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.35rem 1.35rem 1.5rem;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
              border-color 220ms ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--marker) 45%, var(--card-edge));
}

.card__icon {
  font-size: 2.25rem;
  line-height: 1;
}

.card__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1875rem;
  letter-spacing: -0.02em;
  margin: 0;
}

.card__blurb {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--pencil);
  flex-grow: 1;
}

.card__meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--pencil);
  margin-top: 0.35rem;
}

.card__subject {
  font-weight: 600;
  color: var(--ink);
}

.card__meta span:not(:last-child)::after {
  content: "·";
  margin-left: 0.5rem;
  opacity: 0.5;
}

/* Ô trống: cho thấy nhịp mỗi tuần một app, không phải kệ hàng bỏ hoang. */
.card--soon {
  border-style: dashed;
  box-shadow: none;
  background: transparent;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 11rem;
  color: var(--pencil);
}

.card--soon .card__title {
  font-size: 1rem;
  color: var(--pencil);
}

.card--soon p {
  margin: 0.15rem 0 0;
  font-size: 0.8125rem;
}

/* --------------------------------------------------------- ghi chú cuối */
.note {
  max-width: var(--measure);
  padding-top: clamp(1.5rem, 4vw, 2rem);
  border-top: 1px solid var(--card-edge);
}

.note h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.0625rem;
  margin: 0 0 0.75rem;
  letter-spacing: -0.01em;
}

.note p {
  margin: 0 0 0.85rem;
  color: var(--pencil);
  font-size: 0.9375rem;
}

.note p:last-child { margin-bottom: 0; }

/* ============================================================ trang app == */
.back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--pencil);
  text-decoration: none;
  margin-bottom: 1.5rem;
}

.back:hover { color: var(--ink); }

.app-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.app-head__icon { font-size: 2.75rem; line-height: 1; }

.app-head h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.4rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 0.3rem;
  text-wrap: balance;
}

.app-head__meta {
  font-size: 0.875rem;
  color: var(--pencil);
  margin: 0;
}

.app-blurb {
  max-width: var(--measure);
  color: var(--pencil);
  margin: 0 0 1.5rem;
}

/* Khung chơi. Tỉ lệ dọc cho hợp điện thoại, giới hạn chiều cao trên máy to. */
.stage {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 9 / 16;
  max-height: min(78dvh, 44rem);
  margin: 0 auto clamp(1.5rem, 4vw, 2.25rem);
  max-width: 26rem;
}

@media (min-width: 48rem) {
  .stage {
    aspect-ratio: 4 / 3;
    max-width: 52rem;
    max-height: none;
  }
}

.stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.parent-note {
  max-width: var(--measure);
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--card-edge);
  border-left: 3px solid var(--sticker);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--card);
}

.parent-note h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9375rem;
  margin: 0 0 0.4rem;
}

.parent-note p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--pencil);
}

/* Trạng thái không tìm thấy app. */
.missing {
  max-width: var(--measure);
}

.missing h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.4rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem;
}

.missing p { color: var(--pencil); }
