/* ───────── Tokens: paper & ink ─────────
   Light = daytime sketchbook (cream paper, ink accent)
   Dark  = night sketchbook (brown-black paper, sand accent) */
:root {
  --paper: #f3ead9;
  --paper-2: #ebe0cc;
  --surface: #f9f3e7;
  --border: #d9cbb3;
  --text: #241b13;
  --text-soft: #43362b;
  --muted: #6e5f4f;
  --ink: #2e3f66;          /* accent: fountain-pen blue */
  --ink-text: #2a3a5f;
  --on-ink: #fdf8ee;
  --green: #4f8a4a;
  /* watercolor pigments */
  --wc-rose: #e8a3a0;
  --wc-ochre: #e9c47a;
  --wc-sage: #a9c6a2;
  --wc-sky: #9fbfe0;
  --wc-violet: #c3a8d8;
  --photo: #fffdf8;
  --photo-text: #241b13; --photo-soft: #4a3d31; --photo-muted: #7b6c5c; --photo-chip: #f1eadf; --photo-border: #ddd2c2;
  --tape: rgba(255, 228, 150, .55);
  --tape-edge: rgba(120, 90, 20, .12);
  --wash-opacity: .5;
  --grain-opacity: .42;
  --grain-blend: multiply;
  --shadow: 0 1px 2px rgba(60,40,20,.06), 0 10px 28px -14px rgba(60,40,20,.25);
  --radius: 14px;
  --max: 1080px;
}
:root[data-theme="dark"] {
  --paper: #2b2119; --paper-2: #342920; --surface: #382d24; --border: #55463a;
  --text: #f6eee2; --text-soft: #dccfbd; --muted: #a89684;
  --ink: #e4c07a; --ink-text: #ecc98a; --on-ink: #1c1511; --green: #7fc27a;
  --photo: #f6efe3; --tape: rgba(255, 228, 150, .4); --tape-edge: rgba(255,255,255,.1);
  --wash-opacity: .38; --grain-opacity: .22; --grain-blend: screen;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.7);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #2b2119; --paper-2: #342920; --surface: #382d24; --border: #55463a;
    --text: #f6eee2; --text-soft: #dccfbd; --muted: #a89684;
    --ink: #e4c07a; --ink-text: #ecc98a; --on-ink: #1c1511; --green: #7fc27a;
    --photo: #f6efe3; --tape: rgba(255, 228, 150, .4); --tape-edge: rgba(255,255,255,.1);
    --wash-opacity: .38; --grain-opacity: .22; --grain-blend: screen;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.7);
  }
}

/* ───────── Base ───────── */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.65;
  color: var(--text); background: var(--paper);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
/* paper texture over everything: fine grain + coarse mottling, like cold-press watercolor paper */
body::before, body::after {
  content: ""; position: fixed; inset: 0; z-index: 30; pointer-events: none;
  mix-blend-mode: var(--grain-blend);
}
body::before {
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .34 0 0 0 0 .25 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 300px 300px;
}
body::after {
  opacity: calc(var(--grain-opacity) * .9);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='900'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='3' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .38 0 0 0 0 .30 0 0 0 0 .20 0 0 0 .45 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");
  background-size: 900px 900px;
}
a { color: var(--ink-text); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0; }
h1 { font-size: clamp(2.4rem, 5.4vw, 3.8rem); font-weight: 700; letter-spacing: -0.03em; }
h2 { font-family: "Caveat", "Segoe Script", cursive; font-size: 2.9rem; font-weight: 600; letter-spacing: 0; margin-bottom: .1rem; position: relative; display: inline-block; }
h3 { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 1rem; }
ul { margin: 0; padding: 0; list-style: none; }
.container { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); font-weight: 400; }
.hand { font-family: "Caveat", cursive; font-weight: 600; }

/* hand-drawn underline under h2 (svg injected by main.js) */
h2 .underline { position: absolute; left: -2%; bottom: -.15em; width: 104%; height: .5em; overflow: visible; pointer-events: none; }
h2 .underline path { fill: none; stroke: var(--wc-ochre); stroke-width: 6; stroke-linecap: round; opacity: .85;
  stroke-dasharray: 400; stroke-dashoffset: 400; transition: stroke-dashoffset 1.1s ease .25s; }
