/* =========================================================================
   Bùi Ngọc Hiếu — trang giới thiệu kiểu danh thiếp
   Hướng thiết kế: nền giấy dó, mực xanh ngọc, cành mai vàng và một nhánh lan.
   Một nhịp chuyển động duy nhất khi mở trang: cành mai vẽ ra rồi các bông nở.
   ========================================================================= */

:root {
  /* Màu */
  --paper:      #F6F3E9;
  --paper-2:    #FBF9F2;
  --paper-3:    #EFEBDE;
  --jade:       #123B2F;
  --jade-2:     #2C5C4C;
  --jade-mute:  #4F6A5C;
  --gold:       #B98F26;
  --mai:        #E9B93C;
  --mai-light:  #F0CE74;
  --line:       rgba(18, 59, 47, 0.16);
  --line-soft:  rgba(18, 59, 47, 0.085);

  /* Chữ */
  --font-display: "Lora", "Times New Roman", serif;
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;

  --fs-xs:   0.8125rem;
  --fs-sm:   0.9375rem;
  --fs-base: 1.0625rem;
  --fs-lg:   clamp(1.15rem, 1rem + 0.5vw, 1.375rem);
  --fs-name: clamp(2.35rem, 1.5rem + 4.6vw, 3.9rem);
  --fs-title: clamp(1.3rem, 1.1rem + 0.7vw, 1.6rem);

  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;

  --radius: 4px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.68;
  color: var(--jade);
  background-color: var(--paper);
  background-image:
    radial-gradient(120% 80% at 50% 0%, var(--paper-2) 0%, var(--paper) 55%, var(--paper-3) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: var(--font-display); font-weight: 600; margin: 0; line-height: 1.1; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: inherit; text-decoration: none; }

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--jade-2);
  outline-offset: 3px;
  border-radius: var(--radius);
}

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

code {
  font-family: var(--font-body);
  font-size: 0.85em;
  background: var(--line-soft);
  padding: 0.05em 0.35em;
  border-radius: var(--radius);
}

.hint { font-size: var(--fs-xs); color: var(--jade-mute); }

/* ------------------------------ Khung trang ------------------------------ */

main { padding: clamp(1.25rem, 4vw, 3.5rem) clamp(1.25rem, 4vw, 3rem) 0; }

.stage { max-width: 1060px; margin-inline: auto; }

/* ------------------------------- Tấm danh thiếp -------------------------- */

.card {
  position: relative;
  overflow: hidden;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-top: 3px solid var(--jade);
  border-radius: var(--radius);
  box-shadow: 0 30px 70px -40px rgba(18, 59, 47, 0.45);
  padding: clamp(1.75rem, 4vw, 3.5rem);
  padding-top: clamp(1.75rem, 4vw, 3rem);
}

.card__main {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: clamp(1.75rem, 4vw, 3rem);
  align-items: start;
}

/* Cành mai ở góc phải trên */
.branch {
  position: absolute;
  top: 0;
  right: 0;
  width: clamp(160px, 26vw, 300px);
  pointer-events: none;
  transform: translate(6%, -4%);
  color: var(--jade);
}
.branch svg { display: block; width: 100%; height: auto; overflow: visible; }

.branch .net { fill: none; stroke: var(--jade); stroke-linecap: round; }
.branch .nhuy-hoa { fill: none; stroke: var(--gold); stroke-width: 1.1; }
.branch .canh-hoa {
  fill: var(--mai);
  stroke: var(--gold);
  stroke-width: 1.15;
}
.branch .mach-hoa { fill: var(--gold); }
.branch .nu { fill: var(--mai-light); stroke: var(--gold); stroke-width: 1; }
.branch .la { fill: var(--jade-2); opacity: 0.72; stroke: none; }

