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

body {
  margin: 0;
  font-family: monospace;
  background: #f8f8f8;
  color: #222;
}

/* ---- Nav ---- */
nav {
  font-family: monospace;
  font-size: 0.85em;
  padding: 12px 20px;
  border-bottom: 1px solid #e0e0e0;
}
nav a { color: inherit; text-decoration: none; }
nav a:hover { text-decoration: underline; }

/* ---- Layout ---- */
main {
  max-width: 900px;
  margin: auto;
  padding: 40px 24px 80px;
}

h1 {
  font-size: 1.6rem;
  margin: 0 0 8px;
}

h2 {
  font-size: 1rem;
  margin: 0 0 4px;
  color: #222;
}

p {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: #aaa;
  line-height: 1.5;
}
p code {
  background: #fff;
  border: 1px solid #e0e0e0;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.9em;
  color: #222;
}

.section {
  margin-top: 48px;
  padding: 28px 24px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

/* ---- Shared grid cell style ---- */
.grid-cell {
  background: #222;
  color: #fff;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  padding: 8px;
  text-align: center;
}

/* ==== 1. Named Grid Areas ==== */
.named-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  grid-template-rows: 48px 120px 48px;
  grid-template-areas:
    "header  header"
    "sidebar main"
    "footer  footer";
  gap: 6px;
  margin-top: 16px;
}

.area-header  { grid-area: header;  background: #222;  color: #fff; display:flex; align-items:center; padding-left:16px; border-radius: 3px; font-size:0.82rem; }
.area-sidebar { grid-area: sidebar; background: #555;  color: #fff; display:flex; align-items:center; justify-content:center; border-radius: 3px; font-size:0.82rem; }
.area-main    { grid-area: main;    background: #e0e0e0; color: #222; display:flex; align-items:center; justify-content:center; border-radius: 3px; font-size:0.82rem; }
.area-footer  { grid-area: footer;  background: #aaa;  color: #fff; display:flex; align-items:center; padding-left:16px; border-radius: 3px; font-size:0.82rem; }

/* ==== 2. auto-fill + minmax Gallery ==== */
.autofill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  margin-top: 16px;
}

.gallery-item {
  background: #222;
  color: #fff;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  font-size: 0.85rem;
  transition: background 0.2s;
}
.gallery-item:hover { background: #555; }

/* ==== 3. Dense Packing ==== */
.dense-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 60px;
  grid-auto-flow: dense;
  gap: 6px;
  margin-top: 16px;
}

.dense-item {
  background: #222;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  font-size: 0.75rem;
  transition: background 0.2s;
}
.dense-item:hover { background: #444; }

.span-col-2 { grid-column: span 2; }
.span-col-3 { grid-column: span 3; }
.span-row-2 { grid-row: span 2; }

/* Slight shade variation for visual distinction */
.dense-item:nth-child(odd)  { background: #2a2a2a; }
.dense-item:nth-child(3n)   { background: #383838; }

/* ==== 4. Nested / Subgrid-style Layout ==== */
.nested-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto 1fr;
  gap: 12px;
  margin-top: 16px;
}

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

.nested-card {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 3;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
}

.nested-card-img {
  background: linear-gradient(135deg, #222 0%, #555 100%);
  height: 100px;
}
.nested-card-img.tall  { height: 140px; }
.nested-card-img.short { height: 70px; }

.nested-card-title {
  padding: 12px 14px 0;
  font-size: 0.9rem;
  font-weight: bold;
  color: #222;
}

.nested-card-body {
  padding: 8px 14px 16px;
  font-size: 0.78rem;
  color: #aaa;
  line-height: 1.5;
}
