/* ═══════════════════════════════════════════════════════════════
   Newsletter Directory — System 7 inspired UI
   Clean modern feel, six-color accents, Chicago-like typography
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Six colors — classic Mac rainbow, muted for modern use */
  --c-red:    #E63946;
  --c-orange: #F4A261;
  --c-yellow: #E9C46A;
  --c-green:  #2A9D8F;
  --c-blue:   #3A7CA5;
  --c-purple: #8E5BA0;

  /* System 7 grays */
  --mac-white:     #ffffff;
  --mac-light-gray: #eeeee9;
  --mac-gray:      #d0d0c8;
  --mac-dark-gray: #888884;
  --mac-shadow:    #a0a0a0;
  --mac-text:      #1a1a1a;
  --mac-frame:     #000000;

  /* Window chrome */
  --title-bar-h: 28px;
  --menubar-h: 28px;
}

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

html, body {
  height: 100%;
  font-family: "DM Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--mac-text);
  background: var(--mac-light-gray);
  -webkit-font-smoothing: antialiased;
}

/* ─── Menu Bar ────────────────────────────────────────────────── */

#menubar {
  height: var(--menubar-h);
  background: var(--mac-frame);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 16px;
  font-size: 13px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  user-select: none;
}

.menu-apple {
  font-size: 16px;
}

.menu-title {
  font-weight: 700;
  letter-spacing: 0.3px;
}

.menu-item {
  color: #ccc;
}

.menu-right {
  margin-left: auto;
}

.menu-right a {
  color: #ccc;
  text-decoration: none;
}

.menu-right a:hover { color: #fff; }

/* ─── Window ──────────────────────────────────────────────────── */

#window {
  margin: calc(var(--menubar-h) + 12px) auto 20px;
  max-width: 1100px;
  background: var(--mac-white);
  border: 1px solid var(--mac-frame);
  box-shadow: 0 2px 16px rgba(0,0,0,0.15);
  border-radius: 6px;
  overflow: hidden;
}

/* Title bar */
.title-bar {
  height: var(--title-bar-h);
  background: linear-gradient(180deg, #e8e8e0 0%, #d8d8d0 100%);
  border-bottom: 1px solid var(--mac-shadow);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 8px;
  user-select: none;
}

.title-bar-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--mac-text);
  flex: 1;
  text-align: center;
}

.title-bar-controls {
  display: flex;
  gap: 6px;
}

.title-bar-btn {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.2);
  cursor: pointer;
  padding: 0;
}

.title-bar-btn.close { background: var(--c-red); }
.title-bar-btn.zoom { background: var(--c-green); }

/* ─── Window Body ─────────────────────────────────────────────── */

.window-body {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--menubar-h) - var(--title-bar-h) - 32px);
  max-height: 800px;
}

/* ─── Toolbar ─────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--mac-gray);
  background: var(--mac-light-gray);
}

#search {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--mac-shadow);
  border-radius: 4px;
  background: var(--mac-white);
  outline: none;
}

#search:focus {
  border-color: var(--c-blue);
  box-shadow: 0 0 0 2px rgba(58,124,165,0.15);
}

.sort-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.sort-group select {
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid var(--mac-shadow);
  border-radius: 4px;
  background: var(--mac-white);
  cursor: pointer;
}

/* ─── Main Area: Sidebar + Content ────────────────────────────── */

.main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */

.sidebar {
  width: 220px;
  min-width: 220px;
  border-right: 1px solid var(--mac-gray);
  background: var(--mac-light-gray);
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-section {
  margin-bottom: 4px;
}

.sidebar-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--mac-dark-gray);
  padding: 8px 14px 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 14px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.sidebar-item:hover {
  background: rgba(58,124,165,0.08);
}

.sidebar-item input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 14px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.cat-item:hover {
  background: rgba(58,124,165,0.08);
}

.cat-item input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-count {
  margin-left: auto;
  font-size: 10px;
  color: var(--mac-dark-gray);
}

/* Score range */
.score-range {
  padding: 4px 14px;
}

.score-range label {
  font-size: 11px;
  color: var(--mac-dark-gray);
}

.score-range input[type="range"] {
  width: 100%;
  margin-top: 4px;
}

/* ─── Content Area ────────────────────────────────────────────── */

.content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Entry cards */
.entry {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--mac-light-gray);
  text-decoration: none;
  color: inherit;
  transition: background 0.08s;
}

.entry:hover {
  background: #f5f5f0;
}

.entry-score {
  flex-shrink: 0;
  width: 36px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--mac-dark-gray);
  padding-top: 2px;
}

.entry-body {
  flex: 1;
  min-width: 0;
}

.entry-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-title a {
  color: var(--c-blue);
  text-decoration: none;
}

.entry-title a:hover {
  text-decoration: underline;
}

.entry-desc {
  font-size: 12px;
  color: #555;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.entry-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--mac-dark-gray);
}

.entry-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
}

.entry-tag.titaa { background: var(--c-purple); }
.entry-tag.webcurios { background: var(--c-orange); }

.entry-cat {
  font-weight: 500;
}

.entry-date {
  color: var(--mac-dark-gray);
}

/* Category color dots */
.cat-Web Toys       { background: var(--c-blue); }
.cat-Games          { background: var(--c-green); }
.cat-AI-Tools       { background: var(--c-red); }
.cat-AI-Art         { background: var(--c-orange); }
.cat-3D-Three.js    { background: var(--c-purple); }
.cat-Data-Science   { background: var(--c-yellow); }
.cat-Narrative      { background: var(--c-red); }
.cat-Weird-Esoteric { background: var(--c-purple); }
.cat-AI-News        { background: var(--c-orange); }
.cat-Poetry         { background: var(--c-yellow); }
.cat-Books          { background: var(--c-green); }
.cat-TV             { background: var(--c-red); }
.cat-Video          { background: var(--c-blue); }
.cat-Longreads      { background: var(--mac-dark-gray); }
.cat-Tumblr         { background: var(--c-purple); }
.cat-Social         { background: var(--mac-dark-gray); }
.cat-Science        { background: var(--c-green); }
.cat-Other          { background: var(--mac-dark-gray); }

/* ─── Scrollbar ───────────────────────────────────────────────── */

.content::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 8px;
}

.content::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
  background: var(--mac-light-gray);
}

.content::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
  background: var(--mac-gray);
  border-radius: 4px;
}

/* ─── Dialog ──────────────────────────────────────────────────── */

.dialog-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog {
  background: var(--mac-white);
  border: 1px solid var(--mac-frame);
  border-radius: 6px;
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.dialog-body {
  padding: 20px;
  font-size: 13px;
  line-height: 1.5;
}

.dialog-body ul {
  margin: 8px 0 8px 20px;
}

.dialog-body li {
  margin-bottom: 4px;
}

/* ─── Loading state ───────────────────────────────────────────── */

.loading {
  text-align: center;
  padding: 40px;
  color: var(--mac-dark-gray);
  font-size: 13px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--mac-dark-gray);
}

/* ─── Responsive ──────────────────────────────────────────────── */

@media (max-width: 700px) {
  .sidebar {
    display: none;
  }
  #window {
    margin: calc(var(--menubar-h) + 8px) 0 0;
    border-radius: 0;
    max-width: 100%;
  }
  .window-body {
    height: calc(100vh - var(--menubar-h) - var(--title-bar-h) - 8px);
    max-height: none;
  }
}
