/* ==========================================================================
   Sketchbook layer: pencil cursor, doodle mode, self-drawing sketches.
   Loaded after style.css on every page. All three scripts are progressive:
   without JS the site looks exactly as before, plus a static pencil cursor.
   ========================================================================== */

/* handwriting (Caveat); logo letters (DM Serif Display, Special Elite) */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@500;600&family=DM+Serif+Display&family=Special+Elite&display=swap');

:root {
  --graphite: #5f6268;           /* soft HB pencil grey */
  --font-hand: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive;
}

/* ---------- Logo: two cut-out letter stickers (junk-journal / ransom-note style) ---------- */

.brand-letters {
  display: inline-flex;
  align-items: center;
  font-size: 21px;
  filter: drop-shadow(0 2px 2px rgba(24, 36, 73, 0.28));
}
.brand-letters .lt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3em;
  height: 1.5em;
  line-height: 1;
  transition: transform 0.2s ease;
}
/* P: navy paper, yellow serif */
.brand-letters .lt-p {
  background: var(--navy);
  color: var(--yellow);
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.12em;
  padding-top: 0.08em;
  transform: rotate(-7deg);
  clip-path: polygon(4% 2%, 97% 0, 100% 95%, 55% 99%, 1% 100%);
}
/* K: pink paper, typewriter */
.brand-letters .lt-k {
  background: var(--pink);
  color: var(--navy);
  font-family: 'Special Elite', 'Courier New', monospace;
  margin-left: -0.12em;
  transform: rotate(6deg) translateY(0.1em);
  clip-path: polygon(0 5%, 60% 0, 96% 2%, 100% 100%, 3% 96%);
}
.brand:hover .brand-letters .lt-p { transform: rotate(-2deg) translateY(-2px); }
.brand:hover .brand-letters .lt-k { transform: rotate(1deg) translateY(-1px); }


/* ---------- Pencil cursor ---------- */

@media (hover: hover) and (pointer: fine) {
  html,
  a, button, [role="button"], label, summary {
    cursor: url('../images/cursor/pencil.svg') 2 26, auto;
  }
  html.pencil-on,
  html.pencil-on a,
  html.pencil-on button,
  html.pencil-on [role="button"],
  html.pencil-on label,
  html.pencil-on summary {
    cursor: none;
  }
}

/* Embedded prototypes can't report the mouse to us, so they keep the system cursor. */
iframe { cursor: auto; }

.pencil-cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 48px;
  height: 48px;
  pointer-events: none;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s ease;
  will-change: transform;
}
.pencil-cursor.visible { opacity: 1; }

/* rotation / lift / press all pivot on the graphite tip */
.pencil-cursor .pencil-body {
  display: block;
  width: 48px;
  height: 48px;
  overflow: visible;
  transform-origin: 3.4px 44.6px;
  transition: transform 0.18s cubic-bezier(0.3, 1.4, 0.5, 1);
  filter: drop-shadow(1px 2px 0 rgba(24, 36, 73, 0.18));
}
.pencil-cursor.lifted .pencil-body { transform: translate(3px, -5px) rotate(-8deg) scale(1.06); }
.pencil-cursor.pressed .pencil-body { transform: translate(-1px, 1px) scale(0.9); }

/* ---------- Doodle mode ---------- */

.doodle-layer {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 9990;
  overflow: visible;
}
.doodle-layer path {
  fill: none;
  stroke: var(--graphite);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
  /* each segment fades away on its own about a second after it's drawn */
  animation: doodleFade 0.9s ease-in 1s forwards;
}
@keyframes doodleFade { to { opacity: 0; } }
html.doodling, html.doodling * { user-select: none; -webkit-user-select: none; }

/* doodle tip: a yellow tape label, same style as "featured projects", with a pencil icon */
.doodle-chip {
  position: fixed;
  right: 22px;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 9995;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 44px);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.35;
  color: var(--navy);
  background: #f7ecab;
  padding: 12px 42px 12px 18px;
  transform: rotate(-2deg);
  box-shadow: 0 10px 18px rgba(24, 36, 73, 0.14);
  animation: tipIn 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
/* peeling corner, like the featured-projects label */
.doodle-chip::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, #fffdf2 46%, #f7ecab 47%);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  box-shadow: -2px 2px 5px rgba(24, 36, 73, 0.18);
}
@keyframes tipIn {
  from { opacity: 0; transform: translateY(30px) rotate(6deg); }
  to   { opacity: 1; transform: rotate(-2deg); }
}
.doodle-chip[hidden] { display: none; }
.doodle-chip.fade { opacity: 0; transform: translateY(16px) rotate(2deg); }
.doodle-chip-close {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  border: 0;
  background: none;
  color: var(--navy);
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  opacity: 0.55;
}
.doodle-chip-close:hover { opacity: 1; }
.doodle-chip-close:focus-visible { outline: 2px solid var(--blue); border-radius: 4px; }
.doodle-chip svg { width: 18px; height: 18px; flex: none; }

