/* ============================================================
   航泰砂布官網 — 設計系統
   色系:白底 / 炭灰 / 鋼灰 / 工業橘(鏽橘,不螢光)
   字體:系統中文字型、Barlow Condensed(英文眉標/編號)、
        IBM Plex Mono(型號/番號等規格文字)
   簽名元素:番號刻度線(砂粒由粗到細)、砂紙顆粒噪點紋理
   ============================================================ */

:root {
  --paper: #ffffff;
  --mist: #f4f5f6;
  --ink: #22262a;
  --ink-panel: #272b2f;
  --ink-deep: #1b1f23;
  --steel: #5d6874;
  --line: #e2e5e8;
  --grit: #c0510f;
  --grit-deep: #a94407;
  --grit-tint: #faeee4;

  --font-body: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-cond: "Barlow Condensed", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --container: 1180px;
  --radius: 3px;
  --shadow-card: 0 10px 28px rgba(34, 38, 42, 0.1);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---------- 自架字型:拉丁字元(眉標/編號/規格),自架 + 預載,首屏即可用、避免字型換入位移 ---------- */
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../assets/fonts/barlow-condensed-500.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../assets/fonts/barlow-condensed-600.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../assets/fonts/ibm-plex-mono-500.woff2") format("woff2");
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 作者樣式一律勝過瀏覽器預設的 [hidden]{display:none},而 .news-row 與 .pagination
   都是 display:flex —— 沒有這條,news.js 的 el.hidden = true 完全不會生效 */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.85;
  color: var(--ink);
  background: var(--paper);
}

h1, h2, h3, h4, p, ul, ol, figure {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  color: inherit;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--grit);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 版面容器 ---------- */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 簽名元素:番號刻度線(砂粒粗 → 細) ---------- */
.grit-rule {
  width: 212px;
  max-width: 60%;
  height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 106 8'%3E%3Cg fill='%23C0510F'%3E%3Ccircle cx='4' cy='4' r='3.4'/%3E%3Ccircle cx='15' cy='4' r='3'/%3E%3Ccircle cx='25' cy='4' r='2.7'/%3E%3Ccircle cx='34' cy='4' r='2.4'/%3E%3Ccircle cx='42.5' cy='4' r='2.1'/%3E%3Ccircle cx='50' cy='4' r='1.9'/%3E%3Ccircle cx='57' cy='4' r='1.7'/%3E%3Ccircle cx='63.5' cy='4' r='1.5'/%3E%3Ccircle cx='69.5' cy='4' r='1.35'/%3E%3Ccircle cx='75' cy='4' r='1.2'/%3E%3Ccircle cx='80' cy='4' r='1.05'/%3E%3Ccircle cx='84.5' cy='4' r='0.95'/%3E%3Ccircle cx='88.5' cy='4' r='0.85'/%3E%3Ccircle cx='92' cy='4' r='0.75'/%3E%3Ccircle cx='95.2' cy='4' r='0.65'/%3E%3Ccircle cx='98' cy='4' r='0.6'/%3E%3Ccircle cx='100.5' cy='4' r='0.55'/%3E%3Ccircle cx='102.8' cy='4' r='0.5'/%3E%3C/g%3E%3C/svg%3E")
    left center / contain no-repeat;
}

/* 深色底用的淺色刻度線 */
.grit-rule--light {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 106 8'%3E%3Cg fill='%23F4F5F6'%3E%3Ccircle cx='4' cy='4' r='3.4'/%3E%3Ccircle cx='15' cy='4' r='3'/%3E%3Ccircle cx='25' cy='4' r='2.7'/%3E%3Ccircle cx='34' cy='4' r='2.4'/%3E%3Ccircle cx='42.5' cy='4' r='2.1'/%3E%3Ccircle cx='50' cy='4' r='1.9'/%3E%3Ccircle cx='57' cy='4' r='1.7'/%3E%3Ccircle cx='63.5' cy='4' r='1.5'/%3E%3Ccircle cx='69.5' cy='4' r='1.35'/%3E%3Ccircle cx='75' cy='4' r='1.2'/%3E%3Ccircle cx='80' cy='4' r='1.05'/%3E%3Ccircle cx='84.5' cy='4' r='0.95'/%3E%3Ccircle cx='88.5' cy='4' r='0.85'/%3E%3Ccircle cx='92' cy='4' r='0.75'/%3E%3Ccircle cx='95.2' cy='4' r='0.65'/%3E%3Ccircle cx='98' cy='4' r='0.6'/%3E%3Ccircle cx='100.5' cy='4' r='0.55'/%3E%3Ccircle cx='102.8' cy='4' r='0.5'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---------- 簽名元素:砂紙顆粒紋理(用在深色區塊) ---------- */
.grain {
  position: relative;
}

.grain::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.09;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

.grain > * {
  position: relative;
}

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.4;
  border-radius: var(--radius);
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease),
    color 0.2s var(--ease);
}

