/* =========================================================
   KOULSPACE — Trang chủ (mục 5)
   ========================================================= */

.section {
  position: relative;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(72px, 10vw, 140px) var(--gutter) 0;
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: clamp(28px, 4vw, 48px);
}
.section-head h2 { margin-top: 4px; }

/* ---------- 1. Màn hình đầu: Rhythm · Arcs · Words → RAW ---------- */
.hero {
  --hero-fs: clamp(52px, 7.6vw, 136px);
  --raw-scale: 1.75;
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}
.hero__pin {
  position: relative;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 0 var(--gutter);
}
/* Đường nền chạy ngang (JS vẽ), nằm dưới chữ và dưới các khối giấy */
.flow-lines { pointer-events: none; }
.flow-lines path {
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;   /* tự vẽ ra khi tới lượt (pathLength = 1) */
  transition: stroke-dashoffset 2.4s var(--ease-out);
}
.flow-lines path.is-drawn { stroke-dashoffset: 0; }
.flow-lines .sweep { stroke-width: 1.2; opacity: .26; }
.flow-lines .accent { stroke: var(--accent); stroke-width: 1.6; opacity: .75; }
.reduced-motion .flow-lines path { stroke-dashoffset: 0; transition: none; }
.hero__lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}
.page-lines {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 0;
  z-index: 0;
}
main, .site-footer { position: relative; z-index: 1; }
.hero__words, .hero__hint, .hero__rule { z-index: 1; }
.hero__words { position: relative; }

