:root {
  color-scheme: dark;
  --bg: #0e0f11;
  --surface: #15171a;
  --border: #26282d;
  --text: #f1f1f3;
  --text-muted: #a3a5ad;
  --scrim: rgb(0 0 0 / .7);
  --accent: #b6f04a;
  --warn: #d9a441;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 8px;
  --col-text: 26rem;
  --col-wide: 60rem;
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; } /* no layout shift when the open modal hides the page scrollbar */

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 var(--font-sans);
  -webkit-text-size-adjust: 100%;
}

main { padding: 0 max(1.25rem, env(safe-area-inset-right)) 4rem max(1.25rem, env(safe-area-inset-left)); }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.hero {
  max-width: var(--col-wide); /* wide enough that the one-line intro stays on one line on desktop */
  margin: 0 auto;
  padding: 3.5rem 0 2.5rem;
  text-align: center;
  animation: enter .5s ease-out both;
}
h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.hero p { margin: .75rem 0 0; color: var(--text-muted); text-wrap: balance; }

section { margin: 0 auto; padding-top: 2.5rem; }
.text { max-width: var(--col-text); }
.wide { max-width: var(--col-wide); }
.text p { margin: 0 0 1rem; color: var(--text-muted); }

h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
h2 span {
  margin-right: .35em;
  font: 400 .8125rem var(--font-mono);
  letter-spacing: .04em;
  color: var(--accent);
}

#project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
@media (min-width: 720px) {
  #project-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.card {
  display: block;
  min-width: 0;
  padding: .5rem .5rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: transform .15s;
  animation: enter .4s ease-out backwards; /* backwards: nothing is held after the entry, so hover transform still works */
}
.card:nth-child(2) { animation-delay: .06s; }
.card:nth-child(3) { animation-delay: .12s; }
.card:nth-child(4) { animation-delay: .18s; }
.card:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
@media (hover: hover) { .card:hover { border-color: var(--accent); transform: translateY(-2px); } }
.card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  color: var(--text-muted);
  font-size: .75rem;
}
.card h3 { margin: .625rem .25rem 0; font-size: 1rem; line-height: 1.3; overflow-wrap: anywhere; }
.card p { margin: .25rem .25rem 0; color: var(--text-muted); font-size: .8125rem; line-height: 1.45; }

.wip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem 1rem;
  margin-top: 1rem;
  padding: .625rem .875rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
}
.wip-line { flex: 1 1 14rem; min-width: 0; color: var(--text-muted); }
.wip-tag { font: .75rem var(--font-mono); color: var(--warn); }

#projects noscript ul { margin: 1rem 0 0; padding-left: 1.25rem; color: var(--text-muted); }

.links { list-style: none; margin: 0; padding: 0; }
.links a {
  display: flex;
  justify-content: space-between;
  padding: .625rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.links a:hover { color: var(--accent); }

dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(44rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  transform: translateY(1rem);
  transition-property: opacity, transform, display, overlay;
  transition-duration: .25s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete; /* separate longhand: the shorthand would make older browsers drop the whole rule */
}
dialog[open] {
  opacity: 1;
  transform: none;
  @starting-style { opacity: 0; transform: translateY(1rem); }
}
dialog::backdrop {
  background: var(--scrim);
  opacity: 0;
  transition-property: opacity, display, overlay;
  transition-duration: .25s;
  transition-behavior: allow-discrete;
}
dialog[open]::backdrop {
  opacity: 1;
  @starting-style { opacity: 0; }
}
body:has(dialog[open]) { overflow: hidden; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.dlg-head h2 { margin: 0; }
dialog h3 { font-size: .875rem; color: var(--text-muted); margin: 1.25rem 0 .5rem; }
.dlg-main { display: block; width: 100%; height: auto; margin: 1rem 0 .5rem; border-radius: var(--radius); background: var(--bg); }
.dlg-strip { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.dlg-strip button { padding: 0; width: 5rem; background: none; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; overflow: hidden; }
.dlg-strip button[aria-current] { border-color: var(--accent); }
.dlg-strip img { display: block; width: 100%; height: auto; }
.tags { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 1rem 0; }
.tags li { font: .8125rem var(--font-mono); color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: .125rem .5rem; }
.dlg-links { display: flex; flex-wrap: wrap; gap: .75rem; }
.btn { font: inherit; font-size: .9375rem; color: var(--text); background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem 1rem; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
@media (max-width: 720px) {
  dialog {
    width: 100vw; height: 100dvh; max-width: none; max-height: none; border-radius: 0; border: 0;
    padding: max(1.25rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
  }
}

@keyframes enter { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::backdrop {
    animation: none !important;
    transition: none !important;
  }
}
