/* News Aesthetic Computer, 2026.01.15 */
/* HN-inspired layout with AC styling, light/dark themes, mobile-friendly */

/* ===== CSS Reset & Normalization ===== */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body { margin: 0; line-height: 1.5; }
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

/* ===== Light Theme (default) ===== */
:root {
  --bg-page: #f6f6ef;
  --bg-header: rgb(205, 92, 155);
  --bg-secondary: #fafaf5;
  --bg-input: white;
  --text-primary: #000;
  --text-secondary: #828282;
  --text-link: #000;
  --text-link-visited: #828282;
  --text-meta: #828282;
  --text-header: #fff;
  --border-color: #e0e0dc;
  --border-subtle: #f0f0ec;
  --accent: rgb(205, 92, 155);
  --accent-hover: rgb(220, 110, 170);
  --vote-color: #9a9a9a;
  --vote-active: rgb(205, 92, 155);
  
  /* User menu colors (AC-style) */
  --menu-bg: #000;
  --menu-border: #fff;
  --menu-text: #fff;
  --menu-hover: #333;
  
  /* Spacing */
  --header-height: 44px;
  --content-max-width: 85ch;
  --mobile-padding: 8px;
}

/* ===== Dark Theme ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #1a1a1a;
    --bg-header: rgb(170, 70, 130);
    --bg-secondary: #222;
    --bg-input: #2a2a2a;
    --text-primary: #d4d4d4;
    --text-secondary: #858585;
    --text-link: #d4d4d4;
    --text-link-visited: #858585;
    --text-meta: #858585;
    --text-header: #fff;
    --border-color: #333;
    --border-subtle: #2a2a2a;
    --accent: rgb(220, 110, 170);
    --accent-hover: rgb(235, 130, 190);
    --vote-color: #666;
    --vote-active: rgb(220, 110, 170);
    
    --menu-bg: #2a2a2a;
    --menu-border: #555;
    --menu-text: #d4d4d4;
    --menu-hover: #444;
  }
}

/* Manual theme overrides */
[data-theme="light"] {
  --bg-page: #f6f6ef;
  --bg-header: rgb(205, 92, 155);
  --bg-secondary: #fafaf5;
  --bg-input: white;
  --text-primary: #000;
  --text-secondary: #828282;
  --text-link: #000;
  --text-link-visited: #828282;
  --text-meta: #828282;
  --text-header: #fff;
  --border-color: #e0e0dc;
  --accent: rgb(205, 92, 155);
}

[data-theme="dark"] {
  --bg-page: #1a1a1a;
  --bg-header: rgb(170, 70, 130);
  --bg-secondary: #222;
  --bg-input: #2a2a2a;
  --text-primary: #d4d4d4;
  --text-secondary: #858585;
  --text-link: #d4d4d4;
  --text-meta: #858585;
  --border-color: #333;
  --accent: rgb(220, 110, 170);
}

/* ===== Typography ===== */
body {
  font-family: "Berkeley Mono Variable", Verdana, Geneva, sans-serif;
  font-size: 13px;
  background: var(--bg-page);
  color: var(--text-primary);
}

a { color: var(--text-link); text-decoration: none; }
a:visited { color: var(--text-link-visited); }
a:hover { text-decoration: underline; }

/* ===== Layout Container (HN-style centered) ===== */
.news-wrapper {
  max-width: var(--content-max-width);
  margin: 0 auto;
  background: var(--bg-page);
}

/* ===== Header (HN orange bar style) ===== */
.news-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--bg-header);
  color: var(--text-header);
  flex-wrap: wrap;
}

.news-logo a {
  font-weight: bold;
  font-size: 14px;
  color: var(--text-header);
  text-decoration: none;
  white-space: nowrap;
}

.news-logo a:hover { text-decoration: none; }

.news-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  flex-wrap: wrap;
}

.news-nav a { color: var(--text-header); }
.news-nav span { color: var(--text-header); opacity: 0.6; }

.news-auth {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== Auth Buttons (classic AC prompt style - blue login, green signup) ===== */
/* Using explicit colors instead of CSS variables for cross-theme reliability */
.header-login-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: normal;
  border: 1px solid white;
  border-radius: 0;
  cursor: pointer;
  background: rgba(30, 50, 120, 0.95);
  color: white;
  transition: all 0.15s;
  white-space: nowrap;
  box-shadow: 0 0 10px rgba(80, 120, 255, 0.25), 0 0 20px rgba(80, 120, 255, 0.1);
  font-family: inherit;
}

.header-login-btn:hover {
  background: rgba(40, 60, 140, 0.95);
  box-shadow: 0 0 15px rgba(100, 150, 255, 0.4), 0 0 30px rgba(100, 150, 255, 0.2);
}

.header-signup-btn {
  background: rgba(30, 90, 50, 0.95);
  box-shadow: 0 0 10px rgba(80, 200, 120, 0.25), 0 0 20px rgba(80, 200, 120, 0.1);
}

.header-signup-btn:hover {
  background: rgba(40, 110, 60, 0.95);
  box-shadow: 0 0 15px rgba(100, 255, 150, 0.4), 0 0 30px rgba(100, 255, 150, 0.2);
}

/* ===== User Menu (AC-style dropdown) ===== */
.header-user-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px 10px;
  background: var(--menu-bg);
  border: 2px solid var(--menu-border);
  border-radius: 0;
  transition: all 0.15s;
}

.header-user-menu:hover {
  background: var(--menu-hover);
  box-shadow: 0 0 6px rgba(255,255,255,0.2);
}

