/* Base layout helpers */
:root {
  --footer-h: 56px;
  --bg-1: #f8fafc;
  --bg-2: #eef2f7;
  --text: #0f172a;
  --muted: #475569;
  --brand: #2563eb;
  --panel-bg: #ffffff;
  --panel-border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2));
  padding-bottom: calc(var(--footer-h) + 16px);
}
.page { max-width: 980px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { color: var(--text); margin: 0 0 10px; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 650; color: #111827; }
h3 { font-size: 18px; font-weight: 600; color: #1f2937; }
p { color: var(--muted); }
a { color: var(--brand); }
code { background: #f1f5f9; color: #111827; padding: 1px 6px; border-radius: 6px; }

/* Top navigation */
.nav {
  position: sticky;
  top: 0;
  z-index: 1002;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(17, 24, 39, 0.9); /* slate-900 with opacity */
  color: #e5e7eb; /* slate-200 */
  border: 1px solid #0f172a; /* slate-900 */
  border-radius: 12px;
  backdrop-filter: saturate(140%) blur(6px);
  box-shadow: rgba(15, 23, 42, 0.25) 0 6px 18px;
}
.nav a {
  color: inherit;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 120ms ease;
}
.nav a:hover { background: rgba(255,255,255,0.12); }
.nav a:focus { outline: 2px solid #60a5fa; outline-offset: 2px; }

/* Anchor offset and section panel styling */
section {
  scroll-margin-top: 84px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 18px 0;
  box-shadow: var(--shadow);
}

/* Box Model Gallery */
#box-model-gallery { margin-top: 12px; }
.box-gallery {
  display: grid;
  grid-template-columns: 160px repeat(3, 1fr);
  gap: 12px;
  align-items: start;
}

.cell {
  background: #f7f7fa;
  border: 1px solid #e1e3eb;
  border-radius: 10px;
  padding: 10px;
  min-height: 120px;
  display: grid;
  place-items: start;
}

.cell.head {
  background: #111827;
  color: white;
  border-color: #0f172a;
  font-weight: 600;
  text-align: center;
  min-height: auto;
  display: grid;
  place-items: center;
}

.cell.rowhead {
  background: #eef2ff;
  border-color: #c7d2fe;
  font-weight: 600;
  color: #1e3a8a;
  display: grid;
  place-items: center;
}

/* Demo box defaults */
.demo {
  width: 120px;            /* content box width */
  height: 60px;            /* content box height */
  background: #dbeafe;     /* visible for margin demo */
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0 solid #2563eb; /* will change in border demo */
}

.demo .content {
  background: #fff;        /* shows padding area around it */
  border-radius: 4px;
  width: 100%;
  text-align: center;
}

/* Column value classes */
.v0 { --v: 0px; }
.v5 { --v: 5px; }
.v10 { --v: 10px; }

/* Row behaviors */
.demo.margin { margin: var(--v); }
.demo.padding { padding: var(--v); }
.demo.border  { border-width: var(--v); border-style: solid; }

/* Optional: make differences easier to see */
.demo.border { background: #e0f2fe; border-color: #0284c7; }
.demo.padding { background: #fde68a; }
.demo.margin { background: #bbf7d0; }

.container {
  max-width: 800px;
  margin: auto;
  background-color: #fafafa;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Positioning Playground */
#positioning { margin-top: 32px; }
#positioning .sticky-banner {
  position: sticky;
  top: 8px;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  color: #92400e;
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: rgba(0,0,0,0.06) 0 4px 10px;
  z-index: 3;
}

#positioning .stage {
  position: relative;
  min-height: 240px;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: repeating-linear-gradient(45deg, #f8fafc 0 10px, #f1f5f9 10px 20px);
  padding: 24px;
  margin-top: 16px;
  overflow: hidden;
}

.relative-card {
  position: relative;
  top: 10px;  /* offset from normal flow */
  left: 10px;
  background: #d1fae5;
  border: 1px solid #10b981;
  color: #064e3b;
  padding: 10px 12px;
  border-radius: 8px;
  width: max-content;
}

.absolute-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #fee2e2;
  border: 1px solid #ef4444;
  color: #7f1d1d;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: rgba(0,0,0,0.1) 0 2px 6px;
}

#positioning .explain { margin: 8px 0 0; color: #334155; }

.fixed-help {
  position: fixed;
  right: 16px;
  bottom: calc(var(--footer-h) + 16px);
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: rgba(15, 23, 42, 0.25) 0 6px 18px;
  cursor: pointer;
  z-index: 1001;
}
.fixed-help:hover { background: #1d4ed8; }

/* Fixed footer pinned to bottom */
footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111827;
  color: #e5e7eb;
  border-top: 1px solid #0f172a;
  z-index: 1000;
}
