/* fonts ------------------------------------------------------------------ */

@font-face {
  font-family: "EnvyCodeR NF";
  src: url("../assets/fonts/EnvyCodeRNerdFont-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "EnvyCodeR NF";
  src: url("../assets/fonts/EnvyCodeRNerdFont-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* tokens: monochrome only - blacks, greys, whites --------------------------- */

:root {
  --bg: #080808;
  --panel: #0f0f0f;
  --panel-2: #141414;
  --line: #262626;
  --line-bright: #3d3d3d;
  --text: #dcdcdc;
  --muted: #8c8c8c;
  --dim: #4d4d4d;
  --white: #ffffff;
  --glow: rgba(255, 255, 255, 0.25);
  color-scheme: dark;
}

/* base -------------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

html {
  scrollbar-color: var(--line-bright) var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "EnvyCodeR NF", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
}

pre {
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

a {
  color: var(--white);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

a:hover {
  background: var(--white);
  color: #000;
  text-decoration: none;
}

kbd {
  font: inherit;
  border: 1px solid var(--line-bright);
  border-radius: 3px;
  padding: 0 0.4ch;
  color: var(--white);
}

::selection {
  background: var(--white);
  color: #000;
}

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

/* utilities ---------------------------------------------------------------- */

.muted {
  color: var(--muted);
}

.nf {
  display: inline-block;
  min-width: 1.5ch;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  background: var(--white);
  color: #000;
  padding: 0.5rem 1rem;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

/* status bar ---------------------------------------------------------------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 1rem;
  font-size: 0.85em;
}

.bar-id {
  color: var(--white);
  font-weight: 700;
}

.bar-ws {
  display: flex;
  gap: 0.4rem;
}

.ws {
  border: 1px solid var(--line);
  color: var(--dim);
  padding: 0 0.6ch;
}

.ws.on {
  background: var(--white);
  color: #000;
  border-color: var(--white);
}

.bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

#term-toggle {
  font: inherit;
  background: none;
  border: 1px solid var(--line-bright);
  color: var(--text);
  padding: 0.1rem 0.6ch;
  cursor: pointer;
}

#term-toggle:hover,
#term-toggle[aria-expanded="true"] {
  background: var(--white);
  color: #000;
  border-color: var(--white);
}

#clock {
  color: var(--muted);
}

.bar-bottom {
  position: static;
  border-top: 1px solid var(--line);
  border-bottom: none;
  justify-content: space-between;
  color: var(--muted);
}

/* desktop grid ----------------------------------------------------------------- */

.desktop {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  padding: 14px;
  max-width: 1800px;
  margin-inline: auto;
  min-height: calc(100vh - 5rem);
}

.w-4 { grid-column: span 4; }
.w-5 { grid-column: span 5; }
.w-7 { grid-column: span 7; }
.w-12 { grid-column: span 12; }

@media (max-width: 1000px) {
  .w-4, .w-5, .w-7 { grid-column: span 6; }
  .w-12 { grid-column: span 12; }
}

@media (max-width: 660px) {
  .w-4, .w-5, .w-7, .w-12 { grid-column: span 12; }
  .desktop { gap: 10px; padding: 10px; }
}

/* windows ----------------------------------------------------------------------- */

.win {
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.win:hover {
  border-color: var(--line-bright);
}

.win-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  padding: 0.35rem 0.8rem;
}

.win-bar h2,
.win-title {
  font-size: 0.85em;
  font-weight: 700;
  color: var(--white);
  margin: 0;
}

.win-bar h2::before,
.win-title::before {
  content: "~/";
  content: "~/" / "";
  color: var(--dim);
  font-weight: 400;
}

.term-float .win-title::before {
  content: none;
}

.win-btns {
  color: var(--dim);
  font-size: 0.8em;
  letter-spacing: 0.5ch;
  white-space: nowrap;
}

.win-body {
  padding: 1rem 1.2rem 1.2rem;
  min-width: 0;
}

.win-body > :first-child {
  margin-top: 0;
}

.win-body > :last-child {
  margin-bottom: 0;
}

/* hero ---------------------------------------------------------------------- */

.hero .win-body {
  position: relative;
  padding-block: 2rem;
}

.hero .win-body::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.02) 0 1px,
    transparent 1px 3px
  );
}

.banner {
  font-size: clamp(0.72rem, 4vw, 1.1rem);
  line-height: 1.15;
  color: var(--white);
  text-shadow: 0 0 14px var(--glow);
  margin-bottom: 1rem;
}

.prompt-line {
  margin: 0 0 1.2rem;
}

.prompt-user {
  color: var(--white);
  font-weight: 700;
}

.prompt-path {
  color: var(--muted);
}

.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.05em;
  background: var(--white);
  box-shadow: 0 0 8px var(--glow);
  vertical-align: text-bottom;
}

.intro {
  max-width: 68ch;
}

/* currently ---------------------------------------------------------------------- */

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

.now-list li {
  position: relative;
  padding-left: 2rem;
  margin-bottom: 0.9rem;
}

.now-list li:last-child {
  margin-bottom: 0;
}

.now-list li::before {
  content: "->";
  content: "->" / "";
  position: absolute;
  left: 0;
  color: var(--muted);
}

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

h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.75ch;
  font-size: 1em;
  margin: 0 0 0.5rem;
}

.role {
  color: var(--muted);
  font-weight: 400;
}

.dates,
.stack {
  margin-left: auto;
  color: var(--dim);
  font-weight: 400;
  font-size: 0.85em;
}

