:root {
  --bg: #1a1829;
  --bg-deep: #141221;
  --bg-raised: #252242;
  --rule: #3a3760;
  --text: #e8e6f0;
  --text-muted: #a8a5b8;
  --accent: #d4a84b;
  --accent-soft: rgba(212, 168, 75, 0.08);
  --focus: #f0c66a;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: 16px;
  --measure: 34rem;
  --measure-wide: 66rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: clamp(2.5rem, 7vh, 5rem);
  padding-inline: var(--gutter);
  color: var(--text);
  font: 400 1rem/1.6 var(--sans);
  background-color: var(--bg);
  background-image:
    radial-gradient(
      ellipse 70% 55% at 50% 0%,
      rgba(58, 55, 96, 0.55),
      transparent 70%
    ),
    radial-gradient(
      ellipse 60% 50% at 85% 100%,
      rgba(212, 168, 75, 0.05),
      transparent 70%
    ),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Faint paper grain — static SVG noise, very low opacity */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page {
  position: relative;
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
}

/* Header */
header {
  margin-bottom: clamp(2rem, 5vh, 3rem);
}

.mark {
  display: block;
  width: 2.25rem;
  height: 1px;
  margin-bottom: 1.5rem;
  background: var(--accent);
}

h1 {
  margin: 0 0 0.75rem;
  font-family: var(--serif);
  font-weight: 350;
  font-variation-settings:
    "opsz" 144,
    "SOFT" 50;
  font-size: clamp(2.75rem, 9vw, 4.25rem);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}

.lede {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.15rem, 3.4vw, 1.35rem);
  line-height: 1.4;
  color: var(--accent);
}

/* One line at every width: the type steps down with the column rather than
   wrapping. The divisor is the line's length in ems, so 100cqi / 28 is the
   largest size that still fits; change it if the sentence changes. */
header {
  container-type: inline-size;
}

.lede-follow {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
  font-size: min(0.95rem, 100cqi / 28);
  white-space: nowrap;
}

/* Projects */
.label {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.projects {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.projects li {
  border-bottom: 1px solid var(--rule);
}

.projects > li > a {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 1rem;
  padding: 0.95rem 0.75rem;
  margin: 0 -0.75rem;
  color: inherit;
  text-decoration: none;
  border-radius: 2px;
  transition: background-color 200ms ease;
}

.projects > li > a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform 220ms ease;
}

.project-name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.2rem;
  line-height: 1.3;
  transition: color 200ms ease;
}

.project-desc {
  grid-column: 1 / 2;
  margin-top: 0.15rem;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.arrow {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 1rem;
  color: var(--text-muted);
  transition:
    color 200ms ease,
    transform 220ms ease;
}

.tag {
  display: inline-block;
  margin-left: 0.55rem;
  padding: 0.05rem 0.4rem;
  vertical-align: 0.2em;
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(212, 168, 75, 0.45);
  border-radius: 2px;
}

.projects > li > a:hover,
.projects > li > a:focus-visible {
  background-color: var(--accent-soft);
}
.projects > li > a:hover::before,
.projects > li > a:focus-visible::before {
  transform: scaleY(1);
}
.projects > li > a:hover .project-name,
.projects > li > a:focus-visible .project-name {
  color: var(--accent);
}
.projects > li > a:hover .arrow,
.projects > li > a:focus-visible .arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

/* Footer */
footer {
  margin-top: clamp(2rem, 5vh, 3rem);
  font-size: 0.92rem;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.links a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
  transition:
    color 200ms ease,
    text-decoration-color 200ms ease;
}

.links a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* Focus */
a:focus {
  outline: none;
}
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Gentle entrance */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
header,
main,
footer {
  animation: rise 700ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
main {
  animation-delay: 90ms;
}
footer {
  animation-delay: 180ms;
}

/* Self-hosted projects carry a second link under the row (the server image),
   so it sits outside the row's own link rather than nested in it. */
.project-extra {
  margin: -0.45rem 0 0;
  padding-bottom: 0.85rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.project-extra a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 0.25em;
  transition:
    color 200ms ease,
    text-decoration-color 200ms ease;
}

.project-extra a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

section + section {
  margin-top: clamp(1.75rem, 4vh, 2.5rem);
}

/* Split — two columns on wide screens. The left column's top (gold rule)
   aligns with the PROJECTS label; its links sit on the list's last rule. */
@media (min-width: 900px) {
  body {
    padding-inline: clamp(2.5rem, 6vw, 5rem);
  }

  .page {
    max-width: var(--measure-wide);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "intro list"
      ".     list"
      "links list";
    column-gap: clamp(4rem, 8vw, 7.5rem);
    align-items: start;
  }

  /* Gold rule sits on the PROJECTS label's centre line. */
  header {
    grid-area: intro;
    margin-bottom: 0;
    padding-top: 0.55rem;
  }
  main {
    grid-area: list;
  }
  footer {
    grid-area: links;
    margin-top: 2.5rem;
    align-self: end;
  }

  h1 {
    font-size: clamp(3.75rem, 5.6vw, 5rem);
    margin-bottom: 1.1rem;
  }
  .lede {
    font-size: 1.45rem;
  }
  .lede-follow {
    margin-top: 0.5rem;
  }

  .label {
    margin-bottom: 0.85rem;
  }
  .projects > li > a {
    padding-block: 0.8rem;
  }
  .project-name {
    font-size: 1.3rem;
  }

  /* Links stack and bottom-align with the list's last rule. */
  .links {
    flex-direction: column;
    gap: 0.55rem;
  }
  .links a {
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  .projects > li > a {
    padding: 0.85rem 0.5rem;
    margin: 0 -0.5rem;
  }
  .project-name {
    font-size: 1.1rem;
  }
}

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