/* ============================================================
   open:grounds blog — stylesheet
   Pulled out of index.html so markup, styling, and behavior
   each live in their own file.
   ============================================================ */

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

:root {
  --paper:      #F7F4EC;
  --paper-dim:  #ECE6D9;
  --ink:        #15130F;
  --pink:       #FF3E86;
  --sky:        #2F9BD6;
  --sky-tint:   #DDF1FA;
  --grass:      #2F4D22;
  --grass-tint: #E6EEDF;
  --flame:      #FF5722;
  --flame-tint: #ECE6D9;
  --sun:        #FFC53D;
  --stone:      #75695A;
  --border: 3px solid var(--ink);
}

html, body {
  background-color: var(--paper);
  /* faint dot grid so the paper background isn't completely flat —
     subtle enough to stay out of the way of reading */
  background-image: radial-gradient(rgba(21, 19, 15, 0.07) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: 'Space Mono', monospace;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; }

/* ---- accessibility base ---- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.7rem 1.1rem;
  z-index: 100;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  text-decoration: none;
}
.skip-link:focus { left: 1rem; top: 1rem; }

a:focus-visible, button:focus-visible, .post-card:focus-visible,
[role="button"]:focus-visible, .filter-chip:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

/* respect "reduce motion" at the OS level — kill all animation/transition
   timing so nothing moves for people who've asked for that */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ============================================================
   HEADER — mirrors the davis commons header
   ============================================================ */
header {
  border-bottom: var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--paper);
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 0.9rem; cursor: pointer; }
.brand-mark { width: 46px; height: 46px; flex-shrink: 0; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.wordmark { display: flex; flex-direction: column; gap: 0.14rem; }
.brand-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  line-height: 1;
}
.brand-title .punct { font-weight: 100; color: var(--flame); }
.brand-title .ital  { font-weight: 100; font-style: italic; color: var(--pink); }
.brand-sub {
  font-family: 'Space Mono', monospace;
  font-size: 0.66rem;
  letter-spacing: 0.13em;
  color: var(--stone);
  text-transform: uppercase;
}
.header-right { margin-left: auto; display: flex; gap: 0.6rem; }

/* little playful tilt on the logo mark when you hover or focus it */
@media (prefers-reduced-motion: no-preference) {
  .brand-mark svg { transition: transform 0.3s ease; }
  .brand:hover .brand-mark svg, .brand:focus-visible .brand-mark svg { transform: rotate(-8deg) scale(1.06); }
}

.btn {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.5rem 1rem;
  border: var(--border);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.1s, color 0.1s;
  white-space: nowrap;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn:hover  { background: var(--ink); color: var(--paper); }
.btn:active { transform: translate(2px, 2px); }
.btn-secondary { border-width: 2px; font-size: 0.73rem; color: var(--stone); border-color: rgba(21,19,15,0.3); }
.btn-secondary:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* "blog home" — deliberately louder than "all projects" next to it.
   One stays inside the blog (this one), the other leaves the site
   entirely, so they shouldn't read as interchangeable. */
.btn-home {
  background: var(--flame);
  color: var(--paper);
  border-color: var(--ink);
}
.btn-home:hover { background: var(--ink); }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative;
  overflow: hidden;
  max-width: 760px;
  margin: 0 auto;
  padding: 3.2rem 1.5rem 1.5rem;
  text-align: center;
}
.hero h1 {
  position: relative;
  z-index: 1;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.hero h1 .ital { font-weight: 100; font-style: italic; color: var(--pink); }
.hero p {
  position: relative;
  z-index: 1;
  color: var(--stone);
  font-size: 0.85rem;
  margin-top: 0.75rem;
  letter-spacing: 0.01em;
}

/* ---- decorative doodles scattered around the hero ----
   Purely visual — sit behind the text (z-index 0 vs the text's 1)
   and don't intercept clicks, so they never get in the way. */
.hero-doodles {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.doodle {
  position: absolute;
  opacity: 0.9;
}
.doodle-1 { top: 6%;  left: 5%;  width: 34px; }
.doodle-2 { top: 12%; right: 7%; width: 26px; }
.doodle-3 { bottom: 8%; left: 10%; width: 24px; }
.doodle-4 { bottom: 14%; right: 12%; width: 30px; }
.doodle-5 { top: 42%; left: 1%; width: 20px; }

@media (prefers-reduced-motion: no-preference) {
  .doodle-1 { animation: doodleFloat 5.5s ease-in-out infinite; }
  .doodle-2 { animation: doodleFloatAlt 6.5s ease-in-out infinite 0.4s; }
  .doodle-3 { animation: doodleFloatAlt 4.8s ease-in-out infinite 0.9s; }
  .doodle-4 { animation: doodleFloat 6s ease-in-out infinite 0.2s; }
  .doodle-5 { animation: doodleFloatAlt 5.2s ease-in-out infinite 0.6s; }
}
@keyframes doodleFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-9px) rotate(7deg); }
}
@keyframes doodleFloatAlt {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(8px) rotate(-8deg); }
}

/* the two furthest-out doodles get crowded on narrow screens — hide them there */
@media (max-width: 560px) {
  .doodle-2, .doodle-5 { display: none; }
}