.in-view h2 .underline path { stroke-dashoffset: 0; }

/* ───────── Watercolor washes ─────────
   .wash = a soft pigment blob. Filter #wc (in index.html) roughens the edge like wet paper. */
.hero .washes, section .washes { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: visible; }
/* everything that isn't a wash paints above the washes */
.hero > :not(.washes), section > :not(.washes) { position: relative; z-index: 1; }
.wash {
  position: absolute; width: 520px; height: 440px; overflow: visible;
  mix-blend-mode: multiply;
  opacity: 0; transform: scale(.55) rotate(var(--r, 0deg));
  transition: opacity 1.8s ease, transform 2.2s cubic-bezier(.2,.7,.2,1);
  will-change: transform, opacity;
}
:root[data-theme="dark"] .wash { mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wash { mix-blend-mode: screen; } }
.in-view .wash { opacity: var(--wash-opacity); transform: scale(1) rotate(var(--r, 0deg)); animation: drift 26s ease-in-out infinite alternate; }
.wash.w2 { animation-duration: 34s; animation-direction: alternate-reverse; }
@keyframes drift {
  0%   { translate: 0 0; }
  50%  { translate: 18px -14px; }
  100% { translate: -14px 12px; }
}
section, .hero, .site-header { position: relative; }
section > .container, .hero > *, .section > * { position: relative; z-index: 1; }

/* ───────── Scroll reveal ───────── */
.reveal { opacity: 0; translate: 0 18px; transition: opacity .9s ease, transform .9s cubic-bezier(.2,.7,.2,1); }
.reveal.in-view { opacity: 1; translate: 0 0; }
.card.reveal { transition-delay: calc(var(--i, 0) * 90ms); }
@media (prefers-reduced-motion: reduce) {
  .reveal, .wash, h2 .underline path, .doodle path, .doodle ellipse { transition: none !important; animation: none !important; opacity: 1; translate: 0 0; stroke-dashoffset: 0; }
  .wash { opacity: var(--wash-opacity); }
}

