/* ==========================================================
       📸 Project 22 – Masonry Columns with Sticky Sidebar Menu
       - NO JavaScript. Pure HTML + CSS.
       - Menu: Left vertical, sticky, slim accent bar
       - Layout: CSS columns masonry wall
       - Effects: Grayscale -> color on hover, caption ribbon
       - A11y: Alt text, focus styles, big tap areas
       ========================================================== */

/* ---------- Design Tokens (CSS variables) ---------- */
:root {
  --bg: #fbfbfb;
  --ink: #1f2937; /* text */
  --muted: #6b7280; /* secondary text */
  --accent: #059669; /* emerald-600 */
  --accent-ink: #ffffff;
  --card: #ffffff;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
  --maxw: 1200px;
  --sidew: 240px; /* sidebar width on desktop */
  --gap: 1.25rem; /* space between masonry columns */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --ink: #e5e7eb;
    --muted: #9aa2b2;
    --accent: #34d399; /* emerald-400 */
    --accent-ink: #0e1116;
    --card: #161b22;
    --border: #232a34;
    --shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
  }
}

/* ---------- Base / Reset ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
}
body {
  font-family: Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
}
img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ---------- Header (simple) ---------- */
header {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.6rem 1rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
header h1 {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  letter-spacing: 0.2px;
  margin-bottom: 0.25rem;
}
header p {
  color: var(--muted);
}

/* ---------- Page Grid (Sidebar + Content) ---------- */
.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: var(--sidew) 1fr;
  gap: 1rem;
}
@media (max-width: 900px) {
  .page {
    grid-template-columns: 1fr;
  }
}

/* ---------- Sticky Sidebar Menu ---------- */
.sidebar {
  position: sticky;
  top: 1rem; /* stays visible while scrolling */
  align-self: start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.sidebar h2 {
  font-size: 1.05rem;
  margin: 0.1rem 0 0.6rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}

/* Vertical nav: skinny accent bar + link block */
.menu {
  display: grid;
  gap: 0.35rem;
  list-style: none;
}
.menu a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--ink);
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px dashed transparent;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.menu a::before {
  content: "";
  width: 4px;
  height: 1.2em;
  border-radius: 6px;
  background: var(--border); /* neutral when idle */
  flex: 0 0 4px;
}
.menu a:hover {
  background: rgba(5, 150, 105, 0.08);
  border-color: rgba(5, 150, 105, 0.35);
  transform: translateX(2px);
}
.menu a:hover::before {
  background: var(--accent);
}

/* ---------- Masonry Columns ---------- */
.masonry {
  /* Columns produce the "waterfall" effect */
  column-count: 3;
  column-gap: var(--gap);
}
@media (max-width: 1200px) {
  .masonry {
    column-count: 2;
  }
}
@media (max-width: 680px) {
  .masonry {
    column-count: 1;
  }
}

/* Each card must avoid splitting across columns */
.card {
  break-inside: avoid; /* key line for masonry cards */
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0 0 var(--gap);
  overflow: hidden;
  transform: translateZ(0); /* improves rendering on some GPUs */
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.14);
}

/* Image styling: consistent crop + grayscale effect on idle */
.thumb {
  width: 100%;
  /* Use a gentle default height hint; allow natural height too */
  aspect-ratio: 16/10;
  object-fit: cover;
  filter: grayscale(0.35) contrast(1.05);
  transition: filter 0.35s ease, transform 0.45s ease;
}
.card:hover .thumb {
  filter: grayscale(0);
  transform: scale(1.04);
}

.pad {
  padding: 0.9rem 1rem 1rem;
}
.title {
  font-size: 1.15rem;
  color: var(--accent);
  margin: 0.15rem 0 0.4rem;
  line-height: 1.25;
}
.lede {
  margin: 0 0 0.65rem;
  color: var(--ink);
}
.meta {
  color: var(--muted);
  font-size: 0.95rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.55rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

/* Small caption ribbon that sits over the image’s bottom-left corner */
.ribbon {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  background: rgba(5, 150, 105, 0.92);
  color: var(--accent-ink);
  font-size: 0.82rem;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(5, 150, 105, 0.35);
}
.card-figure {
  position: relative;
} /* to anchor the ribbon */

/* ---------- Focus styles for accessibility ---------- */
a:focus-visible {
  outline: 3px solid rgba(5, 150, 105, 0.35);
  outline-offset: 2px;
  border-radius: 10px;
}
