/* ==========================================================================
   云熔智算 / YunRong — Site CSS
   Two style variants: A (Foundry Lab, default) and B (Quiet Precision)
   Toggle via [data-style="b"] on <html>
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Noto+Sans+SC:wght@300;400;500;700;900&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  /* Style A — Foundry Lab */
  --bg: #0a0e1a;
  --bg-elev: #0f1422;
  --bg-card: #11172a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f5f5;
  --text-dim: rgba(245, 245, 245, 0.6);
  --text-faint: rgba(245, 245, 245, 0.4);
  --accent: #ff4d2e;
  --accent-glow: rgba(255, 77, 46, 0.4);
  --accent-2: #06b6d4;
  --accent-3: #fbbf24;
  --grid: rgba(255, 255, 255, 0.04);
  --grid-strong: rgba(255, 255, 255, 0.08);
  --heat-0: #1a0a1a;
  --heat-1: #4a0d2e;
  --heat-2: #b91c1c;
  --heat-3: #f97316;
  --heat-4: #fbbf24;
  --heat-5: #fef3c7;

  --font-display: 'Space Grotesk', 'Noto Sans SC', sans-serif;
  --font-body: 'IBM Plex Sans', 'Noto Sans SC', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 16px;
  --r-xl: 24px;

  --nav-h: 64px;
  --max-w: 1320px;
  --gutter: clamp(20px, 4vw, 56px);
}

