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

:root {
  --content-margin: 5%;

  /* light mode */
  --bg:          #ffffff;
  --card-bg:     #ffffff;
  --card-border: #e0e0e0;
  --text-dark:   #222;
  --text-muted:  #999;
  --accent:      #679970;
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.06);
  --shadow-card: 0 2px 4px rgba(0,0,0,0.10), 0 6px 18px rgba(0,0,0,0.08), 0 1px 0 rgba(255,255,255,0.8) inset;

}

[data-theme="dark"] {
  --bg:          #111;
  --card-bg:     #1c1c1c;
  --card-border: #2e2e2e;
  --text-dark:   #e8e8e8;
  --text-muted:  #666;
  --accent:      #7ab884;
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.3);
  --shadow-card: 0 2px 4px rgba(0,0,0,0.5), 0 6px 18px rgba(0,0,0,0.4);

}

/* ── Fonts ───────────────────────────────────────────────── */

.project-cover .title,
.project-section-title,
.more-item,
.detail-label,
.about-body,
.password-notice {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
}

/* ── Base ────────────────────────────────────────────────── */

html { font-size: 16px; }

body {
  font-family: 'IBM Plex Mono', monospace;
  background-color: var(--bg);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background-color 0.25s, color 0.25s;
}

a { text-decoration: none; color: inherit; }

/* ── Site shell ──────────────────────────────────────────── */

.site-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────── */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--content-margin);
  height: 64px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  transition: background-color 0.25s, border-color 0.25s;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.header-logo img {
  display: block;
  height: 18px;
  width: auto;
}

.header-bio {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Header nav ──────────────────────────────────────────── */

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

.nav-link {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-dark);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.nav-link::after {
  content: attr(data-label);
  font-weight: 700;
  height: 0;
  visibility: hidden;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

.nav-link:hover { color: var(--accent); }

.nav-link.active {
  font-weight: 700;
  color: var(--text-dark);
}

/* ── Footer ──────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--card-border);
  padding: 0 var(--content-margin);
  height: 56px;
  background: var(--card-bg);
  transition: background-color 0.25s, border-color 0.25s;
}

.footer-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-copy {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.footer-social {
  display: flex;
  align-items: center;
  gap: 16px;
}

.footer-social a {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.footer-social a:hover { color: var(--accent); }

.footer-social .icon {
  width: 20px;
  height: 16px;
  fill: currentColor;
}

/* ── Main content ────────────────────────────────────────── */

main {
  width: 100%;
  padding: 52px var(--content-margin) 80px;
  margin-top: 64px;
}

/* ── Project grid ────────────────────────────────────────── */

.project-covers {
  display: flex;
  flex-wrap: wrap;
}

.project-cover {
  display: block;
  position: relative;
  width: 32%;
  margin-right: 2%;
  margin-bottom: 36px;
  text-decoration: none;
  color: inherit;

  background-color: var(--card-bg);
  border-radius: 4px;
  padding: 7px 7px 12px;

  box-shadow:
    0 1px 3px rgba(0,0,0,0.12),
    0 4px 12px rgba(0,0,0,0.10),
    0 12px 32px rgba(0,0,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.9);

  border: 1px solid var(--card-border);

}

.project-cover:nth-child(3n) {
  margin-right: 0;
}

.project-cover:hover {
  transform: translateY(-3px);
  box-shadow:
    0 2px 4px rgba(0,0,0,0.12),
    0 8px 24px rgba(0,0,0,0.13),
    0 20px 48px rgba(0,0,0,0.10),
    inset 0 1px 0 rgba(255,255,255,0.9);
}

/* ── Image area inside card ──────────────────────────────── */

.cover-image-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}

.cover-image {
  position: relative;
}

.cover-image::before {
  content: '';
  display: block;
  width: 100%;
  padding-bottom: 66.66667%;
}

.cover {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow: hidden;
}

.cover__img {
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  object-fit: cover;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: block;
}

.project-cover:hover .cover__img {
  filter: brightness(1.04);
}

/* image frame inner shadow */
.cover-image::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.18);
  pointer-events: none;
  z-index: 1;
  border-radius: 2px;
}