/* Chuyển động: cành vẽ ra trước, rồi từng bông nở */
.js .branch .net {
  stroke-dasharray: var(--len, 400);
  stroke-dashoffset: var(--len, 400);
}
.js .branch .bong { transform: scale(0); transform-origin: 0 0; }
.js .branch .nu { opacity: 0; }

body.is-bloom .branch .net {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.9s var(--ease);
}
body.is-bloom .branch .bong {
  transform: scale(1);
  transition: transform 0.55s cubic-bezier(0.34, 1.4, 0.64, 1);
}
body.is-bloom .branch .nu {
  opacity: 1;
  transition: opacity 0.5s var(--ease) 0.9s;
}
body.is-bloom .branch .bong[data-step="1"] { transition-delay: 0.42s; }
body.is-bloom .branch .bong[data-step="2"] { transition-delay: 0.54s; }
body.is-bloom .branch .bong[data-step="3"] { transition-delay: 0.66s; }
body.is-bloom .branch .bong[data-step="4"] { transition-delay: 0.78s; }
body.is-bloom .branch .bong[data-step="5"] { transition-delay: 0.90s; }
body.is-bloom .branch .bong[data-step="6"] { transition-delay: 1.02s; }

/* -------------------------------- Ảnh chân dung -------------------------- */

.portrait {
  position: relative;
  margin: 0;
  aspect-ratio: 2 / 3;
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--jade);
  border-radius: var(--radius);
  overflow: hidden;
}
.portrait img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.portrait__slot {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-4);
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--jade-mute);
  background-image: repeating-linear-gradient(-45deg, var(--line-soft) 0 6px, transparent 6px 14px);
}
.portrait__slot code { word-break: break-all; }

/* ------------------------------ Khối tên tuổi --------------------------- */

.ident { padding-right: clamp(0px, 15vw, 150px); }

.ident__school {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.ident__badge { width: 48px; height: 48px; flex: none; }
.ident__school p { margin: 0; }
.ident__school-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--jade);
  line-height: 1.35;
}
.ident__school-addr {
  font-size: var(--fs-xs);
  color: var(--jade-mute);
  line-height: 1.45;
}

.ident__name {
  font-size: var(--fs-name);
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-2);
}

.ident__role {
  font-size: var(--fs-lg);
  color: var(--jade-2);
  margin-bottom: var(--sp-5);
  line-height: 1.4;
}

/* Vạch ngăn có nhánh lan nhỏ ở giữa */
.divider {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  color: var(--jade-2);
}
.divider__line {
  height: 1px;
  flex: 1 1 auto;
  max-width: 150px;
  background: linear-gradient(90deg, transparent, var(--gold));
}
.divider__line:last-child { background: linear-gradient(90deg, var(--gold), transparent); }
.divider__mark { width: 26px; height: 29px; flex: none; opacity: 0.85; }

.ident__intro {
  color: var(--jade-mute);
  max-width: 46ch;
  margin-bottom: var(--sp-6);
}

.actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }

/* --------------------------------- Nút ----------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.5rem;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease),
              border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.btn--primary { background: var(--jade); color: var(--paper); }
.btn--primary:hover { background: var(--jade-2); }
.btn--ghost { border-color: var(--gold); color: var(--jade); }
.btn--ghost:hover { background: var(--mai); border-color: var(--mai); color: var(--jade); }
.btn:active { transform: translateY(1px); }

/* ------------------------------- Dải thông tin --------------------------- */

.card__facts {
  margin: clamp(1.75rem, 4vw, 2.75rem) 0 0;
  padding-top: clamp(1.25rem, 3vw, 1.75rem);
  border-top: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--sp-4) clamp(1rem, 3vw, 2rem);
}
.card__facts > div { display: flex; flex-direction: column; gap: 0.15rem; }
.card__facts dt { font-size: var(--fs-xs); color: var(--jade-mute); }
.card__facts dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.4;
}

/* ------------------------------- Liên hệ --------------------------------- */

