/* handwritten.blog — paper, ink, and a little blue for the links. */

@font-face {
  font-family: "Caveat";
  src: url("/assets/caveat-latin-variable-0aa453d2.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --paper: #faf6ee;
  --paper-bright: #fffdf8;
  --ink: #2b2926;
  --ink-soft: #6b6558;
  --line: #e5ddcd;
  --link-ink: #2f5db3;
  --link-wash: rgba(47, 93, 179, 0.14);
  --danger: #a63d2f;
  --danger-wash: rgba(166, 61, 47, 0.06);
  --success: #2e6b34;
  --success-wash: rgba(46, 107, 52, 0.08);
  --ink-hover: #47443f; /* hover shade for ink-filled buttons */
  --shadow: 0 1px 3px rgba(43, 41, 38, 0.12), 0 8px 24px rgba(43, 41, 38, 0.08);
  --hand: "Caveat", "Bradley Hand", "Segoe Script", "Comic Sans MS", cursive;
  --serif: ui-serif, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--link-ink); }

h1, h2, h3 { line-height: 1.2; }

/* Page titles are handwritten; section headings (h2/h3) stay serif on purpose. */
.hero__title, .hero--small h1,
.auth-card h1, .dashboard-narrow h1,
.dashboard__header h1,
.post__title {
  font-family: var(--hand);
}

/* ---------- apex site chrome ---------- */

.site-main {
  flex: 1;
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Unlike .marketing-body, .site-body is full-width, so the shared header and
   footer align themselves with .site-main's container. */
.site-body .hand-header,
.site-body .hand-footer {
  width: 100%;
  max-width: 64rem;
  margin-inline: auto;
  padding-inline: 1.5rem;
}

/* ---------- buttons & forms ---------- */

.btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  border: 1.5px solid var(--ink);
  border-radius: 0.4rem;
  background: var(--paper-bright);
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { background: var(--line); }

.btn--primary {
  background: var(--ink);
  color: var(--paper-bright);
}

.btn--primary:hover { background: var(--ink-hover); }

.btn--danger {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}

.btn--large { padding: 0.8rem 1.6rem; font-size: 1.15rem; }
.btn--small { padding: 0.15rem 0.55rem; font-size: 0.9rem; }

.field { margin-bottom: 1.1rem; }

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="url"],
.field textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1.5px solid var(--line);
  border-radius: 0.4rem;
  background: var(--paper-bright);
  font: inherit;
  color: var(--ink);
}

.field input:focus, .field textarea:focus {
  outline: 2px solid var(--link-ink);
  outline-offset: 1px;
}