/* ── Card text (below image — polaroid label) ────────────── */

.details-wrap {
  padding-top: 0;
  padding: 10px 4px 0;
  width: 100%;
}

.project-cover .title {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 13px;
  font-weight: bold;
  color: var(--text-dark);
  line-height: 1.2;
  margin-bottom: 3px;
}

.project-cover .description {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: normal;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── About page ──────────────────────────────────────────── */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 520px) 1fr;
  gap: 40px;
  align-items: start;
}

.about-left {
  overflow: hidden;
}

.about-ascii {
  font-family: Menlo, Monaco, Consolas, 'Courier New', monospace;
  font-size: min(8.5px, 1.9vw);
  line-height: 1;
  color: var(--text-dark);
  white-space: pre;
  user-select: none;
  opacity: 0.85;
}

.about-ascii--dark { display: none; }
[data-theme="dark"] .about-ascii--light { display: none; }
[data-theme="dark"] .about-ascii--dark { display: block; }

.about-right {
  min-width: 0;
}

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

.about-body {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 17px;
  font-weight: normal;
  line-height: 1.8;
  color: var(--text-dark);
  padding-top: 0;
}

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

#andy-trigger,
#andy-trigger-zh {
  text-decoration: none;
  text-underline-offset: 3px;
}
#andy-trigger:hover,
#andy-trigger-zh:hover {
  text-decoration: underline;
}

.about-details {
  margin-top: 44px;
  padding-top: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-row { display: flex; gap: 20px; }

.detail-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  min-width: 90px;
  padding-top: 2px;
}

.detail-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--text-dark);
  line-height: 1.6;
}

.detail-value a {
  color: var(--accent);
  border-bottom: 1px solid rgba(176,120,48,0.3);
  padding-bottom: 1px;
}

.detail-value a:hover { color: var(--accent-light); }

/* ── More page ───────────────────────────────────────────── */

.more-section { padding-top: 16px; }

.more-item {
  display: block;
  margin-bottom: 12px;
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 17px;
  color: var(--text-dark);
}

.more-item:hover { color: var(--accent); }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 900px) {
  .header-bio { display: none; }

  .header-nav { gap: 16px; }

  .project-cover {
    width: 48%;
    margin-right: 4%;
  }

  .project-cover:nth-child(3n) { margin-right: 4%; }
  .project-cover:nth-child(2n) { margin-right: 0; }
}

@media (max-width: 600px) {
  .site-header { height: 56px; padding: 0 5%; }
  .header-nav { gap: 12px; }
  .nav-link { font-size: 13px; }
}

@media (max-width: 540px) {
  .project-cover {
    width: 100%;
    margin-right: 0;
  }
  .project-cover:nth-child(3n),
  .project-cover:nth-child(2n) { margin-right: 0; }
}

/* ── Theme toggle ────────────────────────────────────────── */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: none;
  padding: 2px;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
}

.theme-toggle:hover { color: var(--text-dark); }

.toggle-icon--sun { display: none; }
[data-theme="dark"] .toggle-icon--moon { display: none; }
[data-theme="dark"] .toggle-icon--sun { display: block; }

/* ── Content link highlights ─────────────────────────────── */

.module-text a,
.about-body a,
.project-intro a,
.project-header-right a,
.pw-gate a {
  color: var(--accent);
  text-decoration: underline;
  border-radius: 2px;
  padding: 0 2px;
  margin: 0 -2px;
}

.module-text a:hover,
.about-body a:hover,
.project-intro a:hover,
.project-header-right a:hover,
.pw-gate a:hover {
  background-color: color-mix(in srgb, var(--accent) 15%, transparent);
}

/* ── Dark mode overrides ─────────────────────────────────── */

[data-theme="dark"] .project-cover {
  box-shadow:
    0 1px 3px rgba(0,0,0,0.5),
    0 4px 12px rgba(0,0,0,0.4),
    0 12px 32px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.04);
}

