/* ─── IDEA·LOG — Teenage Engineering × Obsidian ─── */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

/* ── Variables ── */
:root {
  --bg:          #1a1a1a;
  --bg2:         #212121;
  --border:      #3a3a3a;
  --border-dim:  #2b2b2b;
  --text:        #e8e5df;
  --text-muted:  #b2ada3;
  --text-dim:    #8a8a8a;
  --accent:      #7C3AEC;
  --accent-dim:  #2F283E;
  --accent-glow: rgba(124, 58, 236, 0.25);
  --font:        'IBM Plex Mono', ui-monospace, monospace;
  --header-h:    52px;
  --toolbar-h:   44px;
  --ease:        cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg:          #edeae3;
  --bg2:         #e5e2da;
  --border:      #b8b4ac;
  --border-dim:  #c9c5bd;
  --text:        #1a1a1a;
  --text-muted:  #5d5a52;
  --text-dim:    #6a665e;
  --accent:      #5b21b6;
  --accent-dim:  rgba(91, 33, 182, 0.09);
  --accent-glow: rgba(91, 33, 182, 0.2);
}

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

html {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body { min-height: 100dvh; }

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }
img { display: block; }

/* ── Grain texture ── */
.grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.038;
  pointer-events: none;
  z-index: 9000;
  animation: grain-shift 12s steps(8) infinite;
}

[data-theme="light"] .grain { opacity: 0.022; }

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  12%  { transform: translate(-3%, 2%); }
  25%  { transform: translate(2%, -3%); }
  37%  { transform: translate(-1%, 4%); }
  50%  { transform: translate(4%, -2%); }
  62%  { transform: translate(-2%, 3%); }
  75%  { transform: translate(3%, -1%); }
  87%  { transform: translate(-4%, 2%); }
}

/* ── Scanlines (dark only) ── */
[data-theme="dark"] body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 3px,
    rgba(0,0,0,0.022) 3px,
    rgba(0,0,0,0.022) 4px
  );
  pointer-events: none;
  z-index: 8999;
}

/* ── Theme transitions ── */
html, html * {
  transition:
    background-color 0.18s var(--ease),
    border-color 0.18s var(--ease),
    color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

/* ── Header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.logo {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text);
  user-select: none;
}

.logo-dot {
  color: var(--accent);
  font-weight: 400;
}

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

/* ── Icon buttons ── */
.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  flex-shrink: 0;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-icon { line-height: 1; }

/* ── Auth area ── */
.auth-area {
  display: flex;
  align-items: center;
}

.login-btn {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.12em;
  border-radius: 2px;
  white-space: nowrap;
}

.login-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.user-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 2px;
  border: 1px solid var(--border);
  object-fit: cover;
}

.user-name {
  font-size: 13px;
  color: var(--text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.logout-btn {
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: none;
  letter-spacing: 0.1em;
  padding: 4px 6px;
}

.logout-btn:hover {
  color: var(--accent);
}

/* ── Toolbar ── */
.toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 199;
  height: var(--toolbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-controls {
  display: flex;
  gap: 0;
}

.sort-btn {
  height: 30px;
  padding: 0 13px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.12em;
  margin-right: -1px;
  position: relative;
}

.sort-btn:first-child { border-radius: 2px 0 0 2px; }
.sort-btn:last-child  { border-radius: 0 2px 2px 0; }

.sort-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  z-index: 1;
}

.sort-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  z-index: 2;
}

.filter-btn {
  height: 26px;
  padding: 0 11px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  margin-right: -1px;
  position: relative;
}

.filter-btn:first-child { border-radius: 2px 0 0 2px; }
.filter-btn:last-child  { border-radius: 0 2px 2px 0; }

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  z-index: 1;
}

.filter-btn.active {
  background: var(--text-muted);
  border-color: var(--text-muted);
  color: var(--bg);
  z-index: 2;
}

.post-count {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.14em;
}

.submit-btn {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.12em;
  border-radius: 2px;
}

.submit-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Feed ── */
.feed {
  max-width: 900px;
  margin: 0 auto;
}

/* ── State messages ── */
.state-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  gap: 0;
}

.loading-dots {
  animation: blink 1.1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Post ── */
.post {
  display: grid;
  grid-template-columns: 68px 1fr;
  border-bottom: 1px solid var(--border-dim);
  cursor: pointer;
  animation: post-in 0.25s var(--ease) both;
}

.post:hover {
  background: var(--accent-dim);
}

@keyframes post-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Vote column ── */
.post-vote {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 14px;
  gap: 5px;
  border-right: 1px solid var(--border-dim);
}

.vote-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.vote-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: translateY(100%);
  transition: transform 0.15s var(--ease);
  border-radius: 1px;
}

