:root {
  --bg: #f5efe3;
  --bg-alt: #ebe1cc;
  --card: #faf6ee;
  --ink: #17140f;
  --ink-soft: #4a4239;
  --ink-faint: #8b8372;
  --rule: #ddd0b4;
  --accent: #a13d28;
  --accent-dark: #7e2f1e;
  --accent-soft: rgba(161, 61, 40, 0.09);
  --max-w: 1080px;

  --serif: "Noto Serif TC", "Source Han Serif TC", serif;
  --sans: "Noto Sans TC", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  position: relative;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  /* Content defaults to sans for scannability; serif is applied deliberately. */
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* Paper grain — subtle editorial texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.04;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
}

.wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px;
  position: relative;
}

/* ---------- Header ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(245, 239, 227, 0.9);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease;
}

header.scrolled {
  border-bottom-color: var(--rule);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 28px;
  max-width: var(--max-w);
  margin: 0 auto;
}

/* Hierarchy: the MarpaTek wordmark is the anchor. The icon is a companion
   mark and must not out-weigh it; 瑪巴科技 sits quietly alongside. */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  min-width: 0;
}

.brand-icon {
  height: 30px;
  width: auto;
  display: block;
  flex-shrink: 0;
  opacity: 0.9;
}

.brand-word {
  height: 26px;
  width: auto;
  display: block;
}

/* Readable sub-brand, not metadata: the Latin wordmark still leads on size
   and weight, but the Chinese has to hold its own for CJK readers. */
.brand-cn {
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  white-space: nowrap;
  padding-left: 12px;
  border-left: 1px solid var(--rule);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
}

.lang-switch {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  text-decoration: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 12px;
  transition: color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}

.lang-switch:hover {
  color: var(--accent-dark);
  border-color: var(--accent);
}

.header-cta {
  position: relative;
  font-size: 0.92rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  padding-bottom: 3px;
}

.header-cta::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--ink);
  transform-origin: right;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease;
}

.header-cta:hover {
  color: var(--accent-dark);
}

.header-cta:hover::after {
  background: var(--accent);
  transform: scaleX(1.06);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 84px 0 92px;
  text-align: center;
  overflow: hidden;
  border-top: none;
}

.hero-mark {
  position: absolute;
  top: 50%;
  right: 0;
  width: min(520px, 46vw);
  height: auto;
  transform: translateY(-50%);
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
}

.hero > .wrap {
  z-index: 1;
}

.eyebrow-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
  text-transform: uppercase;
  margin-bottom: 22px;
}

/* The wide tracking above is tuned for Latin caps. On the CJK page it would
   read as decorative spacing, so tighten it and size up slightly — a plain
   label, not a flourish. */
html[lang="zh-Hant"] .eyebrow-mark {
  font-size: 0.88rem;
  letter-spacing: 0.09em;
  text-transform: none;
  color: var(--ink-soft);
}

/* Same correction for the section eyebrows. Colour is deliberately left
   alone so the dark-section override (.why .eyebrow) still applies. */
html[lang="zh-Hant"] .eyebrow {
  font-size: 0.83rem;
  letter-spacing: 0.09em;
  text-transform: none;
}

.eyebrow-mark::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 1px;
  display: inline-block;
  flex-shrink: 0;
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(1.85rem, 4.6vw, 3.3rem);
  font-weight: 700;
  letter-spacing: 0.005em;
  margin: 0 0 24px;
  line-height: 1.36;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.hero .sub {
  font-size: clamp(0.97rem, 1.35vw, 1.08rem);
  color: var(--ink-soft);
  max-width: 33em;
  margin: 0 auto;
  line-height: 1.95;
}

.hero .cta {
  margin-top: 36px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--bg);
  background: var(--ink);
  text-decoration: none;
  padding: 15px 34px;
  border-radius: 2px;
  transition: background 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
  letter-spacing: 0.02em;
}

.btn:hover {
  background: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -10px rgba(161, 61, 40, 0.55);
}

.btn-ghost {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.98rem;
  color: var(--ink);
  text-decoration: none;
  padding-bottom: 3px;
  position: relative;
}

