/* ==========================================================
   Tokens
   ========================================================== */
:root {
  --bg: #f5f5f5;
  --text: #444444;
  --heading: #232323;
  --ink: #000000;
  --muted: #c3c3c3;
  --soft: #888888;
  --accent: #5b6171;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.1);
  --surface: #ffffff;
  --code-bg: #ebebeb;
  --chip-bg: rgba(0, 0, 0, 0.06);
  --on-heading: #ffffff;
  --text-strong: #333333;
  --browser-bar: #ececef;
  color-scheme: light;
  --font: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Montserrat", "Inter", "Helvetica Neue", Arial, sans-serif;
  --gutter: 80px;
  --max: 1280px;
  --header-h: 100px;
}

/* Dark theme: only when chosen with the toggle (light is the default) */
:root[data-theme="dark"] {
  --bg: #111113;
  --text: #c4c4c9;
  --heading: #ececee;
  --ink: #ffffff;
  --muted: #6e6e76;
  --soft: #8b8b92;
  --accent: #aab2c6;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.14);
  --surface: #1c1c1f;
  --code-bg: #1f1f23;
  --chip-bg: rgba(255, 255, 255, 0.1);
  --on-heading: #111113;
  --text-strong: #d6d6da;
  --browser-bar: #2b2b30;
  color-scheme: dark;
}


@media (max-width: 767px) {
  :root {
    --gutter: 20px;
    --header-h: 62px;
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--heading);
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 20px;
  letter-spacing: -0.01em;
}

/* Display font: name, main menu and big headings */
h1, h2,
.logo,
.main-menu a,
.main-menu__game,
.page-intro,
.hero__title,
.project-header h1,
.post-header h1 {
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: 0;
}

/* Smaller headings inside lists and cards stay in Inter */
article.list h2,
.post-item h2 {
  font-family: var(--font);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 { font-size: 36px; }
h2 { font-size: 24px; }
h3 { font-size: 19px; font-weight: 700; }

p, ul, ol, table, pre, dl, blockquote { margin: 0 0 20px; }

a { color: var(--heading); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

img { max-width: 100%; height: auto; }

strong { color: var(--heading); font-weight: 700; }

small { font-size: 13px; color: var(--soft); }

hr { border: 0; height: 1px; background: var(--line); margin: 40px 0; }

blockquote {
  border-left: 3px solid var(--muted);
  padding: 0 0 0 20px;
  font-style: italic;
}

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  color: var(--heading);
}

pre {
  padding: 16px 20px;
  background: var(--code-bg);
  border-radius: 4px;
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }

/* ==========================================================
   Header
   ========================================================== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 35px var(--gutter);
  background: var(--bg);
  transition: padding .3s ease-in-out, box-shadow .3s ease-in-out;
}

.header.is-scrolled {
  padding-top: 20px;
  padding-bottom: 20px;
  box-shadow: 0 1px 0 var(--line);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max);
  margin: 0 auto;
}

.logo {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.4;
  white-space: nowrap;
}

.logo a {
  color: var(--ink);
  text-decoration: none;
  text-transform: uppercase;
}

.logo a:hover { color: var(--accent); }

.main-menu {
  display: flex;
  gap: 40px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.main-menu a,
.main-menu__game {
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.6;
  text-decoration: none;
  transition: color .2s ease-in-out;
}

.main-menu a:hover { color: var(--accent); }
.main-menu__game { padding: 0; border: 0; background: none; cursor: pointer; }
.main-menu__game:hover { color: #e8618c; }
.main-menu a.is-active { color: var(--ink); }

.menu .social { display: none; }
.menu { display: flex; align-items: center; gap: 40px; }

.lang-switch {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
}

.lang-switch a {
  display: block;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--muted);
  text-decoration: none;
  transition: color .2s ease-in-out, background .2s ease-in-out;
}

.lang-switch a:hover { color: var(--accent); }
.lang-switch a.is-active { color: var(--ink); background: var(--chip-bg); }


.toggle-menu {
  display: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.toggle-menu svg { display: block; }

/* Mobile slide-in menu */
@media (max-width: 767px) {
  .header { padding: 16px var(--gutter); }
  .header.is-scrolled { padding: 16px var(--gutter); }
  .logo { font-size: 18px; }

  .toggle-menu { display: inline-flex; position: relative; z-index: 12; }

  .menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 90vw;
    z-index: 11;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 103px 40px 30px 24px;
    background: var(--bg);
    transform: translateX(100%);
    transition: transform .4s ease-in-out;
    overflow-y: auto;
  }

  .menu-open .menu { transform: translateX(0); }

  .main-menu {
    flex-direction: column;
    align-items: flex-end;
    gap: 30px;
  }

  .main-menu a,
  .main-menu__game { font-size: 30px; line-height: 1.5; }

  .menu .social { display: flex; justify-content: flex-end; }
  .menu { align-items: stretch; gap: 0; }
  .menu .social { margin-top: auto; }

  .menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
  }

  .menu-open .menu-backdrop { opacity: .3; pointer-events: auto; }
  body.menu-open { overflow: hidden; }
}