/* ───────── Hand-drawn bits ───────── */
.sketch { border: 2px solid var(--text); border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px; }
.tape { position: absolute; width: 96px; height: 28px; background: var(--tape); border: 1px solid var(--tape-edge);
  box-shadow: 0 1px 2px rgba(0,0,0,.08); pointer-events: none; z-index: 2;
  mask: linear-gradient(90deg, transparent 0, #000 6px, #000 calc(100% - 6px), transparent 100%); }
.note { font-family: "Caveat", cursive; font-weight: 600; font-size: 1.35rem; color: var(--ink-text); line-height: 1.1; }
.doodle { position: absolute; pointer-events: none; overflow: visible; z-index: 2; }
.doodle path, .doodle ellipse { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 600; stroke-dashoffset: 600; transition: stroke-dashoffset 1.4s ease .5s; }
.in-view .doodle path, .in-view .doodle ellipse { stroke-dashoffset: 0; }
.circle-word { position: relative; display: inline-block; }
.circle-word .doodle { left: -10%; top: -18%; width: 120%; height: 140%; }
.circle-word .doodle ellipse { stroke: var(--wc-rose); stroke-width: 3; opacity: .9; }

/* ───────── Header ───────── */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { font-family: "Caveat", cursive; font-weight: 700; font-size: 1.6rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 1.4rem; }
.nav-links a { color: var(--text-soft); font-weight: 500; font-size: .95rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ───────── Hero ───────── */
.hero { padding: 110px 20px 84px; max-width: 800px; margin-left: auto; margin-right: auto; }
.eyebrow { font-family: "Caveat", cursive; color: var(--ink-text); font-weight: 600; font-size: 1.5rem; margin-bottom: .4rem; }
.lede { font-size: 1.15rem; color: var(--text-soft); max-width: 60ch; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: 1.75rem; }
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .65rem 1.15rem; font-weight: 600; font-size: .95rem;
  border: 2px solid var(--text); border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  background: var(--surface); color: var(--text);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-2px) rotate(-.6deg); box-shadow: var(--shadow); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn-primary:hover { transform: translateY(-2px) rotate(.6deg); }
.status-pill {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: .85rem; color: var(--text-soft); padding: .4rem .8rem;
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px; background: var(--surface); border: 1.5px solid var(--border);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }

/* ───────── Sections ───────── */
.section { padding: 64px 20px; }
.section-sub { color: var(--muted); margin: .2rem 0 2rem; }
.subheading { margin: 3rem 0 1rem; font-size: 1.1rem; }

/* ───────── Project cards → photos taped to the page ───────── */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3.2rem 2.6rem; padding-top: 1rem; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--photo); padding: 14px 14px 18px;
  box-shadow: 0 1px 1px rgba(60,40,20,.08), 0 14px 30px -16px rgba(60,40,20,.45);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .35s cubic-bezier(.2,.7,.2,1), box-shadow .35s ease, opacity .9s ease;
}
.card:nth-child(1) { --tilt: -1.4deg; }
.card:nth-child(2) { --tilt: 1.1deg; }
.card:nth-child(3) { --tilt: 1.3deg; }
.card:nth-child(4) { --tilt: -.9deg; }
.card:hover { transform: rotate(0deg) translateY(-6px) scale(1.01); box-shadow: 0 2px 2px rgba(60,40,20,.08), 0 26px 40px -18px rgba(60,40,20,.55); z-index: 3; }
.card .tape { top: -12px; left: 22px; transform: rotate(-5deg); }
.card .tape.r { left: auto; right: 22px; transform: rotate(6deg); }
.card-media { display: block; aspect-ratio: 16 / 10; background: var(--paper-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; object-position: top; filter: saturate(.96) contrast(1.02); transition: transform .5s ease; }
.card:hover .card-media img { transform: scale(1.03); }
.card-body { padding: 1rem .25rem 0; display: flex; flex-direction: column; gap: .55rem; flex: 1; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.card-head h3 { font-family: "Caveat", cursive; font-size: 2rem; font-weight: 700; letter-spacing: 0; }
.tag { font-family: "Caveat", cursive; font-size: 1.1rem; font-weight: 600; color: #2e3f66; border: 1.5px solid #2e3f66; border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px; padding: 0 .65rem; white-space: nowrap; line-height: 1.5; transform: rotate(-2deg); }
.card { color: var(--photo-text); }
.card-body p { margin: 0; color: var(--photo-soft); font-size: .95rem; }
.shows { font-size: .9rem !important; }
.shows strong { font-family: "Caveat", cursive; font-size: 1.2rem; color: #2e3f66; font-weight: 600; }
.stack { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .25rem; }
.stack li { font-size: .78rem; font-weight: 500; color: var(--photo-muted); background: var(--photo-chip); border: 1px solid var(--photo-border); padding: .15rem .55rem; border-radius: 6px; }
.links { display: flex; gap: 1.1rem; margin-top: auto; padding-top: .75rem; font-family: "Caveat", cursive; font-size: 1.35rem; font-weight: 700; }
.links a { color: #2e3f66; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: rgba(46,63,102,.4); }
.links a:hover { text-decoration-color: #2e3f66; }

/* ───────── Mini game tiles → little polaroids ───────── */
.grid-small { grid-template-columns: repeat(5, 1fr); gap: 1.6rem 1.2rem; padding: 1.2rem 0 .5rem; }
.mini {
  position: relative; display: flex; flex-direction: column; gap: .4rem; color: var(--text);
  background: var(--photo); padding: 9px 9px 10px;
  box-shadow: 0 1px 1px rgba(60,40,20,.08), 0 10px 22px -12px rgba(60,40,20,.45);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .3s cubic-bezier(.2,.7,.2,1), box-shadow .3s ease;
}
.mini:nth-child(1) { --tilt: -3deg; } .mini:nth-child(2) { --tilt: 2deg; } .mini:nth-child(3) { --tilt: -1.5deg; }
.mini:nth-child(4) { --tilt: 2.5deg; } .mini:nth-child(5) { --tilt: -2deg; }
.mini:hover { text-decoration: none; transform: rotate(0deg) translateY(-5px) scale(1.04); z-index: 3; }
.mini .tape { top: -11px; left: 50%; width: 70px; height: 22px; transform: translateX(-50%) rotate(-3deg); }
.mini img { aspect-ratio: 16 / 10; width: 100%; object-fit: cover; background: var(--paper-2); }
.mini img.portrait { object-fit: contain; background: #0f5132; }
.mini { color: var(--photo-text); }
.mini span { font-family: "Caveat", cursive; font-size: 1.3rem; font-weight: 700; padding: 0 .1rem; }
.mini small { color: var(--photo-muted); font-weight: 400; font-family: "Inter", sans-serif; font-size: .75rem; }

/* ───────── About / Skills / Contact ───────── */
.prose { max-width: 66ch; color: var(--text-soft); font-size: 1.05rem; }
.skills { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; margin-top: 1.25rem; }
.skill-group:nth-child(odd) { transform: rotate(-.5deg); } .skill-group:nth-child(even) { transform: rotate(.6deg); }
.skill-group { padding: .9rem 1.1rem .6rem; background: var(--surface); }
.skill-group h4 { font-family: "Caveat", cursive; font-size: 1.35rem; font-weight: 600; color: var(--ink-text); margin-bottom: .5rem; }
.skill-group li { padding: .25rem 0; color: var(--text-soft); border-bottom: 1px dashed var(--border); font-size: .95rem; }
.skill-group li:last-child { border-bottom: 0; }
.contact { padding-bottom: 90px; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; padding: 1.5rem 20px 2.5rem; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted); position: relative; z-index: 1; }

/* ───────── Responsive ───────── */
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; gap: 2.6rem; }
  .grid-small { grid-template-columns: repeat(3, 1fr); }
  .skills { grid-template-columns: repeat(2, 1fr); }
  .wash { width: 300px; height: 260px; opacity: 0 !important; }
  .in-view .wash { opacity: calc(var(--wash-opacity) * .6) !important; }
}
@media (max-width: 600px) {
  .hero { padding: 72px 16px 56px; }
  .container { padding-left: 16px; padding-right: 16px; }
  .section { padding: 48px 16px; }
  h2 { font-size: 2.4rem; }
  .nav-links { gap: .9rem; }
  .nav-links a:not(:last-of-type) { display: none; }
  .grid-small { grid-template-columns: repeat(2, 1fr); }
  .skills { grid-template-columns: 1fr 1fr; gap: 1rem; }
}
.mini.reveal { transition: opacity .9s ease, transform .9s cubic-bezier(.2,.7,.2,1); transition-delay: calc(var(--i, 0) * 70ms); }


/* placeholder "photo" for projects without a screenshot yet */
.card-media.placeholder .note { color: #2e3f66; }
.card-media.placeholder { display: flex; align-items: center; justify-content: center; text-align: center; padding: 1rem;
  background: repeating-linear-gradient(0deg, transparent 0 27px, color-mix(in srgb, var(--wc-sky) 55%, transparent) 27px 28px), var(--photo); }
.card-media.placeholder:hover { text-decoration: none; }
.card:nth-child(5) { --tilt: 1.2deg; }
.card:nth-child(3) { --tilt: -1.1deg; }
@media (max-width: 860px) { .note[style*="calc(100%"] , .doodle[style*="calc(100%"] { display: none; } }

/* sticky note filling the last grid slot */
.sticky { position: relative; align-self: start; justify-self: center; margin-top: 2rem; width: min(78%, 330px); aspect-ratio: 1 / .9;
  display: flex; flex-direction: column; justify-content: center; gap: .4rem; padding: 1.4rem 1.5rem; text-align: center;
  background: #fff3a8; color: var(--text); box-shadow: 0 1px 1px rgba(60,40,20,.08), 0 12px 26px -14px rgba(60,40,20,.5);
  transform: rotate(2.5deg); transition: transform .3s cubic-bezier(.2,.7,.2,1); }
.sticky .note { color: #4a3a12; }
.sticky .tape { top: -11px; left: 50%; width: 80px; transform: translateX(-50%) rotate(-2deg); }
.sticky:hover { text-decoration: none; transform: rotate(0deg) translateY(-5px); }
:root[data-theme="dark"] .sticky { background: #d8c46a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sticky { background: #d8c46a; } }
@media (max-width: 860px) { .sticky { margin-top: 0; } }
