/* A BIT Design Studio — 亮／暗主題、黑白介面；標語橘色 #ff6d00 */

:root {
  --font-sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  /* 品牌標準字（與標準字／字標用字一致）；缺字時由 DM Sans 承接（含中文） */
  --font-brand: "Bitcount Single", var(--font-sans);

  --accent-tagline: #ff6d00;
  --accent-tagline-dim: #e85f00;

  --focus-ring: #ff6d00;

  --header-h: 4rem;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-theme="light"] {
  --bg: #fafafa;
  --bg-alt: #f0f0f0;
  --surface: #ffffff;
  --text: #0a0a0a;
  --text-muted: #525252;
  --border: #d4d4d4;
  --border-subtle: #e5e5e5;
  --grid-fg: rgba(10, 10, 10, 0.06);
  --bits: rgba(10, 10, 10, 0.035);
  --header-bg: rgba(250, 250, 250, 0.92);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  --logo-pad-bg: #141414;
}

html[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-alt: #111111;
  --surface: #141414;
  --text: #fafafa;
  --text-muted: #a3a3a3;
  --border: #404040;
  --border-subtle: #262626;
  --grid-fg: rgba(255, 255, 255, 0.06);
  --bits: rgba(255, 255, 255, 0.04);
  --header-bg: rgba(10, 10, 10, 0.9);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
  --logo-pad-bg: transparent;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 0.25s var(--ease-out), color 0.25s var(--ease-out);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
}

.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;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100%;
  z-index: 1000;
  padding: 0.5rem 1rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s var(--ease-out);
}

.skip-link:focus {
  top: 1rem;
  outline: none;
}

.skip-link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

/* —— Header —— */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.site-header.is-scrolled {
  border-bottom-color: var(--border-subtle);
  box-shadow: var(--shadow);
}

.site-header__inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: auto;
  text-decoration: none;
  color: var(--text);
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.site-logo:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 4px;
  border-radius: 0.25rem;
}

.site-logo__img-wrap {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  height: 2.25rem;
  padding: 0.2rem 0.4rem;
  border-radius: 0.375rem;
  border: 1px solid transparent;
}

html[data-theme="light"] .site-logo__img-wrap {
  background: var(--logo-pad-bg);
  border-color: #2a2a2a;
}

html[data-theme="dark"] .site-logo__img-wrap {
  border-color: var(--border-subtle);
}

.site-logo__img {
  display: block;
  height: 1.75rem;
  width: auto;
  max-height: 100%;
  object-fit: contain;
}

.site-nav {
  display: flex;
}

.site-nav__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  transition: color 0.15s;
}

.site-nav a:hover {
  color: var(--text);
}

.site-nav a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 4px;
  border-radius: 0.25rem;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--surface);
  cursor: pointer;
  color: var(--text);
}

.nav-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.nav-toggle__bar {
  display: block;
  width: 1.125rem;
  height: 2px;
  margin: 0 auto;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s var(--ease-out), opacity 0.2s;
}

.site-header.is-open .nav-toggle__bar:first-child {
  transform: translateY(4px) rotate(45deg);
}

.site-header.is-open .nav-toggle__bar:last-child {
  transform: translateY(-4px) rotate(-45deg);
}

.theme-toggle {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--surface);
  cursor: pointer;
  color: var(--text);
  display: grid;
  place-items: center;
  position: relative;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.theme-toggle__icon {
  position: absolute;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  border: 2px solid currentColor;
  transition: opacity 0.2s, transform 0.2s var(--ease-out);
}

.theme-toggle__icon--sun {
  border-width: 2px;
  box-shadow: inset 0 -5px 0 0 currentColor;
  opacity: 0;
  transform: scale(0.5);
}

.theme-toggle__icon--moon {
  border: none;
  border-radius: 50%;
  box-shadow: inset 0.48rem -0.05rem 0 0 currentColor;
  transform: rotate(-18deg) scale(0.5);
  opacity: 0;
}

html[data-theme="light"] .theme-toggle__icon--sun {
  opacity: 1;
  transform: scale(1);
}

html[data-theme="dark"] .theme-toggle__icon--moon {
  opacity: 1;
  transform: rotate(-18deg) scale(1);
}