.details {
  max-width: 1060px;
  margin: clamp(2.5rem, 6vw, 4.5rem) auto 0;
  padding-top: clamp(1.5rem, 4vw, 2.5rem);
  border-top: 1px solid var(--line);
}

.details__title { font-size: var(--fs-title); margin-bottom: var(--sp-3); }

.details__note {
  color: var(--jade-mute);
  font-size: var(--fs-sm);
  max-width: 56ch;
  margin-bottom: var(--sp-6);
}

.details__grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0 clamp(1.5rem, 4vw, 3rem);
}
.details__grid > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--line-soft);
}
.details__grid dt { font-size: var(--fs-xs); color: var(--jade-mute); }
.details__grid dd { margin: 0; font-size: var(--fs-sm); max-width: 34ch; }
.details__grid a { border-bottom: 1px solid var(--line); transition: border-color 0.2s var(--ease); }
.details__grid a:hover { border-bottom-color: var(--jade); }

/* -------------------------------- Chân trang ----------------------------- */

.footer {
  max-width: 1060px;
  margin: clamp(2.5rem, 6vw, 4rem) auto 0;
  padding: var(--sp-6) clamp(1.25rem, 4vw, 3rem) var(--sp-7);
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-5);
  color: var(--jade-mute);
}
.footer__mark { color: var(--gold); width: 26px; height: 26px; flex: none; }
.footer__mark svg { display: block; width: 100%; height: auto; }
.footer p { margin: 0; font-size: var(--fs-xs); }
.footer__name { font-family: var(--font-display); font-weight: 600; color: var(--jade); }
.footer__meta { flex: 1 1 100%; }

/* ------------------------------ Nhịp mở trang ---------------------------- */

.js .ident__school,
.js .ident__name,
.js .ident__role,
.js .divider,
.js .ident__intro,
.js .actions,
.js .portrait {
  opacity: 0;
  transform: translateY(12px);
}
body.is-ready .ident__school,
body.is-ready .ident__name,
body.is-ready .ident__role,
body.is-ready .divider,
body.is-ready .ident__intro,
body.is-ready .actions,
body.is-ready .portrait {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
body.is-ready .ident__school { transition-delay: 0.10s; }
body.is-ready .portrait      { transition-delay: 0.16s; }
body.is-ready .ident__name   { transition-delay: 0.22s; }
body.is-ready .ident__role   { transition-delay: 0.30s; }
body.is-ready .divider       { transition-delay: 0.38s; }
body.is-ready .ident__intro  { transition-delay: 0.46s; }
body.is-ready .actions       { transition-delay: 0.54s; }

/* ------------------------------ Màn hình nhỏ ----------------------------- */

@media (max-width: 820px) {
  .card { padding: clamp(1.25rem, 5vw, 2rem); }

  .card__main {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-5);
  }

  .portrait { width: clamp(8.5rem, 34vw, 12rem); }

  .ident { padding-right: 0; }
  .ident__school { margin-bottom: var(--sp-3); }

  .branch {
    width: clamp(150px, 40vw, 220px);
    opacity: 0.55;
    transform: translate(10%, -6%);
  }

  .divider__line { max-width: 100%; }
}

@media (max-width: 520px) {
  .actions .btn { width: 100%; }
  .card__facts { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
  .details__grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------- Giảm chuyển động --------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0ms !important;
  }
  .js .branch .net { stroke-dashoffset: 0; }
  .js .branch .bong { transform: scale(1); }
  .js .branch .nu { opacity: 1; }
  .js .ident__school,
  .js .ident__name,
  .js .ident__role,
  .js .divider,
  .js .ident__intro,
  .js .actions,
  .js .portrait { opacity: 1; transform: none; }
}

/* --------------------------------- In ấn --------------------------------- */

@media print {
  body { background: #fff; font-size: 11pt; }
  .branch, .actions, .btn { display: none !important; }
  .card { box-shadow: none; border-color: #999; }
  .ident__intro { color: #333; }
}