[data-theme="dark"] .module-image img,
[data-theme="dark"] .module-embed,
[data-theme="dark"] .module-embed-portrait,
[data-theme="dark"] .module-grid-3 img {
  border-color: var(--card-border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

[data-theme="dark"] .detail-value a { color: var(--accent); }


/* ── Project detail pages ────────────────────────────────── */

.project-header-grid {
  display: grid;
  grid-template-columns: 26% 1fr;
  gap: 40px;
  align-items: start;
  margin-bottom: 32px;
  min-width: 0;
  max-width: 1100px;
}

.project-header-right {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.project-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-header-left h1 {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.5;
}

.project-medium {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--text-muted);
}

.project-header-right {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-dark);
}

.project-header-right p { margin-bottom: 12px; }
.project-header-right p:last-child { margin-bottom: 0; }

.project-meta-row {
  display: none !important;
  display: flex;
  flex-wrap: wrap;
  gap: 20px 32px;
  margin-top: 20px;
}

.project-meta-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 80px;
}

.meta-col-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.meta-col-val {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text-dark);
}

.project-details-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.detail-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 80px;
}

.detail-key {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.detail-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--text-dark);
}

@media (max-width: 700px) {
  .project-header-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .project-meta-col {
    flex: 1 1 calc(50% - 32px);
  }
}

.project-body {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-dark);
}

.project-body a { text-decoration: underline; color: var(--accent); }
.project-body a:hover { color: var(--accent-light); }

.project-section-title {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 18px;
  font-weight: bold;
  color: var(--text-dark);
  margin-top: 44px;
  margin-bottom: 14px;
  text-shadow: none;
}

.project-modules {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.module-image { width: 100%; display: block; }

.module-image.cover-hero {
  margin-bottom: 36px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 3px;
}
.module-image.cover-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  box-shadow: none;
}

.module-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 3px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--card-border);
}

.module-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.module-embed {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--card-border);
}

.module-embed iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}

.module-embed-portrait {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--card-border);
}

.module-embed-portrait iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}

.module-grid-3 {
  display: flex;
  gap: 8px;
}

.module-grid-3 img {
  flex: 1;
  width: 0;
  height: auto;
  object-fit: cover;
  display: block;
  border-radius: 3px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--card-border);
}

.module-text {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-dark);
}

.module-text p { margin-bottom: 16px; }
.module-text p:last-child { margin-bottom: 0; }

.module-text a { color: var(--accent); text-decoration: underline; }

.module-image-group {
  display: grid;
  gap: 8px;
  width: 100%;
  margin-bottom: 8px;
}
.module-image-group--2col { grid-template-columns: 1fr 1fr; }
.module-image-group--3col { grid-template-columns: 1fr 1fr 1fr; }
.module-image-group-item { overflow: hidden; }
.module-image-group-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
@media (max-width: 540px) {
  .module-image-group--2col,
  .module-image-group--3col { grid-template-columns: 1fr; }
}

.password-notice {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 16px;
  font-style: italic;
  color: var(--text-muted);
  padding: 48px 0;
}

.password-notice a { color: var(--accent); text-decoration: underline; }

/* ── Password gate ───────────────────────────────────────── */
.pw-gate {
  padding: 32px 0 40px;
}

.pw-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.pw-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.pw-input {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--card-border);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text-dark);
  outline: none;
  width: 200px;
}

.pw-input:focus {
  border-color: var(--text-muted);
}

.pw-submit {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  padding: 8px 16px;
  border: 1px solid var(--card-border);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text-dark);
  cursor: pointer;
}

.pw-submit:hover {
  background: var(--text-dark);
  color: var(--bg);
  border-color: var(--text-dark);
}

.pw-error {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: #c0392b;
  margin-top: 10px;
  min-height: 18px;
}

.pw-protected { display: none; }

.close-btn {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12), 0 8px 24px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
}

.close-btn:hover {
  color: var(--text-dark);
  background: var(--bg);
  box-shadow: 0 4px 16px rgba(0,0,0,0.16), 0 12px 32px rgba(0,0,0,0.10);
}

.close-btn svg { display: block; }
