:root {
  --sky: #beE9f6;
  --paper: #f4f6f7;
  --bar: #7fcde3;
  --bar-hover: rgba(0, 0, 0, 0.14);
  --ink: #000000;
  --shadow-lg: 0.625rem 0.625rem 0 var(--ink);
  --shadow-md: 0.375rem 0.375rem 0 var(--ink);
  --shadow-sm: 0.25rem 0.25rem 0 var(--ink);
  --border-lg: 3px solid var(--ink);
  --border-md: 2px solid var(--ink);
  --heat-0: #e3e8e9;
  --heat-3: #45b0cc;
  --heat-cell: 0.625rem;
  --heat-gap: 0.2rem;
  --heat-col: calc(var(--heat-cell) + var(--heat-gap));
}

* {
  box-sizing: border-box;
}

/* fluid root: every rem below scales with viewport width, % keeps user font prefs */
html {
  font-size: clamp(93.75%, 88% + 0.35vw, 150%);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--sky);
  color: var(--ink);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
  line-height: 1.7;
  overflow-x: clip;
}

::selection {
  background: var(--ink);
  color: var(--sky);
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.desktop {
  max-width: 57.5rem;
  margin: 0 auto;
  padding: 3.5rem 1.25rem 8.75rem;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

/* ---------- window chrome ---------- */

.window {
  background: var(--paper);
  border: var(--border-lg);
  box-shadow: var(--shadow-lg);
}

.window.is-max {
  width: 100vw;
  margin-left: calc(50% - 50vw);
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  height: 2.875rem;
  padding: 0 0.5rem 0 1rem;
  background: var(--bar);
  border-bottom: var(--border-lg);
}

.titlebar-label {
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.titlebar-controls {
  display: flex;
  gap: 0.25rem;
}

.ctrl {
  position: relative;
  width: 2.375rem;
  height: 2.125rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.ctrl::after {
  content: "";
  position: absolute;
  inset: -0.375rem;
}

.ctrl:hover {
  background: var(--bar-hover);
}

.ctrl:active {
  background: rgba(0, 0, 0, 0.24);
}

.ctrl svg {
  width: 0.75rem;
  height: 0.75rem;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
}

.window.is-min .window-body {
  display: none;
}

.window-body {
  padding: 2rem 2.25rem 2.5rem;
}

/* ---------- type ---------- */

h1 {
  margin: 0 0 1.25rem;
  font-size: 2.625rem;
  font-weight: 800;
  line-height: 1.15;
}

h2 {
  margin: 0 0 1.25rem;
  font-size: 1.875rem;
  font-weight: 800;
  line-height: 1.2;
}

h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
}

p {
  margin: 0 0 0.875rem;
}

.lede {
  font-size: 1.0625rem;
  max-width: 62ch;
}

.facts {
  font-size: 0.875rem;
  line-height: 1.9;
  margin-bottom: 1.375rem;
}

.caret {
  animation: blink 1.1s steps(1) infinite;
}

/* ---------- about portrait ---------- */

.about-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.75rem;
  margin-bottom: 1.5rem;
}

.portrait {
  margin: 0;
  width: 13.125rem;
  max-width: 100%;
  flex: 0 0 auto;
  border: var(--border-lg);
  box-shadow: var(--shadow-md);
  background: var(--paper);
}

.portrait svg,
.portrait-img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--bar);
}

.portrait svg path {
  stroke: var(--ink);
  stroke-width: 3;
}

.portrait figcaption {
  border-top: var(--border-lg);
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 700;
}

.about-text {
  flex: 1 1 16.25rem;
  min-width: 0;
}

.about-text p:last-child {
  margin-bottom: 0;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ---------- chips / buttons ---------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
}

.chip {
  display: inline-block;
  padding: 0.5625rem 1rem;
  border: var(--border-md);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
}

.chip-primary {
  background: var(--bar);
}

.chip:hover {
  transform: translate(-2px, -2px);
  box-shadow: 0.375rem 0.375rem 0 var(--ink);
}

.chip:active {
  transform: translate(2px, 2px);
  box-shadow: 0.125rem 0.125rem 0 var(--ink);
}

/* ---------- teams ---------- */

.entry {
  --entry-pad-top: 1.25rem;
  position: relative;
  /* right gutter reserves room for the out-of-flow link column */
  padding: var(--entry-pad-top) 6.5rem 1.25rem 0;
  border-bottom: 0.125rem dashed rgba(0, 0, 0, 0.28);
}

.entry:first-of-type {
  --entry-pad-top: 0.25rem;
}

.entry:last-of-type {
  border-bottom: 0;
  padding-bottom: 0;
}

.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}

.entry-side {
  position: absolute;
  top: var(--entry-pad-top);
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.375rem;
}

.entry-links {
  display: flex;
  gap: 0.375rem;
}

.icon-link {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: var(--border-md);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  transition: transform 150ms ease-out, box-shadow 150ms ease-out, background 150ms ease-out;
}

.icon-link svg {
  width: 0.9375rem;
  height: 0.9375rem;
  fill: currentColor;
}

.icon-link:hover {
  background: var(--bar);
  transform: translate(-0.0625rem, -0.0625rem);
  box-shadow: 0.3125rem 0.3125rem 0 var(--ink);
}

.icon-link:active {
  transform: translate(0.125rem, 0.125rem);
  box-shadow: 0 0 0 var(--ink);
}

.meta {
  font-size: 0.8125rem;
  font-weight: 700;
}

.role {
  margin: 0.125rem 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.entry p:last-child {
  margin: 0;
  max-width: 68ch;
}

/* ---------- projects ---------- */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17.5rem), 1fr));
  gap: 1.625rem;
}

