/* ============================================
   matt0k — monospace × pastel (catppuccin-ish)
   ============================================ */

/* ---------- Self-hosted fonts (latin) ---------- */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('fonts/jetbrainsmono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Press Start 2P';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/pressstart2p-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* base */
  --bg:      #1a1a26;   /* soft dark */
  --bg-soft: #232335;
  --fg:      #cdd6f4;   /* text */
  --body:    #b7bfda;
  --muted:   #9099b8;
  --faint:   #676e8c;
  --line:    rgba(205, 214, 244, 0.10);
  --line-2:  rgba(205, 214, 244, 0.055);

  /* pastels */
  --mauve:  #cba6f7;
  --pink:   #f5c2e7;
  --blue:   #9db4ff;
  --sky:    #89dceb;
  --teal:   #94e2d5;
  --green:  #a6e3a1;
  --peach:  #fab387;
  --yellow: #f9e2af;

  --accent: var(--mauve);

  --mono:  'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --pixel: 'Press Start 2P', var(--mono);

  --col: 660px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Light theme (Catppuccin Latte) ---------- */
:root[data-theme="light"] {
  --bg:      #eff1f5;
  --bg-soft: #e6e9ef;
  --fg:      #4c4f69;
  --body:    #5c5f77;
  --muted:   #7c7f93;
  --faint:   #9ca0b0;
  --line:    rgba(76, 79, 105, 0.14);
  --line-2:  rgba(76, 79, 105, 0.08);

  --mauve:  #8839ef;
  --pink:   #ea76cb;
  --blue:   #1e66f5;
  --sky:    #04a5e5;
  --teal:   #179299;
  --green:  #40a02b;
  --peach:  #fe640b;
  --yellow: #df8e1d;
}
:root[data-theme="light"] .stars { display: none; }

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  font-size: 15px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: var(--mauve); color: #1a1a26; }

a { color: inherit; text-decoration: none; }
em { font-style: normal; }
h1, h2, h3, h4 { font-size: 1em; font-weight: 400; }
img { max-width: 100%; height: auto; }

/* Accessibility: skip to content */
.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 200;
  padding: 8px 14px;
  font-size: 0.8rem;
  color: var(--bg);
  background: var(--mauve);
  border-radius: 8px;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- Pixel wordmark ---------- */
.pixel {
  font-family: var(--pixel);
  letter-spacing: 0.01em;
  -webkit-font-smoothing: none;
}
/* ---------- Avatar ---------- */
.pp {
  display: block;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.pp--sm { width: 26px; height: 26px; border-radius: 7px; }
.pp--lg { width: 88px; height: 88px; border-radius: 18px; }

/* ---------- Links ---------- */
.intro__links a {
  color: var(--fg);
  background-image: linear-gradient(var(--sky), var(--sky));
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 100% 1px;
  padding-bottom: 2px;
  transition: color 0.22s var(--ease), background-size 0.28s var(--ease);
}
.intro__links a:hover { color: var(--sky); background-size: 100% 2px; }

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 28px;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--col);
  margin: 0 auto;
  padding: 16px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--line-2);
}
.topbar__name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--mauve);
}
.topbar__nav {
  display: flex;
  gap: 20px;
  font-size: 0.82rem;
  color: var(--muted);
}
.topbar__nav a { transition: color 0.2s var(--ease); }
.topbar__nav a::before { content: "/"; color: var(--faint); margin-right: 3px; }
.topbar__nav a:hover { color: var(--fg); }
.topbar__nav a.is-active { color: var(--fg); }
.topbar__nav a.is-active::before { color: var(--mauve); }

.topbar__right { display: flex; align-items: center; gap: 18px; }
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  padding: 0;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.theme-toggle:hover { color: var(--fg); border-color: var(--muted); }
.theme-toggle:focus-visible { outline: 2px solid var(--mauve); outline-offset: 2px; }

