/* =========================================================
   Glenn Yu — personal site
   Light/Dark via prefers-color-scheme
   ========================================================= */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --fg: #111418;
  --fg-soft: #5b6470;
  --fg-muted: #8b94a1;
  --border: #e6e8ec;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --code-bg: #f3f4f6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --container: 720px;
  --radius: 10px;
  --font-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
               "Apple SD Gothic Neo", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --bg-soft: #161b22;
    --fg: #e6edf3;
    --fg-soft: #a8b3bf;
    --fg-muted: #768390;
    --border: #232a33;
    --accent: #6ea8ff;
    --accent-hover: #95bdff;
    --code-bg: #161b22;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

/* Manual theme overrides (set via Cmd+K palette) */
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --fg: #111418;
  --fg-soft: #5b6470;
  --fg-muted: #8b94a1;
  --border: #e6e8ec;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --code-bg: #f3f4f6;
}
:root[data-theme="dark"] {
  --bg: #0e1116;
  --bg-soft: #161b22;
  --fg: #e6edf3;
  --fg-soft: #a8b3bf;
  --fg-muted: #768390;
  --border: #232a33;
  --accent: #6ea8ff;
  --accent-hover: #95bdff;
  --code-bg: #161b22;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-hover); }

/* Layout */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

.site-main {
  padding: 56px 0 80px;
  min-height: calc(100vh - 200px);
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
  font-weight: 700;
  font-size: 1.05rem;
}
.site-brand:hover { color: var(--fg); }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg);
  font-weight: 800;
  font-size: 0.95rem;
}
.site-nav { display: flex; gap: 22px; }
.site-nav a {
  color: var(--fg-soft);
  font-weight: 500;
  font-size: 0.95rem;
}
.site-nav a:hover { color: var(--fg); }

/* Hero */
.hero {
  padding: 36px 0 56px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 56px;
}
.hero-eyebrow {
  margin: 0 0 14px;
  color: var(--fg-soft);
  font-size: 0.95rem;
  font-weight: 500;
}
.hero-title {
  margin: 0 0 18px;
  font-size: clamp(1.85rem, 4.2vw, 2.6rem);
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.hero-desc {
  margin: 0 0 28px;
  color: var(--fg-soft);
  font-size: 1.05rem;
  max-width: 540px;
}
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.btn-primary {
  background: var(--fg);
  color: var(--bg);
}
.btn-primary:hover {
  background: var(--fg);
  color: var(--bg);
  opacity: 0.88;
}
.btn-ghost {
  border-color: var(--border);
  color: var(--fg);
  background: transparent;
}
.btn-ghost:hover {
  border-color: var(--fg-muted);
  color: var(--fg);
}

/* Section */
.section-header {
  margin-bottom: 24px;
}
.section-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

/* Post list */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-item {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}
.post-item:first-child { padding-top: 0; }
.post-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  color: var(--fg);
  font-weight: 600;
  font-size: 1.1rem;
}
.post-link:hover .post-item-title { color: var(--accent); }
.post-item-title { transition: color 0.15s ease; }
.post-item-date {
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.post-item-excerpt {
  margin: 6px 0 0;
  color: var(--fg-soft);
  font-size: 0.95rem;
  line-height: 1.6;
}

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--fg-muted);
}

