<div class="infographic-dbadv" id="dbadvWrap">
<style>
.infographic-dbadv {
--ink: #1a1a1a;
--ink-soft: #5c5c5c;
--paper: #ffffff;
--paper-alt: #f6f3ee;
--accent: #2563eb;
--accent-soft:#e3ebfd;
--line: #ddd6c9;
background: var(--paper);
color: var(--ink);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
padding: 2.5rem 1.5rem;
border-radius: 14px;
box-sizing: border-box;
max-width: 920px;
margin: 0 auto;
}
.infographic-dbadv[data-theme="dark"] {
--ink: #e8e6e1;
--ink-soft: #9a968c;
--paper: #121212;
--paper-alt: #1e1e26;
--accent: #5b8def;
--accent-soft:#202942;
--line: #2c313d;
}
.infographic-dbadv * { box-sizing: border-box; }
.dbadv-eyebrow {
font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
color: var(--accent); font-weight: 700; margin: 0 0 0.4rem;
}
.dbadv-title { font-size: 1.55rem; font-weight: 700; margin: 0 0 0.4rem; letter-spacing: -0.01em; }
.dbadv-sub { font-size: 0.9rem; color: var(--ink-soft); margin: 0 0 1.75rem; max-width: 55ch; }
/* --- Advantage hub: grid + detail panel (desktop) --- */
.dbadv-hub { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1.5rem; align-items: start; }
.dbadv-grid {
display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; align-content: start;
}
.dbadv-cell { display: flex; flex-direction: column; }
.dbadv-item {
display: flex; align-items: center; gap: 0.65rem;
background: var(--paper-alt); border: 1px solid var(--line); border-radius: 9px;
padding: 0.6rem 0.7rem; font: inherit; color: var(--ink); text-align: left;
cursor: pointer; transition: border-color .15s, background .15s;
width: 100%;
}
.dbadv-item:hover { border-color: var(--accent); }
.dbadv-item.is-active { background: var(--accent-soft); border-color: var(--accent); }
.dbadv-badge {
flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
background: var(--paper); border: 1.5px solid var(--line);
display: flex; align-items: center; justify-content: center;
font-size: 0.72rem; font-weight: 700; color: var(--ink-soft);
}
.dbadv-item.is-active .dbadv-badge { border-color: var(--accent); color: var(--accent); }
.dbadv-item-label { font-size: 0.82rem; font-weight: 600; line-height: 1.25; }
.dbadv-panel {
background: var(--paper-alt); border: 1px solid var(--line); border-radius: 12px;
padding: 1.4rem 1.5rem; min-height: 220px;
}
.dbadv-panel-title { font-size: 1.05rem; font-weight: 700; margin: 0 0 0.9rem; color: var(--accent); }
.dbadv-panel-text { font-size: 0.9rem; line-height: 1.55; margin: 0; }
/* --- Inline accordion detail (mobile only, hidden on desktop) --- */
.dbadv-detail {
display: none;
overflow: hidden;
max-height: 0;
opacity: 0;
}
.dbadv-detail-inner {
background: var(--accent-soft); border: 1px solid var(--line); border-top: none;
border-radius: 0 0 9px 9px; padding: 0.7rem 0.8rem; margin-top: -1px;
}
.dbadv-detail-text { font-size: 0.82rem; line-height: 1.45; margin: 0; }
@media (max-width: 700px) {
.dbadv-hub { grid-template-columns: 1fr; gap: 0; }
.dbadv-grid { grid-template-columns: 1fr; gap: 0.5rem; }
.dbadv-panel { display: none; }
.dbadv-cell.is-active .dbadv-item { border-radius: 9px 9px 0 0; }
.dbadv-detail {
display: block;
transition: max-height .35s ease, opacity .3s ease;
}
.dbadv-cell.is-active .dbadv-detail {
max-height: 260px;
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.infographic-dbadv *, .infographic-dbadv *::before, .infographic-dbadv *::after {
animation-duration: 0.001ms !important; transition-duration: 0.001ms !important;
}
}
</style>
<p class="dbadv-eyebrow">Why Use a DBMS</p>
<h2 class="dbadv-title">Advantages of a Database</h2>
<p class="dbadv-sub">Eleven reasons teams choose a DBMS over plain files — click one to see why it matters.</p>
<div class="dbadv-hub">
<div class="dbadv-grid" id="dbadvGrid"></div>
<div class="dbadv-panel" id="dbadvPanel"></div>
</div>
</div>
<script>
(function () {
var wrapper = document.getElementById('dbadvWrap');
// Dark mode detection — body attribute wins, then cookie, then light default
var bodyAttr = document.body.getAttribute('data-darkmode');
var dark;
if (bodyAttr === 'true') {
dark = true;
} else if (bodyAttr === 'false') {
dark = false;
} else {
var match = document.cookie.match(/(?:^|;\s*)darkMode=([^;]+)/);
dark = match ? match[1] === 'true' : false;
}
if (dark) wrapper.setAttribute('data-theme', 'dark');
var advantages = [
{ title: 'Data Redundancy Control', detail: 'Integrates all data into one database, minimizing duplicate copies across systems.' },
{ title: 'Data Consistency', detail: 'Centralized data means updates reflect everywhere instantly, keeping information accurate.' },
{ title: 'Improved Data Sharing', detail: 'Authorized users across departments access the same data, enabling collaboration.' },
{ title: 'Better Data Security', detail: 'Authentication and access control let only authorized users view or edit data.' },
{ title: 'Data Integrity', detail: 'Constraints enforce correctness — e.g. age can\u2019t be negative, IDs must be unique.' },
{ title: 'Data Backup & Recovery', detail: 'Automatic backup tools restore data to its prior state after a system failure.' },
{ title: 'Easy Data Access', detail: 'Query languages like SQL let users retrieve data without writing complex programs.' },
{ title: 'Multi-user Access', detail: 'Concurrency control lets many users work at once without affecting each other.' },
{ title: 'Faster App Development', detail: 'DBMS handles storage and access, freeing developers to focus on app logic.' },
{ title: 'Scalability & Flexibility', detail: 'Easily expands to handle growing data volume or a growing user base.' },
{ title: 'Enhanced Decision-Making', detail: 'Accurate, well-organized data supports better business intelligence.' }
];
var grid = document.getElementById('dbadvGrid');
var panel = document.getElementById('dbadvPanel');
function renderPanel(i) {
var a = advantages[i];
panel.innerHTML =
'<h3 class="dbadv-panel-title">' + a.title + '</h3>' +
'<p class="dbadv-panel-text">' + a.detail + '</p>';
}
var cells = [];
advantages.forEach(function (a, i) {
var cell = document.createElement('div');
cell.className = 'dbadv-cell' + (i === 0 ? ' is-active' : '');
var btn = document.createElement('button');
btn.type = 'button';
btn.className = 'dbadv-item' + (i === 0 ? ' is-active' : '');
btn.innerHTML = '<span class="dbadv-badge">' + (i + 1) + '</span><span class="dbadv-item-label">' + a.title + '</span>';
var detail = document.createElement('div');
detail.className = 'dbadv-detail';
detail.innerHTML =
'<div class="dbadv-detail-inner"><p class="dbadv-detail-text">' + a.detail + '</p></div>';
btn.addEventListener('click', function () {
cells.forEach(function (c) {
c.classList.remove('is-active');
c.querySelector('.dbadv-item').classList.remove('is-active');
});
cell.classList.add('is-active');
btn.classList.add('is-active');
renderPanel(i);
});
cell.appendChild(btn);
cell.appendChild(detail);
grid.appendChild(cell);
cells.push(cell);
});
renderPanel(0);
})();
</script>.demo {
font-family: system-ui, sans-serif;
padding: 16px;
}
.demo h1 {
color: #2563eb;
margin: 0 0 8px;
}
.demo p {
color: #4b5563;
margin: 0;
}document.querySelector('.demo h1')?.addEventListener('click', () => {
alert('Hello from live preview!');
});