.btn-primary {
  background: var(--grit);
  color: #fff;
}

.btn-primary:hover {
  background: var(--grit-deep);
}

.btn-ghost {
  border: 1px solid var(--ink);
  color: var(--ink);
  background: transparent;
}

.btn-ghost:hover {
  border-color: var(--grit);
  color: var(--grit);
}

/* 深色底上的反白按鈕 */
.btn-ghost--light {
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: #fff;
}

.btn-ghost--light:hover {
  border-color: var(--grit);
  color: #fff;
  background: var(--grit);
}

/* ---------- 區塊標題 ---------- */
.section {
  padding: 88px 0;
}

.section--mist {
  background: var(--mist);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 44px;
}

.section-eyebrow {
  font-family: var(--font-cond);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--grit);
  display: block;
  margin-bottom: 6px;
}

/* 淺灰底需使用較深的品牌橘，確保小字達到 WCAG AA 對比。 */
.section--mist .section-eyebrow {
  color: var(--grit-deep);
}

.section-title {
  font-size: clamp(26px, 3.2vw, 34px);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.section-more {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 15px;
  color: var(--steel);
  border-bottom: 2px solid var(--line);
  padding-bottom: 2px;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
  white-space: nowrap;
}

.section-more:hover {
  color: var(--grit);
  border-color: var(--grit);
}

/* ---------- 標籤 ---------- */
.tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--grit-deep);
  background: var(--grit-tint);
  border-radius: var(--radius);
}

/* ---------- 進場顯示 ---------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

[data-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* ---------- 最上方資訊列 ---------- */
.topbar {
  background: var(--ink-deep);
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.topbar-in {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 36px;
}

.topbar a:hover {
  color: #fff;
}

.topbar-sep {
  width: 1px;
  height: 12px;
  background: rgba(255, 255, 255, 0.25);
}

.topbar-hours {
  margin-left: auto;
}

/* ---------- 頁首 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  transition: box-shadow 0.25s var(--ease);
}

.site-header.is-scrolled {
  box-shadow: 0 6px 20px rgba(34, 38, 42, 0.08);
}

.header-in {
  display: flex;
  align-items: center;
  gap: 32px;
  min-height: 76px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo-mark {
  width: 38px;
  height: 38px;
}

.brand-name {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
}

.brand-name small {
  font-family: var(--font-cond);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.24em;
  color: var(--steel);
  margin-top: 2px;
}

.site-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.site-nav a {
  position: relative;
  padding: 26px 16px;
  font-size: 15.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink);
  transition: color 0.2s var(--ease);
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  height: 3px;
  background: var(--grit);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s var(--ease);
}

.site-nav a:hover {
  color: var(--grit);
}

.site-nav a.active {
  font-weight: 700;
}

.site-nav a.active::after,
.site-nav a:hover::after {
  transform: scaleX(1);
}

.header-cta {
  flex-shrink: 0;
  padding: 10px 22px;
}

/* 手機版選單按鈕 */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--ink);
  transition: transform 0.25s var(--ease), opacity 0.2s var(--ease);
}

.nav-open .nav-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-open .nav-toggle span:nth-child(2) {
  opacity: 0;
}

.nav-open .nav-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ---------- 頁尾 ---------- */
.site-footer {
  background: var(--ink-deep);
  color: rgba(255, 255, 255, 0.72);
  border-top: 3px solid var(--grit);
  margin-top: auto;
}

.footer-in {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1fr;
  gap: 48px;
  padding: 60px 24px 48px;
}

.footer-brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.site-footer .brand-name {
  color: #fff;
}

.site-footer .brand-name small {
  color: rgba(255, 255, 255, 0.5);
}

.site-footer .logo-mark rect {
  fill: #2e3338;
}

.footer-brand p {
  font-size: 14.5px;
  line-height: 2;
  max-width: 340px;
}

.footer-col h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #fff;
  margin-bottom: 18px;
}

.footer-col li {
  font-size: 14.5px;
  margin-bottom: 10px;
}

.footer-col a:hover {
  color: var(--grit);
}

.site-footer .footer-col a:hover {
  color: #f08a4b;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 18px 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.05em;
}

