/* ============================================================
   Tokens
   ============================================================ */
:root {
  color-scheme: light;
  --paper:  #F6F7F3;
  --surface: #FFFFFF;
  --ink:    #22282C;
  --muted:  #66707A;
  --note-muted: #4E5962;
  --jade:   #157A5B;
  --jade-deep: #0E5941;
  --on-accent: #FFFFFF;
  --butter: #FBEFC3;
  --sky:    #DCEAF7;
  --blush:  #F9E3E0;
  --line:   #DDE1DB;
  --interactive-line: #829088;
  --note-shadow: rgba(34, 40, 44, 0.08);
  --tape-bg: rgba(255, 255, 255, 0.55);
  --tape-border: rgba(34, 40, 44, 0.06);
  --tap-highlight: rgba(21, 122, 91, 0.18);

  --font-display: "Bricolage Grotesque", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-body: "Figtree", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;

  --w: min(1040px, 92vw);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #151A1C;
  --surface: #20272A;
  --ink: #ECF2EE;
  --muted: #AAB7B1;
  --note-muted: #B1BCB7;
  --jade: #62D6AD;
  --jade-deep: #8BE6C5;
  --on-accent: #0F1C18;
  --butter: #403A24;
  --sky: #263849;
  --blush: #462F35;
  --line: #66776F;
  --interactive-line: #66776F;
  --note-shadow: rgba(0, 0, 0, 0.3);
  --tape-bg: rgba(236, 242, 238, 0.12);
  --tape-border: rgba(236, 242, 238, 0.08);
  --tap-highlight: rgba(98, 214, 173, 0.2);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #151A1C;
    --surface: #20272A;
    --ink: #ECF2EE;
    --muted: #AAB7B1;
    --note-muted: #B1BCB7;
    --jade: #62D6AD;
    --jade-deep: #8BE6C5;
    --on-accent: #0F1C18;
    --butter: #403A24;
    --sky: #263849;
    --blush: #462F35;
    --line: #66776F;
    --interactive-line: #66776F;
    --note-shadow: rgba(0, 0, 0, 0.3);
    --tape-bg: rgba(236, 242, 238, 0.12);
    --tape-border: rgba(236, 242, 238, 0.08);
    --tap-highlight: rgba(98, 214, 173, 0.2);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

:lang(zh-Hant) body,
body:lang(zh-Hant) { letter-spacing: 0.01em; }

a { color: var(--jade); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a, button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: var(--tap-highlight);
}
a:hover { color: var(--jade-deep); }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--jade);
  outline-offset: 3px;
  border-radius: 4px;
}

h1, h2, h3 { text-wrap: balance; }

.skip-link {
  position: fixed;
  z-index: 1000;
  inset-block-start: 0.75rem;
  inset-inline-start: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  background: var(--jade);
  color: var(--on-accent);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  transform: translateY(calc(-100% - 1.5rem));
}

.skip-link:hover,
.skip-link:focus-visible {
  color: var(--on-accent);
}

.skip-link:focus-visible { transform: translateY(0); }

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  width: var(--w);
  margin: 0 auto;
  padding: 1.4rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}

.lang-toggle,
.theme-control,
.theme-cycle {
  display: inline-flex;
  align-items: center;
  height: 2.25rem;
  border: 1.5px solid var(--interactive-line);
  background: transparent;
  border-radius: 999px;
  color: var(--muted);
}

.lang-toggle {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.04em;
  padding: 0 0.9rem;
  text-decoration: none;
}

.theme-control { padding: 0.12rem; }

.theme-cycle {
  display: none;
  padding: 0.12rem;
  appearance: none;
  font: inherit;
  cursor: pointer;
}

.lang-toggle:hover,
.theme-control:hover,
.theme-control:focus-within,
.theme-cycle:hover {
  border-color: var(--jade);
}

.theme-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0.42rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-option.active {
  color: var(--on-accent);
  background: var(--jade);
}

.theme-cycle-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0.42rem;
  border-radius: 999px;
  color: var(--muted);
}

:root[data-theme-preference="system"] .theme-cycle-option[data-theme-icon="system"],
:root[data-theme-preference="light"] .theme-cycle-option[data-theme-icon="light"],
:root[data-theme-preference="dark"] .theme-cycle-option[data-theme-icon="dark"] {
  color: var(--on-accent);
  background: var(--jade);
}

.theme-option svg,
.theme-cycle-option svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toggle-opt { color: var(--muted); }
.toggle-opt.active { color: var(--jade); }
.toggle-sep { margin: 0 0.3rem; color: var(--line); }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  width: var(--w);
  margin: 0 auto;
  padding: 5.5rem 0 6rem;
}

.eyebrow {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--jade);
  margin: 0 0 0.6rem;
}

.hero-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3rem, 9vw, 6.2rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 0 0 1.4rem;
}

.hero-line {
  max-width: 34em;
  font-size: 1.2rem;
  color: var(--muted);
  margin: 0 0 2.2rem;
}

.hero-links { display: flex; gap: 0.7rem; flex-wrap: wrap; }

.social-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.65rem;
  height: 2.65rem;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--interactive-line);
  border-radius: 999px;
  text-decoration: none;
  transition: color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.social-icon-link:hover {
  color: var(--jade-deep);
  border-color: var(--jade);
  transform: translateY(-2px);
}

