/* Blog — Matching GUI Aesthetic with Sidebar */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400;500;600&family=Syne:wght@700;800&display=swap');

:root {
  --bg:        #0b0b0b;
  --bg-2:      #111111;
  --border:    #1e1e1e;
  --border-2:  #2a2a2a;
  --text:      #e8e8e8;
  --text-2:    #777777;
  --text-3:    #3a3a3a;
  --t-blue:    #1793d1;
  --t-red:     #d45452;
  --mono:      'IBM Plex Mono', monospace;
  --display:   'Syne', sans-serif;
  --sidebar-w: 220px;
  --titlebar-h: 32px;
  --transition: all 0.18s ease;
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px;
  line-height: 1.6;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 52px 52px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

/* ── Mac Window ── */
.mac-window {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1320px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
}

/* ── Titlebar ── */
.mac-titlebar {
  height: var(--titlebar-h);
  background: #161616;
  border-bottom: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  padding: 0 14px;
  position: sticky;
  top: 0;
  z-index: 200;
  -webkit-user-select: none;
  user-select: none;
}

.mac-buttons { display: flex; gap: 7px; align-items: center; }

.mac-button {
  width: 12px; height: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  border: none; outline: none;
}

.mac-button.close    { background: #d45452; }
.mac-button.minimize { background: #d4a03a; }
.mac-button.maximize { background: #3da65c; }
.mac-button:hover { filter: brightness(1.2); }

.mac-button.close:hover::after,
.mac-button.minimize:hover::after,
.mac-button.maximize:hover::after {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-size: 9px; font-weight: 700; line-height: 1;
}
.mac-button.close:hover::after    { content: '×'; color: #6b1a1a; }
.mac-button.minimize:hover::after { content: '−'; color: #6b4a10; }
.mac-button.maximize:hover::after { content: '+'; color: #1a5030; }

.mac-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ── Mac Body (sidebar + content) ── */
.mac-body {
  display: flex;
  height: calc(100vh - var(--titlebar-h) - 48px);
  overflow: hidden;
}

/* ══════════════════════════════
   SIDEBAR
══════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #0d0d0d;
  border-right: 1px solid var(--border-2);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-name {
  font-family: var(--display);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.02em;
  line-height: 1.1;
  text-decoration: none;
  display: block;
  transition: var(--transition);
}
.sidebar-name:hover { color: var(--t-blue); }

.sidebar-handle {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-2);
  margin-top: 4px;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.sidebar-section-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 10px 18px 4px;
}

.sidebar-nav ul { list-style: none; }

.sidebar-nav ul li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-2);
  text-decoration: none;
  transition: var(--transition);
  border-left: 2px solid transparent;
  letter-spacing: 0.03em;
}

.sidebar-nav ul li a:hover,
.sidebar-nav ul li a.active {
  color: var(--text);
  border-left-color: var(--t-blue);
  background: rgba(23, 147, 209, 0.05);
  padding-left: 20px;
}

.sidebar-nav ul li a .nav-prefix {
  color: var(--t-blue);
  font-size: 0.65rem;
  opacity: 0.7;
  flex-shrink: 0;
}
.sidebar-nav ul li a:hover .nav-prefix { opacity: 1; }

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 18px;
}

.sidebar-ext a { color: var(--text-2) !important; }
.sidebar-ext a:hover { color: var(--t-blue) !important; border-left-color: var(--t-blue) !important; }
.sidebar-ext a.exit-link:hover { color: var(--t-red) !important; border-left-color: var(--t-red) !important; }

.menu-toggle { display: none; }

/* ══════════════════════════════
   MAIN CONTENT
══════════════════════════════ */
.mac-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
  display: flex;
  flex-direction: column;
}

.mac-content::-webkit-scrollbar { width: 4px; }
.mac-content::-webkit-scrollbar-track { background: transparent; }
.mac-content::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

main {
  flex: 1;
  padding: 2rem 2.5rem;
}

footer {
  padding: 0.65rem 2.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.63rem;
  color: var(--text-3);
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-align: center;
  background: var(--bg);
}
footer p { color: var(--text-3); margin: 0; }

/* ── Section heading ── */
h2 {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--t-blue);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding-bottom: 0.6rem;
  margin: 0 0 1.5rem 0;
  border-bottom: 1px solid var(--border-2);
  position: relative;
}

h2::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 32px; height: 1px;
  background: var(--t-blue);
}

/* ══════════════════════════════
   ARTICLES GRID — edge-to-edge
══════════════════════════════ */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
}

/* ── Post Card — horizontal layout ── */
.post {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 240px 1fr;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  min-height: 200px;
}

.post:hover {
  border-color: rgba(23, 147, 209, 0.3);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

.post-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-right: 1px solid var(--border-2);
  display: block;
  transition: opacity 0.18s ease;
}
.post:hover .post-image { opacity: 0.9; }

.post-content {
  padding: 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}

.post-tag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text);
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.post-content h3 {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin: 0 0 0.5rem;
  letter-spacing: 0.02em;
}

.post-date {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-2);
  margin-bottom: 0.75rem;
  display: block;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.post-preview {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.65;
  color: #9a9a9a;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1rem;
  flex: 1;
}

.read-more {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: rgba(23, 147, 209, 0.08);
  color: var(--t-blue);
  border: 1px solid rgba(23, 147, 209, 0.25);
  border-radius: 3px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.68rem;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  align-self: flex-start;
}

.read-more:hover {
  background: rgba(23, 147, 209, 0.15);
  border-color: rgba(23, 147, 209, 0.4);
  color: #4ab8e8;
}

/* ══════════════════════════════
   MODAL
══════════════════════════════ */
.hidden { display: none !important; }

#modal-backdrop {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
}
#modal-backdrop:not(.hidden) { opacity: 1; }

#article-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 90%;
  max-width: 820px;
  max-height: 85vh;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  z-index: 1001;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
  transition: all 0.2s ease;
}
#article-modal:not(.hidden) {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.modal-content {
  padding: 2.2rem 2.8rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}
