/* =========================================================
   layout / motion tokens (theme-agnostic)
   ========================================================= */
:root {
  --max: 1100px;
  --pad: clamp(1.25rem, 4vw, 3rem);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* =========================================================
   themes — gruvbox-dark is the default (applied to :root so
   the page renders even before JS sets data-theme).
   ========================================================= */
:root,
[data-theme="gruvbox-dark"] {
  --bg0-h: #1d2021;
  --bg0:   #282828;
  --bg1:   #3c3836;
  --bg2:   #504945;
  --bg3:   #665c54;
  --bg4:   #7c6f64;

  --fg0:   #fbf1c7;
  --fg1:   #ebdbb2;
  --fg2:   #d5c4a1;
  --fg3:   #bdae93;
  --fg4:   #a89984;

  --gray:   #928374;
  --red:    #fb4934;
  --green:  #b8bb26;
  --yellow: #fabd2f;
  --blue:   #83a598;
  --purple: #d3869b;
  --aqua:   #8ec07c;
  --orange: #fe8019;

  --on-accent: #1d2021;
  --nav-bg: rgba(29, 32, 33, 0.72);
  --glow-1: rgba(254, 128, 25, 0.06);
  --glow-2: rgba(131, 165, 152, 0.05);
}

[data-theme="gruvbox-light"] {
  --bg0-h: #f9f5d7;
  --bg0:   #fbf1c7;
  --bg1:   #ebdbb2;
  --bg2:   #d5c4a1;
  --bg3:   #bdae93;
  --bg4:   #a89984;

  --fg0:   #282828;
  --fg1:   #3c3836;
  --fg2:   #504945;
  --fg3:   #665c54;
  --fg4:   #7c6f64;

  --gray:   #928374;
  --red:    #9d0006;
  --green:  #79740e;
  --yellow: #b57614;
  --blue:   #076678;
  --purple: #8f3f71;
  --aqua:   #427b58;
  --orange: #af3a03;

  --on-accent: #f9f5d7;
  --nav-bg: rgba(249, 245, 215, 0.78);
  --glow-1: rgba(175, 58, 3, 0.07);
  --glow-2: rgba(66, 123, 88, 0.06);
}

[data-theme="nord"] {
  --bg0-h: #2e3440;
  --bg0:   #3b4252;
  --bg1:   #434c5e;
  --bg2:   #4c566a;
  --bg3:   #5e6779;
  --bg4:   #6f7a8e;

  --fg0:   #eceff4;
  --fg1:   #e5e9f0;
  --fg2:   #d8dee9;
  --fg3:   #c5ccd6;
  --fg4:   #8a93a4;

  --gray:   #6c7689;
  --red:    #bf616a;
  --green:  #a3be8c;
  --yellow: #ebcb8b;
  --blue:   #88c0d0;
  --purple: #b48ead;
  --aqua:   #8fbcbb;
  --orange: #d08770;

  --on-accent: #2e3440;
  --nav-bg: rgba(46, 52, 64, 0.75);
  --glow-1: rgba(208, 135, 112, 0.06);
  --glow-2: rgba(136, 192, 208, 0.05);
}

[data-theme="tokyo-night"] {
  --bg0-h: #1a1b26;
  --bg0:   #1f2335;
  --bg1:   #292e42;
  --bg2:   #414868;
  --bg3:   #545c7e;
  --bg4:   #737aa2;

  --fg0:   #c0caf5;
  --fg1:   #a9b1d6;
  --fg2:   #9aa5ce;
  --fg3:   #737aa2;
  --fg4:   #565f89;

  --gray:   #565f89;
  --red:    #f7768e;
  --green:  #9ece6a;
  --yellow: #e0af68;
  --blue:   #7aa2f7;
  --purple: #bb9af7;
  --aqua:   #7dcfff;
  --orange: #ff9e64;

  --on-accent: #1a1b26;
  --nav-bg: rgba(26, 27, 38, 0.75);
  --glow-1: rgba(255, 158, 100, 0.06);
  --glow-2: rgba(122, 162, 247, 0.05);
}

[data-theme="catppuccin"] {
  --bg0-h: #11111b;
  --bg0:   #1e1e2e;
  --bg1:   #313244;
  --bg2:   #45475a;
  --bg3:   #585b70;
  --bg4:   #6c7086;

  --fg0:   #cdd6f4;
  --fg1:   #bac2de;
  --fg2:   #a6adc8;
  --fg3:   #9399b2;
  --fg4:   #7f849c;

  --gray:   #9399b2;
  --red:    #f38ba8;
  --green:  #a6e3a1;
  --yellow: #f9e2af;
  --blue:   #89b4fa;
  --purple: #cba6f7;
  --aqua:   #94e2d5;
  --orange: #fab387;

  --on-accent: #11111b;
  --nav-bg: rgba(17, 17, 27, 0.75);
  --glow-1: rgba(250, 179, 135, 0.06);
  --glow-2: rgba(137, 180, 250, 0.05);
}

/* =========================================================
   reset
   ========================================================= */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg0-h);
  color: var(--fg1);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease);
}