/* Logo Trang chủ: nằm giữa header và chữ RAW, đúng trục logo header */
.hero__logo {
  --logo-size: clamp(76px, 15vh, 148px);
  position: absolute;
  left: 50%;
  top: calc((var(--header-top) + var(--header-h) + 50% - var(--hero-fs) * var(--raw-scale) * .55) / 2);
  width: var(--logo-size);
  height: var(--logo-size);
  transform: translate(-50%, -50%);
  z-index: 2;
  cursor: pointer;
  border-radius: 50%;
}
.hero__logo:focus-visible { outline-offset: 10px; }
.hero__words, .hero__measure {
  font-family: var(--font-display);
  font-size: var(--hero-fs);
  font-weight: 600;
  font-variation-settings: "SOFT" 80, "opsz" 144;
  font-optical-sizing: none;
  line-height: 1;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.hero__words { display: flex; align-items: baseline; gap: .28em; }
.hero__words .w { display: inline-flex; }
.hero__hint > * { display: inline-block; }
/* Không dùng will-change: để trình duyệt vẽ lại nét chữ ở cỡ phóng to (tránh chữ RAW bị mờ) */
.hero__words .i { display: inline-block; transform-origin: 50% 60%; }
.hero__words .rest { display: inline-flex; }
.hero__words .ch { display: inline-block; }
.hero__words .sep { color: var(--accent); font-weight: 400; }
.hero__measure {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-size: calc(var(--hero-fs) * var(--raw-scale));
  visibility: hidden;
  pointer-events: none;
}
/* Nét kẻ màu nhấn dưới RAW, dài từ chân chữ R đến hết chữ W (JS đặt left/width) */
.hero__rule {
  position: absolute;
  top: calc(50% + var(--hero-fs) * var(--raw-scale) * .5);
  left: 50%;
  width: 0;
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 50% 50%;
}
.hero__hint {
  position: absolute;
  bottom: clamp(20px, 5vh, 44px);
  left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.hero__hint .icon { width: 20px; height: 20px; animation: nudge 2.2s var(--ease-out) infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

/* Điện thoại: 3 chữ xếp dọc, chữ đầu đọc từ trên xuống thành RAW */
@media (max-width: 720px) {
  .hero { --hero-fs: clamp(48px, 17vw, 96px); --raw-scale: 1.25; }
  .hero__logo { --logo-size: clamp(72px, 12vh, 112px); }
  .hero__words { flex-direction: column; align-items: flex-start; gap: .04em; }
  .hero__words .sep { display: none; }
}

/* Không có hiệu ứng (giảm chuyển động / thiếu thư viện): hiện tĩnh, chữ đầu tô màu nhấn */
.hero.is-static .hero__words .i { color: var(--accent); }
.hero.is-static .hero__rule { display: none; }

/* ---------- 2. Tin nổi bật: khung lớn chạy 5 nội dung, thanh chạy dưới đáy như story (chủ dự án chốt 2026-12-03) ---------- */
.hl {
  --hl-dur: 5s;
  position: relative;
  aspect-ratio: 21 / 9;
  min-height: 340px;
  overflow: hidden;
  isolation: isolate;
  background: var(--fill-2);
}
.hl__track { position: absolute; inset: 0; }
.hl__slide {
  position: absolute; inset: 0;
  display: block;
  opacity: 0; visibility: hidden;
  transition: opacity .9s ease, visibility 0s .9s;
}
.hl__slide.is-active { opacity: 1; visibility: visible; transition: opacity .9s ease, visibility 0s; z-index: 1; }
.hl__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform-origin: 50% 50%; }
/* Ảnh phóng to / thu nhỏ luân phiên, nhẹ, kéo dài suốt thời gian slide hiện */
.hl__slide.is-active .hl__img { animation: hl-zoom-in calc(var(--hl-dur) + 1s) linear both; }
.hl__slide.is-active:nth-child(even) .hl__img { animation-name: hl-zoom-out; }
@keyframes hl-zoom-in { from { transform: scale(1); } to { transform: scale(1.08); } }
@keyframes hl-zoom-out { from { transform: scale(1.08); } to { transform: scale(1); } }
/* Slide hình minh họa (mảng chưa có ảnh): nền tông màu mảng, hình nằm bên phải */
.hl__slide.is-art { background: var(--fill); }
.hl__art { inset: 6% 4% 6% auto; width: 52%; }
.hl__art svg { display: block; width: 100%; height: 100%; }
/* Chữ: góc dưới trái, trên dải tối mờ (ảnh) */
.hl__slide.is-photo::after {
  content: ""; position: absolute; inset: 40% 0 0 0; z-index: 1;
  background: linear-gradient(to bottom, rgba(20, 20, 18, 0), rgba(20, 20, 18, .72));
}
.hl__text {
  position: absolute; z-index: 2; left: clamp(20px, 4vw, 44px); right: clamp(20px, 4vw, 44px); bottom: clamp(40px, 5vw, 56px);
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-width: 640px;
}
.hl__slide.is-art .hl__text { right: 52%; top: 0; justify-content: center; bottom: 36px; }
.hl__title { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.35rem, 2.6vw, 2.2rem); line-height: 1.2; }
.hl__meta { font-size: .95rem; }
.hl__slide.is-photo .hl__title, .hl__slide.is-photo .hl__meta { color: #fff; }
.hl__slide.is-photo .hl__meta { opacity: .85; }
.hl__slide.is-art .hl__meta { color: var(--ink-soft); }
.hl__slide.is-photo .tag { background: rgba(255, 255, 255, .9); color: #1F1F1D; border-color: transparent; }
.hl__slide.is-photo .tag .icon { color: var(--br-ink, currentColor); }
/* Thanh chạy dưới đáy: mỗi tin một vạch trắng, vạch đang chạy đầy dần trong --hl-dur */
.hl__bars {
  position: absolute; z-index: 3; left: clamp(20px, 4vw, 44px); right: clamp(20px, 4vw, 44px); bottom: 18px;
  display: flex; gap: 6px;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, .35));
}
.hl__bar { flex: 1; height: 16px; padding: 6px 0; border: 0; background: none; cursor: pointer; }
.hl__bar span { display: block; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .45); overflow: hidden; }
.hl__bar i { display: block; height: 100%; width: 0; background: #fff; border-radius: inherit; }
.hl__bar.is-done i { width: 100%; }
.hl__bar.is-active i { animation: hl-fill var(--hl-dur) linear forwards; }
@keyframes hl-fill { from { width: 0; } to { width: 100%; } }
.hl.is-on-art .hl__bars { filter: none; }
.hl.is-on-art .hl__bar span { background: color-mix(in srgb, var(--ink) 16%, transparent); }
.hl.is-on-art .hl__bar i { background: var(--ink); }
.hl.is-paused .hl__bar.is-active i, .hl.is-paused .hl__slide.is-active .hl__img { animation-play-state: paused; }
/* Nút trước / sau: hiện khi rê chuột */
.hl__nav {
  position: absolute; z-index: 3; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .88); color: #1F1F1D;
  border: 1px solid rgba(31, 31, 29, .12);
  opacity: 0; transition: opacity .25s, transform .3s var(--ease-out);
}
.hl__nav .icon { width: 20px; height: 20px; }
.hl__nav--prev { left: 14px; }
.hl__nav--prev .icon { transform: rotate(180deg); } /* mũi tên trái: quay ngược mũi tên phải */
.hl__nav--next { right: 14px; }
.hl:hover .hl__nav, .hl__nav:focus-visible { opacity: 1; }
.hl__nav:hover { transform: translateY(-50%) scale(1.06); }
@media (hover: none) { .hl__nav { display: none; } }
@media (max-width: 720px) {
  .hl { aspect-ratio: 4 / 5; min-height: 0; }
  .hl__art { inset: 8% 8% auto 8%; width: auto; height: 46%; }
  .hl__slide.is-art .hl__text { right: clamp(20px, 4vw, 44px); top: auto; bottom: clamp(40px, 5vw, 56px); }
  .hl__meta { font-size: .88rem; }
}
.reduced-motion .hl__img, .hl.is-static .hl__img { animation: none !important; }
.hl.is-static .hl__bar.is-active i { animation: none !important; width: 100%; } /* giảm chuyển động: vạch đang xem tô đầy, không chạy */