/* Blinking terminal caret */
.caret {
  display: inline-block;
  width: 0.52em;
  height: 0.95em;
  margin-left: 0.14em;
  background: var(--mauve);
  vertical-align: -0.1em;
  animation: caret 1.1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* ---------- Intro ---------- */
.intro {
  position: relative;
  padding: clamp(40px, 9vh, 80px) 0 clamp(60px, 10vh, 100px);
  border-bottom: 1px solid var(--line-2);
}
.stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(120% 80% at 50% 20%, #000 30%, transparent 78%);
  mask-image: radial-gradient(120% 80% at 50% 20%, #000 30%, transparent 78%);
}
.intro__inner { position: relative; z-index: 1; }

.crest {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 30px;
}
.crest__name {
  font-size: clamp(1.6rem, 6.5vw, 2.8rem);
  line-height: 1;
  color: var(--mauve);
}

.eyebrow {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.pin {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(166,227,161,0.5);
  animation: ping 2.6s var(--ease) infinite;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(166,227,161,0.5); }
  70%,100% { box-shadow: 0 0 0 7px rgba(166,227,161,0); }
}

.lead {
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(1.35rem, 4vw, 2.1rem);
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin-bottom: 30px;
  max-width: 24ch;
}
.lead em:nth-of-type(1) { color: var(--pink); }
.lead em:nth-of-type(2) { color: var(--blue); }

.intro__links {
  display: flex;
  gap: 22px;
  font-size: 0.85rem;
}

/* ---------- Blocks ---------- */
.block {
  padding: clamp(50px, 9vh, 84px) 0;
  border-bottom: 1px solid var(--line-2);
}
.block__label {
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: 30px;
}
.block__label span { color: var(--mauve); margin-right: 8px; }
.block__label::before { content: "// "; color: var(--faint); }
#work  .block__label span { color: var(--blue); }
#stack .block__label span { color: var(--teal); }
#contact .block__label span { color: var(--peach); }

/* ---------- Work list ---------- */
.work { list-style: none; }
.work__item { border-top: 1px solid var(--line); }
.work__item:last-child { border-bottom: 1px solid var(--line); }

.work__link {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 8px 20px;
  padding: 22px 4px 24px;
  transition: padding 0.35s var(--ease), background 0.35s var(--ease);
}
.work__link:hover {
  padding-left: 16px;
  padding-right: 16px;
  background: var(--bg-soft);
}
.work__name {
  grid-column: 1; grid-row: 1;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--fg);
  transition: color 0.25s var(--ease);
}
.work__name::before { content: "> "; color: var(--mauve); }
.work__link:hover .work__name { color: var(--mauve); }
.work__meta {
  grid-column: 2; grid-row: 1;
  align-self: start;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}
.work__live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  transition: color 0.3s var(--ease);
}
.work__live.online { color: var(--green); }
.work__live .d {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.work__live.online .d { box-shadow: 0 0 6px 1px rgba(166, 227, 161, 0.6); }
.work__desc {
  grid-column: 1; grid-row: 2;
  font-size: 0.9rem;
  color: var(--body);
  max-width: 46ch;
}
.work__go {
  grid-column: 2; grid-row: 2;
  align-self: center;
  justify-self: end;
  font-size: 0.76rem;
  color: var(--muted);
  transition: transform 0.3s var(--ease), color 0.25s var(--ease);
}
.work__link:hover .work__go { color: var(--sky); transform: translateX(4px); }

/* ---------- Stack ---------- */
.stack { display: grid; gap: 0; }
.stack__row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 24px;
  padding: 18px 0;
  border-top: 1px solid var(--line-2);
}
.stack__row:last-child { border-bottom: 1px solid var(--line-2); }
.stack__key {
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  text-transform: lowercase;
  color: var(--muted);
  padding-top: 2px;
}
.stack__key::before { content: "~ "; color: var(--faint); }
.stack__val { font-size: 0.92rem; color: var(--body); line-height: 1.95; overflow-wrap: anywhere; }
.stack__val span { color: var(--fg); }
.stack__val i { font-style: normal; color: var(--faint); }