/* ---------- Self-drawing sketches (home page) ---------- */

.sketch {
  position: absolute;
  pointer-events: none;
  overflow: visible;
  opacity: 0;
  transition: opacity 0.2s ease 0.5s;   /* fade only after the lines retract */
  z-index: 6;
}
.sketch.drawn { opacity: 0.9; transition-delay: 0s; }
.sketch path {
  fill: none;
  stroke: var(--graphite);
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 0.5s ease-in-out var(--d, 0s);
}
.sketch path.thin { stroke-width: 1.3; }
.sketch.drawn path { stroke-dashoffset: 0; }

/* handwriting is "written" left to right with a wipe */
.sketch text {
  font-family: var(--font-hand);
  font-weight: 600;
  fill: var(--graphite);
  clip-path: inset(0 100% 0 0);
  transition: clip-path 0.7s steps(14, end) var(--d, 0s);
}
.sketch text.center { text-anchor: middle; dominant-baseline: central; transition-timing-function: ease; transition-duration: 0.2s; }
.sketch.drawn text { clip-path: inset(0 0 0 0); }
.sketch text.ink-blue { fill: #0f62fe; }   /* blue ballpoint for IBM */

/* ---------- Hero scrapbook extras (home page) ---------- */

/* breathing room between the hero board and the project list */
.hero .featured-tag { margin-top: 90px; }
@media (max-width: 640px) { .hero .featured-tag { margin-top: 40px; } }

.sketch path.dot { stroke-width: 2.6; }
.sketch path.nostroke { stroke: none; }
.sketch path.filled {
  fill-opacity: 0;
  transition: stroke-dashoffset 0.5s ease-in-out var(--d, 0s), fill-opacity 0.35s ease calc(var(--d, 0s) + 0.3s);
}
.sketch.drawn path.filled { fill-opacity: 1; }

/* Coffee receipt fed out from under the notecard (it lives inside .note-blurb, behind the card).
   It prints from the card's left end, where the coffee ring has already curved away. */
.receipt-slot {
  position: absolute;
  left: 4%;
  top: 88%;
  width: 36%;
  padding: 0 6px 10px;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(24, 36, 73, 0.16));
}
.receipt {
  visibility: hidden;
  transform: translateY(-101%);
  background: #fffdf7;
  color: #3b3f46;
  font-family: var(--font-mono);
  font-size: 8.5px;
  line-height: 1.4;
  padding: 8px 8px 13px;
  /* torn zig-zag bottom edge */
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 6px) no-repeat,
                conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 10px 6px repeat-x;
          mask: linear-gradient(#000 0 0) top / 100% calc(100% - 6px) no-repeat,
                conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 10px 6px repeat-x;
}
/* thermal-printer feed: the paper advances in small jerks */
.receipt-slot.printing .receipt {
  visibility: visible;
  animation: printOut 1.8s steps(9, end) forwards;
}
@keyframes printOut {
  from { transform: translateY(-101%); }
  to   { transform: translateY(0); }
}
.receipt .r-head { text-align: center; font-weight: 700; letter-spacing: 0.06em; margin-bottom: 2px; }
.receipt .r-dog { display: block; width: 62%; margin: 0 auto 3px; overflow: visible; }
.receipt .r-dog path { fill: none; stroke: var(--graphite); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.receipt .r-rule { border-top: 1px dashed currentColor; opacity: 0.5; margin: 4px 0; }
.receipt .r-row { display: flex; justify-content: space-between; gap: 6px; white-space: nowrap; }
.receipt .r-barcode {
  height: 12px;
  width: 80%;
  margin: 5px auto 0;
  background: repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 3px, currentColor 3px 5px,
              transparent 5px 6px, currentColor 6px 7px, transparent 7px 10px);
}

.about-collage .sketch-frame { left: 0; top: 0; z-index: 0; }

/* heart-cornered frame around the About headshot: drawn on the page, so the notes sit on top of it */
.sticky-board .sketch-photo-frame { z-index: 0; }

/* handwritten notes in the open space beside each painting */
.about-collage .sketch-art-note { width: 190px; z-index: 6; }
.about-collage .art-note-still-life { left: 250px; top: 60px; }
.about-collage .art-note-hands-tea  { left: -95px; top: 330px; width: 180px; }
.about-collage .art-note-lipstick   { left: 228px; top: 610px; }
@media (max-width: 480px) {
  .about-collage .sketch-art-note { width: 118px; }
  .about-collage .art-note-still-life { left: 196px; top: 40px; }
  .about-collage .art-note-hands-tea  { left: -44px; top: 290px; width: 112px; }
  .about-collage .art-note-lipstick   { left: 176px; top: 510px; }
}

.featured-tag .sketch-arrow { left: calc(100% + 10px); top: 4px; width: 120px; }

