/*
  NekoLab
  Layout idea: a dot-grid lab notebook. The studio writes in ink and ballpoint
  blue with a yellow highlighter; each product is a door into its own colours.
  Titles are Bricolage Grotesque; the one handwritten note is Shantell Sans.
*/

:root {
  --paper: #f3f5fb;
  --dots: #d3d9e9;
  --card: #ffffff;
  --ink: #1b2040;
  --soft: #555c7e;
  --pen: #2f49e8;
  --marker: #ffe14a;
  --line: rgba(27, 32, 64, 0.16);
  --wash: none;

  --sun: #ffe14a;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --display-weight: 800;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --max: 1080px;

  color-scheme: light;
}

/* NekoLab after dark. The second block is the same palette for viewers that set the theme by attribute. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14172b;
    --dots: #272c4b;
    --card: #1c2040;
    --ink: #eef0fa;
    --soft: #a6accb;
    --pen: #9dadff;
    --marker: #6a5d14;
    --line: rgba(238, 240, 250, 0.18);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #14172b;
  --dots: #272c4b;
  --card: #1c2040;
  --ink: #eef0fa;
  --soft: #a6accb;
  --pen: #9dadff;
  --marker: #6a5d14;
  --line: rgba(238, 240, 250, 0.18);
  color-scheme: dark;
}

/*
  Product brands. A brand class swaps the same tokens the studio uses, so it
  works on a door (a card on the home page) and on <body> (the product's page).
*/
.brand-inkstead {
  --paper: #fff8ef;
  --dots: #f0e2cd;
  --card: #fffdf9;
  --ink: #062748;
  --soft: #2d455e;
  --pen: #6255c7;
  --marker: #ffd98f;
  --line: rgba(6, 39, 72, 0.14);
  --wash:
    radial-gradient(900px 480px at 78% -40px, rgba(255, 106, 27, 0.10), transparent 62%),
    radial-gradient(700px 430px at 96% 200px, rgba(142, 73, 216, 0.09), transparent 60%);
  --display: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --display-weight: 800;
  color-scheme: light;
}

.brand-michimachi {
  --paper: #0d1220;
  --dots: #1b2440;
  --card: #141b2c;
  --ink: #fff3dc;
  --soft: #aab3cd;
  --pen: #ffb547;
  --marker: #7a2947;
  --line: rgba(255, 243, 220, 0.16);
  --wash:
    radial-gradient(700px 420px at 88% -60px, rgba(255, 92, 138, 0.16), transparent 65%),
    radial-gradient(600px 400px at 0% 30%, rgba(255, 181, 71, 0.07), transparent 60%);
  --display: "Zen Maru Gothic", ui-rounded, system-ui, sans-serif;
  --display-weight: 900;
  color-scheme: dark;
}

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

/* Only holds the letters in "occasional cat energy". */
@font-face {
  font-family: "Shantell Sans";
  src: url("fonts/shantell-sans.woff2") format("woff2");
  font-weight: 300 800;
  font-display: swap;
}

@font-face {
  font-family: "Zen Maru Gothic";
  src: url("fonts/zen-maru-gothic-black.woff2") format("woff2");
  font-weight: 900;
  font-display: swap;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    var(--wash),
    radial-gradient(var(--dots) 1.1px, transparent 1.3px) 0 0 / 22px 22px,
    var(--paper);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; height: auto; }

a { color: inherit; }

h1, h2, h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: var(--display-weight);
  line-height: 1.05;
  text-wrap: balance;
}

h1 { font-size: clamp(40px, 6.4vw, 68px); letter-spacing: -0.02em; }
h2 { font-size: 28px; letter-spacing: -0.01em; }
h3 { font-size: 21px; line-height: 1.2; }

p { margin: 0; }