.vote-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.vote-btn.voted {
  border-color: var(--accent);
  color: #fff;
}

.vote-btn.voted::before {
  transform: translateY(0);
}

.vote-btn span { position: relative; z-index: 1; }

.vote-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  min-width: 24px;
  text-align: center;
  letter-spacing: 0.04em;
}

.vote-count.tick {
  animation: count-tick 0.22s var(--ease);
}

@keyframes count-tick {
  0%   { transform: translateY(-5px); opacity: 0; }
  100% { transform: translateY(0);    opacity: 1; }
}

/* ── Post body ── */
.post-body {
  padding: 16px 20px 16px;
  min-width: 0;
}

.post-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.45;
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.tag {
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.06em;
}

.post-meta {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.post-date {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.post-author {
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.06em;
}

.post-draft {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--bg);
  background: var(--text);
  padding: 2px 7px;
  border-radius: 2px;
}

.post-made {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: #fff;
  background: var(--accent);
  padding: 2px 7px;
  border-radius: 2px;
}

.made-toggle {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 2px;
  cursor: pointer;
}

.made-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.made-toggle.is-made {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.post.made .post-title {
  text-decoration: line-through;
  text-decoration-color: var(--text-muted);
  opacity: 0.68;
}

.post.made .post-num,
.post.made .post-tags {
  opacity: 0.5;
}

.post-approve-bar {
  margin-top: 10px;
}

.approve-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 0.14em;
  border-radius: 2px;
}

.approve-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Expanded content ── */
.post-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s var(--ease);
}

.post-content-inner {
  padding: 16px 0 8px;
  border-top: 1px solid var(--border-dim);
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

.post-content-inner p        { margin-bottom: 12px; }
.post-content-inner p:last-child { margin-bottom: 0; }

.post-content-inner h1,
.post-content-inner h2,
.post-content-inner h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  margin: 16px 0 8px;
}

.post-content-inner code {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  font-family: var(--font);
  font-size: 13px;
  border-radius: 2px;
}

.post-content-inner pre {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 14px;
  overflow-x: auto;
  margin-bottom: 12px;
  border-radius: 2px;
}

.post-content-inner pre code {
  border: none;
  background: none;
  padding: 0;
}

.post-content-inner ul,
.post-content-inner ol {
  padding-left: 18px;
  margin-bottom: 12px;
}

.post-content-inner li { margin-bottom: 4px; }

.post-content-inner a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
}

.post-content-inner a:hover { border-color: var(--accent); }

.post-content-inner blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 14px;
  margin: 12px 0;
  color: var(--text-muted);
}

.post-content-inner hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ── Expand indicator ── */
.post-title::after {
  content: ' ›';
  color: var(--text-muted);
  font-weight: 400;
  transition: color 0.15s, transform 0.2s;
  display: inline-block;
}

.post.expanded .post-title::after {
  content: ' ‹';
  color: var(--accent);
}

/* ── Auth modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in 0.15s ease;
}

[data-theme="light"] .modal-overlay {
  background: rgba(0, 0, 0, 0.35);
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 28px;
  width: 300px;
  max-width: 90vw;
  border-radius: 3px;
  animation: modal-in 0.2s var(--ease);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--text);
  font-weight: 500;
}

.modal-close {
  font-size: 18px;
  line-height: 1;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.auth-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 46px;
  padding: 0 16px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.12em;
  border-radius: 2px;
  transition: border-color 0.15s, color 0.15s;
}

.auth-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.auth-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  letter-spacing: 0.1em;
  padding: 10px 18px;
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s var(--ease);
  pointer-events: none;
  z-index: 600;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Create post form ── */
.create-modal {
  width: 480px;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--text);
  margin-bottom: 6px;
}

.form-required {
  color: var(--accent);
  font-weight: 500;
}

.form-input,
.form-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 2px;
  outline: none;
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--accent);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.btn-secondary {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 0.12em;
  border-radius: 2px;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  border-radius: 2px;
}

.btn-primary:hover { opacity: 0.85; }

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  html { font-size: 16px; }

  .header   { padding: 0 14px; }
  .toolbar  { padding: 0 14px; }

  .post { grid-template-columns: 64px 1fr; }

  .post-body { padding: 14px 16px; }

  .post-count { display: none; }

  .post-title { font-size: 16px; }

  .tag, .post-date, .post-author { font-size: 13px; }

  .user-name { display: none; }

  .sort-btn { padding: 0 10px; font-size: 12px; }

  .submit-btn { font-size: 12px; padding: 0 10px; }

  .create-modal { width: 100%; max-width: 92vw; }

  .post-content-inner { font-size: 15px; }
}
