/*
Theme Name: Crixu Notebook
Theme URI: https://crixu.blog
Author: Lucas Radke
Description: Graph-paper digital notebook Block Theme locked to a strict 24px baseline grid with Zero-CLS scroll-typewriter, Post-it blocks, highlighter formatting, and Night Desk mode.
Requires at least: 6.7
Tested up to: 7.1
Requires PHP: 8.2
Version: 1.0.3
Text Domain: crixu-notebook
*/

:root {
  --u: 24px;
  --paper-bg: #fcfcfd;
  --paper-ink: #181a20;
  --paper-muted: #525a66;
  --grid-line: rgba(59, 130, 246, 0.14);
  --margin-line: rgba(220, 38, 38, 0.34);
  --pen-red: #d92d20;
  --marker: #fde047;
  --sticky-bg: #fef08a;
  --sticky-border: #facc15;
  --sticky-ink: #291802;
  --sticky-muted: #78350f;
}

html.crixu-night {
  --paper-bg: #131722;
  --paper-ink: #edf1f7;
  --paper-muted: #98a2b3;
  --grid-line: rgba(96, 165, 250, 0.13);
  --margin-line: rgba(248, 113, 113, 0.32);
  --pen-red: #ff7a70;
  --marker: rgba(250, 204, 21, 0.34);
}

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

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--paper-bg);
  color: var(--paper-ink);
  font-family: 'Newsreader', Georgia, serif;
  font-size: 16px;
  line-height: var(--u);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Full-bleed Karopapier synced to 24px baseline (15px offset puts lines right beneath text baselines) */
.crixu-notebook-canvas {
  min-height: 100vh;
  width: 100%;
  margin: 0;
  padding: 24px 24px 72px 24px;
  background-color: var(--paper-bg);
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: var(--u) var(--u);
  background-position: 0 15px;
  background-attachment: local;
  position: relative;
}

/* Keep the notebook surface full width while centering its contents. */
.crixu-notebook-canvas > * {
  max-width: 816px;
  margin-left: auto;
  margin-right: auto;
}

/* Red vertical margin line aligned with the centered content. */
@media (min-width: 680px) {
  .crixu-notebook-canvas::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: max(144px, calc(50% - 288px));
    width: 1px;
    background: var(--margin-line);
    pointer-events: none;
  }
}

a {
  color: inherit;
  text-decoration-color: var(--pen-red);
  text-underline-offset: 3px;
}

/* Strict 24px Grid Rows (Date left | Content right) */
.crixu-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  column-gap: 48px;
  row-gap: 0;
  align-items: start;
  margin-bottom: 24px;
}

.crixu-margin-col {
  font-family: 'Caveat', cursive;
  font-size: 19px;
  font-weight: 700;
  line-height: var(--u);
  color: var(--pen-red);
  margin: 0;
}

.crixu-content-col {
  min-width: 0;
}

@media (max-width: 679px) {
  .crixu-row {
    grid-template-columns: 1fr;
    margin-bottom: 24px;
  }
}

/* Strict baseline-locked typography */
.wp-site-blocks h1,
.wp-site-blocks h2,
.wp-site-blocks h3,
.crixu-h1,
.crixu-h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--paper-ink);
  text-decoration: underline;
  text-decoration-color: var(--marker);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

.crixu-h1,
.wp-site-blocks h1 {
  font-size: 26px;
  line-height: 24px;
  margin-bottom: 24px;
}

.crixu-h2,
.wp-site-blocks h2 {
  font-size: 20px;
  line-height: 24px;
  margin-bottom: 0;
}

.wp-site-blocks p,
.crixu-body {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 16px;
  line-height: 24px;
  margin: 0;
  color: var(--paper-muted);
}

.wp-site-blocks p + p {
  margin-top: 24px;
}

.crixu-meta,
.wp-block-post-terms {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 24px;
  color: var(--paper-muted);
  margin: 0;
}

/* Header & Navigation */
.crixu-topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.crixu-site-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 22px;
  font-weight: 800;
  line-height: 24px;
  text-decoration: none;
  margin: 0;
}

.crixu-nav-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  line-height: 24px;
}

.crixu-nav-wrap a {
  text-decoration: none;
}

.crixu-nav-wrap a:hover {
  text-decoration: underline;
  text-decoration-color: var(--pen-red);
}

.crixu-desk-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.crixu-pill-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  padding: 1px 8px;
  border-radius: 6px;
  border: 1px solid rgba(128, 128, 128, 0.3);
  background: transparent;
  color: var(--paper-ink);
  cursor: pointer;
}

.crixu-mdot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.25);
  cursor: pointer;
  padding: 0;
}

/* Yellow Textmarker Highlighter (works in Gutenberg & frontend) */
mark.crixu-hl,
.crixu-hl {
  background: linear-gradient(180deg, transparent 38%, var(--marker) 38%, var(--marker) 92%, transparent 92%);
  color: inherit;
  padding: 0 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Grid-locked Post-it Group Style */
.is-style-postit,
.crixu-postit {
  background: var(--sticky-bg);
  color: var(--sticky-ink);
  border-radius: 4px;
  padding: 24px;
  box-shadow: inset 0 4px 0 var(--sticky-border), 0 8px 20px rgba(0, 0, 0, 0.08);
  margin-bottom: 24px;
}

.wp-site-blocks .is-style-postit :is(h1, h2, h3),
.wp-site-blocks .crixu-postit :is(h1, h2, h3),
.is-style-postit p,
.crixu-postit p {
  color: var(--sticky-ink);
}

/* Zero-CLS Scroll Typewriter */
.crixu-tw-wrap {
  position: relative;
  display: block;
}

.crixu-tw-ghost {
  visibility: hidden;
  display: block;
}

.crixu-tw-live {
  position: absolute;
  inset: 0;
  display: block;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.crixu-tw-live.is-in {
  opacity: 1;
}

.wp-site-blocks :is(h1, h2, h3) .crixu-tw-live {
  text-decoration: underline;
  text-decoration-color: var(--marker);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

.crixu-cursor {
  display: inline-block;
  width: 2px;
  height: 0.85em;
  background: var(--pen-red);
  vertical-align: -0.08em;
  margin-left: 1px;
  animation: crixu-blink 0.8s steps(2, start) infinite;
}

@keyframes crixu-blink {
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .crixu-cursor { display: none; }
}

/* Comments & ActivityPub/Webmention Replies */
.crixu-comments-wrap {
  margin-top: 24px;
  padding-top: 24px;
  box-shadow: inset 0 1px 0 var(--grid-line);
}

.comment-list {
  list-style: none;
  margin: 0 0 24px 0;
  padding: 0;
}

.comment-list .comment {
  padding: 12px 16px;
  margin-bottom: 12px;
  border-radius: 6px;
  background: rgba(128, 128, 128, 0.06);
  border-left: 3px solid var(--pen-red);
}

.comment-form textarea,
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"] {
  width: 100%;
  padding: 8px 12px;
  font-family: 'Newsreader', Georgia, serif;
  font-size: 16px;
  line-height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(128, 128, 128, 0.35);
  background: var(--paper-bg);
  color: var(--paper-ink);
}

.comment-form input[type="submit"] {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  background: var(--paper-ink);
  color: var(--paper-bg);
  cursor: pointer;
}
