/* ==========================================================
   If only...  —  styles
   Plain Apple-style text messages, NPSC navy + orange accents.
   ========================================================== */

:root {
  /* Apple greys */
  --bg: #f2f2f7;
  --surface: #ffffff;
  --bar: #e5e8ee;          /* chat header bar */
  --received: #e9e9eb;     /* grey bubble */
  --ink: #1c1c1e;
  --ink-soft: #8e8e93;
  --line: #e5e5ea;

  /* NPSC brand */
  --np-navy: #1c3664;
  --np-navy-dark: #0d1d51;
  --np-orange: #f59421;
  --np-red: #ff3131;

  --danger: #ff3b30;

  /* Bubble colours (keep names in sync with js/config.js and functions/index.js) */
  --b-green: #4caf50;
  --b-blue: #007aff;
  --b-navy: #1c3664;
  --b-orange: #f59421;
  --b-purple: #af52de;
  --b-pink: #ff2d55;
  --b-grey: #e9e9eb;

  --radius: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 14px rgba(0, 0, 0, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--np-navy); }

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 84px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

.brand img { height: 60px; width: auto; display: block; }

.brand .divider { width: 1px; height: 38px; background: var(--line); }

.brand .name {
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
}

.dots { color: var(--np-orange); }

.nav { display: flex; gap: 2px; }

.nav a {
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--ink-soft);
}

.nav a:hover { color: var(--ink); }

.nav a[aria-current="page"] { color: var(--ink); }

