/* --------------------------------------------------------
   probablyuseful.tools — listmonk public pages
   --------------------------------------------------------
   Targets listmonk's default public template class names
   (.wrap, .box, .header, .logo, .footer, .lang-selector,
   .lists, .campaigns) plus the semantic form elements
   used on subscribe / manage / unsubscribe / archive pages.
   -------------------------------------------------------- */

/* --- Design tokens (mirrored from the main site) --- */
:root {
  --bg:           #F5F2EB;
  --surface:      #FAF8F4;
  --text:         #1A1A1A;
  --text-sec:     #6B6560;
  --accent:       #247069;
  --accent-hover: #1A524E;
  --accent-press: #123C38;
  --accent-soft:  rgba(36, 112, 105, 0.08);
  --accent-ring:  rgba(36, 112, 105, 0.20);
  --border:       #DDD8D0;
  --code-bg:      #EDEAE4;
  --error:        #B04A3A;
  --error-soft:   rgba(176, 74, 58, 0.08);
  --success:      #3A7D5C;

  --font-heading: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;

  --max-prose:    560px;
  --max-layout:   720px;

  --radius:       6px;
  --radius-lg:    8px;
  --shadow:       0 1px 3px rgba(0, 0, 0, 0.06);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 500;
  line-height: 1.3;
  color: var(--text);
}

h1 { font-size: 1.75rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.25rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-hover); }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

strong { font-weight: 500; }

code, pre {
  font-family: var(--font-heading);
  font-size: 0.875rem;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 3px;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* --- Layout (listmonk .wrap) --- */
.wrap {
  width: 100%;
  max-width: var(--max-layout);
  margin: 0 auto;
  padding: 0 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* --- Header (listmonk .header + .logo) --- */
.header {
  padding: 32px 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.logo {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--text);
}

.logo a {
  color: var(--text);
  text-decoration: none;
}
.logo a:hover { color: var(--text); }

.logo img {
  max-height: 28px;
  width: auto;
  display: block;
}

/* --- Language selector --- */
.lang-selector,
.lang {
  font-size: 0.85rem;
}

.lang-selector select,
.lang select,
select {
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%236B6560' stroke-width='1.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s ease;
}

select:hover {
  border-color: var(--text-sec);
}

select:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Content box (listmonk .box) --- */
.box,
.content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin: 8px 0 24px;
  max-width: var(--max-prose);
  width: 100%;
  align-self: flex-start;
  box-shadow: var(--shadow);
}

/* --- Forms --- */
form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--text);
}

input[type="email"],
input[type="text"],
input[type="url"],
input[type="number"],
input[type="tel"],
input[type="search"],
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: var(--font-body);
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-sec);
}

input:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: var(--text-sec);
}

input:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:disabled,
textarea:disabled {
  background: var(--code-bg);
  color: var(--text-sec);
  cursor: not-allowed;
}

textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-body);
  line-height: 1.5;
}

/* --- Checkbox / radio --- */
input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background 0.15s ease;
  position: relative;
  top: 2px;
}

input[type="checkbox"] {
  border-radius: 3px;
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="checkbox"]:hover,
input[type="radio"]:hover {
  border-color: var(--accent);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Honeypot (hidden from users, visible to bots) --- */
.hp-field,
.honeypot,
input[name="hp"],
input[name="website"] {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  tab-index: -1;
}

/* --- Buttons --- */
button,
.button,
input[type="submit"],
input[type="button"] {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 12px 24px;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  line-height: 1.2;
}

button:hover,
.button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
  background: var(--accent-hover);
  color: #fff;
}

button:active,
.button:active,
input[type="submit"]:active,
input[type="button"]:active {
  background: var(--accent-press);
}