.btn-ghost::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--ink);
  transition: background-color 0.2s ease;
}

.btn-ghost:hover {
  color: var(--accent-dark);
}

.btn-ghost:hover::after {
  background: var(--accent);
}

/* ---------- Section rhythm ---------- */
section {
  position: relative;
  padding: 88px 0;
  border-top: 1px solid var(--rule);
}

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

.section-head {
  text-align: center;
  max-width: 40em;
  margin: 0 auto 52px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
  text-transform: uppercase;
  margin-bottom: 14px;
}

.eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 1px;
  display: inline-block;
  flex-shrink: 0;
}

/* Section headings: serif, but restrained in size and leading. */
.section-head h2 {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.1vw, 1.62rem);
  font-weight: 700;
  margin: 0;
  line-height: 1.5;
  text-wrap: balance;
  overflow-wrap: break-word;
}

/* ---------- Needs / problems ---------- */
.problems {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.problem-card {
  position: relative;
  background: var(--bg);
  padding: 40px 30px 36px;
  overflow: hidden;
  transition: background 0.3s ease;
}

.problem-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.problem-card:hover {
  background: var(--card);
}

.problem-card:hover::before {
  transform: scaleX(1);
}

.problem-card .num {
  font-family: var(--serif);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.17;
  line-height: 1;
  display: block;
  transition: opacity 0.3s ease;
}

.problem-card:hover .num {
  opacity: 0.32;
}

.problem-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 14px 0 12px;
  line-height: 1.65;
  overflow-wrap: break-word;
}

.problem-card p {
  font-size: 0.93rem;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.9;
}

/* ---------- Selected Work ---------- */
.work-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.work-item {
  position: relative;
  background: var(--bg);
  padding: 34px 32px 32px;
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease;
  min-width: 0;
}

.work-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.work-item:hover {
  background: var(--card);
}

.work-item:hover::before {
  transform: scaleY(1);
}

.work-item .num {
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.24;
  line-height: 1;
  margin-bottom: 12px;
  transition: opacity 0.3s ease;
}

.work-item:hover .num {
  opacity: 0.4;
}

.work-item h3 {
  font-size: 1.06rem;
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.6;
  overflow-wrap: break-word;
}

.work-item .desc {
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin: 0 0 20px;
  line-height: 1.9;
  flex-grow: 1;
  overflow-wrap: break-word;
}

.work-item .tag {
  align-self: flex-start;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 5px 12px;
  border-radius: 999px;
  max-width: 100%;
  overflow-wrap: break-word;
}

/* 7th item spans the full row so the grid never ends on an orphan. */
.work-grid > .work-item:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* ---------- How We Work ---------- */
.why {
  position: relative;
  text-align: center;
  background: var(--ink);
  color: var(--bg);
  overflow: hidden;
}

.why-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(460px, 62vw);
  height: auto;
  transform: translate(-50%, -50%);
  opacity: 0.06;
  pointer-events: none;
  filter: invert(1);
}

.why .wrap {
  position: relative;
  z-index: 1;
}

.why .eyebrow {
  color: rgba(245, 239, 227, 0.55);
}

.why .lede {
  font-family: var(--serif);
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
  font-weight: 700;
  max-width: 18em;
  margin: 0 auto 40px;
  line-height: 1.6;
  text-wrap: balance;
}

.triage {
  list-style: none;
  margin: 0 auto 40px;
  padding: 0;
  max-width: 32em;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: rgba(245, 239, 227, 0.14);
  border: 1px solid rgba(245, 239, 227, 0.14);
  text-align: left;
}

.triage li {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  background: var(--ink);
  padding: 16px 20px;
  font-size: 0.94rem;
}

.triage .cond {
  color: rgba(245, 239, 227, 0.62);
  text-align: right;
  overflow-wrap: break-word;
}

.triage .arrow {
  color: var(--accent);
  flex-shrink: 0;
}

.triage .result {
  color: var(--bg);
  font-weight: 500;
  overflow-wrap: break-word;
}

.why .points {
  max-width: 34em;
  margin: 0 auto;
  color: rgba(245, 239, 227, 0.75);
  font-size: 0.97rem;
  line-height: 1.95;
}

