/* d3dev base — layout + variable-driven colors */
/* Theme files set :root vars; this file uses them */

:root {
  --bg: #fff;
  --fg: #1f2328;
  --fg-muted: #656d76;
  --link: #0969da;
  --link-hover: #0550ae;
  --border: #d1d9e0;
  --surface: #f6f8fa;
  --code-bg: #eff1f3;
  --heading: #1f2328;
  --accent: #0969da;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  padding: 0;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ─── Header ─── */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.logo {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo svg {
  width: 20px;
  height: 20px;
  fill: var(--bg);
}

.site-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--heading);
  text-decoration: none;
}

.site-name:hover { opacity: 0.8; }

.header-spacer { flex: 1; }

/* ─── Nav Tabs ─── */
.nav-tabs {
  display: flex;
  gap: 4px;
  margin-left: 16px;
}

.nav-tab {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.nav-tab:hover {
  background: var(--surface);
  color: var(--fg);
}

.nav-tab.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
}

.theme-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 4px 28px 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.theme-select:hover { border-color: var(--accent); }

/* ─── Article List ─── */
.article-list {
  list-style: none;
}

.article-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.article-item:last-child { border-bottom: none; }

.article-item a {
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
}

.article-item a:hover {
  text-decoration: underline;
  color: var(--link-hover);
}

.meta {
  display: block;
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 3px;
}

.tag {
  background: var(--surface);
  color: var(--fg-muted);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  margin-left: 4px;
  border: 1px solid var(--border);
}

.summary {
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: 4px;
}

.hn-comments {
  font-size: 11px;
  color: var(--fg-muted);
  font-weight: normal;
}

/* ─── Article View ─── */
.back { margin-bottom: 20px; }
.back a {
  color: var(--link);
  text-decoration: none;
  font-size: 14px;
}
.back a:hover { text-decoration: underline; color: var(--link-hover); }

article h1 { font-size: 2em; border-bottom: 1px solid var(--border); padding-bottom: .3em; color: var(--heading); margin: 1em 0 0.4em; }
article h2 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: .3em; color: var(--heading); margin: 1.2em 0 0.4em; }
article h3 { font-size: 1.25em; color: var(--heading); margin: 1em 0 0.4em; }
article h4, article h5, article h6 { color: var(--heading); margin: 1em 0 0.4em; }
article p { margin: 0.8em 0; }
article ul, article ol { padding-left: 2em; margin: 0.8em 0; }
article li { margin: 0.25em 0; }
article code {
  background: var(--code-bg);
  padding: 0.2em 0.4em;
  border-radius: 6px;
  font-size: 85%;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}
article pre {
  background: var(--surface);
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 85%;
  line-height: 1.45;
  margin: 1em 0;
  border: 1px solid var(--border);
}
article pre code { background: none; padding: 0; }
article blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 16px;
  color: var(--fg-muted);
  margin: 1em 0;
}
article a { color: var(--link); }
article a:hover { text-decoration: underline; color: var(--link-hover); }
article table { border-collapse: collapse; width: 100%; margin: 16px 0; }
article th, article td { border: 1px solid var(--border); padding: 6px 13px; }
article th { background: var(--surface); font-weight: 600; }
article tr:nth-child(2n) { background: var(--surface); }
article hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
article img { max-width: 100%; }
article strong { color: var(--heading); }

.error { color: #d1242f; font-style: italic; }

/* ─── Wide layout (for datatable pages) ─── */
#app.wide { max-width: 1400px; }
#app.wide article { max-width: none; }

/* ─── Clickable tags (inside datatables) ─── */
.datatable-wrap { margin: 1.5em 0; overflow-x: auto; }
.datatable td, .datatable th { vertical-align: top; padding: 0.5em 0.75em; }
.datatable td .tag { margin-left: 0; margin-right: 4px; display: inline-block; margin-bottom: 2px; }
.tag-clickable { cursor: pointer; user-select: none; transition: background 0.15s, color 0.15s; }
.tag-clickable:hover { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ─── Badges (paid status etc) ─── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.5;
  border: 1px solid transparent;
}
.badge-free    { background: rgba(31, 122, 58, 0.18);  color: #2ea043; border-color: rgba(46, 160, 67, 0.4); }
.badge-paid    { background: rgba(122, 31, 31, 0.18);  color: #f85149; border-color: rgba(248, 81, 73, 0.4); }
.badge-mixed   { background: rgba(122, 90, 31, 0.18);  color: #e3b341; border-color: rgba(227, 179, 65, 0.4); }
.badge-neutral { background: var(--surface); color: var(--fg-muted); border-color: var(--border); }

/* ─── DataTables theme integration ─── */
.dataTables_wrapper { color: var(--fg); margin-top: 0.5em; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 8px;
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
  outline: none; border-color: var(--accent);
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { color: var(--fg-muted); }
.dataTables_wrapper .dataTables_paginate .paginate_button {
  color: var(--fg) !important; border-radius: 4px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--accent) !important; color: var(--bg) !important;
  border-color: var(--accent) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--surface) !important; color: var(--fg) !important;
  border-color: var(--border) !important;
}
table.datatable thead th {
  background: var(--surface); color: var(--heading);
  border-bottom: 2px solid var(--border) !important;
}
table.datatable.dataTable tbody tr { background: transparent; }
table.datatable.dataTable tbody tr:hover { background: var(--surface); }
table.datatable.dataTable tbody td { border-top: 1px solid var(--border); }
/* Sort arrows readable in dark themes */
table.datatable.dataTable thead .sorting:before,
table.datatable.dataTable thead .sorting:after,
table.datatable.dataTable thead .sorting_asc:before,
table.datatable.dataTable thead .sorting_asc:after,
table.datatable.dataTable thead .sorting_desc:before,
table.datatable.dataTable thead .sorting_desc:after { color: var(--fg-muted) !important; opacity: 0.5; }
