@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,600;1,400&family=Lora:ital,wght@0,400;0,700;1,400&display=swap');

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

:root {
  --bg:       #f5f0e8;
  --paper:    #faf8f3;
  --ink:      #1a1a18;
  --muted:    #6b6860;
  --rule:     #ccc8be;
  --accent:   #c0392b;
  --link:     #2a5a8c;
  --mono:     'IBM Plex Mono', monospace;
  --serif:    'Lora', Georgia, serif;
  --sidebar-w: 220px;
}

html {
  font-size: 16px;
  background: var(--bg);
  color: var(--ink);
}

body {
  font-family: var(--serif);
  line-height: 1.75;
  margin: 0;
  min-height: 100vh;
}

/* ===== LAYOUT ===== */
.site-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

.content-area {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  margin: 2rem 0;
}

main {
  flex: 1;
  min-width: 0;
}

.content-area:has(main:only-child) main {
  max-width: 100%;
}

/* ===== HEADER ===== */
.site-header {
  border-bottom: 2px solid var(--ink);
  padding: 1.2rem 0 0.8rem;
  margin-bottom: 0;
}

.site-header .wordmark {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
  margin-right: 2rem;
}

.site-header .wordmark:hover {
  color: var(--accent);
}

.site-nav {
  display: inline-block;
}

.site-nav a {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  margin-right: 1rem;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--ink);
  text-decoration: underline wavy var(--accent) 1px;
  text-underline-offset: 0.2rem;
}

/* ===== FOOTER ===== */
.site-footer {
  border-top: 2px solid var(--rule);
  margin-top: 3rem;
  padding: 2rem 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ===== FOOTER STACK (horizontal app stats) ===== */
.footer-stack {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 2px solid var(--rule);
}

.footer-stack h3 {
  font-family: var(--mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 1rem 0;
  color: var(--muted);
  text-align: center;
}

.footer-stack .stack-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem 2rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-stack .stack-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  line-height: 1.3;
  min-width: 120px;
}

.footer-stack .stack-icon {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  color: var(--muted);
}

.footer-stack .stack-icon svg {
  width: 100%;
  height: 100%;
}

.footer-stack .stack-label {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink);
}

.footer-stack .stack-dot {
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  margin-left: 0.25rem;
}

.footer-stack .stack-dot.online {
  background-color: #3a9e5f;
  animation: stack-pulse 2.4s ease-in-out infinite;
}

.footer-stack .stack-dot.offline {
  background-color: #c0392b44;
  border: 1px solid var(--accent);
}

.footer-stack .stack-unreachable {
  text-align: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  font-style: italic;
}

/* ===== SIDEBAR (vertical stack for other pages) ===== */
.sidebar {
  width: var(--sidebar-w, 220px);
  flex-shrink: 0;
}

.sidebar h3 {
  font-family: var(--mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 1rem 0;
  color: var(--muted);
}

.sidebar .stack-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar .stack-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
  line-height: 1.3;
}

.sidebar .stack-icon {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  color: var(--muted);
  display: flex;
  align-items: center;
}

.sidebar .stack-icon svg {
  width: 100%;
  height: 100%;
}

.sidebar .stack-label {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink);
}

.sidebar .stack-dot {
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  position: relative;
}

.sidebar .stack-dot.online {
  background-color: #3a9e5f;
  box-shadow: 0 0 0 0 rgba(58, 158, 95, 0.6);
  animation: stack-pulse 2.4s ease-in-out infinite;
}

.sidebar .stack-dot.offline {
  background-color: #c0392b44;
  border: 1px solid var(--accent);
}

.sidebar-block {
  margin-bottom: 2rem;
}

.sidebar-block ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-block ul li {
  margin-bottom: 0.75rem;
}

.sidebar-block ul li a {
  color: var(--ink);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.sidebar-block ul li a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.sidebar-block .post-date {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
}

.sidebar-block .post-tag {
  display: inline-block;
  font-size: 0.65rem;
  background: var(--rule);
  padding: 0 0.3em;
  margin-left: 0.3em;
  color: var(--muted);
}

/* ===== PROJECT LIST (projects.php and stack.php) ===== */
.project-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem 0;
}

.project-list li {
  border-bottom: 1px solid var(--rule);
  padding: 1rem 0;
  position: relative;
}

.project-list li:first-child {
  padding-top: 0;
}

.project-list .proj-name {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  display: inline;
}

.project-list .proj-name:hover {
  color: var(--accent);
}

.project-list .proj-lang {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--rule);
  padding: 0.15rem 0.4rem;
  margin-left: 0.5rem;
  border-radius: 3px;
  display: inline-block;
}

.project-list .proj-desc {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0.25rem 0 0 0;
}

/* Status dots for stack.php - positioned left of project name */
.project-list.has-dots li {
  padding-left: 1.5rem;
}

.project-list .stack-dot {
  position: absolute;
  left: 0;
  top: 1.2rem;
  width: 0.75rem;
  height: 0.75rem;
  display: inline-block;
  border-radius: 50%;
  border: none;
}

.project-list .stack-dot.online {
  background-color: #3a9e5f;
}

.project-list .stack-dot.offline {
  background-color: #c0392b;
}

.project-list .stack-dot.unknown {
  background-color: #888;
  opacity: 0.3;
}

/* ===== POST LIST (blog) ===== */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  border-bottom: 1px solid var(--rule);
  padding: 1.2rem 0;
}

.post-list li:first-child {
  padding-top: 0;
}

.post-list .post-title {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  display: block;
  margin-bottom: 0.2rem;
}

.post-list .post-title:hover {
  color: var(--accent);
}

.post-list .post-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.post-list .post-meta .tag {
  background: var(--rule);
  padding: 0 0.35em;
  margin-left: 0.4em;
}

.post-list .post-excerpt {
  font-size: 0.95rem;
  color: var(--muted);
}

/* ===== PHOTO GRID ===== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.6rem;
  margin-top: 1rem;
}

.photo-thumb {
  display: block;
  position: relative;
  overflow: hidden;
  background: var(--rule);
  aspect-ratio: 1;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s;
}

.photo-thumb:hover img {
  opacity: 0.85;
}

.photo-thumb .photo-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(26, 26, 24, 0.78);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 0.35rem 0.5rem;
  transform: translateY(100%);
  transition: transform 0.18s;
  line-height: 1.3;
}

.photo-thumb:hover .photo-overlay {
  transform: translateY(0);
}

/* ===== ANIMATIONS ===== */
@keyframes stack-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(58, 158, 95, 0.55); }
  60%  { box-shadow: 0 0 0 4px rgba(58, 158, 95, 0); }
  100% { box-shadow: 0 0 0 0 rgba(58, 158, 95, 0); }
}

/* ===== UTILITY CLASSES ===== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.stack-unreachable {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
  font-style: italic;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .content-area {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
  }
  
  .site-nav {
    display: block;
    margin-top: 0.5rem;
  }
  
  .site-nav a {
    display: inline-block;
    margin-bottom: 0.25rem;
  }
  
  .footer-stack .stack-list {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }
  
  .footer-stack .stack-item {
    min-width: auto;
  }
}
