/* Fonts (self-hosted, latin subset) */
@font-face {
  font-family: "Cabin Sketch";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/cabin-sketch-400.woff2") format("woff2");
}
@font-face {
  font-family: "Cabin Sketch";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/cabin-sketch-700.woff2") format("woff2");
}
@font-face {
  font-family: "Neucha";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/neucha-400.woff2") format("woff2");
}

/*
  Tokens. Only the line quality is hand-drawn; the grid is exact.
  Spacing scale: 8, 16, 24, 32, 48, 64. One gutter, one inset.
*/
:root {
  --paper: #fdfdfb;
  --ink: #141414;
  --spot: #c4006f;          /* interaction only: hover, focus, active, selection */
  --spot-text: #ffffff;

  --gutter: 16px;
  --inset: 16px;
  --rule: 2px;
  --frame: 3px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
  --space-6: 64px;

  /* Sketchy's own wobbly radius pattern, one weight everywhere */
  --wobble: 255px 15px 225px 15px / 15px 225px 15px 255px;

  --letter: "Cabin Sketch", "Bradley Hand", cursive;
  --hand: "Neucha", "Comic Sans MS", cursive;

  /* Bootstrap / Sketchy overrides */
  --bs-body-bg: var(--paper);
  --bs-body-color: var(--ink);
  --bs-body-font-family: var(--hand);
  --bs-body-font-size: 1.25rem;
  --bs-body-font-weight: 400;
  --bs-body-line-height: 1.45;
  --bs-heading-color: var(--ink);
  --bs-link-color: var(--ink);
  --bs-link-color-rgb: 20, 20, 20;
  --bs-link-hover-color: var(--spot);
  --bs-link-hover-color-rgb: 196, 0, 111;
  --bs-border-color: var(--ink);
  --bs-emphasis-color: var(--ink);
}

/* Screentone: the only fills. Two densities, 45 degree dot grid. */
.tone-fine {
  background-color: var(--paper);
  background-image:
    radial-gradient(circle, var(--ink) 0.8px, transparent 1.15px),
    radial-gradient(circle, var(--ink) 0.8px, transparent 1.15px);
  background-size: 6px 6px;
  background-position: 0 0, 3px 3px;
}
.tone-coarse {
  background-color: var(--paper);
  background-image:
    radial-gradient(circle, var(--ink) 1.7px, transparent 2.1px),
    radial-gradient(circle, var(--ink) 1.7px, transparent 2.1px);
  background-size: 10px 10px;
  background-position: 0 0, 5px 5px;
}

/* Base */
html {
  scroll-behavior: auto;
  scrollbar-color: var(--ink) var(--paper);
  caret-color: var(--spot);
  -webkit-text-size-adjust: 100%;
}
/* Custom cursor: the mascot pointer. Hotspot (3, 0) is the tip of the blue triangle at 1x.
   The image-set line comes second so browsers without it keep the 1x line. Links and
   buttons use it too (Bootstrap's native hand is overridden); hover and focus states
   carry the link affordance. */
html,
a,
.btn,
button,
[role="button"] {
  cursor: url("../img/cursor.png") 3 0, auto;
  cursor: image-set(url("../img/cursor.png") 1x, url("../img/cursor@2x.png") 2x) 3 0, auto;
}
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--hand);
  font-weight: 400;
  min-width: 320px;
  overflow-wrap: break-word;
}
::selection {
  background: var(--spot);
  color: var(--spot-text);
}
a {
  color: var(--ink);
  text-decoration-thickness: var(--rule);
  text-underline-offset: 0.22em;
}
a:hover {
  color: var(--spot);
}
:focus-visible {
  outline: 3px solid var(--spot);
  outline-offset: 3px;
}
h1, h2, h3 {
  font-family: var(--letter);
  font-weight: 400;
  color: var(--ink);
  text-wrap: balance;
}
p {
  margin: 0;
}
img {
  display: block;
}
[id] {
  scroll-margin-top: var(--space-2);
}
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: currentColor;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: var(--space-2);
  top: var(--space-1);
  z-index: 10;
  padding: var(--space-1) var(--space-2);
  background: var(--paper);
  border: var(--rule) solid var(--ink);
  border-radius: var(--wobble);
  transform: translateY(-300%);
}
.skip-link:focus {
  transform: none;
}

