/* ==========================================================
   ericsutter.online
   Homepage, blog archive, and blog post styles
   ========================================================== */

:root {
  --ink:        oklch(0.14 0.005 250);
  --ink-body:   oklch(0.26 0.01 250);
  --muted:      oklch(0.45 0.02 250);
  --label:      oklch(0.4 0.02 250);
  --accent:     oklch(0.55 0.1 230);
  --accent-ink: oklch(0.48 0.1 230);
  --hairline:   oklch(0.14 0.005 250 / 0.16);
  --card-line:  oklch(0.14 0.005 250 / 0.25);
  --paper:      oklch(0.98 0.005 90);
  --display:    'Space Grotesk', sans-serif;
  --mono:       'JetBrains Mono', monospace;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
}

a {
  color: inherit;
  text-decoration: none;
}

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

::selection {
  background: oklch(0.6 0.1 230 / 0.22);
}

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50%      { transform: translate3d(0, -10px, 0); }
}

@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  10%      { transform: translate(-2%, -4%); }
  30%      { transform: translate(3%, 2%); }
  50%      { transform: translate(-4%, 3%); }
  70%      { transform: translate(2%, -3%); }
  90%      { transform: translate(-3%, 1%); }
}

.page {
  position: relative;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  font-family: var(--mono);
}

.grain-defs {
  position: fixed;
  width: 0;
  height: 0;
}

.grain {
  position: fixed;
  inset: -10%;
  width: 120%;
  height: 120%;
  filter: url(#grainFilter);
  opacity: 0.035;
  animation: grain 8s steps(8) infinite;
  pointer-events: none;
  z-index: 5;
}

/* Fixed background layer. It carries its own perspective so the grid keeps
   its 3D tilt while staying pinned to the screen as the page scrolls. */
.backdrop {
  position: fixed;
  inset: 0;
  perspective: 1400px;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

/* 3D floor grid, tilted in perspective space and nudged by cursor position */
.grid-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60vh;
  transform-style: preserve-3d;
  pointer-events: none;
  will-change: transform;
  backface-visibility: hidden;
}

.grid-plane {
  /* Much taller and wider than the wrap so the floor recedes far into the distance;
     the near edge stays pinned to the bottom of the screen. */
  position: absolute;
  top: -200%;
  bottom: 0;
  left: -60%;
  right: -60%;
  transform-origin: 50% 100%;
  transform: rotateX(70deg);
  backface-visibility: hidden;
  /* The plane is tilted 70deg, which squashes horizontal lines to ~1/3 of their
     height, so they are drawn thicker than the vertical ones to stay >=1px on screen. */
  background-image:
    linear-gradient(oklch(0.2 0.02 240 / 0.2) 4px, transparent 4px),
    linear-gradient(90deg, oklch(0.2 0.02 240 / 0.22) 2px, transparent 2px);
  background-size: 80px 80px;
  /* Fade out toward the horizon (top) and softly toward the viewer (bottom) and sides */
  mask-image:
    linear-gradient(to bottom, transparent 0%, black 45%, black 70%, transparent 100%),
    linear-gradient(to right, transparent 0%, black 30%, black 70%, transparent 100%);
  mask-composite: intersect;
  -webkit-mask-composite: source-in;
}

.glow {
  position: absolute;
  top: -20%;
  left: 50%;
  width: 900px;
  height: 900px;
  transform: translateX(-50%);
  background: radial-gradient(circle, oklch(0.6 0.1 230 / 0.12), transparent 65%);
  pointer-events: none;
}

.content {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 8vh 6vw 6vh;
  box-sizing: border-box;
}

/* ==========================================================
   Homepage
   ========================================================== */

.hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 30vh;
  transform-style: preserve-3d;
}

.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.6rem, 9vw, 8.5rem);
  letter-spacing: -0.02em;
  color: var(--ink);
  text-align: center;
  line-height: 1;
  transform-style: preserve-3d;
  animation: drift 7s ease-in-out infinite;
  user-select: none;
  /* transform + text-shadow (3D tilt + extrusion) are set live by script.js */
}

/* Two columns: Projects | Blog. Stacks on narrow screens. */
.panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 48px 72px;
  align-items: start;
  width: 100%;
  max-width: 1120px;
}