.header-user-handle {
  font-size: 11px;
  color: var(--menu-text);
  font-weight: bold;
}

.header-menu-arrow {
  font-size: 10px;
  color: var(--menu-text);
  opacity: 0.7;
  transition: transform 0.15s;
}

.header-user-menu.open .header-menu-arrow {
  transform: rotate(180deg);
}

.header-user-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--menu-bg);
  border: 2px solid var(--menu-border);
  border-radius: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  min-width: 120px;
  z-index: 9999;
}

.header-user-menu.open .header-user-dropdown {
  display: block;
}

.header-logout-btn {
  width: 100%;
  padding: 10px 14px;
  background: var(--menu-bg);
  border: none;
  text-align: left;
  font-size: 11px;
  color: var(--menu-text);
  cursor: pointer;
  font-weight: bold;
}

.header-logout-btn:hover {
  background: var(--menu-hover);
}

/* ===== Main Content ===== */
.news-main {
  padding: 10px 8px;
}

/* ===== Post List (HN table-like layout) ===== */
.news-list {
  display: flex;
  flex-direction: column;
}

.news-row {
  display: grid;
  grid-template-columns: 24px 18px 1fr;
  gap: 4px;
  align-items: baseline;
  padding: 4px 0;
}

.news-rank {
  text-align: right;
  color: var(--text-meta);
  font-size: 13px;
}

.news-vote {
  display: flex;
  align-items: center;
  justify-content: center;
}

.news-vote-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: var(--vote-color);
  padding: 0;
  line-height: 1;
}

.news-vote-btn:hover { color: var(--vote-active); }
.news-vote-btn.voted { color: var(--vote-active); }

.news-content { min-width: 0; }

.news-title-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
}

.news-title {
  font-size: 13px;
  color: var(--text-link);
}

.news-title:visited { color: var(--text-link-visited); }

.news-domain {
  font-size: 11px;
  color: var(--text-meta);
}

.news-domain a { color: var(--text-meta); }

.news-meta {
  font-size: 11px;
  color: var(--text-meta);
  margin-top: 2px;
}

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

/* ===== Item Page ===== */
.news-item-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.news-item-title {
  font-size: 15px;
  font-weight: normal;
  margin: 0 0 4px;
}

.news-text {
  font-size: 13px;
  color: var(--text-primary);
  margin: 12px 0;
  line-height: 1.6;
}

/* ===== Comments ===== */
.news-comments {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.news-comment {
  padding-left: calc(var(--depth, 0) * 20px);
}

.news-comment-meta {
  font-size: 11px;
  color: var(--text-meta);
  margin-bottom: 4px;
}

.news-comment-body {
  font-size: 13px;
  line-height: 1.5;
}

.news-comment-form {
  margin-top: 16px;
}

/* ===== Submit Page ===== */
.news-submit {
  max-width: 500px;
}

.news-submit h2 {
  font-size: 15px;
  font-weight: bold;
  margin: 0 0 12px;
}

.news-submit form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.news-submit label {
  font-size: 12px;
  color: var(--text-secondary);
}

.news-submit input,
.news-submit textarea {
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: 2px;
}

.news-submit input:focus,
.news-submit textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.news-submit textarea {
  min-height: 80px;
  resize: vertical;
}

.news-submit button {
  align-self: flex-start;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: bold;
  border: none;
  border-radius: 2px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.news-submit button:hover {
  background: var(--accent-hover);
}

/* Comment form shares submit styles */
.news-comment-form form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.news-comment-form textarea {
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: 2px;
  min-height: 60px;
  resize: vertical;
}

.news-comment-form button {
  align-self: flex-start;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: bold;
  border: none;
  border-radius: 2px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

/* ===== Empty State ===== */
.news-empty {
  color: var(--text-meta);
  padding: 20px 0;
  font-style: italic;
}

/* ===== Footer ===== */
.news-footer {
  padding: 20px 8px;
  margin-top: 20px;
  border-top: 2px solid var(--bg-header);
  text-align: center;
  font-size: 11px;
  color: var(--text-meta);
}

.news-footer a { margin: 0 8px; }

/* ===== Mobile Responsive ===== */
@media (max-width: 600px) {
  .news-header {
    padding: 6px var(--mobile-padding);
    gap: 6px;
  }
  
  .news-logo a {
    font-size: 12px;
  }
  
  .news-nav {
    font-size: 11px;
    gap: 3px;
  }
  
  .news-auth {
    gap: 4px;
  }
  
  .header-login-btn {
    padding: 3px 8px;
    font-size: 10px;
  }
  
  .header-user-menu {
    padding: 3px 8px;
  }
  
  .news-main {
    padding: 8px var(--mobile-padding);
  }
  
  .news-row {
    grid-template-columns: 20px 16px 1fr;
    gap: 3px;
  }
  
  .news-rank { font-size: 11px; }
  .news-title { font-size: 12px; }
  .news-domain { font-size: 10px; }
  .news-meta { font-size: 10px; }
}

/* Very narrow - hide signup button */
@media (max-width: 400px) {
  .header-signup-btn {
    display: none;
  }
  
  .news-logo a {
    font-size: 11px;
  }
  
  .news-nav {
    font-size: 10px;
  }
}

/* ===== Touch-friendly tap targets ===== */
@media (hover: none) and (pointer: coarse) {
  .news-vote-btn {
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .header-login-btn,
  .header-user-menu {
    min-height: 36px;
  }
  
  .news-title {
    padding: 4px 0;
  }
}
