/*
  The small "Stay Connected" button at the top of each page, and the sign-up pop-up it opens.
  Used by every page except the home page, which carries its own version of these styles in index.html.
  The pop-up itself is built by stay-connected.js.
*/

/* ---------- The button ---------- */
a.stay-connected {
  float: right;
  margin: 0 0 0.35rem 0.75rem;
  padding: 0.3rem 0.8rem;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.3;
  white-space: nowrap;
  text-decoration: none;
  color: #1e40af;
  background: transparent;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
a.stay-connected:hover,
a.stay-connected:focus-visible { color: #fff; background: #1e40af; border-color: #1e40af; }

/* The page title always starts below the button, never beside it */
a.stay-connected ~ h1 { clear: right; }

/* A little smaller on phones, so it fits on the same line as the "Back to…" link */
@media (max-width: 480px) {
  a.stay-connected { margin-left: 0.5rem; padding: 0.3rem 0.6rem; font-size: 0.76rem; }
}

/* ---------- The pop-up ---------- */
html:has(.sc-dialog[open]) { overflow: hidden; }

.sc-dialog,
.sc-dialog * { box-sizing: border-box; }

.sc-dialog {
  --sc-ink: #2a2520;
  --sc-ink-soft: #4a4138;
  --sc-paper: #fbf8f3;
  --sc-paper-warm: #f5eee1;
  --sc-accent: #8e3520;
  --sc-accent-soft: #b54328;
  --sc-line: #dcd2c0;
  --sc-serif: Lora, Georgia, 'Times New Roman', serif;
  --sc-sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  width: min(33rem, calc(100% - 1.5rem));
  max-width: none;
  max-height: calc(100% - 1.5rem);
  margin: auto;
  padding: 0;
  font-family: var(--sc-serif);
  font-size: 1rem;
  line-height: 1.65;
  text-align: center;
  color: var(--sc-ink);
  background: #fffdf9;
  border: 1px solid var(--sc-line);
  border-top: 4px solid var(--sc-accent);
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  overflow: auto;
}
.sc-dialog[open] { animation: sc-rise 0.25s ease; }
.sc-dialog::backdrop { background: rgba(22, 18, 15, 0.72); }
@keyframes sc-rise { from { opacity: 0; transform: translateY(12px); } }

.sc-body { position: relative; padding: 2.6rem 1.5rem 2.25rem; }

.sc-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  padding: 0;
  font-family: var(--sc-sans);
  font-size: 1.5rem;
  line-height: 1;
  color: var(--sc-ink-soft);
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.sc-close:hover { color: var(--sc-accent); background: var(--sc-paper-warm); }

.sc-face {
  display: block;
  width: 4.75rem;
  height: 4.75rem;
  margin: 0 auto 1.1rem;
  object-fit: cover;
  border: 3px solid #e0c47a;
  border-radius: 50%;
  box-shadow: 0 8px 20px rgba(42, 37, 32, 0.2);
}

.sc-dialog h2 {
  margin: 0 0 1.1rem;
  padding: 0;
  font-family: var(--sc-serif);
  font-weight: 700;
  font-size: clamp(1.6rem, 3.6vw, 2.05rem);
  line-height: 1.2;
  letter-spacing: normal;
  text-align: center;
  color: var(--sc-ink);
  border: none;
}
.sc-dialog p {
  margin: 0 0 0.7rem;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1.65;
  text-align: center;
  color: var(--sc-ink-soft);
}

.sc-form { display: grid; gap: 0.75rem; max-width: 25rem; margin: 1.75rem auto 0; }
.sc-form input[type="text"],
.sc-form input[type="email"] {
  width: 100%;
  margin: 0;
  padding: 0.95rem 1rem;
  font-family: var(--sc-sans);
  font-size: 1rem;
  line-height: 1.3;
  color: var(--sc-ink);
  background: #fff;
  border: 1px solid var(--sc-line);
  border-radius: 5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sc-form input::placeholder { color: #8a7f72; }
.sc-form input:focus {
  outline: none;
  border-color: var(--sc-accent);
  box-shadow: 0 0 0 3px rgba(142, 53, 32, 0.16);
}
.sc-form button {
  margin: 0;
  padding: 1rem 1.2rem;
  font-family: var(--sc-sans);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--sc-paper);
  background: var(--sc-accent);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.sc-form button:hover {
  background: var(--sc-accent-soft);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(142, 53, 32, 0.25);
}
.sc-form button:disabled { opacity: 0.75; cursor: default; transform: none; box-shadow: none; }
.sc-dialog .sc-note { margin: 0.1rem 0 0; font-family: var(--sc-sans); font-size: 0.85rem; line-height: 1.5; }
.sc-dialog .sc-error { margin: 0; font-family: var(--sc-sans); font-weight: 600; font-size: 0.92rem; line-height: 1.5; color: var(--sc-accent); }

/* After signing up, the form gives way to the thank-you line and a button back to the page */
.sc-dialog .sc-thanks { display: none; margin: 1.5rem 0 0; font-style: italic; }
.sc-done {
  display: none;
  margin: 1.4rem auto 0;
  padding: 0.8rem 1.4rem;
  font-family: var(--sc-sans);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--sc-accent);
  background: transparent;
  border: 1px solid var(--sc-accent);
  border-radius: 5px;
  cursor: pointer;
}
.sc-done:hover { color: var(--sc-paper); background: var(--sc-accent); }
.sc-signed-up .sc-form { display: none; }
.sc-dialog.sc-signed-up .sc-thanks { display: block; }
.sc-signed-up .sc-done { display: inline-block; }

@media (max-width: 640px) {
  .sc-body { padding: 2.5rem 1.15rem 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  a.stay-connected,
  .sc-dialog,
  .sc-dialog * { transition: none !important; animation: none !important; }
}