/* Page sheet and running head */
.sheet {
  max-width: calc(1200px + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.running-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) 0 var(--space-1);
  margin-bottom: var(--gutter);
  border-bottom: var(--rule) solid var(--ink);
  line-height: 1.2;
}
.running-head__home {
  font-family: var(--letter);
  font-size: 1.6rem;
  text-decoration: none;
  margin-right: auto;
}
.running-head__nav {
  display: flex;
  gap: var(--space-3);
  font-size: 1.1rem;
}
.running-head__nav a {
  text-decoration-line: underline;
}
.running-head__page {
  font-family: var(--letter);
  font-size: 1.1rem;
  min-width: 3ch;
  text-align: right;
}

/* Panels */
.page + .page {
  margin-top: var(--space-5);
}
.panel {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  background-color: var(--paper);
  border: var(--frame) solid var(--ink);
  border-radius: var(--wobble);
}
.project:hover,
.project:focus-within {
  border-color: var(--spot);
}

/* Narration box: the rectangular caption, no wobble */
.narration {
  background: var(--paper);
  border: var(--rule) solid var(--ink);
  padding: var(--space-2);
  min-width: 0;
}
.narration > * + * {
  margin-top: var(--space-1);
}
.narration p {
  text-wrap: pretty;
}

/* Bubbles */
.bubble {
  position: relative;
  display: block;
  margin: 0;
  padding: 12px 20px;
  background: var(--paper);
  border: var(--rule) solid var(--ink);
  border-radius: var(--wobble);
  font-size: 1.6rem;
  line-height: 1.2;
  transform-origin: 28px 100%;
}
.bubble__tail {
  position: absolute;
  left: 20px;
  top: 100%;
  width: 44px;
  height: 38px;
  overflow: visible;
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: var(--rule);
  stroke-linejoin: round;
  stroke-linecap: butt;
}
.tail__cover {
  stroke: var(--paper);
  stroke-width: 4px;
}
.bubble__body {
  display: grid;
}
.bubble__body > * {
  grid-area: 1 / 1;
}
.bubble__sizer {
  visibility: hidden;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: none; }
}
.is-pop,
.bubble--hero {
  animation: pop 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
@media (prefers-reduced-motion: reduce) {
  .is-pop,
  .bubble--hero {
    animation: none;
  }
}

/* Buttons: Sketchy's .btn, restyled to ink on paper, spot on interaction */
.btn-ink {
  --bs-btn-color: var(--ink);
  --bs-btn-bg: var(--paper);
  --bs-btn-border-color: var(--ink);
  --bs-btn-border-width: var(--rule);
  --bs-btn-hover-color: var(--spot-text);
  --bs-btn-hover-bg: var(--spot);
  --bs-btn-hover-border-color: var(--spot);
  --bs-btn-active-color: var(--spot-text);
  --bs-btn-active-bg: var(--spot);
  --bs-btn-active-border-color: var(--spot);
  --bs-btn-active-shadow: none;
  --bs-btn-padding-x: 1.1rem;
  --bs-btn-padding-y: 0.4rem;
  --bs-btn-font-size: 1.2rem;
  --bs-btn-line-height: 1.3;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  transition: none;
}
.btn-ink:focus-visible {
  outline: 3px solid var(--spot);
  outline-offset: 3px;
  box-shadow: none;
  color: var(--spot-text);
}

/* Page 1 */
.hero {
  display: grid;
  gap: var(--gutter);
}
.hero__main {
  display: flex;
  flex-direction: column;
  overflow: visible;
  border-color: transparent;
}
/* Frame drawn above the contents, so the wobbly edge is never covered */
.hero__main::after {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--frame));
  z-index: 1;
  border: var(--frame) solid var(--ink);
  border-radius: var(--wobble);
  pointer-events: none;
}
.hero__title {
  margin: 0;
  padding: var(--space-2) var(--inset) var(--space-1);
  border-bottom: var(--rule) solid var(--ink);
  font-family: var(--letter);
  font-weight: 700;
  font-size: clamp(3.5rem, 15vw, 6rem);
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
}
.hero__scene {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 44px;
  padding: var(--space-4) var(--inset);
  /* Focus lines, centred on the mascot (the bubble above it shifts it down) */
  --lines: 820px;
  background: var(--paper) url("../img/speedlines.svg") 50% calc(50% + 56px) / var(--lines) var(--lines) no-repeat;
  border-radius: 0 0 225px 15px / 0 0 15px 255px;
}
.hero__stage {
  line-height: 0;
}
/* The one element that breaks its frame */
.bubble--hero {
  position: relative;
  z-index: 2;
  align-self: flex-end;
  margin-right: -12px;
  font-size: 2rem;
}
.hero__mascot {
  position: relative;
  width: 240px;
  max-width: 100%;
  height: auto;
}
.beats {
  display: grid;
  gap: var(--gutter);
  margin: 0;
  padding: 0;
}
.beat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--inset);
  container-type: inline-size;
}
.beat .narration {
  flex: 0 1 auto;
  max-width: 100%;
}
/* SFX lettering: always fully inside its own cell, clear of caption and frame */
.beat__sfx {
  align-self: flex-end;
  margin: auto var(--space-1) var(--space-1) 0;
  font-family: var(--letter);
  font-weight: 700;
  font-size: var(--sfx-size);
  line-height: 0.8;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: rotate(var(--sfx-tilt));
  pointer-events: none;
  user-select: none;
}
.beat--dev   { --sfx-size: 13cqw; --sfx-tilt: -4deg; }
.beat--gamer { --sfx-size: min(6rem, 30cqw); --sfx-tilt: 5deg; }
.beat--friend { --sfx-size: min(4.5rem, 24cqw); --sfx-tilt: -5deg; }
/* "Nya~" is lettered in mixed case */
.beat--friend .beat__sfx {
  text-transform: none;
}
@supports (paint-order: stroke fill) {
  .beat__sfx,
  .sfx {
    -webkit-text-stroke: 8px var(--paper);
    paint-order: stroke fill;
  }
}
.beat__label {
  font-family: var(--letter);
  font-size: 2rem;
  line-height: 1;
}

