/* =========================================================
   QDF Meme Library — background + preview-faithful layout
   ========================================================= */

/* The comic/doodle texture belongs to the whole page, not the hero. */
body {
    background-color: #03233a;
    background-image: url("assets/meme-page-bg.jpg");
    background-repeat: repeat;
    background-size: 180px 480px;
    background-attachment: fixed;
}

/* Keep the common QDF header visually clean above the texture. */
.topbar {
    background: rgba(2, 13, 23, .98);
}

/* Main canvas: keep the preview composition centered without forcing it wider. */
.meme-library {
    width: min(1450px, calc(100% - 40px));
    margin: 28px auto 70px;
    color: var(--text);
}

/* Hero and quote are complete image compositions.
   Do not crop them with object-fit/background-size: cover. */
.meme-preview-hero,
.meme-preview-quote {
    overflow: visible;
}

.meme-preview-hero {
    width: 100%;
}

/* Quote must align exactly with the hero and the collection below. */
.meme-preview-quote {
    width: 100%;
    max-width: none;
    margin: 20px 0 28px;
}

.meme-preview-hero img,
.meme-preview-quote img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
}

.meme-preview-hero {
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 20px 42px rgba(0,0,0,.30);
}

.meme-preview-quote {
    margin: 20px auto 28px;
    filter: drop-shadow(0 14px 22px rgba(0,0,0,.30));
}

/* Category heading */
.meme-section-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin: 8px 0 18px;
}

.meme-eyebrow {
    margin: 0 0 5px;
    color: #39c9ff;
    font-size: 12px;
    font-weight: 1000;
    letter-spacing: .15em;
    text-transform: uppercase;
}

.meme-section-title h1 {
    margin: 0;
    color: #27d3ff;
    font-family: Impact, "Arial Black", sans-serif;
    font-size: clamp(42px, 4vw, 58px);
    line-height: .9;
    letter-spacing: -.015em;
    text-shadow: 3px 3px 0 #071b2a, 0 0 18px rgba(0,197,255,.14);
}

.meme-section-title > span {
    color: #a8bdcb;
    font-size: 13px;
    font-weight: 700;
    padding-bottom: 5px;
}

/* Six cards, as in the approved desktop preview. */
.meme-category-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
}

.meme-category-card {
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 2px solid rgba(70,196,255,.48);
    border-radius: 17px;
    background: #0b293b;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 13px 28px rgba(0,0,0,.28);
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.meme-category-card:hover {
    transform: translateY(-5px) rotate(-.35deg);
    border-color: #32caff;
    box-shadow: 0 20px 34px rgba(0,0,0,.36);
}

.meme-category-image {
    height: 160px;
    display: grid;
    place-items: center;
    padding: 10px;
    overflow: hidden;
}

.meme-category-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 7px 5px rgba(0,0,0,.28));
}

.meme-category-body {
    padding: 11px 13px 13px;
    background: #092b3f;
}

.meme-category-body h2 {
    margin: 0 0 5px;
    color: #fff;
    font-family: "Trebuchet MS", Arial, sans-serif;
    font-size: 17px;
    font-weight: 900;
    line-height: 1.05;
}

.meme-category-body span {
    color: #cbe4ef;
    font-size: 12px;
    font-weight: 700;
}

.meme-category-body b {
    margin-left: 3px;
    color: #fff;
    font-size: 17px;
}

.tone-0 .meme-category-image { background: #4b3c91; }
.tone-1 .meme-category-image { background: #b44f2e; }
.tone-2 .meme-category-image { background: #1c7d50; }
.tone-3 .meme-category-image { background: #1971aa; }
.tone-4 .meme-category-image { background: #a33e73; }
.tone-5 .meme-category-image { background: #168c97; }

.meme-empty {
    padding: 30px;
    border: 1px dashed var(--line);
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(7,31,49,.78);
}

.meme-empty code { color: var(--accent-2); }

/* Category page */
.meme-breadcrumb { margin-bottom: 22px; }

.meme-breadcrumb a {
    color: var(--accent-2);
    text-decoration: none;
    font-weight: 900;
}

.meme-category-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255,255,255,.10);
}

.meme-category-head h1 {
    margin: 0;
    font-family: Impact, "Arial Black", sans-serif;
    font-size: clamp(42px, 5vw, 70px);
    line-height: .95;
}

.meme-category-head p:not(.meme-eyebrow) {
    margin: 9px 0 0;
    color: var(--muted);
}

.meme-back-button {
    padding: 11px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    font-weight: 800;
    white-space: nowrap;
}

.meme-back-button:hover { background: rgba(255,255,255,.05); }

.meme-gallery {
    margin-top: 26px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0,1fr));
    gap: 18px;
}

.meme-item {
    position: relative;
    min-height: 250px;
    padding: 10px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 18px;
    background: #071f31;
    color: var(--text);
    cursor: pointer;
    overflow: hidden;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.meme-item:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 15px 30px rgba(0,0,0,.3);
}

.meme-item-image {
    height: 220px;
    display: grid;
    place-items: center;
}

.meme-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.meme-copy-label {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 5px 9px;
    border-radius: 8px;
    background: rgba(2,13,23,.84);
    color: var(--accent-2);
    font-size: 12px;
    font-weight: 900;
    opacity: 0;
    transition: opacity .15s ease;
}

.meme-item:hover .meme-copy-label,
.meme-item.copied .meme-copy-label { opacity: 1; }

.meme-item.copied { border-color: #42d98b; }
.meme-item.copied .meme-copy-label { color: #42d98b; }

.meme-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translate(-50%,20px);
    padding: 12px 18px;
    border: 1px solid var(--accent);
    border-radius: 12px;
    background: #061a2a;
    color: #fff;
    font-weight: 800;
    opacity: 0;
    pointer-events: none;
    transition: .18s ease;
    z-index: 50;
    box-shadow: var(--shadow);
}

.meme-toast.show {
    opacity: 1;
    transform: translate(-50%,0);
}

@media (max-width: 1250px) {
    .meme-category-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
}

@media (max-width: 900px) {
    .meme-library { width: min(100% - 28px, 760px); }
    .meme-category-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .meme-category-image { height: 170px; }
    .meme-category-head { align-items: start; flex-direction: column; }
}

@media (max-width: 620px) {
    .meme-library { width: min(100% - 20px, 520px); margin-top: 18px; }
    .meme-preview-hero { border-radius: 12px; }
    .meme-preview-quote { width: 100%; margin: 14px auto 22px; }
    .meme-category-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
    .meme-category-image { height: 150px; }
    .meme-section-title h1 { font-size: 34px; }
    .meme-gallery { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
}

@media (max-width: 420px) {
    .meme-category-grid { grid-template-columns: 1fr; }
    .meme-category-image { height: 190px; }
    .meme-gallery { grid-template-columns: 1fr; }
}
