/* ============================================================
   My Brain at 2 AM — shared stylesheet
   Base palette: Ink / Bone / Stone / Sage / Dust / Burgundy
   The Wall itself uses full, user-chosen color per note — everything
   else around it stays restrained so the notes are what pops.
   Type: Playfair Display (display) + Poppins (UI/body)
   ============================================================ */

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

:root {
  --ink: #17161a;
  --bone: #f5f1e8;
  --stone: #a8a296;
  --sage: #7d8c6f;
  --dust: #cabfa9;
  --burgundy: #6e2b33;

  --bone-dim: #ece5d6;
  --ink-soft: #33333a;
  --ink-deep: #0e0d10;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;

  --max-w: 1160px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --focus-ring: 3px solid var(--dust);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bone);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font-family: inherit; font-size: inherit; }
:focus-visible { outline: var(--focus-ring); outline-offset: 3px; }

.wrap { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Header / nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(23, 22, 26, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(245, 241, 232, 0.1);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.25rem;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1rem, 2.6vw, 1.3rem);
  text-decoration: none;
  color: var(--bone);
  white-space: nowrap;
}
.wordmark span { color: #e8a13e; font-style: italic; }

.site-nav { display: flex; gap: clamp(1rem, 3vw, 2.25rem); list-style: none; margin: 0; padding: 0; }
.site-nav a {
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--dust);
  padding: 0.4rem 0.1rem;
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--bone); border-color: #e8a13e; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  border-radius: 3px;
  padding: 0.85rem 1.6rem;
  font-size: 0.94rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}
.btn-primary { background: var(--bone); color: var(--ink); }
.btn-primary:hover { background: #e8a13e; }
.btn-on-light { background: var(--ink); color: var(--bone); }
.btn-on-light:hover { background: var(--burgundy); }
.btn-outline { background: transparent; color: var(--bone); border: 1.5px solid rgba(245,241,232,0.5); }
.btn-outline:hover { border-color: var(--bone); background: rgba(245,241,232,0.08); }
.btn-outline.btn-ink { color: var(--ink); border-color: rgba(23,22,26,0.4); }
.btn-outline.btn-ink:hover { border-color: var(--ink); background: rgba(23,22,26,0.06); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Shared: night-sky texture ---------- */

.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.6;
  background-image:
    radial-gradient(1.5px 1.5px at 8% 22%, var(--dust), transparent),
    radial-gradient(1.5px 1.5px at 22% 68%, var(--stone), transparent),
    radial-gradient(1px 1px at 38% 15%, var(--dust), transparent),
    radial-gradient(2px 2px at 58% 40%, var(--stone), transparent),
    radial-gradient(1px 1px at 72% 75%, var(--dust), transparent),
    radial-gradient(1.5px 1.5px at 83% 20%, var(--stone), transparent),
    radial-gradient(1px 1px at 91% 60%, var(--dust), transparent),
    radial-gradient(1.5px 1.5px at 13% 85%, var(--stone), transparent),
    radial-gradient(1px 1px at 47% 90%, var(--dust), transparent),
    radial-gradient(1.5px 1.5px at 65% 8%, var(--dust), transparent),
    radial-gradient(1px 1px at 96% 88%, var(--stone), transparent);
  background-repeat: no-repeat;
}

/* ---------- Colorful page backdrop (Wall page only) ----------
   Inspired by a colorful paint-splash mood, built from the brand's own
   hues pushed brighter, on a warm dark ground rather than flat black —
   "in between": still moody/night, but colorful throughout, not dark void. */

body.page-wall {
  background:
    radial-gradient(600px 600px at 12% 8%,  rgba(226,140,31,0.38), transparent 70%),
    radial-gradient(650px 650px at 88% 12%, rgba(194,59,59,0.34), transparent 70%),
    radial-gradient(700px 700px at 80% 82%, rgba(63,111,158,0.36), transparent 70%),
    radial-gradient(550px 550px at 15% 88%, rgba(194,59,59,0.22), transparent 70%),
    radial-gradient(600px 600px at 50% 48%, rgba(226,140,31,0.12), transparent 75%),
    linear-gradient(180deg, #1a1015, #150d13);
  background-attachment: fixed;
  background-size: 100% 100%;
}

@media (max-width: 780px) {
  /* fixed backgrounds are unreliable on some mobile browsers; fall back to
     a scrolling background sized generously so the wash still covers */
  body.page-wall {
    background-attachment: scroll;
    background-size: 100% 140%;
  }
}

/* ---------- Landing hero (Wall page) ---------- */

.landing-hero {
  position: relative;
  color: var(--bone);
  padding: clamp(2rem, 5vw, 3rem) 0 clamp(1.5rem, 4vw, 2.25rem);
  overflow: hidden;
}

.landing-hero .wrap { position: relative; text-align: center; max-width: 640px; }
.landing-hero .eyebrow { color: #e8a13e; }
.landing-hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 5vw, 3rem);
  line-height: 1.15;
  margin: 0 0 1rem;
}
.landing-hero p.lede { color: var(--dust); font-size: 1.02rem; margin: 0 0 1.75rem; }
.landing-hero .hero-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.85rem; }