/* Post page */
.post-header {
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.post-title {
  margin: 0 0 14px;
  font-size: clamp(1.7rem, 3.5vw, 2.2rem);
  line-height: 1.3;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.post-meta {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.9rem;
}
.post-meta .dot { margin: 0 8px; }
.tag { color: var(--accent); }

.post-content {
  font-size: 1.02rem;
  line-height: 1.8;
}
.post-content h2 {
  margin-top: 2.2em;
  margin-bottom: 0.8em;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.post-content h3 {
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  font-size: 1.15rem;
  font-weight: 700;
}
.post-content p { margin: 1em 0; }
.post-content ul, .post-content ol { padding-left: 1.4em; margin: 1em 0; }
.post-content li { margin: 0.3em 0; }
.post-content blockquote {
  margin: 1.4em 0;
  padding: 4px 18px;
  border-left: 3px solid var(--accent);
  color: var(--fg-soft);
  background: var(--bg-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--code-bg);
  color: var(--fg);
}
.post-content pre {
  margin: 1.4em 0;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--code-bg);
  overflow-x: auto;
  font-size: 0.92em;
  line-height: 1.6;
  border: 1px solid var(--border);
}
.post-content pre code {
  padding: 0;
  background: transparent;
  border-radius: 0;
}
.post-content hr {
  margin: 2.6em 0;
  border: 0;
  border-top: 1px solid var(--border);
}
.post-content img {
  margin: 1.4em auto;
  border-radius: var(--radius);
}

.post-footer {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.back-link {
  display: inline-flex;
  align-items: center;
  color: var(--fg-soft);
  font-weight: 500;
  font-size: 0.95rem;
}
.back-link:hover { color: var(--accent); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  background: var(--bg-soft);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-meta, .footer-links {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.88rem;
}
.footer-links a { color: var(--fg-soft); }
.footer-links a:hover { color: var(--accent); }
.footer-links .dot { margin: 0 8px; color: var(--fg-muted); }

/* Responsive */
@media (max-width: 540px) {
  .header-inner { height: 56px; }
  .site-nav { gap: 14px; font-size: 0.9rem; }
  .post-link {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* =========================================================
   Boot intro (logcat style)
   ========================================================= */
html.boot-pending body > .site-header,
html.boot-pending body > .site-main,
html.boot-pending body > .site-footer { visibility: hidden; }

.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #07090c;
  color: #3ddc84; /* Android green */
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: opacity 0.28s ease;
}
.boot-overlay.boot-fade { opacity: 0; pointer-events: none; }

.boot-screen {
  width: min(720px, 100%);
  border: 1px solid #1c2530;
  border-radius: 10px;
  background: #0a0d12;
  box-shadow: 0 0 0 1px rgba(61, 220, 132, 0.08), 0 30px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.boot-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: #11161d;
  border-bottom: 1px solid #1c2530;
}
.boot-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2a323d;
}
.boot-dot:nth-child(1) { background: #ff5f57; }
.boot-dot:nth-child(2) { background: #febc2e; }
.boot-dot:nth-child(3) { background: #28c840; }
.boot-title {
  margin-left: 10px;
  font-size: 0.78rem;
  color: #6b7785;
  letter-spacing: 0.02em;
}
.boot-log {
  margin: 0;
  padding: 18px 20px 8px;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: #3ddc84;
  min-height: 220px;
}
.boot-skip {
  margin: 0;
  padding: 12px 20px 18px;
  font-size: 0.75rem;
  color: #4a5564;
  letter-spacing: 0.02em;
}

/* =========================================================
   Command palette (Cmd+K)
   ========================================================= */
.palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(8, 10, 14, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
  animation: paletteFade 0.16s ease;
}
.palette-overlay[hidden] { display: none; }
@keyframes paletteFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.palette {
  width: min(560px, 100%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.25), 0 8px 20px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  animation: palettePop 0.18s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes palettePop {
  from { transform: translateY(-8px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.palette-input {
  border: 0;
  outline: 0;
  width: 100%;
  padding: 18px 20px;
  font: inherit;
  font-size: 1.05rem;
  background: transparent;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
}
.palette-input::placeholder { color: var(--fg-muted); }
.palette-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
}
.palette-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--fg);
}
.palette-item.is-active { background: var(--bg-soft); }
.palette-item:hover { background: var(--bg-soft); }
.palette-kind {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-align: center;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.palette-kind-page { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.palette-kind-post { color: #c084fc; border-color: rgba(192, 132, 252, 0.35); }
.palette-kind-cmd  { color: #3ddc84; border-color: rgba(61, 220, 132, 0.35); }
.palette-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-sub {
  color: var(--fg-muted);
  font-size: 0.82rem;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.palette-empty {
  list-style: none;
  padding: 28px;
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.95rem;
}
.palette-hint {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 0.78rem;
  color: var(--fg-muted);
}
.palette-hint kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 1px 6px;
  margin: 0 3px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg-soft);
}

/* =========================================================
   Toast
   ========================================================= */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9500;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast-show { opacity: 1; transform: translateY(0); }

/* =========================================================
   CRT mode (Konami easter egg)
   ========================================================= */
@keyframes crtFlicker {
  0%, 100% { opacity: 1; }
  3% { opacity: 0.92; }
  7% { opacity: 0.96; }
  50% { opacity: 0.98; }
  88% { opacity: 0.94; }
}
body.crt-mode {
  animation: crtFlicker 0.4s steps(2) infinite;
  filter: contrast(1.05) saturate(1.15) hue-rotate(-4deg);
  text-shadow: 0 0 1px rgba(61, 220, 132, 0.4);
}
body.crt-mode::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8000;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.18) 0px,
      rgba(0, 0, 0, 0.18) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.35) 100%);
  mix-blend-mode: multiply;
}

/* Reduce motion users — skip animations */
@media (prefers-reduced-motion: reduce) {
  .palette { animation: none; }
  .palette-overlay { animation: none; }
  .boot-overlay { transition: none; }
  body.crt-mode { animation: none; }
}

/* Palette trigger button in header */
.palette-trigger {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  margin-left: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-soft);
  font: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.palette-trigger:hover {
  color: var(--fg);
  border-color: var(--fg-muted);
}
.palette-trigger kbd {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}
@media (max-width: 540px) {
  .palette-trigger { display: none; }
}

/* Projects section (home) */
.projects { margin-bottom: 56px; }
.project-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--fg);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.project-card:hover {
  border-color: var(--fg-muted);
  color: var(--fg);
  transform: translateY(-1px);
}
.project-card:hover .project-arrow { color: var(--accent); transform: translateX(2px); }
.project-emoji {
  font-size: 1.8rem;
  line-height: 1;
  text-align: center;
}
.project-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.project-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.project-title small {
  font-weight: 500;
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin-left: 6px;
}
.project-desc {
  color: var(--fg-soft);
  font-size: 0.92rem;
  line-height: 1.55;
}
.project-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.project-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-muted);
  letter-spacing: 0.02em;
}
.project-arrow {
  color: var(--fg-muted);
  font-size: 1.1rem;
  transition: transform 0.15s ease, color 0.15s ease;
}

/* Post: reading time meta */
.reading-time { color: var(--fg-soft); font-variant-numeric: tabular-nums; }

/* Post: code copy button */
.post-content pre { position: relative; }
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg-soft);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.post-content pre:hover .copy-btn,
.copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover {
  color: var(--fg);
  border-color: var(--fg-muted);
}
.copy-btn.is-copied {
  color: #3ddc84;
  border-color: rgba(61, 220, 132, 0.45);
}
@media (max-width: 540px) {
  .copy-btn { opacity: 1; }
}

/* Post: heading anchors */
.post-content h2,
.post-content h3 {
  position: relative;
  scroll-margin-top: 80px;
}
.heading-anchor {
  display: inline-block;
  margin-left: 8px;
  color: var(--fg-muted);
  opacity: 0;
  text-decoration: none;
  font-weight: 400;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.heading-anchor:hover { color: var(--accent); }
.post-content h2:hover .heading-anchor,
.post-content h3:hover .heading-anchor,
.heading-anchor:focus-visible { opacity: 1; }

/* Comments (giscus) */
.post-comments {
  margin-top: 56px;
  padding-top: 36px;
  border-top: 1px solid var(--border);
}
.comments-title {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.comments-hint {
  margin: 0 0 20px;
  color: var(--fg-muted);
  font-size: 0.9rem;
}
.giscus, .giscus-frame { width: 100%; }
.giscus-frame { color-scheme: normal; }

/* =========================================================
   404 page — logcat-style fatal exception
   ========================================================= */
.error-page {
  display: flex;
  flex-direction: column;
  gap: 36px;
  padding: 16px 0 40px;
}
.crash-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0a0d12;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.crash-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: #11161d;
  border-bottom: 1px solid #1c2530;
}
.crash-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.crash-dot-red { background: #ff5f57; }
.crash-dot-yellow { background: #febc2e; }
.crash-dot-green { background: #28c840; }
.crash-bar-title {
  margin-left: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #6b7785;
  letter-spacing: 0.02em;
}
.crash-body {
  padding: 20px 22px;
  overflow-x: auto;
}
.crash-stack {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.7;
  color: #a8b3bf;
  white-space: pre;
}
.crash-line { display: block; }
.crash-line-fatal { color: #ff5f57; font-weight: 700; }
.crash-line-meta { color: #6b7785; }
.crash-line-exc { color: #febc2e; }
.crash-line-exc .crash-msg { color: #ff8c87; }
.crash-line-caused { color: #d97757; margin-top: 6px; }
.crash-pid { color: #3ddc84; }

#bad-path {
  color: #3ddc84;
  background: rgba(61, 220, 132, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
}

.error-actions {
  text-align: center;
  padding: 12px 0 20px;
}
.error-title {
  margin: 0 0 12px;
  font-size: clamp(1.6rem, 3.5vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.error-desc {
  margin: 0 auto 24px;
  max-width: 480px;
  color: var(--fg-soft);
  font-size: 1rem;
}
.error-cta {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.error-cta .palette-trigger {
  height: 40px;
  padding: 0 16px;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}
.error-hint {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin: 0;
}
.error-hint kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px 6px;
  margin: 0 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--fg-soft);
}

@media (max-width: 540px) {
  .crash-stack { font-size: 0.78rem; }
  .crash-body { padding: 14px; }
}
