/* Lớp học của Milo: cả màn hình là một tấm bảng xanh trong khung gỗ.
   Chữ trên bảng là chữ phấn; đồng hồ buổi học là viên phấn ngắn dần ở máng phấn. */

@font-face {
  font-family: 'Patrick Hand';
  src: url('/fonts/patrick-hand-vietnamese-400-normal.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301,
    U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Patrick Hand';
  src: url('/fonts/patrick-hand-latin-ext-400-normal.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Patrick Hand';
  src: url('/fonts/patrick-hand-latin-400-normal.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bang: #1f4d3a;
  --bang-toi: #173a2c;
  --phan: #f4f1e6;
  --phan-mo: #c9d6cc;
  --phan-vang: #f3d36b;
  --go: #6f4526;
  --go-sang: #96663a;
  --do: #d8372b;
  --am: 0;
  --net: 255px 18px 225px 18px / 18px 225px 18px 255px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--go);
  color: var(--phan);
  font-family: 'Patrick Hand', 'Comic Sans MS', cursive;
  font-size: clamp(1.25rem, 1rem + 1.4vw, 1.75rem);
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

/* Khung gỗ quanh bảng */
.khung {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: clamp(10px, 2.4vw, 22px);
  padding-bottom: 0;
  background: linear-gradient(90deg, rgb(0 0 0 / 0.1), transparent 12%, transparent 88%, rgb(0 0 0 / 0.12)),
    repeating-linear-gradient(90deg, var(--go) 0 38px, var(--go-sang) 38px 41px, var(--go) 41px 97px);
}

/* Mặt bảng: xanh, có vệt phấn lau chưa sạch */
.bang {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: clamp(16px, 4vw, 40px);
  border-radius: 6px;
  background: radial-gradient(60% 34% at 22% 30%, rgb(255 255 255 / 0.055), transparent 70%),
    radial-gradient(48% 30% at 78% 72%, rgb(255 255 255 / 0.045), transparent 70%),
    radial-gradient(30% 18% at 60% 18%, rgb(255 255 255 / 0.03), transparent 70%),
    linear-gradient(160deg, var(--bang), var(--bang-toi));
  box-shadow: inset 0 0 0 3px rgb(0 0 0 / 0.25), inset 0 12px 40px rgb(0 0 0 / 0.28);
}

/* Dòng ngày tháng cô viết ở góc bảng */
.ngay {
  margin: 0;
  color: var(--phan-mo);
  font-size: 0.95em;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

.man {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vh, 28px);
  text-align: center;
  padding-block: clamp(12px, 3vh, 32px);
}

h1 {
  margin: 0;
  font-weight: 400;
  font-size: clamp(2.6rem, 1.4rem + 7vw, 5.4rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-shadow: 0 0 1px rgb(244 241 230 / 0.6);
}

.loi {
  margin: 0;
  max-width: 26ch;
  min-height: 1.35em;
  text-wrap: balance;
}

.bao {
  margin: 0;
  max-width: 30ch;
  min-height: 1.35em;
  color: var(--phan-vang);
  font-size: 0.9em;
  text-wrap: balance;
}

/* Nút bấm: khung vẽ tay bằng phấn */
.nut {
  appearance: none;
  min-height: 60px;
  padding: 10px 26px;
  border: 3px solid var(--phan);
  border-radius: var(--net);
  background: transparent;
  color: var(--phan);
  font: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.12s ease;
}
.nut:active {
  transform: scale(0.97);
}
.nut:focus-visible,
.cua-bo-me:focus-visible,
input:focus-visible {
  outline: 3px solid var(--phan-vang);
  outline-offset: 4px;
}
.nut[disabled] {
  opacity: 0.45;
  cursor: default;
}
.nut-chinh {
  border-color: var(--phan-vang);
  background: var(--phan-vang);
  color: var(--bang-toi);
}
.nut-to {
  min-height: 84px;
  padding-inline: 56px;
  font-size: 1.5em;
}
.nut[aria-pressed='true'] {
  background: var(--phan);
  color: var(--bang-toi);
}

.hang-nut {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 18px;
}

/* Vòng phấn quanh tên cô: nở ra theo tiếng cô nói */
.vong {
  position: relative;
  width: min(62vw, 46vh, 420px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.vong svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.vong circle {
  fill: none;
  stroke: var(--phan);
  stroke-linecap: round;
  transform-origin: 100px 100px;
  transition: transform 0.09s linear, opacity 0.09s linear;
}
.vong-trong {
  stroke-width: 2.6;
  stroke-dasharray: 58 5 120 7 36 4;
  transform: scale(calc(1 + var(--am) * 0.05));
}
.vong-giua {
  stroke-width: 1.8;
  stroke-dasharray: 30 9 84 6 140 11;
  opacity: calc(0.25 + var(--am) * 0.75);
  transform: rotate(40deg) scale(calc(1 + var(--am) * 0.09));
}
.vong-ngoai {
  stroke-width: 1.2;
  stroke-dasharray: 12 14 60 10 90 16;
  opacity: calc(0.08 + var(--am) * 0.7);
  transform: rotate(-70deg) scale(calc(1 + var(--am) * 0.13));
}
.ten-trong-vong {
  position: relative;
  max-width: 62%;
  font-size: clamp(1.9rem, 1rem + 5vw, 3.6rem);
}
.vong[data-nghi='true'] {
  opacity: 0.45;
}

/* Sao bé ngoan */
.sao {
  width: clamp(96px, 22vw, 150px);
  fill: var(--do);
  stroke: var(--phan);
  stroke-width: 3;
  stroke-linejoin: round;
  filter: drop-shadow(0 4px 0 rgb(0 0 0 / 0.25));
}

/* Ô nhập mã gia đình */
.form-ma {
  display: grid;
  gap: 12px;
  justify-items: center;
}
.form-ma label {
  color: var(--phan-mo);
}
.form-ma input {
  width: min(78vw, 320px);
  min-height: 60px;
  padding: 8px 16px;
  border: 3px solid var(--phan);
  border-radius: var(--net);
  background: rgb(0 0 0 / 0.18);
  color: var(--phan);
  font: inherit;
  text-align: center;
  letter-spacing: 0.2em;
}

/* Máng phấn dưới bảng: viên phấn là đồng hồ buổi học */
.mang {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px 18px;
  min-height: 58px;
  padding: 8px clamp(6px, 2vw, 18px) calc(8px + env(safe-area-inset-bottom));
  font-size: 0.8em;
  color: #f1dfc9;
}
.ranh-phan {
  height: 16px;
  max-width: 420px;
  border-radius: 3px;
  background: rgb(0 0 0 / 0.28);
  box-shadow: inset 0 2px 3px rgb(0 0 0 / 0.4);
}
.phan {
  width: calc(max(var(--con, 1), 0.03) * 100%);
  height: 100%;
  border-radius: 8px 3px 3px 8px;
  background: linear-gradient(180deg, #ffffff, var(--phan) 55%, #d9d5c6);
  box-shadow: 0 2px 2px rgb(0 0 0 / 0.35);
  transition: width 1s linear;
}
.con-lai {
  margin: 0;
  white-space: nowrap;
}
.cua-bo-me {
  color: inherit;
  opacity: 0.75;
  text-underline-offset: 4px;
}

@media (max-width: 520px) {
  .mang {
    grid-template-columns: 1fr auto;
  }
  .ranh-phan {
    grid-column: 1 / -1;
    max-width: none;
  }
  .hang-nut {
    flex-direction: column;
    align-self: stretch;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .man {
    gap: 10px;
    padding-block: 4px;
  }
  .vong {
    width: min(38vh, 240px);
  }
  h1 {
    font-size: clamp(2rem, 9vh, 3.2rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .nut,
  .vong circle,
  .phan {
    transition: none;
  }
  .vong circle {
    transform: none;
  }
}
