/* Giao diện tra cứu TTHC công khai.
   Giá trị lấy từ docs/05-dac-ta-giao-dien-kiosk.md §3–§5. Màu luôn qua biến, không chép hex (R1).
   `--dept` do template đặt inline từ màu phòng ban ĐÃ KIỂM ĐỊNH; luôn có màu dự phòng. */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.stage {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.content {
  flex: 1;
  min-width: 0;
}

.content-plain {
  padding: 26px 30px 40px;
}

/* ---- Rail phòng ban ---- */

.rail {
  width: 230px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rail-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--dept, var(--red));
  /* Màu chữ tính theo độ sáng nền ở máy chủ — chữ trắng KHÔNG đạt 4.5:1 trên mọi màu phòng ban (R4). */
  color: var(--dept-ink, #fff);
  text-decoration: none;
  box-shadow: 0 3px 0 rgb(0 0 0 / 16%);
  transition: transform 0.12s ease;
}

.rail-item:hover {
  transform: translateX(2px);
}

.rail-item.active {
  border: 3px solid #fff;
  /* Khai hai lần: bản trung tính cho trình duyệt cũ, bản theo màu đơn vị cho trình duyệt hiểu color-mix.
     Viết cứng màu đỏ ở đây sẽ khiến đơn vị chọn màu khác vẫn bị viền đỏ mặc định (R1). */
  box-shadow: 0 0 0 4px rgb(0 0 0 / 14%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 20%, transparent);
  transform: translateX(3px);
}

.rail-dot {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}

.rail-text {
  min-width: 0;
}

.rail-text b {
  display: block;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

/* KHÔNG dùng opacity để tạo phân cấp: nó kéo tương phản xuống dưới ngưỡng R4 (3,06:1 trên màu nhạt nhất).
   Phân cấp đến từ cỡ chữ và độ đậm. */
.rail-text small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 400;
}

/* ---- Trang chủ ---- */

/* Bọc nội dung trang chủ, canh giữa như bản gốc (docs/01 §A.6). */
.home-wrap {
  max-width: 1100px;
  margin: 0 auto;
}

/* Khối giữa: vòng logo + "Chạm vào một phòng ban" — KHÔNG phải thẻ nổi, chỉ là nội dung canh giữa. */
.home-hero {
  padding: 8px 0 22px;
  text-align: center;
}

.home-hero .ring {
  width: 110px;
  height: 110px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 8px var(--red-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  overflow: hidden;
  animation: pulse 2.4s ease-in-out infinite;
}

.home-hero .ring img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 8px var(--red-soft);
  }

  50% {
    box-shadow: 0 0 0 14px var(--red-soft);
  }
}

/* Người dùng đã khai không muốn hiệu ứng chuyển động thì tôn trọng (WCAG 2.3.3). */
@media (prefers-reduced-motion: reduce) {
  .home-hero .ring {
    animation: none;
  }

  .rail-item {
    transition: none;
  }
}

.home-hero h2 {
  margin: 0 0 6px;
  color: var(--red-dark);
}

.hero-sub {
  margin: 0 0 16px;
  color: var(--ink-soft);
}

.section-title {
  margin: 26px 0 12px;
  font-size: 17px;
}

/* Tiêu đề khối "tra cứu nhiều" — chữ nhỏ, in hoa, giãn chữ, như bản gốc. */
.quick-label {
  margin: 4px 0 12px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.quick-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  min-height: 118px;
  padding: 16px 18px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-left: 7px solid var(--dept, var(--red));
  border-radius: 16px;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 2px 6px rgb(0 0 0 / 4%);
}

.quick-icon {
  font-size: 28px;
  line-height: 1;
}

/* Tên thủ tục: gọn 2 dòng để các thẻ trong lưới cao đều nhau. */
.quick-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Nhãn mức độ tự co theo chữ, không kéo dài cả dòng. */
.quick-card .badge {
  align-self: flex-start;
}

/* "Mã … · Phòng ban" đẩy xuống đáy thẻ. */
.quick-meta,
.quick-card small {
  margin-top: auto;
  color: var(--ink-soft);
}

/* ---- Tìm kiếm và bộ lọc ---- */

.search {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.search input {
  flex: 1;
  min-width: 220px;
  max-width: 420px;
  min-height: 48px;
  padding: 0 14px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
}

.search input:focus-visible,
.filters select:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 1px;
}

.search button {
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 14px 0 10px;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.filters select {
  min-height: 44px;
  max-width: 320px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
}

.clear-filters {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--red);
  font-weight: 700;
}

.result-count {
  margin: 6px 0 12px;
  color: var(--ink-soft);
}

/* ---- Danh sách thủ tục ---- */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--ink-soft);
}

.crumbs a {
  color: var(--red);
}

.list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-head h2 {
  margin: 0;
  color: var(--red-dark);
  font-size: 20px;
}