.hero-meta {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
}
.hero-count {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--stone);
}
.hero-count strong { color: var(--ink); }
.btn-surprise {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  background: var(--sun);
  border: 2px solid var(--ink);
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn-surprise:hover { background: var(--ink); color: var(--paper); }
.btn-surprise:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

/* ---- accent filter chips ---- */
.filter-row {
  max-width: 760px;
  margin: 0 auto 1.2rem;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.filter-label {
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stone);
  margin-right: 0.2rem;
}
.filter-chip {
  width: 30px; height: 30px;
  border: 2px solid var(--ink);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.1s;
}
.filter-chip:hover { transform: translateY(-2px); }
.filter-chip[aria-pressed="true"]::after {
  content: '✓';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--paper); font-weight: 700; text-shadow: 0 0 2px var(--ink);
}
.filter-chip--all {
  width: auto;
  height: 30px;
  padding: 0 0.65rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.68rem;
  background: var(--paper);
  color: var(--ink);
}
.filter-chip--all[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.filter-chip--all[aria-pressed="true"]::after { content: none; }

.post-readtime::before { content: '·'; margin: 0 0.4em; }

/* ============================================================
   POST LIST
   ============================================================ */
.wrap { max-width: 760px; margin: 0 auto; padding: 1rem 1.5rem 5rem; }

.state-msg {
  color: var(--stone);
  font-size: 0.82rem;
  text-align: center;
  padding: 3rem 1rem;
}

.post-card {
  border: var(--border);
  background: var(--paper);
  margin-bottom: 1.25rem;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
}
.post-card:hover  { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.post-card:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }

/* cards fade/slide in one after another when the list first renders —
   --i is set inline per card in scripts.js so each one is staggered */
@media (prefers-reduced-motion: no-preference) {
  .post-card.enter {
    animation: cardIn 0.5s cubic-bezier(.2,.8,.2,1) both;
    animation-delay: calc(var(--i, 0) * 60ms);
  }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.post-card-accent { height: 8px; }

.post-card-body { padding: 1.1rem 1.3rem 1.3rem; }

.post-date {
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stone);
  margin-bottom: 0.4rem;
}

.post-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
  line-height: 1.25;
}

.post-excerpt {
  font-size: 0.85rem;
  color: #3a362e;
  line-height: 1.65;
}

.post-readmore {
  display: inline-block;
  margin-top: 0.75rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ============================================================
   FULL POST VIEW — its own page, not a popup, so it has a
   real shareable URL (#post/<id>) and back/forward works.
   ============================================================ */
#view-post { display: none; }

.post-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 2.2rem 1.5rem 5rem;
}

.post-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  color: var(--stone);
}
.post-back:hover { color: var(--ink); }

.post-page-accent { height: 6px; margin-bottom: 1.6rem; }

.post-page-date {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stone);
  margin-bottom: 0.6rem;
}
.post-page-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 4.5vw, 2.2rem);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 1.6rem;
  padding-bottom: 1.6rem;
  border-bottom: 2px solid rgba(21,19,15,0.12);
}

.post-body p { margin-bottom: 1.1rem; font-size: 0.98rem; line-height: 1.8; }
.post-body h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  margin: 1.6rem 0 0.7rem;
}
.post-body blockquote {
  border-left: 3px solid var(--flame);
  padding-left: 1rem;
  color: var(--stone);
  font-style: italic;
  margin-bottom: 1.1rem;
}
.post-body ul { margin: 0 0 1.1rem 1.3rem; }
.post-body li { margin-bottom: 0.4rem; font-size: 0.98rem; }
.post-body strong { font-weight: 700; }

/* links inside a post — a highlighter-style sweep instead of the
   plain default blue/visited-purple browsers give you for free.
   The fill grows from the left on hover/focus; color and text
   stay the same for visited links, no dull purple. */
.post-body a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 3px solid var(--flame);
  background-image: linear-gradient(var(--flame), var(--flame));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 100%;
  padding: 0 0.05em;
  transition: background-size 0.25s ease, color 0.25s ease;
}
.post-body a:visited { color: var(--ink); }
.post-body a:hover,
.post-body a:focus-visible {
  background-size: 100% 100%;
  color: var(--paper);
}
/* a little arrow on links that open in a new tab, so it's obvious
   before you click */
.post-body a[target="_blank"]::after {
  content: ' ↗';
  font-weight: 700;
}

/* photos embedded in a post, via ![caption](url) on its own line */
.post-body figure {
  margin: 1.6rem 0;
  border: 2px solid var(--ink);
  background: var(--paper-dim);
  box-shadow: 4px 4px 0 var(--ink);
}
.post-body figure img {
  display: block;
  width: 100%;
  height: auto;
}
.post-body figcaption {
  padding: 0.6rem 0.8rem;
  font-size: 0.74rem;
  color: var(--stone);
  font-style: italic;
  border-top: 2px solid var(--ink);
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  border-top: var(--border);
  padding: 1.4rem 1.5rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--stone);
}
footer a { color: var(--flame); font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; transition: color 0.15s; }
footer a:hover, footer a:focus-visible { color: var(--sky); }

@media (max-width: 560px) {
  .header-right .btn-secondary span.long { display: none; }
}

/* ---- back to top ---- */
#back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 46px; height: 46px;
  border: var(--border);
  background: var(--flame);
  color: var(--paper);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s, background 0.1s;
  z-index: 40;
}
#back-to-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
#back-to-top:hover { background: var(--ink); }
#back-to-top:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }

/* ---- reading progress bar — fills in as you scroll through a post ---- */
#reading-progress {
  position: fixed;
  top: 64px; /* sits right under the sticky header */
  left: 0;
  height: 4px;
  width: 0%;
  background: var(--flame);
  z-index: 25;
  transition: width 0.1s linear;
}

/* ---- post page top bar: back link + copy link button, side by side ---- */
.post-page-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}
.copy-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, transform 0.08s;
}
.copy-link-btn:hover { background: var(--ink); color: var(--paper); }
.copy-link-btn:active { transform: translate(1px, 1px); }

/* ---- toast — little confirmation that pops up bottom-center ---- */
#toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 0.7rem 1.2rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--flame);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }