/* =========================================================
   Max's Website — landing page
   Every sprite is a true-size PNG. --px is how many screen
   pixels one art pixel takes up; all sizes are multiples of it.
   ========================================================= */

:root {
  --px: 4;
  --peek: calc(44px * var(--px));   /* how much tree shows on arrival */
  --navy: #2a3566;
  --dirt: #8b5a34;
  /* banner colours, from the original site */
  --banner: #9f9393;
  --banner-edge: #ebe2e2;
  --ink: #3a3129;
}
/* the tree is 400 art pixels wide, so step down before it gets clipped */
@media (max-width: 1619px) { :root { --px: 3; } }
@media (max-width: 1219px) { :root { --px: 2; } }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  overflow-x: clip;
}

body {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: #000;
  background-color: #4fc7e4;
}

/* anything drawn in pixel art stays crisp when scaled */
.px { image-rendering: pixelated; }

/* ---------- the sky, fixed behind everything ----------
   taller than the window; main.js glides it upward as you scroll so it
   moves slower than the page (parallax) */
.bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 135vh;
  z-index: -1;
  pointer-events: none;
  background: #7ed6e8 url("assets/img/wallpaper4.png") center top / cover no-repeat;
  will-change: transform;
}

/* ---------- hero: banner + nav clouds ---------- */
.hero {
  min-height: calc(100vh - var(--peek));
  min-height: calc(100svh - var(--peek));
  display: grid;
  place-items: start center;
  /* room for the two clouds that hang below the banner */
  padding: 80px 16px 150px;
}
.hero-wrap {
  position: relative;
  width: min(1200px, 100% - 200px);
}