.social-icon-link svg {
  display: block;
  width: 1.2rem;
  height: 1.2rem;
}

/* ============================================================
   Sections
   ============================================================ */
.section {
  width: var(--w);
  margin: 0 auto;
  padding: 4rem 0;
  border-top: 1.5px solid var(--line);
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2.5rem;
  scroll-margin-top: 1.5rem;
}

.section-label h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0 0 0.4rem;
}

.section-sub {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.feed-link {
  display: inline-block;
  margin-top: 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.section-body { min-width: 0; }
.section-body p { margin: 0 0 1.1rem; max-width: 38em; }
.section-body p:last-child { margin-bottom: 0; }

/* ============================================================
   Signature: the noteboard (胡思亂想)
   ============================================================ */
.noteboard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.4rem;
}

.musing-status {
  color: var(--muted);
  font-size: 0.95rem;
}

.note {
  position: relative;
  scroll-margin-top: 1.5rem;
  padding: 1.5rem 1.25rem 1.25rem;
  border-radius: 4px;
  box-shadow: 0 6px 14px var(--note-shadow);
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
  transition: transform 180ms ease;
}
.note:nth-child(odd)  { transform: rotate(-1.2deg); }
.note:nth-child(even) { transform: rotate(1deg); }
.note:hover { transform: rotate(0deg) translateY(-3px); }
.note:target { outline: 2px solid var(--jade); outline-offset: 4px; }

/* tape strip */
.note::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 58px;
  height: 18px;
  transform: translateX(-50%) rotate(-2deg);
  background: var(--tape-bg);
  border: 1px solid var(--tape-border);
}

.note-butter { background: var(--butter); }
.note-sky    { background: var(--sky); }
.note-blush  { background: var(--blush); }

.note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.45rem;
}

.note time {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--note-muted);
}

.note-permalink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  color: var(--note-muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  opacity: 0.7;
}
.note-permalink:hover { color: var(--jade-deep); opacity: 1; }

.note-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 0.55rem;
}
.note p { margin: 0; }
.note .note-attribution {
  margin-top: 0.75rem;
  color: var(--note-muted);
  font-size: 0.85rem;
  text-align: right;
}

/* ============================================================
   GitHub repos
   ============================================================ */
.repo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.2rem;
}

.repo-status {
  color: var(--muted);
  font-size: 0.95rem;
}

.repo-card {
  display: block;
  border: 1.5px solid var(--interactive-line);
  border-radius: 10px;
  padding: 1.2rem 1.3rem;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
  overflow-wrap: anywhere;
  transition: border-color 160ms ease, transform 160ms ease;
}
.repo-card:hover {
  border-color: var(--jade);
  transform: translateY(-2px);
  color: var(--ink);
}

.repo-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0 0 0.4rem;
  color: var(--jade-deep);
}

.repo-card p {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.8rem;
  line-height: 1.55;
}

.repo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}
.repo-meta .lang-chip::before {
  content: "";
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--jade);
  margin-right: 0.35rem;
}

.repo-cta { color: var(--jade-deep); }

/* ============================================================
   Experience list
   ============================================================ */
.experience-list {
  margin: 0;
  padding-left: 1.25rem;
}

.experience-item {
  padding-left: 0.25rem;
}

.experience-item + .experience-item { margin-top: 1rem; }
.experience-item::marker { color: var(--jade); }

.experience-item h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  margin: 0 0 0.15rem;
}
.experience-meta { font-size: 0.85rem; color: var(--muted); margin: 0; }

/* ============================================================
   Footer
   ============================================================ */
.footer {
  width: var(--w);
  margin: 0 auto;
  padding: 3rem 0 2.5rem;
  border-top: 1.5px solid var(--line);
  font-size: 0.85rem;
  color: var(--muted);
}
.footer p { margin: 0; }

/* ============================================================
   Error page
   ============================================================ */
.error-main {
  width: var(--w);
  min-height: calc(100vh - 8rem);
  margin: 0 auto;
  display: grid;
  align-content: center;
  justify-items: start;
  padding: 4rem 0 7rem;
}

.error-code {
  margin: 0 0 0.8rem;
  color: var(--jade);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.error-title {
  max-width: 9em;
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: clamp(2.7rem, 8vw, 5.5rem);
  line-height: 1.05;
}

.error-copy {
  max-width: 32em;
  margin: 0 0 1.8rem;
  color: var(--muted);
}

.home-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: var(--jade);
  color: var(--on-accent);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  transition: background 160ms ease, transform 160ms ease;
}

.home-button:hover {
  background: var(--jade-deep);
  color: var(--on-accent);
  transform: translateY(-2px);
}

/* ============================================================
   Responsive & motion
   ============================================================ */
@media (max-width: 720px) {
  .theme-control { display: none; }
  .theme-cycle { display: inline-flex; }
  .section { grid-template-columns: 1fr; gap: 1.4rem; padding: 3rem 0; }
  .hero { padding: 3.5rem 0 4rem; }
}

@media (max-width: 380px) {
  .topbar-actions { gap: 0.4rem; }
  .lang-toggle { padding: 0 0.65rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .note, .repo-card, .social-icon-link, .home-button { transition: none; }
  .note:nth-child(odd), .note:nth-child(even) { transform: none; }
  .social-icon-link:hover, .home-button:hover { transform: none; }
}