.nav a.cta { background: var(--np-navy); color: #fff; }
.nav a.cta:hover { background: var(--np-navy-dark); }

/* ---------- Hero ---------- */

.hero {
  text-align: center;
  padding: 56px 0 36px;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(2.8rem, 9vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.hero .tagline {
  margin: 0 auto 8px;
  font-size: clamp(1.2rem, 3.2vw, 1.75rem);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.hero .count {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1rem;
}

/* ---------- Inputs & buttons ---------- */

.search {
  display: flex;
  gap: 10px;
  margin: 0 auto;
}

.search input { font-size: 1.05rem; padding: 14px 18px; }
.search .btn { padding: 0 26px; }

.search input { flex: 1; min-width: 0; }

input[type="text"],
input[type="search"],
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus {
  border-color: var(--np-orange);
  box-shadow: 0 0 0 3px rgba(245, 148, 33, 0.2);
}

.btn {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  background: var(--np-navy);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: var(--np-navy-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Results bar + page-size picker ---------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 18px 0 6px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.results { margin: 0; min-height: 1.4em; }

.per-page { display: flex; align-items: center; gap: 8px; }

select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  cursor: pointer;
}

select:focus { outline: none; border-color: var(--np-orange); box-shadow: 0 0 0 3px rgba(245, 148, 33, 0.2); }

/* ---------- Message grid: 3 roomy columns on laptops ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  padding: 18px 0 8px;
}

@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.grid .msg { margin: 0; display: flex; flex-direction: column; }
.grid .msg-body { flex: 1; }

.empty {
  text-align: center;
  padding: 48px 0 24px;
  color: var(--ink-soft);
  font-size: 1.1rem;
}

.empty .btn { display: inline-block; text-decoration: none; margin-top: 6px; }
.empty[hidden] { display: none; }

/* ---------- Pager ---------- */

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 36px 0 64px;
}

.pager button {
  font: inherit;
  font-weight: 600;
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.pager button:hover:not(:disabled) { border-color: var(--np-navy); }
.pager button[aria-current="page"] { background: var(--np-navy); border-color: var(--np-navy); color: #fff; }
.pager button:disabled { opacity: 0.4; cursor: default; }
.pager .gap { color: var(--ink-soft); padding: 0 4px; }

/* ---------- Message card: one text thread ---------- */

.msg {
  margin: 0 0 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.3s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Grey bar with back arrow and the name in the middle */
.msg-to {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 12px 44px;
  background: var(--bar);
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  overflow-wrap: anywhere;
}

.msg-to .back {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 11px;
  height: 11px;
  border-left: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: translateY(-50%) rotate(45deg);
}

.msg-body {
  padding: 14px 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* iMessage-style time above the bubble */
.msg-time {
  align-self: center;
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-soft);
}

/* Heart on the left, "Not Delivered" on the right */
.msg-foot {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
}

.felt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 4px 10px 4px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.felt:hover { background: var(--bg); }
.felt svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.felt[aria-pressed="true"] { color: var(--b-pink); }
.felt[aria-pressed="true"] svg { fill: currentColor; }
.felt.pop svg { animation: heart 0.35s ease; }

@keyframes heart {
  40% { transform: scale(1.3); }
}

/* The sent bubble (right side) */
.bubble {
  margin: 0;
  max-width: 88%;
  padding: 11px 17px;
  background: var(--bubble, var(--b-green));
  color: var(--bubble-ink, #fff);
  border-radius: 22px 22px 5px 22px;
  font-size: 1.2rem;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-status {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-status::before {
  content: "!";
  display: inline-grid;
  place-items: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
}

/* ---------- Loader / end of feed ---------- */

.loader {
  display: flex;
  justify-content: center;
  padding: 24px 0 48px;
}

.loader[hidden] { display: none; }

/* Grey "typing..." bubble */
.typing {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  background: var(--received);
  border-radius: 20px;
}

.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-soft);
  opacity: 0.35;
  animation: blink 1.2s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink { 50% { opacity: 1; } }


/* ---------- Write page ---------- */

.write {
  display: grid;
  gap: 28px;
  padding: 32px 0 64px;
}

@media (min-width: 860px) {
  .write { grid-template-columns: 1fr 1fr; align-items: start; }
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
}

.panel h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel .lead { margin: 0 0 20px; color: var(--ink-soft); }

.field { margin-bottom: 18px; }

.field label,
.field legend {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 6px;
  padding: 0;
}

.field .hint {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

fieldset { border: 0; margin: 0; padding: 0; }

textarea { resize: vertical; min-height: 120px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }

.swatches input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.swatches label {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--sw);
  cursor: pointer;
  margin: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.swatches input:checked + label { outline-color: var(--ink); }
.swatches input:focus-visible + label { outline-color: var(--np-orange); }

.notice {
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 0.95rem;
  margin: 0 0 16px;
}

.notice[hidden] { display: none; }
.notice.error { background: #ffeceb; color: #b3261e; }
.notice.success { background: #e8f5e9; color: #2e6b31; }
.notice.info { background: #eef1f7; color: var(--np-navy); }

.rules {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.rules li { margin-bottom: 4px; }

.preview-title {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

.preview .msg { animation: none; }

/* ---------- About page ---------- */

.prose {
  max-width: 620px;
  margin: 0 auto;
  padding: 40px 0 64px;
}

.prose h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 12px; }
.prose h2 { font-size: 1.1rem; font-weight: 700; margin: 28px 0 6px; }
.prose p, .prose li { color: #48484a; }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 28px 0 32px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
}

.site-footer p { margin: 4px 0; }

.footer-logo { height: 40px; width: auto; margin-bottom: 10px; }

.socials {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 12px;
}

.socials a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
}

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

.socials svg { width: 17px; height: 17px; flex: none; }

.admin-link { color: var(--ink-soft); font-size: 0.8rem; }

.demo-banner {
  background: var(--np-orange);
  color: #1c1c1e;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 16px;
}

.demo-banner[hidden] { display: none; }

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

@media (max-width: 640px) {
  .site-header .wrap { height: 68px; }
  .brand img { height: 44px; }
  .brand .divider, .brand .name { display: none; }
  .nav a { padding: 7px 11px; }
  .hero { padding: 36px 0 26px; }
  .grid { gap: 18px; }
  .msg-to { font-size: 1.1rem; }
  .bubble { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .msg, .typing span { animation: none; }
}
