:root {
  --bg: #0c0c0c;
  --fg: #e6e1d6;
  --fg-bright: #f5f0e6;
  --muted: #7a746b;
  --dim: #4a453f;
  --accent: #d4926a;
  --rule: rgba(230, 225, 214, 0.08);
  --selection-fg: #0c0c0c;
  --code-bg: rgba(230, 225, 214, 0.07);

  --mono:
    "IBM Plex Mono", ui-monospace, "JetBrains Mono", "SF Mono", "Menlo",
    monospace;

  --measure: 78ch;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f5f0e6;
    --fg: #2a2620;
    --fg-bright: #0c0c0c;
    --muted: #6b665d;
    --dim: #b8b0a3;
    --accent: #b56d3f;
    --rule: rgba(42, 38, 32, 0.10);
    --selection-fg: #f5f0e6;
    --code-bg: rgba(42, 38, 32, 0.06);
  }
}

:root[data-theme="light"] {
  --bg: #f5f0e6;
  --fg: #2a2620;
  --fg-bright: #0c0c0c;
  --muted: #6b665d;
  --dim: #b8b0a3;
  --accent: #b56d3f;
  --rule: rgba(42, 38, 32, 0.10);
  --selection-fg: #f5f0e6;
  --code-bg: rgba(42, 38, 32, 0.06);
}

:root[data-theme="dark"] {
  --bg: #0c0c0c;
  --fg: #e6e1d6;
  --fg-bright: #f5f0e6;
  --muted: #7a746b;
  --dim: #4a453f;
  --accent: #d4926a;
  --rule: rgba(230, 225, 214, 0.08);
  --selection-fg: #0c0c0c;
  --code-bg: rgba(230, 225, 214, 0.07);
}

:not(:root)[lang="ko"] {
  display: none;
}

:root[data-lang="ko"] [lang="ko"] {
  display: revert;
}

:root[data-lang="ko"] [lang="en"] {
  display: none;
}

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

html {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings:
    "ss01",
    "ss02",
    "calt" 0;
}

@media (min-width: 768px) {
  html {
    font-size: 17px;
  }
}

body {
  min-height: 100vh;
  padding: 3rem 1.5rem 4rem;
}

@media (min-width: 768px) {
  body {
    padding: 5rem 3rem;
  }
}

main {
  max-width: var(--measure);
  margin: 0 auto;
}

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

ul {
  list-style: none;
}

p {
  font-weight: 400;
}

::selection {
  background: var(--accent);
  color: var(--selection-fg);
}

/* ---------- Avatar ---------- */

.avatar {
  display: block;
  width: 220px;
  height: 220px;
  object-fit: cover;
  border: 1px solid var(--rule);
  margin: 0 auto;
  margin-bottom: 4.25rem;
  filter: grayscale(0.15) contrast(1.02);
}

/* ---------- Prompt header ---------- */

.prompt {
  margin-bottom: 4rem;
}

.cmd {
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.cmd .user {
  color: var(--accent);
}
.cmd .host {
  color: var(--muted);
}
.cmd .dim {
  color: var(--dim);
}
.cmd .dollar {
  color: var(--muted);
  margin: 0 0.15ch;
}

.output .line {
  color: var(--fg);
  padding-left: 2.6ch;
  text-indent: -2.6ch;
}

.output .line + .line {
  margin-top: 0.15rem;
}

.caret {
  color: var(--dim);
  margin-right: 0.6ch;
}

.name {
  color: var(--fg-bright);
  font-weight: 500;
}

.status-dot {
  color: var(--accent);
  font-size: 0.7em;
  vertical-align: 0.18em;
  animation: pulse 2.4s ease-in-out infinite;
  display: inline-block;
  margin-left: -0.4ch;
}

.status-text {
  color: var(--muted);
}

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

/* ---------- Quick links ---------- */

.quick-links {
  display: flex;
  gap: 1.25rem;
  margin-top: 1.5rem;
  padding-left: 2.6ch;
}

.icon-link {
  color: var(--muted);
  display: inline-flex;
  transition:
    color 250ms var(--ease),
    transform 250ms var(--ease);
}

.icon-link:hover {
  color: var(--accent);
  transform: translateY(-1px);
}

.icon-link svg {
  display: block;
}

/* ---------- Sections ---------- */

.section {
  margin-bottom: 3rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 1ch;
  margin-bottom: 1.25rem;
  letter-spacing: 0.01em;
}

.section-title .rule {
  flex: 1;
  height: 1px;
  background: var(--rule);
  display: block;
}

/* ---------- Bio ---------- */

.bio {
  display: grid;
  gap: 0.85rem;
  max-width: 64ch;
}

.bio p {
  color: var(--fg);
  line-height: 1.65;
  padding-left: 2.6ch;
  text-indent: -2.6ch;
}

/* ---------- Lists ---------- */

.list {
  display: grid;
  gap: 1.25rem;
}

.list.compact {
  gap: 0.4rem;
}

.item {
  display: grid;
  grid-template-columns: 10ch 1fr;
  gap: 1.5ch;
  align-items: baseline;
}

.key {
  color: var(--muted);
  font-size: 0.875rem;
}

.entry-title {
  color: var(--fg);
  font-weight: 400;
  position: relative;
  display: inline-block;
}

.entry-title::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -2px;
  height: 1px;
  background: var(--fg);
  transition: right 350ms var(--ease);
}

