@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #101014;
  --surface: #18181e;
  --border: rgba(255, 255, 255, 0.06);
  --fg: #e4e4e9;
  --muted: #6e6e7a;
  --accent: #8b9cf7;
  --accent-dim: rgba(139, 156, 247, 0.12);
  --heat: #7c8cf4;
  --radius: 12px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── layout ── */

main.three-col {
  display: grid;
  grid-template-columns: min-content minmax(0, 1fr) 300px;
  gap: 1.5rem;
  padding: 3rem 2rem;
}

/* ── cards ── */

#center section,
#left-sidebar,
#right {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  align-self: start;
}

#left-sidebar {
  align-self: start;
  position: sticky;
  top: 2rem;
  padding: 1rem 1rem;
  white-space: nowrap;
}

/* ── header ── */

#center > h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--fg);
  margin-bottom: 0.25rem;
}

#center > p {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

/* ── one-year celebration (body.anniversary is set by app.js) ── */

#banner {
  font-size: 0.8rem;
  color: var(--fg);
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

body.anniversary {
  --bg: #120f17;
  --surface: #1a1522;
  --border: rgba(247, 178, 103, 0.14);
  --accent: #f7b267;
  --accent-dim: rgba(247, 178, 103, 0.16);
  --heat: #f7b267;
}

body.anniversary #center > h1 > span {
  display: inline-block;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, #f7b267, #f4845f, #c77dff, #7fd1ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

body.anniversary #center > h1::after {
  content: ' 🎂';
}

/* gradient hairline border around the entry box, radius-safe */
body.anniversary #entry-box {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(120deg, #f7b267, #f4845f, #c77dff, #7fd1ff) border-box;
}

/* confetti heatmap: cells cycle through four hues, intensity still from data-w */
body.anniversary .day[data-w] {
  background-color: hsl(var(--h, 32) 90% 70% / var(--a, 1));
}
body.anniversary .day:nth-child(4n+1) { --h: 32; }
body.anniversary .day:nth-child(4n+2) { --h: 12; }
body.anniversary .day:nth-child(4n+3) { --h: 275; }
body.anniversary .day:nth-child(4n)   { --h: 200; }

body.anniversary .day[data-w="1"]  { --a: 0.22; }
body.anniversary .day[data-w="2"]  { --a: 0.32; }
body.anniversary .day[data-w="3"]  { --a: 0.42; }
body.anniversary .day[data-w="4"]  { --a: 0.5; }
body.anniversary .day[data-w="5"]  { --a: 0.58; }
body.anniversary .day[data-w="6"]  { --a: 0.66; }
body.anniversary .day[data-w="7"]  { --a: 0.74; }
body.anniversary .day[data-w="8"]  { --a: 0.84; }
body.anniversary .day[data-w="9"]  { --a: 0.92; }
body.anniversary .day[data-w="10"] { --a: 1; }

/* ── form ── */

#inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#inline-form input,
#inline-form textarea {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

#inline-form input:focus,
#inline-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

#inline-form #name { width: 9rem; }
#inline-form #password { width: 11rem; }
#inline-form #text {
  flex: 1;
  min-width: 10rem;
  resize: none;
}

button, .linklike {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--accent);
  color: var(--bg);
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

button:hover, .linklike:hover {
  opacity: 0.85;
}

.linklike {
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 600;
  font-size: 0.95rem;
}

#entry-date {
  display: flex;
  gap: 1rem;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}

#entry-date label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

#entry-date input {
  accent-color: var(--accent);
}

#word-count {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.15s;
}

#word-count.over {
  color: #f08c8c;
}

#msg {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.2em;
}

/* ── calendar heatmap ── */

#viz h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--fg);
}

#viz h3 {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 1.25rem 0 0.5rem;
}

#calendar {
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-color: var(--border) transparent;
}

.month-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
  line-height: 1;
}

.day {
  width: 11px;
  height: 11px;
  background: rgba(255, 255, 255, 0.03);
  border: none;
  border-radius: 3px;
  transition: background-color 0.15s;
}

.day[data-w="1"]  { background-color: rgba(124, 140, 244, 0.2); }
.day[data-w="2"]  { background-color: rgba(124, 140, 244, 0.3); }
.day[data-w="3"]  { background-color: rgba(124, 140, 244, 0.4); }
.day[data-w="4"]  { background-color: rgba(124, 140, 244, 0.48); }
.day[data-w="5"]  { background-color: rgba(124, 140, 244, 0.56); }
.day[data-w="6"]  { background-color: rgba(124, 140, 244, 0.64); }
.day[data-w="7"]  { background-color: rgba(124, 140, 244, 0.72); }
.day[data-w="8"]  { background-color: rgba(124, 140, 244, 0.82); }
.day[data-w="9"]  { background-color: rgba(124, 140, 244, 0.91); }
.day[data-w="10"] { background-color: rgba(124, 140, 244, 1); }

