/*
 * main.css
 * 名片系統視覺樣式（金屬工單銘牌版）
 * 風格：拉絲鋁底、石墨藍、不對稱規格表、CNC 定位標記
 * 核心概念：名片像一塊銑刻的拉絲鋁銘牌，左側姓名為視覺重心，右側聯絡規格表對齊如工單
 */

/* ================================
 * 1. 設計權杖（Design Tokens）
 * ================================ */
:root {
  /* 色彩：拉絲鋁淺底 + 石墨藍強調（OKLCH） */
  --color-bg: oklch(94% 0.004 250);
  --color-bg-deep: oklch(86% 0.008 250);
  --color-surface: oklch(98% 0.003 250);
  --color-surface-elevated: oklch(96% 0.004 250);
  --color-ink: oklch(26% 0.006 250);
  --color-ink-muted: oklch(44% 0.007 250);
  --color-ink-subtle: oklch(50% 0.007 250);
  --color-primary: oklch(40% 0.07 250);
  --color-primary-soft: oklch(50% 0.08 250);
  --color-primary-deep: oklch(33% 0.06 250);
  --color-accent: oklch(58% 0.015 250);
  --color-border: oklch(84% 0.006 250);
  --color-border-subtle: oklch(74% 0.01 250);
  --color-highlight: oklch(100% 0 0 / 0.7);

  /* 字體 */
  --font-display: "Bree Serif", "Noto Serif TC", Georgia, serif;
  --font-body: "Saira", "Noto Sans TC", "PingFang TC", sans-serif;

  /* 字階 */
  --text-display: clamp(3rem, 9vw, 5.25rem);
  --text-role: clamp(0.8125rem, 2vw, 0.9375rem);
  --text-spec-key: 0.75rem;
  --text-spec-val: 1rem;
  --text-spec-no: 0.6875rem;
  --text-mark: 0.625rem;

  /* 間距 */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-xxl: 4rem;

  /* 圓角：銘牌略寬，規格表無圓角 */
  --radius-plate: 8px;
  --radius-chip: 3px;
  --radius-btn: 4px;

  /* 動效 */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --duration-fast: 200ms;
  --duration-base: 400ms;
  --duration-slow: 700ms;

  /* 銘牌浮起陰影：克制、偏冷 */
  --shadow-plate:
    0 1px 0 oklch(100% 0 0 / 0.9) inset,
    0 -1px 0 oklch(0% 0 0 / 0.04) inset,
    0 30px 70px -32px oklch(25% 0.03 250 / 0.42),
    0 10px 26px -16px oklch(25% 0.03 250 / 0.22);
  --shadow-plate-hover:
    0 1px 0 oklch(100% 0 0 / 0.95) inset,
    0 -1px 0 oklch(0% 0 0 / 0.05) inset,
    0 40px 90px -34px oklch(25% 0.03 250 / 0.5),
    0 14px 32px -16px oklch(25% 0.03 250 / 0.26);
}

/* ================================
 * 2. 基礎重置
 * ================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg) var(--space-md);
  /* 拉絲鋁底：冷光漸層 + 細微拉絲紋 */
  background-color: var(--color-bg);
  background-image:
    radial-gradient(120% 80% at 10% 0%, oklch(99% 0.012 250 / 0.9), transparent 60%),
    radial-gradient(110% 70% at 95% 100%, oklch(82% 0.022 250 / 0.7), transparent 55%),
    repeating-linear-gradient(125deg, oklch(90% 0.005 250 / 0.5) 0 1px, transparent 1px 6px);
  background-attachment: fixed;
}

/* ================================
 * 3. 名片舞台與入場動畫
 * ================================ */
.card-stage {
  width: 100%;
  max-width: 720px;
  perspective: 1400px;
}

.nameplate {
  opacity: 0;
  transform: rotateX(6deg) translateY(36px) scale(0.985);
  transform-origin: center top;
  transition:
    opacity var(--duration-slow) var(--ease-out-expo),
    transform var(--duration-slow) var(--ease-out-expo),
    box-shadow var(--duration-base) var(--ease-out-quart);
}

.nameplate.is-revealed {
  opacity: 1;
  transform: rotateX(0) translateY(0) scale(1);
}

.nameplate.is-revealed .np-identity,
.nameplate.is-revealed .np-spec,
.nameplate.is-revealed .np-services,
.nameplate.is-revealed .np-actions {
  opacity: 1;
  transform: translateY(0);
}

.nameplate .np-identity,
.nameplate .np-spec,
.nameplate .np-services,
.nameplate .np-actions {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity var(--duration-base) var(--ease-out-expo),
    transform var(--duration-base) var(--ease-out-expo);
}

