@font-face {
  font-family: "NotebookHand";
  src: url("/NotebookHand-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  /* Real warm unbleached notepad paper & royal blue ballpoint ink */
  --desk-bg: #dcd5c7;
  --paper-base: #f5f0e2;
  --paper-edge: #ebe3cf;
  --paper-back: #efe9d8;
  --rule-blue: rgba(114, 148, 186, 0.26);
  --margin-red: rgba(208, 114, 114, 0.34);

  --ink-blue: #1b399e;
  --ink-blue-deep: #142c80;
  --ink-blue-muted: rgba(27, 57, 158, 0.72);
  --ink-black: #161619;

  --line-h: 42px;
  --pad-max-w: 940px;
  --pad-h: min(640px, calc(100dvh - 88px));
  --paper-grain: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background-color: var(--desk-bg);
  background-image:
    radial-gradient(circle at 50% 28%, rgba(255, 252, 244, 0.55), transparent 70%),
    radial-gradient(circle at 50% 100%, rgba(92, 79, 60, 0.18), transparent 65%);
  color: var(--ink-blue);
  font-family: "NotebookHand", "Segoe Print", cursive, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

.desk {
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 16px 24px;
}

.notepad-shell {
  width: 100%;
  max-width: var(--pad-max-w);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  filter: drop-shadow(0 20px 36px rgba(45, 37, 24, 0.22))
          drop-shadow(0 4px 10px rgba(45, 37, 24, 0.12));
}

/* Dark walnut notepad binding with a fine horizontal grain */
.pad-binding {
  position: relative;
  z-index: 30;
  flex: none;
  background-color: #4e2d1d;
  background-image:
    repeating-linear-gradient(1deg, transparent 0 3px, rgb(250 209 167 / 6%) 4px, transparent 6px 10px, rgb(43 19 9 / 20%) 12px, transparent 14px 18px),
    linear-gradient(180deg, #603d29 0%, #4e2d1d 58%, #3d2419 100%);
  color: #f5e4d1;
  border-radius: 9px 9px 0 0;
  padding: 10px 18px 8px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.28);
  user-select: none;
}

.binding-stitch {
  border-top: 1.5px dashed rgb(245 228 209 / 30%);
  margin-bottom: 7px;
}

.binding-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pad-brand {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: #e3c2a7;
}

.pad-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pad-tab {
  appearance: none;
  border: 1px solid rgb(245 228 209 / 24%);
  background: rgb(255 235 209 / 7%);
  color: #f5e4d1;
  font: 400 0.875rem / 1.2 system-ui, "Segoe UI", Arial, sans-serif;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.pad-tab-number {
  font-size: 0.84em;
  font-variant-numeric: tabular-nums;
}

.pad-tab:hover,
.pad-tab:focus-visible {
  background: rgba(255, 250, 240, 0.14);
  color: #fffaf0;
}

.pad-tab:focus-visible {
  outline: 2px solid #fffaf0;
  outline-offset: 2px;
}

.pad-tab.is-active {
  background: var(--paper-base);
  color: var(--ink-blue);
  border-color: var(--paper-base);
}

.perforation {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 3px;
  background-image: radial-gradient(circle, rgba(40, 34, 26, 0.42) 1px, transparent 1.2px);
  background-size: 8px 3px;
}

/* 3D Vertical Flip Stage */
.pad-stage {
  position: relative;
  width: 100%;
  height: var(--pad-h);
  min-height: 0;
  perspective: 2100px;
  perspective-origin: 50% 8%;
}

.sheet {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: 50% 0%;
  transform: rotateX(0deg);
  opacity: 1;
  pointer-events: none;
  will-change: transform, opacity;
  transition:
    transform 0.68s cubic-bezier(0.24, 0.86, 0.32, 1) var(--flip-delay, 0ms),
    opacity 0.12s ease var(--flip-delay, 0ms);
}

.sheet.is-current {
  pointer-events: auto;
}

/* Flipped vertically UP over the top binding */
.sheet.is-flipped {
  transform: rotateX(178deg);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.66s cubic-bezier(0.36, 0.04, 0.22, 1) var(--flip-delay, 0ms),
    opacity 0.2s ease calc(var(--flip-delay, 0ms) + 450ms);
}

.sheet-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 0 0 5px 5px;
  overflow: hidden;
}

/* Front of real paper sheet: base ivory + randomized canvas fiber grain + ruled lines + margin rule */
.sheet-front {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: var(--paper-base);
  background-image:
    var(--sheet-grain, var(--paper-grain)),
    linear-gradient(90deg, transparent 42px, var(--margin-red) 42px, var(--margin-red) 43.5px, transparent 43.5px),
    repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent calc(var(--line-h) - 1.5px),
      var(--rule-blue) calc(var(--line-h) - 1.5px),
      var(--rule-blue) var(--line-h)
    ),
    radial-gradient(ellipse at 50% 45%, rgba(255, 253, 246, 0.4), rgba(226, 216, 193, 0.38) 100%);
  background-position:
    var(--grain-pos, 0 0),
    0 0,
    0 18px,
    0 0;
  box-shadow:
    inset 0 5px 10px -5px rgba(32, 26, 18, 0.25),
    inset 0 0 0 1px rgba(175, 162, 136, 0.38),
    0 6px 18px rgba(38, 30, 18, 0.12);
}

/* Backside of flipping sheet */
.sheet-back {
  transform: rotateX(180deg);
  background-color: var(--paper-back);
  background-image:
    var(--sheet-grain, var(--paper-grain)),
    repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent calc(var(--line-h) - 1px),
      rgba(114, 148, 186, 0.12) calc(var(--line-h) - 1px),
      rgba(114, 148, 186, 0.12) var(--line-h)
    ),
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.15) 45%, rgba(0, 0, 0, 0.05));
  box-shadow: inset 0 0 0 1px rgba(175, 162, 136, 0.4);
}

