/* =====================================================================
   heavyion.cc — shared stylesheet
   Used across the splash page, the posts index, and individual posts.
   Aesthetic: refined editorial, FRIB/MSU Spartan Green on warm paper.
   ===================================================================== */

:root {
  --green:        #18453B;
  --green-deep:   #0B2920;
  --green-soft:   #2A5A4E;
  --accent:       #7A9A01;
  --paper:        #F9F6EF;
  --paper-edge:   #EFEAE0;
  --ink:          #1A1A1A;
  --ink-muted:    #5C5C5C;
  --rule:         rgba(24, 69, 59, 0.18);
}

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

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: "JetBrains Mono", Georgia, serif;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Atmospheric background layers */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(24, 69, 59, 0.06), transparent 60%),
    radial-gradient(ellipse at 100% 100%, rgba(122, 154, 1, 0.05), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.09 0 0 0 0 0.27 0 0 0 0 0.23 0 0 0 0.08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.5;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 0;
}

/* ----- Frame: shared page container ----- */
.frame {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 2.5rem clamp(1.5rem, 5vw, 4rem);
  max-width: 1280px;
  margin: 0 auto;
}

/* ----- Site header (consistent across all pages) ----- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1.25rem;
  animation: fade-down 0.8s ease-out both;
}

.mark {
  font-family: "JetBrains Mono", serif;
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--green-deep);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
}

.mark .dot {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-1px);
}

.meta, .nav-mono a {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.nav-mono {
  display: flex;
  gap: 1.5rem;
}

.nav-mono a {
  text-decoration: none;
  transition: color 0.2s;
}

.nav-mono a:hover {
  color: var(--green);
}

/* ----- Footer (consistent across all pages) ----- */
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-top: 1px solid var(--rule);
  padding-top: 1.25rem;
  margin-top: 4rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  animation: fade-up 0.8s ease-out 0.5s both;
}

.site-footer .right { text-align: right; }
.site-footer .right span { display: block; }
.site-footer a { color: var(--ink-muted); text-decoration: none; }
.site-footer a:hover { color: var(--green); }

/* ----- Posts index ----- */
.page-title {
  font-family: "JetBrains Mono", serif;
  font-weight: 300;
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--green-deep);
  margin: clamp(2rem, 5vw, 3.5rem) 0 0.75rem;
  font-variation-settings: "opsz" 144;
  animation: fade-up 0.7s ease-out 0.15s both;
}

.page-lede {
  font-size: 1.1rem;
  color: var(--ink-muted);
  margin-bottom: 3rem;
  max-width: 38rem;
  animation: fade-up 0.7s ease-out 0.25s both;
}

.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 4rem;
}

.post-list li {
  border-top: 1px solid var(--rule);
  animation: fade-up 0.6s ease-out both;
}

.post-list li:last-child { border-bottom: 1px solid var(--rule); }

.post-list a {
  display: grid;
  grid-template-columns: 9rem 1fr auto;
  gap: 2rem;
  align-items: baseline;
  padding: 1.5rem 0.5rem;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.2s, padding 0.2s;
}

.post-list a:hover {
  background: rgba(24, 69, 59, 0.04);
  padding-left: 1rem;
}

.post-list .date {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--green-soft);
  text-transform: uppercase;
}

.post-list .title {
  font-family: "JetBrains Mono", serif;
  font-weight: 400;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  color: var(--green-deep);
  line-height: 1.3;
}

.post-list .arrow {
  font-family: "JetBrains Mono", monospace;
  color: var(--green-soft);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.post-list a:hover .arrow {
  opacity: 1;
  transform: translateX(4px);
}

@media (max-width: 640px) {
  .post-list a {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .post-list .arrow { display: none; }
}

/* ----- Individual post page ----- */
article.post {
  max-width: 44rem;
  margin: clamp(2rem, 5vw, 3.5rem) auto 0;
  animation: fade-up 0.7s ease-out 0.15s both;
}

article.post .post-date {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green-soft);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

article.post .post-date::before {
  content: "";
  width: 1.75rem;
  height: 1px;
  background: var(--green-soft);
}

article.post h1 {
  font-family: "JetBrains Mono", serif;
  font-weight: 300;
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--green-deep);
  margin-bottom: 2.5rem;
  font-variation-settings: "opsz" 144;
}

article.post h2 {
  font-family: "JetBrains Mono", serif;
  font-weight: 400;
  font-size: 1.65rem;
  letter-spacing: -0.01em;
  color: var(--green);
  margin: 3rem 0 1rem;
  font-variation-settings: "opsz" 36;
}

article.post h3 {
  font-family: "JetBrains Mono", serif;
  font-weight: 500;
  font-size: 1.2rem;
  color: var(--green-deep);
  margin: 2rem 0 0.75rem;
}

article.post p {
  font-size: 1.075rem;
  line-height: 1.7;
  margin-bottom: 1.25rem;
  color: var(--ink);
}

article.post a {
  color: var(--green);
  text-decoration: underline;
  text-decoration-color: rgba(24, 69, 59, 0.3);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}

article.post a:hover {
  text-decoration-color: var(--accent);
}

article.post strong { color: var(--green-deep); font-weight: 600; }
article.post em { font-style: italic; color: var(--green); }

article.post code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.92em;
  background: var(--paper-edge);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  color: var(--green-deep);
}

article.post pre {
  background: var(--green-deep);
  color: var(--paper);
  padding: 1.25rem 1.5rem;
  border-radius: 4px;
  overflow-x: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  margin: 1.5rem 0;
}

article.post pre code {
  background: none;
  padding: 0;
  color: inherit;
}

article.post blockquote {
  border-left: 3px solid var(--green-soft);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--ink-muted);
  font-style: italic;
}

article.post ul, article.post ol {
  margin: 1rem 0 1.5rem 1.5rem;
}

article.post li {
  margin-bottom: 0.5rem;
  line-height: 1.65;
}

/* ----- Media in posts ----- */
.media {
  margin: 2rem 0;
}

.media figure {
  margin: 0;
}

.media img,
.media video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  background: var(--paper-edge);
}

.media figcaption {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  text-align: center;
  margin-top: 0.75rem;
}

/* Side-by-side media pair */
.media-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 2rem 0;
}

@media (max-width: 640px) {
  .media-pair { grid-template-columns: 1fr; }
}

/* ----- ROOT canvas embed ----- */
.canvas-embed {
  margin: 2rem 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: white;
  overflow: hidden;
}

.canvas-embed .canvas-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--paper-edge);
  border-bottom: 1px solid var(--rule);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.canvas-embed .canvas-title {
  color: var(--green-deep);
}

.canvas-embed .canvas-hint {
  opacity: 0.7;
}

.canvas-embed .canvas-host {
  width: 100%;
  min-height: 420px;
}

/* Back link at the bottom of posts */
.post-nav {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
}

.post-nav a {
  color: var(--green-deep);
  text-decoration: none;
  transition: color 0.2s, transform 0.2s;
  display: inline-block;
}

.post-nav a:hover {
  color: var(--accent);
  transform: translateX(-3px);
}

.post-nav a::before {
  content: "← ";
}

/* ----- Animations ----- */
@keyframes fade-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; }
}
.pulse { animation: pulse 3s ease-in-out infinite; }

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