/* ── timeline ── */

#timeline {
  list-style: none;
}

#timeline li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

#timeline li:last-child { border-bottom: none; }

#timeline .date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted);
}

#timeline .text {
  display: block;
  margin-top: 0.15rem;
  white-space: pre-wrap;
  font-size: 0.9rem;
}

/* ── sidebars ── */

#right h3 {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

#everyone-btn {
  display: block;
  padding: 0.35rem 0;
  margin-bottom: 0.3rem;
  font-size: 1rem;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  border-bottom: 1px solid var(--border);
}

#sidebar-search {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.5rem;
  outline: none;
}

#sidebar-search::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

#sidebar-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

#users {
  list-style: none;
  max-height: 55vh;
  overflow-y: auto;
  scrollbar-color: var(--border) transparent;
}

#all-timeline {
  list-style: none;
}

/* thin custom scrollbar */
#users::-webkit-scrollbar,
#all-timeline::-webkit-scrollbar,
#timeline::-webkit-scrollbar,
#calendar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
#users::-webkit-scrollbar-track,
#all-timeline::-webkit-scrollbar-track,
#timeline::-webkit-scrollbar-track,
#calendar::-webkit-scrollbar-track {
  background: transparent;
}
#users::-webkit-scrollbar-thumb,
#all-timeline::-webkit-scrollbar-thumb,
#timeline::-webkit-scrollbar-thumb,
#calendar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

#users li {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}
#users li:last-child { border-bottom: none; }

#all-timeline li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
#all-timeline li:last-child { border-bottom: none; }

#all-timeline .meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted);
}

#all-timeline .txt {
  display: block;
  margin-top: 0.1rem;
  white-space: pre-wrap;
  color: var(--fg);
  font-size: 0.88rem;
}

/* ── streaks ── */

#streaks {
  list-style: none;
}

#streaks li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

#streaks li:last-child { border-bottom: none; }

#streaks .streak-user {
  color: var(--accent);
  cursor: pointer;
  transition: opacity 0.15s;
}

#streaks .streak-user:hover { opacity: 0.75; }

#streaks .streak-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── links ── */

a,
#timeline a,
#users a,
.meta a,
#all-timeline a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

a:hover { opacity: 0.75; }

.txt {
  color: var(--fg);
}

/* ── fireworks overlay (created by app.js after a post) ── */

#fireworks {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2000;
}

/* ── user-picker modal ── */

#user-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
}

#user-modal.open {
  display: flex;
}

#modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90vw;
  max-width: 360px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#modal-search {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  background: var(--bg);
  color: var(--fg);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1rem;
  outline: none;
}

#modal-search::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

#modal-users {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

#modal-users li {
  padding: 0.7rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

#modal-users li:last-child { border-bottom: none; }

#modal-users li:active {
  background: var(--accent-dim);
}

/* ── mobile ── */

@media (max-width: 640px) {
  main.three-col {
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    gap: 1rem;
  }

  #left-sidebar {
    display: none;
  }

  #right {
    display: none;
  }

  #who {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: var(--muted);
    text-underline-offset: 3px;
  }

  #who::after {
    content: ' \25BE';
    font-size: 0.75em;
    color: var(--muted);
  }

  #center section,
  #left-sidebar,
  #right {
    padding: 1rem 1.1rem;
  }

  #inline-form {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  #inline-form #text {
    overflow-y: hidden;
  }

  #inline-form input,
  #inline-form #text {
    width: 100% !important;
    min-width: 0 !important;
    padding: 0.7rem 0.75rem;
    font-size: 1rem;
  }

  #inline-form #name    { order: 1; }
  #inline-form #password { order: 2; }
  #inline-form #text     { order: 3; }
  #inline-form button    { order: 4; justify-self: start; padding: 0.65rem 1.2rem; }

  #entry-date {
    flex-wrap: wrap;
  }

  #entry-date label {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  #users,
  #all-timeline {
    overflow-x: hidden;
  }

  #users li,
  #all-timeline li,
  #all-timeline .txt {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  html, body { overflow-x: hidden; }
}
