/* =========================================================
   H'REB Coffee — Responsive CSS
   Nguyên tắc: Tất cả nội dung PHẢI vừa trong 1 màn hình.
   Fluid typography + grid co giãn + overflow handling.
   ========================================================= */

/* ============================================================
   BASE: Thay fixed 100vh → min-height 100vh + overflow hidden
   Giữ body/canvas không scroll được (kiosk)
   ============================================================ */
html, body {
  overflow: hidden !important;
  height: 100%;
  min-height: 100dvh; /* dvh = dynamic viewport height, tính cả thanh URL mobile */
}

.hren-bg,
.hren-main {
  width: 100%;
  min-height: 100dvh;
  height: 100dvh; /* fallback */
}

/* ============================================================
   FLUID TYPOGRAPHY — clamp(min, fluid, max)
   Tự động co giãn theo viewport mà không cần breakpoint
   ============================================================ */

/* Logo */
.hren-logo__img   { width: clamp(52px, 5vw, 72px); height: clamp(52px, 5vw, 72px); }
.hren-logo__name  { font-size: clamp(28px, 3.8vw, 46px); }
.hren-logo__sub   { font-size: clamp(15px, 1.8vw, 24px); }
.hren-logo__tagline { font-size: clamp(8px, 0.85vw, 11px); letter-spacing: clamp(0.18em, 0.25vw, 0.32em); }
.hren-logo__poetry { font-size: clamp(14px, 1.6vw, 22px); }

/* Greeting */
.hren-greeting__title          { font-size: clamp(26px, 3.8vw, 46px); }
.hren-greeting__line--accent   { font-size: clamp(30px, 4.4vw, 52px); }
.hren-greeting__subtitle       { font-size: clamp(12px, 1.5vw, 19px); }

/* Menu cards */
.hren-menu__card-title         { font-size: clamp(14px, 1.6vw, 21px); }
.hren-menu__card-desc          { font-size: clamp(12px, 1.3vw, 17px); }
.hren-menu__card-icon          { width: clamp(24px, 2.5vw, 30px); height: clamp(24px, 2.5vw, 30px); }
.hren-menu__card-icon svg       { width: clamp(13px, 1.5vw, 16px); height: clamp(13px, 1.5vw, 16px); }
.hren-menu__card-arrow         { width: clamp(32px, 3.2vw, 40px); height: clamp(32px, 3.2vw, 40px); }
.hren-menu__card-arrow svg     { width: clamp(13px, 1.3vw, 16px); height: clamp(13px, 1.3vw, 16px); }

/* Footer */
.hren-footer__value             { font-size: clamp(8px, 0.8vw, 10px); letter-spacing: clamp(0.08em, 0.12vw, 0.15em); }
.hren-footer__tagline           { font-size: clamp(8px, 0.7vw, 9px); letter-spacing: clamp(0.14em, 0.16vw, 0.18em); }

/* Character */
.hren-character__bubble          { font-size: clamp(13px, 1.4vw, 18px); }

/* Lang buttons */
.hren-lang__btn {
  padding: clamp(6px, 0.7vw, 9px) clamp(8px, 1.2vw, 14px);
  font-size: clamp(10px, 0.9vw, 12px);
  gap: clamp(4px, 0.6vw, 8px);
  min-height: clamp(36px, 4vw, 44px);
}

/* ============================================================
   BREAKPOINT: Ultra-wide (>= 1920px)
   Giới hạn max-width để layout không quá rộng
   ============================================================ */