/* ---------- 無障礙:視覺隱藏但保留給讀屏與 SEO ---------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 產品卡片(首頁/產品列表共用) ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}

.product-grid .state-note {
  grid-column: 1 / -1;
}

.p-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

.p-card:hover {
  border-color: var(--grit);
  transform: translateY(-4px);
  box-shadow: var(--shadow-card);
}

.p-card > a {
  display: block;
}

.p-media {
  aspect-ratio: 4 / 3;
  background: var(--mist);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.p-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--ease);
}

.p-card:hover .p-media img {
  transform: scale(1.04);
}

.p-media-empty {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--steel);
  font-size: 13px;
  letter-spacing: 0.1em;
}

.p-body {
  padding: 20px 22px 22px;
}

.p-cat {
  display: block;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: var(--steel);
  margin-bottom: 6px;
}

.p-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.5;
  margin-bottom: 6px;
}

.p-spec {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--steel);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 16px;
  min-height: 1.6em;
}

.p-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.p-arrow {
  color: var(--steel);
  transition: transform 0.25s var(--ease), color 0.25s var(--ease);
}

.p-card:hover .p-arrow {
  transform: translateX(4px);
  color: var(--grit);
}

/* ---------- 消息列(首頁/消息列表共用) ---------- */
.news-list {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.news-list .state-note {
  border: 0;
}

.news-row {
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 24px 30px;
  transition: background-color 0.2s var(--ease);
}

.news-row + .news-row {
  border-top: 1px solid var(--line);
}

.news-row:hover {
  background: var(--grit-tint);
}

.news-date {
  flex-shrink: 0;
  width: 74px;
  text-align: center;
  font-family: var(--font-cond);
  line-height: 1.1;
}

.news-date b {
  display: block;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.news-date span {
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--steel);
}

.news-row .tag {
  flex-shrink: 0;
}

.news-main {
  min-width: 0;
}

.news-main h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.news-main p {
  font-size: 14px;
  color: var(--steel);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.news-arrow {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--steel);
  transition: transform 0.25s var(--ease), color 0.25s var(--ease);
}

.news-row:hover .news-arrow {
  transform: translateX(4px);
  color: var(--grit);
}

/* ---------- 搜尋框與結果說明(產品/消息列表共用) ---------- */
.p-search {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.p-search input {
  flex: 1;
  min-width: 0;
  padding: 11px 16px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  transition: border-color 0.2s var(--ease);
}

.p-search input:focus {
  outline: none;
  border-color: var(--grit);
}

.p-search input::placeholder {
  color: var(--steel);
}

.p-result-info {
  font-size: 14px;
  color: var(--steel);
  margin-bottom: 22px;
  min-height: 1.5em;
}

.p-result-info b {
  color: var(--grit);
  font-weight: 700;
}

/* ---------- 分頁 ---------- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 44px;
}

/* 靜態頁的分頁是 <a>(爬蟲要跟得到第 2 頁以後),不可點的項目是 <span class="pg-item">;
   button 仍保留在選擇器裡,給還沒靜態化的頁面用 */
.pagination a,
.pagination .pg-item,
.pagination button {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-cond);
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease),
    background-color 0.2s var(--ease);
}

.pagination a:hover:not(.is-current),
.pagination button:hover:not(:disabled):not(.is-current) {
  border-color: var(--grit);
  color: var(--grit);
}

.pagination .is-current {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  cursor: default;
}

.pagination .is-disabled,
.pagination button:disabled {
  opacity: 0.35;
  cursor: default;
}

.pagination .pg-gap {
  color: var(--steel);
  padding: 0 2px;
}

/* ---------- 狀態顯示(載入中/暫無資料) ---------- */
.state-note {
  padding: 36px 0;
  color: var(--steel);
  font-size: 15px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- 響應式 ---------- */
@media (max-width: 1024px) {
  .site-nav a {
    padding: 26px 10px;
  }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .product-grid {
    grid-template-columns: 1fr;
  }

  .news-row {
    flex-wrap: wrap;
    gap: 12px 16px;
    padding: 20px;
  }

  .news-main {
    flex-basis: 100%;
  }

  .news-main h3,
  .news-main p {
    white-space: normal;
  }

  .news-arrow {
    display: none;
  }
}

@media (max-width: 860px) {
  .topbar-hours {
    display: none;
  }

  .header-in {
    min-height: 64px;
    gap: 16px;
  }

  .header-cta {
    display: none;
  }

  .nav-toggle {
    display: flex;
    margin-left: auto;
  }

  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 30px rgba(34, 38, 42, 0.12);
    display: none;
  }

  .nav-open .site-nav {
    display: flex;
  }

  .site-nav a {
    padding: 15px 24px;
    border-top: 1px solid var(--line);
  }

  .site-nav a::after {
    display: none;
  }

  .site-nav a.active {
    color: var(--grit);
  }

  .section {
    padding: 60px 0;
  }

  .section-head {
    flex-wrap: wrap;
    margin-bottom: 32px;
  }

  .footer-in {
    grid-template-columns: 1fr;
    gap: 36px;
    padding: 44px 24px 36px;
  }
}
