/* === LAB NOTEBOOK PORTFOLIO === */

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;700&family=Kalam:wght@400;700&family=IBM+Plex+Sans:wght@400;600&family=IBM+Plex+Mono:wght@400&family=IBM+Plex+Serif:ital,wght@0,400;1,400&display=swap');

:root {
  --paper: #f5efe0;
  --paper-warm: #efe7d3;
  --paper-cream: #faf5e6;
  --ink: #1a1a2e;
  --ink-soft: #3a3a52;
  --ink-faded: #6b6b80;
  --grid: rgba(60, 80, 120, 0.10);
  --grid-strong: rgba(60, 80, 120, 0.18);
  --red-pen: #c8324a;
  --red-pen-soft: #e85d70;
  --blue-pen: #2a4d8f;
  --blue-pen-soft: #4a6fb0;
  --pencil: #4a4a4a;
  --highlight-yellow: #fff48c;
  --highlight-yellow-deep: #ffe85c;
  --tape: rgba(220, 200, 140, 0.55);
  --shadow-soft: 0 2px 6px rgba(40, 30, 20, 0.08);
  --shadow-paper: 0 4px 16px rgba(40, 30, 20, 0.12), 0 1px 3px rgba(40, 30, 20, 0.08);
  --shadow-deep: 0 12px 40px rgba(40, 30, 20, 0.18), 0 2px 6px rgba(40, 30, 20, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #2a2620;
  font-family: 'IBM Plex Sans', sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Paper texture overlay applied to anything with .paper */
.paper {
  background-color: var(--paper);
  background-image:
    /* horizontal lines (notebook ruling) */
    linear-gradient(transparent 31px, var(--grid) 31px, var(--grid) 32px, transparent 32px),
    /* subtle paper noise */
    radial-gradient(ellipse at top left, rgba(255, 240, 200, 0.4), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(180, 160, 120, 0.15), transparent 50%);
  background-size: 100% 32px, 100% 100%, 100% 100%;
  position: relative;
}

.paper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent 0, transparent 31px, var(--grid) 31px, var(--grid) 32px),
    repeating-linear-gradient(90deg, transparent 0, transparent 31px, var(--grid) 31px, var(--grid) 32px);
  pointer-events: none;
  opacity: 0.6;
  z-index: 0;
}

.paper::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    /* random fiber/noise speckle */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' seed='5'/><feColorMatrix values='0 0 0 0 0.3  0 0 0 0 0.25  0 0 0 0 0.15  0 0 0 0.04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: multiply;
  z-index: 1;
}

/* Notebook page wrapper — perspective binding on the left */
.notebook {
  max-width: 980px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.notebook-page {
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(60, 80, 120, 0.08) 31px, rgba(60, 80, 120, 0.08) 32px);
  position: relative;
  padding: 80px 80px 100px 110px;
  box-shadow: var(--shadow-deep);
  margin: 40px auto;
  min-height: 100vh;
}

/* Red margin line — left side of notebook */
.notebook-page::before {
  content: '';
  position: absolute;
  left: 80px;
  top: 0;
  bottom: 0;
  width: 1.5px;
  background: rgba(200, 50, 74, 0.45);
  z-index: 1;
}

