/* Shared foundation and site shell. The 3D gallery keeps its own full-screen layout;
   archive pages retain their frozen legacy styles instead of loading this file. */
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('../fonts/atkinson-hyperlegible-next.woff2') format('woff2');
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('../fonts/ibm-plex-mono.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --site-max-width: 1200px;
  --site-gutter: 32px;
  --site-nav-height: 64px;
  --site-bg: #fff;
  --site-text: #202020;
  --site-muted: #666;
  --site-border: #d9d9d9;
  --site-accent: #6b3fa0;
  --action-bg: #6b3fa0;
  --action-fg: #fff;
  --action-hover-bg: #b48be0;
  --action-hover-fg: #202020;
  --site-nav-bg: rgba(255, 255, 255, 0.88);
  --bg: var(--site-bg);
  --bg-card: #fff;
  --text: var(--site-text);
  --text-muted: var(--site-muted);
  --faint: var(--site-muted);
  --accent: var(--site-accent);
  --accent-dim: color-mix(in srgb, var(--site-accent) 7%, transparent);
  --border: var(--site-border);
  --ph-bg: #f6f6f6;
  --font-body: 'Atkinson Hyperlegible Next', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
  --font-display: var(--font-body);
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 4rem;
  --space-xl: 8rem;
  --shadow: 0 1px 2px rgba(17, 17, 16, 0.05), 0 12px 32px rgba(17, 17, 16, 0.09);
}
[data-theme="dark"] {
  --site-bg: #202020;
  --site-text: #fff;
  --site-muted: #d9d9d9;
  --site-border: #666;
  --site-accent: #b48be0;
  --site-nav-bg: rgba(32, 32, 32, 0.92);
  --bg-card: #282828;
  --ph-bg: #282828;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); }
h1 { font-weight: 800; }
h2 { font-weight: 700; }
h3, h4, h5, h6 { font-weight: 600; }
strong, b { font-weight: 600; }
code, pre { font-family: var(--font-mono); font-weight: 400; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--site-accent); outline-offset: 4px; }

.icon-arrow-inline { display: inline-block; vertical-align: middle; }
.icon-arrow-inline--right { margin-left: 4px; }
.icon-arrow-inline--left { margin-right: 4px; }

/* Shared text-link behavior for the existing case and project-page components.
   Return links on Contact keep their quieter site-shell treatment. */
:where(body[data-page$="-case-study"], body[data-page="fun-projects"]) .text-link {
  color: var(--site-accent);
  font-weight: 600;
}
:where(body[data-page$="-case-study"], body[data-page="fun-projects"]) .text-link:hover {
  color: var(--site-text);
}

/* One outer frame. Narrow reading columns live inside it, without another gutter. */
.site-container, .container {
  width: 100%;
  max-width: var(--site-max-width);
  margin-inline: auto;
  padding-inline: var(--site-gutter);
}
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  top: 0.5rem; left: 0.5rem;
  z-index: 200;
  padding: 0.6rem 1rem;
  background: var(--site-bg);
  color: var(--site-text);
  border: 1px solid var(--site-text);
  font-size: 0.85rem;
  font-weight: 600;
  transform: translateY(-300%);
}
.skip-link:focus { transform: none; }