/* Page 2 */
.title-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  column-gap: var(--space-4);
  row-gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-2);
  margin-bottom: var(--gutter);
  overflow: visible;
}
.title-panel h2 {
  flex: 1 0 100%;
  margin: 0;
  font-size: clamp(2.25rem, 8vw, 3.5rem);
  line-height: 1;
}
.sfx {
  position: relative;
  margin-left: auto;
  font-family: var(--letter);
  font-weight: 700;
  font-size: clamp(1.9rem, 8.4vw, 4rem);
  line-height: 0.9;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: rotate(-7deg);
  transform-origin: 0 100%;
  translate: 0 14px;
}
/* The mumbled afterthought trailing the shout */
.sfx__aside {
  margin-left: 0.3em;
  font-size: max(0.5em, 1.25rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
}

.spread {
  display: grid;
  gap: var(--gutter);
}
.oru {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-bottom: var(--space-1);
}
.oru .bubble {
  width: 100%;
  font-size: 1.25rem;
  margin-bottom: 44px;
}
.oru__img {
  width: 140px;
  height: auto;
  margin-left: var(--space-2);
  transform: scaleX(-1);
}

.projects {
  display: grid;
  gap: var(--gutter);
  min-width: 0;
}
.project {
  display: grid;
  gap: var(--inset);
  padding: var(--inset);
  align-content: start;
}
.project__art img {
  width: 100%;
  max-width: 304px;
  height: auto;
  border: var(--rule) solid var(--ink);
  background: var(--paper);
}
.project__name {
  margin: 0;
  font-size: 2.25rem;
  line-height: 1;
}
.project .narration p {
  max-width: 34ch;
}
.project .btn {
  margin-top: var(--space-2);
}
.project .narration {
  align-self: end;
}
.project--strip .project__art {
  position: relative;
  width: 100%;
  max-width: 232px;
  min-height: 180px;
  justify-self: center;
}
/* Native-size crop: the wordmark fills the cell */
.project--strip .project__art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: none;
  object-position: -6px -84px;
}
.project--tall {
  grid-template-rows: auto 1fr;
}

