@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Noto+Sans+SC:wght@400;700&display=swap');

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

/* ========== Theme ========== */
:root {
  --bg: #fafafa;
  --fg: #111;
  --muted: #666;
  --border: #ddd;
}

html[data-theme="dark"] {
  --bg: #111;
  --fg: #f5f5f5;
  --muted: #999;
  --border: #333;
}

html[data-theme="light"] {
  --bg: #fafafa;
  --fg: #111;
  --muted: #666;
  --border: #ddd;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #111;
    --fg: #f5f5f5;
    --muted: #999;
    --border: #333;
  }
}

/* ========== Base ========== */
body {
  font-family: "JetBrains Mono", "Cascadia Code", "Fira Code", "SF Mono", "Menlo", "Consolas", "DejaVu Sans Mono", "Liberation Mono", "Roboto", "PingFang SC", "Microsoft YaHei", "WenQuanYi Micro Hei", "Noto Sans SC", monospace, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ========== Layout ========== */
main {
  padding: 3rem 2rem;
  max-width: 480px;
  width: 100%;
  text-align: left;
  position: relative;
  z-index: 1;
}

/* ========== Floppy Decoration ========== */
.floppy-bg {
  --focus-x: 50%;
  --focus-y: 50%;
  position: fixed;
  right: 0;
  top: 50%;
  transform: translate(30%, -50%);
  width: 60vh;
  height: 60vh;
  color: var(--fg);
  pointer-events: none;
  z-index: 0;
}

.floppy-bg svg {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.floppy-soft {
  opacity: 0.06;
  filter: grayscale() saturate(0) brightness(1.9) contrast(0.55);
}

.floppy-color {
  opacity: 0.3;
  -webkit-mask-image: radial-gradient(
    circle at var(--focus-x) var(--focus-y),
    rgba(0,0,0,0.6) 0%,
    rgba(0,0,0,0.5) 18%,
    rgba(0,0,0,0.25) 42%,
    rgba(0,0,0,0.04) 62%,
    transparent 76%
  );
  mask-image: radial-gradient(
    circle at var(--focus-x) var(--focus-y),
    rgba(0,0,0,0.6) 0%,
    rgba(0,0,0,0.5) 18%,
    rgba(0,0,0,0.25) 42%,
    rgba(0,0,0,0.04) 62%,
    transparent 76%
  );
}

/* ========== Typography ========== */
.terminal-name {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.prompt {
  color: var(--fg);
  font-weight: 700;
}

.cmd {
  color: var(--muted);
}

.name {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.name a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--border);
  transition: border-color 0.2s;
}

.name a:hover {
  border-color: var(--fg);
}

.profession {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 2.5rem;
  line-height: 1.7;
  min-height: 1.7em;
}

.cursor {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ========== Links ========== */
.links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

.link-item {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.95rem;
  transition: opacity 0.2s;
  width: fit-content;
}

.link-item:hover {
  opacity: 0.6;
}

.link-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ========== Blog Menu (Desktop) ========== */
.blog-link {
  display: inline-block;
  color: var(--fg);
  text-decoration: none;
  font-family: inherit;
  font-size: 0.95rem;
  border: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
  background: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.blog-link:hover {
  opacity: 0.6;
}

.blog-wrapper {
  position: relative;
  display: inline-block;
}

.blog-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  min-width: 180px;
  z-index: 10;
}

.blog-menu.open {
  display: block;
}

.blog-menu a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.15s;
}

.blog-menu a:hover {
  background: var(--border);
}

/* ========== Blog Dialog (Mobile) ========== */
.blog-dialog {
  display: none;
  position: fixed;
  inset: 0;
  margin: auto;
  border: none;
  background: none;
  padding: 0;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
}

.blog-dialog[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.blog-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.blog-dialog-inner {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1.5rem;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.blog-dialog-title {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.blog-dialog a {
  display: block;
  padding: 0.6rem 1rem;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  text-align: center;
  transition: background 0.15s;
}

.blog-dialog a:hover {
  background: var(--border);
}

.blog-dialog-close {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.15s;
}

.blog-dialog-close:hover {
  color: var(--fg);
}

/* ========== Redirect Toast (Desktop) ========== */
.redirect-toast {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.6rem 1.2rem;
  z-index: 100;
  min-width: 260px;
  opacity: 0;
  pointer-events: none;
}

.redirect-toast.show {
  display: block;
  pointer-events: auto;
  animation: toast-in 0.25s ease-out forwards;
}

.redirect-toast.hiding {
  display: block;
  animation: toast-out 0.2s ease-in forwards;
}

@keyframes toast-in {
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
}

/* ========== Redirect Dialog (Mobile) ========== */
.redirect-dialog {
  display: none;
  position: fixed;
  inset: 0;
  margin: auto;
  border: none;
  background: none;
  padding: 0;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
}

.redirect-dialog[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.redirect-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.redirect-dialog-inner {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1.5rem;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.redirect-dialog-title {
  font-size: 0.9rem;
  color: var(--fg);
  text-align: center;
}

.redirect-dialog-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.redirect-dialog-go {
  padding: 0.5rem;
  background: var(--fg);
  border: 1px solid var(--fg);
  color: var(--bg);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.redirect-dialog-go:hover {
  opacity: 0.8;
}

.redirect-dialog-close {
  padding: 0.5rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.15s;
}

.redirect-dialog-close:hover {
  color: var(--fg);
}

/* ========== Progress Bar (Shared) ========== */
.redirect-progress {
  width: 100%;
  height: 3px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.redirect-progress-bar {
  width: 0%;
  height: 100%;
  background: var(--fg);
  transition: width 0.1s linear;
}

.redirect-toast-text {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}



/* ========== Footer ========== */
.footer {
  margin-top: 3rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.theme-switcher {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.theme-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.7rem;
  transition: color 0.2s, border-color 0.2s;
}

.theme-btn:hover {
  color: var(--fg);
  border-color: var(--fg);
}

.theme-btn.active {
  color: var(--fg);
  border-color: var(--fg);
}

/* ========== Pixel Effects ========== */
.px {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  background: var(--fg);
}

.px-snow {
  opacity: 0;
  animation: snow-drift var(--life) linear forwards;
}

.px-burst {
  opacity: 0.7;
  animation: burst-fade var(--life) ease-out forwards;
}

.px-trail {
  opacity: 0.55;
  animation: trail-fade var(--life) ease-out forwards;
}

@keyframes snow-drift {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  20% {
    opacity: 0.4;
    transform: scale(1);
  }
  80% {
    opacity: 0.3;
  }
  100% {
    opacity: 0;
    transform: scale(0.8);
  }
}

@keyframes burst-fade {
  0% {
    opacity: 0.75;
    transform: scale(1);
  }
  60% {
    opacity: 0.4;
  }
  100% {
    opacity: 0;
    transform: scale(0.2);
  }
}

@keyframes trail-fade {
  0% {
    opacity: 0.55;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.25);
  }
}

/* ========== Responsive (Mobile) ========== */
@media (max-width: 640px) {
  main {
    text-align: center;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  .content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 1.5rem;
  }

  .floppy-bg {
    position: fixed;
    right: -60px;
    top: 50%;
    transform: translateY(-50%);
    width: 280px;
    height: 280px;
  }

  .floppy-soft {
    opacity: 0.04;
  }

  .links {
    align-items: center;
  }

  .link-item {
    width: auto;
  }

  .blog-wrapper {
    display: inline-block;
  }

  .blog-menu {
    display: none !important;
  }

  .footer {
    padding: 1.5rem;
  }

  .theme-switcher {
    justify-content: center;
  }
}

/* ========== Reduced Motion ========== */
@media (prefers-reduced-motion: reduce) {
  .floppy-color {
    mask-image: radial-gradient(
      circle at 50% 50%,
      rgba(0,0,0,0.6) 0%,
      rgba(0,0,0,0.5) 18%,
      rgba(0,0,0,0.25) 42%,
      rgba(0,0,0,0.04) 62%,
      transparent 76%
    );
  }

  .px {
    animation: none !important;
  }
}
