/*
Theme Name: 陽億羊科技
Theme URI: https://szyyy.com.cn
Author: 小羊（CEO）/ 小繪（美工）
Author URI: https://szyyy.com.cn
Description: 陽億羊科技官方網站主題（基於 zip 交付包視覺，復刻 Tailwind sky-blue 風格）
Version: 1.0.7
Requires at least: 6.5
Tested up to: 7.0
Requires PHP: 8.0
License: Proprietary
Text Domain: yangyiyang
Tags: business, custom-colors, custom-menu, featured-images, threaded-comments, translation-ready
*/

/* === Brand Tokens === */
:root {
  --yy-sky:        #0EA5E9;
  --yy-sky-dark:   #0284C7;
  --yy-sky-light:  #E0F2FE;
  --yy-black:      #0F172A;
  --yy-gray:       #64748B;
  --yy-gray-mid:   #94A3B8;
  --yy-gray-light: #F1F5F9;
  --yy-white:      #FFFFFF;
  --yy-radius:     12px;
  --yy-radius-sm:  6px;
  --yy-shadow:     0 10px 30px -10px rgba(14,165,233,0.2);
}

/* === Base === */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang TC", "PingFang SC", "Microsoft JhengHei",
               "Noto Sans TC", "Noto Sans SC", sans-serif;
  color: var(--yy-black);
  line-height: 1.65;
  background: var(--yy-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* 2026-08-03：鎖水平溢出 — 防 marquee max-content 撐破 viewport 導致 iOS Safari 卡垂直滾動 */
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--yy-sky-dark); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--yy-sky); }
h1,h2,h3,h4 { color: var(--yy-black); line-height: 1.25; margin: 0 0 1rem; }
p { margin: 0 0 1rem; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }

/* === Header === */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--yy-gray-light);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 0.875rem; padding-bottom: 0.875rem;
  gap: 1.5rem;
}
.site-logo-link,
.custom-logo-link {
  display: inline-flex;
  align-items: center;
  width: 220px !important;        /* ★ 鎖死 link 容器（避免 flex 擠壓） */
  height: 40px !important;        /* 鎖死 link 容器高度 */
  flex-shrink: 0 !important;      /* 避免在 flex parent 被 shrink */
  -webkit-tap-highlight-color: transparent;
  outline: none;
  text-decoration: none;
  touch-action: manipulation;
}
.site-logo-link:focus-visible,
.custom-logo-link:focus-visible {
  outline: 2px solid var(--yy-sky);
  outline-offset: 4px;
  border-radius: 6px;
}

.site-logo,
.custom-logo {
  width: 220px !important;        /* ★ 固定寬度（1132/203×40 = 223 → 220） */
  height: 40px !important;
  flex-shrink: 0 !important;
  max-width: 220px !important;
  min-width: 120px !important;
  object-fit: contain;             /* 圖內容 contain 進 220×40 框，保留比例 */
  display: block;
  transition: none !important;
  transform: none !important;
  filter: none !important;
  -webkit-user-drag: none;
  user-select: none;
}

