/* public/style.css */
html {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow-y: scroll;
  overflow-x: hidden;
}

:root {
  --bg:         #fbf1c7;
  --bg1:        #f2e5bc;
  --bg2:        #ebdbb2;
  --text:       #3c3836;
  --text-muted: #7c6f64;
  --link:       #b16286;
  --link-hover: #d65d0e;
  --hr:         #d5c4a1;
  --avatar-shadow: 0 0 35px rgba(0, 0, 0, 0.15), 0 0 15px rgba(0, 0, 0, 0.2);
}

html.dark {
  color-scheme: dark;
  --bg:         #282828;
  --bg1:        #3c3836;
  --bg2:        #504945;
  --text:       #ebdbb2;
  --text-muted: #a89984;
  --link:       #d3869b;
  --link-hover: #fe8019;
  --hr:         #504945;
  --avatar-shadow: 0 0 35px rgba(255, 255, 255, 0.3), 0 0 15px rgba(255, 255, 255, 0.6);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.6;
  font-size: 1rem;
  overflow-x: hidden;
  transition: background-color 0.2s, color 0.2s;
}

#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
}

.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 1.5rem;
}

@media (min-width: 768px) {
  .container {
    padding: 2rem;
  }
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 500;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 1rem;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

a {
  color: var(--link);
  text-decoration: underline;
}

a:hover {
  color: var(--link-hover);
}

hr {
  border: 0;
  height: 1px;
  background: var(--hr);
  margin: 1.5rem 0;
}

/* Header */
header {
  margin-bottom: 3rem;
}
header a {
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
}
header a:hover {
  color: var(--link);
  text-decoration: underline;
}

/* Footer */
footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hr);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
footer button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  text-decoration: underline;
}
footer button:hover {
  color: var(--text);
}

/* Code */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background-color: #f2f2f2;
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-size: 0.9em;
  color: #333;
}

html.dark code {
  background-color: var(--bg1);
  color: var(--text);
}

pre {
  background-color: #f6f8fa;
  padding: 1rem;
  overflow-x: auto;
  position: relative;
  border-radius: 4px;
}

html.dark pre {
  background-color: var(--bg1);
}

pre code {
  background-color: transparent;
  padding: 0;
  font-size: 0.9em;
  color: inherit;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg2);
  color: var(--text);
  border: none;
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 3px;
  opacity: 0.7;
}
.copy-btn:hover {
  opacity: 1;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

html.dark img {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

img:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

html.dark img:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* Home page posts */
.post-list {
  display: flex;
  flex-direction: column;
}
.post-item {
  margin-bottom: 2rem;
  padding: 1.5rem;
  border-radius: 12px;
  background-color: var(--bg);
  border: 1px solid var(--hr);
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
}
.post-item:hover {
  transform: translateY(-5px) scale(1.01);
  box-shadow: 0 15px 35px rgba(0,0,0,0.08);
  border-color: var(--link);
  background-color: var(--bg2);
}
.post-item:active {
  transform: translateY(-2px) scale(0.97) !important;
  transition: transform 0.1s ease-out;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
html.dark .post-item:hover {
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.post-item h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.5px;
}
.post-item h2 a {
  text-decoration: none;
}
.post-item-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.post-meta-index {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.post-meta-header {
  font-family: monospace;
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: 2rem;
}
.post-preview {
  margin-bottom: 1rem;
}

/* Post page */
.post-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: -1rem;
  margin-bottom: 2rem;
}
.back-link {
  display: inline-block;
  margin-bottom: 2rem;
  text-decoration: none;
}

/* Footnotes */
.footnotes {
  margin-top: 3rem;
  border-top: 1px solid var(--hr);
  padding-top: 1rem;
  font-size: 0.9rem;
}
.footnotes p {
  margin: 0.5rem 0;
}

/* TOC */
.toc {
  margin-bottom: 2rem;
}
.toc strong {
  display: block;
  margin-bottom: 0.5rem;
}
.toc ul {
  list-style: decimal;
  margin: 0;
  padding-left: 1.5rem;
}
.toc li {
  margin-bottom: 0.25rem;
}
.toc a {
  text-decoration: none;
}
.toc a:hover {
  text-decoration: underline;
}

/* Progress bar */
#progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 8px;
  background-color: var(--post-bg);
  background-image: radial-gradient(var(--text-muted) 2px, transparent 2px);
  background-size: 20px 8px;
  background-position: left center;
  background-repeat: repeat-x;
  z-index: 1000;
}

#progress-bar {
  height: 100%;
  background-color: var(--bg);
  width: 0%;
  transition: width 0.2s ease-out;
  position: relative;
  overflow: visible;
}

#progress-bar::after {
  content: '';
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border: 7px solid #eab308;
  border-right-color: transparent;
  border-radius: 50%;
}

#progress-bar.is-scrolling::after {
  animation: chomp 0.2s infinite;
}

