/* =========================================================
   THE REBUILD LETTER — style.css
   Design: Rebuild brand identity
   ABC Social Mono for all type
   Mobile-first responsive
   ========================================================= */

/* ---------------------------------------------------------
   Google Fonts - Allura for signatures
   --------------------------------------------------------- */
@import url("https://fonts.googleapis.com/css2?family=Allura&display=swap");

/* ---------------------------------------------------------
   ABC Social Mono font loading
   --------------------------------------------------------- */
@font-face {
  font-family: "ABC Social Mono";
  src: url("/ABCSocialMono-Book.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "ABC Social Mono";
  src: url("/ABCSocialMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------------------------------------------------------
   Custom properties — Rebuild brand
   --------------------------------------------------------- */
:root {
  --bg: #e8e8e8; /* Rebuild light */
  --bg-card: #e8e8e8;
  --text-primary: #22223e; /* Rebuild dark */
  --text-muted: #5a5a78;
  --text-faint: #8686a0;
  --accent: #22223e;
  --accent-hover: #3a3a5e;
  --border: #d0d0d8;
  --border-light: #e0e0e8;
  --error: #b00020;
  --page-max: 960px;
  --letter-max: 70ch;
  --radius: 2px;

  --font-mono: "ABC Social Mono", ui-monospace, "Courier New", monospace;

  --transition: 200ms ease;
}

/* ---------------------------------------------------------
   Reset & base
   --------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 18px;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-mono);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------
   Page wrapper
   --------------------------------------------------------- */
.page-wrapper {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

/* ---------------------------------------------------------
   Site header
   --------------------------------------------------------- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 100%;
  padding: 1.5rem 0;
}

@media (min-width: 600px) {
  .site-header {
    padding: 1.5rem 3rem;
    flex-direction: row;
  }
}

@media (max-width: 599px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}

.logo-link {
  display: block;
  line-height: 0;
  transition: opacity var(--transition);
}

.logo-link:hover {
  opacity: 0.7;
}

.site-logo {
  height: 24px;
  width: auto;
  display: block;
}

.cta-button {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: var(--radius);
  transition:
    transform var(--transition),
    box-shadow var(--transition);
}

.cta-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(34, 34, 62, 0.15);
}

.cta-button:active {
  transform: translateY(0);
}

@media (max-width: 599px) {
  .cta-button {
    padding: 0.625rem 1.25rem;
    font-size: 0.8125rem;
  }
}

/* ---------------------------------------------------------
   Letter card
   --------------------------------------------------------- */
.letter {
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: var(--radius);
  max-width: 100%;
  margin-bottom: 0;
  padding: 2.5rem 0;
}

@media (min-width: 600px) {
  .letter {
    padding: 3rem;
  }
}

/* Kicker / meta */
.letter-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 1rem;
}

/* Title */
.letter-title {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 2.5rem;
  letter-spacing: 0;
}

/* Letter body — constrained width for readability */
.letter-body {
  max-width: var(--letter-max);
}

/* Section headings */
.letter-section {
  margin-bottom: 2rem;
}

.section-heading {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

/* Anchor link — hidden until hover/focus */
.anchor-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.anchor-icon {
  opacity: 0;
  font-size: 0.8em;
  transition: opacity var(--transition);
  cursor: pointer;
  color: var(--accent);
}

.section-heading:hover .anchor-icon,
.anchor-link:focus .anchor-icon {
  opacity: 1;
}

/* Paragraph text */
.letter-body p {
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-primary);
  margin-bottom: 1.25em;
}
.letter-body p:last-child {
  margin-bottom: 0;
}

/* Strong/bold text in letter */
.letter-body strong {
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Letter footer */
.letter-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.letter-author {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ---------------------------------------------------------
   Signing area — below letter, feels like bottom of doc
   --------------------------------------------------------- */
.signing-area {
  background: var(--bg-card);
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 2.5rem 0;
  margin-bottom: 3rem;
}

@media (min-width: 600px) {
  .signing-area {
    padding: 3rem;
  }
}

.signing-document-line {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin-bottom: 2.5rem;
}

.signing-title {
  font-family: var(--font-mono);
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.signing-intro {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* ---------------------------------------------------------
   Form fields
   --------------------------------------------------------- */
.field-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.optional-label {
  font-weight: 400;
  font-style: italic;
  color: var(--text-faint);
}

input[type="text"],
input[type="email"] {
  display: block;
  width: 100%;
  max-width: 42ch;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-primary);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
  appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 34, 62, 0.12);
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 0.4rem;
  line-height: 1.5;
}

.gdpr-note {
  color: var(--text-faint);
}

/* Inline button (privacy toggle) */
.inline-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}
.inline-button:hover {
  color: var(--accent-hover);
}

/* Privacy panel */
.privacy-panel {
  background: #f0ede6;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.privacy-panel h3 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
}

.privacy-panel ul {
  list-style: disc;
  padding-left: 1.25rem;
}

.privacy-panel li {
  margin-bottom: 0.5rem;
}

.privacy-panel a {
  color: var(--accent);
}

/* ---------------------------------------------------------
   Signature preview (text-based)
   --------------------------------------------------------- */
.signature-preview-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.signature-preview-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 500px;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 1.5rem;
}

.signature-preview-text {
  font-family: "Allura", cursive;
  font-size: 2.5rem;
  color: var(--text-primary);
  font-style: normal;
  text-align: center;
}

/* ---------------------------------------------------------
   Consent checkbox
   --------------------------------------------------------- */
.consent-group {
  margin-top: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
  font-weight: 400;
}

.checkbox-label input[type="checkbox"] {
  margin-top: 0.2rem;
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.checkbox-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---------------------------------------------------------
   Submit button
   --------------------------------------------------------- */
.form-actions {
  margin-top: 2rem;
}

.submit-btn {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background var(--transition),
    transform 80ms ease;
}
.submit-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}
.submit-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.submit-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.form-error {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--error);
}

/* ---------------------------------------------------------
   Post-signature confirmation
   --------------------------------------------------------- */
#confirmation {
  padding-top: 0.5rem;
}

.confirmation-inner {
  max-width: 46rem;
}

.confirmation-thanks {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.confirmation-sig {
  margin-bottom: 2rem;
}

.confirmation-sig img {
  max-width: 260px;
  height: auto;
  display: block;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

/* Share section */
.share-section {
  margin-top: 2rem;
}

.share-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
}

.share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.share-btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  transition:
    opacity var(--transition),
    transform 80ms ease;
  border: 1px solid transparent;
}
.share-btn:hover {
  opacity: 0.85;
}
.share-btn:active {
  transform: translateY(1px);
}

.share-linkedin {
  background: #0077b5;
  color: #fff;
}
.share-twitter {
  background: #000;
  color: #fff;
}
.share-bluesky {
  background: #0085ff;
  color: #fff;
}
.share-whatsapp {
  background: #25d366;
  color: #fff;
}
.share-email {
  background: transparent;
  color: var(--accent);
  border-color: var(--border);
}
.share-copy {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
  font-family: var(--font-sans);
}
.share-copy.copied {
  color: #2a7a2a;
  border-color: #2a7a2a;
}

/* WhatsApp: show only on mobile via media query */
.whatsapp-only {
  display: none;
}
@media (max-width: 768px) {
  .whatsapp-only {
    display: inline-block;
  }
}

/* ---------------------------------------------------------
   Signatures wall
   --------------------------------------------------------- */
.signatures-wall {
  color: var(--text-primary);
  padding: 2.5rem 0 1rem;
  border-top: 1px solid var(--border);
}

@media (min-width: 600px) {
  .signatures-wall {
    padding: 3rem 3rem 1rem;
  }
}

.wall-header {
  margin-bottom: 1.75rem;
}

.wall-title {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--text-primary);
  font-weight: 400;
}

