@font-face {
  font-family: "Pixel Arial 11";
  src: url("../assets/fonts/PixelArial11-Regular.TTF") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Pixel Arial 11";
  src: url("../assets/fonts/PixelArial11-Bold.TTF") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #fff;
  --text: #111;
  --muted: #8b8b8b;
  --line: #d7d7d7;
  --hover: #8d8d8d;
  --soft: #f2f2f2;
  --site-width: 900px;
  --page-height: 420px;
  --project-height: 500px;
  --home-height: 250px;
  --fade-time: 220ms;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  min-height: 100svh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Pixel Arial 11", monospace;
  font-size: 11px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  font-synthesis: none;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
img, video { display: block; max-width: 100%; }

/* ---------------------------------------------------------
   Loading + page transitions
   The navigation/chrome stays visible at all times. Only the
   page content fades while the loading label is displayed.
   --------------------------------------------------------- */
.site-loader {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: transparent;
  opacity: 0;
  visibility: hidden;
  transition: opacity 140ms linear, visibility 0s linear 140ms;
}
.site-loader__label {
  color: var(--muted);
  white-space: nowrap;
  font-weight: 400;
}
.loader-dot {
  display: inline-block;
  opacity: .18;
  animation: loader-dot 900ms steps(1, end) infinite;
}
.loader-dot:nth-child(2) { animation-delay: 150ms; }
.loader-dot:nth-child(3) { animation-delay: 300ms; }
@keyframes loader-dot {
  0%, 24% { opacity: .18; }
  25%, 74% { opacity: 1; }
  75%, 100% { opacity: .18; }
}

.site-shell {
  width: min(var(--site-width), calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.js .site-shell > main {
  opacity: 1;
  transition: opacity var(--fade-time) ease;
}
.js body[data-page-state="loading"] .site-shell > main,
.js body[data-page-state="leaving"] .site-shell > main { opacity: 0; }
.js body[data-page-state="loading"] .site-loader,
.js body[data-page-state="leaving"] .site-loader {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}
.no-js .site-loader { display: none; }

/* ---------------------------------------------------------
   Fixed 900px content object
   --------------------------------------------------------- */
.page,
.work-page {
  width: 100%;
  height: min(var(--page-height), calc(100svh - 120px));
  margin: 0;
  padding: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
}
.page::-webkit-scrollbar,
.work-page::-webkit-scrollbar { width: 7px; height: 7px; }
.page::-webkit-scrollbar-track,
.work-page::-webkit-scrollbar-track { background: transparent; }
.page::-webkit-scrollbar-thumb,
.work-page::-webkit-scrollbar-thumb { background: var(--muted); }

.page-title { margin: 0 0 28px; font-size: inherit; font-weight: 400; }
.muted { color: var(--muted); }
.empty-state { margin: 0; color: var(--muted); }

/* ---------------------------------------------------------
   Navigation — always directly under content box
   --------------------------------------------------------- */
.site-footer {
  width: 100%;
  min-height: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  background: var(--bg);
}
.footer-nav,
.display-switch {
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.footer-nav { gap: 16px; }
.display-switch { gap: 3px; justify-self: center; }
.footer-nav a,
.display-switch button { color: var(--muted); }
.footer-nav a:hover,
.display-switch button:hover { color: var(--text); }
.footer-nav a[aria-current="page"],
.display-switch button.is-active {
  color: var(--text);
  font-weight: 400;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.display-switch::before { content: "Display:"; margin-right: 1px; }
.display-switch button {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.footer-copyright {
  justify-self: end;
  white-space: nowrap;
}

/* Site credit easter egg */
.site-credit-trigger {
  position: relative;
  cursor: default;
  outline: none;
  user-select: none;
}
.site-credit-trigger__label::after {
  content: " +";
  opacity: 0;
  transition: opacity 90ms linear;
}
.site-credit-trigger:hover .site-credit-trigger__label::after,
.site-credit-trigger:focus-visible .site-credit-trigger__label::after,
.site-credit-trigger.is-open .site-credit-trigger__label::after { opacity: .45; }
.site-credit-trigger:hover { cursor: pointer; }
.site-credit-trigger:focus-visible .site-credit-trigger__label {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.site-credit-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: min(420px, calc(100vw - 32px));
  color: var(--muted);
  background: var(--bg);
  white-space: normal;
  text-align: right;
}
.site-credit-popover[hidden] { display: none; }

/* ---------------------------------------------------------
   Home — 4 selected projects / one continuous image strip
   --------------------------------------------------------- */
.page--home {
  height: min(var(--home-height), calc((100vw - 32px) * .4545));
  max-height: var(--home-height);
  overflow: hidden;
}
.project-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  background: var(--soft);
}
.project-card {
  min-width: 0;
  height: 100%;
  overflow: hidden;
}
.project-card__media {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--soft);
}
.project-card__media img,
.project-card__media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 120ms linear;
}
.project-card:hover .project-card__media img,
.project-card:focus-visible .project-card__media img { opacity: .82; }
.project-card:focus-visible { outline: 1px solid var(--text); outline-offset: -1px; }

/* ---------------------------------------------------------
   Work — Grid / List
   --------------------------------------------------------- */
.work-page { padding-right: 7px; }
.work-view[hidden] { display: none !important; }
.work-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px 10px;
}
.work-grid-card { min-width: 0; }
.work-grid-card__media {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--soft);
}
.work-grid-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.work-grid-card__title {
  padding-top: 5px;
  color: var(--muted);
  line-height: 1.2;
}
.work-grid-card__title span {
  display: inline;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.work-grid-card:hover .work-grid-card__media {
  outline: 3px solid #696969;
  outline-offset: -3px;
}
.work-grid-card:hover .work-grid-card__title { color: #fff; }
.work-grid-card:hover .work-grid-card__title span {
  background: #696969;
  padding: 1px 3px 2px;
}

.work-list-wrap { width: 100%; overflow-x: auto; padding-bottom: 6px; }
.work-list { min-width: 520px; }
.work-list__header,
.work-list__row {
  display: grid;
  grid-template-columns: minmax(170px, 1.8fr) 92px 125px 44px;
  column-gap: 10px;
  align-items: baseline;
}
.work-list__header {
  padding: 0 0 12px;
  color: var(--muted);
  font-weight: 400;
}
.work-list__header span {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.work-list__header span:last-child,
.work-list__row span:last-child { text-align: right; }
.work-list__row {
  margin: 0;
  padding: 2px 0;
  color: var(--muted);
  line-height: 1.25;
}
.work-list__row:hover,
.work-list__row:focus-visible {
  color: #fff;
  background: var(--hover);
  outline: none;
}
.work-hover-preview {
  position: fixed;
  z-index: 30;
  width: 170px;
  aspect-ratio: 1 / 1;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  background: var(--soft);
  transition: opacity 80ms linear;
}
.work-hover-preview.is-visible { opacity: 1; visibility: visible; }
.work-hover-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------------------------------------------------
   Project page — current structure; text layout will be
   refined after the supplied project-page reference.
   --------------------------------------------------------- */
.page--project {
  height: min(var(--project-height), calc(100svh - 120px));
  padding-right: 7px;
}
.project-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
  align-items: start;
}
.project-stage {
  min-height: 350px;
  background: var(--soft);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.project-stage img,
.project-stage video {
  width: 100%;
  max-height: 430px;
  object-fit: contain;
  background: #fff;
}
.project-thumbs {
  display: grid;
  gap: 5px;
  align-content: start;
  position: sticky;
  top: 0;
}
.thumb {
  appearance: none;
  border: 1px solid transparent;
  background: none;
  padding: 0;
  cursor: pointer;
  opacity: .45;
}
.thumb:hover,
.thumb.is-active { opacity: 1; }
.thumb.is-active { border-color: var(--text); }
.thumb img,
.thumb video {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--soft);
}
.thumb__fallback {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--muted);
  font-size: 10px;
}
.project-info {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 22px;
  margin-top: 18px;
  padding-bottom: 28px;
}
.project-info h1 { margin: 0; font-size: inherit; font-weight: 700; }
.project-info p { margin: 0; }
.project-details { display: grid; gap: 6px; }
.project-details p:first-child { margin-bottom: 8px; }
.project-details span {
  display: inline-block;
  min-width: 54px;
  color: var(--muted);
}

/* ---------------------------------------------------------
   About + Connect
   --------------------------------------------------------- */
.text-page {
  display: grid;
  align-content: start;
  gap: 34px;
  padding-right: 7px;
}
.text-page section { display: grid; gap: 9px; }
.text-page h1,
.text-page h2,
.text-page p { margin: 0; }
.text-page h1,
.text-page h2 { font-size: inherit; }
.text-page h1 { font-weight: 400; }
.text-page h2 { color: var(--muted); font-weight: 400; }
.resume-list,
.connect-list { border-top: 1px solid var(--line); }
.resume-row,
.connect-row {
  display: grid;
  grid-template-columns: 105px minmax(0, 1fr);
  gap: 14px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.resume-row > :first-child,
.connect-row > :first-child { color: var(--muted); }
.connect-row:hover > :last-child { text-decoration: underline; text-underline-offset: 2px; }
.random-redirect-page { display: grid; place-items: center; }

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */
@media (max-width: 590px) {
  body { padding: 14px 10px; overflow: auto; }
  .site-shell { width: min(var(--site-width), calc(100vw - 20px)); }
  .page--home { height: calc((100vw - 20px) * .4545); }

  .site-footer {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "nav copyright"
      "display display";
    row-gap: 7px;
  }
  .footer-nav { grid-area: nav; gap: 10px; flex-wrap: wrap; }
  .footer-copyright { grid-area: copyright; }
  .display-switch { grid-area: display; justify-self: start; }

  .work-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .work-hover-preview { display: none; }
  .project-layout { grid-template-columns: minmax(0, 1fr) 50px; }
  .project-stage { min-height: 280px; }
  .project-info { grid-template-columns: 1fr; gap: 10px; }
}

@media (max-width: 420px) {
  .footer-copyright { display: none; }
  .site-footer { grid-template-columns: 1fr; grid-template-areas: "nav" "display"; }
  .footer-nav { gap: 9px; }
  .work-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .js .site-shell,
  .site-loader,
  .site-credit-trigger__label::after,
  .work-hover-preview,
  .project-card__media img { transition: none; }
  .loader-dot { animation: none; opacity: 1; }
}