/* ---------- General sections (About / Terms) ---------- */

section { padding: clamp(3rem, 7vw, 5.5rem) 0; }
.section-alt { background: var(--bone-dim); }
.section-dark { background: var(--ink); color: var(--bone); }

.eyebrow { font-size: 0.85rem; color: var(--burgundy); margin: 0 0 0.75rem; font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase; }
.section-dark .eyebrow { color: var(--dust); }

.hero h1, h2.section-title, h1.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 4vw, 2.75rem);
  max-width: 22ch;
  margin: 0 0 1.25rem;
  line-height: 1.15;
}

.section-body, .hero p.lede { max-width: 60ch; color: var(--ink-soft); font-size: 1.02rem; }
.section-dark .section-body { color: var(--dust); }

.hero { padding: clamp(3rem, 8vw, 6rem) 0 clamp(2rem, 6vw, 4rem); overflow: hidden; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 1rem; }

/* ---------- How it works ---------- */

.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2.5rem; margin-top: 3rem; }
@media (max-width: 780px) { .how-grid { grid-template-columns: 1fr; gap: 2.25rem; } }

.how-step { border-top: 1px solid rgba(27, 27, 30, 0.15); padding-top: 1.25rem; }
.how-step .num { font-family: var(--font-display); font-style: italic; color: var(--stone); font-size: 1rem; display: block; margin-bottom: 0.6rem; }
.how-step h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; margin: 0 0 0.6rem; }
.how-step p { color: var(--ink-soft); font-size: 0.96rem; margin: 0; }

/* ============================================================
   The Wall — the corkboard.
   Full user-chosen color per note (that part came back), but staged
   as an untidy, hand-pinned board on a dark ground rather than a
   clean tile grid: uneven torn corners, a strip of "tape," a slight
   independent tilt per note, mixed sizes. This is the "what does the
   inside of a 2am brain look like" bit — busy, colorful, a little
   overlapping, nothing perfectly aligned.
   ============================================================ */

.wall-section {
  background: transparent;
  padding-top: clamp(1.5rem, 4vw, 2.25rem);
}

.wall-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.wall-search input {
  width: 100%;
  max-width: 360px;
  border: none;
  border-bottom: 1.5px solid rgba(245,241,232,0.4);
  background: transparent;
  color: var(--bone);
  padding: 0.55rem 0.1rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
}
.wall-search input::placeholder { color: var(--stone); }
.wall-search input:focus { outline: none; border-bottom-color: #e8a13e; }

.wall-meta { font-size: 0.82rem; color: var(--stone); }

.wall-grid {
  column-count: 1;
  column-gap: 1.25rem;
  padding-bottom: 1rem;
}
@media (min-width: 620px) { .wall-grid { column-count: 2; } }
@media (min-width: 980px) { .wall-grid { column-count: 3; } }
@media (min-width: 1300px) { .wall-grid { column-count: 4; } }

.note-card {
  --accent: #6e2b33;
  --ink-on: #17161a;
  --bone-on: #f5f1e8;
  break-inside: avoid;
  margin: 0 0 1.4rem;
  padding: 1.4rem 1.3rem 1.15rem;
  background: var(--accent);
  color: var(--text, var(--bone-on));
  position: relative;
  box-shadow: 4px 8px 18px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.06) inset;
}

/* uneven, torn-paper corners — cycles through a few variants */
.note-card:nth-child(4n)   { border-radius: 2px 16px 3px 18px; }
.note-card:nth-child(4n+1) { border-radius: 18px 3px 16px 2px; }
.note-card:nth-child(4n+2) { border-radius: 3px 3px 20px 3px; }
.note-card:nth-child(4n+3) { border-radius: 20px 3px 3px 3px; }

