/* ================================
   Catalog pages: apps.html, games.html, resources.html
   Same brand tokens and type as the home (.hd) and about (.ab) pages.
   ================================ */

.ct {
    --ct-bg: #f3f7fe;
    --ct-ink: #0d1f3c;
    --ct-muted: #4f6283;
    --ct-card: #ffffff;
    --ct-line: #dbe5f4;
    --ct-blue: #1d5fc4;
    --ct-tint: #e8f0fd;
    --ct-orange: #e07a0c;
    --ct-shadow: rgba(23, 56, 120, 0.12);
    --ct-head: 'Montserrat', 'Mulish', system-ui, sans-serif;
    --ct-body: 'Mulish', system-ui, sans-serif;
    background: var(--ct-bg);
    color: var(--ct-ink);
    font-family: var(--ct-body);
    border: 1px solid var(--ct-line);
    border-radius: 1.25rem;
    padding: clamp(1.5rem, 4vw, 3rem);
    display: grid;
    gap: clamp(1.75rem, 4vw, 2.75rem);
}

html.dark .ct {
    --ct-bg: #111a2c;
    --ct-ink: #e8eefa;
    --ct-muted: #a3b3cd;
    --ct-card: #172440;
    --ct-line: #263a60;
    --ct-blue: #79a9ff;
    --ct-tint: #1a2b4b;
    --ct-orange: #ffad4d;
    --ct-shadow: rgba(0, 0, 0, 0.35);
}

.ct h1, .ct h2, .ct h3, .ct p { margin: 0; }

.ct svg.ct-i {
    width: 20px;
    height: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ct a:focus-visible,
.ct button:focus-visible {
    outline: 2px solid var(--ct-blue);
    outline-offset: 3px;
    border-radius: 10px;
}

/* ---------- page header ---------- */
.ct-head {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: clamp(1rem, 4vw, 2.5rem);
    align-items: center;
}

.ct-eyebrow {
    font-family: var(--ct-head);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ct-blue);
}

.ct .ct-title {
    font-family: var(--ct-head);
    font-weight: 800;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    line-height: 1.14;
    letter-spacing: -0.02em;
    color: var(--ct-ink);
    margin-top: 0.75rem;
    text-wrap: balance;
}

.ct-rule {
    width: 64px;
    height: 4px;
    border-radius: 4px;
    background: var(--ct-orange);
    margin: 1rem 0;
}

.ct-lede {
    font-size: 1.06rem;
    line-height: 1.65;
    color: var(--ct-muted);
    max-width: 34em;
}

.ct-art {
    width: 100%;
    max-width: 380px;
    height: auto;
    justify-self: center;
    aspect-ratio: 4 / 3;
    object-fit: contain;
}

/* ---------- apps: search + API key help ---------- */
.ct-tools {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 1rem;
}

.ct-panel {
    background: var(--ct-card);
    border: 1px solid var(--ct-line);
    border-radius: 18px;
    padding: 1.25rem;
    display: grid;
    gap: 0.6rem;
    align-content: start;
}

.ct .ct-panel-h {
    display: flex;
    gap: 10px;
    align-items: center;
    font-family: var(--ct-head);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ct-ink);
}

.ct-panel-h svg.ct-i { color: var(--ct-blue); }
.ct-panel p { color: var(--ct-muted); font-size: 0.94rem; line-height: 1.55; }

/* style.css colours .app-search for light and dark; these win over both */
html .ct .app-search { background: var(--ct-card); border: 1px solid var(--ct-line); }
html .ct .app-search label { color: var(--ct-ink); }
html .ct .app-search p { color: var(--ct-muted); }
html .ct .app-search-field { position: relative; margin-top: 0.25rem; }
html .ct .app-search-icon { left: 0.9rem; color: var(--ct-muted); }
html .ct #app-search-input {
    min-height: 50px;
    padding: 0.7rem 2.75rem;
    font: inherit;
    font-size: 1rem;
    color: var(--ct-ink);
    background: var(--ct-bg);
    border: 1.5px solid var(--ct-line);
    border-radius: 14px;
}
html .ct #app-search-input::placeholder { color: var(--ct-muted); }
html .ct #app-search-input:focus {
    outline: none;
    border-color: var(--ct-blue);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ct-blue) 25%, transparent);
}
html .ct .app-search-kbd {
    right: 0.9rem;
    color: var(--ct-muted);
    background: var(--ct-card);
    border-color: var(--ct-line);
}
html .ct .app-search .app-search-count { color: var(--ct-muted); font-size: 0.88rem; }