/* Stacked pages edge thickness below the pad */
.pad-stack-edges {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: -8px;
  height: 9px;
  z-index: 0;
  border-radius: 0 0 5px 5px;
  background:
    repeating-linear-gradient(
      to bottom,
      #efe8d6 0px,
      #efe8d6 2px,
      #cfc5ae 2px,
      #cfc5ae 3px
    );
  box-shadow: 0 3px 6px rgba(35, 28, 18, 0.18);
  pointer-events: none;
}

/* ==================== LAYOUT & INK TYPOGRAPHY ==================== */
.sheet-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 26px 28px 10px 60px;
  gap: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  mix-blend-mode: multiply;
}

.sheet-single {
  flex: 1;
  padding: 28px 34px 12px 60px;
  overflow-y: auto;
  overflow-x: hidden;
  mix-blend-mode: multiply;
}

.writing-area {
  position: relative;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 8px;
}

.ink-line {
  margin: 0;
  font-size: clamp(1.38rem, 2.2vw, 1.78rem);
  line-height: var(--line-h);
  color: var(--ink-blue);
  letter-spacing: 0.01em;
}

.hero-greeting {
  font-weight: 400;
  font-size: clamp(1.58rem, 2.75vw, 2.15rem);
  line-height: var(--line-h);
  margin-bottom: var(--line-h);
  position: relative;
}

.bio-line {
  margin-bottom: var(--line-h);
}

.actions-block {
  margin-bottom: var(--line-h);
}

/* Name underlined in black ink */
.name-wrap {
  position: relative;
  display: inline-block;
  white-space: nowrap;
}

.black-underline {
  position: absolute;
  left: -3px;
  right: -5px;
  bottom: -4px;
  width: calc(100% + 8px);
  height: 15px;
  pointer-events: none;
  overflow: visible;
}

