:root {
  /* Sampled from the Manaiakalani logo (the periwinkle-blue line art). */
  --brand: #5583ff;
  --brand-dark: #1f3b9e;
  --brand-tint: #eaf0ff;
  --bg: #f4f8fb;
  --ink: #1f2933;
  --paper: #ffffff;
  --error: #c0392b;
  --success: #2f855a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Quicksand", "Atkinson Hyperlegible", "Comic Sans MS", "Segoe UI", Verdana, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- Screen 1: picker ---------- */

.picker {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.card {
  background: var(--paper);
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  padding: 40px 32px;
  max-width: 480px;
  width: 100%;
}

.brand-logo {
  height: 84px;
  width: auto;
  margin-bottom: 12px;
}

h1 {
  font-size: 2.4rem;
  margin: 0 0 8px;
  color: var(--brand-dark);
}

.subtitle {
  font-size: 1.2rem;
  color: #52606d;
  margin: 0 0 28px;
}

label {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: left;
}

#blog-url {
  width: 100%;
  font-size: 1.3rem;
  padding: 16px;
  border: 3px solid #cbd2d9;
  border-radius: 14px;
  margin-bottom: 20px;
}

#blog-url:focus {
  outline: none;
  border-color: var(--brand);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 14px;
}

#go-btn {
  width: 100%;
  font-size: 1.4rem;
  font-weight: 800;
  padding: 18px;
  background: var(--brand);
  color: white;
  transition: background 0.15s ease, transform 0.05s ease;
}

#go-btn:hover { background: var(--brand-dark); }
#go-btn:active { transform: scale(0.98); }
#go-btn:disabled { background: #a0aec0; cursor: wait; }

.status {
  min-height: 28px;
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 16px;
}

.status.error { color: var(--error); }
.status.success { color: var(--success); }

.poc-note {
  margin-top: 20px;
  font-size: 0.85rem;
  color: #8b9aa8;
  max-width: 480px;
}

/* ---------- Screen 2: storybook ---------- */

.hidden { display: none; }

.storybook-actions {
  position: sticky;
  top: 0;
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 16px;
  background: var(--bg);
  z-index: 10;
}

.storybook-actions button {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 14px 22px;
  background: var(--paper);
  border: 2px solid var(--brand);
  color: var(--brand);
}

#print-btn {
  background: var(--brand);
  color: white;
}

#storybook-content {
  max-width: 720px;
  margin: 0 auto 60px;
  background: var(--paper);
  padding: 40px;
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.06);
  overflow-wrap: anywhere;
  word-break: break-word;
}

#storybook-content * {
  max-width: 100%;
}

.cover {
  text-align: center;
  padding-bottom: 32px;
  margin-bottom: 32px;
  border-bottom: 4px dashed #cbd2d9;
}

.cover img {
  max-width: 160px;
  border-radius: 50%;
  margin-bottom: 16px;
}

.cover .brand-logo {
  height: 64px;
  width: auto;
  border-radius: 0;
  margin-bottom: 16px;
}

.cover .brand-tag {
  display: inline-block;
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.cover .truncation-warning {
  margin-top: 20px;
  padding: 12px 16px;
  background: #fff6e5;
  border: 1px solid #f0c869;
  border-radius: 10px;
  color: #7a5b00;
  font-size: 0.85rem;
  text-align: left;
}

.cover h1 {
  margin: 0 0 8px;
}

.cover .tagline {
  color: #52606d;
  font-size: 1.1rem;
}

.cover .meta {
  margin-top: 20px;
  font-size: 0.95rem;
  color: #8b9aa8;
}

.post {
  margin-bottom: 48px;
  page-break-inside: avoid;
}

.post h2 {
  font-size: 1.6rem;
  margin-bottom: 4px;
  color: var(--brand-dark);
}

.post .post-meta {
  font-size: 0.9rem;
  color: #8b9aa8;
  margin-bottom: 16px;
}

.post .post-body img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 16px auto;
  break-inside: avoid;
  page-break-inside: avoid;
}

/* A figure/gallery/grid wrapper shouldn't cap the image below full width */
.post .post-body figure,
.post .post-body .wp-block-image,
.post .post-body .wp-caption,
.post .post-body p {
  max-width: 100%;
  width: auto;
}

.post .post-body figcaption,
.post .post-body .wp-caption-text {
  text-align: center;
  font-size: 0.85rem;
  color: #52606d;
  margin-top: -8px;
  margin-bottom: 16px;
}

/* Side-by-side image rows (galleries) still get a decent size each rather
   than shrinking to thumbnail width */
.post .post-body .gallery,
.post .post-body .wp-block-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.post .post-body .gallery img,
.post .post-body .wp-block-gallery img {
  margin: 0;
}

.post .post-body {
  line-height: 1.6;
  font-size: 1.05rem;
}

.post .post-body table,
.post .post-body pre {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.comments {
  margin-top: 24px;
  padding: 16px 18px;
  background: var(--brand-tint);
  border-radius: 12px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.comments h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--brand-dark);
}

.comment {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(31, 59, 158, 0.12);
}

.comment:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.comment-meta {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 2px;
}

.comment-body {
  font-size: 0.95rem;
  line-height: 1.5;
}

.comment-body p {
  margin: 4px 0;
}

.embed-card {
  display: block;
  border: 2px dashed var(--brand);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
  text-decoration: none;
  color: var(--brand-dark);
  font-weight: 700;
}

.embed-card small {
  display: block;
  font-weight: 400;
  color: #52606d;
  margin-top: 4px;
}

.divider {
  text-align: center;
  color: #cbd2d9;
  margin: 24px 0;
}

/* ---------- Branded print footer ---------- */
/* CSS has no reliable way to draw custom running headers/footers into the
   browser's print margins, so this uses the common workaround: reserve
   extra bottom space on the page via @page margin, then pin a
   position:fixed bar into that reserved space — Chrome repeats a
   bottom-anchored fixed element on every printed page. Hidden entirely on
   screen — it only appears in the print/PDF output. */

.print-footer {
  display: none;
}

/* ---------- Print ---------- */

@media print {
  .no-print { display: none !important; }

  body { background: white; }

  #storybook-content {
    box-shadow: none;
    max-width: 100%;
    padding: 0;
  }

  .post {
    break-inside: avoid;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.75rem;
    font-weight: 400;
    color: #52606d;
  }

  .embed-card::after {
    content: "";
  }

  /* A repeating branded FOOTER is included (see below) — a matching
     repeating header was tried and dropped. Chromium's `position: fixed`
     containing block in paginated print turned out to behave differently
     for top- vs bottom-anchored offsets (bottom repeats cleanly in the
     margin band; top consistently overlapped the first lines of content
     no matter which offset was tried), and it's not worth chasing a
     browser print-engine quirk further for a proof of concept. The cover
     page already carries the logo/trust name prominently, so the header
     was redundant anyway. */

  .print-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    bottom: 8mm;
    left: 16mm;
    right: 16mm;
    height: 8mm;
    border-top: 1px solid #cbd2d9;
    padding-top: 5px;
    font-size: 8.5pt;
    color: #52606d;
  }
}

@page {
  /* extra top/bottom margin reserves room for the fixed print header/footer */
  margin: 32mm 16mm 24mm 16mm;
}