.card {
  border: var(--border-md);
  box-shadow: var(--shadow-md);
  background: var(--paper);
  padding: 1.25rem 1.25rem 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.card p {
  margin: 0;
  font-size: 0.90625rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  border: var(--border-md);
  background: var(--bar);
  padding: 0.0625rem 0.5625rem;
  font-size: 0.8125rem;
  font-weight: 700;
}

.links {
  margin-top: auto;
  display: flex;
  gap: 1.125rem;
}

.links a,
.contrib-list a,
.heat-foot a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 0.125rem;
  text-underline-offset: 0.1875rem;
}

.links a:hover,
.contrib-list a:hover {
  background: var(--bar);
}

/* ---------- contributions ---------- */

.contrib-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.contrib-list li {
  position: relative;
  padding: 0.25rem 0 0.25rem 1.625rem;
  margin-bottom: 1rem;
}

.contrib-list li::before {
  content: "+";
  position: absolute;
  left: 0.125rem;
  top: 0.25rem;
  font-weight: 800;
  font-size: 1.125rem;
}

.contrib-list li p {
  margin: 0 0 0.375rem;
  max-width: 68ch;
}

/* ---------- commit heatmap ---------- */

.heat-panel {
  margin-top: 1.75rem;
  border: var(--border-md);
  box-shadow: var(--shadow-sm);
  background: var(--paper);
  padding: 1rem 1rem 0.875rem;
}

.heat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.75rem;
}

.heat-total {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
}

.heat-body {
  display: flex;
  gap: 0.5rem;
}

.heat-days {
  display: grid;
  grid-template-rows: repeat(7, var(--heat-cell));
  gap: var(--heat-gap);
  padding-top: calc(1.125rem + var(--heat-gap));
  font-size: 0.625rem;
  font-weight: 700;
  line-height: var(--heat-cell);
}

.heat-scroll {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--bar) var(--paper);
}

.heat-scroll::-webkit-scrollbar {
  height: 0.625rem;
}

.heat-scroll::-webkit-scrollbar-track {
  background: var(--paper);
  border: var(--border-md);
}

.heat-scroll::-webkit-scrollbar-thumb {
  background: var(--bar);
  border-left: var(--border-md);
}

.heat-months {
  display: flex;
  gap: var(--heat-gap);
  height: 1.125rem;
  margin-bottom: var(--heat-gap);
  font-size: 0.625rem;
  font-weight: 700;
}

.heat-month {
  overflow: hidden;
  white-space: nowrap;
}

.heat-grid {
  display: flex;
  gap: var(--heat-gap);
  width: max-content;
}

.heat-week {
  display: grid;
  grid-template-rows: repeat(7, var(--heat-cell));
  gap: var(--heat-gap);
}

.heat-cell {
  width: var(--heat-cell);
  height: var(--heat-cell);
  background: var(--heat-0);
}

.heat-cell.lv1 {
  background: var(--sky);
}

.heat-cell.lv2 {
  background: var(--bar);
}

.heat-cell.lv3 {
  background: var(--heat-3);
}

.heat-cell.lv4 {
  background: var(--ink);
}

.heat-cell.blank {
  visibility: hidden;
}

.heat-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.heat-legend {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.heat-error {
  font-size: 0.875rem;
  font-weight: 700;
  padding: 0.5rem 0;
}

/* ---------- tetris ---------- */

.tetris-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
  margin-top: 1.25rem;
}

.tetris-board-wrapper {
  position: relative;
  width: 200px;
  height: 400px;
  border: var(--border-lg);
  box-shadow: var(--shadow-md);
  background: #000;
  overflow: hidden;
  flex-shrink: 0;
}

#tetris-canvas {
  display: block;
  width: 200px;
  height: 400px;
  background: #000;
}

.tetris-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  text-align: center;
  color: var(--sky);
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1.5;
  text-transform: lowercase;
  pointer-events: none;
}

.tetris-overlay.is-hidden {
  display: none;
}

.tetris-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  min-width: 8.5rem;
}

.tetris-stat-box {
  background: var(--paper);
  border: var(--border-md);
  box-shadow: var(--shadow-sm);
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.tetris-stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.tetris-stat-val {
  font-size: 1.25rem;
  font-weight: 800;
}

#tetris-next-canvas {
  display: block;
  background: #000;
  border: 1px solid var(--ink);
  margin-top: 0.25rem;
}

.tetris-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.tetris-actions .chip {
  text-align: center;
  width: 100%;
}

.tetris-actions .chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-sm);
}

/* ---------- footer / taskbar ---------- */

.footer p {
  margin: 0;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 500;
}

.taskbar {
  position: fixed;
  left: 50%;
  bottom: 1.125rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: calc(100vw - 2rem);
  padding: 0.625rem 0.875rem;
  background: var(--paper);
  border: var(--border-lg);
  box-shadow: var(--shadow-md);
  z-index: 50;
}

.taskbar-label {
  font-size: 0.8125rem;
  font-weight: 700;
}

.tasklist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.task-chip {
  border: var(--border-md);
  background: var(--bar);
  padding: 0.625rem 0.875rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0.1875rem 0.1875rem 0 var(--ink);
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
}

.task-chip:hover {
  transform: translate(-1px, -1px);
  box-shadow: 0.25rem 0.25rem 0 var(--ink);
}

.task-chip:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

/* the reserved gutter costs too much text width on phones: stack the links back into flow */
@media (max-width: 640px) {
  .entry {
    padding-right: 0;
  }

  .entry-side {
    position: static;
    align-items: flex-start;
    margin-top: 0.375rem;
  }
}

/* integer step keeps line weights crisp where the fluid scale outgrows 3px */
@media (min-width: 1800px) {
  :root {
    --border-lg: 4px solid var(--ink);
    --border-md: 3px solid var(--ink);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