:focus-visible {
  outline: 3px solid var(--pen);
  outline-offset: 3px;
  border-radius: 6px;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.lede {
  max-width: 54ch;
  font-size: 19px;
  color: var(--soft);
}

/* Text links get a swipe of highlighter on hover. */
.link,
.prose a {
  text-decoration: none;
  background: linear-gradient(var(--marker), var(--marker)) no-repeat 0 88% / 0% 42%;
  transition: background-size 0.3s var(--ease);
}

.link,
.prose a {
  font-weight: 650;
  text-decoration: underline;
  text-decoration-color: var(--pen);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.link:hover,
.prose a:hover,
.door:hover .link {
  background-size: 100% 42%;
}

/* ---------- Shell: header ---------- */

.site-header { padding-bottom: 40px; }

.brand {
  display: inline-flex;
  align-items: flex-end;
  gap: 12px;
  text-decoration: none;
}

.brand-cat {
  width: 46px;
  transform: rotate(-4deg);
  filter: drop-shadow(0 3px 5px rgba(27, 32, 64, 0.2));
  transition: transform 0.4s var(--ease);
}

.brand:hover .brand-cat { transform: rotate(4deg) scale(1.06); }

/* The logo's own lettering, inked in the current page's colour. */
.wordmark {
  width: 132px;
  margin-bottom: 5px;
  fill: currentColor;
}

/* ---------- Pages ---------- */

.view {
  display: grid;
  gap: 72px;
}

.view[hidden] { display: none; }

.block {
  display: grid;
  gap: 22px;
}

.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

/* ---------- Home: hero ---------- */

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 32px 56px;
  padding-top: 16px;
}

.hero-copy {
  display: grid;
  gap: 22px;
}

.hero h1 { font-size: clamp(40px, 5.6vw, 64px); max-width: 11em; }

/* The cat sticker, stuck on a highlighter-yellow sun. */
.hero-cat {
  position: relative;
  width: min(320px, 72vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin-right: 24px;
}

.hero-cat::before {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  background: var(--sun);
}

.cat {
  position: relative;
  width: 78%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* --lean is set by scripts.js: the cat tilts a little toward the pointer. */
.cat img {
  width: 100%;
  transform: rotate(calc(-5deg + var(--lean, 0deg)));
  transform-origin: 50% 92%;
  filter: drop-shadow(0 12px 14px rgba(27, 32, 64, 0.22));
  transition: transform 0.7s var(--ease);
  animation: sticker-land 0.6s var(--ease) backwards;
}

@keyframes sticker-land {
  from { opacity: 0; transform: rotate(-17deg) scale(1.15); }
  60% { opacity: 1; transform: rotate(-2deg) scale(.97); }
}

.cat.is-booped img { animation: boop 0.45s var(--ease); }

@keyframes boop {
  30% { transform: rotate(-16deg) scale(1.08); }
  60% { transform: rotate(2deg) scale(.96); }
}

/* A note in ballpoint, pointing back at the cat. */
.note {
  position: absolute;
  top: -6%;
  left: 44%;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  width: max-content;
  color: var(--pen);
  font-family: "Shantell Sans", var(--body);
  font-weight: 500;
  font-size: 16px;
  font-variation-settings: "INFM" 60, "BNCE" 8;
  transform: rotate(-4deg);
  transform-origin: left;
  animation: note-in 0.4s ease 0.75s backwards;
}

.note svg {
  width: 30px;
  margin-top: 6px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The arrow is drawn after the sticker lands. */
.note path {
  stroke-dasharray: 1;
  animation: draw 0.5s ease 0.55s backwards;
}

@keyframes draw { from { stroke-dashoffset: 1; } }
@keyframes note-in { from { opacity: 0; } }

/* While you hover the cat, the handwriting "boils" like hand-drawn animation. */
.hero-cat:hover .note { animation: boil 0.5s steps(1) infinite; }

@keyframes boil {
  0%  { font-variation-settings: "INFM" 60, "BNCE" 8; }
  33% { font-variation-settings: "INFM" 85, "BNCE" -10; }
  66% { font-variation-settings: "INFM" 45, "BNCE" 16; }
}

/* ---------- Home: doors into each product ---------- */

.doors {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.door {
  display: grid;
  grid-template-rows: 1fr auto auto auto;
  justify-items: start;
  gap: 12px;
  min-height: 340px;
  padding: 28px;
  border: 2px solid var(--line);
  border-radius: 28px;
  color: var(--ink);
  background:
    var(--wash),
    radial-gradient(var(--dots) 1.1px, transparent 1.3px) 0 0 / 22px 22px,
    var(--paper);
  box-shadow: 0 22px 40px -24px rgba(27, 32, 64, 0.45);
  text-decoration: none;
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
}

.door:hover {
  transform: translateY(-5px) rotate(-0.6deg);
  box-shadow: 0 30px 48px -24px rgba(27, 32, 64, 0.5);
}

.door-michimachi:hover { transform: translateY(-5px) rotate(0.6deg); }

.door-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

.door-icon {
  width: 96px;
  transform: rotate(-5deg);
  transition: transform 0.4s var(--ease);
}

.door:hover .door-icon { transform: rotate(0deg) scale(1.05); }

.door h3 { font-size: 34px; }

.door p {
  max-width: 40ch;
  color: var(--soft);
}

.door .link { margin-top: 6px; }

.kana {
  font-size: 0.55em;
  white-space: nowrap;
  color: #ff5c8a;
}

/* The sign's own dark backing melts into whatever is behind it. */
.neon { mix-blend-mode: lighten; }

/* The Michimachi sign buzzes on like real neon: on hover, and when its page opens. */
.door:hover .neon,
.product-icon.neon {
  animation: neon-flicker 0.9s step-end;
}

@keyframes neon-flicker {
  0%   { filter: brightness(1); }
  6%   { filter: brightness(.5) saturate(.5); }
  10%  { filter: brightness(1.15) saturate(1.2); }
  16%  { filter: brightness(.55) saturate(.5); }
  22%  { filter: brightness(1.15) saturate(1.2); }
  34%  { filter: brightness(.8) saturate(.8); }
  40%  { filter: brightness(1.12) saturate(1.15); }
  100% { filter: brightness(1); }
}

/* Says where a project is, in plain words and the product's own accent colour. */
.status {
  color: var(--pen);
  font-size: 15px;
  font-weight: 700;
}

/* ---------- News ---------- */

.posts {
  margin: 0;
  padding: 0;
  list-style: none;
  border-bottom: 2px dashed var(--line);
}

.post {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: baseline;
  gap: 6px 20px;
  padding: 18px 4px;
  border-top: 2px dashed var(--line);
  text-decoration: none;
}

.post time {
  color: var(--soft);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.post-title {
  justify-self: start;
  font-family: var(--display);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.25;
  background: linear-gradient(var(--marker), var(--marker)) no-repeat 0 88% / 0% 42%;
  transition: background-size 0.3s var(--ease);
}

.post:hover .post-title { background-size: 100% 42%; }

.post-excerpt {
  grid-column: 2;
  max-width: 62ch;
  color: var(--soft);
}

.posts-full .post { padding-block: 24px; }

.page-head {
  display: grid;
  gap: 16px;
  padding-top: 16px;
}

/* ---------- Articles: news posts and the privacy policy ---------- */

.article {
  gap: 20px;
  max-width: 680px;
  padding-top: 16px;
}

.article h1 { font-size: clamp(34px, 5vw, 52px); }

.back { justify-self: start; }

.article-meta {
  color: var(--soft);
  font-size: 15px;
}

.prose {
  display: grid;
  gap: 16px;
  font-size: 18px;
  line-height: 1.7;
}

.prose h2 { margin-top: 20px; font-size: 24px; }
.prose h3 { margin-top: 6px; font-size: 19px; }

.prose ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 22px;
}

/* ---------- Product pages ---------- */

.product-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 32px 56px;
  padding-top: 16px;
}

.product-copy {
  display: grid;
  justify-items: start;
  gap: 18px;
}

.product-hero h1 { font-size: clamp(46px, 8vw, 84px); }

.product-icon {
  order: 1;
  width: clamp(120px, 22vw, 220px);
  margin-right: 24px;
  transform: rotate(-5deg);
}

.tagline {
  font-family: var(--display);
  font-weight: var(--display-weight);
  font-size: clamp(22px, 3vw, 28px);
  line-height: 1.2;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 24px;
  margin-top: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  padding: 13px 22px;
  border-radius: 999px;
  color: var(--paper);
  background: var(--ink);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.3s var(--ease);
}

.button:hover { transform: translateY(-2px) rotate(-1deg); }

/* The image carries its own soft shadow, so it overlaps its neighbours a little. */
.product-shot {
  width: min(100%, 1000px);
  margin-inline: auto;
  margin-block: -40px -72px;
}

.features {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 36px 32px;
}

.feature {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 10px;
}

.feature p { color: var(--soft); }

.feature-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 6px;
  border-radius: 50%;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, white);
}

.feature-icon svg {
  width: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The studio signing its work at the bottom of each product page. */
.made-by {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 28px;
  border-top: 2px dashed var(--line);
  color: var(--soft);
}

.made-by img {
  width: 44px;
  flex: none;
  transform: rotate(-4deg);
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.2));
}

/* Inkstead: the rainbow bar from its own site. */
.inkstead-bar {
  width: 54px;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff5a2f 0%, #ff842e 22%, #f7b733 43%, #5fc9b5 66%, #4fa7d6 82%, #6255c7 100%);
}

/* Michimachi: neon lettering and a street. */
.brand-michimachi h1 { text-shadow: 0 0 22px rgba(255, 181, 71, 0.45); }
.brand-michimachi .kana { text-shadow: 0 0 16px rgba(255, 92, 138, 0.7); }

/* Each Michimachi feature sits under a dashed rule, like lane markings. */
#michimachi .feature {
  padding-top: 18px;
  border-top: 2px dashed var(--line);
}