body {
  background-image:
    radial-gradient(1200px 600px at 80% -10%, var(--glow-1), transparent 60%),
    radial-gradient(900px 600px at -10% 30%, var(--glow-2), transparent 60%);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--yellow);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
a:hover { color: var(--orange); }

ul { list-style: none; padding: 0; margin: 0; }

img { max-width: 100%; display: block; }

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

/* custom scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg0-h); }
::-webkit-scrollbar-thumb { background: var(--bg2); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--bg3); }

/* =========================================================
   nav
   ========================================================= */
.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem var(--pad);
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--bg1);
  transition: background-color 0.35s var(--ease), border-color 0.35s var(--ease);
}
.nav__logo { margin-right: auto; }

.nav__logo {
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nav__links {
  display: flex;
  gap: 1.4rem;
  font-size: 0.9rem;
}
.nav__links a {
  color: var(--fg3);
  position: relative;
}
.nav__links a::before { content: '·'; color: var(--gray); margin-right: 6px; }
.nav__links a:hover { color: var(--yellow); }

/* theme switcher */
.theme-switch {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-left: 0.4rem;
}
.theme-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--bg3);
  background: transparent;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.18s var(--ease),
              border-color 0.18s var(--ease),
              box-shadow 0.18s var(--ease);
}
.theme-dot:hover { transform: scale(1.18); border-color: var(--fg4); }
.theme-dot:focus-visible {
  outline: none;
  border-color: var(--yellow);
}
.theme-dot.is-active {
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--yellow) 35%, transparent);
}
.theme-dot[data-theme="gruvbox-dark"]  { background: linear-gradient(135deg, #282828 50%, #fe8019 50%); }
.theme-dot[data-theme="gruvbox-light"] { background: linear-gradient(135deg, #fbf1c7 50%, #af3a03 50%); }
.theme-dot[data-theme="nord"]          { background: linear-gradient(135deg, #2e3440 50%, #88c0d0 50%); }
.theme-dot[data-theme="tokyo-night"]   { background: linear-gradient(135deg, #1a1b26 50%, #7aa2f7 50%); }
.theme-dot[data-theme="catppuccin"]    { background: linear-gradient(135deg, #1e1e2e 50%, #cba6f7 50%); }

@media (max-width: 640px) {
  .nav { padding: 0.7rem 1rem; gap: 0.6rem; }
  .nav__logo { font-size: 0.85rem; }
  .nav__links {
    gap: 0.7rem;
    font-size: 0.78rem;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    max-width: 50vw;
    padding-right: 0.25rem;
  }
  .nav__links::-webkit-scrollbar { display: none; }
  .nav__links a { white-space: nowrap; }
  .nav__links a::before { display: none; }
  .theme-switch { gap: 0.3rem; margin-left: 0.3rem; flex-shrink: 0; }
  .theme-dot { width: 14px; height: 14px; }
}

/* =========================================================
   hero
   ========================================================= */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 7rem var(--pad) 7rem;
  position: relative;
  gap: 0.9rem;
}

.hero__meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.8rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.hero__meta .hero__date { color: var(--aqua); }
.hero__meta .hero__loc::before { content: '· '; color: var(--gray); }

.hero__canvas-wrap {
  width: 100%;
  max-width: 1100px;
  height: clamp(220px, 40vh, 440px);
  position: relative;
}

#pixel-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.hero__sub {
  margin: 0.5rem 0 0;
  color: var(--fg3);
  font-size: clamp(0.95rem, 1.3vw, 1.05rem);
  letter-spacing: 0.04em;
}
.cursor-prompt {
  color: var(--green);
  margin-right: 0.5rem;
  font-weight: 700;
}

.hero__cta {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 0.7rem 1.2rem;
  border: 1px solid var(--bg3);
  background: transparent;
  color: var(--fg1);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  letter-spacing: 0.04em;
}
.btn:hover {
  background: var(--bg1);
  border-color: var(--fg4);
  color: var(--fg0);
  transform: translateY(-1px);
}
.btn--primary {
  background: var(--yellow);
  color: var(--on-accent);
  border-color: var(--yellow);
  font-weight: 700;
}
.btn--primary:hover {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--on-accent);
}

.hero__scroll {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  color: var(--gray);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.hero__scroll-line {
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, var(--gray), transparent);
  position: relative;
  overflow: hidden;
}
.hero__scroll-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--yellow);
  animation: scrollPulse 2.2s var(--ease) infinite;
}
@keyframes scrollPulse {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

@media (max-height: 640px) {
  .hero { padding: 5rem var(--pad) 5rem; }
  .hero__scroll { display: none; }
}

/* =========================================================
   sections
   ========================================================= */
.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: 6rem var(--pad) 4rem;
  position: relative;
}

.section__head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}
.section__num {
  color: var(--orange);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  font-weight: 700;
}
.section__title {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  color: var(--fg0);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.section__hint {
  color: var(--gray);
  font-size: 0.85rem;
  margin: 0 0 0 auto;
}
.section__hint code {
  background: var(--bg1);
  color: var(--green);
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
}

/* about */
.about__grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2.5rem;
  align-items: center;
}
@media (max-width: 800px) {
  .about__grid { grid-template-columns: 1fr; }
}

.about__text p {
  margin: 0 0 1rem;
  color: var(--fg2);
  font-size: 1.02rem;
}
.about__text strong {
  color: var(--yellow);
  font-weight: 700;
}

.about__ascii {
  font-family: var(--mono);
  color: var(--aqua);
  font-size: 0.85rem;
  line-height: 1.4;
  margin: 0;
  background: var(--bg0);
  padding: 1rem;
  border: 1px solid var(--bg1);
  border-left: 3px solid var(--green);
  white-space: pre;
  overflow-x: auto;
}

/* skills */
.skills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.skills li {
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--bg2);
  background: var(--bg0);
  color: var(--fg2);
  transition: all 0.2s var(--ease);
  cursor: default;
  position: relative;
}
.skills li::before {
  content: '';
  width: 8px; height: 8px;
  display: inline-block;
  margin-right: 0.5rem;
  background: var(--gray);
  vertical-align: middle;
  transition: background 0.2s var(--ease);
}
.skills li[data-cat="lang"]::before  { background: var(--orange); }
.skills li[data-cat="sys"]::before   { background: var(--blue); }
.skills li[data-cat="db"]::before    { background: var(--purple); }
.skills li[data-cat="cloud"]::before { background: var(--aqua); }
.skills li[data-cat="tool"]::before  { background: var(--green); }
.skills li[data-cat="meta"]::before  { background: var(--yellow); }

.skills li:hover {
  background: var(--bg1);
  color: var(--fg0);
  border-color: var(--fg4);
  transform: translateY(-2px);
}

/* projects */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
}
.project {
  background: var(--bg0);
  border: 1px solid var(--bg1);
  padding: 1.25rem 1.4rem 1.4rem;
  position: relative;
  transition: all 0.25s var(--ease);
  display: flex;
  flex-direction: column;
}
.project::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--bg2);
  transition: background 0.25s var(--ease);
}
.project:hover {
  background: var(--bg1);
  border-color: var(--fg4);
  transform: translateY(-3px);
}
.project:hover::before { background: var(--yellow); }

