/* =============================================
   CSS Layouts — original design
   Aesthetic: technical documentation style,
   dark header sections, colour-coded examples,
   code snippets inline
============================================= */

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

:root {
    --bg:       #f2f2f0;
    --bg-alt:   #e8e4de;
    --ink:      #1a1a1a;
    --muted:    #666;
    --rule:     #d0ccc4;
    --purple:   #6c63ff;
    --teal:     #2a9d8f;
    --orange:   #f4a261;
    --red:      #e05260;
    --green:    #3a7d44;
    --sans:     Verdana, Geneva, sans-serif;
    --mono:     'Courier New', Courier, monospace;
}

body {
    font-family: var(--sans);
    font-size: 0.88rem;
    line-height: 1.7;
    background: var(--bg);
    color: var(--ink);
}

code {
    font-family: var(--mono);
    font-size: 0.82em;
    background: rgba(0,0,0,0.07);
    padding: 1px 5px;
    border-radius: 2px;
}

small { font-size: 0.82em; opacity: 0.7; }

/* ── Page header ── */
.page-header {
    background: #111;
    color: #fff;
    padding: 2.5rem 3rem;
    border-bottom: 4px solid var(--purple);
}

.page-header h1 {
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: #fff;
    font-family: var(--sans);
}

.page-header p {
    color: rgba(255,255,255,0.45);
    font-family: var(--mono);
    font-size: 0.8rem;
    margin-top: 0.4rem;
    letter-spacing: 0.1em;
}

/* ── Demo sections ── */
.demo-section {
    padding: 2.5rem 3rem;
    background: var(--bg);
}

.demo-section.alt {
    background: var(--bg-alt);
}

/* ── Demo meta (label + prose) ── */
.demo-meta {
    margin-bottom: 1.5rem;
}

.demo-meta h2 {
    font-size: 1.05rem;
    font-weight: bold;
    color: var(--ink);
    margin: 0.4rem 0 0.5rem;
}

.demo-meta p {
    color: var(--muted);
    font-size: 0.82rem;
    max-width: 680px;
}

/* ── Badges ── */
.badge {
    display: inline-block;
    background: var(--purple);
    color: white;
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    padding: 3px 10px;
    text-transform: uppercase;
}
.badge-teal   { background: var(--teal); }
.badge-orange { background: #c96a2a; }
.badge-green  { background: var(--green); }
.badge-purple { background: #5a3fa0; }

/* ══ PART 1 — CSS GRID ══ */

.grid-demo {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: 56px 220px 44px;
    gap: 6px;
    max-width: 860px;
}

.gd-header, .gd-footer, .gd-sidebar, .gd-main {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: white;
    padding: 0.5rem 1rem;
    text-align: center;
}

.gd-header {
    grid-column: 1 / -1;
    background: #6c63ff;
    font-weight: bold;
}

.gd-sidebar {
    background: #e05260;
    flex-direction: column;
    gap: 4px;
}

.gd-main {
    background: #f0f0ec;
    color: var(--ink);
    font-family: var(--sans);
    font-size: 0.82rem;
    align-items: flex-start;
    flex-direction: column;
    justify-content: flex-start;
    padding: 1.2rem 1.5rem;
    gap: 0.6rem;
}

.gd-main p {
    color: var(--muted);
    font-size: 0.8rem;
}

.gd-footer {
    grid-column: 1 / -1;
    background: #333;
    font-weight: bold;
}

/* ══ PART 1B — GALLERY ══ */

.grid-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    max-width: 860px;
}

.gallery-cell {
    background: #333;
    color: white;
    height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.82rem;
    text-align: center;
    gap: 4px;
    overflow: hidden;
    position: relative;
}

.gallery-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-cell span {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.55);
    padding: 4px 6px;
    font-size: 0.78rem;
    line-height: 1.4;
}

/* ══ PART 2 — FLEXBOX NAVBAR ══ */

.flex-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1a1a1a;
    padding: 0 1.5rem;
    max-width: 860px;
}

.flex-navbar__logo {
    color: white;
    font-weight: bold;
    font-size: 0.95rem;
    padding: 0.8rem 0;
    letter-spacing: 0.04em;
}

.flex-navbar__links {
    list-style: none;
    display: flex;
}