/* The site shell uses site tokens, never a case study's accent or typography. */
.site-nav, .mobile-menu, .site-footer {
  color: var(--site-text);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.7;
  letter-spacing: normal;
}
.site-nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  background: var(--site-nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--site-border);
  transition: background 0.3s, border-color 0.3s;
}
.nav-inner { height: var(--site-nav-height); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.nav-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.nav-logo .nav-logo-image { width: auto; height: 48px; max-width: none; }
.nav-logo .nav-logo-dark { display: none; }
[data-theme="dark"] .nav-logo .nav-logo-light { display: none; }
[data-theme="dark"] .nav-logo .nav-logo-dark { display: block; }
.nav-logo:hover { opacity: 0.7; }
.nav-links { display: flex; align-items: center; gap: 2rem; list-style: none; }
.nav-links a { font-family: var(--font-mono); font-size: 0.875rem; font-weight: 400; color: var(--site-accent); letter-spacing: 0.02em; transition: color 0.2s; }
.nav-links a:hover { color: var(--site-text); }
.nav-links .nav-resume { color: var(--site-accent); border: 1px solid var(--site-accent); padding: 0.25rem 0.65rem; transition: background 0.2s, color 0.2s; }
.nav-links .nav-resume:hover { background: var(--action-bg); color: var(--action-fg); }
.theme-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--site-border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--site-muted);
  transition: border-color 0.2s, color 0.2s;
}
.theme-btn:hover { border-color: var(--site-accent); color: var(--site-text); }
.theme-btn svg { width: 14px; height: 14px; fill: currentColor; }
.theme-btn .icon-sun { display: none; }
.theme-btn .icon-moon { display: block; }
[data-theme="dark"] .theme-btn .icon-sun { display: block; }
[data-theme="dark"] .theme-btn .icon-moon { display: none; }
.hamburger {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 34px; height: 34px;
  flex-shrink: 0;
  background: none; border: none; padding: 0;
  cursor: pointer;
}
.hamburger span { display: block; width: 22px; height: 2px; background: var(--site-muted); border-radius: 2px; transition: transform 0.25s, opacity 0.25s; }
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.mobile-menu {
  display: none;
  position: fixed; inset: var(--site-nav-height) 0 auto;
  z-index: 99;
  background: var(--site-bg);
  border-bottom: 1px solid var(--site-border);
  padding-block: 1.25rem 1.5rem;
  transform: translateY(-8px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease, visibility 0s 0.25s;
}
.mobile-menu.open { transform: none; opacity: 1; visibility: visible; pointer-events: auto; transition: transform 0.25s ease, opacity 0.25s ease; }
.mobile-menu ul { list-style: none; display: flex; flex-direction: column; gap: 0.25rem; }
.mobile-menu a { display: block; padding-block: 0.6rem; font-family: var(--font-mono); font-size: 1rem; color: var(--site-accent); border-bottom: 1px solid var(--site-border); transition: color 0.2s; }
.mobile-menu li:last-child a { border-bottom: none; }
.mobile-menu a:hover { color: var(--site-text); }

.site-footer { border-top: 1px solid var(--site-border); background: var(--site-bg); padding-block: 2rem; font-size: 0.78rem; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; color: var(--site-muted); }
.footer-note { font-style: italic; }
.case-return { margin-block: 2rem 4rem; }
.case-return a { display: inline-flex; align-items: center; min-height: 44px; font-size: 0.875rem; color: var(--text-muted); }
.case-return a:hover { color: var(--site-accent); }

/* Primary action: one outline button per view, same voice as the nav Résumé link */
.button-link { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; padding: 0.45rem 1rem; font-family: var(--font-mono); font-size: 0.875rem; font-weight: 400; letter-spacing: 0.02em; color: var(--site-accent); border: 1px solid var(--site-accent); transition: background 0.2s, color 0.2s, border-color 0.2s; }
.button-link:hover { background: var(--action-bg); color: var(--action-fg); border-color: var(--site-accent); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.fade-up { opacity: 0; animation: fadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.delay-1 { animation-delay: 0.15s; }
.delay-2 { animation-delay: 0.30s; }
.delay-3 { animation-delay: 0.45s; }
.reveal { opacity: 1; transform: none; transition: opacity 0.65s ease, transform 0.65s ease; }
.reveal.is-reveal-pending { opacity: 0; transform: translateY(24px); }
.reveal.visible { opacity: 1; transform: none; }

@media (max-width: 768px) {
  :root { --site-gutter: 20px; }
  .nav-links { display: none; }
  .hamburger { display: flex; }
  .mobile-menu { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fade-up, .reveal, .reveal.is-reveal-pending { opacity: 1; transform: none; animation: none; transition: none; }
  .mobile-menu, .hamburger span { transition: none; }
  .button-link { transition: none; }
}
