/* Notebook paper (light) and chalkboard (dark) */
:root {
  --bg: #fdfcf7;
  --rule: #e3ecf6;
  --margin: #f6c4c4;
  --text: #2a2a3a;
  --muted: #6a6a7c;
  --pen: #e0553d;
  --hl: #fff27a;
  --card: #ffffff;
  --border: #dcdce4;
  --hand: "Caveat", "Comic Sans MS", cursive;
  --print: "Patrick Hand", "Comic Sans MS", system-ui, sans-serif;
  --max: 760px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f2d27;
    --rule: rgba(255, 255, 255, .04);
    --margin: rgba(255, 140, 140, .2);
    --text: #f1efe6;
    --muted: #b0bcb4;
    --pen: #ff9b85;
    --hl: rgba(255, 233, 92, .3);
    --card: #26362f;
    --border: #3a4c44;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1f2d27;
  --rule: rgba(255, 255, 255, .04);
  --margin: rgba(255, 140, 140, .2);
  --text: #f1efe6;
  --muted: #b0bcb4;
  --pen: #ff9b85;
  --hl: rgba(255, 233, 92, .3);
  --card: #26362f;
  --border: #3a4c44;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  font: 20px/1.6 var(--print);
  background-color: var(--bg);
  /* lined paper + margin line */
  background-image:
    linear-gradient(90deg, transparent 40px, var(--margin) 40px, var(--margin) 42px, transparent 42px),
    repeating-linear-gradient(transparent 0 31px, var(--rule) 31px 32px);
  background-attachment: local;
}
h1, h2, h3 { font-family: var(--hand); font-weight: 700; line-height: 1.1; }

/* Top bar */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--max); margin: 0 auto; padding: 16px 24px 0 64px;
}
.brand { font-family: var(--hand); font-size: 2rem; font-weight: 700; color: var(--pen); text-decoration: none; }
.theme-toggle {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card);
  font-size: 1.1rem; cursor: pointer;
}
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: inline; }
}

main { max-width: var(--max); margin: 0 auto; padding: 0 24px 0 64px; }

/* Intro */
/* name on the left, photo on the right of it */
.hero {
  position: relative; padding: 48px 0 32px;
  display: grid; grid-template-columns: 1fr auto; column-gap: 24px;
}
.hero > * { grid-column: 1; }
.hero .photo-frame { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
.hero .tagline, .hero .links { grid-column: 1 / -1; }
.avatar {
  width: 160px; height: 160px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--border); font-size: 3.6rem;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.hi { margin: 0; font-family: var(--hand); font-size: 1.8rem; color: var(--muted); }
.hero h1 { margin: 0; font-size: clamp(3rem, 9vw, 4.6rem); }
.highlight { background: linear-gradient(transparent 60%, var(--hl) 60% 90%, transparent 90%); padding: 0 4px; }
.grade { margin: 4px 0 0; color: var(--pen); }
.tagline { max-width: 480px; margin: 12px 0 20px; }
.links { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; padding: 0; margin: 0; }
.links a {
  display: inline-block; padding: 4px 16px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--card); color: var(--text); text-decoration: none;
}
.links a:hover { border-color: var(--pen); color: var(--pen); }

.doodle.star {
  position: absolute; top: 36px; right: -12px; width: 44px; z-index: 1;
  fill: none; stroke: var(--pen); stroke-width: 3; stroke-linejoin: round;
}

/* Sections */
.section { padding: 32px 0; }
.section h2 { margin: 0 0 16px; font-size: 2.6rem; }
.paper, .activity, .fave, .card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
}
.paper { padding: 16px 20px; }
.paper p { margin: 0 0 12px; }
.paper p:last-child { margin: 0; }

/* Games */
html { scroll-behavior: smooth; }
.play-note { margin: 0 0 16px; color: var(--muted); }
.play-note a { color: var(--pen); }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.game-card {
  display: block; overflow: hidden; color: var(--text); text-decoration: none;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  transition: transform .15s, border-color .15s;
}
.game-card:hover { border-color: var(--pen); transform: translateY(-3px) rotate(-.6deg); }
.game-card img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; background: #120a24; }
.game-card .text { padding: 10px 16px 14px; }
.game-card h3 { margin: 0; font-size: 1.7rem; }
.game-card p { margin: 0; color: var(--muted); }

/* A game's own page */
.game-page h1 { margin: 8px 0 12px; font-size: clamp(2.6rem, 8vw, 3.6rem); }
.back { color: var(--pen); text-decoration: none; }
.back:hover { text-decoration: underline; }
.game-frame iframe {
  display: block; width: 100%; height: 900px; margin: 0 auto;
  border: 1px solid var(--border); border-radius: 16px; background: #120a24;
}
.footer a { color: inherit; }