.why .points p {
  margin: 0;
}

/* ---------- About ----------
   Asymmetric two-column: label left, prose right and left-aligned. Five
   centered paragraphs would read as a corporate boilerplate block and break
   the scan rhythm after four centered sections in a row. */
.about .wrap {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.7fr);
  gap: 20px 72px;
  align-items: start;
}

.about-head {
  text-align: left;
}

.about-head h2 {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.1vw, 1.62rem);
  font-weight: 700;
  margin: 0;
  line-height: 1.5;
  overflow-wrap: break-word;
}

.about-body p {
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: 0.97rem;
  line-height: 2;
  overflow-wrap: break-word;
}

.about-body p:last-child {
  margin-bottom: 0;
}

.about-body .lead {
  font-size: 1.08rem;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.9;
  margin-bottom: 24px;
}

/* ---------- Partnership ---------- */
.partner {
  background: var(--bg-alt);
  text-align: center;
  padding: 62px 0;
}

.partner h2 {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 1.9vw, 1.35rem);
  font-weight: 700;
  margin: 0 0 14px;
  line-height: 1.5;
}

.partner p {
  color: var(--ink-soft);
  max-width: 34em;
  margin: 0 auto 24px;
  font-size: 0.95rem;
}

/* ---------- Contact ---------- */
.contact {
  text-align: center;
  padding-bottom: 100px;
}

.contact h2 {
  font-family: var(--serif);
  font-size: clamp(1.45rem, 2.8vw, 2rem);
  font-weight: 700;
  margin: 0 0 20px;
  line-height: 1.45;
  text-wrap: balance;
}

.contact p {
  color: var(--ink-soft);
  max-width: 32em;
  margin: 0 auto 36px;
  font-size: 0.98rem;
}

.contact .email {
  font-size: clamp(1.1rem, 2.2vw, 1.45rem);
  color: var(--ink);
  text-decoration: none;
  padding-bottom: 6px;
  letter-spacing: 0.01em;
  position: relative;
  display: inline-block;
  overflow-wrap: break-word;
  max-width: 100%;
}

.contact .email::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--ink);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease;
  transform-origin: left;
}

.contact .email:hover {
  color: var(--accent-dark);
}

.contact .email:hover::after {
  background: var(--accent);
  transform: scaleY(2);
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--rule);
  padding: 28px;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .problems {
    grid-template-columns: 1fr;
  }

  .work-grid {
    grid-template-columns: 1fr;
  }

  .work-grid > .work-item:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .about .wrap {
    grid-template-columns: 1fr;
    gap: 26px;
  }

  section {
    padding: 68px 0;
  }

  .hero {
    padding: 64px 0 72px;
  }

  .header-inner {
    padding: 12px 20px;
  }
}

@media (max-width: 600px) {
  .wrap {
    padding: 0 20px;
  }

  .header-cta {
    display: none;
  }

  .header-actions {
    gap: 12px;
  }

  .brand {
    gap: 9px;
  }

  .brand-icon {
    height: 26px;
  }

  .brand-word {
    height: 22px;
  }

  .brand-cn {
    font-size: 0.8rem;
    padding-left: 10px;
  }

  /* Keep the watermark fully inside the viewport on phones: no bleed at all,
     so no horizontal scroll can appear even where overflow clipping is
     unreliable (older iOS Safari). */
  .hero-mark {
    width: 56vw;
    right: 0;
    opacity: 0.045;
  }

  .problem-card {
    padding: 32px 24px 30px;
  }

  .work-item {
    padding: 30px 24px 28px;
  }

  .triage li {
    grid-template-columns: 1fr;
    gap: 4px;
    text-align: center;
    padding: 15px 18px;
  }

  .triage .cond {
    text-align: center;
  }

  .footer-inner {
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 380px) {
  .brand-cn {
    font-size: 0.76rem;
    padding-left: 9px;
  }

  .brand-icon {
    height: 24px;
  }

  .brand-word {
    height: 20px;
  }

  .header-inner {
    padding: 12px 16px;
  }
}