/* ---------- Thẻ bài (trang "Xem tất cả") ---------- */
.latest__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(16px, 2.2vw, 28px);
}
.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .5s var(--ease-out), border-color .25s;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.card__thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  border-bottom: var(--stroke) solid var(--line);
  background: var(--fill-2);
  overflow: hidden;
}
.card__thumb svg, .card__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease-out); }
.card:hover .card__thumb svg, .card:hover .card__thumb img { transform: scale(1.04); }
.card__body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.tag {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 7px;
  border: var(--stroke) solid var(--line);
  border-radius: 999px;
  background: var(--fill);
  font-size: .78rem;
  font-weight: 600;
}
.tag .icon { width: 16px; height: 16px; }
.tag .sw-mark { width: 16px; height: auto; }

/* Trang "Xem tất cả" (updates.html): lưới xếp dọc cả trên điện thoại */
.updates { padding-top: clamp(28px, 5vw, 56px); }
.updates__title { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.updates__back { transform: scaleX(-1); }
.updates .filters { margin-bottom: 24px; }
@media (max-width: 620px) {
  .latest__grid.latest__grid--page { grid-auto-flow: row; grid-template-columns: 1fr; overflow: visible; margin-right: 0; padding: 0; }
}
.card__title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; line-height: 1.3; }
.card__meta { margin-top: auto; font-size: .82rem; color: var(--ink-soft); }
.thumb-note {
  position: absolute; right: 10px; bottom: 8px;
  font-size: .68rem; letter-spacing: .06em; color: var(--ink-soft);
}

@media (max-width: 980px) { .latest__grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) {
  .latest__grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 82%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 4px 6px 14px 2px;
    margin-right: calc(var(--gutter) * -1);
    padding-right: var(--gutter);
    scrollbar-width: none;
  }
  .latest__grid::-webkit-scrollbar { display: none; }
  .card { scroll-snap-align: start; }
}

/* ---------- 3. Ba thanh lớn R · A · W ---------- */
.triad__stack { display: flex; flex-direction: column; gap: 6vh; }
.bar {
  --shade: 0;
  position: sticky;
  top: calc(var(--header-top) + var(--header-h) + 22px);
  min-height: min(680px, calc(100svh - var(--header-top) - var(--header-h) - 44px));
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  overflow: hidden;
  transform-origin: 50% 0;
}
/* Mỗi thanh chỉ mang màu mảng ở viền, tiêu đề và chi tiết minh họa (không khối màu đặc) */
.bar[data-branch] { border-color: var(--br-line); }
.bar[data-branch] .bar__letter { -webkit-text-stroke-color: var(--br); opacity: .45; }
.card[data-branch] .tag .icon { color: var(--accent); }
.bar::after { /* lớp phủ tối dần khi thanh sau trượt đè lên */
  content: "";
  position: absolute;
  inset: 0;
  background: var(--paper);
  opacity: var(--shade);
  pointer-events: none;
}
.bar__cover {
  position: relative;
  border-right: var(--stroke) solid var(--line);
  background: var(--fill-2);
  display: grid;
  place-items: center;
  padding: clamp(16px, 3vw, 40px);
  overflow: hidden;
}
.bar__cover svg.ill { width: 100%; max-width: 560px; height: auto; }
/* Ảnh thật thay hình minh họa: phủ kín ô, chữ R / A / W nằm trên ảnh */
.bar__cover.has-photo { padding: 0; }
.bar__photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.bar__cover.has-photo .bar__letter { z-index: 1; -webkit-text-stroke-color: #fff; opacity: .85; filter: drop-shadow(0 0 3px rgba(0, 0, 0, .45)); } /* bóng mờ nhẹ để chữ viền trắng đọc được trên ảnh sáng */
.bar__cover .thumb-note { right: 16px; bottom: 12px; }
.bar__letter {
  position: absolute;
  left: clamp(12px, 2vw, 24px);
  top: clamp(4px, 1vw, 12px);
  font-family: var(--font-display);
  font-size: clamp(5rem, 11vw, 9.5rem);
  font-weight: 700;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--ink);
  opacity: .22;
  pointer-events: none;
}
.bar__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: clamp(24px, 4vw, 56px);
}
.bar__body { position: relative; }
/* Logo động của mảng ở góc trên phải (chủ dự án yêu cầu 2026-12-03; giống thẻ lĩnh vực trang Về tôi):
   Kouls tô màu mảng, rê chuột thì về cỏ bốn lá; Sino Words rê chuột thì 3 cánh bay ra. Điện thoại: chạm để đổi. */