button:focus-visible,
.button:focus-visible,
input[type="submit"]:focus-visible,
input[type="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled,
.button:disabled,
input[type="submit"]:disabled {
  background: var(--text-sec);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Secondary / outline button variant */
.button.is-secondary,
.button-secondary,
button.secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

.button.is-secondary:hover,
.button-secondary:hover,
button.secondary:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* --- List selection (subscribe + manage lists) --- */
ul.lists,
.list-group,
.sub-lists {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

ul.lists li,
.list-group li,
.sub-lists li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color 0.15s ease, background 0.15s ease;
}

ul.lists li:hover,
.list-group li:hover,
.sub-lists li:hover {
  border-color: var(--text-sec);
}

ul.lists li label,
.list-group li label,
.sub-lists li label {
  margin-bottom: 0;
  cursor: pointer;
  font-weight: 400;
  font-size: 0.95rem;
  flex: 1;
  line-height: 1.5;
}

ul.lists li .list-description,
ul.lists li small,
.list-group li small {
  display: block;
  font-size: 0.85rem;
  color: var(--text-sec);
  margin-top: 2px;
}

/* When a list row contains a checked checkbox, tint it */
ul.lists li:has(input:checked),
.list-group li:has(input:checked),
.sub-lists li:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* --- Messages (info, success, error, warning) --- */
.message,
.msg,
.flash,
.notice {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.message.is-success,
.msg.success,
.flash.success,
.notice.success,
.message--success {
  color: var(--success);
  background: rgba(58, 125, 92, 0.08);
  border-color: rgba(58, 125, 92, 0.25);
}

.message.is-info,
.msg.info,
.flash.info,
.notice.info,
.message--info {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-ring);
}

.message.is-warning,
.msg.warning,
.flash.warning,
.notice.warning {
  color: #8A5A1E;
  background: rgba(138, 90, 30, 0.08);
  border-color: rgba(138, 90, 30, 0.25);
}

.message.is-error,
.message.is-danger,
.msg.error,
.msg.danger,
.flash.error,
.notice.error,
.message--error,
.error {
  color: var(--error);
  background: var(--error-soft);
  border-color: rgba(176, 74, 58, 0.25);
}

/* --- Message / status pages (subscription confirmed, unsubscribed) --- */
.message-page,
.page-message {
  text-align: left;
}

.message-page h1,
.page-message h1 {
  color: var(--text);
  margin-bottom: 0.75rem;
}

.message-page p,
.page-message p {
  color: var(--text-sec);
  font-size: 0.95rem;
}

/* --- Campaign archive listing --- */
.campaigns,
.archive,
ul.campaigns,
.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.campaigns li,
.archive li,
.archive-item,
ul.campaigns li {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.campaigns li:first-child,
.archive li:first-child,
.archive-item:first-child,
ul.campaigns li:first-child {
  padding-top: 0;
}

.campaigns li:last-child,
.archive li:last-child,
.archive-item:last-child,
ul.campaigns li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.campaigns li a,
.archive li a,
.archive-item a {
  display: block;
  text-decoration: none;
  color: var(--text);
}

.campaigns li a:hover .campaign-subject,
.archive li a:hover .campaign-subject,
.archive-item a:hover .subject {
  color: var(--accent);
}

.campaign-subject,
.archive-item .subject,
.campaigns li .subject {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 4px;
  transition: color 0.15s ease;
}

.campaign-date,
.archive-item time,
.campaigns li time,
.campaigns li .date {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--text-sec);
  display: block;
}

/* --- Campaign body (viewing an archived campaign in browser) --- */
.campaign-body {
  max-width: var(--max-prose);
}

.campaign-body img {
  max-width: 100%;
  height: auto;
}

/* --- Help text --- */
.help,
.help-text,
.hint {
  font-size: 0.85rem;
  color: var(--text-sec);
  margin-top: 4px;
  line-height: 1.5;
}

/* --- Footer --- */
.footer {
  padding: 24px 0 32px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-sec);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer a {
  color: var(--text-sec);
  text-decoration: none;
}

.footer a:hover {
  color: var(--text);
  text-decoration: underline;
}

.footer .powered-by {
  font-family: var(--font-heading);
  font-size: 0.75rem;
}

/* --- Form actions row (submit buttons, cancel links) --- */
.form-actions,
.actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.form-actions a,
.actions a {
  font-size: 0.9rem;
}

/* --- Loading state on buttons --- */
button.is-loading,
.button.is-loading {
  color: transparent;
  position: relative;
  pointer-events: none;
}

button.is-loading::after,
.button.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- ARIA live region (announcements) --- */
.sr-only,
.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;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }

  .header {
    padding: 20px 0 16px;
  }

  .box,
  .content {
    padding: 24px 20px;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.15rem; }

  button,
  .button,
  input[type="submit"] {
    width: 100%;
    text-align: center;
  }

  .form-actions,
  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions a,
  .actions a {
    text-align: center;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Print --- */
@media print {
  body { background: #fff; }
  .box, .content { border: none; box-shadow: none; padding: 0; }
  .footer, .header .lang-selector { display: none; }
}