.job,
.project {
  margin-bottom: 1.6rem;
}

.job:last-child,
.project:last-child {
  margin-bottom: 0;
}

.job p,
.project p {
  margin: 0.4rem 0;
}

/* contribution graph ----------------------------------------------------------------- */

.gh-cal {
  min-height: 7.5rem;
}

.cal-total {
  margin: 0 0 0.7rem;
  color: var(--white);
}

.cal-scroll {
  overflow-x: auto;
  padding-bottom: 0.4rem;
}

.cal {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 3px;
  width: max-content;
}

.cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
}

.c0 { background: #1a1a1a; }
.c1 { background: #3d3d3d; }
.c2 { background: #707070; }
.c3 { background: #ababab; }
.c4 { background: #f2f2f2; }

.cell.empty {
  background: transparent;
}

.cal-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 0.5rem;
  color: var(--dim);
  font-size: 0.8em;
}

/* stats ---------------------------------------------------------------------- */

.stats {
  margin: 0;
}

.stats div {
  display: flex;
  align-items: baseline;
  gap: 0.75ch;
  margin-bottom: 0.55rem;
}

.stats div:last-child {
  margin-bottom: 0;
}

.stats dt {
  display: flex;
  flex: 1;
  min-width: 0;
  color: var(--muted);
}

.stats dt::after {
  content: "";
  flex: 1;
  min-width: 2ch;
  border-bottom: 1px dotted var(--line-bright);
  margin: 0 0 0.3em 0.75ch;
}

.stats dd {
  margin: 0;
  text-align: right;
}

/* goals / reading / links ----------------------------------------------------------- */

.goals,
.reading,
.links-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.goals li,
.reading li,
.links-list li {
  margin-bottom: 0.5rem;
}

.goals li:last-child,
.reading li:last-child,
.links-list li:last-child {
  margin-bottom: 0;
}

.goals li {
  color: var(--muted);
}

.goals .done {
  color: var(--white);
}

.reading {
  margin-block: 0.5rem;
}

/* window swapping (the tiling wm bit) ----------------------------------------------- */

.desktop .win-bar {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

body.wm-dragging {
  cursor: grabbing;
  user-select: none;
}

body.wm-dragging .desktop .win-bar {
  cursor: grabbing;
}

.win.dragging {
  position: relative;
  z-index: 30;
  opacity: 0.65;
  pointer-events: none; /* so elementFromPoint sees the window underneath */
}

.win.drop-target {
  border-style: dashed;
  border-color: var(--white);
}

.win.drop-target .win-bar {
  background: var(--line);
}

/* floating terminal ---------------------------------------------------------------------- */

.term-float {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  width: min(540px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line-bright);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.75), 0 0 0 1px #000;
}

.term-drag {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.term-drag:active {
  cursor: grabbing;
}

.term-close {
  font: inherit;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.5ch;
  font-size: 1.1em;
  line-height: 1;
}

.term-close:hover {
  background: var(--white);
  color: #000;
}

.term-body {
  padding: 0.7rem 0.9rem 0.9rem;
}

.term-out {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  max-height: min(15rem, 40vh);
  overflow-y: auto;
}

.term-out:not(:empty) {
  margin-bottom: 0.5rem;
}

.t-cmd {
  color: var(--muted);
}

.t-ok {
  color: var(--white);
}

#term-form {
  display: flex;
  gap: 0.75ch;
}

.term-prompt {
  white-space: nowrap;
}

#term-in {
  flex: 1;
  min-width: 8ch;
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text);
  font: inherit;
  caret-color: var(--white);
}

#term-in:focus {
  outline: none; /* focus is shown on the window border via :focus-within */
}

.term-float:focus-within {
  border-color: var(--white);
}

@media (max-width: 660px) {
  .term-float {
    right: 0;
    bottom: 0;
    width: 100vw;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
}

/* crt mode (konami) ---------------------------------------------------------------------- */

body.crt {
  filter: contrast(1.08);
}

body.crt::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.25) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.65) 100%);
}

/* motion (all animation lives here) ------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  .cursor {
    animation: blink 1.1s steps(2, start) infinite;
  }

  .glitch {
    animation: glitch-in 0.9s steps(1) 1;
  }

  body.crt::before {
    animation: crt-roll 0.25s linear infinite;
  }

  @keyframes blink {
    to {
      visibility: hidden;
    }
  }

  @keyframes glitch-in {
    0% {
      transform: translateX(-2px) skewX(-6deg);
      text-shadow: 3px 0 var(--muted), -3px 0 var(--white);
      opacity: 0.6;
    }
    20% {
      transform: translateX(2px);
      text-shadow: -3px 0 var(--muted), 3px 0 var(--white);
    }
    45% {
      transform: translateX(-1px) skewX(3deg);
      text-shadow: 2px 0 var(--muted), -2px 0 var(--white);
      opacity: 1;
    }
    70% {
      transform: none;
      text-shadow: 1px 0 var(--muted), -1px 0 var(--white);
    }
    100% {
      transform: none;
      text-shadow: 0 0 14px var(--glow);
    }
  }

  @keyframes crt-roll {
    to {
      background-position: 0 3px, 0 0;
    }
  }
}

/* print: the site is a desktop, paper gets the plain reading order ---------------- */

@media print {
  .bar,
  .term-float,
  .win-btns {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }

  .win {
    border-color: #999;
  }
}