.route {
  width: 100%;
  margin-block: -32px;
  overflow: visible;
}

.route path { fill: none; }

.route-road {
  stroke: var(--card);
  stroke-width: 26;
  stroke-linecap: round;
}

.route-lane {
  stroke: var(--line);
  stroke-width: 2;
  stroke-dasharray: 10 12;
}

.route-car {
  fill: #ffb547;
  filter: drop-shadow(0 0 6px #ffb547);
  offset-path: path("M0 90H180Q200 90 200 70V50Q200 30 220 30H470Q490 30 490 50V80Q490 100 510 100H760Q780 100 780 80V40Q780 20 800 20H1080");
  animation: drive 40s linear infinite;
}

@keyframes drive {
  from { offset-distance: 0%; }
  to { offset-distance: 100%; }
}

/* ---------- Shell: footer ---------- */

.site-footer {
  display: grid;
  gap: 64px;
  margin-top: 96px;
}

.hello {
  display: grid;
  gap: 12px;
  font-size: 19px;
  color: var(--soft);
}

.hello h2 { color: var(--ink); }

.footer-bar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  padding-top: 24px;
  border-top: 2px dashed var(--line);
  color: var(--soft);
  font-size: 13.5px;
}

/* The cat supervising QA, sitting on the footer line. */
.footer-cat {
  position: absolute;
  right: 40px;
  bottom: 100%;
  width: 40px;
}

