/* =====================================================================
   hi.io.vn — Giao diện kỹ thuật
   Thứ tự: biến màu → typography → trang chủ → bài viết → thành phần
   ===================================================================== */

/* ---------- 1. Bảng màu & biến dùng chung ---------- */
:root {
  --hi-steel-900: #263238;
  --hi-steel-800: #37474f;
  --hi-steel-700: #455a64;
  --hi-steel-500: #607d8b;
  --hi-amber: #ffb300;
  --hi-amber-dark: #ff8f00;

  --hi-radius: 10px;
  --hi-border: 1px solid var(--md-default-fg-color--lightest);
  --hi-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 6px 18px rgba(0, 0, 0, .06);
  --hi-shadow-hover: 0 4px 10px rgba(0, 0, 0, .10), 0 14px 32px rgba(0, 0, 0, .12);

  --md-primary-fg-color: var(--hi-steel-800);
  --md-primary-fg-color--light: #546e7a;
  --md-primary-fg-color--dark: var(--hi-steel-900);
  --md-accent-fg-color: var(--hi-amber);
  --md-typeset-a-color: #11618c;
}

[data-md-color-scheme="slate"] {
  --md-primary-fg-color: var(--hi-steel-900);
  --md-primary-fg-color--light: #455a64;
  --md-primary-fg-color--dark: #1b2429;
  --md-typeset-a-color: #7fc4e8;
  --hi-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
  --hi-shadow-hover: 0 4px 12px rgba(0, 0, 0, .5), 0 16px 36px rgba(0, 0, 0, .45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-md-color-scheme="default"]) {
    --md-typeset-a-color: #7fc4e8;
  }
}

/* ---------- 2. Typography ---------- */
.md-header__title {
  font-weight: 700;
  letter-spacing: .2px;
}

.md-typeset {
  font-size: .78rem;
  line-height: 1.75;
}

.md-typeset h1 {
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--md-default-fg-color);
}

.md-typeset h2 {
  font-weight: 700;
  margin-top: 2.2em;
  padding-bottom: .35em;
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
}

.md-typeset h3 {
  font-weight: 700;
}

.md-typeset blockquote {
  border-left: 3px solid var(--hi-amber);
  color: var(--md-default-fg-color--light);
  padding-left: 1rem;
}

.md-typeset a {
  text-underline-offset: .15em;
}

.md-typeset :is(h1, h2, h3) .headerlink {
  color: var(--md-default-fg-color--lighter);
}

/* ---------- 3. Trang chủ: hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 4rem 1rem 3.25rem;
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(255, 179, 0, .14), transparent 60%),
    linear-gradient(135deg, #263238 0%, #37474f 55%, #455a64 100%);
  color: #fff;
}

/* Lưới blueprint mờ */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .9), transparent);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .9), transparent);
}

.hero__inner {
  position: relative;
  max-width: 61rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .8rem .3rem .6rem;
  border: 1px solid rgba(255, 179, 0, .45);
  border-radius: 999px;
  background: rgba(255, 179, 0, .08);
  color: #ffd54f;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.hero__dot {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: var(--hi-amber);
  box-shadow: 0 0 0 4px rgba(255, 179, 0, .18);
}

.hero__title {
  margin: .9rem 0 .7rem;
  font-size: clamp(1.9rem, 5vw, 3.1rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.03em;
  color: #fff;
}

.hero__accent {
  color: var(--hi-amber);
}

.hero__lead {
  max-width: 44rem;
  margin: 0 0 1.6rem;
  font-size: .86rem;
  line-height: 1.7;
  color: #cfd8dc;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin-bottom: 1.8rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .62rem 1.1rem;
  border-radius: 8px;
  font-size: .74rem;
  font-weight: 700;
  text-decoration: none !important;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.btn__icon svg {
  display: block;
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
}

.btn--primary {
  background: var(--hi-amber);
  color: var(--hi-steel-900) !important;
  box-shadow: 0 4px 14px rgba(255, 179, 0, .28);
}

.btn--primary:hover {
  background: #ffc233;
  transform: translateY(-2px);
}

.btn--ghost {
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff !important;
  background: rgba(255, 255, 255, .04);
}

.btn--ghost:hover {
  border-color: #fff;
  background: rgba(255, 255, 255, .1);
  transform: translateY(-2px);
}

.hero__points {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .68rem;
  color: #b0bec5;
}

.hero__points li::before {
  content: "✓";
  margin-right: .4rem;
  color: var(--hi-amber);
  font-weight: 700;
}

/* ---------- 4. Trang chủ: khối nội dung ---------- */
.home-section {
  margin: 2.6rem 0;
}

.home-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: var(--hi-border);
}

.home-section__head h2 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 1.15rem;
}