.project header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.project h3 {
  margin: 0;
  color: var(--fg0);
  font-size: 1.15rem;
  font-weight: 700;
}
.project__year {
  font-size: 0.75rem;
  color: var(--gray);
  letter-spacing: 0.15em;
}
.project p {
  color: var(--fg3);
  margin: 0 0 1rem;
  font-size: 0.92rem;
  flex: 1;
}
.project__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.project__tags span {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  background: var(--bg2);
  color: var(--fg3);
  letter-spacing: 0.04em;
}
.project__links {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
}
.project__link {
  font-size: 0.85rem;
  color: var(--aqua);
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: all 0.2s var(--ease);
}
.project__link:hover {
  color: var(--yellow);
  border-color: var(--yellow);
}
.project p code {
  background: var(--bg2);
  color: var(--aqua);
  padding: 0.05rem 0.35rem;
  font-size: 0.85em;
}

/* =========================================================
   terminal
   ========================================================= */
.term {
  background: var(--bg0);
  border: 1px solid var(--bg1);
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.6);
  font-size: 0.92rem;
  overflow: hidden;
}
.term__bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg1);
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--bg0);
}
.term__dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--gray);
}
.term__dot--r { background: var(--red); }
.term__dot--y { background: var(--yellow); }
.term__dot--g { background: var(--green); }
.term__title {
  margin-left: auto;
  color: var(--fg4);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
}

.term__body {
  padding: 1rem 1.1rem 1.2rem;
  min-height: 360px;
  max-height: 60vh;
  overflow-y: auto;
  cursor: text;
}
.term__body:focus { outline: none; }

.term__output { white-space: pre-wrap; word-break: break-word; }
.term__output .line { margin: 0; padding: 0; }
.term__output .echo {
  color: var(--fg2);
}
.term__output .err   { color: var(--red); }
.term__output .ok    { color: var(--green); }
.term__output .info  { color: var(--aqua); }
.term__output .warn  { color: var(--yellow); }
.term__output .dim   { color: var(--gray); }
.term__output .accent{ color: var(--orange); font-weight: 700; }
.term__output .link  { color: var(--blue); text-decoration: underline dotted; }