/* washi-tape strip, alternating position + tone */
.note-card::before {
  content: '';
  position: absolute;
  top: -0.6rem;
  width: 3.6rem;
  height: 1.3rem;
  background: rgba(245, 241, 232, 0.75);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.note-card:nth-child(3n)   { transform: rotate(-1.6deg); }
.note-card:nth-child(3n+1) { transform: rotate(1.1deg); }
.note-card:nth-child(3n+2) { transform: rotate(-0.5deg); }

.note-card:nth-child(5n)::before   { left: 18%; transform: rotate(-5deg); }
.note-card:nth-child(5n+1)::before { left: 55%; transform: rotate(4deg); background: rgba(23,22,26,0.28); }
.note-card:nth-child(5n+2)::before { left: 35%; transform: rotate(-3deg); }
.note-card:nth-child(5n+3)::before { left: 65%; transform: rotate(6deg); background: rgba(23,22,26,0.22); }
.note-card:nth-child(5n+4)::before { left: 42%; transform: rotate(-2deg); }

.note-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 1.08rem;
  display: block;
  margin-top: 0.35rem;
}
.note-msg {
  font-size: 0.93rem;
  line-height: 1.55;
  margin: 0.75rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.note-meta {
  font-size: 0.72rem;
  opacity: 0.75;
  margin: 0.9rem 0 0;
}

.skeleton-card {
  break-inside: avoid;
  margin: 0 0 1.4rem;
  height: 170px;
  border-radius: 6px;
  background: linear-gradient(90deg, #262530 25%, #34323f 37%, #262530 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--stone);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.2rem;
  display: none;
}
.empty-state.is-visible { display: block; }

.load-more-wrap { text-align: center; margin-top: 1.5rem; padding-bottom: 1rem; }

/* ---------- Write section (same page, below the Wall) ---------- */

.write-section {
  background: transparent;
}

.write-intro { max-width: 560px; margin: 0 auto 2rem; text-align: center; }
.write-intro .eyebrow { color: #e8a13e; }
.write-intro .section-title { color: var(--bone); margin-left: auto; margin-right: auto; }
.write-intro .section-body { color: var(--dust); margin-left: auto; margin-right: auto; }

.write-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
  gap: clamp(1.75rem, 4vw, 3rem);
  align-items: start;
  max-width: 980px;
  margin: 0 auto;
}
@media (max-width: 860px) { .write-layout { grid-template-columns: 1fr; } }

.form-panel { background: var(--bone); padding: clamp(1.5rem, 4vw, 2.25rem); border: 1px solid rgba(23,22,26,0.1); border-radius: 4px; }
.field { margin-bottom: 1.4rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.5rem; color: var(--ink); }
.field .hint { display: block; font-size: 0.78rem; color: var(--stone); margin-top: 0.4rem; }

.field input[type="text"], .field textarea {
  width: 100%;
  border: 1.5px solid rgba(27,27,30,0.2);
  background: var(--bone-dim);
  padding: 0.8rem 1rem;
  border-radius: 3px;
  color: var(--ink);
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--burgundy); outline: none; }

.char-count { text-align: right; font-size: 0.75rem; color: var(--stone); margin-top: 0.35rem; }

.color-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.color-swatch { width: 2.2rem; height: 2.2rem; border-radius: 50%; border: 2px solid transparent; cursor: pointer; position: relative; }
.color-swatch.is-selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bone-dim); }
.color-swatch:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

.color-custom { display: flex; align-items: center; gap: 0.6rem; font-size: 0.83rem; color: var(--ink-soft); }
.color-custom input[type="color"] { width: 2.2rem; height: 2.2rem; border: none; border-radius: 50%; padding: 0; cursor: pointer; background: none; }

.write-preview-label { font-size: 0.85rem; font-weight: 500; color: var(--dust); margin: 0 0 0.75rem; }
.write-preview-col { position: sticky; top: 5.5rem; }
@media (max-width: 860px) { .write-preview-col { position: static; margin-top: 0.5rem; } }
.write-preview-col .note-card { margin: 0; }

.form-msg { font-size: 0.85rem; padding: 0.75rem 1rem; border-radius: 3px; margin-top: 1rem; display: none; }
.form-msg.is-visible { display: block; }
.form-msg.is-error { background: rgba(110,43,51,0.12); color: var(--burgundy); }

.confirmation {
  display: none;
  text-align: center;
  padding: 2.5rem 1.5rem;
  background: var(--ink);
  color: var(--bone);
  border-radius: 4px;
}
.confirmation.is-visible { display: block; }
.confirmation h3 { font-family: var(--font-display); font-style: italic; font-size: 1.5rem; margin: 0 0 0.75rem; }

/* ---------- Terms / prose pages ---------- */

.prose { max-width: 68ch; margin: 0 auto; }
.prose h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  margin: 2.25rem 0 0.75rem;
}
.prose h2:first-of-type { margin-top: 0; }
.prose p, .prose li { color: var(--ink-soft); font-size: 0.98rem; line-height: 1.7; }
.prose ul { padding-left: 1.2rem; }
.prose .updated { font-size: 0.85rem; color: var(--stone); margin-bottom: 2.5rem; }

/* ---------- Footer ---------- */

.site-footer { background: var(--ink); border-top: 1px solid rgba(245,241,232,0.08); padding: 2.5rem 0; font-size: 0.85rem; color: var(--stone); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: center; }
.site-footer nav { display: flex; gap: 1.5rem; }
.site-footer a { text-decoration: none; color: var(--stone); }
.site-footer a:hover { color: var(--bone); }