/* Punch holes on left edge */
.notebook-page::after {
  content: '';
  position: absolute;
  left: 18px;
  top: 0;
  bottom: 0;
  width: 8px;
  background:
    radial-gradient(circle at 50% 80px, #2a2620 8px, transparent 9px),
    radial-gradient(circle at 50% 240px, #2a2620 8px, transparent 9px),
    radial-gradient(circle at 50% 400px, #2a2620 8px, transparent 9px),
    radial-gradient(circle at 50% 560px, #2a2620 8px, transparent 9px),
    radial-gradient(circle at 50% 720px, #2a2620 8px, transparent 9px),
    radial-gradient(circle at 50% 880px, #2a2620 8px, transparent 9px),
    radial-gradient(circle at 50% 1040px, #2a2620 8px, transparent 9px),
    radial-gradient(circle at 50% 1200px, #2a2620 8px, transparent 9px);
  background-repeat: repeat-y;
  background-size: 100% 1280px;
  pointer-events: none;
}

/* === HANDWRITING + INK === */
.handwritten {
  font-family: 'Caveat', 'Caveat-fallback', cursive;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.scribble {
  font-family: 'Kalam', cursive;
  font-weight: 400;
}

.ink-red { color: var(--red-pen); }
.ink-blue { color: var(--blue-pen); }
.ink-pencil { color: var(--pencil); }

/* === MARGIN ANNOTATIONS === */
.margin-note {
  position: absolute;
  font-family: 'Caveat', cursive;
  font-size: 18px;
  color: var(--red-pen);
  line-height: 1.1;
  transform: rotate(-3deg);
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.margin-note.visible {
  opacity: 1;
}

.margin-note.left {
  right: calc(100% + 10px);
  width: 140px;
  text-align: right;
  transform: rotate(-2deg);
}

.margin-note.right {
  left: calc(100% + 10px);
  width: 160px;
  text-align: left;
  transform: rotate(3deg);
}

/* === HEADERS === */
.section-num {
  font-family: 'Caveat', cursive;
  font-size: 28px;
  color: var(--red-pen);
  display: inline-block;
  margin-right: 12px;
  transform: rotate(-2deg);
}

.section-title {
  font-family: 'IBM Plex Serif', serif;
  font-weight: 500;
  font-size: 38px;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--ink);
  margin: 0 0 8px 0;
  position: relative;
  display: inline-block;
}

/* Underline drawn by hand */
.underline-hand {
  position: relative;
  display: inline-block;
}

.underline-hand::after {
  content: '';
  position: absolute;
  left: -4px;
  right: -4px;
  bottom: -6px;
  height: 8px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 10' preserveAspectRatio='none'><path d='M 2 6 Q 50 2 100 5 T 198 4' stroke='%23c8324a' stroke-width='2.2' fill='none' stroke-linecap='round'/></svg>") no-repeat center / 100% 100%;
  pointer-events: none;
}

.section-sub {
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--blue-pen);
  margin: 12px 0 24px 0;
  font-weight: 500;
  position: relative;
  z-index: 3;
}

/* === BODY === */
.body-text {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 16px;
  line-height: 1.85;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.body-text p { margin: 0 0 16px 0; }

/* Highlighted text */
.highlight {
  background: linear-gradient(180deg, transparent 0%, transparent 50%, var(--highlight-yellow) 50%, var(--highlight-yellow) 95%, transparent 95%);
  padding: 0 3px;
}

.highlight-deep {
  background: linear-gradient(180deg, transparent 0%, transparent 55%, var(--highlight-yellow-deep) 55%, var(--highlight-yellow-deep) 92%, transparent 92%);
  padding: 0 3px;
}

/* Inline ink scribbles */
.ink-strike {
  position: relative;
  color: var(--ink-faded);
}

.ink-strike::after {
  content: '';
  position: absolute;
  left: -2px;
  right: -2px;
  top: 50%;
  height: 2px;
  background: var(--red-pen);
  transform: rotate(-1.5deg);
}

/* === POLAROID / FIGURE FRAMES === */
.polaroid {
  background: #fdfaf0;
  padding: 14px 14px 50px 14px;
  box-shadow: var(--shadow-paper);
  position: relative;
  display: inline-block;
  transform: rotate(-2deg);
  transition: transform 0.4s ease;
}

.polaroid:hover {
  transform: rotate(0deg) scale(1.03);
}

.polaroid-caption {
  position: absolute;
  bottom: 12px;
  left: 14px;
  right: 14px;
  font-family: 'Caveat', cursive;
  font-size: 18px;
  color: var(--ink-soft);
  text-align: center;
}

/* Tape strips */
.tape {
  position: absolute;
  background: var(--tape);
  width: 80px;
  height: 22px;
  border-left: 1px dashed rgba(180, 160, 100, 0.6);
  border-right: 1px dashed rgba(180, 160, 100, 0.6);
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

.tape.tl { top: -10px; left: -20px; transform: rotate(-25deg); }
.tape.tr { top: -10px; right: -20px; transform: rotate(20deg); }

/* === FIGURE BLOCK (taped-in) === */
.figure {
  position: relative;
  background: var(--paper-cream);
  border: 1px solid rgba(60, 60, 80, 0.15);
  padding: 24px;
  margin: 32px 0;
  box-shadow: var(--shadow-paper);
}

.figure-label {
  position: absolute;
  top: -14px;
  left: 24px;
  background: var(--paper);
  padding: 0 10px;
  font-family: 'Caveat', cursive;
  font-size: 18px;
  color: var(--red-pen);
  font-weight: 600;
}

/* === MONO BLOCKS (code, terminal) === */
.code-block {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  line-height: 1.7;
  background: #1a1a2e;
  color: #e8e6dc;
  padding: 20px 24px;
  border-radius: 4px;
  overflow-x: auto;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.4);
  position: relative;
}

.code-block .comment { color: #8b8b9e; font-style: italic; }
.code-block .keyword { color: #ff8866; }
.code-block .string { color: #98d982; }
.code-block .number { color: #f0c674; }
.code-block .func { color: #82aaff; }

/* === SVG SKETCH ANIMATIONS === */
.sketch path,
.sketch circle,
.sketch line,
.sketch rect,
.sketch polyline,
.sketch ellipse {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  transition: stroke-dashoffset 1.6s cubic-bezier(0.65, 0, 0.35, 1);
}

.sketch.drawn path,
.sketch.drawn circle,
.sketch.drawn line,
.sketch.drawn rect,
.sketch.drawn polyline,
.sketch.drawn ellipse {
  stroke-dashoffset: 0;
}

/* Stagger animation delays */
.sketch.drawn *:nth-child(1) { transition-delay: 0s; }
.sketch.drawn *:nth-child(2) { transition-delay: 0.2s; }
.sketch.drawn *:nth-child(3) { transition-delay: 0.4s; }
.sketch.drawn *:nth-child(4) { transition-delay: 0.6s; }
.sketch.drawn *:nth-child(5) { transition-delay: 0.8s; }
.sketch.drawn *:nth-child(6) { transition-delay: 1.0s; }
.sketch.drawn *:nth-child(7) { transition-delay: 1.2s; }
.sketch.drawn *:nth-child(8) { transition-delay: 1.4s; }
.sketch.drawn *:nth-child(9) { transition-delay: 1.6s; }
.sketch.drawn *:nth-child(10) { transition-delay: 1.8s; }

/* === REVEAL ON SCROLL === */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.2, 0.6, 0.2, 1);
}

.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

.reveal.delay-1 { transition-delay: 0.15s; }
.reveal.delay-2 { transition-delay: 0.3s; }
.reveal.delay-3 { transition-delay: 0.45s; }
.reveal.delay-4 { transition-delay: 0.6s; }

/* Fade-and-rotate for polaroids */
.reveal-polaroid {
  opacity: 0;
  transform: translateY(30px) rotate(-8deg) scale(0.95);
  transition: opacity 1s ease, transform 1s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.reveal-polaroid.in {
  opacity: 1;
  transform: translateY(0) rotate(-2deg) scale(1);
}

/* === HERO SIGNATURE === */
.signature-svg {
  display: block;
  width: 100%;
  /* Reserve aspect ratio so signature animation can't shift surrounding layout */
  aspect-ratio: 420 / 100;
  max-width: 360px;
  height: auto;
}

.signature-svg path {
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  animation: drawSig 2.4s 0.6s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

@keyframes drawSig {
  to { stroke-dashoffset: 0; }
}

/* === DOODLES === */
.doodle-arrow {
  position: absolute;
  pointer-events: none;
  z-index: 4;
}

.doodle-arrow path {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  transition: stroke-dashoffset 1.2s ease 0.3s;
}

.doodle-arrow.drawn path {
  stroke-dashoffset: 0;
}

/* === PAGE-FLIP TRANSITION === */
.page-flip {
  perspective: 2000px;
  margin: 60px 0;
  text-align: center;
}

.page-flip-line {
  display: inline-block;
  width: 100%;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(60, 80, 120, 0.3), transparent);
  position: relative;
}

.page-flip-line::after {
  content: '✦';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--paper);
  padding: 0 16px;
  color: var(--ink-faded);
  font-size: 14px;
}

/* === COVER PAGE === */
.cover-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  padding: 80px;
  /* Reserve space — prevents CLS as fonts/animations settle */
  contain: layout style;
}

.cover-stamp {
  position: absolute;
  top: 60px;
  right: 80px;
  border: 3px solid var(--red-pen);
  padding: 12px 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 14px;
  color: var(--red-pen);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transform: rotate(8deg);
  opacity: 0.85;
}

.cover-stamp .stamp-line {
  font-size: 10px;
  font-weight: 400;
  margin-top: 4px;
}

/* === STICKERS / BADGES === */
.sticker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--highlight-yellow);
  border: 1px solid rgba(0,0,0,0.1);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  transform: rotate(-1deg);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

/* === LINKS === */
a { color: var(--blue-pen); text-decoration: none; border-bottom: 1px solid currentColor; }
a:hover { color: var(--red-pen); }

/* === CTA BUTTONS === */
.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  background: var(--paper-cream);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  text-decoration: none !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 1px 1px 0 rgba(0,0,0,0.08);
}
.cta-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 rgba(0,0,0,0.12); color: var(--red-pen); }
.cta-btn.cta-primary { background: var(--red-pen); color: #fff; border-color: var(--red-pen); }
.cta-btn.cta-primary:hover { color: #fff; background: #b02a3e; }
.cta-btn.cta-secondary { background: var(--blue-pen); color: #fff; border-color: var(--blue-pen); }
.cta-btn.cta-secondary:hover { color: #fff; background: #1f3d7a; }

/* Brand-colored CTA buttons */
.cta-btn.cta-mail { background: #ea4335; color: #fff; border-color: #c5221f; }
.cta-btn.cta-mail:hover { color: #fff; background: #c5221f; }
.cta-btn.cta-linkedin { background: #0a66c2; color: #fff; border-color: #084b91; }
.cta-btn.cta-linkedin:hover { color: #fff; background: #084b91; }
.cta-btn.cta-github { background: #1a1a2e; color: #fff; border-color: #000; }
.cta-btn.cta-github:hover { color: #fff; background: #000; }
.cta-btn.cta-resume { background: #2a2620; color: #f5efe0; border-color: #1a1a2e; }
.cta-btn.cta-resume:hover { color: #f5efe0; background: #1a1a2e; }

/* === KONAMI TERMINAL === */
.konami-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.konami-term {
  width: min(680px, 90vw);
  height: min(440px, 70vh);
  background: #1a1a2e;
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  overflow: hidden;
  display: flex; flex-direction: column;
  font-family: 'IBM Plex Mono', monospace;
}
.konami-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  background: #2a2a44;
  color: #d8d8e8;
}
.konami-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; cursor: pointer; }
.konami-body {
  flex: 1; overflow-y: auto;
  padding: 16px 20px;
  color: #e8e6dc; font-size: 13.5px; line-height: 1.7;
}
.konami-line { margin-bottom: 4px; }
.konami-sys { color: #98d982; font-style: italic; }
.konami-out { color: #d4d4e0; padding-left: 12px; }
.konami-input {
  background: transparent; border: none; outline: none;
  color: #e8e6dc; font-family: inherit; font-size: inherit;
  width: 80%;
}

/* Ribbon bookmark down right edge of cover */
.notebook-page .ribbon {
  position: absolute;
  top: -4px;
  right: 80px;
  width: 32px;
  height: 140px;
  background: linear-gradient(180deg, #c8324a 0%, #a02438 100%);
  z-index: 4;
  box-shadow: 1px 2px 6px rgba(0,0,0,0.18);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
  pointer-events: none;
}
.notebook-page .ribbon::after {
  content: '';
  position: absolute;
  inset: 4px;
  background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.08) 50%, transparent 100%);
}

/* Tape strip — chapter labels */
.chapter-tape {
  display: inline-block;
  background: var(--tape);
  padding: 4px 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  transform: rotate(-1.2deg);
  border-left: 1px dashed rgba(180, 160, 100, 0.6);
  border-right: 1px dashed rgba(180, 160, 100, 0.6);
  margin-bottom: 12px;
  position: relative;
  z-index: 2;
}

/* === DARK MODE (sepia notebook by lamp) === */
body.dark { background: #1a1612; color: #e8dec5; }
body.dark .paper { background: #1a1612; }
body.dark .notebook-page {
  background: #221c14;
  background-image:
    linear-gradient(rgba(220, 200, 150, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(220, 200, 150, 0.04) 1px, transparent 1px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
body.dark .notebook-page::before { background: linear-gradient(180deg, transparent 0%, rgba(255,120,140,0.5) 8%, rgba(255,120,140,0.5) 92%, transparent 100%); }
body.dark .notebook-page::after { background-image: radial-gradient(circle, #14110d 30%, transparent 32%); }
body.dark {
  --paper: #221c14;
  --paper-warm: #1e1810;
  --paper-cream: #2a2218;
  --ink: #e8dec5;
  --ink-soft: #c8bca0;
  --ink-faded: #908774;
  --grid: rgba(220, 200, 150, 0.06);
  --grid-strong: rgba(220, 200, 150, 0.12);
  --red-pen: #ff8a9a;
  --red-pen-soft: #ff95a3;
  --blue-pen: #9ec1f5;
  --blue-pen-soft: #b8d0ff;
  --pencil: #a89c80;
  --highlight-yellow: rgba(255, 220, 90, 0.22);
  --highlight-yellow-deep: rgba(255, 220, 90, 0.36);
  --tape: rgba(180, 160, 100, 0.18);
}
body.dark .body-text, body.dark .body-text p { color: var(--ink); }
body.dark .section-title { color: var(--ink); }
body.dark .handwritten { color: var(--ink); }
body.dark .code-block { background: #0f0d0a !important; border-color: rgba(220,200,150,0.15) !important; }
body.dark .code-block * { color: #e8dec5 !important; }
body.dark .polaroid { background: #2f2820; box-shadow: 0 6px 16px rgba(0,0,0,0.5); }
body.dark .ink-strike { color: var(--ink-faded); }
body.dark .figure { background: #2a2218; border-color: rgba(220, 200, 150, 0.18); }
body.dark .figure img { filter: brightness(0.92); }
body.dark .sketch path, body.dark .sketch rect, body.dark .sketch line, body.dark .sketch circle { stroke: var(--ink) !important; }
body.dark .sketch path[stroke="#c8324a"], body.dark .sketch [stroke="#c8324a"] { stroke: var(--red-pen) !important; }
body.dark .sketch [fill="#c8324a"] { fill: var(--red-pen) !important; }
body.dark .sketch text { fill: var(--ink) !important; }
body.dark .signature-svg path { stroke: var(--ink) !important; }
body.dark .margin-note { color: var(--red-pen); }
body.dark .figure-label { color: var(--ink-soft); }

/* Theme toggle button */
.theme-toggle {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 100;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.2s ease;
  font-family: inherit;
}
.theme-toggle:hover { transform: scale(1.08) rotate(15deg); }

/* === PRINT STYLES === */
@media print {
  @page { margin: 0.5in; size: A4; }
  body { background: #fff !important; }
  body.dark { background: #fff !important; }
  body.dark { --paper: #fff; --ink: #1a1a2e; --paper-cream: #f5efe0; }
  .notebook { max-width: 100% !important; }
  .notebook-page { padding: 24px !important; box-shadow: none !important; margin: 0 !important; }
  .notebook-page::after, .ribbon, .theme-toggle, .konami-overlay { display: none !important; }
  .reveal { opacity: 1 !important; transform: none !important; }
  .sketch *, .signature-svg path { stroke-dashoffset: 0 !important; animation: none !important; }
  .page-flip { page-break-after: always; }
  .figure, .polaroid, .code-block { page-break-inside: avoid; }
  .body-text { font-size: 11pt; }
  .section-title { font-size: 20pt; }
  a { color: #2a4d8f !important; text-decoration: underline !important; }
}

@media (max-width: 768px) {
  .notebook-page { padding: 50px 24px 60px 50px; }
  .notebook-page::before { left: 38px; }
  .notebook-page::after { left: 12px; }
  .section-title { font-size: 28px; }
  .body-text { font-size: 15px; }
  .margin-note { display: none; }
  .cover-page { padding: 60px 30px; }
  .cover-stamp { top: 30px; right: 30px; padding: 8px 14px; font-size: 11px; }
  .cover-page h1 { font-size: clamp(36px, 9vw, 56px) !important; }
  .ribbon { right: 30px !important; width: 24px !important; height: 100px !important; }
  /* stack columns on mobile */
  section [style*="grid-template-columns: 1.4fr 1fr"],
  section [style*="grid-template-columns: 1.2fr 1fr"],
  section [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* polaroid on cover doesn't overlap text */
  .cover-page > div[style*="position: absolute"][style*="right: 80px"] {
    display: none;
  }
  .doodle-arrow { display: none; }
}

@media (max-width: 480px) {
  .notebook-page { padding: 40px 18px 50px 42px; }
  .notebook-page::before { left: 30px; }
  .section-title { font-size: 24px; }
  .handwritten[style*="font-size: 56px"] { font-size: 36px !important; }
  .cta-btn { font-size: 12px !important; padding: 8px 14px !important; }
}
