/* style.css v2-r4 — TaskFramer main index page */

:root {
  --bg: #f5f5f7;
  --bg-alt: #ffffff;
  --text: #111111;
  --text-muted: #666666;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.07);
  --border: #dddddf;
  --max-width: 960px;
}


/* ── Dark mode ────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0f1117;
  --bg-alt: #1a1d27;
  --text: #e8eaf0;
  --text-muted: #8b92a5;
  --accent: #4d8ef7;
  --accent-soft: rgba(77, 142, 247, 0.10);
  --border: #2a2d3a;
  --shadow-soft: 0 8px 20px rgba(0,0,0,0.3);
}

[data-theme="dark"] .frames-search-input { background: #1a1d27; color: var(--text); }
[data-theme="dark"] .frame-button { background: #252836; color: var(--text-muted); }
[data-theme="dark"] .frame-button.active { background: var(--accent); color: #fff; }
[data-theme="dark"] .frames-dir-btn { background: #252836; color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .sidebar-btn { background: #252836; }
[data-theme="dark"] .sidebar-btn:hover { background: var(--accent); }
[data-theme="dark"] .modal-container { background: var(--bg-alt); }
[data-theme="dark"] #modal-support-bar { background: #1a1d27 !important; border-color: var(--border) !important; }

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.page { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Header ───────────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand { display: flex; align-items: center; gap: 0.65rem; }

.brand-mark {
  width: 36px; height: 36px;
  background: var(--text);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  display: flex; align-items: center; justify-content: center;
}

.brand-title { font-size: 0.9rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub   { font-size: 0.72rem; color: var(--text-muted); }
.nav-right   { font-size: 0.78rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.75rem; }

/* ── Theme toggle ─────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.28rem 0.6rem;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── Hero ─────────────────────────────────────────────── */
.hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.1rem 1.2rem;
}

.hero-eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.hero-title {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 0.5rem;
}

.hero-title span { color: var(--accent); }

.hero-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 560px;
  margin-bottom: 0.6rem;
}

.hero-meta {
  display: flex;
  gap: 0.5rem 1.1rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hero-meta span::before { content: '·'; margin-right: 0.5rem; }
.hero-meta span:first-child::before { display: none; }

/* ── Frames section ───────────────────────────────────── */
.frames-section {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0.75rem 1.1rem 3rem;
  flex: 1;
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: 190px;
  flex-shrink: 0;
  position: sticky;
  top: 0.75rem;
  padding-top: 0;
  align-self: flex-start;
}

@media (max-width: 720px) {
  .frames-section { flex-direction: column; }
  .sidebar { width: 100%; position: static; }
}

.sidebar-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.38rem 0.5rem;
  font-size: 0.75rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  border-radius: 0;
  text-decoration: none;
  line-height: 1.3;
  transition: background 0.1s, color 0.1s;
}

.sidebar-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-rank {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-right: 0.3rem;
  font-family: ui-monospace, monospace;
}

.sidebar-footer {
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Main content (search + grid) ─────────────────────── */
.frames-main {
  flex: 1;
  min-width: 0;
}

.frames-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.frames-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

.frames-sub { font-size: 0.78rem; color: var(--text-muted); }

.frames-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
}

/* ── Frame card ───────────────────────────────────────── */
.frame-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 1.1rem 1.1rem 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.9rem;
}

.frame-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.frame-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.frame-title { font-size: 0.92rem; font-weight: 700; line-height: 1.3; }

.frame-id {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
  white-space: nowrap;
  padding-top: 0.15rem;
}

.frame-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

.frame-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 0.65rem;
}

.frame-pill {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
}

.frame-button {
  font-size: 0.74rem;
  padding: 0.38rem 0.85rem;
  background: #f3f4f6;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.06em;
  cursor: not-allowed;
}

.frame-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
}

.frame-button.active:hover { background: #1d4ed8; border-color: #1d4ed8; }

/* ── Footer ───────────────────────────────────────────── */
footer { border-top: 1px solid var(--border); background: var(--bg-alt); }

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* ── Modal (index page) ───────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 9999;
  padding-top: 3vh;
}

.modal-overlay.open { display: flex; }

.modal-container {
  background: var(--bg-alt);
  width: 95vw;
  max-width: 1020px;
  height: 92vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  overflow: hidden; /* prevent iframe content from pushing width */
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 0; /* allow flex children to shrink */
}

.modal-header span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0 0.2rem;
}

.modal-body { flex: 1; overflow: hidden; }
.modal-body iframe { width: 100%; height: 100%; border: none; display: block; }

