:root {
  --sky: #d9ecef;
  --mint: #e4f1ea;
  --grid: #cfe3da;
  --paper: #f8fcfa;
  --ink: #1f3b36;
  --muted: #5d7570;
  --line: #b9d3c9;
  --strip: #dcebe4;
  --coral: #e8665a;
  --water: #8fbcd0;
  --mono: "JetBrains Mono", ui-monospace, Consolas, "Noto Sans TC", monospace;
  --display: "Space Grotesk", "JetBrains Mono", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  font: 14px/1.7 var(--mono);
  background-color: var(--mint);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}

a { color: var(--ink); }
em { font-style: normal; background: #fbe3c4; padding: 0 .2em; }
code { background: var(--strip); padding: .05em .35em; border: 1px solid var(--line); font-size: .92em; }

.px { shape-rendering: crispEdges; image-rendering: pixelated; }

/* header */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px max(16px, calc((100% - 1040px) / 2));
  background: var(--sky);
  border-bottom: 2px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; }
.brand svg { width: 14px; height: 20px; }
.top nav { display: flex; gap: 20px; font-size: 13px; }
.top nav a { text-decoration: none; }
.top nav a:hover { text-decoration: underline; text-underline-offset: 4px; }

/* sky + hero */
.sky {
  position: relative;
  background: linear-gradient(var(--sky) 0%, var(--sky) 55%, #e2f0ea 100%);
  padding: 56px 16px 0;
  border-bottom: 2px solid var(--ink);
  overflow: hidden;
}
.hero-card {
  position: relative;
  z-index: 2;
  max-width: 1040px;
  margin: 0 auto;
  padding: 36px 40px 40px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
}
.ref { font-size: 11px; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; }
.hero-main { display: grid; grid-template-columns: 1fr 300px; gap: 40px; }
h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(42px, 8vw, 76px);
  line-height: .98;
  letter-spacing: -.01em;
  margin: 4px 0 20px;
}
hr { border: 0; border-top: 2px solid var(--ink); margin: 0 0 18px; max-width: 520px; }
.subtitle { letter-spacing: .06em; text-transform: uppercase; font-size: 13px; color: var(--muted); max-width: 520px; margin: 0; }
.btns { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 2px solid var(--ink);
  background: var(--paper);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .06em;
  text-decoration: none;
  text-transform: uppercase;
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 2px 2px 0 var(--ink); }
.btn.primary { background: var(--coral); color: #fff; }
.hero-side { border-left: 2px solid var(--ink); padding-left: 28px; display: flex; flex-direction: column; gap: 14px; }
.barcode { width: 100%; height: 44px; }
.spec { border: 1.5px solid var(--ink); }
.spec-k { margin: 0; padding: 2px 8px; font-size: 10px; font-weight: 700; letter-spacing: .08em; background: var(--strip); border-bottom: 1.5px solid var(--ink); }
.spec-v { margin: 0; padding: 6px 8px; font-size: 12px; font-weight: 500; }
.spec-sep { border-top: 1.5px dashed var(--ink); }
.corner { position: absolute; right: 10px; bottom: 10px; width: 16px; height: 16px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }

.scene { display: block; width: calc(100% + 32px); margin: -28px -16px 0; height: 300px; position: relative; z-index: 1; }
.cloud-layer { animation: drift linear infinite; }
.cloud-layer.back { opacity: .75; animation-duration: 240s; }
.cloud-layer.front { animation-duration: 120s; }
.ripples { animation: shimmer 3.2s steps(2) infinite; }
@keyframes drift { to { transform: translateX(calc(-1 * var(--w))); } }
@keyframes shimmer { 50% { transform: translateX(2px); } }

/* fishing cat: wait, nibble, catch */
.rod-wait { animation: rod-wait 9s step-end infinite; }
.rod-catch { opacity: 0; animation: rod-catch 9s step-end infinite; }
.bobber { animation: nibble 9s step-end infinite; }
.hooked { animation: wriggle .3s steps(2) infinite; }
@keyframes rod-wait { 0% { opacity: 1; } 78% { opacity: 0; } 96% { opacity: 1; } }
@keyframes rod-catch { 0% { opacity: 0; } 78% { opacity: 1; } 96% { opacity: 0; } }
@keyframes nibble { 0% { transform: none; } 64% { transform: translateY(1px); } 67% { transform: none; } 71% { transform: translateY(1px); } 74% { transform: none; } }
@keyframes wriggle { 50% { transform: translateX(1px); } }
.lure { animation: glow 1.4s steps(2) infinite; }
@keyframes glow { 50% { fill: #fff6d2; } }

/* pixel fish behind the Projects section, spanning the full window width */
#projects { position: relative; }
#projects > :not(.fish-school) { position: relative; z-index: 1; }
.fish-school { position: absolute; top: 0; bottom: 0; left: calc(50% - 50vw); width: 100vw; overflow: hidden; pointer-events: none; }
.fish { position: absolute; left: 0; opacity: .9; animation: swim linear infinite; }
.fish.left { animation-name: swim-left; }
.fish.left svg { transform: scaleX(-1); }
.fish svg { display: block; animation: bob 1.6s steps(2) infinite; }
.fish.left svg { animation-name: bob-flip; }
@keyframes swim { from { transform: translateX(-60px); } to { transform: translateX(calc(100vw + 60px)); } }
@keyframes swim-left { from { transform: translateX(calc(100vw + 60px)); } to { transform: translateX(-60px); } }
@keyframes bob { 50% { transform: translateY(2px); } }
@keyframes bob-flip { from, to { transform: scaleX(-1); } 50% { transform: scaleX(-1) translateY(2px); } }

/* sections */
main { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
section { padding: 64px 0 8px; }
.section-head { margin-bottom: 28px; }
h2 { font-family: var(--display); font-weight: 700; font-size: 34px; margin: 0; line-height: 1.1; }
.note { color: var(--muted); max-width: 560px; margin: 8px 0 0; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 28px; }
.card { background: var(--paper); border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.card.wide { grid-column: 1 / -1; display: grid; grid-template-columns: 1.4fr 1fr; grid-template-rows: auto auto 1fr; }
.card.wide .card-id { grid-column: 1 / -1; }
.card.wide .preview { grid-row: 2 / 4; border-right: 2px solid var(--ink); border-bottom: 0; min-height: 260px; }
.card.wide .strip { border-top: 0; }
.card-id { display: flex; justify-content: space-between; padding: 6px 12px; font-size: 11px; font-weight: 700; letter-spacing: .06em; border-bottom: 2px solid var(--ink); }
.preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 190px;
  border-bottom: 2px solid var(--ink);
  background-color: #fbfefd;
  background-image:
    radial-gradient(var(--line) 1px, transparent 1.2px),
    linear-gradient(var(--line), var(--line)),
    linear-gradient(var(--line), var(--line));
  background-size: 12px 12px, 1px 100%, 100% 1px;
  background-position: 0 0, center, center;
  background-repeat: repeat, no-repeat, no-repeat;
}
.preview.media { display: block; aspect-ratio: 16 / 9; min-height: 0; overflow: hidden; background: #0b0b08; }
.preview.media img, .preview.media video { display: block; width: 100%; height: 100%; object-fit: cover; }
.preview.media img { transition: transform .3s; }
a.preview.media:hover img { transform: scale(1.03); }
.card.wide .preview.media .label { top: 12px; bottom: auto; }
.card.wide .preview.media { aspect-ratio: auto; display: flex; align-items: center; min-height: 0; }
.card.wide .preview.media video { height: auto; }
.badge { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; padding: 4px; background: var(--paper); border: 2px solid var(--ink); }
.play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  padding-left: 4px;
  background: var(--coral);
  color: #fff;
  font-size: 22px;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .12s, box-shadow .12s;
}
a.preview.media:hover .play { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.icon { width: 88px; height: 88px; transition: transform .2s steps(2); }
.card:hover .icon { transform: translateY(-6px); }
.label { position: absolute; left: 12px; bottom: 12px; padding: 3px 9px; background: var(--paper); border: 2px solid var(--ink); font-weight: 700; font-size: 13px; letter-spacing: .04em; }
.strip { display: flex; justify-content: space-between; gap: 12px; padding: 4px 12px; font-size: 10.5px; letter-spacing: .06em; background: var(--strip); border-bottom: 2px solid var(--ink); }
.strip span:first-child { font-weight: 700; }
.body { padding: 14px 16px 16px; }
.body p { margin: 0 0 12px; }
.tags { list-style: none; padding: 0; margin: 0 0 4px; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font-size: 11px; padding: 1px 8px; border: 1.5px solid var(--ink); background: var(--mint); }
.tags.big { padding: 16px; gap: 8px; }
.tags.big li { font-size: 12px; padding: 3px 10px; }
.links { display: flex; gap: 18px; margin: 12px 0 0 !important; font-weight: 700; font-size: 13px; }
.links a { text-decoration: none; border-bottom: 2px solid var(--coral); }
.links a:hover { color: var(--coral); }

.two { display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; }
.timeline { margin: 0; padding: 16px 16px 4px; }
.timeline dt { font-size: 11px; letter-spacing: .06em; color: var(--muted); }
.timeline dd { margin: 2px 0 18px; }

.contact .big { font-size: 17px; font-weight: 500; max-width: 600px; }
.contact .btns { margin-top: 8px; }
.contact .btn { text-transform: none; letter-spacing: 0; }

footer { max-width: 1040px; margin: 0 auto; padding: 56px 16px 40px; font-size: 11px; color: var(--muted); letter-spacing: .06em; }

@media (max-width: 760px) {
  .hero-card { padding: 24px 20px 28px; }
  .hero-main { grid-template-columns: 1fr; gap: 24px; }
  .hero-side { border-left: 0; border-top: 2px solid var(--ink); padding: 20px 0 0; }
  .grid, .two { grid-template-columns: 1fr; }
  .card.wide { display: block; }
  .card.wide .preview { border-right: 0; border-bottom: 2px solid var(--ink); min-height: 190px; }
  .scene { height: 200px; }
  .top nav { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud-layer, .ripples { animation: none; }
  .fish-school { display: none; }
  .rod-wait, .bobber, .hooked, .lure { animation: none; }
  .rod-catch { display: none; }
  .btn, .icon { transition: none; }
  html { scroll-behavior: auto; }
}