.home-section__head a {
  font-size: .7rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Thẻ chuyên mục */
.grid-cards {
  display: grid;
  gap: .9rem;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.card {
  padding: 1.1rem 1.15rem;
  border: var(--hi-border);
  border-top: 3px solid var(--hi-amber);
  border-radius: var(--hi-radius);
  background: var(--md-default-bg-color);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--hi-amber);
  box-shadow: var(--hi-shadow-hover);
}

.card .twemoji,
.card svg {
  color: var(--hi-amber);
}

.card strong {
  font-size: .82rem;
}

.card a {
  font-weight: 600;
  font-size: .7rem;
}

/* Thẻ bài viết do hook sinh ra */
.post-grid {
  display: grid;
  gap: .9rem;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.post-card {
  border: var(--hi-border);
  border-radius: var(--hi-radius);
  background: var(--md-default-bg-color);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.post-card:hover {
  transform: translateY(-3px);
  border-color: var(--md-accent-fg-color);
  box-shadow: var(--hi-shadow-hover);
}

.post-card__link {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  height: 100%;
  padding: 1.05rem 1.1rem;
  color: inherit !important;
  text-decoration: none !important;
}

.post-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  font-size: .62rem;
  color: var(--md-default-fg-color--light);
}

.post-card__cat {
  padding: .12rem .5rem;
  border-radius: 999px;
  background: rgba(255, 179, 0, .14);
  color: var(--hi-amber-dark);
  font-weight: 700;
  letter-spacing: .02em;
}

[data-md-color-scheme="slate"] .post-card__cat {
  color: var(--hi-amber);
}

.post-card__title {
  margin: 0;
  font-size: .84rem;
  font-weight: 700;
  line-height: 1.4;
}

.post-card__desc {
  margin: 0;
  font-size: .68rem;
  line-height: 1.6;
  color: var(--md-default-fg-color--light);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card__more {
  margin-top: auto;
  font-size: .66rem;
  font-weight: 700;
  color: var(--md-accent-fg-color);
}

.post-empty {
  padding: 1rem;
  border: 1px dashed var(--md-default-fg-color--lighter);
  border-radius: var(--hi-radius);
  color: var(--md-default-fg-color--light);
  font-size: .72rem;
}

/* Quy trình 3 bước */
.steps {
  display: grid;
  gap: .8rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  counter-reset: step;
}

.steps > div {
  position: relative;
  padding: 1rem 1.05rem 1rem 2.6rem;
  border: var(--hi-border);
  border-radius: var(--hi-radius);
  counter-increment: step;
  font-size: .7rem;
}

.steps > div::before {
  content: counter(step);
  position: absolute;
  left: .9rem;
  top: .9rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--hi-amber);
  color: var(--hi-steel-900);
  font-weight: 800;
  font-size: .62rem;
  line-height: 1.25rem;
  text-align: center;
}

/* ---------- 5. Blog ---------- */
.md-post--excerpt {
  padding: 1.1rem 1.2rem !important;
  border: var(--hi-border);
  border-left: 3px solid var(--hi-amber);
  border-radius: var(--hi-radius);
  transition: box-shadow .18s ease, transform .18s ease;
}

.md-post--excerpt:hover {
  transform: translateY(-2px);
  box-shadow: var(--hi-shadow);
}

.md-post__meta {
  font-size: .64rem;
}

.md-post__meta .md-meta__link,
.md-post__meta .md-meta__item {
  font-weight: 600;
}

.md-post__header h2,
.md-post__header h3 {
  margin: .35rem 0 .3rem;
  font-size: 1rem;
  border: 0;
  padding: 0;
}

.md-post__header h2 a,
.md-post__header h3 a {
  color: var(--md-default-fg-color);
}

.md-post h2 a,
.md-post h3 a,
.md-typeset .md-post h2 a,
.md-typeset .md-post h3 a {
  color: var(--md-default-fg-color);
}

.md-author {
  border-radius: 50%;
}

.md-post__content {
  font-size: .74rem;
}

[data-md-color-scheme="slate"] .md-post--excerpt {
  background: rgba(255, 255, 255, .02);
}

/* ---------- 6. Bảng & mã ---------- */
.md-typeset__table {
  width: 100%;
}

.md-typeset__table > table:not([class]) {
  width: 100%;
}

.md-typeset table:not([class]) {
  border: 1px solid var(--md-default-fg-color--lighter);
  font-size: .72rem;
  display: table;
  width: 100%;
}

.md-typeset table:not([class]) th {
  background: var(--hi-steel-800);
  color: #fff;
  font-weight: 600;
  border-bottom: 0;
}

.md-typeset table:not([class]) tr:nth-child(even) td {
  background: var(--md-default-fg-color--lightest);
}

.md-typeset .highlight {
  border-radius: 8px;
  border: var(--hi-border);
}

.md-typeset pre > code {
  font-size: .7rem;
  line-height: 1.65;
}

.md-typeset code {
  font-size: .78em;
}

/* ---------- 7. Admonition ---------- */
.md-typeset .admonition,
.md-typeset details {
  border-width: 1px;
  border-left-width: 3px;
  border-radius: 8px;
  font-size: .72rem;
}

/* ---------- 8. Nút nổi "Viết bài" ---------- */
/* Nút "lên đầu trang" của Material lùi sang trái để không đè nút Viết bài */
.md-top {
  right: 5.5rem !important;
}

.fab-post {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .7rem 1rem;
  border-radius: 999px;
  background: var(--hi-amber);
  color: var(--hi-steel-900) !important;
  font-size: .72rem;
  font-weight: 800;
  text-decoration: none !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
  transition: transform .18s ease, box-shadow .18s ease;
}

.fab-post:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .34);
}