.nameplate.is-revealed .np-identity { transition-delay: 120ms; }
.nameplate.is-revealed .np-spec     { transition-delay: 220ms; }
.nameplate.is-revealed .np-services { transition-delay: 340ms; }
.nameplate.is-revealed .np-actions  { transition-delay: 460ms; }

/* ================================
 * 4. 拉絲鋁銘牌本體
 * ================================ */
.nameplate {
  position: relative;
  background-color: var(--color-surface);
  border: 1px solid oklch(100% 0 0 / 0.55);
  border-radius: var(--radius-plate);
  padding: clamp(1.75rem, 5vw, 3rem);
  overflow: hidden;
  box-shadow: var(--shadow-plate);
}

/* 預設可見（無頭瀏覽器 / reduced motion 退化） */
.nameplate .np-identity,
.nameplate .np-spec,
.nameplate .np-services,
.nameplate .np-actions {
  opacity: 1;
  transform: translateY(0);
}

/* 拉絲鋁紋理層：更明顯的橫向拉絲 */
.nameplate::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    /* 對角冷光：模擬光線打在金屬上的反光帶 */
    linear-gradient(115deg, transparent 30%, oklch(100% 0 0 / 0.18) 48%, oklch(100% 0 0 / 0.05) 52%, transparent 70%),
    /* 拉絲紋 */
    repeating-linear-gradient(0deg, oklch(82% 0.006 250 / 0.18) 0 1px, transparent 1px 3px),
    /* 底層冷光漸層 */
    radial-gradient(140% 100% at 0% 0%, oklch(100% 0 0 / 0.5), transparent 55%);
  opacity: 0.9;
}

/* 邊緣倒角高光：頂部亮、底部暗，模擬金屬板邊緣 */
.nameplate::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 1px 0 oklch(100% 0 0 / 0.85),
    inset 0 -1px 0 oklch(0% 0 0 / 0.08),
    inset 1px 0 0 oklch(100% 0 0 / 0.35),
    inset -1px 0 0 oklch(0% 0 0 / 0.05);
}

.nameplate:hover {
  box-shadow: var(--shadow-plate-hover);
  transform: translateY(-2px);
}

/* ================================
 * 5. CNC 四角定位標記
 * ================================ */
.np-tick {
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
  z-index: 2;
}

.np-tick::before,
.np-tick::after {
  content: "";
  position: absolute;
  background-color: var(--color-primary);
  opacity: 0.55;
}

.np-tick::before { width: 14px; height: 1px; }
.np-tick::after  { width: 1px; height: 14px; }

.np-tick-tl { top: 12px; left: 12px; }
.np-tick-tr { top: 12px; right: 12px; }
.np-tick-bl { bottom: 12px; left: 12px; }
.np-tick-br { bottom: 12px; right: 12px; }

.np-tick-tl::before, .np-tick-tl::after { top: 0; left: 0; }
.np-tick-tr::before, .np-tick-tr::after { top: 0; right: 0; }
.np-tick-bl::before, .np-tick-bl::after { bottom: 0; left: 0; }
.np-tick-br::before, .np-tick-br::after { bottom: 0; right: 0; }

/* ================================
 * 6. 不對稱雙欄主體
 * ================================ */
.np-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
  padding-bottom: clamp(1.5rem, 4vw, 2.25rem);
  margin-bottom: clamp(1.5rem, 4vw, 2.25rem);
  border-bottom: 1px solid var(--color-border-subtle);
}

/* 左欄：姓名銘牌（視覺重心） */
.np-identity {
  position: relative;
  z-index: 1;
}

.np-mark {
  font-family: var(--font-body);
  font-size: var(--text-mark);
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin: 0 0 var(--space-md);
}

.np-name {
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: 0.01em;
  color: var(--color-ink);
  margin: 0 0 var(--space-md);
  text-wrap: balance;
  /* 銑刻效果：頂部高光、底部微暗，像刻入金屬 */
  text-shadow:
    0 1px 0 oklch(100% 0 0 / 0.65),
    0 -1px 0 oklch(0% 0 0 / 0.04);
}

.np-role {
  font-family: var(--font-body);
  font-size: var(--text-role);
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--color-ink-muted);
  margin: 0;
  line-height: 1.5;
}

.np-role span {
  color: var(--color-ink);
}

/* ================================
 * 7. 右欄：聯絡規格表（工單感）
 * ================================ */
.np-spec {
  position: relative;
  z-index: 1;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.np-spec-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: spec;
}