.ct .ct-api-btn {
    justify-self: start;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-height: 44px;
    margin-top: 0.25rem;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #2f80ed, #1d5fc4 60%, #0b2f6b);
    color: #ffffff;
    font: 700 0.92rem var(--ct-head);
    cursor: pointer;
    box-shadow: 0 8px 20px var(--ct-shadow);
}
/* style.css paints this button red with !important */
#watch-tutorial-btn.ct-api-btn,
#watch-tutorial-btn.ct-api-btn:hover {
    background-image: linear-gradient(135deg, #2f80ed, #1d5fc4 60%, #0b2f6b) !important;
}

/* ---------- apps: jump bar (behaviour in js/apps-jumpnav.js) ---------- */
.ct .app-jumpnav {
    margin-top: 0;
    padding: 0.6rem 0;
    background: var(--ct-bg);
    border-bottom: 1px solid var(--ct-line);
}
.ct .app-jumpnav a {
    min-height: 40px;
    padding: 0.4rem 0.9rem 0.4rem 0.45rem;
    gap: 0.5rem;
    border: 1px solid var(--ct-line);
    background: var(--ct-card);
    color: var(--ct-ink);
    font-family: var(--ct-body);
    font-weight: 700;
}
.ct .app-jumpnav a svg.ct-i {
    width: 26px;
    height: 26px;
    padding: 5px;
    border-radius: 50%;
    background: var(--ct-tint);
    color: var(--ct-blue);
}
.ct .app-jumpnav a:hover { border-color: var(--ct-blue); color: var(--ct-blue); }
.ct .app-jumpnav a[aria-current] {
    background: var(--ct-blue);
    border-color: var(--ct-blue);
    color: var(--ct-card);
}
.ct .app-jumpnav a[aria-current] svg.ct-i { background: rgba(255, 255, 255, 0.2); color: inherit; }

/* ---------- groups and cards ---------- */
.ct-group { display: grid; gap: 1rem; }

.ct .ct-group-h {
    display: flex;
    gap: 12px;
    align-items: center;
    font-family: var(--ct-head);
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--ct-ink);
}