@media (min-width: 1920px) {
  .hren-main {
    padding: 36px 52px 26px;
    /* Giới hạn max-width để layout không quá rộng trên ultra-wide */
    max-width: 100%;
  }
  /* Cô gái to hơn trên ultra-wide */
  .hren-character { height: min(94vh, 1100px); }
  .hren-character__img { max-width: 46vw; }
  .hren-logo__name { font-size: clamp(42px, 2.5vw + 0.5vh, 54px); }
  .hren-logo__sub { font-size: clamp(20px, 1.3vw + 0.3vh, 26px); }
  .hren-greeting { top: clamp(12px, 2vh, 40px); }
  .hren-greeting__title { font-size: clamp(38px, 2.5vw + 2vh, 60px); }
  .hren-greeting__line--accent { font-size: clamp(42px, 2.8vw + 2.5vh, 66px); }
  .hren-greeting__subtitle { font-size: clamp(16px, 1vw + 1vh, 24px); }
  .hren-menu__grid {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: clamp(12px, 1vw, 18px);
    max-width: 620px;
  }
  .hren-menu__card { min-height: clamp(140px, 12vh, 200px); }
  .hren-menu__card-title { font-size: clamp(17px, 1vw + 0.8vh, 24px); }
  .hren-menu__card-desc { font-size: clamp(14px, 0.9vw + 0.6vh, 20px); }
  .hren-character__bubble { font-size: clamp(16px, 0.8vw + 0.5vh, 20px); max-width: 240px; }
  .hren-footer__value { font-size: clamp(9px, 0.5vw + 0.2vh, 11px); }
}

/* ============================================================
   BREAKPOINT: Desktop (1280–1919px) — mặc định
   Giữ nguyên layout chính, tinh chỉnh padding
   ============================================================ */
@media (min-width: 1280px) and (max-width: 1919px) {
  .hren-main {
    padding: 28px 36px 22px;
  }
  /* Greeting scale nhẹ theo chiều cao trên desktop */
  .hren-greeting { top: clamp(10px, 1.5vh, 30px); }
  .hren-greeting__title { font-size: clamp(30px, 2.5vw + 1.5vh, 56px); }
  .hren-greeting__line--accent { font-size: clamp(34px, 2.8vw + 1.8vh, 62px); }
  .hren-greeting__subtitle { font-size: clamp(13px, 1vw + 0.8vh, 22px); }
  .hren-menu__card { min-height: clamp(130px, 11vh, 180px); }
  .hren-menu__card-title { font-size: clamp(15px, 1vw + 0.7vh, 22px); }
  .hren-menu__card-desc { font-size: clamp(12px, 0.8vw + 0.5vh, 18px); }
}

/* ============================================================
   BREAKPOINT: Laptop nhỏ / iPad ngang lớn (1100–1279px)
   Thu hẹp grid left column, giảm gap
   ============================================================ */
@media (min-width: 1100px) and (max-width: 1279px) {
  .hren-main {
    padding: 22px 26px 16px;
    gap: 10px;
  }
  .hren-logo__poetry { font-size: 19px; }
  .hren-menu__grid {
    grid-template-columns: repeat(2, minmax(190px, 1fr));
    gap: 11px;
    max-width: 480px;
  }
  .hren-menu__card { aspect-ratio: 1.55 / 1; }
  .hren-character__bubble { font-size: 16px; max-width: 200px; }
  .hren-character__img { max-height: 85%; }
  .hren-sidetext { font-size: 16px; }
}

/* ============================================================
   BREAKPOINT: iPad ngang 1024×768 — TARGET CHÍNH
   Layout gốc, giữ nguyên tỷ lệ
   ============================================================ */
@media (min-width: 1024px) and (max-width: 1099px) {
  .hren-main {
    padding: 20px 24px 14px;
    gap: 10px;
  }
  .hren-menu__grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 10px;
    max-width: 440px;
  }
  .hren-menu__card {
    min-height: 130px;
    aspect-ratio: 1.5 / 1;
  }
  .hren-menu__card-title { font-size: 17px; }
  .hren-menu__card-desc { font-size: 14px; }
  .hren-menu__card-arrow { width: 34px; height: 34px; bottom: 10px; right: 10px; }
  .hren-character__img { max-height: 80%; }
  .hren-character__bubble { font-size: 15px; max-width: 170px; }
  .hren-sidetext { font-size: 15px; }
}