/* Things I do */
.activities { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.activity { display: flex; gap: 14px; padding: 16px 20px; }
.activity .emoji { font-size: 2rem; line-height: 1.2; }
.activity h3 { margin: 0 0 4px; font-size: 1.7rem; }
.activity h3 a { color: var(--text); text-decoration: none; }
.activity h3 a:hover { color: var(--pen); }
.activity ul { margin: 0; padding-left: 18px; color: var(--muted); }

/* Favorites */
.faves { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.fave { padding: 14px; text-align: center; }
.fave .emoji { font-size: 2rem; line-height: 1; }
.fave .label { font-size: .85rem; color: var(--muted); margin-top: 6px; }
.fave .value { font-family: var(--hand); font-size: 1.5rem; font-weight: 700; line-height: 1.2; }

/* Projects */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { position: relative; display: block; padding: 16px 20px; color: var(--text); text-decoration: none; }
a.card:hover { border-color: var(--pen); }
.card h3 { margin: 0 0 4px; font-size: 1.7rem; }
.card p { margin: 0; color: var(--muted); }
.card .store {
  display: inline-block; margin-top: 10px; padding: 2px 14px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: .95rem;
}
.card .arrow { position: absolute; top: 12px; right: 16px; color: var(--pen); }

.footer {
  max-width: var(--max); margin: 0 auto; padding: 24px 24px 48px 64px;
  font-family: var(--hand); font-size: 1.4rem; color: var(--muted);
}

/* Phones */
@media (max-width: 600px) {
  body {
    font-size: 18px;
    background-image:
      linear-gradient(90deg, transparent 20px, var(--margin) 20px, var(--margin) 22px, transparent 22px),
      repeating-linear-gradient(transparent 0 31px, var(--rule) 31px 32px);
  }
  .nav { padding: 12px 16px 0 36px; }
  .hero { column-gap: 12px; }
  .avatar { width: 96px; height: 96px; }
  .doodle.star { top: 40px; right: -8px; width: 32px; }
  main { padding: 0 16px 0 36px; }
  .footer { padding: 24px 16px 40px 36px; }
  .faves { grid-template-columns: repeat(2, 1fr); }
  .activities { grid-template-columns: 1fr; }
}

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

/* ── Easter eggs 🥚 ─────────────────────────────────────── */
.photo-frame { display: inline-block; cursor: pointer; user-select: none; }
.doodle.star { cursor: pointer; }
.photo-frame.wiggle { animation: wiggle .4s ease; }
.photo-frame.flip { animation: flip .7s ease; }
@keyframes wiggle {
  25% { transform: rotate(-8deg) scale(1.04); }
  75% { transform: rotate(8deg) scale(1.04); }
}
@keyframes flip { to { transform: rotateY(360deg); } }

.egg-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100;
  max-width: calc(100vw - 32px); padding: 10px 18px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
  font-size: 1.1rem; text-align: center;
  transform: translate(-50%, 140%); opacity: 0;
  transition: transform .3s ease, opacity .2s;
  pointer-events: none;
}
.egg-toast.show { transform: translate(-50%, 0); opacity: 1; }

.egg-fall {
  position: fixed; top: -60px; z-index: 90; pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(calc(100vh + 120px)) rotate(540deg); } }

.egg-burst {
  position: fixed; z-index: 90; pointer-events: none; font-size: 22px;
  translate: -50% -50%;
  animation: burst .9s ease-out forwards;
}
@keyframes burst {
  from { transform: translate(0, 0) scale(.4); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(1.2); opacity: 0; }
}

.egg-plane {
  position: fixed; top: 30vh; left: -60px; z-index: 90; pointer-events: none;
  font-size: 44px; animation: fly 3s ease-in-out forwards;
}
@keyframes fly {
  0% { transform: translate(0, 0) rotate(10deg); }
  30% { transform: translate(35vw, -12vh) rotate(-10deg); }
  60% { transform: translate(65vw, 8vh) rotate(15deg); }
  100% { transform: translate(calc(100vw + 120px), -20vh) rotate(-20deg); }
}

.egg-heart {
  border: 0; padding: 0 2px; background: none; cursor: pointer;
  font: inherit; color: var(--pen);
}

.cheat-mode .highlight,
.cheat-mode .section h2 {
  background: linear-gradient(90deg, #ff4d4d, #ffb84d, #ffe94d, #4dff88, #4db8ff, #b84dff, #ff4d4d);
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: rainbow 1.2s linear infinite;
}
.cheat-mode .fave, .cheat-mode .card, .cheat-mode .game-card { animation: bounce .6s ease-in-out infinite alternate; }
@keyframes rainbow { to { background-position: 200% center; } }
@keyframes bounce { to { translate: 0 -8px; } }
