/* ==============================================
   HENG KI ENGINEERING | Shared Styles
   Design Read: industrial engineering B2B, structural confidence
   Dials: VARIANCE=6, MOTION=4, DENSITY=4
   Stack: Bootstrap 5.3 + Outfit + Noto Sans TC
   Palette: Charcoal + Orange + Steel (NO beige/cream)
   ============================================== */

/* --- CSS Custom Properties (Dark Mode Default) --- */
:root {
  --bg-primary: #0a0f14;
  --bg-surface: #12171d;
  --bg-elevated: #181d24;
  --bg-muted: #1c2229;
  --accent: #e8613c;
  --accent-hover: #f0734f;
  --accent-muted: rgba(232, 97, 60, 0.12);
  --steel: #7c8a9a;
  --steel-light: #9aa8b5;
  --text-primary: #e6edf3;
  --text-secondary: #a3b3c2;
  --text-muted: #6b7887;
  --border-default: rgba(124, 138, 154, 0.18);
  --border-strong: rgba(124, 138, 154, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-heading: 'Outfit', 'Noto Sans TC', sans-serif;
  --font-body: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Global Reset & Typography --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Noise overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

@media (prefers-reduced-motion: reduce) {
  body::after { opacity: 0.02; }
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2.5rem, 5vw, 4.5rem); }
h2 { font-size: clamp(2rem, 4vw, 3.5rem); }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.75rem); }
h4 { font-size: 1.125rem; }

p { color: var(--text-secondary); max-width: 65ch; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-smooth);
}
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; display: block; }

/* --- Mesh Gradient Decorative Background --- */
.mesh-gradient {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.07;
  background:
    radial-gradient(ellipse 80% 60% at 20% 30%, rgba(232, 97, 60, 0.4), transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 70%, rgba(124, 138, 154, 0.25), transparent 50%),
    radial-gradient(ellipse 40% 40% at 50% 20%, rgba(232, 97, 60, 0.15), transparent 50%);
}

/* --- Container Override --- */
.container-custom {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* --- Buttons --- */
.btn-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.75rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9375rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), background var(--transition-smooth);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn-brand:hover {
  transform: scale(0.97);
}

.btn-brand:active {
  transform: scale(0.95);
}

.btn-primary-brand {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(232, 97, 60, 0.3);
}
.btn-primary-brand:hover {
  background: var(--accent-hover);
  color: #fff;
  box-shadow: 0 4px 16px rgba(232, 97, 60, 0.4);
}

.btn-outline-brand {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border-strong);
}
.btn-outline-brand:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-muted);
}

/* --- Cards --- */
.card-brand {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
}

.card-brand:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-brand-interactive {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-smooth);
}
.card-brand-interactive:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

/* --- Section Spacing --- */
.section-padding {
  padding: 5rem 0;
}

.section-padding-lg {
  padding: 7rem 0;
}

/* --- Section Headers --- */
.section-header {
  margin-bottom: 3.5rem;
}

.section-header h2 {
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.section-header p {
  font-size: 1.1rem;
  color: var(--text-muted);
}

/* --- Eyebrow (used sparingly per tasteskill rules) --- */
.eyebrow {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

/* --- Badge / Tag --- */
.tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-muted);
  border-radius: 999px;
  font-family: var(--font-heading);
}

/* --- Divider --- */
.divider {
  width: 100%;
  height: 1px;
  background: var(--border-default);
  margin: 4rem 0;
}

/* --- Navigation --- */
.nav-brand {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(10, 15, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-default);
  height: 68px;
}

.nav-brand .nav-link {
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color var(--transition-smooth);
  padding: 0.5rem 1rem;
}
.nav-brand .nav-link:hover,
.nav-brand .nav-link.active {
  color: var(--text-primary);
}

.nav-brand .navbar-brand {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}

/* --- Footer --- */
.footer-brand {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-default);
  padding: 4rem 0 2rem;
}

.footer-brand h5 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  font-size: 0.9375rem;
  margin-bottom: 1rem;
}

.footer-brand a {
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: color var(--transition-smooth);
}
.footer-brand a:hover {
  color: var(--accent);
}