/* 鎖定所有互動狀態（任何瀏覽器偽類都擋） */
.site-logo-link,
.custom-logo-link,
.site-logo-link:active,
.site-logo-link:focus,
.site-logo-link:focus-visible,
.site-logo-link:hover,
.site-logo-link:visited,
.custom-logo-link:active,
.custom-logo-link:focus,
.custom-logo-link:focus-visible,
.custom-logo-link:hover,
.custom-logo-link:visited {
  width: 220px !important;
  height: 40px !important;
  flex-shrink: 0 !important;
  max-width: 220px !important;
  min-width: 120px !important;
  transform: none !important;
  opacity: 1 !important;
  filter: none !important;
  margin: 0 !important;
  padding: 0 !important;
  font-size: inherit !important;
  line-height: inherit !important;
  vertical-align: middle !important;
}
.site-logo-link:active .site-logo,
.site-logo-link:focus .site-logo,
.site-logo-link:focus-visible .site-logo,
.site-logo-link:hover .site-logo,
.custom-logo-link:active .custom-logo,
.custom-logo-link:focus .custom-logo,
.custom-logo-link:focus-visible .custom-logo,
.custom-logo-link:hover .custom-logo {
  width: 220px !important;
  height: 40px !important;
  flex-shrink: 0 !important;
  max-width: 220px !important;
  min-width: 120px !important;
  transform: none !important !important;
  opacity: 1 !important;
  filter: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
.site-nav { display: flex; gap: 1.75rem; }
.site-nav a {
  color: var(--yy-black); font-weight: 500; font-size: 0.95rem;
  padding: 0.5rem 0;
}
.site-nav a:hover { color: var(--yy-sky); }
.lang-switcher { display: flex; gap: 0.25rem; }
.lang-switcher a {
  padding: 0.3rem 0.6rem; border-radius: var(--yy-radius-sm);
  font-size: 0.8rem; font-weight: 600;
  color: var(--yy-gray);
  border: 1px solid transparent;
}
.lang-switcher a:hover { color: var(--yy-sky); border-color: var(--yy-sky-light); }
.lang-switcher .current {
  background: var(--yy-sky-light); color: var(--yy-sky-dark);
  border-color: var(--yy-sky);
}

/* === Hero === */
.hero {
  padding: 6rem 0 5rem;
  text-align: center;
  background: linear-gradient(180deg, var(--yy-sky-light) 0%, var(--yy-white) 100%);
}
.hero h1 {
  font-size: clamp(1.875rem, 4.5vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
}
.hero .subtitle {
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  color: var(--yy-gray);
  margin: 0 auto 2.5rem;
  max-width: 720px;
}
.cta-group { display: flex; gap: 0.875rem; justify-content: center; flex-wrap: wrap; }

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 0.875rem 1.875rem;
  border-radius: var(--yy-radius-sm);
  font-weight: 600;
  font-size: 1rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  text-align: center;
}
.btn-primary { background: var(--yy-sky); color: var(--yy-white); }
.btn-primary:hover { background: var(--yy-sky-dark); color: var(--yy-white); transform: translateY(-1px); }
.btn-secondary {
  background: transparent; color: var(--yy-black);
  border-color: var(--yy-black);
}
.btn-secondary:hover { background: var(--yy-black); color: var(--yy-white); }

/* === Sections === */
section.yy-section { padding: 5rem 0; }
section.yy-section.alt { background: var(--yy-gray-light); }
.section-title {
  text-align: center;
  font-size: clamp(1.625rem, 3vw, 2.25rem);
  font-weight: 700;
  margin: 0 0 0.75rem;
}
.section-subtitle {
  text-align: center;
  color: var(--yy-gray);
  margin: 0 auto 3rem;
  max-width: 640px;
  font-size: 1.05rem;
}

/* === Card Grid === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}
.card {
  padding: 1.875rem;
  border-radius: var(--yy-radius);
  background: var(--yy-white);
  border: 1px solid var(--yy-gray-light);
  transition: all 0.2s ease;
}
.card:hover {
  border-color: var(--yy-sky);
  box-shadow: var(--yy-shadow);
  transform: translateY(-2px);
}
.card h3 {
  margin: 0 0 0.625rem;
  font-size: 1.2rem;
  font-weight: 700;
}
.card p {
  margin: 0;
  color: var(--yy-gray);
  font-size: 0.95rem;
}

/* === Consultation Dual Track === */
.dual-track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  max-width: 980px;
  margin: 0 auto;
}
.track {
  padding: 2.25rem;
  border-radius: var(--yy-radius);
  text-align: center;
}
.track-ai {
  background: var(--yy-sky-light);
  border: 1px solid var(--yy-sky);
}
.track-human {
  background: var(--yy-white);
  border: 1px solid var(--yy-gray-light);
}
.track h3 { margin: 0 0 0.625rem; font-size: 1.4rem; }
.track > p { color: var(--yy-gray); margin: 0 0 1.5rem; }