.entry-title:hover {
  color: var(--fg-bright);
}

.entry-title:hover::after {
  right: 0;
}

.entry-desc {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 0.15rem;
  line-height: 1.6;
}

.entry-desc code {
  background: var(--code-bg);
  color: var(--fg);
  padding: 0.05em 0.45ch;
  border-radius: 2px;
  font-size: 0.95em;
}

.arrow {
  color: var(--dim);
  margin-right: 0.4ch;
  display: inline-block;
  transition:
    transform 300ms var(--ease),
    color 300ms var(--ease);
}

.entry-title:hover .arrow {
  color: var(--accent);
  transform: translateX(2px);
}

/* ---------- Footer ---------- */

footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.exit {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6ch;
  margin-bottom: 0.75rem;
}

.exit .dim {
  color: var(--dim);
}
.exit .dollar {
  color: var(--muted);
}

.cursor {
  display: inline-block;
  width: 0.6ch;
  height: 1em;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1.05s steps(2, jump-none) infinite;
}

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

.copy {
  color: var(--dim);
  font-size: 0.8rem;
}

/* ---------- Entrance ---------- */

.avatar,
.prompt,
.section,
footer {
  opacity: 0;
  transform: translateY(0.35rem);
  animation: rise 700ms var(--ease) forwards;
}

.avatar {
  animation-delay: 0ms;
}
.prompt {
  animation-delay: 140ms;
}
.section:nth-of-type(1) {
  animation-delay: 300ms;
}
.section:nth-of-type(2) {
  animation-delay: 400ms;
}
.section:nth-of-type(3) {
  animation-delay: 500ms;
}
.section:nth-of-type(4) {
  animation-delay: 600ms;
}
footer {
  animation-delay: 720ms;
}

@keyframes rise {
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .avatar,
  .prompt,
  .section,
  footer {
    opacity: 1;
    transform: none;
    animation: none;
  }
  .cursor,
  .status-dot {
    animation: none;
  }
  :root.theme-transition,
  :root.theme-transition * {
    transition: none !important;
  }
  .entry-title::after {
    transition: none;
  }
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.5rem;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition:
    color 250ms var(--ease),
    border-color 250ms var(--ease),
    transform 250ms var(--ease);
}

@media (min-width: 768px) {
  .theme-toggle {
    top: 1.5rem;
    right: 1.5rem;
  }
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.theme-toggle:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle svg {
  display: block;
}

/* Default (no explicit theme, OS dark or unknown): show sun = "switch to light" */
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }

/* OS prefers light, no explicit choice: show moon = "switch to dark" */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme]) .theme-toggle .icon-moon { display: block; }
}

/* Explicit light: show moon */
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* Explicit dark: show sun (covers OS=light + user picked dark) */
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Theme switch transition (added on click, removed 250ms later) ---------- */

.theme-transition,
.theme-transition * {
  transition:
    background-color 200ms var(--ease),
    color 200ms var(--ease),
    border-color 200ms var(--ease) !important;
}

/* ---------- Language toggle ---------- */

.lang-toggle {
  position: fixed;
  top: 1rem;
  right: 4rem;
  z-index: 10;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.5rem;
  min-width: 2.4rem;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    color 250ms var(--ease),
    border-color 250ms var(--ease),
    transform 250ms var(--ease);
}

@media (min-width: 768px) {
  .lang-toggle {
    top: 1.5rem;
    right: 4.5rem;
  }
}

.lang-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.lang-toggle:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

.lang-toggle .glyph-ko { display: none; }
.lang-toggle .glyph-en { display: inline; }

:root[data-lang="ko"] .lang-toggle .glyph-en { display: none; }
:root[data-lang="ko"] .lang-toggle .glyph-ko { display: inline; }
