:root {
  --bg: #ffffff;
  --fg: #111111;
  --fg-75: rgba(17, 17, 17, 0.75);
  --fg-60: rgba(17, 17, 17, 0.60);
  --fg-50: rgba(17, 17, 17, 0.50);
  --fg-10: rgba(17, 17, 17, 0.10);
  --muted: #6b7280;
  --hover: #4b5563;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #ededed;
  --fg-75: rgba(237, 237, 237, 0.75);
  --fg-60: rgba(237, 237, 237, 0.60);
  --fg-50: rgba(237, 237, 237, 0.50);
  --fg-10: rgba(237, 237, 237, 0.10);
  --muted: #9ca3af;
  --hover: #d1d5db;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "Inter", "Inter var", system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

@supports (font-variation-settings: normal) {
  html, body { font-family: "Inter var", -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif; }
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (min-width: 640px) {
  main { padding: 0 2rem; }
}

section {
  padding: 5rem 0;
}

.header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

h1 {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

@media (min-width: 640px) {
  h1 { font-size: 2.25rem; }
}

#theme {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  color: #9ca3af;
  transition: color 150ms ease;
  user-select: none;
}

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

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-bottom: 2rem;
}

.nav button,
.nav a {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  color: var(--fg-60);
  text-decoration: none;
  transition: color 150ms ease;
}

.nav button:hover,
.nav a:hover,
.nav button[aria-expanded="true"] { color: var(--fg); }

.timeline {
  list-style: none;
  padding: 0;
  max-width: 42rem;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--fg-75);
  overflow: hidden;
  max-height: 1500px;
  opacity: 1;
  margin: 0 0 2rem;
  transition: max-height 380ms cubic-bezier(.2, .7, .2, 1),
              opacity 220ms ease 60ms,
              margin 380ms ease;
}

.timeline[hidden] {
  display: block;
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
  pointer-events: none;
  transition: max-height 320ms cubic-bezier(.4, 0, .9, .3),
              opacity 160ms ease,
              margin 320ms ease;
}

.timeline li {
  padding: 0.15rem 0;
}

.timeline .y {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.timeline .aside {
  color: var(--fg-50);
  font-style: italic;
}

.timeline .thumb-hover {
  display: block;
  margin: 0.5rem 0 0.25rem;
}

.timeline .game-thumb {
  display: block;
  max-width: 24rem;
  border: 1px solid var(--fg-10);
  border-radius: 4px;
  overflow: hidden;
  text-decoration: none;
  transition: border-color 150ms ease;
}

.timeline .game-thumb:hover { border-color: var(--fg-50); }

.timeline .game-thumb img {
  display: block;
  width: 100%;
  height: auto;
}

/* Hover popup: full-size overlay with backdrop, fades in/out */
.timeline .thumb-popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: opacity 180ms ease;
  padding: 2rem;
}

.timeline .thumb-popup img {
  max-width: 92vw;
  max-height: 88vh;
  width: auto;
  height: auto;
  display: block;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.97);
  transition: transform 220ms cubic-bezier(.2, .7, .2, 1);
}

.timeline .thumb-hover:hover .thumb-popup {
  opacity: 1;
}

.timeline .thumb-hover:hover .thumb-popup img {
  transform: scale(1);
}

/* On touch / no hover devices, skip the overlay (the link still opens full-size on tap) */
@media (hover: none) {
  .timeline .thumb-popup { display: none; }
}

.thoughts-list .thoughts-empty {
  color: var(--fg-50);
  font-style: italic;
}

.thoughts-list .thoughts-all {
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

.thoughts-list .thoughts-all a {
  color: var(--fg-50);
  text-decoration: none;
}

.thoughts-list .thoughts-all a:hover {
  color: var(--fg);
}

a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 150ms ease;
}

a:hover { color: var(--hover); }

.redact {
  background: var(--fg);
  color: transparent;
  user-select: none;
  padding: 0 0.15em;
  border-radius: 1px;
  -webkit-text-fill-color: transparent;
}

.redact::selection { background: var(--fg); color: transparent; }

footer {
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  border-top: 1px solid var(--fg-10);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

@media (min-width: 640px) {
  footer { padding: 2.5rem 2rem; }
}

footer p { margin: 0; }

footer a {
  color: var(--muted);
  text-decoration: none;
}

footer a:hover { color: var(--fg); }

/* --- writing index + post pages --- */

.writing-index,
.post {
  max-width: 36rem;
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0 0 3rem;
  font-size: 1rem;
  line-height: 1.7;
}

.post-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.25rem 0;
}

.post-list a {
  color: var(--fg);
  text-decoration: none;
  transition: color 150ms ease;
}

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

.post-list .post-date {
  color: var(--fg-50);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.post-meta {
  color: var(--fg-50);
  font-size: 0.875rem;
  margin: -1rem 0 2.5rem;
}

.post article {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--fg-75);
}

.post article p {
  margin: 0 0 1.25rem;
}

.post article h2,
.post article h3,
.post article h4 {
  color: var(--fg);
  font-weight: 400;
  margin: 2.25rem 0 0.75rem;
  letter-spacing: -0.01em;
}

.post article h2 { font-size: 1.25rem; }
.post article h3 { font-size: 1.0625rem; }
.post article h4 { font-size: 1rem; color: var(--fg-75); }

.post article a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.post article ul,
.post article ol {
  margin: 0 0 1.25rem;
  padding-left: 1.25rem;
}

.post article li { margin: 0.25rem 0; }

.post article blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--fg-10);
  color: var(--fg-60);
  font-style: italic;
}

.post article code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--fg-10);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

.post article pre {
  background: var(--fg-10);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
  margin: 0 0 1.5rem;
}

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

.post article hr {
  border: 0;
  border-top: 1px solid var(--fg-10);
  margin: 2.5rem 0;
}

.post article img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
}

.back-link {
  margin-top: 3rem;
  font-size: 0.875rem;
}

.back-link a {
  color: var(--fg-60);
  text-decoration: none;
  transition: color 150ms ease;
}

.back-link a:hover { color: var(--fg); }

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