.np-spec-row {
  display: grid;
  grid-template-columns: 22px 40px minmax(0, 1fr);
  align-items: baseline;
  column-gap: var(--space-sm);
  row-gap: 0;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.np-spec-row:last-child {
  border-bottom: none;
}

.np-spec-row:first-child {
  padding-top: 0;
}

.np-spec-no {
  font-family: var(--font-body);
  font-size: var(--text-spec-no);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.np-spec-key {
  font-family: var(--font-body);
  font-size: var(--text-spec-key);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-ink-subtle);
}

.np-spec-val {
  font-family: var(--font-body);
  font-size: var(--text-spec-val);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--color-ink);
  text-decoration: none;
  word-break: break-all;
  overflow-wrap: anywhere;
  min-width: 0;
  text-align: right;
  transition: color var(--duration-fast) var(--ease-out-quart);
  font-variant-numeric: tabular-nums;
}

a.np-spec-val:hover {
  color: var(--color-primary);
}

a.np-spec-val:focus-visible {
  outline: 2px solid var(--color-primary-soft);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ================================
 * 8. 服務項目：横向規格帶
 * ================================ */
.np-services {
  position: relative;
  z-index: 1;
  margin-bottom: clamp(1.5rem, 4vw, 2.25rem);
}

.np-services-mark {
  font-family: var(--font-body);
  font-size: var(--text-mark);
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin: 0 0 var(--space-md);
}

.np-services-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  margin: 0;
  padding: 0;
  list-style: none;
}

.np-service-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-ink-muted);
  letter-spacing: 0.02em;
}

.np-service-item::before {
  content: "";
  width: 8px;
  height: 1px;
  background-color: var(--color-primary);
  flex-shrink: 0;
}

/* ================================
 * 9. 行動區
 * ================================ */
.np-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.8125rem 1.75rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out-quart),
    color var(--duration-fast) var(--ease-out-quart),
    transform var(--duration-fast) var(--ease-out-quart),
    border-color var(--duration-fast) var(--ease-out-quart),
    box-shadow var(--duration-fast) var(--ease-out-quart);
}

.btn-primary {
  background-color: var(--color-primary);
  color: oklch(99% 0 0);
  box-shadow: 0 8px 20px -10px oklch(40% 0.07 250 / 0.6);
}

.btn-primary:hover {
  background-color: var(--color-primary-soft);
  transform: translateY(-1px);
  box-shadow: 0 12px 26px -10px oklch(40% 0.07 250 / 0.7);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--color-primary-soft);
  outline-offset: 3px;
}

.btn-primary:active {
  transform: translateY(0);
  background-color: var(--color-primary-deep);
}

.btn-ghost {
  background-color: transparent;
  color: var(--color-ink-muted);
  border: 1px solid var(--color-border-subtle);
}

.btn-ghost:hover {
  color: var(--color-primary);
  border-color: var(--color-primary-soft);
}

.btn-ghost:focus-visible {
  outline: 2px solid var(--color-primary-soft);
  outline-offset: 3px;
}

/* ================================
 * 10. 空值狀態
 * ================================ */
.empty-value {
  color: var(--color-ink-subtle);
  font-style: italic;
}

/* ================================
 * 11. 響應式：手機堆疊
 * ================================ */
@media (max-width: 620px) {
  body {
    padding: var(--space-md) var(--space-sm);
    justify-content: flex-start;
  }

  .nameplate {
    padding: clamp(1.25rem, 6vw, 1.75rem);
  }

  .np-grid {
    grid-template-columns: 1fr;
    gap: clamp(1.5rem, 6vw, 2rem);
  }

  /* 手機上姓名仍是最大視覺，但收斂一階 */
  .np-name {
    line-height: 1;
  }

  /* 規格表在手機上：編號縮窄、key/value 仍對齊 */
  .np-spec-row {
    grid-template-columns: 20px 36px minmax(0, 1fr);
    column-gap: var(--space-xs);
  }

  .np-spec-val {
    text-align: right;
  }

  .np-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }

  /* 手機上角標更靠邊 */
  .np-tick { width: 11px; height: 11px; }
  .np-tick::before { width: 11px; }
  .np-tick::after { height: 11px; }
  .np-tick-tl, .np-tick-tr { top: 9px; }
  .np-tick-bl, .np-tick-br { bottom: 9px; }
  .np-tick-tl, .np-tick-bl { left: 9px; }
  .np-tick-tr, .np-tick-br { right: 9px; }
}

/* ================================
 * 12. 減少動畫偏好
 * ================================ */
@media (prefers-reduced-motion: reduce) {
  .nameplate,
  .nameplate .np-identity,
  .nameplate .np-spec,
  .nameplate .np-services,
  .nameplate .np-actions,
  .btn,
  .np-service-item,
  a.np-spec-val {
    transition: none;
  }

  .nameplate,
  .nameplate .np-identity,
  .nameplate .np-spec,
  .nameplate .np-services,
  .nameplate .np-actions {
    opacity: 1;
    transform: none;
  }
}