.legal {
  display: grid;
  gap: 6px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

#footer-line { transition: opacity 0.4s ease; }
#footer-line.is-changing { opacity: 0; }

/* Easter egg: five quick boops send the cat walking across the page. */
.paw-trail {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  pointer-events: none;
}

.paw-print {
  position: absolute;
  width: 22px;
  height: 22px;
  background: var(--soft);
  mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><ellipse cx='12' cy='16' rx='5' ry='4.2'/><circle cx='6.4' cy='10.6' r='2'/><circle cx='9.8' cy='6.6' r='2.1'/><circle cx='14.2' cy='6.6' r='2.1'/><circle cx='17.6' cy='10.6' r='2'/></svg>") center / contain no-repeat;
  transform: rotate(90deg);
  animation: paw-step 1.6s ease-out calc(var(--i) * 120ms) both;
}

@keyframes paw-step {
  0% { opacity: 0; transform: rotate(90deg) scale(.5); }
  12% { opacity: 1; transform: rotate(90deg) scale(1); }
  60% { opacity: 1; }
  100% { opacity: 0; }
}

/*
  Page changes: a quick cross-fade, and a door grows into its product page.
  The door and the page's hero share a name, so the browser morphs one into the other.
*/
.door-inkstead,
#inkstead .product-hero { view-transition-name: inkstead; }

.door-michimachi,
#michimachi .product-hero { view-transition-name: michimachi; }

::view-transition-group(inkstead),
::view-transition-group(michimachi) {
  animation-duration: 0.45s;
  animation-timing-function: var(--ease);
}

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
  .features { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .view { gap: 56px; }

  .hero,
  .product-hero { grid-template-columns: 1fr; }

  .hero-cat { justify-self: center; margin-right: 0; }
  .note { left: 30%; }

  .product-icon { order: 0; }
  .product-shot { margin-block: -16px -32px; }

  .doors { grid-template-columns: 1fr; }
  .door { min-height: 300px; }

  .post { grid-template-columns: 1fr; }
  .post-excerpt { grid-column: 1; }
}

@media (max-width: 480px) {
  .features { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
    transition: none !important;
  }

  html { scroll-behavior: auto; }
}
