/* ─── Variables ────────────────────────────────────────────────────────────── */

:root {
  --bg:     #ededeb;
  --ink:    #0a0a0a;
  --prose:  #2a2a2a;
  --muted:  #666666;
  --rule:   #c8c7c2;
  --accent: #1a5a9e;

  --serif: 'Lora', Georgia, 'Times New Roman', serif;
  --sans:  'DM Sans', system-ui, -apple-system, sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
}

[data-theme="dark"] {
  --bg:     #222222;
  --ink:    #f0f0f0;
  --prose:  #f0f0f0;
  --muted:  #f0f0f0;
  --rule:   #444444;
  --accent: #6aaae8;
}

/* ─── Suppress transitions on initial load ──────────────────────────────────── */

.preload, .preload * {
  transition: none !important;
}

/* ─── Dark mode toggle ──────────────────────────────────────────────────────── */

#theme-toggle {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 100;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.08em;
}

#theme-toggle:hover {
  color: var(--ink);
}

/* ─── Scramble ───────────────────────────────────────────────────────────────── */

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

/* ─── Flicker ────────────────────────────────────────────────────────────────── */

@keyframes elementFlicker {
  0%   { opacity: 0; }
  15%  { opacity: 0.8; }
  25%  { opacity: 0.1; }
  40%  { opacity: 0.9; }
  55%  { opacity: 0.3; }
  70%  { opacity: 1; }
  100% { opacity: 1; }
}

/* ─── Page transitions ───────────────────────────────────────────────────────── */

@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page {
  animation: pageIn 0.4s ease forwards;
}

body.fade-out .page {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */

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

body, a, h1, h2, h3, p, hr, button, aside, main, section, article, div, li, strong {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ─── Base ───────────────────────────────────────────────────────────────────── */

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: none;
  opacity: 0.7;
}
a[target="_blank"]::after {
  content: ' ↗';
}
.book-item a[target="_blank"]::after,
#work a[target="_blank"]::after,
.article-body a[target="_blank"]::after,
.col-left a[target="_blank"]::after {
  content: none;
}


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

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

/* ─── Layout ─────────────────────────────────────────────────────────────────── */

.page {
  max-width: 1300px;
  margin: 0 auto;
  padding: 64px 48px 100px;
  display: grid;
  grid-template-columns: 225px minmax(0, 555px) 250px;
  grid-template-areas: "left center right";
  column-gap: 64px;
  align-items: start;
}

/* ─── Left column ────────────────────────────────────────────────────────────── */

.col-left {
  grid-area: left;
  position: sticky;
  top: 64px;
  text-align: left;
  width: 100%;
  padding-left: 28px;
}

/* Photo */
.photo {
  width: 185px;
  height: 185px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--rule);
  margin-bottom: 18px;
  background: #e2ddd6;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  display: block;
  filter: saturate(0.7) brightness(0.92);
}

/* Portrait rectangle */
.photo-placeholder {
  background: var(--rule);
}

.photo-rect {
  width: 82%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 50%;
  margin: 0 0 18px;
}

.photo-rect img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 40% 35%;
  display: block;
  transform: scale(1.12);
  transform-origin: 40% 35%;
}

/* Name */
.col-left h2 {
  font-family: var(--sans);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
}

/* Bio */
.bio {
  font-size: 13.5px;
  color: var(--prose);
  line-height: 1.65;
  margin-bottom: 12px;
}
.bio:last-of-type {
  margin-bottom: 20px;
}

/* Contact */
.contact {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13.5px;
}
.contact strong {
  display: block;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.contact ul {
  list-style: none;
}
.contact ul li + li {
  margin-top: 2px;
}

/* ─── Center column ──────────────────────────────────────────────────────────── */

.col-center {
  grid-area: center;
  min-width: 0;
}

.col-center section,
.col-right section {
  margin-bottom: 0;
}

h2 {
  font-family: var(--sans);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 18px;
  letter-spacing: -0.02em;
}

h3 {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.divider {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 40px 0;
}

.divider-writing {
  display: none;
}

/* ─── Entries ────────────────────────────────────────────────────────────────── */

.entries {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#work .entries {
  gap: 20px;
}

.entry-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0;
}

#books .entry-title {
  font-weight: 600;
}

.entry-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 0;
}

article.coming-soon .entry-title {
  opacity: 0.45;
}

.entry-desc {
  font-size: 13.5px;
  color: var(--prose);
  line-height: 1.65;
}

/* ─── Numbered projects ──────────────────────────────────────────────────────── */

.project-numbered {
  display: flex;
  flex-direction: row;
  gap: 16px;
  align-items: flex-start;
}

.project-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.05em;
  padding-top: 2px;
  flex-shrink: 0;
  width: 28px;
}

/* ─── Books ──────────────────────────────────────────────────────────────────── */

.book-group + .book-group {
  margin-top: 24px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 16px;
}

.book-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.book-item img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
}

/* ─── Project cards (used for books) ────────────────────────────────────────── */

.project-card {
  display: flex;
  flex-direction: row;
  gap: 20px;
  align-items: center;
}

.project-text {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.project-img {
  width: 160px;
  flex-shrink: 0;
  aspect-ratio: 16 / 10;
  border-radius: 4px;
  border: 1px solid var(--rule);
  overflow: hidden;
  user-select: none;
}

.project-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* ─── Right column ───────────────────────────────────────────────────────────── */

.col-right {
  grid-area: right;
  position: sticky;
  top: 64px;
}

.col-right h2 {
  font-size: 1.45rem;
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */

.site-footer {
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px 48px 40px;
  display: flex;
  gap: 32px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 1023px) {
  .page {
    grid-template-columns: 210px 1fr;
    grid-template-areas:
      "left center"
      ".    right";
    column-gap: 40px;
  }
  .col-right {
    padding-top: 12px;
  }
  .col-left h2 {
    font-size: 1.3rem;
  }
  .divider-writing {
    display: block;
  }
}

@media (max-width: 699px) {

  #theme-toggle {
    position: absolute;
  }
  .page {
    grid-template-columns: 1fr;
    grid-template-areas:
      "left"
      "center"
      "right";
    padding: 28px 20px 60px;
    row-gap: 32px;
  }
  .col-left {
    position: static;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: left;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 32px;
    padding-left: 0;
  }
  .left-hero {
    width: 100%;
    text-align: center;
  }
  .photo-rect {
    margin: 0 auto 18px;
    width: 130px;
  }
  .bio,
  .contact {
    width: 100%;
  }
  .col-right {
    position: static;
  }
  .photo {
    width: 130px;
    height: 130px;
    margin-top: 24px;
    margin-bottom: 12px;
    margin-left: auto;
    margin-right: auto;
  }
  .col-left h2 {
    margin-bottom: 20px;
  }
  .bio {
    max-width: 100%;
  }
  .project-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  #projects .entries {
    gap: 22px;
  }
  #books .project-card {
    flex-direction: row;
    align-items: flex-start;
  }
  #books .project-card:not(:has(.entry-desc)) {
    align-items: center;
  }
  .project-img {
    width: 100%;
  }
  h2 {
    font-size: 1.25rem;
  }
  .divider {
    margin: 20px 0;
  }
}