.flex-navbar__links a {
    display: inline-block;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 0.9rem 1rem;
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.flex-navbar__links a:hover,
.flex-navbar__links a.active {
    color: white;
    border-bottom-color: var(--purple);
}

.flex-navbar__cta {
    background: var(--purple);
    color: white;
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: bold;
    padding: 0.5rem 1.2rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: background 0.2s;
}

.flex-navbar__cta:hover { background: #5048cc; }

/* ══ PART 2B — FLEX CARDS ══ */

.flex-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-width: 860px;
}

.flex-card {
    flex: 1 1 260px;
    background: white;
    border-top: 3px solid #c96a2a;
    padding: 1.2rem 1.4rem;
}

.flex-card__num {
    font-family: var(--mono);
    font-size: 1.8rem;
    font-weight: bold;
    color: #e8d8cc;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.flex-card h3 {
    font-size: 0.9rem;
    color: var(--ink);
    margin-bottom: 0.4rem;
}

.flex-card p {
    font-size: 0.8rem;
    color: var(--muted);
}

/* ══ PART 3 — COMBINED ══ */

.combined {
    display: grid;
    grid-template-columns: 170px 1fr;
    grid-template-rows: auto 1fr auto;
    max-width: 860px;
    border: 1px solid var(--rule);
    overflow: hidden;
}

.cmb-header {
    grid-column: 1 / -1;
    background: #1a1a1a;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.2rem;
}

.cmb-brand {
    font-size: 0.88rem;
    font-weight: bold;
}

.cmb-nav {
    display: flex;
}

.cmb-nav a {
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: bold;
    padding: 0.5rem 0.9rem;
    transition: color 0.2s;
}

.cmb-nav a:hover { color: white; }

.cmb-sidebar {
    background: var(--green);
    color: white;
    padding: 1.2rem 1rem;
    font-size: 0.8rem;
}

.cmb-sidebar h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.65;
    margin-bottom: 0.8rem;
}

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

.cmb-sidebar li {
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    cursor: pointer;
    transition: opacity 0.2s;
}

.cmb-sidebar li.active { font-weight: bold; }
.cmb-sidebar li:last-child { border-bottom: none; }

.cmb-main {
    background: white;
    padding: 1.2rem 1.5rem;
    font-size: 0.82rem;
}

.cmb-main h3 {
    color: var(--ink);
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
}

.cmb-main p {
    color: var(--muted);
    margin-bottom: 1rem;
}

.cmb-cards {
    display: flex;
    gap: 8px;
}

.cmb-card {
    flex: 1;
    background: var(--ac, #888);
    color: white;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.78rem;
}

.cmb-footer {
    grid-column: 1 / -1;
    background: #333;
    color: rgba(255,255,255,0.45);
    text-align: center;
    padding: 0.6rem;
    font-family: var(--mono);
    font-size: 0.7rem;
}

/* ══ PART 4 — FLUID & RESPONSIVE ══ */

.fluid-wrap {
    background: #ebe5db;
    padding: 1rem;
}

/* Outer wrapper controlled by media queries */
#fluid-inner {
    float: left;
    width: 100%;
    background: #f7f3ed;
}

#fluid-head {
    float: left;
    clear: both;
    width: 100%;
    text-align: center;
    padding: 1.2rem 1rem 0.6rem;
    background: #3a5a40;
    color: white;
}

#fluid-head h2 {
    font-size: 1rem;
    font-weight: bold;
    color: white;
}

#fluid-head p {
    font-size: 0.78rem;
    opacity: 0.65;
    margin-top: 0.2rem;
}

#fluid-boxes {
    float: left;
    width: 100%;
    padding: 8px 4px;
}

/* The floating boxes — classic fluid layout */
.fbox {
    float: left;
    margin: 5px;
    padding: 10px;
    width: 285px;
    height: 480px;
    border: 1px solid #c0b89a;
    background: white;
}

.fbox img {
    width: 280px;
    display: block;
    margin-bottom: 8px;
}

.fbox h3 {
    font-size: 0.88rem;
    color: #3a5a40;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #e8e0d0;
    padding-bottom: 0.4rem;
}

.fbox p {
    font-size: 0.78rem;
    color: var(--muted);
}

#fluid-foot {
    float: left;
    clear: both;
    width: 100%;
    text-align: center;
    background: #2b211a;
    color: rgba(255,255,255,0.5);
    padding: 0.7rem;
    font-family: var(--mono);
    font-size: 0.7rem;
}

/* ══ MEDIA QUERIES ══ */

/* 960 px breakpoint */
@media screen and (max-width: 960px) {

    #fluid-inner {
        width: 640px;
        margin: 0 auto;
        float: none;
    }

    /* Stack the combined grid */
    .combined {
        grid-template-columns: 1fr;
    }

    .cmb-sidebar { display: none; }

    .cmb-header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    /* Grid demo: collapse sidebar */
    .grid-demo {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .gd-sidebar { display: none; }
}

/* 640 px breakpoint */
@media screen and (max-width: 640px) {

    #fluid-inner {
        width: 320px;
    }

    h1, h2, h3, p {
        word-wrap: break-word;
    }

    /* Navbar collapses to column */
    .flex-navbar {
        flex-direction: column;
        align-items: stretch;
    }

    .flex-navbar__links {
        flex-direction: column;
    }

    .flex-navbar__links a {
        border-bottom: 1px solid rgba(255,255,255,0.1);
        padding: 0.7rem 1rem;
    }

    .flex-navbar__cta {
        text-align: center;
        padding: 0.8rem 1rem;
    }

    /* Gallery: one column */
    .grid-gallery {
        grid-template-columns: 1fr;
    }

    /* Cards: full width */
    .flex-card {
        flex: 1 1 100%;
    }
}