.modal-content::-webkit-scrollbar { width: 4px; }
.modal-content::-webkit-scrollbar-track { background: transparent; }
.modal-content::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.close-button {
  position: absolute;
  top: 0.75rem; right: 0.75rem;
  width: 2rem; height: 2rem;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 3px;
  color: var(--text-2);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 10;
}
.close-button:hover {
  color: var(--text);
  border-color: var(--t-blue);
  background: rgba(23, 147, 209, 0.05);
}

#modal-title {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
  color: var(--text);
  line-height: 1.3;
  letter-spacing: 0.02em;
}

#modal-date {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-2);
  display: block;
  margin-bottom: 1.3rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#modal-image {
  width: 100%;
  height: auto;
  max-height: 360px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 1.3rem;
  border: 1px solid var(--border-2);
}

#modal-text {
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.78;
  color: #9a9a9a;
}
#modal-text p { margin-bottom: 1rem; }
#modal-text p:last-child { margin-bottom: 0; }

.error { color: var(--t-red); text-align: center; padding: 2rem; }

/* ══════════════════════════════
   RESPONSIVE
══════════════════════════════ */
@media (max-width: 900px) {
  body { padding: 0; }

  .mac-window {
    border-radius: 0;
    min-height: 100vh;
    border: none;
    overflow: visible;
  }

  .mac-titlebar {
    position: sticky;
    top: 0;
    z-index: 300;
    border-radius: 0;
  }

  .mac-body {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-2);
    overflow: visible;
    position: sticky;
    top: var(--titlebar-h);
    z-index: 100;
    background: #0d0d0d;
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
  }

  .sidebar-name { font-size: 0.75rem; }
  .sidebar-handle { display: none; }

  .sidebar-nav {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 200;
    background: #0d0d0d;
    border: 1px solid var(--border-2);
    border-top: none;
    padding: 4px 0 6px;
    width: auto;
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  }
  .sidebar-nav.open { display: block; }

  .sidebar-section-label { padding: 5px 12px 2px; font-size: 0.54rem; white-space: nowrap; }
  .sidebar-nav ul li a { padding: 5px 18px 5px 12px; font-size: 0.72rem; white-space: nowrap; }
  .sidebar-divider { margin: 3px 12px; }

  .menu-toggle {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    gap: 4px;
    padding: 4px;
  }
  .menu-toggle div { width: 18px; height: 2px; background: var(--text-2); border-radius: 1px; transition: var(--transition); }

  .mac-content { overflow: visible; height: auto; }
  main { padding: 1.5rem 1.2rem; }
  footer { padding: 0.5rem 1.2rem; }

  /* Stack to single column */
  .articles-grid { grid-template-columns: 1fr; gap: 1rem; }

  /* Vertical card layout on mobile */
  .post { grid-template-columns: 1fr; min-height: auto; }
  .post-image { height: 200px; border-right: none; border-bottom: 1px solid var(--border-2); }
}

@media (max-width: 600px) {
  main { padding: 1rem 0.9rem; }
  .post-content { padding: 1rem 1.1rem; }
  .post-content h3 { font-size: 0.9rem; }
  .post-preview { font-size: 0.78rem; }
  #modal-title { font-size: 1.2rem; }
  .modal-content { padding: 1.5rem 1.2rem; }
}

@media (max-width: 900px) {
  #article-modal { width: 95%; max-height: 90vh; }
  .modal-content { max-height: calc(90vh - 1rem); }
}