[data-style="b"] {
  /* Style B — Quiet Precision */
  --bg: #0a0a0a;
  --bg-elev: #131313;
  --bg-card: #161616;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #fafafa;
  --text-dim: rgba(250, 250, 250, 0.58);
  --text-faint: rgba(250, 250, 250, 0.36);
  --accent: #ff6b3d;
  --accent-glow: rgba(255, 107, 61, 0.35);
  --accent-2: #e5e5e5;
  --accent-3: #ff6b3d;
  --grid: rgba(255, 255, 255, 0.025);
  --grid-strong: rgba(255, 255, 255, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  font-feature-settings: "ss01", "cv02", "cv11";
}

body {
  overflow-x: hidden;
}

/* Bilingual: hide opposite-language elements */
[data-lang="en"] [data-zh] { display: none !important; }
[data-lang="zh"] [data-en] { display: none !important; }

/* CJK optical sizing: Chinese glyphs read smaller than Latin at the same point size */
[data-lang="zh"] :where([data-zh]) { font-size: 1.06em; }

/* Inline bilingual switch */
.bi { display: inline; }
[data-lang="en"] .bi[data-zh],
[data-lang="zh"] .bi[data-en] { display: none !important; }

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.18s ease, opacity 0.18s ease;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5 L6 6.5 L11 1.5' stroke='%23999' stroke-width='1.5' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

/* Make dropdown popup readable on all OS/browsers */
select option,
select optgroup {
  background-color: #14182a;
  color: #f5f5f5;
}
[data-style="b"] select option,
[data-style="b"] select optgroup {
  background-color: #131313;
  color: #fafafa;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  background: rgba(255, 77, 46, 0.04);
}

textarea {
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
  width: 100%;
}

.section {
  padding: clamp(80px, 12vw, 160px) 0;
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.section-tight {
  padding: clamp(48px, 7vw, 96px) 0;
  min-height: 0;
  display: block;
}

/* Sections that own their internal scroll height (e.g. pillar rail) opt out */
.section.pillars {
  min-height: 0;
  display: block;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.05;
}

[lang="zh"], [data-zh], html[data-lang="zh"] h1, html[data-lang="zh"] h2, html[data-lang="zh"] h3 {
  font-family: var(--font-body);
  letter-spacing: -0.01em;
}

[data-lang="zh"] h1, [data-lang="zh"] h2, [data-lang="zh"] h3 {
  font-family: 'Noto Sans SC', var(--font-body);
  font-weight: 700;
}

.h-display {
  font-size: clamp(48px, 6.8vw, 96px);
  line-height: 0.98;
  letter-spacing: -0.035em;
}

.h-xl {
  font-size: clamp(36px, 4.5vw, 64px);
  line-height: 1.04;
}

.h-lg {
  font-size: clamp(28px, 3vw, 44px);
}

.h-md {
  font-size: clamp(22px, 2vw, 28px);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.eyebrow::before {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--accent);
}

.eyebrow--center::before { content: none; }
.eyebrow--center::after { content: none; }

.mono {
  font-family: var(--font-mono);
  font-feature-settings: "ss01";
}

.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }

p {
  margin: 0;
  color: var(--text-dim);
  font-size: clamp(15px, 1.05vw, 17px);
  line-height: 1.65;
  text-wrap: pretty;
}

p.lead {
  font-size: clamp(18px, 1.4vw, 22px);
  line-height: 1.5;
  color: var(--text);
  max-width: 60ch;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: all 0.22s cubic-bezier(.2,.6,.2,1);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 1px var(--accent), 0 12px 32px -10px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px var(--accent), 0 18px 40px -10px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}

.btn-link::after {
  content: "→";
  transition: transform 0.22s ease;
}

.btn-link:hover::after { transform: translateX(4px); }

/* ==========================================================================
   Nav
   ========================================================================== */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.brand-mark svg { width: 100%; height: 100%; }
.brand-name { color: var(--text); font-family: 'Noto Sans SC', var(--font-body); font-weight: 700; }
.brand-sub { color: var(--text-faint); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; margin-left: 4px; }

/* PNG logos: render monochrome white on the dark theme so the navy
   text + icon stay legible without needing per-element color variants. */
.brand-logo {
  display: block;
  height: 48px;
  width: auto;
  filter: brightness(0) invert(1);
}
.brand-logo-en { height: 48px; }
.brand-logo-footer { height: 60px; }
.brand-logo-footer.brand-logo-en { height: 60px; }

/* Logo is fixed per brand/domain (set pre-paint via [data-brand]), not by language */
.brand-logo-en { display: none; }
[data-brand="am"] .brand-logo-zh { display: none; }
[data-brand="am"] .brand-logo-en { display: block; }
@media (max-width: 720px) {
  .brand-logo, .brand-logo-en { height: 38px; }
  .brand-logo-footer, .brand-logo-footer.brand-logo-en { height: 48px; }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 36px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  position: relative;
  padding: 8px 0;
}

.nav-links a:hover, .nav-links a.is-active {
  color: var(--text);
}

.nav-links a.is-active::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 0; right: 0;
  height: 1px;
  background: var(--accent);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lang-toggle {
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  overflow: hidden;
}

.lang-toggle button {
  padding: 6px 10px;
  color: var(--text-dim);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.18s;
}

.lang-toggle button.is-active {
  background: var(--text);
  color: var(--bg);
}

.btn-nav {
  padding: 10px 18px;
  font-size: 13px;
}

@media (max-width: 880px) {
  .nav-links { display: none; }
  .brand-sub { display: none; }
}

/* ==========================================================================
   Grid background utility
   ========================================================================== */

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at 50% 50%, #000 30%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}

.bg-noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.4;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' /></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.5' /></svg>");
  z-index: 0;
}

.section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 64px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  flex-wrap: wrap;
}

.section-label > span:first-child {
  font-family: var(--font-display);
  font-size: clamp(15px, 1.1vw, 18px);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-dim);
}

[data-lang="zh"] .section-label > span:first-child {
  font-family: 'Noto Sans SC', var(--font-body);
  font-weight: 700;
}

.section-label > span:first-child .idx {
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.08em;
  margin-right: 6px;
  font-size: 0.82em;
}

.section-label > span:not(:first-child) {
  font-family: var(--font-display);
  font-size: clamp(15px, 1.1vw, 18px);
  font-weight: 400;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--text-dim);
}

[data-lang="zh"] .section-label > span:not(:first-child) {
  font-family: 'Noto Sans SC', var(--font-body);
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 28px;
  position: relative;
  transition: border-color 0.22s, transform 0.22s, background 0.22s;
}

.card:hover {
  border-color: var(--border-strong);
}

