/* Reset and base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-code: "SF Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  --color-text: rgb(17, 17, 17);
  --color-text-muted: rgba(0, 0, 0, 0.4);
  --color-link: rgb(36, 128, 237);
  --color-accent: #FFD900;
  --color-bg: #fff;
  --color-border: rgba(0, 0, 0, 0.1);
  --color-code-bg: #f5f5f5;
  --max-width: 550px;
  --spacing-unit: 1rem;
}

body.dark {
  --color-text: #e4e4e7;
  --color-text-muted: rgba(255, 255, 255, 0.4);
  --color-link: #60a5fa;
  --color-bg: #111111;
  --color-border: rgba(255, 255, 255, 0.1);
  --color-code-bg: #1e1e1e;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 460;
  line-height: 22px;
  letter-spacing: -0.09px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem 1.5rem;
}

/* Typography */
h1, h2, h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.3;
}

h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

h2 {
  font-size: 1.125rem;
  margin-top: 3rem;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  font-weight: 500;
}

h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

p {
  margin-bottom: 1rem;
}

/* Header */
.header {
  margin-bottom: 2rem;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header .name {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: -0.09px;
  color: var(--color-text);
  margin-bottom: 0;
}

.header time {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 460;
  line-height: 20px;
  letter-spacing: -0.09px;
  color: var(--color-text-muted);
  display: block;
}

/* Links */
a {
  color: var(--color-link);
  text-decoration: none;
  display: inline-block;
  position: relative;
  transition: all 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

a::after {
  content: none;
}

.footer a::after,
.links-row a::after {
  content: " ↗";
  font-size: 0.75em;
  position: relative;
  top: -0.3em;
}

/* About */
.about {
  margin-bottom: 2rem;
}

.about a,
.container > section > p a {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-color: var(--color-border);
  text-underline-offset: 2px;
}

.about a:hover,
.container > section > p a:hover {
  text-decoration-color: var(--color-text);
  opacity: 1;
}

/* ── GHOST TWINKLE ──────────────────────────────────── */
/*
 *    0s    idle, no glow
 *  ~0.6s   soft glow fades in around text
 *  ~1.2s   glow fades out
 *  ~4.0s   pause before next twinkle
 */
:root {
  --ghost-glow:      rgba(0, 0, 0, 0.32);
  --ghost-glow-soft: rgba(0, 0, 0, 0.12);
}

body.dark {
  --ghost-glow:      rgba(255, 255, 255, 0.72);
  --ghost-glow-soft: rgba(255, 255, 255, 0.3);
}

@keyframes ghost-twinkle {
  0%, 30%, 100% { text-shadow: 0 0 0 transparent; }
  15% {
    text-shadow:
      0 0 6px var(--ghost-glow),
      0 0 14px var(--ghost-glow-soft);
  }
}

.ghost-link {
  animation: ghost-twinkle 4s ease-in-out infinite;
}

.links-row {
  color: var(--color-text);
}

/* Writing section */
.writing-list {
  list-style: none;
}

.writing-item {
  display: flex;
  align-items: baseline;
  margin-bottom: 0.5rem;
  gap: 1rem;
}

.writing-year {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 460;
  line-height: 20px;
  letter-spacing: -0.09px;
  color: var(--color-text-muted);
  min-width: 40px;
}

.writing-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.writing-title a {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.09px;
  line-height: normal;
  color: var(--color-text);
  text-decoration: none;
  transition: opacity 0.14s ease;
}

.writing-title a:hover {
  opacity: 0.6;
}


.writing-date {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 460;
  line-height: 20px;
  letter-spacing: -0.09px;
  color: var(--color-text-muted);
}

.new-marker {
  background: rgba(255, 217, 0, 0.3);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  margin-left: 0.5rem;
  color: var(--color-text);
}

/* Work section */
.work-list {
  list-style: none;
}

.work-item {
  margin-bottom: 1.5rem;
}

.work-title {
  font-family: var(--font-sans);
  font-weight: 600;
}

.work-role {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.work-description {
  font-size: 0.9375rem;
  margin-top: 0.5rem;
}

.work-description ul {
  margin-left: 1.25rem;
  margin-top: 0.25rem;
}

.work-description li {
  margin-bottom: 0.25rem;
}

/* Projects */
.projects-list {
  list-style: none;
}

.project-item {
  margin-bottom: 1rem;
}

.project-name {
  font-family: var(--font-sans);
  font-weight: 600;
}

.project-description {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

/* Education */
.education-list {
  list-style: none;
}

.education-item {
  margin-bottom: 0.75rem;
  font-family: var(--font-sans);
}

.education-degree {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0 0 2rem 0;
}

/* Footer */
.footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.footer p {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 460;
  line-height: 20px;
  letter-spacing: -0.09px;
  color: var(--color-text-muted);
  margin-bottom: 0;
}

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

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 2rem 1rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    margin-top: 2rem;
  }
}

/* ─────────────────────────────────────────────────────────
 * PHYSICS PLAYGROUND
 *
 * 10 draggable blocks with gravity, collisions, stacking.
 * Blocks sit below the footer. Drag to move. Throw to toss.
 * Contained within max-width. Pure physics toy.
 * ───────────────────────────────────────────────────────── */

.playground {
  max-width: var(--max-width);
  margin: 2rem auto 0;
  padding: 0 1.5rem;
  height: 180px;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.block {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  position: absolute;
  top: 0;
  left: 0;
  cursor: grab;
  will-change: transform;
  background-size: cover;
  background-position: center;
  image-rendering: pixelated;
  transition: filter 0.15s ease;
}

.block:hover {
  filter: brightness(1.08);
}

.block.dragging {
  cursor: grabbing;
  z-index: 10;
  filter: brightness(1.12) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

/* Blog post layout */
.post-layout {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem 1.5rem;
  position: relative;
}

.post-sidebar {
  width: 200px;
  position: absolute;
  right: calc(100% + 2rem);
  top: 4rem;
}

.sidebar-index {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 460;
  letter-spacing: -0.04px;
  line-height: 15.6px;
  color: var(--color-text-muted);
  text-decoration: none;
  display: block;
  margin-bottom: 2rem;
  transition: color 0.1s ease;
}

.sidebar-index:hover {
  color: var(--color-text);
}


.post-toc {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toc-link {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 460;
  letter-spacing: -0.04px;
  line-height: 15.6px;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.1s ease;
}

.toc-link:hover {
  color: var(--color-text);
}


.post-main {
  width: 100%;
}

@media (max-width: 900px) {
  .post-sidebar {
    position: static;
    width: 100%;
    margin-bottom: 2rem;
  }

  .post-toc {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1rem;
  }
}

/* Blog post page styles */
.post-header {
  margin-bottom: 2rem;
}

.post-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.post-date {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.post-content {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 460;
  line-height: 20px;
  letter-spacing: -0.09px;
  color: var(--color-text);
}

.post-image {
  width: 100%;
  height: auto;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.post-content p {
  padding-top: 0;
  margin-bottom: 16px;
}

.post-content h2 {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.13px;
  line-height: normal;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0;
  margin-bottom: 16px;
  padding-top: 32px;
}

.post-content h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.post-content p {
  margin-bottom: 1.25rem;
}

.post-content code {
  font-family: var(--font-code);
  font-size: 0.875em;
  background: var(--color-code-bg);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
}

.post-content pre {
  background: var(--color-code-bg);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.post-content pre code {
  background: none;
  padding: 0;
}

.back-link {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  margin-bottom: 2rem;
  display: block;
}

/* ─────────────────────────────────────────────────────────
 * DARK MODE TOGGLE
 *
 * Two-state toggle. All motion driven by `.dark` class.
 *
 *    0ms   click → .dark class toggles
 *    0ms   knob slides to opposite side (spring overshoot)
 *    0ms   sun rays rotate 120° and retract to 0 opacity
 *    0ms   moon mask circle slides in from right
 *  150ms   track background completes color shift
 *  300ms   knob arrives at resting position
 *  400ms   icon morph fully settled
 *  500ms   spring overshoot dampens, all motion complete
 * ───────────────────────────────────────────────────────── */

/* ── TOGGLE TIMING ───────────────────────────────────── */
:root {
  --t-knob:        0.5s;                                /* knob slide               */
  --t-knob-ease:   cubic-bezier(0.34, 1.56, 0.64, 1);  /* spring w/ overshoot      */
  --t-icon:        0.4s;                                /* icon morph               */
  --t-icon-ease:   cubic-bezier(0.34, 1.56, 0.64, 1);  /* spring w/ overshoot      */
  --t-track:       0.3s;                                /* track bg color           */
  --t-track-ease:  ease;                                /* gentle color shift       */
  --t-rays:        0.3s;                                /* ray retract              */
  --t-rays-ease:   ease-in;                             /* rays accelerate out      */
}

/* ── TOGGLE TRACK ────────────────────────────────────── */
:root {
  --track-w:        56px;                               /* track width              */
  --track-h:        28px;                               /* track height             */
  --track-r:        14px;                               /* fully rounded            */
  --track-light:    #e2e8f0;                            /* light mode bg            */
  --track-dark:     #1e293b;                            /* dark mode bg             */
  --track-border:   rgba(0, 0, 0, 0.08);               /* subtle edge              */
}

/* ── TOGGLE KNOB ─────────────────────────────────────── */
:root {
  --knob-size:      22px;                               /* knob diameter            */
  --knob-inset:     3px;                                /* gap from track edge      */
  --knob-travel:    28px;                               /* slide distance           */
  --knob-bg:        #ffffff;                            /* knob fill                */
  --knob-shadow:    0 1px 3px rgba(0, 0, 0, 0.12),
                    0 0 0 1px rgba(0, 0, 0, 0.04);     /* depth + edge             */
}

/* ── TOGGLE ICON ─────────────────────────────────────── */
:root {
  --icon-size:      14px;                               /* SVG render size          */
  --sun-color:      #f59e0b;                            /* sun fill                 */
  --moon-color:     #94a3b8;                            /* moon fill                */
  --sun-rotate-out: 120deg;                             /* sun exit rotation        */
  --mask-x-active:  -7px;                               /* moon mask slide distance */
}

.toggle {
  position: relative;
  width: var(--track-w);
  height: var(--track-h);
  border-radius: var(--track-r);
  background: var(--track-light);
  border: 1px solid var(--track-border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  flex-shrink: 0;
  transition: background var(--t-track) var(--t-track-ease),
              border-color var(--t-track) var(--t-track-ease);
}

body.dark .toggle {
  background: var(--track-dark);
  border-color: rgba(255, 255, 255, 0.06);
}

.toggle-knob {
  position: absolute;
  top: var(--knob-inset);
  left: var(--knob-inset);
  width: var(--knob-size);
  height: var(--knob-size);
  border-radius: 50%;
  background: var(--knob-bg);
  box-shadow: var(--knob-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(0);
  transition: transform var(--t-knob) var(--t-knob-ease);
}

body.dark .toggle-knob {
  transform: translateX(var(--knob-travel));
}

.toggle-icon {
  width: var(--icon-size);
  height: var(--icon-size);
  position: relative;
}

.toggle-icon svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sun-body {
  fill: var(--sun-color);
  transform-origin: center;
  transition: fill var(--t-icon) var(--t-icon-ease);
}

body.dark .sun-body {
  fill: var(--moon-color);
}

.sun-rays {
  transform-origin: 12px 12px;
  transition: transform var(--t-icon) var(--t-icon-ease),
              opacity var(--t-rays) var(--t-rays-ease);
}

body.dark .sun-rays {
  transform: rotate(var(--sun-rotate-out));
  opacity: 0;
}

.sun-ray {
  stroke: var(--sun-color);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.moon-mask {
  fill: var(--knob-bg);
  transform: translateX(0);
  opacity: 0;
  transition: transform var(--t-icon) var(--t-icon-ease),
              opacity var(--t-icon) var(--t-icon-ease);
}

body.dark .moon-mask {
  transform: translateX(var(--mask-x-active));
  opacity: 1;
}