/* ============================================================
   BREAKPOINT: Tablet dọc / iPad dọc / màn hình nhỏ (768–1023px)
   Chuyển sang grid 1 cột, character thu nhỏ
   ============================================================ */
@media (max-width: 1023px) {
  .hren-main {
    /* Chuyển sang 1 cột duy nhất — tất cả vừa trong 1 màn hình */
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas:
      "header"
      "lang"
      "char"
      "menu"
      "footer";
    padding: 16px 16px 12px;
    gap: 8px;
    height: auto;
    min-height: 100dvh;
    overflow: hidden;
  }

  .hren-header {
    grid-area: header;
    align-items: center;
    text-align: center;
    margin: 0 auto;
    padding: 0;
  }
  .hren-logo__poetry { display: none; } /* ẩn thơ trên tablet dọc để tiết kiệm không gian */

  .hren-lang {
    grid-area: lang;
    justify-content: center;
  }
  .hren-lang__list { gap: 8px; }
  .hren-lang__btn { padding: 6px 10px; font-size: 11px; }

  .hren-character {
    grid-area: char;
    position: relative;
    bottom: auto;
    left: auto;
    width: 100%;
    height: clamp(200px, 30vw, 320px);
    align-items: flex-end;
    justify-content: center;
  }
  .hren-character__img {
    max-height: 100%;
    max-width: 50%;
    width: auto;
    object-fit: contain;
    object-position: bottom center;
  }
  .hren-character__bubble {
    display: none; /* ẩn bubble để tiết kiệm không gian */
  }
  .hren-sidetext { display: none; }

  .hren-greeting {
    position: relative;
    top: auto; left: auto;
    width: 100%;
    max-width: 100%;
    text-align: center;
  }
  .hren-greeting__title { font-size: clamp(22px, 6vw, 36px); }
  .hren-greeting__line--accent { font-size: clamp(26px, 7vw, 40px); }
  .hren-greeting__subtitle { font-size: clamp(11px, 2.8vw, 15px); }

  .hren-menu {
    grid-area: menu;
    justify-content: center;
    padding-right: 0;
  }
  .hren-menu__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: min(480px, 95vw);
  }
  .hren-menu__card {
    min-height: 100px;
    aspect-ratio: 1.6 / 1;
  }
  .hren-menu__card-title { font-size: clamp(13px, 3.2vw, 17px); }
  .hren-menu__card-desc { font-size: clamp(11px, 2.8vw, 14px); }
  .hren-menu__card-icon { width: clamp(22px, 5vw, 28px); height: clamp(22px, 5vw, 28px); }
  .hren-menu__card-arrow { width: clamp(28px, 6vw, 34px); height: clamp(28px, 6vw, 34px); bottom: 8px; right: 8px; }
  .hren-menu__card-body { padding: 10px 12px 50px; gap: 6px; }

  .hren-footer {
    grid-area: footer;
  }
  .hren-footer__values {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 16px;
  }
}

/* ============================================================
   BREAKPOINT: Small tablet / phablet (600–767px)
   Grid menu co lại, font nhỏ hơn
   ============================================================ */