@keyframes chomp {
  0%, 100% { border-right-color: transparent; }
  50% { border-right-color: #eab308; }
}

/* Anchors */
h2, h3 {
  position: relative;
}
.anchor {
  position: absolute;
  left: -1.2em;
  opacity: 0;
  color: var(--text-muted);
  text-decoration: none;
  transition: opacity 0.2s;
  padding-right: 0.5em;
  cursor: pointer;
}
h2:hover .anchor, h3:hover .anchor {
  opacity: 1;
}

/* Custom Buttons & Header */
.read-more-btn {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.6rem 1.2rem;
  background-color: var(--link);
  color: var(--bg);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.read-more-btn:hover {
  background-color: var(--link-hover);
  color: var(--bg);
  transform: translateY(-2px);
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.main-header {
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  display: flex;
  justify-content: center;
  margin-bottom: 0;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  padding: 1.5rem 0 0 0;
}

.header-link {
  text-decoration: none;
  display: inline-block;
  position: relative;
  transition: transform 0.5s ease;
}

/* Invisible square hitbox for parallax trigger */
.header-link::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  height: 400px;
  border-radius: 50%; /* Make it a circle/square that doesn't mess with layout */
}

.header-link:hover {
  transform: scale(1.02);
  text-decoration: none;
}

.bio-section {
  text-align: justify;
  margin: 0 auto 3rem auto;
  max-width: 500px;
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1.7;
  font-weight: 300;
}

.header-text-container {
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  width: 100%;
  margin-bottom: -4rem; /* Съедаем пустое пространство */
}

.header-avatar-wrapper {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-avatar {
  width: 57.5%;
  height: 57.5%;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--avatar-shadow);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.4s ease;
  border: 5px solid rgba(255, 255, 255, 0.1);
  z-index: 2;
}

/* The Backrooms Mode */
html.backrooms-mode {
  --bg:         #d6c385;
  --bg1:        #cebb7c;
  --bg2:        #c6b26d;
  --text:       #3d3522;
  --text-muted: #5e543b;
  --link:       #8b7941;
  --link-hover: #5d4d23;
  --hr:         #bda868;
  --post-bg:    #cebb7c;
}

html.backrooms-mode, html.backrooms-mode body {
  background-image: 
    linear-gradient(90deg, rgba(160, 140, 80, 0.15) 1px, transparent 1px),
    linear-gradient(rgba(160, 140, 80, 0.15) 1px, transparent 1px),
    repeating-linear-gradient(45deg, rgba(160, 140, 80, 0.05) 0, rgba(160, 140, 80, 0.05) 2px, transparent 2px, transparent 8px),
    repeating-linear-gradient(-45deg, rgba(160, 140, 80, 0.05) 0, rgba(160, 140, 80, 0.05) 2px, transparent 2px, transparent 8px) !important;
  background-size: 30px 30px, 30px 30px, 100% 100%, 100% 100% !important;
}

html.backrooms-mode * {
  font-family: "Times New Roman", serif !important;
}

html.backrooms-mode body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9998;
  background: radial-gradient(circle, transparent 50%, rgba(20, 20, 0, 0.25) 150%);
}

html.backrooms-mode body::after {
  content: '';
  position: fixed;
  top: -10px; right: -10px;
  width: 250px; height: 250px;
  background-image: url("/public/images/spiderweb.png");
  background-repeat: no-repeat;
  background-size: cover;
  pointer-events: none;
  z-index: 9999;
}
html.backrooms-mode #bg-canvas {
  opacity: 0 !important;
}
html.backrooms-mode .main-header {
  animation: flicker 4s infinite !important;
}
@keyframes flicker {
  0%, 19.9%, 22%, 62.9%, 64%, 64.9%, 70%, 100% { opacity: 0.9; }
  20%, 21.9%, 63%, 63.9%, 65%, 69.9% { opacity: 0.2; }
}

.header-circular-text {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
  /* transition deleted, we will use animation */
}

@keyframes barrelRoll {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.header-circular-text.do-barrel-roll {
  animation: barrelRoll 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

#header-svg-circle {
  transform-origin: center;
  width: 100%;
  height: 100%;
  animation: spinSlow 40s linear infinite;
}

.header-circular-text text {
  font-family: 'Inter', sans-serif;
  font-size: 36px;
  font-weight: 800;
  fill: var(--text);
  letter-spacing: 4px;
  text-transform: uppercase;
}

@media (hover: hover) and (pointer: fine) {
  .header-link:hover .header-avatar {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 0 50px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.8);
  }
  
  .header-link:hover .header-circular-text {
    transform: scale(1.05);
  }
}



/* Post Page Specific Styles */
.post-page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--hr);
}

.post-page-title {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -1px;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.post-navigation {
  display: flex;
  width: 100%;
}

.post-navigation.bottom {
  margin-top: 3rem;
  justify-content: flex-end;
}

/* Neutral Back Button */
.back-btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background-color: var(--bg2);
  color: var(--text);
  border: 1px solid var(--hr);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.back-btn:hover {
  background-color: var(--hr);
  transform: translateY(-2px);
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* Breadcrumb / Laconic Back Link */
.breadcrumb {
  margin-bottom: 0.2rem;
  font-family: monospace;
  font-size: 0.95rem;
}

.breadcrumb-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
  display: inline-block;
}

/* Scroll Reveal */
.reveal-item {
  opacity: 0.35;
  transform: translateY(15px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.reveal-item.visible {
  opacity: 1;
  transform: translateY(0);
}


.breadcrumb-link:hover {
  color: var(--link);
  transform: translateX(-3px);
  text-decoration: none;
}