/* Page 3: To be continued. The peeker rises from the panel's bottom edge; the panel clips her. */
.end {
  container-type: inline-size;
}
.end__tbc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--space-2);
  row-gap: var(--space-2);
  padding: var(--space-3);
}
.end__lettering {
  grid-column: 1 / -1;
  grid-row: 1;
  font-family: var(--letter);
  font-weight: 700;
  font-size: clamp(2.5rem, 12vw, 5.5rem);
  overflow-wrap: normal;
  line-height: 0.95;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.end__arrow {
  grid-column: 1;
  grid-row: 2;
  align-self: end;
  justify-self: start;
  width: min(210px, 100%);
  aspect-ratio: 3 / 1;
  height: auto;
  fill: var(--ink);
}
.end__peeker {
  grid-column: 2;
  grid-row: 2;
  align-self: end;
  width: min(45cqw, 260px);
  height: auto;
  /* cancel the panel padding so her cut edge sits on the frame's inner bottom edge */
  margin-bottom: calc(-1 * var(--space-3));
  user-select: none;
  pointer-events: none;
}

/* Footer */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  margin-top: var(--space-5);
  padding: var(--space-2) 0 var(--space-4);
  border-top: var(--rule) solid var(--ink);
  font-size: 1.1rem;
}

/* Wider than a phone */
@media (min-width: 576px) {
  .project--wide,
  .project--strip {
    grid-template-columns: 304px 1fr;
  }
  .project--strip {
    grid-template-columns: 1fr 232px;
  }
  .project--strip .project__art {
    order: 2;
    min-height: 190px;
  }
  .beat {
    flex-direction: row;
    justify-content: space-between;
    column-gap: var(--space-4);
    min-height: 170px;
  }
  .beat .narration {
    flex: 1 1 auto;
  }
  .beat__sfx {
    margin: 0 var(--space-1) var(--space-1) 0;
  }
  .beat--dev   { --sfx-size: 6.6cqw; }
  .beat--gamer { --sfx-size: 16cqw; }
  .beat--friend { --sfx-size: 11cqw; }
  .hero__scene {
    --lines: 1000px;
  }
  .end__lettering {
    font-size: 4rem;
    white-space: nowrap;
  }
  .end__peeker {
    width: 260px;
  }
  .end__lettering br {
    display: none;
  }
}

/* Desktop manga layout */
@media (min-width: 992px) {
  .hero {
    grid-template-columns: 3fr 2fr;
    min-height: clamp(560px, calc(100svh - 120px), 720px);
  }
  .beats {
    grid-template-rows: 2fr 1.4fr 1.6fr;
  }
  .beat {
    min-height: 0;
    flex-direction: column;
    justify-content: flex-start;
  }
  .beat .narration {
    flex: 0 1 auto;
  }
  .beat__sfx {
    margin: auto var(--space-1) var(--space-1) 0;
  }
  .beat--dev   { --sfx-size: 14cqw; }
  .beat--friend { --sfx-size: 13cqw; }
  .beat--gamer {
    flex-direction: row;
    justify-content: space-between;
    --sfx-size: 26cqw;
  }
  .bubble--hero {
    margin-right: -30px;
  }
  .spread {
    grid-template-columns: 224px 1fr;
    align-items: start;
  }
  .oru {
    position: sticky;
    top: var(--gutter);
    padding-bottom: 0;
  }
  .projects {
    grid-template-columns: 342px 1fr;
  }
  .project--tall {
    grid-row: span 2;
  }
  .end__lettering {
    grid-column: 1;
  }
  .end__peeker {
    grid-row: 1 / span 2;
  }
}

/* Between phone and desktop: single column spread, panels stay horizontal */
@media (min-width: 576px) and (max-width: 991.98px) {
  .title-panel {
    row-gap: var(--space-5);
  }
  .sfx {
    font-size: 2.75rem;
  }
  .project--tall {
    grid-template-columns: 304px 1fr;
    grid-template-rows: none;
  }
  .oru {
    flex-direction: row;
    align-items: flex-end;
    gap: var(--space-3);
  }
  .oru .bubble {
    order: 2;
    width: min(100%, 22rem);
  }
}

@media (max-width: 575.98px) {
  .running-head {
    gap: var(--space-2);
    flex-wrap: wrap;
  }
  .running-head__page {
    display: none;
  }
  .running-head__nav {
    gap: var(--space-2);
  }
  .oru .bubble {
    width: 100%;
  }
  .sfx {
    font-size: clamp(1.4rem, 6.4vw, 2rem);
    white-space: normal;
    text-align: right;
  }
  .sfx__aside {
    display: block;
    margin: 0;
    font-size: max(0.6em, 1.1rem);
  }
  .project__art img {
    margin-inline: auto;
  }
}

/* 404 */
.lost {
  max-width: 720px;
  margin: 0 auto;
}
.lost__back {
  padding: var(--inset);
  border-top: var(--rule) solid var(--ink);
}
.lost__back .narration {
  display: flex;
  justify-content: center;
}
