/* ========================================
   n9dev.com - 九峰智创 Custom Styles
   Phase 1: Foundation
   ======================================== */

:root {
  --brand-dark: #0a1628;
  --brand-darker: #0f172a;
  --brand-black: #000000;
  --brand-gray: #111111;
  --brand-ice: #00d4ff;
  --brand-sky: #38bdf8;
  --brand-ice-dim: rgba(0, 212, 255, 0.1);
  --header-height: 64px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background-color: var(--brand-dark);
  color: #e2e8f0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header */
.site-header {
  height: var(--header-height);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.site-header.scrolled {
  background-color: rgba(10, 22, 40, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* Logo */
.brand-logo {
  font-weight: 700;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #ffffff 0%, var(--brand-sky) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Navigation Links */
.nav-link {
  position: relative;
  transition: color 0.2s ease;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-ice), var(--brand-sky));
  transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

.nav-link:hover,
.nav-link.active {
  color: var(--brand-ice);
}

/* Dropdown Menus */
.dropdown-menu {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.group:hover .dropdown-menu,
.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  transition: background-color 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
}

.dropdown-item:hover {
  background-color: var(--brand-ice-dim);
  color: var(--brand-ice);
  padding-left: 1.25rem;
}

/* Mobile Menu */
.mobile-menu {
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
}

.mobile-menu.open {
  transform: translateX(0);
}

.mobile-overlay {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Floating Sidebar */
.floating-sidebar {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-btn {
  writing-mode: horizontal-tb;
  transition: all 0.3s ease;
  box-shadow: -2px 0 12px rgba(0, 212, 255, 0.15);
}

.sidebar-btn:hover {
  transform: translateX(-4px);
  box-shadow: -4px 0 20px rgba(0, 212, 255, 0.3);
}

/* Main Content Padding for Fixed Header */
main {
  padding-top: var(--header-height);
}

/* Footer */
.site-footer {
  border-top: 1px solid rgba(56, 189, 248, 0.1);
}

.footer-link {
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: var(--brand-ice);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--brand-ice), var(--brand-sky));
  transition: all 0.3s ease;
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
  transform: translateY(-1px);
}

.btn-outline {
  border: 1px solid var(--brand-ice);
  color: var(--brand-ice);
  transition: all 0.3s ease;
}

.btn-outline:hover {
  background-color: var(--brand-ice);
  color: var(--brand-dark);
}

/* Cards */
.card {
  background-color: var(--brand-darker);
  border: 1px solid rgba(56, 189, 248, 0.08);
  transition: all 0.3s ease;
}

.card:hover {
  border-color: rgba(56, 189, 248, 0.2);
  box-shadow: 0 8px 30px rgba(0, 212, 255, 0.08);
}

/* Utility */
.text-gradient {
  background: linear-gradient(135deg, var(--brand-ice), var(--brand-sky));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.bg-grid {
  background-image: linear-gradient(rgba(56, 189, 248, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* Responsive */
@media (max-width: 1023px) {
  :root {
    --header-height: 56px;
  }

  .floating-sidebar {
    top: auto;
    bottom: 1.5rem;
    right: 1rem;
    transform: none;
    flex-direction: row;
  }

  .sidebar-btn {
    writing-mode: horizontal-tb;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem !important;
  }

  /* Improve hero spacing on tablets */
  .min-h-\[90vh\] {
    min-height: auto;
  }
}

@media (max-width: 767px) {
  .floating-sidebar {
    bottom: 1rem;
    right: 0.75rem;
    gap: 0.375rem;
  }

  .sidebar-btn {
    padding: 0.625rem 0.875rem;
    font-size: 0.75rem;
  }

  /* Prevent horizontal overflow */
  body {
    overflow-x: hidden;
  }

  /* Ensure images and cards don't overflow */
  .card {
    word-break: break-word;
  }

  /* Fix dropdown menu width on touch */
  .dropdown-menu {
    position: fixed !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    width: auto !important;
  }
}

@media (max-width: 639px) {
  /* Ultra-small screens */
  .grid {
    gap: 0.75rem !important;
  }

  .sidebar-btn span {
    display: none !important;
  }
}

/* ========================================
   自适应宽度：主容器随分辨率调节，保留左右各2%留白
   ======================================== */
@media (min-width: 1280px) {
  .max-w-7xl,
  .max-w-6xl {
    width: 96% !important;
    max-width: none !important;
  }
}

/* ============================================================
   n9dev 微交互层 (追加于 2026-09-08) —— 青色主题 #00d4ff
   品牌色 ice #00d4ff / sky #38bdf8；统一 300ms ease-out；
   优先 transform/opacity/filter；hover 上浮仅 PC；尊重减弱动态
   ============================================================ */

/* ---------- 1. 卡片 hover：上浮 + 微放大 + 阴影加深（仅 PC） ---------- */
@media (hover: hover) and (pointer: fine) {
  .card:hover {
    transform: translateY(-4px) scale(1.012);
    border-color: rgba(56, 189, 248, 0.35);
    box-shadow: 0 16px 34px -14px rgba(0, 212, 255, 0.22);
  }
  .card:active {
    transform: translateY(-2px) scale(0.99);
  }
}

/* 图内卡片（image card，overflow hidden）hover 图片微放大 */
@media (hover: hover) and (pointer: fine) {
  .ui-media img {
    display: block;
    width: 100%;
    transition: transform 300ms ease-out, filter 300ms ease-out;
    will-change: transform;
  }
  .ui-media:hover img {
    transform: scale(1.04);
    filter: brightness(1.05) saturate(1.06);
  }
}

/* ---------- 2. 按钮：hover 变亮 + 按压收缩回弹 ---------- */
.btn-primary,
.btn-outline {
  transition: background-color 300ms ease-out, border-color 300ms ease-out,
    color 300ms ease-out, box-shadow 300ms ease-out, transform 300ms ease-out,
    filter 300ms ease-out;
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    filter: brightness(1.08);
    box-shadow: 0 6px 24px rgba(0, 212, 255, 0.35);
    transform: translateY(-1px);
  }
  .btn-outline:hover {
    filter: brightness(1.12);
  }
}
.btn-primary:active,
.btn-outline:active,
button:active {
  transform: translateY(1px) scale(0.97);
}
button {
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 3. 图标动效（仅 PC）：图标块/装饰图标微动 ---------- */
@media (hover: hover) and (pointer: fine) {
  .ui-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 300ms ease-out, background-color 300ms ease-out,
      color 300ms ease-out;
    will-change: transform;
  }
  .ui-icon:hover {
    transform: translateY(-2px) scale(1.08);
  }
}

/* ---------- 4. 数据统计卡高亮（仅 PC） ---------- */
@media (hover: hover) and (pointer: fine) {
  .ui-stat {
    transition: background-color 300ms ease-out, box-shadow 300ms ease-out,
      border-color 300ms ease-out;
  }
  .ui-stat:hover {
    background-color: rgba(0, 212, 255, 0.07);
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 10px 26px -14px rgba(0, 212, 255, 0.25);
  }
  .ui-stat:hover .ui-stat-value {
    color: #00d4ff;
    transform: scale(1.06);
  }
  .ui-stat-value {
    display: inline-block;
    transition: color 300ms ease-out, transform 300ms ease-out;
  }
}

/* ---------- 5. 表单交互 ---------- */
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):focus:not([class*="focus:ring"]),
select:focus:not([class*="focus:ring"]),
textarea:focus:not([class*="focus:ring"]) {
  border-color: #00d4ff;
  box-shadow:
    0 0 0 3px rgba(0, 212, 255, 0.16),
    0 0 14px rgba(0, 212, 255, 0.2);
}
input[type="checkbox"],
input[type="radio"] {
  accent-color: #00d4ff;
  transition: transform 300ms ease-out, opacity 300ms ease-out;
}
input[type="checkbox"]:active,
input[type="radio"]:active {
  transform: scale(0.92);
}
input[type="checkbox"]:checked,
input[type="radio"]:checked {
  transform: scale(1.06);
}
button:disabled,
input[type="submit"]:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* ---------- 6. 滚动入场（JS 打 .reveal，CSS 控制显隐） ---------- */
html.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 300ms ease-out, transform 300ms ease-out;
  will-change: opacity, transform;
}
html.js .reveal.reveal-in {
  opacity: 1;
  transform: translateY(0);
}
.reveal[data-delay="1"] { transition-delay: 60ms; }
.reveal[data-delay="2"] { transition-delay: 120ms; }
.reveal[data-delay="3"] { transition-delay: 180ms; }
.reveal[data-delay="4"] { transition-delay: 240ms; }
.reveal[data-delay="5"] { transition-delay: 300ms; }

/* ---------- 7. 状态切换过渡 ---------- */
.swap-fade {
  transition: opacity 300ms ease-out, transform 300ms ease-out;
}
.swap-fade.swap-out {
  opacity: 0;
  transform: translateY(4px);
}
.swap-fade.swap-in {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- 7b. 流程步骤卡（服务页技术流程 01-05 步骤） ---------- */
@media (hover: hover) and (pointer: fine) {
  .ui-step {
    transition: transform 300ms ease-out;
    will-change: transform;
  }
  .ui-step:hover {
    transform: translateY(-3px);
  }
  .ui-step:hover .rounded-full,
  .ui-step:hover .rounded-2xl {
    box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.15), 0 6px 18px rgba(0, 212, 255, 0.28);
    transform: scale(1.04);
  }
  .ui-step .rounded-full,
  .ui-step .rounded-2xl {
    transition: transform 300ms ease-out, box-shadow 300ms ease-out;
  }
  /* 行内清单小图标（w-5 交付物清单）hover 变亮 */
  .ui-icon {
    transition: transform 300ms ease-out, color 300ms ease-out, filter 300ms ease-out, background-color 300ms ease-out;
    will-change: transform;
  }
  /* svg 行内图标保持自身 display，不受容器 inline-flex 影响 */
  svg.ui-icon {
    display: inline-block;
  }
  .ui-icon:hover {
    transform: translateY(-2px) scale(1.1);
    filter: brightness(1.25);
  }
}

/* ---------- 8. 减弱动态 ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
  }
  html.js .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}