@media (max-width: 767px) {
  .hren-main {
    padding: 12px 12px 10px;
    gap: 6px;
  }
  .hren-logo__name { font-size: clamp(24px, 7vw, 32px); }
  .hren-logo__sub { font-size: clamp(12px, 3.5vw, 18px); }
  .hren-logo__tagline { font-size: 8px; }
  .hren-character { height: clamp(160px, 25vw, 220px); }
  .hren-greeting__title { font-size: clamp(18px, 5.5vw, 28px); }
  .hren-greeting__line--accent { font-size: clamp(22px, 6.5vw, 34px); }
  .hren-greeting__subtitle { font-size: clamp(10px, 2.8vw, 13px); }
  .hren-menu__grid { gap: 8px; max-width: min(420px, 95vw); }
  .hren-menu__card { min-height: 90px; aspect-ratio: 1.65 / 1; }
  .hren-menu__card-title { font-size: clamp(12px, 3.5vw, 15px); }
  .hren-menu__card-desc { font-size: clamp(10px, 2.8vw, 12px); }
  .hren-menu__card-body { padding: 8px 10px 44px; gap: 4px; }
  .hren-menu__card-arrow { width: clamp(26px, 7vw, 32px); height: clamp(26px, 7vw, 32px); bottom: 6px; right: 6px; }
  .hren-lang__btn .hren-lang__label { display: none; } /* chỉ hiện flag trên mobile */
  .hren-footer__values { gap: 8px 12px; }
  .hren-footer__value { font-size: clamp(7px, 2vw, 9px); }
  .hren-footer__tagline { font-size: 7px; }
}

/* ============================================================
   BREAKPOINT: Mobile (≤ 599px)
   Layout tối thiểu — 1 cột menu, font cực nhỏ
   ============================================================ */
@media (max-width: 599px) {
  .hren-main {
    padding: 10px 10px 8px;
    gap: 5px;
  }
  .hren-logo__img { width: 44px; height: 44px; }
  .hren-logo__name { font-size: clamp(20px, 7vw, 26px); }
  .hren-logo__sub { font-size: clamp(11px, 3.8vw, 14px); }
  .hren-logo__tagline { display: none; }
  .hren-character { height: clamp(120px, 22vw, 160px); }
  .hren-greeting__title { font-size: clamp(16px, 5.5vw, 22px); }
  .hren-greeting__line--accent { font-size: clamp(18px, 6.5vw, 26px); }
  .hren-greeting__subtitle { font-size: clamp(9px, 2.5vw, 11px); }
  .hren-menu__grid {
    grid-template-columns: 1fr;
    max-width: min(360px, 95vw);
  }
  .hren-menu__card { aspect-ratio: 2.2 / 1; min-height: 72px; }
  .hren-menu__card-title { font-size: clamp(13px, 4vw, 16px); }
  .hren-menu__card-desc { display: none; } /* ẩn desc trên mobile rất nhỏ */
  .hren-menu__card-icon { width: 22px; height: 22px; }
  .hren-menu__card-body { padding: 8px 10px 40px; }
  .hren-menu__card-arrow { width: 28px; height: 28px; bottom: 6px; right: 6px; }
  .hren-lang__list { gap: 6px; }
  .hren-lang__btn { padding: 5px 8px; min-height: 32px; }
  .hren-footer__values { gap: 6px 10px; }
  .hren-footer__value { font-size: 7px; }
}

/* ============================================================
   NGÔN NGỮ DÀI — điều chỉnh riêng
   Tiếng Nga thường dài nhất, tiếng Trung ngắn hơn
   ============================================================ */
:root[lang="ru"] .hren-greeting__title { font-size: clamp(22px, 3vw, 38px); }
:root[lang="ru"] .hren-menu__card-title { font-size: clamp(12px, 1.3vw, 17px); }
:root[lang="ru"] .hren-menu__grid { gap: 10px; }
:root[lang="ru"] .hren-menu__card-desc { font-size: clamp(10px, 1.1vw, 14px); }

:root[lang="zh"] .hren-greeting__title { font-size: clamp(22px, 3vw, 38px); }
:root[lang="zh"] .hren-menu__card-title { font-size: clamp(13px, 1.4vw, 18px); line-height: 1.2; }
:root[lang="zh"] .hren-menu__card-desc { font-size: clamp(11px, 1.2vw, 15px); }

:root[lang="en"] .hren-menu__card-desc { font-size: clamp(11px, 1.2vw, 15px); }
:root[lang="vi"] .hren-menu__card-desc { font-size: clamp(12px, 1.3vw, 16px); }