/* Blog hidden (database unreachable): center the Projects column alone */
.panels--single {
  grid-template-columns: minmax(0, 560px);
  justify-content: center;
}

/* Shared column styling (both panels) */
.projects,
.blog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
  max-width: 560px;
  justify-self: center;
  transform-style: preserve-3d;
  /* transform (subtle tilt) is set live by script.js */
}

.projects-label {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--label);
  font-weight: 400;
}

/* ---------- Project cards ---------- */

.project-links {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.project-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px;
  border: 1px solid var(--card-line);
  border-radius: 2px;
  background: oklch(1 0 0 / 0.6);
  backdrop-filter: blur(6px);
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(.2, .8, .2, 1), border-color 0.35s, background 0.35s;
}

.project-link:hover {
  border-color: oklch(0.6 0.1 230 / 0.8);
  background: oklch(1 0 0 / 0.9);
}

/* left/right cards tilt toward opposite corners on hover */
.project-link--left:hover  { transform: perspective(600px) rotateX(6deg) rotateY(-4deg) translateZ(14px); }
.project-link--right:hover { transform: perspective(600px) rotateX(6deg) rotateY(4deg) translateZ(14px); }

.project-name {
  font-family: var(--display);
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  font-weight: 500;
  color: var(--ink);
}

.project-arrow {
  font-size: 1.2rem;
  color: var(--accent);
}

/* ---------- Blog rows ----------
   Deliberately not cards: no box, no glass, no 3D tilt.
   A hairline ledger so posts read as a running log. */

.post-list {
  width: 100%;
  border-top: 1px solid var(--hairline);
}

.post-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: baseline;
  column-gap: 18px;
  row-gap: 4px;
  padding: 15px 4px;
  border-bottom: 1px solid var(--hairline);
}

.post-date {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.post-title {
  font-family: var(--display);
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  overflow-wrap: anywhere;
  transition: transform 0.3s cubic-bezier(.2, .8, .2, 1), color 0.3s;
}

.post-tag {
  align-self: center;
  font-size: 10px;
  letter-spacing: 0.14em;
  line-height: 1;
  padding: 4px 6px 3px;
  border: 1px solid oklch(0.55 0.1 230 / 0.35);
  border-radius: 2px;
  color: var(--accent-ink);
}

.post-arrow {
  grid-column: -2;
  color: var(--accent);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.3s, transform 0.3s cubic-bezier(.2, .8, .2, 1);
}

.post-row:hover .post-title,
.post-row:focus-visible .post-title {
  transform: translateX(6px);
  color: var(--accent-ink);
}

.post-row:hover .post-arrow,
.post-row:focus-visible .post-arrow {
  opacity: 1;
  transform: none;
}

.post-empty {
  margin: 0;
  padding: 18px 4px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: center;
}

.blog-all {
  align-self: flex-end;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--muted);
  transition: color 0.2s;
}

.blog-all:hover {
  color: var(--accent);
}

/* ---------- Footer ---------- */

.contact {
  padding-top: 6vh;
}

.contact a {
  font-size: 14px;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.contact a:hover {
  color: var(--accent);
}

/* ==========================================================
   Blog pages (archive + post)
   ========================================================== */

.page--blog .content,
.page--post .content {
  justify-content: flex-start;
  padding-top: 5vh;
}

.page--blog .contact,
.page--post .contact {
  margin-top: auto;
}

/* Soft paper-colored panel behind the reading column so the floor grid doesn't
   compete with the text. Solid in the middle, feathered at every edge so a little
   grid still shows around it. Sits behind the text but above the backdrop. */
.article,
.archive {
  position: relative;
}

.article::before,
.archive::before {
  content: '';
  position: absolute;
  inset: -70px -130px;
  z-index: -1;
  pointer-events: none;
  background: var(--paper);
  mask-image:
    linear-gradient(to right, transparent 0, #000 100px, #000 calc(100% - 100px), transparent 100%),
    linear-gradient(to bottom, transparent 0, #000 60px, #000 calc(100% - 60px), transparent 100%);
  mask-composite: intersect;
  -webkit-mask-composite: source-in;
}

.site-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  max-width: 1120px;
}

.site-bar__mark {
  /* text-shadow (extrusion) is set live by script.js */
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  transition: color 0.2s;
}

.site-bar__link {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--muted);
  transition: color 0.2s;
}

.site-bar__mark:hover,
.site-bar__link:hover {
  color: var(--accent);
}

.page-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.2rem, 6vw, 4rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--ink);
  text-wrap: balance;
}