.ct-gico,
.ct-ico {
    display: grid;
    place-items: center;
    flex: none;
    color: #ffffff;
    background: linear-gradient(150deg, #38bdf8 0%, #1d5fc4 55%, #0b2f6b 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.ct-gico { width: 36px; height: 36px; border-radius: 10px; }
.ct-gico svg.ct-i { width: 18px; height: 18px; }
.ct-ico { width: 44px; height: 44px; border-radius: 12px; }
.ct-ico svg.ct-i { width: 22px; height: 22px; }

.ct-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    gap: 1rem;
}

.ct-card {
    position: relative;
    background: var(--ct-card);
    border-radius: 18px;
    padding: 1.15rem 1.2rem 1.1rem;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 0.5rem;
    box-shadow: 0 1px 2px var(--ct-shadow), 0 10px 26px var(--ct-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.ct-card:hover { transform: translateY(-2px); }
.ct-card:has(.ct-card-link:focus-visible) { outline: 2px solid var(--ct-blue); outline-offset: 3px; }

.ct-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 0.25rem; }

.ct-badge {
    font-size: 0.74rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--ct-tint);
    color: var(--ct-blue);
    white-space: nowrap;
}
.ct-badge-desktop { background: transparent; border: 1px solid var(--ct-line); color: var(--ct-muted); }

.ct .ct-card-title {
    font-family: var(--ct-head);
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.3;
    color: var(--ct-ink);
    overflow-wrap: anywhere;
}

.ct .ct-card-desc { color: var(--ct-muted); font-size: 0.92rem; line-height: 1.55; margin: 0; }

.ct .ct-card-link {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin-top: 0.35rem;
    color: var(--ct-blue);
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
}
.ct-card-link svg.ct-i { width: 16px; height: 16px; transition: transform 0.2s; }
.ct-card:hover .ct-card-link svg.ct-i { transform: translateX(3px); }
/* the whole card is the link target */
.ct-card-link::after { content: ""; position: absolute; inset: 0; border-radius: 18px; }
.ct .ct-card-link:focus-visible { outline: none; }

html .ct .app-search-empty {
    border: 1px dashed var(--ct-line);
    border-radius: 18px;
    color: var(--ct-muted);
    padding: 2rem 1rem;
}

/* ---------- closing call to action ---------- */
.ct-cta {
    background: linear-gradient(140deg, #2f80ed 0%, #1d5fc4 45%, #0b2f6b 100%);
    color: #ffffff;
    border-radius: 22px;
    padding: clamp(1.3rem, 4vw, 2.2rem);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1.25rem;
    align-items: center;
}
.ct .ct-cta h2 {
    font-family: var(--ct-head);
    font-weight: 800;
    font-size: clamp(1.25rem, 2.6vw, 1.6rem);
    line-height: 1.25;
    color: #ffffff;
    text-wrap: balance;
}
.ct-cta p { color: #dce8ff; margin-top: 0.4rem; line-height: 1.55; }
.ct .ct-cta a {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-height: 46px;
    padding: 0 20px;
    border-radius: 12px;
    background: #ffffff;
    color: #0b2f6b;
    font: 700 0.92rem var(--ct-head);
    white-space: nowrap;
    text-decoration: none;
}

/* ---------- API key guide dialog (markup in apps.html, behaviour in js/api-key-guide.js) ---------- */
.akg {
    --akg-bg: #ffffff;
    --akg-paper: #f3f7fe;
    --akg-ink: #0d1f3c;
    --akg-muted: #4f6283;
    --akg-line: #dbe5f4;
    --akg-blue: #1d5fc4;
    --akg-tint: #e8f0fd;
    --akg-orange: #e07a0c;
    --akg-orange-ink: #ad5904;
    --akg-warn-bg: #fdf1e4;
    width: min(880px, calc(100% - 24px));
    max-width: none;
    height: min(900px, calc(100dvh - 24px));
    max-height: none;
    margin: auto;
    padding: 0;
    border: 1px solid var(--akg-line);
    border-radius: 20px;
    background: var(--akg-bg);
    color: var(--akg-ink);
    font-family: 'Mulish', system-ui, sans-serif;
    box-shadow: 0 30px 80px rgba(11, 47, 107, 0.35);
    overflow: hidden;
}
.akg::backdrop { background: rgba(7, 29, 69, 0.55); backdrop-filter: blur(6px); }
.akg[open] { animation: akg-in 0.28s cubic-bezier(.2, .7, .2, 1); }
@keyframes akg-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
html.akg-lock { overflow: hidden; }
html.dark .akg {
    --akg-bg: #111a2c;
    --akg-paper: #172440;
    --akg-ink: #e8eefa;
    --akg-muted: #a3b3cd;
    --akg-line: #263a60;
    --akg-blue: #79a9ff;
    --akg-tint: #1a2b4b;
    --akg-orange: #ffad4d;
    --akg-orange-ink: #ffad4d;
    --akg-warn-bg: #2b2216;
}

.akg-shell { display: flex; flex-direction: column; height: 100%; }

.akg-head {
    position: relative;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 64px 18px 24px;
    background: linear-gradient(150deg, #38bdf8 0%, #1d5fc4 55%, #0b2f6b 100%);
    color: #ffffff;
    flex: none;
}
.akg-head-mochi { width: 64px; height: auto; flex: none; filter: drop-shadow(0 6px 10px rgba(7, 29, 69, 0.35)); }
.akg .akg-kicker { margin: 0; font: 800 0.72rem 'Montserrat', 'Mulish', sans-serif; letter-spacing: 0.12em; text-transform: uppercase; color: #ffd0a1; }
.akg .akg-head h2 { margin: 2px 0 4px; font: 800 1.45rem/1.2 'Montserrat', 'Mulish', sans-serif; color: #ffffff; }
.akg .akg-meta { margin: 0; font-size: 0.88rem; color: #dce8ff; }
.akg-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    cursor: pointer;
}
.akg-close:hover { background: rgba(255, 255, 255, 0.28); }
.akg-close svg { width: 20px; height: 20px; }
.akg-close:focus-visible, .akg a:focus-visible, .akg summary:focus-visible { outline: 3px solid #ffad4d; outline-offset: 2px; }

.akg-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 0 28px 24px; outline: none; }
html[lang="vi"] .akg-en, html:not([lang="vi"]) .akg-vi { display: none; }

.akg-jump {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 -28px 4px;
    padding: 12px 28px;
    background: var(--akg-bg);
    border-bottom: 1px solid var(--akg-line);
}
.akg-jump a {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--akg-line);
    border-radius: 999px;
    background: var(--akg-paper);
    color: var(--akg-ink);
    font: 700 0.82rem 'Montserrat', 'Mulish', sans-serif;
    text-decoration: none;
}
.akg-jump a:hover { border-color: var(--akg-blue); color: var(--akg-blue); }
.akg-jump a[aria-current] { background: var(--akg-blue); border-color: var(--akg-blue); color: #ffffff; }
html.dark .akg-jump a[aria-current] { color: #0b1630; }

.akg-sec { padding: 22px 0 6px; scroll-margin-top: 64px; border-bottom: 1px dashed var(--akg-line); }
.akg-sec:last-child { border-bottom: 0; }
.akg .akg-sec h3 { margin: 0 0 10px; font: 800 1.12rem/1.3 'Montserrat', 'Mulish', sans-serif; color: var(--akg-ink); }
.akg .akg-sec p, .akg .akg-sec li { font-size: 0.98rem; line-height: 1.65; color: var(--akg-ink); }
.akg .akg-sec p { margin: 0 0 10px; }
.akg .akg-sec ul { margin: 0 0 12px; padding-left: 1.25rem; list-style: disc; }
.akg .akg-sec li { margin: 4px 0; }
.akg .akg-sec li::marker { color: var(--akg-blue); }
.akg-sec strong { font-weight: 800; }
.akg-sec code { padding: 1px 6px; border-radius: 6px; background: var(--akg-tint); color: var(--akg-blue); font: 700 0.9em ui-monospace, Consolas, monospace; }
.akg .akg-url { color: var(--akg-blue); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }

.akg .akg-step { display: flex; align-items: center; gap: 12px; }
.akg-num {
    display: grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--akg-orange);
    color: #ffffff;
    font: 800 1.15rem 'Montserrat', sans-serif;
}
html.dark .akg-num { color: #2b1503; }
.akg-step small { display: block; font: 800 0.7rem 'Montserrat', sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: var(--akg-orange-ink); }

.akg-prep, .akg-with-mochi { display: flex; gap: 16px; align-items: center; }
.akg-prep > div, .akg-with-mochi > div { flex: 1 1 auto; }
.akg-prep img, .akg-with-mochi img { width: 92px; height: auto; flex: none; }
.akg .akg-h-mochi { display: flex; align-items: center; gap: 10px; }
.akg-h-mochi img { width: 48px; height: auto; }

.akg-note {
    margin: 6px 0 14px;
    padding: 12px 14px;
    border-left: 4px solid var(--akg-blue);
    border-radius: 0 12px 12px 0;
    background: var(--akg-paper);
    font-size: 0.95rem;
    line-height: 1.6;
}
.akg-note > strong:first-child { display: block; margin-bottom: 2px; color: var(--akg-blue); font-family: 'Montserrat', sans-serif; }
.akg-note.akg-warn { border-left-color: var(--akg-orange); background: var(--akg-warn-bg); }
.akg-note.akg-warn > strong:first-child { color: var(--akg-orange-ink); }

.akg .akg-sec .akg-abc { list-style: none; padding-left: 0; }
.akg-abc li { display: flex; gap: 10px; align-items: flex-start; }
.akg-abc b {
    display: grid;
    place-items: center;
    flex: none;
    width: 26px;
    height: 26px;
    margin-top: 2px;
    border-radius: 50%;
    background: #e5322d;
    color: #ffffff;
    font: 800 0.8rem 'Montserrat', sans-serif;
}

.akg-fig { margin: 8px 0 14px; }
.akg-fig a { display: block; }
.akg-fig img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--akg-line);
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(23, 56, 120, 0.12);
    cursor: zoom-in;
}
.akg-fig-sm { max-width: 520px; }
.akg-fig figcaption { margin-top: 6px; font-size: 0.84rem; font-style: italic; color: var(--akg-muted); }

.akg-more { margin: 4px 0 12px; border: 1px solid var(--akg-line); border-radius: 12px; background: var(--akg-paper); }
.akg-more summary { padding: 10px 14px; font: 700 0.95rem 'Montserrat', 'Mulish', sans-serif; color: var(--akg-blue); cursor: pointer; }
.akg-more[open] { padding-bottom: 4px; }
.akg-more > :not(summary) { margin-left: 14px; margin-right: 14px; }

.akg-faq { margin: 0 0 12px; display: grid; gap: 8px; }
.akg-faq > div { padding: 12px 14px; border: 1px solid var(--akg-line); border-radius: 12px; background: var(--akg-paper); }
.akg-faq dt { font-weight: 800; color: var(--akg-ink); }
.akg-faq dd { margin: 4px 0 0; color: var(--akg-muted); line-height: 1.55; }
.akg .akg-sec .akg-fine { font-size: 0.85rem; color: var(--akg-muted); }

.akg-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    padding: 12px 20px;
    border-top: 1px solid var(--akg-line);
    background: var(--akg-paper);
    flex: none;
}
.akg-btn {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--akg-line);
    border-radius: 12px;
    background: var(--akg-bg);
    color: var(--akg-ink);
    font: 700 0.9rem 'Montserrat', 'Mulish', sans-serif;
    text-decoration: none;
}
.akg-btn svg.ct-i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.akg .akg-btn-main { border: 0; background: linear-gradient(135deg, #2f80ed, #1d5fc4 60%, #0b2f6b); color: #ffffff; }
.akg-btn:hover { filter: brightness(1.06); }

@media (max-width: 640px) {
    .akg { width: 100%; height: 100dvh; border-radius: 0; border: 0; }
    .akg-head { padding: 14px 60px 14px 16px; gap: 12px; }
    .akg-head-mochi { width: 48px; }
    .akg .akg-head h2 { font-size: 1.15rem; }
    .akg .akg-meta { font-size: 0.8rem; }
    .akg-body { padding: 0 16px 20px; }
    .akg-jump { margin: 0 -16px 4px; padding: 10px 16px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .akg-jump a { flex: none; }
    .akg-prep img, .akg-with-mochi img { width: 64px; }
    .akg-foot { padding: 10px 12px; flex-wrap: nowrap; gap: 8px; }
    .akg-btn { flex: 1 1 auto; justify-content: center; padding: 0 10px; font-size: 0.8rem; white-space: nowrap; }
    .akg-btn svg.ct-i { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .akg[open] { animation: none; }
}

@media (max-width: 860px) {
    .ct-head { grid-template-columns: minmax(0, 1fr); }
    .ct-art { order: -1; max-width: 300px; }
    .ct-tools, .ct-cta { grid-template-columns: minmax(0, 1fr); }
    .ct .ct-cta a { justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
    .ct *, .ct-card { transition: none !important; }
    .ct-card:hover, .ct-card:hover .ct-card-link svg.ct-i { transform: none; }
}

/* few cards (resources): let them share the row instead of leaving empty columns */
.ct-grid-fit { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