/* ============================================================
   UTILITY — tránh tràn nội dung trên mọi màn hình
   ============================================================ */
.hren-menu__card-title,
.hren-menu__card-desc {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.hren-greeting__title,
.hren-greeting__subtitle,
.hren-logo__name,
.hren-logo__poetry {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Đảm bảo card không tràn grid */
.hren-menu__card {
  min-width: 0;
  overflow: hidden;
  max-width: 100%;
}

/* Footer giá trị không bị nén quá */
.hren-footer__values {
  flex-wrap: wrap;
  min-width: 0;
}

/* Character image không vượt container */
.hren-character__img {
  max-width: 100%;
  object-fit: contain;
}

/* Greeting không tràn bên phải */
.hren-greeting {
  max-width: 100%;
  min-width: 0;
}

/* ============================================================
   ASPECT-RATIO MEDIA QUERIES — xử lý màn hình có tỷ lệ đặc biệt
   ============================================================ */

/* Màn hình CAO (height > 1000px) — tăng kích thước mọi thứ tỷ lệ */
@media (min-height: 1000px) and (min-width: 1280px) {
  .hren-main {
    padding: clamp(24px, 3vh, 48px) clamp(28px, 3vw, 56px) clamp(18px, 2.5vh, 40px);
    gap: clamp(10px, 1.5vh, 20px);
  }
  /* Cô gái to hơn, bám đáy */
  .hren-character { height: min(95vh, 1050px); }
  .hren-logo__img { width: clamp(60px, 4.5vw, 84px); height: clamp(60px, 4.5vw, 84px); }
  .hren-logo__name { font-size: clamp(36px, 3.2vw + 1vh, 56px); }
  .hren-logo__sub { font-size: clamp(18px, 1.6vw + 0.5vh, 28px); }
  .hren-logo__poetry { font-size: clamp(17px, 1.5vw + 0.5vh, 26px); }
  .hren-greeting { top: clamp(8px, 1.2vh, 24px); }
  .hren-greeting__title { font-size: clamp(36px, 3vw + 1.5vh, 60px); }
  .hren-greeting__line--accent { font-size: clamp(40px, 3.4vw + 1.8vh, 68px); }
  .hren-greeting__subtitle { font-size: clamp(15px, 1.2vw + 0.8vh, 26px); }
  .hren-menu__grid { gap: clamp(12px, 1.2vw, 18px); }
  .hren-menu__card-title { font-size: clamp(16px, 1.2vw + 0.7vh, 24px); }
  .hren-menu__card-desc { font-size: clamp(13px, 1vw + 0.5vh, 20px); }
  .hren-character__bubble { font-size: clamp(15px, 0.9vw + 0.4vh, 22px); }
  .hren-footer__value { font-size: clamp(9px, 0.5vw + 0.2vh, 12px); }
}

/* Màn hình RỘNG (width > 2400px) — giới hạn max-width */
@media (min-width: 2400px) {
  .hren-main {
    max-width: 2400px;
    margin: 0 auto;
  }
}

/* Màn hình ngắn (height < 700px) — compact mode cho laptop nhỏ */
@media (max-height: 700px) and (min-width: 1024px) {
  .hren-main {
    padding: 14px 22px 10px;
    gap: 6px;
  }
  .hren-logo__img { width: 50px; height: 50px; }
  .hren-logo__name { font-size: 32px; }
  .hren-logo__sub { font-size: 17px; }
  .hren-logo__poetry { font-size: 16px; }
  .hren-logo__tagline { font-size: 8px; }
  .hren-greeting__title { font-size: 34px; }
  .hren-greeting__line--accent { font-size: 38px; }
  .hren-greeting__subtitle { font-size: 14px; }
  .hren-menu__card-title { font-size: 14px; }
  .hren-menu__card-desc { font-size: 12px; }
  .hren-character__bubble { font-size: 13px; max-width: 140px; }
  .hren-footer__value { font-size: 8px; }
}