/* === Form === */
.yy-form { text-align: left; }
.form-field { margin-bottom: 0.875rem; }
.form-field label {
  display: block; margin-bottom: 0.4rem; font-weight: 500;
  font-size: 0.9rem;
}
.form-field label .req { color: #DC2626; }
.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--yy-gray-light);
  border-radius: var(--yy-radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--yy-white);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--yy-sky);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.12);
}
.form-field textarea { resize: vertical; min-height: 80px; }
.form-status {
  margin-top: 0.75rem; padding: 0.625rem 0.875rem;
  border-radius: var(--yy-radius-sm);
  font-size: 0.9rem;
  display: none;
}
.form-status.success { display: block; background: #DCFCE7; color: #166534; }
.form-status.error   { display: block; background: #FEE2E2; color: #991B1B; }

/* === Footer === */
.site-footer {
  padding: 2.5rem 0;
  background: var(--yy-black);
  color: var(--yy-gray-mid);
  text-align: center;
  font-size: 0.9rem;
}
.site-footer p { margin: 0; }

/* === Chat Widget === */
.yy-chat-fab {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--yy-sky); color: var(--yy-white);
  border: none; cursor: pointer;
  box-shadow: 0 8px 24px rgba(14,165,233,0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; z-index: 60;
  transition: all 0.2s;
}
.yy-chat-fab:hover { background: var(--yy-sky-dark); transform: scale(1.05); }
.yy-chat-panel {
  position: fixed; bottom: 5.5rem; right: 1.5rem;
  width: 360px; max-width: calc(100vw - 3rem);
  height: 520px; max-height: calc(100vh - 7rem);
  background: var(--yy-white);
  border-radius: var(--yy-radius);
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.3);
  z-index: 60;
  display: none; flex-direction: column;
  overflow: hidden;
}
.yy-chat-panel.open { display: flex; }
.yy-chat-header {
  padding: 1rem 1.25rem;
  background: var(--yy-sky);
  color: var(--yy-white);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600;
}
.yy-chat-header .close {
  background: none; border: none; color: var(--yy-white);
  font-size: 1.25rem; cursor: pointer; opacity: 0.85;
}
.yy-chat-header .close:hover { opacity: 1; }
.yy-chat-body {
  flex: 1; overflow-y: auto; padding: 1rem;
  background: var(--yy-gray-light);
  display: flex; flex-direction: column; gap: 0.5rem;
}
.yy-msg {
  max-width: 80%;
  padding: 0.5rem 0.75rem;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.5;
}
.yy-msg.bot {
  align-self: flex-start;
  background: var(--yy-white);
  color: var(--yy-black);
  border-bottom-left-radius: 4px;
}
.yy-msg.user {
  align-self: flex-end;
  background: var(--yy-sky);
  color: var(--yy-white);
  border-bottom-right-radius: 4px;
}
.yy-msg.typing {
  align-self: flex-start;
  background: var(--yy-white);
  color: var(--yy-gray);
  font-style: italic;
}
.yy-chat-input {
  display: flex; padding: 0.625rem;
  border-top: 1px solid var(--yy-gray-light);
  background: var(--yy-white);
}
.yy-chat-input input {
  flex: 1; border: 1px solid var(--yy-gray-light);
  border-radius: 18px; padding: 0.5rem 0.875rem;
  font-size: 0.92rem; outline: none;
}
.yy-chat-input input:focus { border-color: var(--yy-sky); }
.yy-chat-input button {
  margin-left: 0.5rem; background: var(--yy-sky); color: var(--yy-white);
  border: none; border-radius: 18px; padding: 0.5rem 1rem;
  cursor: pointer; font-weight: 600; font-size: 0.9rem;
}
.yy-chat-input button:hover { background: var(--yy-sky-dark); }
.yy-chat-input button:disabled { background: var(--yy-gray-mid); cursor: not-allowed; }

/* === Responsive === */
@media (max-width: 768px) {
  .site-header .container { flex-wrap: wrap; }
  .site-nav { width: 100%; justify-content: center; order: 3; }
  section.yy-section { padding: 3.5rem 0; }
  .hero { padding: 4rem 0 3rem; }
  .yy-chat-panel { right: 1rem; left: 1rem; width: auto; }

  /* 手機 logo 略放大（保留可識別度，避免在窄螢幕被 nav 擠壓到變小） */
  .site-logo,
  .custom-logo {
    height: 44px;
    min-width: 140px;
    max-width: 240px;
  }
  .site-logo-link:active .site-logo,
  .site-logo-link:focus .site-logo,
  .site-logo-link:hover .site-logo,
  .custom-logo-link:active .custom-logo,
  .custom-logo-link:focus .custom-logo,
  .custom-logo-link:hover .custom-logo {
    height: 44px !important;
    min-width: 140px !important;
    max-width: 240px !important;
  }
}

/* === Chat Prefill Modal === */
.yy-prefill-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.yy-prefill-modal[hidden] { display: none; }
.yy-prefill-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.yy-prefill-card {
  position: relative;
  background: var(--yy-white);
  border-radius: var(--yy-radius);
  padding: 2rem;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.3);
}
.yy-prefill-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--yy-black);
}
.yy-prefill-desc {
  margin: 0 0 1.5rem;
  color: var(--yy-gray);
  font-size: 0.92rem;
  line-height: 1.5;
}
.yy-prefill-status {
  margin: 0.5rem 0;
  font-size: 0.88rem;
  display: none;
}
.yy-prefill-status.error {
  display: block;
  color: #991B1B;
  background: #FEE2E2;
  padding: 0.5rem 0.75rem;
  border-radius: var(--yy-radius-sm);
}
.yy-prefill-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

@media (max-width: 480px) {
  .yy-prefill-card { padding: 1.5rem; }
}