/* ==========================================================
   Main
   ========================================================== */
.main {
  flex: 1 0 auto;
  width: 100%;
  max-width: calc(var(--max) + var(--gutter) * 2);
  margin: 0 auto;
  padding: calc(var(--header-h) + 20px) var(--gutter) 0;
}

/* Content pages (about, blog, posts) */
.page {
  max-width: 760px;
  padding: 40px 0 40px;
}

.page-intro {
  max-width: 980px;
  margin: 0 0 40px;
  font-size: 36px;
  font-weight: 900;
  line-height: 1.4;
  color: var(--heading);
}

@media (max-width: 767px) {
  .page { padding-top: 20px; }
  .page-intro { font-size: 24px; }
  h1 { font-size: 28px; }
}

/* ==========================================================
   Work grid
   ========================================================== */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

@media (max-width: 767px) {
  .grid { grid-template-columns: 1fr; gap: 10px; }
}

.asset {
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(40px);
  animation: rise .9s cubic-bezier(.5, 0, .2, 1) forwards;
}

.asset:nth-child(2) { animation-delay: .08s; }
.asset:nth-child(3) { animation-delay: .16s; }
.asset:nth-child(4) { animation-delay: .24s; }
.asset:nth-child(5) { animation-delay: .32s; }
.asset:nth-child(n+6) { animation-delay: .4s; }

@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .asset { animation: none; opacity: 1; transform: none; }
}

.asset > a {
  position: relative;
  display: block;
  aspect-ratio: 1600 / 1092;
  background: var(--tile, #e9e9e6);
  color: inherit;
  text-decoration: none;
}

.asset-holder {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: 50% 50%;
  transition: transform .6s cubic-bezier(.2, .6, .2, 1);
}

.asset:hover .asset-holder { transform: scale(1.03); }

/* Device mockups on a colored tile (sized with container query units) */
.asset > a { container-type: size; overflow: hidden; }

.mockup {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4.5cqw;
  transition: transform .6s cubic-bezier(.2, .6, .2, 1);
}

.asset:hover .mockup { transform: scale(1.03); }

.mockup img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Phone */
.device-phone {
  position: relative;
  height: 80cqh;
  aspect-ratio: 0.47;
  padding: 1.5cqh;
  border-radius: 5.5cqh;
  background: #141414;
  box-shadow:
    inset 0 0 0 .35cqh #3a3a3a,
    0 3cqh 6cqh rgba(20, 30, 50, .18),
    0 1cqh 2cqh rgba(20, 30, 50, .12);
}

.device-phone::before {
  content: "";
  position: absolute;
  top: 2.8cqh;
  left: 50%;
  z-index: 1;
  width: 2cqh;
  height: 2cqh;
  border-radius: 50%;
  background: #141414;
  transform: translateX(-50%);
}

.device-phone img { border-radius: 4.2cqh; object-position: 50% 0; }

.mockup--n2 .device-phone { height: 78cqh; }
.mockup--n3 { gap: 3.5cqw; }
.mockup--n3 .device-phone { height: 70cqh; }
.mockup--n3 .device-phone:nth-child(2) { transform: translateY(-3cqh); }

/* Laptop */
.device-laptop { width: 70cqw; margin-top: 2cqh; }

.device-laptop__screen {
  aspect-ratio: 16 / 10;
  padding: 1.3cqw 1.3cqw 1.6cqw;
  border-radius: 1.8cqw 1.8cqw 0 0;
  background: #141414;
  box-shadow: inset 0 0 0 .25cqw #333, 0 3cqh 6cqh rgba(20, 30, 50, .16);
}

.device-laptop__screen img { background: #fff; }

.device-laptop__base {
  position: relative;
  width: 116%;
  height: 2.3cqw;
  margin-left: -8%;
  border-radius: 0 0 2cqw 2cqw;
  background: linear-gradient(#e4e6ea 0%, #c4c7ce 60%, #a9adb6 100%);
  box-shadow: 0 2cqh 4cqh rgba(20, 30, 50, .18);
}

.device-laptop__base::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 16%;
  height: 45%;
  border-radius: 0 0 1cqw 1cqw;
  background: #b3b7bf;
  transform: translateX(-50%);
}

/* Browser window */
.device-browser {
  width: 82cqw;
  overflow: hidden;
  border-radius: 1.2cqw;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06), 0 3cqh 7cqh rgba(20, 30, 50, .18);
}

.device-browser__bar {
  display: flex;
  align-items: center;
  gap: .8cqw;
  height: 3.4cqw;
  padding: 0 1.4cqw;
  background: var(--browser-bar);
}

.device-browser__bar i { width: 1.1cqw; height: 1.1cqw; border-radius: 50%; background: #ff5f57; }
.device-browser__bar i:nth-child(2) { background: #febc2e; }
.device-browser__bar i:nth-child(3) { background: #28c840; }

.device-browser img { height: auto; max-height: 70cqh; aspect-ratio: auto; }

/* Caption hidden until hover (cards with a cover image) */
.asset .title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 30px;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  background-image: linear-gradient(-180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, .5) 100%);
  opacity: 0;
  transform: translateY(5px);
  transition: opacity .2s ease-in-out, transform .2s ease-in-out;
}

.asset .title small {
  display: block;
  color: rgba(255, 255, 255, .8);
  font-size: 14px;
  font-weight: 400;
}

.asset:hover .title,
.asset a:focus-visible .title { opacity: 1; transform: translateY(0); }

/* Cards without an image: typographic tile, caption always visible */
.asset.no-image .title {
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: var(--heading);
  background: none;
  opacity: 1;
  transform: none;
}

.asset.no-image .title small { color: var(--text); }

.asset.no-image .tile-mark {
  position: absolute;
  top: 30px;
  left: 30px;
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
  color: var(--heading);
  opacity: .12;
  transition: opacity .3s ease-in-out;
}

.asset.no-image:hover .tile-mark { opacity: .25; }

@media (max-width: 767px) {
  .asset .title { padding: 20px; font-size: 18px; opacity: 1; transform: none; }
  .asset.no-image .tile-mark { top: 20px; left: 20px; font-size: 48px; }
}

/* ==========================================================
   Project page
   ========================================================== */
.project { padding: 40px 0 20px; }

.project-header { max-width: 760px; margin: 0 0 40px; }
.project-header h1 { margin-bottom: 8px; font-size: 48px; }
.project-headline { margin: 0 0 6px; color: var(--heading); font-size: 20px; font-weight: 600; line-height: 1.4; }
.project-meta { margin: 0; color: var(--soft); font-size: 15px; }

.project-hero {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 80vh;
  margin: 0 0 60px;
  overflow: hidden;
  background: var(--tile, #e9e9e6);
  container-type: size;
}

.project-hero .device-laptop { width: 60cqw; }
.project-hero .device-browser { width: 74cqw; }
.project-hero .mockup--n3 .device-phone { height: 74cqh; }

@media (max-width: 767px) {
  .project-hero { aspect-ratio: 4 / 3; margin-bottom: 40px; }
  .project-hero .device-laptop { width: 78cqw; }
  .project-hero .device-browser { width: 88cqw; }
}

.project-figure { margin: 0 0 40px; }
.project-figure img {
  display: block;
  max-width: 100%;
  max-height: 90vh;
  margin: 0 auto;
  background: #fff;
}
.project-figure figcaption { margin-top: 10px; color: var(--soft); font-size: 14px; text-align: center; }

.project-body { max-width: 760px; margin: 0 0 60px; }
.project-body h3 { margin-top: 36px; font-size: 18px; }
.project-body ul { padding-left: 20px; }
.project-body li { margin-bottom: 4px; }

.project-gallery .project-figure { margin-bottom: 20px; }

.project-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
  font-weight: 700;
}
.project-nav a { text-decoration: none; }

@media (max-width: 767px) {
  .project { padding-top: 20px; }
  .project-header h1 { font-size: 32px; }
  .project-headline { font-size: 17px; }
}

/* ==========================================================
   About
   ========================================================== */
.about-photo {
  display: block;
  width: 160px;
  height: 160px;
  margin: 0 0 40px;
  border-radius: 50%;
  object-fit: cover;
}

.timeline { padding: 0; list-style: none; }
.timeline li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.timeline li:first-child { border-top: 1px solid var(--line); }
.timeline .when { display: block; color: var(--soft); font-size: 14px; }
.timeline .what { font-weight: 700; color: var(--heading); }
.timeline p { margin: 8px 0 0; }
.experience > li { padding: 20px 0; }
.experience .what { display: block; margin-bottom: 4px; font-size: 18px; }
.experience .role { margin-top: 14px; padding-left: 16px; border-left: 2px solid var(--line); }
.experience .role strong a { text-decoration: none; }
.experience .role .when { margin-top: 2px; }
.experience .role p { font-size: 15px; }

/* ==========================================================
   Blog
   ========================================================== */
article.list { padding: 24px 0; border-bottom: 1px solid var(--line); }
article.list h2 { margin-bottom: 8px; font-size: 20px; font-weight: 700; }
article.list h2 a { text-decoration: none; }
article.list p { margin: 0; }

.post h2 { font-size: 32px; font-weight: 900; }

.btn, .share {
  display: inline-block;
  margin: 0 8px 20px 0;
  padding: 6px 18px;
  border: 1px solid rgba(91, 97, 113, .5);
  border-radius: 100px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background .25s ease, color .25s ease;
}

.btn:hover, .share:hover { background: var(--accent); color: #f5f5f5; }

/* ==========================================================
   Footer
   ========================================================== */
.footer {
  padding: 35px var(--gutter);
  color: var(--soft);
  font-size: 16px;
}

.footer-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max);
  margin: 0 auto;
}

.copyright { margin: 0; }
.footer-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; }
.footer .lang-switch { letter-spacing: 0; font-size: 14px; font-weight: 600; }

.social ul {
  display: flex;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.social a { display: block; color: var(--muted); transition: color .2s ease-in-out; }
.social a:hover { color: var(--accent); }
.social svg { display: block; width: 22px; height: 22px; }

@media (max-width: 767px) {
  .footer-container { flex-direction: column-reverse; gap: 15px; }
  .footer-meta { flex-direction: column; gap: 10px; }
}

/* Legacy pages and posts rendered straight into .main */
.main > article:not(.page):not(.project) { max-width: 760px; }
.main > article:not(.page):not(.project):first-child { padding-top: 40px; }
.main > article:not(.page):not(.project):last-child { padding-bottom: 40px; }

.blog-note { color: var(--soft); font-size: 15px; }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 40px; margin: 0 0 20px; }
.skills__group h3 { margin: 0 0 10px; font-size: 15px; font-weight: 700; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tags li {
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 100px;
  background: var(--surface);
  color: var(--heading);
  font-size: 13px;
  line-height: 1.6;
}
@media (max-width: 767px) { .skills { grid-template-columns: 1fr; } }

/* CV download */
.cv-download { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 40px; }
.btn-cv {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 100px;
  background: var(--heading);
  color: var(--on-heading);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  transition: background .25s ease;
}
.btn-cv:hover { background: var(--accent); color: var(--on-heading); }

.lead { font-size: 18px; color: var(--heading); }

/* Blog list */
.blog-intro { margin: 0 0 30px; color: var(--soft); font-size: 15px; }
.post-list { display: grid; gap: 0; }
.post-item { border-top: 1px solid var(--line); }
.post-item:last-child { border-bottom: 1px solid var(--line); }
.post-item__link {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding: 28px 0;
  color: inherit;
  text-decoration: none;
}
.post-item__img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 4px; background: #e9e9e6; }
.post-item h2 { margin: 4px 0 8px; font-size: 21px; font-weight: 700; line-height: 1.35; transition: color .2s; }
.post-item p { margin: 0; color: var(--text); font-size: 15px; }
.post-item__link:hover h2 { color: var(--accent); }
@media (max-width: 767px) {
  .post-item__link { grid-template-columns: 1fr; gap: 14px; }
}

/* Post page */
.post-page { max-width: 760px; padding: 40px 0 20px; }
.post-header h1 { margin: 6px 0 30px; font-size: 40px; line-height: 1.2; }
.post-cover { margin: 0 0 40px; }
.post-cover img { display: block; width: 100%; max-height: 460px; object-fit: cover; border-radius: 4px; }
.post-cover figcaption, .post-content figcaption { margin-top: 8px; color: var(--soft); font-size: 13px; text-align: center; }
.post-content { font-size: 18px; line-height: 1.75; color: var(--text-strong); }
.post-content h3 { margin: 40px 0 14px; font-size: 22px; }
.post-content h4 { margin: 30px 0 10px; font-size: 18px; }
.post-content figure { margin: 30px 0; }
.post-content img { display: block; max-width: 100%; margin: 0 auto; }
.post-content blockquote { margin: 24px 0; font-size: 20px; }
.post-content ul, .post-content ol { padding-left: 22px; }
.post-tags { margin: 30px 0 40px; }
@media (max-width: 767px) {
  .post-header h1 { font-size: 28px; }
  .post-content { font-size: 17px; }
}

/* Home hero */
.hero { max-width: 980px; padding: 30px 0 60px; }
.hero__title { margin: 0 0 20px; font-size: 44px; font-weight: 900; line-height: 1.2; }
.hero__text { max-width: 760px; margin: 0 0 24px; font-size: 19px; color: var(--text); }
.hero__links { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0; font-weight: 700; }
.hero__links a { text-decoration: none; border-bottom: 2px solid var(--heading); padding-bottom: 2px; }
.hero__links a:hover { border-color: var(--accent); }
.hero__game {
  padding: 0 0 2px; border: 0; border-bottom: 2px dashed #e8618c; background: none;
  color: var(--heading); font: inherit; font-weight: 700; cursor: pointer;
}
.hero__game:hover { color: #e8618c; }
@media (max-width: 767px) {
  .hero { padding: 10px 0 36px; }
  .hero__title { font-size: 28px; }
  .hero__text { font-size: 17px; }
}

/* Communities timeline */
.communities li { display: grid; grid-template-columns: 70px minmax(0, 1fr); column-gap: 16px; align-items: baseline; }
.communities .when { grid-row: span 2; font-weight: 700; color: var(--heading); font-size: 15px; }
.communities .what { font-weight: 700; color: var(--heading); }
.communities p { grid-column: 2; margin: 4px 0 0; font-size: 15px; }

/* Theme toggle */
.header-container { gap: 24px; }
.header .menu { margin-left: auto; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--heading);
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.theme-toggle:hover { background: var(--chip-bg); color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (max-width: 767px) {
  .theme-toggle { margin-left: auto; order: 2; width: 34px; height: 34px; }
  .header .toggle-menu { order: 3; }
}

/* Dark theme: colored tiles become deep tinted surfaces */
:root[data-theme="dark"] .asset > a,
:root[data-theme="dark"] .project-hero {
  background: color-mix(in srgb, var(--tile, #e9e9e6) 22%, #19191c);
}
:root[data-theme="dark"] .device-browser { box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 3cqh 7cqh rgba(0, 0, 0, .45); }
:root[data-theme="dark"] .device-phone { box-shadow: inset 0 0 0 .35cqh #3a3a3a, 0 0 0 1px rgba(255, 255, 255, .08), 0 3cqh 6cqh rgba(0, 0, 0, .45); }
:root[data-theme="dark"] .post-item__img,
:root[data-theme="dark"] .about-photo { box-shadow: 0 0 0 1px var(--line); }

/* WhatsApp floating button (bottom right) */
.wa-float {
  position: fixed;
  right: 24px;
  bottom: calc(24px + var(--float-lift, 0px));
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.wa-float__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--heading);
  color: var(--on-heading);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  opacity: .88;
  transition: opacity .2s ease, transform .2s ease, background .2s ease;
}
.wa-float__tip {
  padding: 7px 14px;
  border-radius: 100px;
  background: var(--surface);
  color: var(--heading);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 0 0 1px var(--line-strong), 0 6px 18px rgba(0, 0, 0, .1);
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.wa-float:hover .wa-float__btn,
.wa-float:focus-visible .wa-float__btn { opacity: 1; transform: translateY(-2px); background: var(--accent); }
.wa-float:hover .wa-float__tip,
.wa-float:focus-visible .wa-float__tip,
.wa-float.is-hinting .wa-float__tip { opacity: 1; transform: translateX(0); }
.wa-float:focus-visible { outline: none; }
.wa-float:focus-visible .wa-float__btn { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
body.menu-open .wa-float { opacity: 0; pointer-events: none; }
@media (max-width: 767px) {
  .wa-float { right: 16px; bottom: calc(16px + var(--float-lift, 0px)); }
  .wa-float__btn { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .wa-float__btn, .wa-float__tip { transition: none; }
}

/* ==========================================================
   Bug Hunt mini game
   ========================================================== */
.bh-open .wa-float { opacity: 0; pointer-events: none; }

/* Overlay: the site stays visible behind a translucent, blurred layer */
.bh-open, .bh-open body { overflow: hidden; }
.bh-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  padding: 0;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(6px) saturate(1.1);
  backdrop-filter: blur(6px) saturate(1.1);
}
.bh-overlay[hidden] { display: none; }

.bh-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
  padding: 16px 24px 12px;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  outline: none;
}
.bh-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex: none; }
.bh-hud { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.bh-hud b { color: var(--heading); font-weight: 700; margin-right: 4px; }
.bh-lives { display: inline-flex; align-items: center; gap: 3px; }
.bh-life {
  display: inline-block; width: 0; height: 0;
  border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 11px solid #f6c453;
}
.bh-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; flex: none;
  border: 1px solid var(--line-strong); border-radius: 50%;
  background: transparent; color: var(--heading); cursor: pointer;
}
.bh-close:hover { background: var(--chip-bg); }

.bh-stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.bh-stage > .bh-screen { left: 50%; top: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%); width: var(--bh-w, 100%); height: var(--bh-h, 100%); }
.bh-canvas {
  display: block;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  box-shadow: inset 0 0 0 1px var(--line);
}

.bh-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
}
.bh-screen[hidden] { display: none; }
.bh-title { margin: 0; font-size: 34px; }
.bh-sub { margin: 0; max-width: 440px; color: var(--text); }
.bh-big { margin: 0; font-size: 20px; font-weight: 700; color: var(--heading); }
.bh-new { color: #e8618c; }
.bh-touch { margin: 0; font-size: 14px; color: var(--soft); }
.bh-hint { margin: 0; font-size: 13px; color: var(--soft); }
.bh-hint--touch { display: none; }
.is-touch .bh-hint--touch { display: block; }
.is-touch .bh-hint--keys { display: none; }

.bh-keys {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 8px 26px;
  margin: 6px 0 2px;
  padding: 0;
  list-style: none;
  font-size: 15px;
  color: var(--heading);
  text-align: left;
}
.bh-keys span { color: var(--soft); font-size: 13px; }
kbd {
  display: inline-block;
  min-width: 26px;
  margin-right: 3px;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 3px;
  background: var(--surface);
  color: var(--heading);
  font: 600 13px/1.4 var(--font);
  text-align: center;
}
kbd.bh-wide { min-width: 64px; }
.bh-legend { margin: 10px 0 0; flex: none; font-size: 13px; color: var(--soft); text-align: center; }
.bh-legend kbd { min-width: 22px; padding: 0 5px; font-size: 12px; }
.is-touch .bh-legend { display: none; }

.bh-btn {
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 6px; padding: 10px 22px;
  border: 0; border-radius: 100px;
  background: var(--heading); color: var(--on-heading);
  font: 700 15px var(--font); text-decoration: none; cursor: pointer;
}
.bh-btn:hover { background: var(--accent); color: var(--on-heading); }
.bh-btn--ghost { background: transparent; color: var(--heading); box-shadow: inset 0 0 0 1px var(--line-strong); }
.bh-btn--ghost:hover { background: var(--chip-bg); color: var(--heading); }
.bh-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

@media (max-width: 767px) {
  .bh-panel { padding: 10px 10px 8px; }
  .bh-title { font-size: 26px; }
  .bh-keys { display: none; }
  .bh-hud { font-size: 12px; gap: 4px 12px; }
  .bh-screen { gap: 8px; padding: 14px; }
}
@media (hover: none) and (pointer: coarse) {
  .bh-keys, .bh-legend, .bh-hint--keys { display: none; }
  .bh-hint--touch { display: block; }
}
.bh-tools { display: flex; gap: 8px; flex: none; }

/* Bomb: bottom-right corner of the playfield */
.bh-bomb {
  position: absolute;
  right: calc(50% - var(--bh-w, 100%) / 2 + 12px);
  bottom: calc(50% - var(--bh-h, 100%) / 2 + 14px);
  z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--heading); color: var(--on-heading);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
  cursor: pointer;
  opacity: .92;
  transition: opacity .2s ease, transform .15s ease;
}
.bh-bomb[hidden] { display: none; }
.bh-bomb:hover { transform: scale(1.06); }
.bh-bomb:active { transform: scale(.94); }
.bh-bomb.is-off { opacity: .3; }
.bh-bomb__cost {
  position: absolute; top: -4px; right: -6px;
  display: inline-flex; align-items: center; gap: 2px;
  padding: 1px 6px; border-radius: 10px;
  background: #e8618c; color: #fff;
  font: 700 11px/1.4 var(--font);
}
.bh-bomb__cost .bh-life { border-left-width: 4px; border-right-width: 4px; border-bottom-width: 7px; }
.is-touch .bh-bomb { width: 60px; height: 60px; }
.is-touch .bh-bomb svg { width: 26px; height: 26px; }
.bh-close[hidden] { display: none; }
@media (max-width: 420px) {
  .bh-best { display: none; }
  .bh-tools { gap: 6px; }
  .bh-close { width: 38px; height: 38px; }
}