.underline-stroke-main {
  fill: none;
  stroke: var(--ink-black);
  stroke-width: 2.35;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

.underline-stroke-echo {
  fill: none;
  stroke: var(--ink-black);
  stroke-width: 1.15;
  stroke-linecap: round;
  opacity: 0.72;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

/* Fast handwriting character reveal states */
.js-writing .write-char {
  display: inline-block;
  opacity: 0;
  clip-path: inset(-35% 100% -40% -8%);
  transform: translateY(1px);
  transition:
    clip-path 0.065s linear,
    opacity 0.045s ease-out,
    transform 0.065s ease-out;
}

.js-writing .write-char.is-written {
  opacity: 1;
  clip-path: inset(-35% -12% -40% -8%);
  transform: translateY(0);
}

.js-writing .write-word {
  display: inline-block;
  white-space: nowrap;
}

.js-writing .write-space {
  display: inline;
  white-space: normal;
}

.js-writing .underline-stroke-main,
.js-writing .underline-stroke-echo {
  stroke-dashoffset: 1;
}

.js-writing.underline-drawn .underline-stroke-main {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s cubic-bezier(0.22, 0.78, 0.26, 1);
}

.js-writing.underline-drawn .underline-stroke-echo {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.22s cubic-bezier(0.22, 0.78, 0.26, 1) 0.09s;
}

/* Moving pen nib during opening line write */
.pen-nib {
  position: fixed;
  top: 0;
  left: 0;
  width: 34px;
  height: 34px;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transform: translate(-999px, -999px);
  transition: opacity 0.14s ease;
  filter: drop-shadow(2px 4px 3px rgba(20, 18, 15, 0.22));
}

.pen-nib.is-active {
  opacity: 0.95;
}

/* Links in royal blue ballpoint ink */
.ink-link {
  color: var(--ink-blue-deep);
  text-decoration: none;
  position: relative;
  display: inline-block;
  border-bottom: 1.6px dashed rgba(27, 57, 158, 0.48);
  line-height: 1.15;
  padding: 0 2px;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.ink-link:hover,
.ink-link:focus-visible {
  color: #0e226b;
  border-bottom-style: solid;
  border-bottom-color: var(--ink-blue);
  transform: translateY(-1px);
}

/* ==================== DOODLES (BOTH DESKTOP & MOBILE) ==================== */
.ink-svg {
  color: var(--ink-blue);
  filter: url(#ballpoint-rough);
}

.doodle-sky {
  align-self: flex-end;
  width: clamp(132px, 22vw, 178px);
  margin: -10px 4px 2px auto;
  opacity: 0.88;
}

.doodle-sky svg {
  width: 100%;
  height: auto;
  display: block;
}

.doodle-bday {
  margin-top: auto;
  padding-top: 8px;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: clamp(1.28rem, 2vw, 1.6rem);
  line-height: var(--line-h);
  color: var(--ink-blue);
}

.cake-doodle {
  width: 38px;
  height: 36px;
  flex-shrink: 0;
  transform: translateY(-2px) rotate(-3deg);
}

.age-scratched {
  position: relative;
  display: inline-block;
  padding: 0 5px;
  margin-right: 4px;
  color: var(--ink-blue-muted);
}

.scratch-svg {
  position: absolute;
  left: -3px;
  top: 14%;
  width: calc(100% + 6px);
  height: 72%;
  pointer-events: none;
  color: var(--ink-blue);
}

.age-replacement {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  margin-left: 2px;
  transform: translateY(-4px) rotate(-4deg);
  color: var(--ink-blue-deep);
}

.caret-svg {
  width: 14px;
  height: 11px;
  transform: translateY(4px);
}

.age-nineteen {
  font-size: 1.12em;
}

/* ==================== DESKTOP-ONLY MARGIN SECTION ==================== */
.desktop-only {
  display: none;
}

@media (min-width: 860px) {
  .sheet-grid {
    grid-template-columns: minmax(0, 1fr) 235px;
    gap: 26px;
    padding-right: 22px;
  }

  .desktop-only {
    display: flex;
  }

  .margin-column {
    border-left: 1.5px solid rgba(208, 114, 114, 0.32);
    padding-left: 18px;
    padding-top: 6px;
    flex-direction: column;
    justify-content: space-between;
    color: var(--ink-blue-muted);
    font-size: 1.18rem;
    line-height: 1.32;
    user-select: none;
  }

  .margin-note {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  .tilt-left {
    transform: rotate(-3.2deg);
  }

  .tilt-right {
    transform: rotate(2.4deg);
    padding-left: 10px;
  }

  .tilt-left-soft {
    transform: rotate(-1.8deg);
  }

  .margin-arrow {
    width: 38px;
    height: 20px;
    margin-left: -14px;
    margin-bottom: -2px;
  }

  .margin-doodles {
    display: flex;
    align-items: center;
    gap: 16px;
  }

  .margin-doodles svg {
    height: auto;
    opacity: 0.86;
  }

  .rocket-doodle {
    width: 78px;
    transform: rotate(-7deg);
  }

  .tic-tac-toe-doodle {
    width: 70px;
    transform: translateY(8px) rotate(6deg);
  }
}

/* ==================== INNER PAGES & FOOTER ==================== */
.page-top-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: calc(var(--line-h) * 0.5);
}

.ink-heading {
  margin: 0;
  font-weight: 400;
  font-size: clamp(1.65rem, 2.7vw, 2.15rem);
  line-height: var(--line-h);
  color: var(--ink-blue-deep);
}

.ink-back {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 1.4px dashed rgba(27, 57, 158, 0.45);
  font-family: inherit;
  font-size: 1.18rem;
  color: var(--ink-blue);
  cursor: pointer;
  padding: 0 2px;
}

.ink-back:hover {
  border-bottom-style: solid;
}

.notebook-list {
  margin-top: calc(var(--line-h) * 0.5);
  display: flex;
  flex-direction: column;
  gap: calc(var(--line-h) * 0.5);
}

.note-entry {
  display: flex;
  flex-direction: column;
}

.note-date {
  font-size: 1.12rem;
  line-height: calc(var(--line-h) * 0.75);
  color: var(--ink-blue-muted);
}

.inline-doodle-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: calc(var(--line-h) * 0.5);
  flex-wrap: wrap;
}

.mini-doodle {
  width: 82px;
  height: 44px;
  flex-shrink: 0;
}

.sheet-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 22px 10px 60px;
  color: var(--ink-blue-muted);
  font-size: 1.08rem;
  mix-blend-mode: multiply;
}

.flip-hint {
  appearance: none;
  background: none;
  border: none;
  color: var(--ink-blue);
  font-family: inherit;
  font-size: 1.12rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: transform 0.16s ease, background 0.16s ease;
}

.flip-hint:hover,
.flip-hint:focus-visible {
  background: rgba(27, 57, 158, 0.07);
  transform: translateY(1px);
}

.ink-link:focus-visible,
.ink-back:focus-visible,
.flip-hint:focus-visible {
  outline: 2px solid var(--ink-blue);
  outline-offset: 2px;
}

.flip-hint svg {
  width: 18px;
  height: 18px;
}

/* ==================== MOBILE REFINEMENTS ==================== */
@media (max-width: 640px) {
  :root {
    --line-h: 34px;
    --pad-h: calc(100dvh - 82px);
  }

  .desk {
    padding: 8px 8px 14px;
  }

  .pad-binding {
    padding: 8px 10px 6px;
  }

  .pad-brand {
    display: none;
  }

  .pad-tabs {
    gap: 4px;
  }

  .pad-tab {
    min-height: 30px;
    font-size: 0.75rem;
    padding-inline: 4px;
  }

  .sheet-front {
    background-image:
      var(--sheet-grain, var(--paper-grain)),
      linear-gradient(90deg, transparent 28px, var(--margin-red) 28px, var(--margin-red) 29.5px, transparent 29.5px),
      repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent calc(var(--line-h) - 1.5px),
        var(--rule-blue) calc(var(--line-h) - 1.5px),
        var(--rule-blue) var(--line-h)
      ),
      radial-gradient(ellipse at 50% 45%, rgba(255, 253, 246, 0.4), rgba(226, 216, 193, 0.38) 100%);
  }

  .sheet-grid,
  .sheet-single {
    padding: 18px 18px 8px 40px;
  }

  .sheet-footer {
    padding: 4px 16px 8px 40px;
    font-size: 0.98rem;
  }

  .hero-greeting,
  .bio-line,
  .actions-block {
    margin-bottom: calc(var(--line-h) * 0.75);
  }

  .hero-greeting {
    font-size: 1.48rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet,
  .sheet.is-flipped {
    transition: opacity 0.15s ease;
    transform: none !important;
  }

  .pen-nib {
    display: none !important;
  }
}
