/* ============================================================
   恆信律師行 (Heng Xin Law Firm) - Shared Styles
   Design System: Deep Navy + Gold, Outfit + Noto Sans TC
   Dials: VARIANCE=6, MOTION=4, DENSITY=3
   ============================================================ */

/* --- CSS Variables (Light & Dark) --- */
:root {
  /* Core palette */
  --color-accent: #b8943c;
  --color-accent-hover: #a07e2e;
  --color-accent-light: rgba(184, 148, 60, 0.12);
  --color-accent-glow: rgba(184, 148, 60, 0.25);

  /* Surfaces */
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-elevated: #f1f5f9;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;

  /* Text */
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;

  /* Specifics */
  --color-nav-bg: rgba(255, 255, 255, 0.92);
  --color-footer-bg: #0f172a;
  --color-footer-text: #cbd5e1;
  --color-card-hover-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);

  /* Shape */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  /* Animation */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast: 200ms var(--ease-out-expo);
  --transition-base: 350ms var(--ease-out-expo);
  --transition-slow: 500ms var(--ease-out-expo);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-surface-elevated: #273548;
    --color-border: #334155;
    --color-border-light: #1e293b;

    --color-text: #f1f5f9;
    --color-text-secondary: #94a3b8;
    --color-text-muted: #64748b;

    --color-nav-bg: rgba(15, 23, 42, 0.92);
    --color-card-hover-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    --color-accent-light: rgba(184, 148, 60, 0.15);
  }
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  font-family: 'Noto Sans TC', 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  overflow-x: hidden;
  /* Page fade-in */
  animation: bodyFadeIn 0.5s var(--ease-out-expo) both;
}

@keyframes bodyFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Typography --- */
h1, h2, h3, h4, .display-font {
  font-family: 'Outfit', 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

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

.eyebrow {
  font-family: 'Outfit', sans-serif;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 0.75rem;
  /* Eyebrow fade-in */
  animation: eyebrowFade 0.6s var(--ease-out-expo) both;
}

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

/* --- Noise Texture Overlay --- */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.03;
  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)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}
@media (prefers-color-scheme: dark) {
  .noise-overlay { opacity: 0.05; }
}
@media (prefers-reduced-motion: reduce) {
  .noise-overlay { display: none; }
}

/* --- Navbar --- */
.navbar {
  background: var(--color-nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
  min-height: 68px;
  transition: background var(--transition-base), border-color var(--transition-base);
}
.navbar .nav-link {
  font-family: 'Outfit', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 0.5rem 1rem !important;
  transition: color var(--transition-fast);
  position: relative;
}
.navbar .nav-link:hover,
.navbar .nav-link.active {
  color: var(--color-accent);
}
.navbar .nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--color-accent);
  transition: width var(--transition-fast), left var(--transition-fast);
}
.navbar .nav-link:hover::after,
.navbar .nav-link.active::after {
  width: 60%;
  left: 20%;
}
.navbar-brand {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-text) !important;
  letter-spacing: -0.01em;
}
.navbar-brand .brand-accent {
  color: var(--color-accent);
}
.navbar-toggler {
  border: none;
  padding: 0.25rem;
}
.navbar-toggler:focus {
  box-shadow: 0 0 0 2px var(--color-accent-light);
}

/* --- Buttons --- */
.btn {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: var(--radius-pill);
  padding: 0.75rem 1.75rem;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #0f172a;
}
.btn-primary:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: #0f172a;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--color-accent-glow);
}
.btn-outline-primary {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: transparent;
}
.btn-outline-primary:hover {
  background: var(--color-accent);
  color: #0f172a;
  transform: translateY(-1px);
}
/* Dark mode button contrast fix */
@media (prefers-color-scheme: dark) {
  .btn-outline-primary { color: var(--color-accent); }
  .btn-primary { color: #0f172a; }
}

/* --- Section Reveal Animations --- */
.section-reveal {
  animation: sectionReveal 0.7s var(--ease-out-expo) both;
  animation-timeline: view();
  animation-range: entry 0% entry 100%;
}

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

/* Section heading slide-up */
.section-heading {
  animation: headingSlideUp 0.8s var(--ease-out-expo) both;
  animation-timeline: view();
  animation-range: entry 10% entry 90%;
}

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

/* --- Card Hover --- */
.card-hover {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  overflow: hidden;
}
.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--color-card-hover-shadow);
  border-color: var(--color-accent);
}

/* Gradient border pulse */
.card-gradient-border {
  position: relative;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
}
.card-gradient-border::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, var(--color-accent), transparent 60%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  transition: opacity var(--transition-base);
  opacity: 0;
}
.card-gradient-border:hover::before {
  opacity: 1;
  animation: borderShimmer 2s linear infinite;
}