@media (max-width: 52rem) {
  .nav-toggle {
    display: flex;
  }

  .site-nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    max-height: 0;
    overflow: hidden;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    transition: max-height 0.35s var(--ease-out);
  }

  .site-header.is-open .site-nav {
    max-height: 16rem;
  }

  .site-nav__list {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem 1.25rem 1.25rem;
    gap: 0;
  }

  .site-nav__list li a {
    display: block;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border-subtle);
  }

  .site-nav__list li:last-child a {
    border-bottom: none;
  }
}

/* —— Hero —— */

.hero {
  position: relative;
  padding: clamp(3rem, 8vw, 6rem) 1.25rem clamp(4rem, 10vw, 7rem);
  overflow: hidden;
}

.hero__bg {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--grid-fg) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-fg) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, black 20%, transparent 70%);
}

.hero__bg::after {
  content: "01001000 01101001 00100000 01100010 01101001 01110100";
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translate(-50%, -50%) rotate(-4deg);
  font-family: var(--font-mono);
  font-size: clamp(0.65rem, 1.2vw, 0.75rem);
  color: var(--bits);
  white-space: nowrap;
  letter-spacing: 0.35em;
}

.hero__inner {
  position: relative;
  max-width: 48rem;
  margin: 0 auto;
  text-align: center;
}

.hero__mono {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
}

.hero__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin-bottom: 1.75rem;
}

.hero__brand-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
  max-width: 36rem;
  padding: clamp(1rem, 3vw, 1.5rem) clamp(1rem, 3vw, 1.75rem);
  border-radius: 1rem;
  border: 1px solid var(--border-subtle);
  background: transparent;
}

html[data-theme="light"] .hero__brand-board {
  background: var(--logo-pad-bg);
  border-color: #2a2a2a;
}

html[data-theme="dark"] .hero__brand-board {
  border-color: var(--border);
}

.hero__logo {
  display: block;
  width: min(100%, 220px);
  height: auto;
  vertical-align: middle;
}

.hero__wordmark {
  display: block;
  width: min(100%, 520px);
  height: auto;
  margin: 0 auto;
}

.hero__title {
  margin: 0 0 0.35rem;
  font-family: var(--font-brand);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hero__subtitle {
  margin: 0 0 1rem;
  font-family: var(--font-brand);
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.06em;
}

.hero__tagline-img {
  display: block;
  width: min(100%, 42rem);
  height: auto;
  margin: 0 auto 1.75rem;
}

/* —— Buttons —— */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}

.btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

.btn--primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn--primary:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

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

.btn--outline:hover {
  background: var(--bg-alt);
  border-color: var(--text-muted);
}

/* —— Sections —— */

.section {
  padding: clamp(3rem, 6vw, 5rem) 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

.section--alt {
  background: var(--bg-alt);
}

.section__inner {
  max-width: 52rem;
  margin: 0 auto;
}

.section__inner--narrow {
  max-width: 36rem;
}

.section__title {
  margin: 0 0 1rem;
  font-family: var(--font-brand);
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.section__lead {
  margin: 0;
  color: var(--text-muted);
  font-size: 1.0625rem;
}

.cards {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.card {
  padding: 1.35rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card:hover {
  border-color: var(--text-muted);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

html[data-theme="dark"] .card:hover {
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.35);
}

.card__title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.card__text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* —— Footer —— */

.site-footer {
  padding: 2rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-alt);
}

.site-footer__inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-footer__copy {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.site-footer__link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: border-color 0.15s, color 0.15s;
}

.site-footer__link:hover {
  border-bottom-color: var(--accent-tagline);
  color: var(--accent-tagline-dim);
}

.site-footer__link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 4px;
  border-radius: 0.25rem;
}

/* —— Legal / copyright page —— */

.legal-main {
  padding: clamp(2.5rem, 5vw, 4rem) 1.25rem clamp(4rem, 8vw, 6rem);
}

.legal-page {
  max-width: 42rem;
  margin: 0 auto;
}

.legal-page__title {
  margin: 0 0 2rem;
  font-family: var(--font-brand);
  font-size: clamp(1.75rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.legal-section {
  margin-bottom: 2.25rem;
}

.legal-section__title {
  margin: 0 0 0.75rem;
  font-family: var(--font-brand);
  font-size: 1.125rem;
  font-weight: 700;
}

.legal-section p {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.legal-section p:last-child {
  margin-bottom: 0;
}

.legal-page__date {
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
}

.legal-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
}

.legal-list a {
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-list a:hover {
  color: var(--accent-tagline-dim);
}

.legal-list a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 0.2rem;
}

.legal-back {
  margin: 2.5rem 0 0;
}
