/* Compudata Brand Typography */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

/* InterVariable Self-Hosted Font */
@font-face {
    font-family: 'InterVariable';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('https://branding.compudata.ca/fonts/InterVariable.woff2') format('woff2');
}

@font-face {
    font-family: 'InterVariable';
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
    src: url('https://branding.compudata.ca/fonts/InterVariable-Italic.woff2') format('woff2');
}

/* ---------------------------------------------------------------------------
   Theme tokens
--------------------------------------------------------------------------- */
:root {
    --cd-blue: #3377cc;
    --cd-blue-dark: #2566bb;
    --cd-orange: #ff6600;
    --cd-orange-dark: #e65c00;

    --bg-body: #f4f6f9;
    --bg-card: #ffffff;
    --bg-elev: #ffffff;
    --bg-sunken: #eef1f5;
    --bg-hover: #f3f6fb;

    --text-primary: #2a2f36;
    --text-secondary: #6b7280;
    --border-color: #e3e7ee;
    --border-strong: #d2d8e2;

    --accent-soft: rgba(51, 119, 204, 0.10);
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 14px rgba(16, 24, 40, 0.06);
    --radius: 12px;
    --radius-sm: 8px;
}

html.dark {
    --bg-body: #0f141b;
    --bg-card: #161c24;
    --bg-elev: #1b222c;
    --bg-sunken: #11161d;
    --bg-hover: #1f2732;

    --text-primary: #e6e9ee;
    --text-secondary: #9aa3b0;
    --border-color: #28303b;
    --border-strong: #333d4a;

    --accent-soft: rgba(51, 119, 204, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* ---------------------------------------------------------------------------
   Reset / base — locked height for fixed-height iframe embedding
--------------------------------------------------------------------------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: 'InterVariable', system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#app { height: 100%; }

h1, h2, h3 { font-family: 'Plus Jakarta Sans', sans-serif; line-height: 1.2; }

a { color: inherit; text-decoration: none; }

button { font-family: inherit; cursor: pointer; }

/* Thin scrollbars for the internal scroll regions */
.scroll, .rail, #quickAccess, #tagPills {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.5) transparent;
}
.scroll::-webkit-scrollbar,
.rail::-webkit-scrollbar,
#quickAccess::-webkit-scrollbar,
#tagPills::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll::-webkit-scrollbar-thumb,
.rail::-webkit-scrollbar-thumb,
#quickAccess::-webkit-scrollbar-thumb,
#tagPills::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.45); border-radius: 999px; }
.scroll::-webkit-scrollbar-corner,
.rail::-webkit-scrollbar-corner { background: transparent; }

/* ---------------------------------------------------------------------------
   Shell
--------------------------------------------------------------------------- */
.launcher {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg-body);
}

/* --- Top brand + search bar --- */
.brandbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border-color);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-logo {
    height: 26px;
    width: auto;
}
html.dark .brand-logo { filter: brightness(0) invert(1); }

.brand-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.search-wrap svg {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    pointer-events: none;
}

#search {
    width: 100%;
    padding: 9px 12px 9px 34px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#search::placeholder { color: var(--text-secondary); }
#search:focus {
    border-color: var(--cd-blue);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 16px;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--cd-blue);
    border-color: var(--cd-blue);
}

/* Reset button "are you sure?" armed state */
.icon-btn.is-armed,
.icon-btn.is-armed:hover {
    width: auto;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: var(--cd-orange);
    border-color: var(--cd-orange);
}

/* --- Quick Access strip --- */
.quickbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border-color);
}