/* ── Frames search bar ────────────────────────────────── */
.frames-header {
  margin-bottom: 1.1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.frames-search-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.frames-search-wrap {
  flex: 1;
  position: relative;
}

.frames-search-input {
  width: 100%;
  padding: 0.5rem 2.5rem 0.5rem 0.75rem;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

.frames-search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.frames-search-count {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.68rem;
  color: var(--text-muted);
  pointer-events: none;
}

.frames-dir-btn {
  font-size: 0.74rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  background: var(--text);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.05em;
  font-family: inherit;
}

.frames-dir-btn:hover { background: #333; }

/* ── Search highlight ─────────────────────────────────── */
.search-highlight {
  background: #fef08a;
  color: var(--text);
}

/* ── Hidden card (search) ─────────────────────────────── */
.frame-card.search-hidden {
  display: none;
}

/* ── No results message ───────────────────────────────── */
.no-results-msg {
  grid-column: 1 / -1;
  padding: 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  border: 1px dashed var(--border);
}

/* ── Directory modal list items ───────────────────────── */
.dir-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.dir-item:hover { background: var(--accent-soft); }

.dir-item-num {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
  min-width: 24px;
  text-align: right;
}

.dir-item-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--text-muted);
  min-width: 110px;
}

.dir-item-title {
  font-size: 0.84rem;
  font-weight: 600;
  flex: 1;
}

.dir-item-arrow {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dir-highlight { background: #fef08a; }

/* ── Search bar (replaces frames-header text) ─────────── */
.frames-header {
  margin-bottom: 1.1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.frames-search-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.frames-search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.frames-search-input {
  width: 100%;
  padding: 0.5rem 3rem 0.5rem 0.75rem;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  line-height: 1.4;
}

.frames-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}

.frames-search-count {
  position: absolute;
  right: 0.65rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  pointer-events: none;
  white-space: nowrap;
}

.frames-dir-btn {
  flex-shrink: 0;
  font-size: 0.74rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  background: var(--text);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.05em;
  font-family: inherit;
  line-height: 1.4;
}

.frames-dir-btn:hover { background: #333; }

/* ── Search highlight ─────────────────────────────────── */
mark.tf-highlight {
  background: #fef08a;
  color: inherit;
  padding: 0;
}

/* ── Hidden card (filtered out) ───────────────────────── */
.frame-card.tf-hidden { display: none; }

/* ── No results ───────────────────────────────────────── */
.tf-no-results {
  grid-column: 1 / -1;
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.84rem;
  color: var(--text-muted);
  border: 1px dashed var(--border);
}

/* ── Directory modal overlay ──────────────────────────── */
#directoryModal {
  align-items: flex-start;
  justify-content: center;
}

/* ── Directory list rows ──────────────────────────────── */
.dir-item {
  display: grid;
  grid-template-columns: 28px 130px 1fr 18px;
  align-items: center;
  gap: 0 0.7rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  user-select: none;
}

@media (max-width: 500px) {
  .dir-item { grid-template-columns: 24px 1fr 18px; }
  .dir-label { display: none; }
}

.dir-item:hover { background: var(--accent-soft); }

.dir-num {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
  text-align: right;
}

.dir-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-title {
  font-size: 0.84rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-arrow {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: right;
}

.dir-empty {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ── Sort Controls ──────────────────────────────────────── */
.frames-sort-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0 2px;
  flex-wrap: wrap;
}
.sort-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
}
.sort-btn {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-size: 0.76rem;
  font-weight: 500;
  font-family: inherit;
  padding: 4px 12px;
  border-radius: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.5;
  display: inline-block;
  box-sizing: border-box;
}
.sort-btn:hover {
  background: var(--text-muted);
  color: #fff;
  border-color: var(--text-muted);
}
.sort-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
[data-theme="dark"] .sort-btn {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
[data-theme="dark"] .sort-btn:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text);
}
[data-theme="dark"] .sort-btn.active {
  background: var(--text);
  color: #000;
}
.category-separator {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 4px 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.category-separator:first-child { border-top: none; margin-top: 0; }

/* ── Donate modal (index page) ────────────────────────── */
.donation-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.donation-modal-overlay.open { display: flex; }
.modal-card {
  max-width: 440px;
  width: 100%;
  background: #ffffff;
  border: 1px solid #dddddf;
  box-shadow: 0 18px 45px rgba(15,23,42,0.18);
  padding: 1.5rem 1.4rem 1.4rem;
}
.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.modal-title { font-size: 0.9rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.modal-close-btn {
  background: none; border: none; font-size: 0.82rem; cursor: pointer;
  color: #666; padding: 0.2rem 0.4rem; font-family: inherit;
}
.modal-close-btn:hover { color: #2563eb; }
.donate-body { text-align: center; padding: 0.5rem 0 0; }
.donate-icon { font-size: 2.8rem; line-height: 1; margin-bottom: 0.5rem; }
.donate-headline { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.75rem; line-height: 1.3; }
.donate-headline small { font-size: 0.8rem; font-weight: 400; color: #666; }
.donate-text { font-size: 0.83rem; color: #666; line-height: 1.6; margin-bottom: 1.25rem; }
.donate-cta {
  display: block; width: 100%; padding: 0.75rem 1rem;
  font-size: 0.85rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  background: #2563eb; color: #fff; border: none; cursor: pointer; font-family: inherit;
  margin-bottom: 0.6rem;
}
.donate-cta:hover { background: #1d4ed8; }
.donate-fine { font-size: 0.7rem; color: #999; margin: 0; }