/* the banner, as in the original: mauve-grey box with a pale border */
.banner {
  position: relative;
  padding: 10px;
  background: var(--banner);
  border: 8px solid var(--banner-edge);
  text-align: center;
}
.banner h1 {
  margin: 0.67em 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 2em;
  font-weight: 700;
  color: #000;
}
.banner-img {
  display: block;
  width: 250px;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

/* ---------- nav clouds ----------
   the original cloud images: 300px wide, swapping to the second
   cloud on hover, with the label on top */
.cloud {
  position: absolute;
  z-index: 2;
  width: 25%;               /* 300px on the full 1200px layout */
  max-width: 300px;
  min-width: 150px;
  text-decoration: none;
}
.cloud img {
  display: block;
  width: 100%;
  image-rendering: pixelated;
  transition: opacity 0.15s;
}
.cloud .cloud-hover { position: absolute; inset: 0; opacity: 0; }
.cloud:hover .cloud-hover,   .cloud:focus-visible .cloud-hover   { opacity: 1; }
.cloud:hover .cloud-default, .cloud:focus-visible .cloud-default { opacity: 0; }
.cloud:focus-visible { outline: none; }
.cloud span {
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 70%;
  text-align: center;
  pointer-events: none;
  font-size: clamp(13px, 2vw, 24px);
  font-weight: 700;
  color: #000;
}

/* the original positions, as fractions of the 1200px-wide banner */
.cloud-1 { left: -4.2%;  top: 0; }      /* About Me */
.cloud-2 { left: 83.3%;  top: 0; }      /* Gallery */
.cloud-3 { left: 10.4%;  top: 175px; }  /* Projects */
.cloud-4 { left: 70.8%;  top: 175px; }  /* Record Shelf */

/* the mini clouds, tucked in between the big ones */
.cloud-mini {
  width: 12%;
  max-width: 144px;
  min-width: 92px;
}
.cloud-mini span { font-size: clamp(11px, 1.15vw, 15px); line-height: 1.1; }
.mini-reposts { left: 96%;  top: 180px; }
.mini-colour  { left: -8%;  top: 180px; }
.mini-fortune { left: 38%;  top: 330px; }
.mini-films   { left: 51%;  top: 352px; }
.mini-minifigs { left: 88%; top: 340px; }
.mini-sites    { left: 0%;  top: 345px; }
.mini-toolbox  { left: 64%; top: 352px; }
.cloud[hidden] { display: none; }

@media (max-width: 899px) {
  .hero-wrap { width: calc(100% - 80px); }
}
/* phones: clouds tucked onto the banner's corners */
@media (max-width: 640px) {
  .hero { padding-top: 110px; padding-bottom: 110px; }
  .hero-wrap { width: 100%; }
  .cloud { width: 150px; }
  .cloud-1 { left: -14px; top: -96px; }
  .cloud-2 { left: auto; right: -14px; top: -96px; }
  .cloud-3 { left: -6px; top: calc(100% - 66px); }
  .cloud-4 { left: auto; right: -6px; top: calc(100% - 66px); }
  .cloud-mini { width: 84px; min-width: 0; }
  .mini-reposts { left: auto; right: 96px; top: -60px; }
  .mini-colour  { left: 90px; top: -60px; }
  .mini-fortune { left: calc(50% - 92px); top: calc(100% + 8px); }
  .mini-films   { left: calc(50% + 8px);  top: calc(100% + 20px); }
  .mini-minifigs { left: auto; right: -10px; top: calc(100% + 34px); }
  .mini-sites    { left: -10px; top: calc(100% + 62px); }
  .mini-toolbox  { left: calc(50% - 30px); top: calc(100% + 82px); }
}

/* ---------- the tree ---------- */
.tree-zone {
  position: relative;
  height: calc(680px * var(--px));
  overflow-x: clip;
}
.tree {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: calc(400px * var(--px));
  height: calc(680px * var(--px));
  transform: translateX(-50%);
}
.tree-img { display: block; width: 100%; height: 100%; }
.hang-layer { position: absolute; inset: 0; }

/* debug markers, shown with ?hang in the URL */
.hang-dot {
  position: absolute;
  width: calc(2px * var(--px));
  height: calc(2px * var(--px));
  transform: translateX(-50%);
  background: #ff3b6b;
  outline: calc(1px * var(--px)) solid #fff;
}
.hang-dot span {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
}

/* ---------- ground ---------- */
.ground {
  position: relative;
  z-index: 3;
  margin-top: calc(-14px * var(--px));   /* grass covers the tree's base */
}
.grass {
  height: calc(40px * var(--px));
  background: url("assets/sprites/grass.png") repeat-x 0 0 / calc(48px * var(--px)) calc(40px * var(--px));
}
.dirt {
  min-height: calc(36px * var(--px));
  margin-top: -1px;
  background: var(--dirt) url("assets/sprites/dirt.png") repeat 0 0 / calc(48px * var(--px)) calc(48px * var(--px));
  display: grid;
  place-items: center;
  padding: calc(6px * var(--px)) 16px;
}
.dirt p {
  margin: 0;
  font-size: 16px;
  color: #f3dcb8;
  text-shadow: 2px 2px 0 #4a2c18;
  letter-spacing: 1px;
}

/* ---------- sub-pages (under construction for now) ---------- */
.sub .hero { min-height: 100vh; padding-bottom: 80px; }
.under { margin: 0 0 0.8em; font-size: 18px; }
.under a { color: #000; font-weight: 700; }

/* ---------- about page: the resume ---------- */
.resume { margin-top: 40px; }
.resume h2 {
  margin: 0.4em 0 0.3em;
  font-family: "Times New Roman", Times, serif;
  font-size: 1.6em;
  color: #000;
}
.resume-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 14px;
}
.resume-links a {
  padding: 5px 14px;
  font-weight: 700;
  color: #000;
  text-decoration: none;
  background: var(--banner-edge);
  border: 3px solid #000;
  box-shadow: 3px 3px 0 #000;
}
.resume-links a:hover { background: #fff; }
.resume-links a:active { transform: translate(3px, 3px); box-shadow: none; }
.resume-pdf {
  display: block;
  width: 100%;
  max-width: 900px;
  aspect-ratio: 1 / 1.414;   /* an A4 page */
  margin: 0 auto;
  border: 4px solid #000;
  background: #fff;
}

/* =========================================================
   life in and around the tree (treelife.js)
   ========================================================= */
body.home { position: relative; }
.life {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}
.life img {
  position: absolute;
  top: 0;
  left: 0;
  image-rendering: pixelated;
  will-change: transform;
}
.life .clickable { pointer-events: auto; cursor: pointer; }

.tree-apple {
  position: absolute;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  cursor: pointer;
  filter: drop-shadow(1px 2px 0 rgba(0, 0, 0, 0.35));
}
.tree-apple:hover { transform: translate(-50%, -50%) rotate(-12deg); }

/* things hanging on a cord from a branch */
.hung {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transform: translateX(-50%);
  transform-origin: 50% 0;
  /* each thing gets its own swing (set by treelife.js) so they never move in step */
  animation: dangle var(--swing-time, 4.6s) ease-in-out var(--swing-start, 0s) infinite alternate;
}
@keyframes dangle {
  from { transform: translateX(-50%) rotate(calc(var(--swing, 3deg) * -1)); }
  to   { transform: translateX(-50%) rotate(var(--swing, 3deg)); }
}
.hung .cord {
  width: calc(1px * var(--px));
  height: calc(var(--len) * 1px * var(--px));
  background: #d8cdb0;
}
.hung img {
  width: calc(var(--w) * 1px * var(--px));
  image-rendering: pixelated;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.35));
}
.hung:hover img, .hung:focus-visible img { filter: drop-shadow(0 0 0 #fff) drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.35)) brightness(1.12); }
.hung:focus-visible { outline: 3px dashed #fff; outline-offset: 4px; }
.radio.playing img { animation: thump 0.45s steps(2) infinite; }
@keyframes thump { 50% { transform: scale(1.05, 0.96); } }

.note {
  position: absolute;
  z-index: 2;
  font-size: calc(7px * var(--px));
  color: #fff;
  text-shadow: 2px 2px 0 #1d1c21;
  pointer-events: none;
  animation: floatup 2.2s ease-out forwards;
}
@keyframes floatup {
  from { transform: translate(0, 0); opacity: 1; }
  to   { transform: translate(var(--drift), calc(-28px * var(--px))); opacity: 0; }
}

.radio-panel {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 190px;
  margin-top: calc(42px * var(--px));
  padding: 8px 10px;
  transform: translateX(-50%);
  font: 12px "Trebuchet MS", sans-serif;
  color: #f4ecd2;
  background: #2b6662;
  border: 3px solid #1d1c21;
  box-shadow: 4px 5px 0 rgba(0, 0, 0, 0.4);
}
.radio-panel[hidden] { display: none; }
.hung[hidden] { display: none; }
.rp-title { font: 700 13px Georgia, serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-artist { color: #bfe8e0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-buttons { display: flex; gap: 6px; margin-top: 2px; }
.rp-buttons button {
  flex: 1;
  padding: 2px 0;
  font-size: 14px;
  color: #1d1c21;
  background: #f4d78a;
  border: 2px solid #1d1c21;
  cursor: pointer;
}
.rp-vol { display: flex; align-items: center; gap: 6px; color: #bfe8e0; }
.rp-vol input { flex: 1; accent-color: #f4d78a; }

/* the guestbook */
.guestbook {
  width: min(560px, 94vw);
  max-height: 86vh;
  padding: 20px 22px;
  color: #2a1a0c;
  background: #c9925a;
  border: 4px solid #2a1a0c;
  box-shadow: inset 0 0 0 6px #8a5a2c, 8px 10px 0 rgba(0, 0, 0, 0.4);
}
.guestbook::backdrop { background: rgba(20, 30, 40, 0.6); }
.guestbook h2 { margin: 0; font: 700 26px Georgia, serif; color: #2a1a0c; }
.gb-lede { margin: 4px 0 12px; font-size: 14px; }
.gb-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  font: 700 20px "Trebuchet MS", sans-serif;
  background: #f4ecd2;
  border: 3px solid #2a1a0c;
  cursor: pointer;
}
.gb-form { display: grid; gap: 8px; padding: 10px; background: #fffdf4; border: 3px solid #2a1a0c; }
.gb-form[hidden] { display: none; }
.gb-form input, .gb-form textarea {
  font: 15px Georgia, serif;
  padding: 6px 8px;
  border: 2px solid #8a7a60;
  background: #fff;
  resize: vertical;
}
.gb-form button {
  justify-self: end;
  padding: 5px 14px;
  font: 700 14px "Trebuchet MS", sans-serif;
  background: #f4d78a;
  border: 3px solid #2a1a0c;
  box-shadow: 3px 3px 0 #2a1a0c;
  cursor: pointer;
}
.gb-status { min-height: 1em; margin: 8px 0; font-weight: 700; font-size: 14px; }
.gb-notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.gb-notes li {
  position: relative;
  padding: 12px 10px 8px;
  background: #fbe58a;
  border: 2px solid #2a1a0c;
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.3);
  transform: rotate(var(--tilt, 0deg));
}
.gb-notes li:nth-child(3n + 2) { background: #fffdf4; }
.gb-notes li:nth-child(3n) { background: #cfe8f4; }
.gb-notes li::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: #c0392b;
  border: 1px solid #2a1a0c;
}
.gb-notes p { margin: 0 0 6px; font: 15px Georgia, serif; overflow-wrap: anywhere; }
.gb-notes b { display: block; font-size: 13px; }
.gb-notes small { color: #6b5a40; font-size: 11px; }
.gb-notes .gb-empty { background: #fffdf4; transform: none; grid-column: 1 / -1; text-align: center; }
.gb-notes .gb-empty::before { display: none; }

/* ---- more things in the tree (treethings.js) ---- */
.hung.gusty { --swing: 8deg; animation-duration: 1.1s; }
.chime.ringing img { animation: jingle 1.4s ease-out; }
@keyframes jingle {
  10%, 30%, 50% { transform: rotate(4deg); }
  20%, 40%, 60% { transform: rotate(-4deg); }
  80% { transform: rotate(1deg); }
}
.lantern img { animation: lanternglow 3.2s ease-in-out infinite alternate; }
@keyframes lanternglow {
  from { filter: drop-shadow(0 0 4px rgba(111, 220, 132, 0.55)); }
  to   { filter: drop-shadow(0 0 12px rgba(111, 220, 132, 0.9)); }
}
.lantern.flare img { animation: none; filter: brightness(1.12) saturate(1.3) drop-shadow(0 0 18px #6fdc84) drop-shadow(0 0 40px #2f9e4f); }
.verse-ring {
  position: absolute;
  overflow: visible;
  pointer-events: none;
  font: 700 15px Georgia, serif;
  letter-spacing: 1px;
  fill: #c8ffd0;
  filter: drop-shadow(0 0 4px #6fdc84) drop-shadow(0 0 10px #2f9e4f);
  animation: versespin 16s linear infinite reverse;   /* turns anticlockwise */
  transition: opacity 1.4s;
}
.verse-ring tspan { opacity: 0; animation: wordin 0.5s ease-out forwards; }
.verse-ring.fading { opacity: 0; }
@keyframes wordin { to { opacity: 1; } }
@keyframes versespin { to { transform: rotate(360deg); } }
.tyre .cord { width: calc(2px * var(--px)); background: #b08a5a; }
.bat img { margin-left: calc(7px * var(--px)); }
.bat.wiggle img { animation: wiggle 0.18s linear 5; }
@keyframes wiggle { 50% { transform: rotate(6deg); } }
.zzz {
  position: absolute;
  font: 700 calc(5px * var(--px)) Georgia, serif;
  color: #d8d0f0;
  text-shadow: 1px 1px 0 #1a1420;
  pointer-events: none;
  animation: snooze 2.6s ease-out forwards;
}
@keyframes snooze {
  from { transform: translate(0, 0); opacity: 0.9; }
  to   { transform: translate(calc(8px * var(--px)), calc(-14px * var(--px))); opacity: 0; }
}
.dreamcatcher .beads {
  position: absolute;
  left: 50%;
  top: calc(var(--len) * 1px * var(--px));
  width: calc(18px * var(--px));
  height: calc(18px * var(--px));
  transform: translateX(-50%);
  pointer-events: none;
}
.bead {
  display: inline-block;
  width: calc(2px * var(--px));
  height: calc(2px * var(--px));
  background: #8fd3ff;
  box-shadow: 0 0 6px 2px currentColor;
  color: #8fd3ff;
}
.beads .bead { position: absolute; transform: translate(-50%, -50%); animation: beadpulse 2s ease-in-out infinite alternate; }
@keyframes beadpulse { from { opacity: 0.7; } to { opacity: 1; } }
.bead.attack { background: #ff5a5a; color: #ff5a5a; }
.bead.probe { background: #ffae42; color: #ffae42; }
.bead.tool { background: #c38cff; color: #c38cff; }
.bead.odd { background: #ff8fc8; color: #ff8fc8; }
.bead.lost { background: #ffe066; color: #ffe066; }
.bead.note { background: #7fd1a8; color: #7fd1a8; }
.bead.visitor { background: #8fd3ff; color: #8fd3ff; }
.dream-panel {
  position: absolute;
  z-index: 5;
  width: 260px;
  max-height: 320px;
  overflow-y: auto;
  margin-top: calc(56px * var(--px));
  padding: 10px 12px;
  transform: translateX(-50%);
  font: 12px "Trebuchet MS", sans-serif;
  color: #f4ecd2;
  background: #241c33;
  border: 3px solid #1a1420;
  box-shadow: 4px 5px 0 rgba(0, 0, 0, 0.4);
}
.dream-panel[hidden] { display: none; }
.dream-panel b { font: 700 14px Georgia, serif; }
.dp-lede { margin: 2px 0 8px; color: #c9bfe0; }
.dream-panel ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.dream-panel li { display: grid; grid-template-columns: 12px 1fr; gap: 2px 8px; align-items: center; }
.dream-panel li .bead { width: 8px; height: 8px; box-shadow: 0 0 5px 1px currentColor; }
.dream-panel li small { grid-column: 2; color: #a99fc4; overflow-wrap: anywhere; }
.dp-empty { display: block !important; color: #c9bfe0; }

/* ---------- back to top: floats bottom-right on every page (totop.js) ---------- */
.to-top {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 52px;
  padding: 8px 0 6px;
  font: bold 12px/1 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
  background: var(--navy);
  border: 3px solid #0b0f1c;
  box-shadow: inset 0 0 0 2px #4b5ba3, 4px 4px 0 rgba(0, 0, 0, 0.45);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.2s, transform 0.2s, visibility 0s 0.2s;
}
.to-top.shown {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.2s, transform 0.2s;
}
.to-top:hover { background: #3a4a8c; }
.to-top:active { transform: translate(2px, 2px); box-shadow: inset 0 0 0 2px #4b5ba3, 2px 2px 0 rgba(0, 0, 0, 0.45); }
.to-top:focus-visible { outline: 3px solid #ffd84a; outline-offset: 2px; }
/* a chunky stepped pixel arrow */
.to-top-arrow {
  width: 18px;
  height: 15px;
  background: #ffd84a;
  clip-path: polygon(50% 0, 66.6% 0, 66.6% 20%, 83.3% 20%, 83.3% 40%, 100% 40%, 100% 60%,
    66.6% 60%, 66.6% 100%, 33.3% 100%, 33.3% 60%, 0 60%, 0 40%, 16.6% 40%, 16.6% 20%,
    33.3% 20%, 33.3% 0);
}
/* sit above the Record Shelf's hi-fi bar when it's showing */
body:has(.hifi:not([hidden])) .to-top { bottom: 120px; }
@media (max-width: 600px) { .to-top { right: 12px; bottom: 12px; } }
