/* ==========================================================================
   Devadatta Pokharanakar — portfolio
   Design system: strict black & white, invertible. No third hue anywhere —
   "muted" is always the ink colour at reduced opacity, never a grey literal.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --ink: #000000;
  --sans: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --line: rgba(0, 0, 0, .12);
  --line-strong: rgba(0, 0, 0, .3);
}
html.inverted {
  --bg: #000000;
  --ink: #ffffff;
  --line: rgba(255, 255, 255, .15);
  --line-strong: rgba(255, 255, 255, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  transition: background .15s, color .15s;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, p, ul, figure { text-wrap: balance; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 28px; }
.wrap-wide { max-width: 980px; margin: 0 auto; padding: 0 28px; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; height: 64px; padding: 0 28px; border-bottom: 1px solid var(--line);
  background: var(--bg); flex-wrap: wrap; position: sticky; top: 0; z-index: 100;
}
.topbar .brand { font-weight: 800; font-size: 14px; letter-spacing: -0.01em; }
.topbar .topbar-nav { display: flex; gap: 18px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.topbar .topbar-nav a { font-size: 12.5px; opacity: .6; padding-bottom: 3px; border-bottom: 1px solid transparent; }
.topbar .topbar-nav a:hover { opacity: 1; }
.topbar .topbar-nav a.active { opacity: 1; font-weight: 700; border-bottom-color: currentColor; }
.topbar-nav-cv { display: none; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.nav-toggle {
  display: none; width: 20px; height: 16px; padding: 0; border: none; background: transparent;
  cursor: pointer; flex-direction: column; justify-content: space-between; flex-shrink: 0;
  color: var(--ink);
}
.nav-toggle span { display: block; height: 1.5px; width: 100%; background: currentColor; transition: transform .15s, opacity .15s; transform-origin: center; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7.25px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7.25px) rotate(-45deg); }
.cv-link { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; border: 1px solid currentColor; padding: 7px 13px; }
.cv-link:hover { background: var(--ink); color: var(--bg); }
.invert-btn {
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer; padding: 0; flex-shrink: 0;
  border: 1.5px solid #000; background: linear-gradient(to right, #fff 50%, #000 50%);
}
html.inverted .invert-btn { border-color: #fff; }
.invert-btn:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

/* ------------------------------------------------------------ page band */
.band { background: var(--ink); color: var(--bg); padding: 56px 28px 40px; }
.band.band-sm { padding: 42px 28px 34px; }
.band h1 { font-size: clamp(32px, 6vw, 60px); font-weight: 800; line-height: .98; letter-spacing: -0.02em; margin: 0 0 14px; }
.band .role { font-size: clamp(15px, 2vw, 19px); font-weight: 300; opacity: .82; margin: 0 0 22px; }
.band .rule { height: 1px; background: var(--bg); opacity: .3; margin: 22px 0; }
.band p.desc { font-size: 14.5px; line-height: 1.75; max-width: 70ch; opacity: .85; margin: 0; }
.band .band-stats { display: flex; gap: 30px; margin-top: 26px; flex-wrap: wrap; }
.band .band-stat .v { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.band .band-stat .l { font-size: 10.5px; opacity: .62; text-transform: uppercase; letter-spacing: .05em; margin-top: 3px; }

.band .band-head { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; }
.band .avatar {
  width: 225px; height: 225px; border-radius: 18px; overflow: hidden; flex-shrink: 0;
  border: 1.5px solid var(--bg); background: rgba(255, 255, 255, .08);
}
.band .avatar img { width: 100%; height: 100%; object-fit: cover; }
.band .band-head-text { flex: 1; min-width: 220px; }
.band .band-head-text h1 { margin-bottom: 10px; }

/* -------------------------------------------------------- highlights strip */
.highlights { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.highlight { background: var(--bg); padding: 20px 18px; display: block; }
a.highlight { cursor: pointer; transition: background .12s, color .12s; }
a.highlight:hover { background: var(--ink); color: var(--bg); }
.highlight .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.highlight .l { font-size: 10.5px; opacity: .55; text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; }

/* ----------------------------------------------------------- updates */
.updates { list-style: none; margin: 0; padding: 0; }
.updates li { position: relative; padding: 14px 6px 14px 22px; border-bottom: 1px solid var(--line); font-size: 14.5px; line-height: 1.65; opacity: .88; }
.updates li:last-child { border-bottom: none; }
.updates li::before { content: "—"; position: absolute; left: 0; opacity: .5; }

/* ------------------------------------------------------------- quote */
.quote-block { max-width: 760px; margin: 0 auto; padding: 10px 28px 48px; }
.quote-block .q-text { font-size: 18px; font-style: italic; line-height: 1.6; margin: 0 0 10px; opacity: .85; max-width: 58ch; }
.quote-block .q-author { font-size: 12.5px; opacity: .55; margin: 0; text-transform: uppercase; letter-spacing: .04em; }

/* -------------------------------------------------------- section label */
.section-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .5; margin-bottom: 16px; }
.section { padding: 40px 0; border-bottom: 1px solid var(--line); }
.section:last-of-type { border-bottom: none; }

/* --------------------------------------------------- toc / dot leaders */
.toc { list-style: none; margin: 0; padding: 0; }
.toc li { border-bottom: 1px solid var(--line); }
.toc a { display: flex; align-items: baseline; gap: 10px; padding: 13px 6px; font-size: 16px; font-weight: 500; }
.toc a .leader { flex: 1; overflow: hidden; white-space: nowrap; opacity: .35; letter-spacing: .12em; font-size: 12px; }
.toc a .num { font-size: 12px; opacity: .55; min-width: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.toc a:hover { background: var(--ink); color: var(--bg); margin: 0 -6px; padding-left: 12px; padding-right: 12px; }
.toc a:hover .leader, .toc a:hover .num { opacity: .55; }

/* -------------------------------------------------------------- facts */
.facts p { font-size: 15px; line-height: 1.85; margin: 0; max-width: 62ch; }
.facts b { font-weight: 700; }

/* ------------------------------------------------ index list (ghost №) */
.idx-list { margin: 0; padding: 0; }
.idx-row { display: grid; grid-template-columns: 60px 1fr; gap: 4px 18px; padding: 22px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.idx-row:last-child { border-bottom: none; }
.idx-row .ghost { font-size: 38px; font-weight: 800; opacity: .12; line-height: 1; font-variant-numeric: tabular-nums; }
html.inverted .idx-row .ghost { opacity: .28; }
.idx-row .t { font-size: 17px; font-weight: 700; margin: 0 0 4px; }
.idx-row .t a { border-bottom: 1px solid transparent; }
.idx-row .t a:hover { border-bottom-color: currentColor; }
.idx-row .d { font-size: 13.5px; opacity: .65; margin: 0; line-height: 1.6; }
.idx-row .tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.idx-row .tags span { font-size: 10.5px; letter-spacing: .02em; padding: 3px 8px; border: 1px solid currentColor; opacity: .65; }
.idx-row .links { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; }
.idx-row .links a { border-bottom: 1px solid currentColor; }
.idx-row .status { font-size: 10.5px; opacity: .5; text-transform: uppercase; letter-spacing: .04em; }
.idx-row-plain { grid-template-columns: 1fr; opacity: .65; }

/* ------------------------------------------------------------- row list */
.row-list { list-style: none; margin: 0; padding: 0; }
.row-item { display: flex; justify-content: space-between; gap: 16px; padding: 15px 6px; border-bottom: 1px solid var(--line); align-items: baseline; flex-wrap: wrap; cursor: default; }
.row-item.linkable { cursor: pointer; }
.row-item.linkable:hover { background: var(--ink); color: var(--bg); margin: 0 -6px; padding-left: 12px; padding-right: 12px; }
.row-item .main { font-size: 15px; font-weight: 600; }
.row-item .meta { font-size: 11.5px; opacity: .6; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-item .sub { font-size: 12.5px; opacity: .62; width: 100%; margin-top: 5px; line-height: 1.6; }
.row-item .tags-inline { font-size: 11px; opacity: .55; margin-top: 4px; width: 100%; }

/* ---------------------------------------------------------------- chips */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 26px; }
.filter-chip {
  font-size: 11.5px; letter-spacing: .02em; padding: 7px 13px; border: 1px solid currentColor;
  opacity: .55; background: transparent; cursor: pointer; font-family: inherit; color: var(--ink);
}
.filter-chip.active { opacity: 1; font-weight: 700; background: var(--ink); color: var(--bg); }
.filter-chip:hover { opacity: .85; }

/* --------------------------------------------------------- field rows */
.field-list { border-top: 1px solid var(--line); }
.field-row { display: grid; grid-template-columns: 96px 1fr; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.field-row .y { font-size: 12px; opacity: .55; font-variant-numeric: tabular-nums; line-height: 1.5; }
.field-row .inst { font-size: 16px; font-weight: 700; margin-bottom: 3px; }
.field-row .deg { font-size: 13.5px; opacity: .72; }
.field-row .badge { display: inline-block; font-size: 9.5px; letter-spacing: .03em; border: 1px solid currentColor; padding: 2px 7px; margin-top: 9px; margin-right: 6px; opacity: .7; text-transform: uppercase; }

.award-row { display: flex; justify-content: space-between; gap: 14px; padding: 13px 6px; border-bottom: 1px solid var(--line); }
.award-row .name { font-size: 13.5px; font-weight: 600; }
.award-row .sub { font-size: 11px; opacity: .55; display: block; margin-top: 2px; font-weight: 400; }
.award-row .year { font-size: 11.5px; opacity: .55; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- exp/list */
.exp-block { padding: 24px 0; border-bottom: 1px solid var(--line); }
.exp-block .exp-top { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.exp-block .role { font-size: 18px; font-weight: 700; }
.exp-block .company { font-size: 13px; opacity: .62; margin-top: 3px; }
.exp-block .date { font-size: 12px; opacity: .55; font-variant-numeric: tabular-nums; white-space: nowrap; }
.exp-block ul { margin: 16px 0 0; padding-left: 18px; font-size: 13.5px; line-height: 1.85; opacity: .88; }
.exp-block ul ul { margin: 4px 0 8px; padding-left: 20px; font-size: 12.5px; opacity: .85; line-height: 1.7; }

.cert-link { border-bottom: 1px solid transparent; }
.cert-link:hover { border-bottom-color: currentColor; }
.cert-arrow { display: inline-block; margin-left: 4px; opacity: .55; font-size: .85em; transform: translateY(-1px); }

.train-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.train-row .name { font-size: 13px; font-weight: 600; }
.train-row .issuer { font-size: 11.5px; opacity: .55; margin-top: 2px; }
.train-row .date { font-size: 11px; opacity: .55; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- skills */
.skill-groups { display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.skill-group { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 24px 26px; }
.skill-group .label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .5; margin-bottom: 15px; }
.skill-group .items { display: flex; flex-direction: column; gap: 9px; font-size: 14.5px; font-weight: 500; }

/* ----------------------------------------------------------- art grid */
.art-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.art-cell { background: var(--bg); display: flex; flex-direction: column; cursor: pointer; border: none; text-align: left; font-family: inherit; color: var(--ink); padding: 0; }
.art-thumb { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--line); overflow: hidden; }
.art-thumb img { width: 100%; height: 100%; object-fit: cover; }
.art-thumb .mono { font-size: 24px; font-weight: 800; opacity: .15; letter-spacing: -0.02em; }
.art-cell .cap { padding: 12px 14px; }
.art-cell .cap .t { font-size: 12.5px; font-weight: 600; line-height: 1.4; }
.art-cell .cap .m { font-size: 10px; opacity: .55; margin-top: 4px; text-transform: uppercase; letter-spacing: .03em; }

/* -------------------------------------------------------------- lightbox */
.lightbox { position: fixed; inset: 0; background: var(--bg); z-index: 200; display: none; flex-direction: column; }
.lightbox.open { display: flex; }
.lightbox-top { display: flex; justify-content: space-between; align-items: center; padding: 20px 28px; font-size: 11.5px; opacity: .6; }
.lightbox-top button { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--ink); line-height: 1; padding: 0; }
.lightbox-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 0 60px; position: relative; min-height: 0; }
.lightbox-body .stage { max-width: 100%; max-height: 62vh; aspect-ratio: 4/3; width: min(640px, 100%); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; }
.lightbox-body .stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-body .stage .mono { font-size: 34px; font-weight: 800; opacity: .12; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 26px; cursor: pointer; color: var(--ink); padding: 12px; }
.lightbox-nav.prev { left: 4px; }
.lightbox-nav.next { right: 4px; }
.lightbox-caption { padding: 18px 28px 44px; max-width: 640px; margin: 0 auto; text-align: center; }
.lightbox-caption h3 { margin: 0 0 6px; font-size: 16px; }
.lightbox-caption p { margin: 0 0 8px; font-size: 13px; opacity: .65; }
.lightbox-caption .tools { font-size: 11px; opacity: .5; }

/* --------------------------------------------------------------- forms */
.social-rows { margin-bottom: 8px; }
.contact-form { display: flex; flex-direction: column; gap: 16px; margin-top: 22px; }
.contact-form input, .contact-form textarea {
  background: transparent; border: none; border-bottom: 1px solid var(--line-strong);
  color: var(--ink); font-family: inherit; font-size: 14px; padding: 10px 2px; width: 100%;
}
.contact-form input::placeholder, .contact-form textarea::placeholder { color: var(--ink); opacity: .4; }
.contact-form input:focus, .contact-form textarea:focus { outline: none; border-bottom-color: currentColor; }
.contact-form textarea { resize: vertical; min-height: 100px; }
.btn-solid {
  align-self: flex-start; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase;
  padding: 12px 24px; border: 1px solid currentColor; background: var(--ink); color: var(--bg);
  cursor: pointer; font-family: inherit;
}
.btn-solid:hover { opacity: .82; }
.topic-tabs { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.topic-tab { font-size: 11.5px; padding: 8px 14px; border: 1px solid currentColor; background: transparent; opacity: .55; cursor: pointer; font-family: inherit; color: var(--ink); }
.topic-tab.active { opacity: 1; font-weight: 700; }
.form-panel { display: none; }
.form-panel.active { display: block; }
.form-note { font-size: 11.5px; opacity: .55; margin-top: 10px; }

/* --------------------------------------------------------------- games */
.game-picker { display: flex; gap: 10px; margin-bottom: 26px; flex-wrap: wrap; }
.game-tab { font-size: 12.5px; padding: 9px 16px; border: 1px solid currentColor; opacity: .55; background: transparent; cursor: pointer; font-family: inherit; color: var(--ink); }
.game-tab.active { opacity: 1; font-weight: 700; background: var(--ink); color: var(--bg); }
.game-panel { display: none; }
.game-panel.active { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.game-stage { border: 1px solid var(--line-strong); padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.game-hud { display: flex; gap: 24px; font-size: 13px; font-variant-numeric: tabular-nums; }
#snakeCanvas { background: var(--bg); border: 1px solid currentColor; touch-action: none; }
.ttt-board { display: grid; grid-template-columns: repeat(3, 68px); grid-template-rows: repeat(3, 68px); border: 1px solid currentColor; }
.ttt-cell { border: 1px solid currentColor; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 700; cursor: pointer; background: transparent; font-family: inherit; color: var(--ink); }
.ttt-cell:disabled { cursor: default; }
.game-note { font-size: 12px; opacity: .55; text-align: center; max-width: 42ch; }
.game-btn { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; padding: 8px 16px; border: 1px solid currentColor; background: transparent; cursor: pointer; font-family: inherit; color: var(--ink); }
.game-btn:hover { background: var(--ink); color: var(--bg); }

/* ------------------------------------------------------------- article */
.article h2 { font-size: 22px; margin: 38px 0 14px; font-weight: 700; letter-spacing: -0.01em; }
.article h3 { font-size: 17px; margin: 26px 0 10px; font-weight: 700; }
.article p { font-size: 15px; line-height: 1.85; margin: 0 0 16px; opacity: .9; }
.article ul { margin: 0 0 16px; padding-left: 20px; font-size: 14.5px; line-height: 1.85; opacity: .9; }
.article li { margin-bottom: 4px; }
.article blockquote { border-left: 2px solid currentColor; padding-left: 18px; margin: 26px 0; font-size: 16.5px; font-style: italic; opacity: .85; }
.article pre { background: var(--line); border: 1px solid var(--line); padding: 16px; overflow-x: auto; font-size: 12.5px; line-height: 1.65; margin: 22px 0; font-family: var(--mono); }
.article figure { margin: 26px 0; }
.article figure .imgbox { border: 1px solid var(--line); aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; font-size: 10.5px; opacity: .4; text-transform: uppercase; letter-spacing: .05em; }
.article figcaption { font-size: 12px; opacity: .55; margin-top: 8px; text-align: center; }
.article-meta { font-size: 12px; opacity: .55; margin-bottom: 6px; }
.back-link { display: inline-block; font-size: 12px; opacity: .6; margin-bottom: 24px; border-bottom: 1px solid currentColor; }
.back-link:hover { opacity: 1; }

/* ---------------------------------------------------------------- misc */
.loading { opacity: .4; font-size: 13px; padding: 30px 0; }
.empty { opacity: .5; font-size: 13px; padding: 20px 0; }

.site-footer { padding: 24px 24px 24px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 11.5px; opacity: .55; max-width: 760px; margin: 0 auto; }
.site-footer a { border-bottom: 1px solid currentColor; opacity: 1; }
.site-footer a:hover { opacity: .6; }

@media (max-width: 820px) {
  .toc a .leader { display: none; }
  .idx-row { grid-template-columns: 40px 1fr; }
  .idx-row.idx-row-plain { grid-template-columns: 1fr; }
  .idx-row .ghost { font-size: 26px; }
  .field-row { grid-template-columns: 1fr; }
  .field-row .y { opacity: .5; }
  .skill-groups { grid-template-columns: 1fr; }
  .art-grid { grid-template-columns: repeat(2, 1fr); }
  .exp-block .date { white-space: normal; }
  .lightbox-body { padding: 0 12px; }
  .lightbox-nav { padding: 8px; font-size: 22px; }

  .band .avatar { width: 128px; height: 128px; border-radius: 12px; }
  .band .band-head { gap: 18px; }

  .nav-toggle { display: flex; }
  .topbar { padding: 0 20px; }
  .topbar .topbar-nav {
    order: 3; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 0; background: var(--bg);
    max-height: 0; overflow: hidden; border-bottom: 0 solid var(--line);
    transition: max-height .2s ease;
  }
  .topbar.nav-open .topbar-nav { max-height: 400px; border-bottom-width: 1px; }
  .topbar .topbar-nav li { width: 100%; border-top: 1px solid var(--line); }
  .topbar .topbar-nav a { display: block; padding: 12px 20px; }
  .cv-link { display: none; }

  .topbar-nav-cv { display: block; }
  .topbar-nav-cv a {
    font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
    font-weight: 700; opacity: 1;
  }
}