.project-card { position: relative; }
.project-card .sketch-corner { bottom: calc(100% + 4px); right: 6px; width: 60px; transform: rotate(6deg); }
.project-card:nth-child(even) .sketch-corner { transform: rotate(-6deg); }
.project-card .meta h3 { position: relative; display: inline-block; }
.project-card .sketch-underline { left: -4px; right: -4px; bottom: -8px; width: calc(100% + 8px); height: 12px; }

/* phone layout of the sticky board (see style.css @480px) */
@media (max-width: 480px) {
  .receipt-slot { left: 0; width: 36%; }
  .receipt { font-size: 5.1px; padding: 5px 4px 11px; }
  .receipt .r-row { gap: 2px; }
  .receipt .r-barcode { height: 8px; }
}

@media (max-width: 640px) {
  .project-card .sketch-corner { width: 46px; }
  .featured-tag .sketch-arrow { width: 80px; }
}

/* Tilted tape labels and sketches must never make the page scroll sideways */
main { overflow-x: clip; }
/* ---------- Lightbox (case-study images) ---------- */
.lb-zoomable { cursor: zoom-in; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.lb-zoomable:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(24, 36, 73, 0.16); }
.lb-zoomable:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
html.lb-open { overflow: hidden; }

.lb {
  position: fixed;
  inset: 0;
  z-index: 9998;                    /* above the page and doodle tip, below the pencil cursor */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 56px 16px 64px;
  background: rgba(24, 36, 73, 0.86);
  -webkit-backdrop-filter: blur(3px);
          backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.lb[hidden] { display: none; }
.lb.lb-visible { opacity: 1; }
/* the image is shown like a printed photo: white border, slight tilt, soft shadow */
.lb-figure {
  margin: 0;
  max-width: min(1100px, 100%);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: scale(0.96) rotate(-0.6deg);
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.lb.lb-visible .lb-figure { transform: scale(1) rotate(-0.6deg); }
.lb-img {
  max-width: 100%;
  max-height: calc(100vh - 190px);
  height: auto;
  object-fit: contain;
  background: #fff;
  border: 10px solid #fff;
  border-radius: 3px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
}
.lb-caption {
  max-width: 70ch;
  text-align: center;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.9);
}
.lb-close,
.lb-nav {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--navy);
  font-family: var(--font-head);
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.lb-close:hover, .lb-nav:hover { transform: scale(1.08); background: var(--yellow-soft); }
.lb-close:focus-visible, .lb-nav:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
.lb-close { position: absolute; top: 14px; right: 16px; width: 40px; height: 40px; font-size: 26px; line-height: 1; }
.lb-nav { width: 46px; height: 46px; font-size: 20px; }
.lb-nav[hidden] { display: none; }
.lb-count {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.8);
}
@media (max-width: 640px) {
  .lb { padding: 60px 10px 70px; gap: 0; }
  /* on phones the arrows move below the image, either side of the counter */
  .lb-nav { position: absolute; bottom: 12px; width: 42px; height: 42px; }
  .lb-prev { left: calc(50% - 110px); }
  .lb-next { right: calc(50% - 110px); }
  .lb-img { border-width: 6px; max-height: calc(100vh - 220px); }
  .lb-caption { font-size: 14px; }
}

/* ---------- Footer switch: doodle mode on/off (added by js/doodle.js) ---------- */
.footer-nav { align-items: center; }
.doodle-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: 4px;
  padding: 6px 8px 6px 12px;
  border: 0;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.08em;
  transition: background-color 0.2s ease;
}
.doodle-toggle:hover { background: rgba(255, 255, 255, 0.2); }
.doodle-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.doodle-toggle svg { width: 18px; height: 18px; flex: none; }
.doodle-toggle-track {
  position: relative;
  width: 38px; height: 22px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.3);
  transition: background-color 0.25s ease;
}
.doodle-toggle-track::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(24, 36, 73, 0.3);
  transition: transform 0.25s ease, background-color 0.25s ease;
}
.doodle-toggle[aria-checked="true"] .doodle-toggle-track { background: var(--yellow); }
.doodle-toggle[aria-checked="true"] .doodle-toggle-track::after { transform: translateX(16px); background: var(--navy); }

/* ---------- Polaroid (Mylo, on the WoPet page): photo with a pencilled caption ---------- */
.polaroid {
  position: relative;
  width: 230px;
  max-width: 100%;
  margin: 10px auto;
  padding: 10px 10px 0;
  background: #fffdf8;
  box-shadow: inset 0 0 14px rgba(120, 92, 48, 0.12), 0 1px 2px rgba(0, 0, 0, 0.12), 0 12px 24px rgba(24, 36, 73, 0.18);
  transform: rotate(5deg);
  transition: transform 0.3s ease;
}
.polaroid:hover { transform: rotate(1deg) translateY(-5px); }
.polaroid img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 0; }
.polaroid figcaption {
  padding: 12px 4px 14px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--graphite);
  transform: rotate(-2deg);
}