/* ---------- Contact ---------- */
.block--contact { border-bottom: none; }
.contact__line {
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(1.4rem, 4vw, 2.1rem);
  line-height: 1.3;
  color: var(--fg);
  margin-bottom: 34px;
}
.contact__line em { color: var(--peach); }

.contact__list { list-style: none; }
.contact__list li { border-top: 1px solid var(--line); }
.contact__list li:last-child { border-bottom: 1px solid var(--line); }
.contact__list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 4px;
  transition: padding 0.3s var(--ease), color 0.25s var(--ease);
}
.contact__list a:hover { padding-left: 14px; color: var(--mauve); }
.contact__key { font-size: 0.98rem; }
.contact__key::before { content: "→ "; color: var(--faint); }
.contact__list a:hover .contact__key::before { color: var(--mauve); }
.contact__val {
  font-size: 0.8rem;
  color: var(--muted);
  transition: color 0.25s var(--ease);
}
.contact__list a:hover .contact__val { color: var(--mauve); }
.contact__list a.copied .contact__val { color: var(--green); }

/* ---------- Footer ---------- */
.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 38px;
  padding-bottom: 54px;
  font-size: 0.72rem;
  color: var(--faint);
}
.foot__logo { font-size: 0.6rem; color: var(--muted); }

/* ---------- Reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.reveal.visible { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */

/* Tablet / small laptop */
@media (max-width: 720px) {
  .wrap { padding: 0 24px; }
  .topbar { padding: 14px 24px; }
  .stack__row { grid-template-columns: 130px 1fr; gap: 18px; }
}

/* Phone */
@media (max-width: 560px) {
  body { font-size: 14px; }
  .wrap { padding: 0 20px; }
  .topbar { padding: 13px 20px; gap: 12px; }
  .topbar__name .pixel { font-size: 0.66rem; }
  .topbar__nav { gap: 13px; font-size: 0.76rem; }

  .intro { padding: 24px 0 clamp(48px, 9vh, 72px); }
  .crest { gap: 14px; margin-bottom: 26px; }
  .pp--lg { width: 74px; height: 74px; border-radius: 16px; }
  .lead { line-height: 1.35; }

  .block { padding: clamp(44px, 8vh, 68px) 0; }

  /* Projects stack vertically, meta below name */
  .work__link { grid-template-columns: 1fr; gap: 6px; padding: 20px 4px 22px; }
  .work__link:hover { padding-left: 10px; padding-right: 10px; }
  .work__name { font-size: 1.15rem; }
  .work__meta { grid-column: 1; grid-row: 2; align-self: start; align-items: flex-start; flex-direction: row; gap: 12px; text-align: left; }
  .work__desc { grid-row: 3; }
  .work__go { grid-column: 1; grid-row: 4; align-self: start; justify-self: start; margin-top: 2px; }

  /* Stack: label above values */
  .stack__row { grid-template-columns: 1fr; gap: 5px; padding: 16px 0; }

  /* Contact: key above value, no overflow on long email */
  .contact__list a { flex-direction: column; align-items: flex-start; gap: 3px; padding: 15px 4px; }
  .contact__list a:hover { padding-left: 10px; }
  .contact__val { font-size: 0.76rem; word-break: break-all; }
}

/* Very small phones */
@media (max-width: 380px) {
  .wrap { padding: 0 16px; }
  .topbar { padding: 12px 16px; }
  .topbar__nav { gap: 10px; font-size: 0.72rem; }
  .topbar__nav a::before { margin-right: 2px; }
  .crest__name { font-size: 1.9rem; }
  .lead { font-size: 1.28rem; }
}

/* Safe-area (notched phones, portrait) */
@media (max-width: 560px) {
  .topbar { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .wrap { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}
