/* =========================================================================
   Cloudy County — shared theme
   Source of truth for design tokens, header, navigation, cards, chips,
   buttons, modal, toast, and footer. Imported by every page.
   ========================================================================= */

/* -------------------------------------------------------------------------
   Design tokens
   ------------------------------------------------------------------------- */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d8dde3;
  --text: #1b1f24;
  --text-muted: #5b6470;
  --accent: #2b5fd9;
  --accent-hover: #1f4cbf;
  --accent-contrast: #ffffff;
  --success: #1f7a3a;
  --warn: #b06a00;
  --focus: #ffbf47;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.05);
  --radius: 10px;
  --radius-lg: 16px;
  --max-w: 1280px;
}

[data-theme="dark"] {
  --bg: #0f1216;
  --surface: #181c22;
  --surface-2: #1f242c;
  --border: #2c333d;
  --text: #e7ebf0;
  --text-muted: #9aa4b2;
  --accent: #7aa2ff;
  --accent-hover: #98b6ff;
  --accent-contrast: #0f1216;
  --success: #6cd28a;
  --warn: #ffb86b;
  --focus: #ffbf47;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.35);
}

/* -------------------------------------------------------------------------
   Reset + base
   ------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 2rem; margin: 0 0 0.5em; }
h2 { font-size: 1.5rem; margin: 0 0 0.5em; }
h3 { font-size: 1.15rem; margin: 0 0 0.4em; }
p { margin: 0 0 1em; }

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

/* -------------------------------------------------------------------------
   Accessibility primitives
   ------------------------------------------------------------------------- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 8px 12px;
  border-radius: 6px;
  z-index: 1000;
  text-decoration: none;
}
.skip-link:focus { left: 8px; }

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

/* -------------------------------------------------------------------------
   Layout primitives
   ------------------------------------------------------------------------- */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
}

/* -------------------------------------------------------------------------
   Header + navigation
   ------------------------------------------------------------------------- */
header.site {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #6c92ff);
  display: grid; place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-self: center;
}
.site-nav a {
  display: inline-block;
  padding: 8px 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 8px;
  position: relative;
}
.site-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}
.site-nav a[aria-current="page"] {
  color: var(--accent);
}
.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px;
  bottom: 2px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Compact primary CTA used in the header (e.g., "Join now"). */
.header-cta {
  padding: 8px 14px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--border); }

#nav-toggle { display: none; }

/* -------------------------------------------------------------------------
   Buttons (generic)
   ------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}
.btn:hover { border-color: var(--accent); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-contrast);
}
.btn-ghost { background: transparent; }

/* -------------------------------------------------------------------------
   Cards (homepage feature cards + library prompt cards share these)
   ------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  text-decoration: none;
  color: inherit;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}
.card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.card-title button,
.card-title a {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  text-align: left;
  font: inherit;
  text-decoration: none;
}
.card-title button:hover,
.card-title a:hover { color: var(--accent); }
.card-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}
.card-desc.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* -------------------------------------------------------------------------
   Chips and tags
   ------------------------------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
  font: inherit;
  font-size: 0.82rem;
}
.chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
}
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Library copy/vote buttons — kept here so library markup is purely shared
   styling for these components. */
.vote-btn,
.copy-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.85rem;
  text-decoration: none;
}
.vote-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}
.vote-btn:hover,
.copy-btn:hover { border-color: var(--accent); }
.vote-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
.vote-btn[disabled]:hover { border-color: var(--border); }
.copy-btn.primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}
.copy-btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-contrast);
}

/* -------------------------------------------------------------------------
   Modal
   ------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}
.modal h2 { margin: 0 0 8px; }
.modal .close {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.prompt-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 0.88rem;
  white-space: pre-wrap;
  margin: 12px 0;
  line-height: 1.55;
}
.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.modal-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 8px 0 0;
}

/* -------------------------------------------------------------------------
   Toast
   ------------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  box-shadow: var(--shadow);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* -------------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------------- */
footer.site {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 20px;
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}
footer.site p { margin: 0 0 4px; }
footer.site a { color: var(--text-muted); }
footer.site a:hover { color: var(--accent); }

/* -------------------------------------------------------------------------
   Host badges (homepage) — fixed bottom corners on desktop, in-flow on mobile
   ------------------------------------------------------------------------- */
.hosts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 16px;
  display: flex;
  justify-content: space-between;
  padding: 0 16px;
  pointer-events: none;
  z-index: 50;
}
.host-badge {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 18px 6px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  max-width: 340px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.host-badge:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  color: var(--text);
}
.host-badge img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
  box-shadow: 0 0 0 1px var(--border) inset;
}
.host-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.host-name {
  font-size: 0.95rem;
  font-weight: 600;
}
.host-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 1023px) {
  .host-title { display: none; }
}
@media (max-width: 859px) {
  .hosts {
    position: static;
    flex-direction: row;
    justify-content: center;
    gap: 12px;
    padding: 0 16px 16px;
  }
  .host-badge {
    padding: 4px 14px 4px 4px;
    gap: 10px;
  }
  .host-badge img {
    width: 48px;
    height: 48px;
  }
  .host-name { font-size: 0.9rem; }
}
@media (prefers-reduced-motion: reduce) {
  .host-badge { transition: none; }
  .host-badge:hover { transform: none; }
}

/* -------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------- */
@media (max-width: 860px) {
  .header-inner {
    grid-template-columns: auto 1fr auto;
  }
  #nav-toggle { display: grid; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    justify-self: stretch;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 10px 12px; }
  .site-nav a[aria-current="page"]::after { display: none; }
  .site-nav a[aria-current="page"] {
    background: var(--surface-2);
  }
}
@media (max-width: 480px) {
  .header-inner { padding: 10px 12px; }
}