.bar__mark {
  position: absolute; top: clamp(18px, 2.6vw, 32px); right: clamp(18px, 2.6vw, 32px);
  width: 60px; height: 60px;
  display: grid; place-items: center;
  border-radius: 15px;
  background: var(--fill);
  cursor: pointer;
  transition: transform .35s var(--ease-out);
}
.bar__mark:hover { transform: scale(1.06); }
.bar__mark.kmark > div, .bar__mark.kmark svg { width: 42px !important; height: 42px !important; }
.bar__mark.swmark svg { width: 38px !important; height: 38px !important; }
.bar__mark img.sw-mark { width: 38px; }
.bar__title { font-size: clamp(2.2rem, 4.2vw, 3.6rem); }
.bar__title b { color: var(--accent); }
.bar__slogan { font-family: var(--font-display); font-style: italic; font-weight: 500; font-size: clamp(1.15rem, 1.8vw, 1.4rem); line-height: 1.3; } /* cùng kiểu slogan ở màn giới thiệu từng mảng */

.slides { margin: 14px 0 8px; }
.slides__track { display: grid; }
.slide {
  grid-area: 1 / 1;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 16px;
  align-items: start;
  padding: 18px;
  border: var(--stroke) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  opacity: 0;
  transform: translateY(12px);
  visibility: hidden;
  transition: opacity .5s ease, transform .6s var(--ease-out), visibility 0s .6s;
}
.slide.is-active { opacity: 1; transform: none; visibility: visible; transition: opacity .5s ease .1s, transform .6s var(--ease-out) .1s, visibility 0s; }
.slide__num { font-family: var(--font-display); font-size: 1rem; font-weight: 600; font-variant-numeric: lining-nums; color: var(--accent); line-height: 1.9; }
.slide h4 { font-size: 1.3rem; margin-bottom: 4px; }
.slide p { font-size: .92rem; color: var(--ink-soft); }
.slide .flags { display: flex; gap: 6px; margin-top: 10px; }
.slides__nav { display: flex; gap: 8px; margin-top: 12px; }
.slides__dot {
  flex: 1;
  height: 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  text-align: left;
  font-size: .72rem;
  font-weight: 500;
  color: var(--ink-soft);
}
.slides__dot .track { display: block; height: 3px; border-radius: 3px; background: var(--ink-faint); overflow: hidden; }
.slides__dot .fill { display: block; height: 100%; width: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }
.slides__dot.is-done .fill { transform: scaleX(1); }
.slides__dot.is-active { color: var(--ink); }
.slides__dot.is-active .fill { animation: slide-fill var(--dur, 3.6s) linear forwards; }
.slides.is-paused .slides__dot.is-active .fill { animation-play-state: paused; }
.slides.is-manual .slides__dot.is-active .fill { animation: none; transform: scaleX(1); }
@keyframes slide-fill { to { transform: scaleX(1); } }
.bar__cta { align-self: flex-start; margin-top: 6px; }

@media (max-width: 860px), (max-height: 620px) {
  .bar { position: relative; top: auto; min-height: 0; grid-template-columns: 1fr; }
  .bar__cover { border-right: 0; border-bottom: var(--stroke) solid var(--line); aspect-ratio: 4 / 3; }
  .triad__stack { gap: 28px; }
  .bar__mark { position: static; align-self: flex-start; width: 48px; height: 48px; border-radius: 12px; } /* khổ hẹp: hàng riêng trên cùng, không đè chữ */
  .bar__mark.kmark > div, .bar__mark.kmark svg { width: 34px !important; height: 34px !important; }
  .bar__mark.swmark svg, .bar__mark img.sw-mark { width: 30px !important; height: 30px !important; }
}