/* === Accessibility === */
:focus-visible { outline: 2px solid var(--yy-sky); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
/* === P4 compliance-deploy 2026-07-26 === */
.yy-compliance-banner {
  background: #FFF8E1;
  border-top: 1px solid #F0C36D;
  border-bottom: 1px solid #F0C36D;
  padding: 0.75rem 0;
  font-size: 0.9375rem;
  color: #5C4400;
}
.yy-compliance-banner p { margin: 0; line-height: 1.5; }
.cases-paragraph {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: var(--yy-radius-sm, 8px);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: #1f2937;
}
.cases-paragraph p { margin: 0; }

/* === Plans Section（2026-08-02 新增） === */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  max-width: 980px;
  margin: 0 auto;
}
.plan-card {
  padding: 2.25rem;
  border-radius: var(--yy-radius);
  text-align: center;
  background: var(--yy-white);
  border: 1px solid var(--yy-gray-light);
  display: flex;
  flex-direction: column;
}
/* 2026-08-02 22:55：兩欄統一無底色，移除月租藍色覆蓋（原 --yy-sky-light + --yy-sky 邊框） */
.plan-card-onetime {
  background: var(--yy-white);
  border: 1px solid var(--yy-gray-light);
}
.plan-card h3 { margin: 0 0 0.625rem; font-size: 1.4rem; }
.plan-card .plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  text-align: left;
}
.plan-card .plan-features li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--yy-gray-light, #e5e7eb);
  color: var(--yy-gray);
  font-size: 0.9375rem;
}
.plan-card .plan-features li:last-child { border-bottom: none; }
.plan-card .plan-for {
  color: var(--yy-gray);
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
}
.plan-card .btn { margin-top: auto; }
.plans-note {
  text-align: center;
  margin: 2rem auto 0;
  max-width: 800px;
  color: var(--yy-gray);
  font-size: 0.9375rem;
}

/* === Cases Carousel（2026-08-02 改為 marquee：持續慢速滾動 + hover 暫停） === */
/* 純 CSS 動畫（@keyframes translateX -50%），無 JS 依賴
 * 卡片重複渲染兩次，動畫滾到一半時第二組接續，視覺無縫 loop
 * 兩側 fade-out mask-image 讓邊緣漸隱 */
.cases-carousel {
  position: relative;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  padding: 1rem 0;
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 4%, black 96%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, black 4%, black 96%, transparent 100%);
}
.carousel-track {
  display: flex;
  gap: 1rem;
  width: max-content;
  animation: cases-marquee 40s linear infinite;
  will-change: transform;
}
.cases-carousel:hover .carousel-track,
.cases-carousel:focus-within .carousel-track {
  animation-play-state: paused;
}
@keyframes cases-marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.case-card {
  flex: 0 0 280px;
  width: 280px;
  background: var(--yy-white);
  border: 1px solid var(--yy-gray-light);
  border-radius: var(--yy-radius);
  padding: 1.25rem 1.5rem;
}
@media (max-width: 640px) {
  .case-card { flex: 0 0 240px; width: 240px; padding: 1rem 1.25rem; }
}
.case-industry {
  font-size: 0.75rem;
  color: var(--yy-sky-dark, #0284C7);
  font-weight: 600;
  margin: 0 0 0.4rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.case-title {
  font-size: 1.125rem;
  margin: 0 0 0.875rem;
  color: #1f2937;
  font-weight: 700;
  line-height: 1.35;
}
.case-section {
  margin: 0.75rem 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--yy-gray-light, #F1F5F9);
}
.case-section:first-of-type {
  border-top: none;
  padding-top: 0;
}
.case-section h4 {
  font-size: 0.75rem;
  color: var(--yy-gray);
  margin: 0 0 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.case-section p {
  margin: 0;
  line-height: 1.5;
  color: #1f2937;
  font-size: 0.875rem;
}
/* accessibility：使用者偏好減少動態效果則停止 marquee */
@media (prefers-reduced-motion: reduce) {
  .carousel-track { animation: none; }
}
/* 保留舊 class 避免 JS 報錯，但視覺隱藏（已改為 marquee，不需要箭頭/dots）*/
.carousel-arrow { display: none !important; }
.carousel-dots  { display: none !important; }

/* === Mobile marquee fix（2026-08-03，Chrome 補強）===
 * iOS Safari 問題（0110 已修）：marquee 重複渲染 + width: max-content → 卡垂直滾動
 * Chrome Android 追加問題：Safari 修法（隱藏 duplicate + 停動畫）對 Chrome 不夠，
 *   仍會受 width: max-content 影響 scroll。改用垂直 grid 完全消掉 overflow 來源。
 * 桌機 marquee 行為完全不變。
 */
@media (max-width: 640px) {
  .cases-carousel {
    overflow: visible !important;
    -webkit-mask-image: none !important;
            mask-image: none !important;
    padding: 0;
  }
  .carousel-track {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 1rem;
    width: auto !important;
    animation: none !important;
    transform: none !important;
  }
  .case-card {
    width: 100% !important;
    flex: 0 0 auto;
  }
  /* 隱藏 marquee 重複渲染組（aria-hidden） */
  .case-card[aria-hidden="true"] {
    display: none !important;
  }
  /* 手機下把共用 CTA 撐滿，好按 */
  .plans-shared-cta {
    display: block;
    width: 100%;
    text-align: center;
  }
}