.fab-post:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.fab-post__icon svg {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
}

/* ---------- 8b. Công cụ tính toán ---------- */
.calc {
  margin: 1.4rem 0;
  padding: 1.1rem 1.15rem;
  border: var(--hi-border);
  border-left: 3px solid var(--hi-amber);
  border-radius: var(--hi-radius);
  background: var(--md-code-bg-color);
}

.calc__fields {
  display: grid;
  gap: .8rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.calc__field {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .68rem;
  font-weight: 600;
}

.calc__field em {
  color: var(--md-accent-fg-color);
  font-style: normal;
}

.calc__field input {
  padding: .5rem .6rem;
  border: 1px solid var(--md-default-fg-color--lighter);
  border-radius: 6px;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font-family: var(--md-code-font-family);
  font-size: .8rem;
}

.calc__field input:focus {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: 1px;
}

.calc__result {
  margin: 1rem 0 0;
  font-size: .8rem;
}

.calc__result strong {
  color: var(--md-accent-fg-color);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.calc__sub {
  display: block;
  margin-top: .15rem;
  font-size: .66rem;
  color: var(--md-default-fg-color--light);
}

.calc__error {
  margin: .5rem 0 0;
  color: #e53935;
  font-size: .7rem;
}

/* ---------- 9. Trang 404 ---------- */
.notfound {
  max-width: 38rem;
  margin: 3rem auto;
  padding: 0 1rem;
  text-align: center;
}

.notfound__code {
  margin: 0;
  font-family: var(--md-code-font-family);
  font-size: 4.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--hi-amber);
}

.notfound h1 {
  margin: .5rem 0 .6rem;
  font-size: 1.35rem;
}

.notfound__text {
  color: var(--md-default-fg-color--light);
  font-size: .78rem;
}

.notfound__actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 1.4rem 0;
}

.notfound__actions .btn--ghost {
  border-color: var(--md-default-fg-color--lighter);
  color: var(--md-default-fg-color) !important;
  background: transparent;
}

.notfound__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem 1.1rem;
  font-size: .7rem;
}

/* ---------- 10. Tối ưu hiển thị ---------- */
.md-typeset img {
  border-radius: 8px;
}

.md-nav__link--active,
.md-tabs__link--active {
  font-weight: 700;
}

.md-search__form {
  border-radius: 8px;
}

/* Mobile */
@media screen and (max-width: 76.1875em) {
  .hero {
    padding: 2.8rem 1rem 2.4rem;
  }

  .hero__lead {
    font-size: .8rem;
  }
}

@media screen and (max-width: 44.9375em) {
  .md-typeset {
    font-size: .76rem;
  }

  .hero__title {
    font-size: clamp(1.6rem, 8vw, 2.1rem);
  }

  .hero__badge {
    font-size: .58rem;
    letter-spacing: .05em;
  }

  .hero__actions .btn {
    flex: 1 1 100%;
    justify-content: center;
  }

  .fab-post {
    padding: .85rem;
    border-radius: 50%;
  }

  .md-top {
    right: 4.9rem !important;
  }

  .fab-post__label {
    display: none;
  }

  .post-grid,
  .grid-cards {
    grid-template-columns: 1fr;
  }

  .hero__points {
    flex-direction: column;
    gap: .3rem;
  }
}

/* Người dùng giảm chuyển động */
@media (prefers-reduced-motion: reduce) {
  .card,
  .post-card,
  .btn,
  .fab-post,
  .md-post--excerpt {
    transition: none !important;
  }
}

/* In ấn */
@media print {
  .fab-post,
  .hero__actions,
  .md-header,
  .md-tabs,
  .md-sidebar,
  .md-top {
    display: none !important;
  }

  .hero {
    background: none !important;
    color: #000 !important;
    padding: 0 0 1rem;
  }

  .hero__title,
  .hero__accent {
    color: #000 !important;
  }
}