.quickbar-label {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

#quickAccess {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    flex: 1;
    min-width: 0;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    white-space: nowrap;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.chip:hover { border-color: var(--cd-blue); background: var(--accent-soft); }
.chip img { width: 16px; height: 16px; border-radius: 3px; }
.chip .star { color: var(--cd-orange); font-size: 11px; }

.quick-empty { font-size: 13px; color: var(--text-secondary); }

/* --- Body: rail + content --- */
.bodywrap {
    display: flex;
    flex: 1;
    min-height: 0;
}

.rail {
    flex-shrink: 0;
    width: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px;
    background: var(--bg-sunken);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.rail-heading {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 4px 8px 8px;
}

.tag--rail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    color: var(--text-primary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: background 0.12s ease, color 0.12s ease;
}
.tag--rail:hover { background: var(--bg-hover); }
.tag--rail .count { font-size: 11px; color: var(--text-secondary); }
.tag--rail.is-active { background: var(--cd-blue); color: #fff; }
.tag--rail.is-active .count { color: rgba(255, 255, 255, 0.85); }

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#tagPills {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-elev);
}

.tag--pill {
    flex-shrink: 0;
    padding: 6px 13px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.tag--pill:hover { border-color: var(--cd-blue); }
.tag--pill.is-active { background: var(--cd-blue); color: #fff; border-color: var(--cd-blue); }

.scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px;
}

.breadcrumb {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* --- Tool grid / cards --- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    align-content: start;
}

.card {
    position: relative;
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
    transform: translateY(-2px);
    border-color: var(--cd-blue);
    box-shadow: 0 8px 20px rgba(51, 119, 204, 0.18);
}

.card-link {
    flex: 1;
    min-width: 0;
    display: block;
    padding: 14px 16px;
}

.card-head { display: flex; align-items: center; gap: 11px; }
.card-icon { flex-shrink: 0; width: 22px; height: 22px; border-radius: 4px; }
.card-name {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--cd-blue);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}
.card-tags span {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-sunken);
    border-radius: 5px;
    padding: 2px 6px;
}

.desc {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pin {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.card:hover .pin, .pin.is-pinned { opacity: 1; }
.pin:hover { background: var(--bg-hover); color: var(--cd-orange); }
.pin.is-pinned { color: var(--cd-orange); }

.empty {
    grid-column: 1 / -1;
    padding: 40px 20px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg-sunken);
}

/* --- Footer --- */
.footer {
    flex-shrink: 0;
    padding: 10px 14px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-elev);
    border-top: 1px solid var(--border-color);
}

/* ---------------------------------------------------------------------------
   Layout modes (driven by ResizeObserver -> data-layout, or URL ?layout=)
--------------------------------------------------------------------------- */
/* Rail layout: show sidebar, hide top pills */
.launcher[data-layout="rail"] #tagPills { display: none; }
/* Pills + list layouts: hide sidebar, show top pills */
.launcher[data-layout="pills"] .rail,
.launcher[data-layout="list"] .rail { display: none; }

/* List layout: single-column dense rows */
.launcher[data-layout="list"] .grid { grid-template-columns: 1fr; }
.launcher[data-layout="list"] .card-tags { display: none; }
.launcher[data-layout="list"] .desc {
    -webkit-line-clamp: 1;
    margin-top: 4px;
}
.launcher[data-layout="list"] .card-link { padding: 10px 14px; }

/* ---------------------------------------------------------------------------
   Density (driven by container height -> data-height)
--------------------------------------------------------------------------- */
.launcher[data-height="short"] .desc { display: none; }
.launcher[data-height="short"] .card-tags { margin-top: 6px; }
.launcher[data-height="short"] .card-link { padding: 10px 14px; }
.launcher[data-height="short"] .quickbar { padding-top: 6px; padding-bottom: 6px; }
.launcher[data-height="short"] .grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}

/* ---------------------------------------------------------------------------
   Embed mode (?embed=1): drop footer chrome, flush edges
--------------------------------------------------------------------------- */
.launcher[data-embed="1"] .footer { display: none; }
body.is-embed { background: var(--bg-body); }

/* ---------------------------------------------------------------------------
   Blend mode (?bg=transparent or ?bg=<css-color>)
   Lets the embedded launcher sit on the host page's own background. Works
   cross-origin: the browser composites the transparent iframe over the parent
   (rendering, not script access). Cards/inputs keep their surface for contrast;
   pair with ?theme= so the foreground matches the host's light/dark.
--------------------------------------------------------------------------- */
html.bg-blend body { background: var(--embed-bg, transparent); }
html.bg-blend .launcher,
html.bg-blend .brandbar,
html.bg-blend .quickbar,
html.bg-blend #tagPills,
html.bg-blend .rail,
html.bg-blend .footer { background: transparent; }
html.bg-blend .brandbar,
html.bg-blend .quickbar,
html.bg-blend #tagPills { border-bottom-color: transparent; }
html.bg-blend .rail { border-right-color: transparent; }
html.bg-blend .footer { border-top-color: transparent; }
/* Strengthen the card edge so tiles stay distinct on an unknown surface */
html.bg-blend .card { border-color: var(--border-strong); }

/* Hide elements via URL flags */
.is-hidden { display: none !important; }

/* ---------------------------------------------------------------------------
   Narrow viewport fallback (standalone on phones)
--------------------------------------------------------------------------- */
@media (max-width: 520px) {
    .brand-title { display: none; }
    .quickbar-label { display: none; }
}