.signatures-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

@media (min-width: 500px) {
  .signatures-list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 800px) {
  .signatures-list {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.signature-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  min-height: 2.5rem;
}

.sig-name {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.3;
  margin: 0;
  margin-top: auto;
}

.sig-org {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.3;
}

.wall-footer {
  margin-top: 1.5rem;
  text-align: center;
}

.load-more-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.5rem 1.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    border-color var(--transition),
    color var(--transition);
}
.load-more-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.wall-empty,
.wall-loading {
  font-size: 0.875rem;
  color: var(--text-faint);
  text-align: center;
  padding: 1rem 0;
}

/* ---------------------------------------------------------
   Site footer
   --------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border-light);
  padding-top: 1.5rem;
  margin-top: 3rem;
}

.site-footer p {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.site-footer a {
  color: var(--text-muted);
}

/* ---------------------------------------------------------
   Focus visible — accessibility
   --------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------
   Banner (verification/deletion status)
   --------------------------------------------------------- */
.banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 1rem 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.banner-success {
  background: #2a7a2a;
  color: white;
}

.banner-error {
  background: #b00020;
  color: white;
}

/* ---------------------------------------------------------
   Co-creator badge
   --------------------------------------------------------- */
.co-creator-badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  background: #6ba1cc;
  color: white;
  font-size: 0.5625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 2px;
  margin-bottom: 0.375rem;
}