.field__hint {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.subdomain-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.subdomain-field input { max-width: 14rem; }

.subdomain-field__suffix { color: var(--ink-soft); }

.form-errors {
  border: 1.5px solid var(--danger);
  border-radius: 0.4rem;
  background: var(--danger-wash);
  color: var(--danger);
  padding: 0.6rem 1rem;
  margin-bottom: 1.1rem;
}

.form-errors ul { margin: 0; padding-left: 1.1rem; }

.flash {
  padding: 0.6rem 1rem;
  border-radius: 0.4rem;
  margin-bottom: 1.2rem;
  border: 1.5px solid var(--line);
  background: var(--paper-bright);
}

.flash--alert { border-color: var(--danger); color: var(--danger); }

.empty-state {
  color: var(--ink-soft);
  font-style: italic;
}

/* ---------- marketing home ---------- */

.hero {
  text-align: center;
  padding: 3.5rem 1rem 2.5rem;
}

.hero--small { padding: 2.5rem 1rem; }

.hero__title, .hero--small h1 {
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  margin: 0 0 1rem;
}

.hero__lede {
  max-width: 38rem;
  margin: 0 auto 1.8rem;
  font-size: 1.15rem;
}

/* ---------- auth & narrow dashboard forms ---------- */

.auth-card, .dashboard-narrow {
  max-width: 26rem;
  margin: 2rem auto;
}

.dashboard-narrow { max-width: 30rem; }

.auth-card__alt { margin-top: 1.4rem; color: var(--ink-soft); }

.settings-section {
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}

.settings-back { margin-top: 2rem; }

.lede { color: var(--ink-soft); }

/* ---------- dashboard ---------- */

.dashboard--narrow {
  max-width: 40rem;
  margin: 0 auto;
}

.dashboard__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.dashboard__header h1 { margin: 0; }

.dashboard__actions {
  display: flex;
  gap: 1.1rem;
  align-items: center;
  flex-wrap: wrap;
}

.dashboard__quiet-link { color: var(--ink-soft); }

.dashboard__quiet-link:hover { color: var(--link-ink); }

.dashboard__meta { margin: 0; }

.badge {
  display: inline-block;
  font-size: 0.8rem;
  padding: 0.1rem 0.5rem;
  border-radius: 1rem;
  border: 1px solid;
}

.badge--published { color: var(--success); border-color: var(--success); background: var(--success-wash); }
.badge--draft { color: var(--ink-soft); border-color: var(--ink-soft); }
.badge--kind { color: var(--link-ink); border-color: var(--link-ink); background: var(--link-wash); }

.dashboard-posts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dashboard-posts__item {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
}

.dashboard-posts__item:first-child { border-top: 1px solid var(--line); }

.dashboard-posts__thumb img,
.dashboard-posts__thumb--empty {
  width: 4rem;
  height: 4rem;
  object-fit: cover;
  object-position: top;
  border-radius: 0.3rem;
  border: 1px solid var(--line);
}

.dashboard-posts__thumb--empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--ink-soft);
  background: var(--paper);
}

.dashboard-posts__body { flex: 1; }

.dashboard-posts__title {
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
}

.dashboard-posts__meta { margin: 0.2rem 0 0; color: var(--ink-soft); font-size: 0.9rem; }

.dashboard-columns {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
  gap: 2rem;
}

@media (max-width: 52rem) {
  .dashboard-columns { grid-template-columns: 1fr; }
}

.page-card {
  background: var(--paper-bright);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.8rem;
  margin-bottom: 1.4rem;
  box-shadow: var(--shadow);
}

.page-card__toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.page-card__label { font-weight: 700; }

.page-card__buttons {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
}

.page-card__buttons form { display: inline; }

.page-card__hint {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.replace-image {
  margin-top: 0.6rem;
  font-size: 0.9rem;
}

.replace-image summary {
  cursor: pointer;
  color: var(--ink-soft);
}

.replace-image form {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.upload-card {
  border: 1.5px dashed var(--ink-soft);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-top: 1rem;
}

.upload-card h3 { margin-top: 0; }

.upload-card form {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------- region editor ---------- */

.region-editor { position: relative; }

.region-editor__canvas {
  position: relative;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

.region-editor__canvas img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 0.3rem;
}

.region-draft {
  position: absolute;
  border: 2px dashed var(--link-ink);
  background: var(--link-wash);
  pointer-events: none;
}

.editor-region {
  position: absolute;
  border: 1.5px dashed var(--link-ink);
  background: var(--link-wash);
  border-radius: 2px;
}

.editor-region__remove {
  position: absolute;
  top: -0.7rem;
  right: -0.7rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  border: 1.5px solid var(--danger);
  background: var(--paper-bright);
  color: var(--danger);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.region-editor__form {
  position: absolute;
  z-index: 10;
  width: min(20rem, 90%);
  background: var(--paper-bright);
  border: 1.5px solid var(--ink);
  border-radius: 0.5rem;
  box-shadow: var(--shadow);
  padding: 0.8rem;
}

.region-editor__form label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.region-editor__form input,
.region-editor__form select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1.5px solid var(--line);
  border-radius: 0.3rem;
  font: inherit;
  margin-top: 0.2rem;
  background: var(--paper-bright);
  color: var(--ink);
}

.region-editor__form-actions {
  display: flex;
  gap: 0.5rem;
}

.region-editor__error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0 0 0.5rem;
}

/* ---------- public blog ---------- */

.blog-body {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.2rem;
}

/* The blog's typed title as quiet chrome above post pages, in the same
   hand style as the footer SVGs. Clicking it goes to the handwritten index. */
.blog-masthead {
  margin: 0.4rem 0 1.2rem;
  text-align: center;
  font-family: var(--hand);
  font-size: 1.4rem;
}

.blog-masthead a {
  color: var(--ink);
  text-decoration: none;
}

.blog-masthead a:hover, .blog-masthead a:focus-visible { color: var(--link-ink); }

.post__header { text-align: center; margin-bottom: 1.4rem; }

.post__title {
  font-size: 2rem;
  margin: 0 0 0.2rem;
}

.post__date { color: var(--ink-soft); }

/* The handwritten page: an image with clickable regions layered on top. */
.hw-page { margin: 0 0 1.6rem; }

.hw-page__canvas {
  position: relative;
  background: var(--paper-bright);
  box-shadow: var(--shadow);
  border-radius: 0.3rem;
}

.hw-page__canvas img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.3rem;
}

.hw-region {
  position: absolute;
  display: block;
  border-radius: 2px;
}

.hw-region:hover, .hw-region:focus-visible {
  background: var(--link-wash);
  outline: 1.5px dashed var(--link-ink);
}

.transcript {
  margin-top: 1.4rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--paper-bright);
  padding: 0.7rem 1rem;
}