@keyframes borderShimmer {
  0% { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

/* --- Grid Item Stagger --- */
.stagger-grid > * {
  animation: staggerReveal 0.6s var(--ease-out-expo) both;
  animation-timeline: view();
  animation-range: entry 5% entry 85%;
}
.stagger-grid > *:nth-child(1) { animation-delay: 0ms; }
.stagger-grid > *:nth-child(2) { animation-delay: 80ms; }
.stagger-grid > *:nth-child(3) { animation-delay: 160ms; }
.stagger-grid > *:nth-child(4) { animation-delay: 240ms; }
.stagger-grid > *:nth-child(5) { animation-delay: 320ms; }
.stagger-grid > *:nth-child(6) { animation-delay: 400ms; }

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

/* --- Hero Typography Stagger --- */
.hero-stagger > * {
  animation: heroReveal 0.7s var(--ease-out-expo) both;
}
.hero-stagger > *:nth-child(1) { animation-delay: 0ms; }
.hero-stagger > *:nth-child(2) { animation-delay: 100ms; }
.hero-stagger > *:nth-child(3) { animation-delay: 200ms; }
.hero-stagger > *:nth-child(4) { animation-delay: 300ms; }

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

/* --- Bento Image Hover --- */
.bento-img {
  transition: transform 0.5s var(--ease-out-expo);
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.bento-img:hover {
  transform: scale(1.03);
}

/* --- Logo Carousel --- */
.logo-carousel {
  overflow: hidden;
  position: relative;
}
.logo-track {
  display: flex;
  width: max-content;
  animation: logoScroll 30s linear infinite;
}
.logo-track:hover {
  animation-play-state: paused;
}
.logo-track > * {
  flex-shrink: 0;
  padding: 0 2rem;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}
.logo-track > *:hover {
  opacity: 1;
}

@keyframes logoScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* --- Mesh Gradient Background --- */
.mesh-gradient {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.mesh-gradient::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  background: var(--color-accent);
  top: -200px;
  right: -100px;
  animation: meshFloat 20s ease-in-out infinite;
}
.mesh-gradient::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.1;
  background: #3b82f6;
  bottom: -150px;
  left: -80px;
  animation: meshFloat 25s ease-in-out infinite reverse;
}

@keyframes meshFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* --- Section Spacing (DENSITY=3: art gallery) --- */
.section-py {
  padding-top: 6rem;
  padding-bottom: 6rem;
}
@media (min-width: 768px) {
  .section-py {
    padding-top: 8rem;
    padding-bottom: 8rem;
  }
}

/* --- Footer --- */
.footer {
  background: var(--color-footer-bg);
  color: var(--color-footer-text);
  padding-top: 4rem;
  padding-bottom: 2rem;
}
.footer a {
  color: var(--color-footer-text);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.footer a:hover {
  color: var(--color-accent);
}
.footer .footer-heading {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 1.25rem;
}

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

/* --- Blog Card --- */
.blog-card .blog-img {
  aspect-ratio: 16/10;
  object-fit: cover;
  transition: transform 0.5s var(--ease-out-expo);
}
.blog-card:hover .blog-img {
  transform: scale(1.04);
}
.blog-card .blog-category {
  font-family: 'Outfit', sans-serif;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent);
}
.blog-card .blog-date {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* --- Profile Card --- */
.profile-card .profile-img {
  aspect-ratio: 3/4;
  object-fit: cover;
  filter: grayscale(20%);
  transition: filter var(--transition-base), transform var(--transition-base);
}
.profile-card:hover .profile-img {
  filter: grayscale(0%);
  transform: scale(1.02);
}

/* --- Form Styles --- */
.form-control {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: 0.75rem 1rem;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 0.9375rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
  background: var(--color-surface);
}
.form-control::placeholder {
  color: var(--color-text-muted);
  opacity: 0.7;
}
.form-label {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

/* --- Pagination --- */
.pagination .page-link {
  font-family: 'Outfit', sans-serif;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  margin: 0 0.125rem;
  background: var(--color-surface);
  transition: all var(--transition-fast);
}
.pagination .page-link:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}
.pagination .active .page-link {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #0f172a;
}

/* --- Map Placeholder --- */
.map-placeholder {
  aspect-ratio: 4/3;
  background: var(--color-surface-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  .logo-track { animation: none; }
  body { animation: none; }
}

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

/* --- Split Hero Layout --- */
.split-hero {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
  align-items: center;
}
@media (min-width: 992px) {
  .split-hero {
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
  }
}
.split-hero .hero-image {
  aspect-ratio: 4/5;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.split-hero .hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease-out-expo);
}
.split-hero .hero-image:hover img {
  transform: scale(1.03);
}

/* --- Bento Grid --- */
.bento-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 768px) {
  .bento-grid {
    grid-template-columns: 1fr 1fr;
  }
  .bento-grid .bento-tall {
    grid-row: span 2;
  }
  .bento-grid .bento-wide {
    grid-column: span 2;
  }
}
.bento-cell {
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.bento-cell:hover {
  transform: translateY(-3px);
  box-shadow: var(--color-card-hover-shadow);
}

/* --- Service Icon --- */
.service-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--color-accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* --- Highlight stat --- */
.stat-number {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-accent);
  line-height: 1;
}

/* --- Divider --- */
.section-divider {
  border: none;
  height: 1px;
  background: var(--color-border);
  margin: 0;
}