.term__line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 0.3rem;
}
.term__prompt {
  flex-shrink: 0;
  font-weight: 500;
  white-space: nowrap;
}
.term__user   { color: var(--green); font-weight: 700; }
.term__at     { color: var(--fg4); }
.term__host   { color: var(--aqua); font-weight: 700; }
.term__colon  { color: var(--fg4); }
.term__path   { color: var(--blue); }
.term__dollar { color: var(--fg1); margin-left: 0.4rem; }

.term__input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg0);
  font-family: var(--mono);
  font-size: inherit;
  caret-color: var(--yellow);
  padding: 0;
}
.term__input::selection { background: var(--yellow); color: var(--on-accent); }

/* render-only past prompt lines */
.term__output .prompt-line {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* =========================================================
   contact / footer
   ========================================================= */
.section--contact { padding-bottom: 6rem; }
.contact__lead {
  font-size: clamp(1.2rem, 2.4vw, 1.6rem);
  color: var(--fg1);
  max-width: 40ch;
  margin-top: 0;
}
.contact__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 1.5rem;
}
.contact__list a {
  font-size: 1rem;
  color: var(--fg2);
  border-bottom: 1px dashed var(--bg3);
  padding-bottom: 2px;
}
.contact__list a:hover {
  color: var(--yellow);
  border-color: var(--yellow);
}

.footer {
  border-top: 1px solid var(--bg1);
  padding: 1.2rem var(--pad);
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--gray);
  letter-spacing: 0.06em;
}

/* =========================================================
   reveal animations
   ========================================================= */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  will-change: opacity, transform;
}
.reveal.is-in {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* =========================================================
   mobile (≤ 720px)
   ========================================================= */
@media (max-width: 720px) {
  :root { --pad: 1.1rem; }
  html, body { font-size: 14px; }

  /* hero — tighter, canvas shorter so letters render denser */
  .hero {
    padding: 5.5rem 1rem 3.5rem;
    gap: 0.6rem;
  }
  .hero__meta {
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
  }
  .hero__meta .hero__loc::before { display: none; }
  .hero__canvas-wrap {
    height: clamp(160px, 28vh, 240px);
  }
  .hero__sub { font-size: 0.85rem; margin-top: 0.4rem; }
  .hero__cta { margin-top: 0.6rem; gap: 0.5rem; }
  .btn { padding: 0.6rem 1rem; font-size: 0.82rem; }
  /* hide the decorative scroll hint on phones — too easy to collide
     with the CTA buttons on short viewports, and mobile users already
     know to scroll. */
  .hero__scroll { display: none; }

  /* sections — reclaim vertical space */
  .section {
    padding: 3.5rem 1rem 2.5rem;
  }
  .section__head {
    margin-bottom: 1.5rem;
    gap: 0.5rem;
  }
  .section__num { font-size: 0.7rem; }
  .section__title { font-size: 1.5rem; }
  .section__hint {
    margin-left: 0;
    flex-basis: 100%;
    font-size: 0.78rem;
  }

  /* about */
  .about__grid { gap: 1.2rem; }
  .about__text p { font-size: 0.95rem; }
  .about__ascii {
    font-size: 0.72rem;
    padding: 0.7rem 0.8rem;
    overflow-x: auto;
  }

  /* skills */
  .skills { gap: 0.4rem; }
  .skills li { font-size: 0.78rem; padding: 0.35rem 0.7rem; }

  /* projects — single column, tighter */
  .projects { gap: 0.85rem; }
  .project { padding: 1rem 1.1rem 1.1rem; }
  .project h3 { font-size: 1rem; }
  .project p { font-size: 0.85rem; }

  /* terminal — readable on small screens */
  .term { font-size: 0.78rem; }
  .term__bar { padding: 0.45rem 0.6rem; }
  .term__dot { width: 10px; height: 10px; }
  .term__title { font-size: 0.65rem; }
  .term__body {
    padding: 0.7rem 0.8rem 0.9rem;
    min-height: 280px;
    max-height: 65vh;
  }
  .term__line { gap: 0.3rem; }
  .term__prompt { font-size: 0.78rem; }

  /* contact / footer */
  .section--contact { padding-bottom: 4rem; }
  .contact__lead { font-size: 1.15rem; }
  .contact__list { gap: 0.5rem 1rem; }
  .contact__list a { font-size: 0.9rem; }
  .footer {
    flex-direction: column;
    gap: 0.4rem;
    align-items: flex-start;
    padding: 1rem;
  }
}

@media (max-width: 380px) {
  .hero__canvas-wrap { height: 150px; }
  .section__title { font-size: 1.3rem; }
}