.transcript summary {
  cursor: pointer;
  font-weight: 700;
}

/* Shared hand-drawn footer, used by every layout. */
.hand-footer {
  margin-top: 2.4rem;
  padding: 1.2rem 0 2rem;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--ink-soft);
}

/* ---------- handwritten chrome ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Inline hand-drawn SVGs pick up the surrounding ink via currentColor. */
.hand-svg {
  height: 1.7em;
  width: auto;
  vertical-align: middle;
}

.hand-link {
  display: inline-flex;
  color: inherit;
  text-decoration: none;
}

.hand-link:hover, .hand-link:focus-visible { color: var(--link-ink); }

.hand-footer__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0;
}

/* Typed contact address under the hand-drawn row, in the same hand style
   as the blog masthead. */
.hand-footer__contact {
  margin: 0.6rem 0 0;
  font-family: var(--hand);
  font-size: 1.3rem;
}

.empty-state--hand { text-align: center; }

.empty-state--hand .hand-svg {
  height: auto;
  width: min(24rem, 85%);
}

/* Handwritten marketing hero */
.hero--hand { padding: 2rem 1rem 2.5rem; }

.hero__canvas {
  position: relative;
  max-width: 44rem;
  margin: 0 auto;
  box-shadow: var(--shadow);
  border-radius: 0.4rem;
}

.hero__image {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
}

/* ---------- marketing chrome (handwritten header & footer) ---------- */

.marketing-body {
  max-width: 52rem;
  margin: 0 auto;
  padding: 1.2rem;
}

/* Shared hand-drawn header, used by the marketing and application layouts. */
.hand-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.6rem 0 1rem;
}

.hand-nav {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.hand-nav .hand-svg { height: 2.2em; }

.hand-button {
  border: none;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
}

.hand-button:hover, .hand-button:focus-visible { color: var(--link-ink); }

/* ---------- merged dashboard ---------- */

.homepage-nudge {
  color: var(--ink-soft);
  margin-bottom: 1.6rem;
}

.homepage-nudge p { margin-top: 0; }

/* A button that looks like a link, for quiet actions inside prose. */
.link-button {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--link-ink);
  text-decoration: underline;
  cursor: pointer;
}

/* The operator's /admin page: a quiet ledger of every blog on the site. */
.admin-stats { color: var(--ink-soft); margin: 0 0 2rem; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.admin-table th {
  text-align: left;
  font-weight: 600;
  padding: 0 1rem 0.4rem 0;
  border-bottom: 1.5px solid var(--ink);
}

.admin-table td {
  padding: 0.5rem 1rem 0.5rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: baseline;
}

.admin-table__quiet {
  display: block;
  color: var(--ink-soft);
  font-size: 0.85rem;
}