.footer-brand .footer-bottom {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-default);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* --- Image placeholders --- */
.img-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-gallery {
  border-radius: var(--radius-md);
  transition: transform var(--transition-smooth);
  cursor: pointer;
}
.img-gallery:hover {
  transform: scale(1.03);
}

/* --- Partner Logo Carousel --- */
.partner-track {
  display: flex;
  gap: 3rem;
  animation: scroll-partners 25s linear infinite;
  width: max-content;
}

@keyframes scroll-partners {
  to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .partner-track { animation: none; }
}

.partner-logo {
  flex-shrink: 0;
  height: 2.5rem;
  opacity: 0.5;
  filter: grayscale(1) brightness(2);
  transition: opacity var(--transition-smooth), filter var(--transition-smooth);
}
.partner-logo:hover {
  opacity: 0.8;
  filter: grayscale(0.5) brightness(2);
}

/* --- Form Styles --- */
.form-brand .form-control {
  background: var(--bg-muted);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}
.form-brand .form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
  background: var(--bg-elevated);
}
.form-brand .form-control::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}
.form-brand .form-label {
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* --- Pagination --- */
.pagination-brand .page-link {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-smooth);
}
.pagination-brand .page-link:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.pagination-brand .page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* --- Timeline --- */
.timeline {
  position: relative;
  padding-left: 2rem;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-default);
}
.timeline-item {
  position: relative;
  padding-bottom: 2.5rem;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -2rem;
  top: 0.35rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-primary);
  transform: translateX(-5px);
}

/* --- Map Placeholder --- */
.map-placeholder {
  width: 100%;
  height: 100%;
  min-height: 400px;
  background: var(--bg-muted);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.map-placeholder iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: var(--radius-lg);
}

/* --- Service Detail Varied Layouts --- */
.service-block {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.service-block-alt {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
}

.service-block-dark {
  background: var(--bg-elevated);
}

/* ==============================================
   ANIMATIONS
   ============================================== */

/* Page fade in */
@keyframes pageFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page-fade-in {
  animation: pageFadeIn 0.5s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .page-fade-in { animation: none; }
}

/* Hero stagger | each word appears in sequence */
.hero-word {
  display: inline-block;
  opacity: 0;
  animation: heroWordIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes heroWordIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-word {
    opacity: 1;
    animation: none;
  }
}

/* Section slide-up | scroll-driven via CSS view-timeline */
@keyframes sectionSlideUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-on-scroll {
  animation: sectionSlideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-timeline: view();
  animation-range: entry 0% entry 100%;
}

/* Staggered children within a scroll-revealed container */
.animate-stagger > * {
  opacity: 0;
  animation: sectionSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-timeline: view();
  animation-range: entry 5% entry 75%;
}

.animate-stagger > *:nth-child(1) { animation-delay: 0s; }
.animate-stagger > *:nth-child(2) { animation-delay: 0.05s; }
.animate-stagger > *:nth-child(3) { animation-delay: 0.1s; }
.animate-stagger > *:nth-child(4) { animation-delay: 0.15s; }
.animate-stagger > *:nth-child(5) { animation-delay: 0.2s; }
.animate-stagger > *:nth-child(6) { animation-delay: 0.25s; }

/* Fallback for browsers without scroll-driven animation support */
@supports not (animation-timeline: view()) {
  .animate-on-scroll {
    opacity: 1;
    animation: none;
  }
  .animate-stagger > * {
    opacity: 1;
    animation: none;
  }
}

/* Reduced motion: disable all */
@media (prefers-reduced-motion: reduce) {
  .animate-on-scroll,
  .animate-stagger > * {
    animation: none;
    opacity: 1;
  }
}

/* Decorative pulse for accent elements */
@keyframes accentPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 97, 60, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(232, 97, 60, 0); }
}

/* Gallery zoom on hover | applies to .img-gallery above */

/* Blog card image zoom */
.blog-card-img {
  overflow: hidden;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.blog-card-img img {
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.card-brand:hover .blog-card-img img {
  transform: scale(1.03);
}

/* Service stat number animation */
.stat-number {
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

/* Profile card hover */
.profile-card {
  transition: transform var(--transition-smooth);
}
.profile-card:hover {
  transform: translateY(-6px);
}

/* Contact info icon row */
.contact-icon-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.contact-icon-row .icon-box {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-muted);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}