.card-glow:hover {
  background: linear-gradient(160deg, var(--bg-card) 0%, color-mix(in srgb, var(--accent) 5%, var(--bg-card)) 100%);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  border-top: 1px solid var(--border);
  padding: 80px 0 36px;
  background: var(--bg);
  position: relative;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 48px;
  margin-bottom: 64px;
}

.footer h5 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 18px;
  font-weight: 500;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-links a {
  font-size: 14px;
  color: var(--text-dim);
}
.footer-links a:hover { color: var(--text); }

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  gap: 24px;
  flex-wrap: wrap;
}

@media (max-width: 800px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

/* ==========================================================================
   Tweaks panel (always rendered, toggled by host)
   ========================================================================== */

#tweaks-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 280px;
  background: rgba(20, 22, 32, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  z-index: 80;
  font-family: var(--font-body);
  display: none;
  box-shadow: 0 24px 64px -12px rgba(0, 0, 0, 0.6);
}

#tweaks-panel.is-open { display: block; }

#tweaks-panel .tp-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}

#tweaks-panel .tp-body { padding: 16px; display: flex; flex-direction: column; gap: 18px; }

.tp-group label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.tp-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.tp-seg button {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-dim);
  background: transparent;
  transition: all 0.16s;
}

.tp-seg button.is-active {
  background: var(--accent);
  color: #fff;
}

.tp-swatches { display: flex; gap: 8px; }
.tp-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  outline: 1px solid var(--border);
}
.tp-swatch.is-active { border-color: var(--text); }

.tp-close {
  font-size: 16px;
  color: var(--text-dim);
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.tp-close:hover { background: rgba(255,255,255,0.06); color: var(--text); }

/* ==========================================================================
   Misc utilities
   ========================================================================== */

.row { display: flex; gap: 16px; align-items: center; }
.row-wrap { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.col { display: flex; flex-direction: column; gap: 16px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  color: var(--text-dim);
}

.tag .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

main {
  padding-top: var(--nav-h);
}

/* Subtle entrance */
.reveal {
  opacity: 0;
  transform: translate3d(0, 36px, 0);
  transition:
    opacity 0.8s cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 0.8s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.reveal.is-in { opacity: 1; transform: translate3d(0, 0, 0); }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ==========================================================================
   Page header (used on inner pages)
   ========================================================================== */

.page-head {
  position: relative;
  padding: clamp(80px, 12vw, 140px) 0 clamp(48px, 6vw, 80px);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.page-head::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 90% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 50%),
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 4%, transparent), transparent 60%);
  pointer-events: none;
}

.page-head .container { position: relative; z-index: 1; }

.page-head .crumbs {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-head .crumbs .sep { color: var(--text-faint); opacity: 0.5; }
.page-head .crumbs .cur { color: var(--accent); }

.page-head h1 {
  margin-bottom: 24px;
  max-width: 24ch;
}

.page-head .page-lead {
  max-width: 56ch;
  font-size: clamp(17px, 1.3vw, 21px);
  line-height: 1.5;
  color: var(--text);
}

/* Page header decorative grid */
.page-head .head-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 90% 0%, #000 10%, transparent 70%);
  pointer-events: none;
  opacity: 0.6;
}

/* Generic two-col content row used on inner pages */
.duo {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 80px;
  align-items: start;
}
.duo-reverse { grid-template-columns: 7fr 5fr; }
.duo-reverse > :first-child { order: 2; }
.duo-reverse > :last-child { order: 1; }
@media (max-width: 1000px) {
  .duo, .duo-reverse { grid-template-columns: 1fr; gap: 32px; }
  .duo-reverse > :first-child { order: 1; }
  .duo-reverse > :last-child { order: 2; }
}

.duo-text h2 { margin-bottom: 20px; }
.duo-text .lead { margin-bottom: 24px; }

/* CTA strip used at bottom of inner pages */
.cta-strip {
  border-top: 1px solid var(--border);
  padding: clamp(48px, 6vw, 80px) 0;
  background:
    radial-gradient(ellipse at 20% 50%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 50%);
}
.cta-strip-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 40px;
  flex-wrap: wrap;
}
.cta-strip h2 { max-width: 22ch; }
.cta-strip .row-wrap { gap: 14px; }