/* ---------- Archive ---------- */

.archive {
  display: flex;
  flex-direction: column;
  gap: 56px;
  width: 100%;
  max-width: 680px;
  margin: 10vh 0 8vh;
}

.archive-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
}

.feed-link {
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.feed-link:hover {
  color: var(--accent);
}

.archive-year {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- Single post ---------- */

.article {
  width: 100%;
  max-width: 680px;
  margin: 9vh 0 8vh;
}

.article-head {
  margin-bottom: 44px;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 0 0 20px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.post-meta a {
  color: var(--accent-ink);
}

.post-meta a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.lede {
  margin: 22px 0 0;
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
  line-height: 1.5;
  color: var(--muted);
}

.article-cover {
  margin: 0 0 48px;
}

.article-cover img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--hairline);
  border-radius: 2px;
}

/* Post body: Space Grotesk for comfortable long-form reading */
.post-body {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.125rem;
  line-height: 1.75;
  color: var(--ink-body);
  overflow-wrap: break-word;
}

.post-body > * {
  margin: 0;
}

.post-body > * + * {
  margin-top: 1.25em;
}

.post-body h2,
.post-body h3,
.post-body h4 {
  color: var(--ink);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.post-body h2 {
  font-size: 1.6rem;
  font-weight: 700;
}

.post-body h3 {
  font-size: 1.25rem;
  font-weight: 500;
}

.post-body > * + h2,
.post-body > * + h3 {
  margin-top: 2em;
}

.post-body a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.post-body a:hover {
  color: var(--ink);
}

.post-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.75em 0;
  border: 1px solid var(--hairline);
  border-radius: 2px;
}

.post-body blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 2px 0 2px 20px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}

.post-body blockquote > * {
  margin: 0;
}

.post-body ul,
.post-body ol {
  padding-left: 1.3em;
}

.post-body li + li {
  margin-top: 0.4em;
}

.post-body li::marker {
  color: var(--accent);
}

.post-body code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 0.12em 0.36em;
  border-radius: 2px;
  background: oklch(0.14 0.005 250 / 0.06);
}

.post-body pre {
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  border: 1px solid var(--hairline);
  border-radius: 2px;
  background: oklch(1 0 0 / 0.7);
}

.post-body pre code {
  padding: 0;
  font-size: inherit;
  background: none;
}

.post-body hr {
  margin: 3em 0;
  border: 0;
  border-top: 1px solid var(--hairline);
}

.post-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.post-body th,
.post-body td {
  padding: 10px 14px 10px 0;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
}

.post-body th {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--label);
}

/* Newer / older links: glass cards like the project list */
.post-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 72px;
  padding-top: 28px;
  border-top: 1px solid var(--hairline);
}

.post-nav__item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--card-line);
  border-radius: 2px;
  background: oklch(1 0 0 / 0.6);
  backdrop-filter: blur(6px);
  transition: border-color 0.3s, background 0.3s;
}

.post-nav__item:hover {
  border-color: oklch(0.6 0.1 230 / 0.8);
  background: oklch(1 0 0 / 0.9);
}

.post-nav__item--older {
  grid-column: 2;
  text-align: right;
}

.post-nav__label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.post-nav__title {
  font-family: var(--display);
  font-weight: 500;
  color: var(--ink);
}

.article--missing .blog-all {
  display: inline-block;
  margin-top: 16px;
}

/* ==========================================================
   Responsive
   ========================================================== */

@media (max-width: 860px) {
  .panels {
    grid-template-columns: minmax(0, 1fr);
    max-width: 560px;
    gap: 56px;
  }
}

@media (max-width: 520px) {
  .content {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* date sits above the title on small phones */
  .post-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .post-date {
    grid-column: 1 / -1;
  }

  .post-nav {
    grid-template-columns: minmax(0, 1fr);
  }

  .post-nav__item--older {
    grid-column: auto;
  }
}

/* Touch screens: no hover, so drop the hidden arrow column and let tags sit flush right */
@media (hover: none) {
  .post-arrow {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