/* Badge in signatures list (block display, left-aligned) */
.signature-item .co-creator-badge {
  display: block;
  width: fit-content;
}

/* ---------------------------------------------------------
   Updated confirmation styles
   --------------------------------------------------------- */
.confirmation-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

@media (max-width: 599px) {
  .confirmation-title {
    font-size: 1.125rem;
  }
}

.confirmation-notice {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.confirmation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background var(--transition),
    transform 80ms ease;
  text-align: center;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

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

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}

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

.btn-delete {
  background: #b00020;
  color: white;
}

.btn-delete:hover {
  background: #8d001a;
}

.share-help {
  font-size: 0.875rem;
  color: var(--text-faint);
  margin-bottom: 1rem;
}

.resend-verification-notice {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
}

/* ---------------------------------------------------------
   Signature images in wall
   --------------------------------------------------------- */
/* Hide signature images on all screen sizes */
.sig-image-wrap {
  display: none;
}

.sig-image {
  max-width: 200px;
  height: auto;
  display: block;
  /* Remove white background - make it transparent */
  mix-blend-mode: multiply;
  filter: contrast(1.1);
}

/* ---------------------------------------------------------
   Required label
   --------------------------------------------------------- */
.required-label {
  color: var(--error);
  font-weight: 600;
  font-style: normal;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ---------------------------------------------------------
   Utilities
   --------------------------------------------------------- */
[hidden] {
  display: none !important;
}

/* Smooth anchor target highlight */
:target .section-heading .anchor-icon {
  opacity: 1;
}

/* ---------------------------------------------------------
   Template selector styles
   --------------------------------------------------------- */
.template-selector {
  margin-bottom: 1.5rem;
}

.template-selector-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.template-options {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.template-swatch {
  width: 3rem;
  height: 3rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    border-color var(--transition),
    transform var(--transition);
  padding: 0;
  background: none;
}

.template-swatch:hover {
  transform: scale(1.05);
}

.template-swatch.active {
  border-color: var(--accent);
  border-width: 3px;
  box-shadow: 0 0 0 2px rgba(34, 34, 62, 0.2);
}

.template-swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.swatch-color {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: calc(var(--radius) - 2px);
}

/* Preview container */
.preview-container {
  margin-bottom: 2rem;
}

.share-preview-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
  margin: 0 auto;
}

.preview-caption {
  font-size: 0.75rem;
  color: var(--text-faint);
  text-align: center;
  margin-top: 0.75rem;
  margin-bottom: 0;
}

/* Mobile responsive */
@media (max-width: 599px) {
  .template-swatch {
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* ---------------------------------------------------------
   Reduced motion
   --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
  html {
    scroll-behavior: auto;
  }
}