.proc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.proc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--tap-min);
  padding: 12px 16px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--ink);
  text-decoration: none;
}

.proc-row:hover {
  border-color: var(--dept, var(--red));
}

.proc-icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--dept, var(--red));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.proc-main {
  flex: 1;
  min-width: 0;
}

.proc-name {
  display: block;
  font-weight: 700;
  line-height: 1.3;
}

.proc-meta {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.proc-arrow {
  font-size: 26px;
  color: var(--ink-soft);
}

.badge {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-neutral {
  background: var(--border);
  color: var(--ink-soft);
}

/* ---- Chi tiết thủ tục ---- */

.detail {
  background: var(--paper);
  border: 1px solid var(--border);
  border-left: 7px solid var(--dept, var(--red));
  border-radius: var(--radius);
  padding: 24px 26px;
}

.detail h2 {
  margin-top: 0;
  color: var(--red-dark);
  line-height: 1.3;
}

.detail-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 18px 0 22px;
}

.detail-info dt {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.detail-info dd {
  margin: 0;
  font-weight: 700;
}

.qr-panel {
  border: 3px solid var(--red);
  border-radius: 22px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 8px 24px rgb(0 0 0 / 10%);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--red) 12%, transparent);
}

.qr-panel h3 {
  margin: 0 0 14px;
  font-size: 15px;
}

.qr-box svg,
.qr-image {
  max-width: 220px;
  height: auto;
}

.qr-state {
  color: var(--ink-soft);
  margin: 0;
}

.qr-error {
  color: var(--warn);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 22px;
}

.btn-primary,
.btn-plain {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 22px;
  border-radius: 14px;
  font-weight: 700;
  text-decoration: none;
}

.btn-primary {
  background: var(--red);
  color: #fff;
}

.btn-plain {
  background: var(--paper);
  border: 1px solid var(--border);
  color: var(--ink);
}

.detail-hotline {
  margin: 18px 0 0;
  color: var(--ink-soft);
}

.state {
  background: var(--paper);
  border: 1px dashed var(--red-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--ink-soft);
}

.preview-note {
  background: var(--red-soft);
  border: 1px solid var(--red-border);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 0 0 16px;
  font-size: 13.5px;
}

/* ---- Điểm ngắt (docs/05 §4) ---- */

@media (max-width: 900px) {
  .rail {
    width: 170px;
  }

  .rail-item {
    min-height: 78px;
  }

  .quick-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }
}

/*
 * Điện thoại: rail KHÔNG bị ẩn mà chuyển thành dải chip cuộn ngang phía trên nội dung.
 * Giữ nguyên đường điều hướng chính trên mọi kích thước — đây là điểm bản gốc làm tốt (ui-guidelines §2).
 */
@media (max-width: 640px) {
  .stage {
    flex-direction: column;
    gap: 14px;
  }

  .rail {
    width: 100%;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .rail-item {
    min-height: 60px;
    min-width: 150px;
    flex-shrink: 0;
    padding: 10px 12px;
  }

  .rail-text b {
    font-size: 13.5px;
  }

  .content {
    width: 100%;
  }

  .list-head {
    flex-direction: column;
    align-items: stretch;
  }

  .search input {
    min-width: 0;
  }

  .filters select {
    max-width: none;
    width: 100%;
  }

  /*
   * Tên thủ tục hành chính rất dài (có tên tới hơn 100 ký tự). Giữ badge nằm cùng hàng với tên trên
   * màn hẹp thì cột tên chỉ còn ~150px và một dòng thủ tục cao tới 300px — cuộn hết 375 thủ tục là
   * không dùng nổi. Trên điện thoại, cho tên chiếm trọn chiều ngang và đẩy badge xuống hàng dưới.
   */
  /* docs/05 §4 chốt thẻ nhanh 2 cột ở điện thoại; `auto-fill minmax(170px)` tụt xuống 1 cột dưới 380px. */
  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .proc-row {
    flex-wrap: wrap;
    align-items: flex-start;
    row-gap: 8px;
  }

  .proc-icon {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .proc-main {
    flex: 1 1 calc(100% - 52px);
  }

  .badge {
    margin-left: 52px;
  }

  .proc-arrow {
    margin-left: auto;
    line-height: 1;
  }

  .qr-box svg,
  .qr-image {
    max-width: 150px;
  }

  .detail-info {
    grid-template-columns: 1fr;
  }

  .btn-primary,
  .btn-plain {
    width: 100%;
    justify-content: center;
  }
}

/* Dải thông báo của bản tĩnh — chỉ hiện khi người dân đang đọc một bản chụp lúc hệ thống gián đoạn.
   Dùng token cảnh báo sẵn có (R1), không chép hex. */
.static-notice {
  margin: 0;
  padding: 12px 22px;
  background: var(--warn-bg);
  color: var(--warn);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.45;
}
