/* ---------- fonts (self-hosted, see wwwroot/lib/fonts) ---------- */
@font-face {
    font-family: "Raleway";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../lib/fonts/raleway-400.woff2") format("woff2");
}

@font-face {
    font-family: "Lato";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../lib/fonts/lato-400.woff2") format("woff2");
}

@font-face {
    font-family: "Lato";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../lib/fonts/lato-700.woff2") format("woff2");
}

@font-face {
    font-family: "Lato";
    font-style: normal;
    font-weight: 900;
    font-display: swap;
    src: url("../lib/fonts/lato-900.woff2") format("woff2");
}

/*
 * Color variables come from /css/theme.css (generated server-side from config.yml).
 * Two roles matter here:
 *   --text / --text-header   : text sitting directly on the page background (wallpaper).
 *   --text-title / --text-subtitle : text sitting on top of --card-background (tiles, the
 *                               search box, buttons, the login card). Homer's own config keeps
 *                               these pairs independent (e.g. a light card on a dark wallpaper),
 *                               so mixing them up makes text invisible on one of the two themes.
 */

/* ---------- base / reset ---------- */
* { box-sizing: border-box; }

html, body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: "Raleway", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text, #eaeaea);
    background-color: var(--background, #12152B);
    background-image: var(--background-image, none);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
}

a {
    color: var(--link, #c1c1c1);
    text-decoration: none;
}

a:hover {
    color: var(--link-hover, #fafafa);
}

/* ---------- app shell ---------- */
.app {
    max-width: 1920px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.app-header {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2.5rem;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.app-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 8px;
}

.app-icon {
    font-size: 2.2rem;
    color: var(--text-header, #7C71DD);
}

.app-titles h1 {
    margin: 0;
    font-family: "Lato", sans-serif;
    font-size: 1.6rem;
    color: var(--text-header, #7C71DD);
    font-weight: 900;
}

.app-subtitle {
    margin: 0.15rem 0 0;
    color: var(--text, #8B8D9C);
    font-size: 0.95rem;
}

.app-controls {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-background, rgba(24, 28, 58, 0.8));
    border-radius: 8px;
    padding: 0.5rem 0.9rem;
    box-shadow: 0 2px 6px var(--card-shadow, rgba(0, 0, 0, 0.5));
    color: var(--text-title, #eaeaea);
}

.search-box input {
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--text-title, #eaeaea);
    caret-color: var(--text-title, #eaeaea);
    font-family: inherit;
    font-size: 0.95rem;
    width: 160px;
}

.search-box input::placeholder {
    color: var(--text-subtitle, #8B8D9C);
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 0;
    background: var(--card-background, rgba(24, 28, 58, 0.8));
    color: var(--text-title, #eaeaea);
    cursor: pointer;
    box-shadow: 0 2px 6px var(--card-shadow, rgba(0, 0, 0, 0.5));
    transition: background-color 0.15s ease;
}

.icon-button:hover {
    background: var(--highlight-hover, #1F2347);
}

.app-controls form {
    display: contents;
}

/* ---------- groups + tiles ---------- */
/*
 * Default "column" layout: groups sit side by side in N columns ("columns:" in config.yml),
 * each group's items stacked single-file within its column. Because it's a real CSS Grid (not
 * height-balanced masonry), groups snap into aligned rows - "Favorites"/"Work"/"Dynamics 365 BC"
 * line up on the same row even when "Courses" above holds more items.
 *
 * The layout-toggle button (site.js sets html[data-layout="list"]) switches to "list" layout:
 * groups stacked full-width down the page instead, each with its OWN items wrapped into an
 * N-column grid. Despite the name this is the roomier/grid-like view - good on a wide desktop
 * screen when you want fewer, wider groups instead of many narrow side-by-side columns.
 */
.tile-groups {
    display: grid;
    grid-template-columns: repeat(var(--columns, 3), minmax(0, 1fr));
    gap: 0.5rem 1.75rem;
    align-items: start;
}

@media (max-width: 900px) {
    .tile-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
    .tile-groups { grid-template-columns: 1fr; }
}

html[data-layout="list"] .tile-groups {
    grid-template-columns: 1fr;
}

.group {
    margin-bottom: 1.75rem;
}

.group-title {
    font-family: "Lato", sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text, #8B8D9C);
    margin: 0 0 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tile-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* "list" layout: each full-width group lays its own items out in an N-column grid. */
html[data-layout="list"] .tile-list {
    display: grid;
    grid-template-columns: repeat(var(--columns, 3), minmax(0, 1fr));
    gap: 1rem;
}

@media (max-width: 900px) {
    html[data-layout="list"] .tile-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
    html[data-layout="list"] .tile-list { grid-template-columns: 1fr; }
}

.tile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1.1rem;
    padding: 1.15rem 1.3rem;
    border-radius: 1rem;
    background: var(--card-background, rgba(24, 28, 58, 0.8));
    box-shadow: 0 2px 8px var(--card-shadow, rgba(0, 0, 0, 0.5));
    transition: transform 0.12s ease, background-color 0.12s ease;
    color: var(--text-title, #eaeaea);
}

.tile:hover {
    background: var(--highlight-hover, #1F2347);
    transform: translateY(-2px);
    color: var(--text-title, #eaeaea);
}

.tile-icon {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: var(--text-title, #7C71DD);
}

.tile-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.tile-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.tile-name {
    font-family: "Lato", sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-title, #eaeaea);
    line-height: 1.3;
}

.tile-subtitle {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-subtitle, #8B8D9C);
    line-height: 1.3;
}

.tile-tag {
    flex: 0 0 auto;
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--highlight-primary, #181C3A);
    color: var(--text-title, #eaeaea);
}

.tile-tag.is-primary { background: #7C71DD; color: #ffffff; }
.tile-tag.is-link { background: #3273dc; color: #ffffff; }

.tile[hidden] { display: none; }

.no-results {
    text-align: center;
    color: var(--text, #8B8D9C);
    margin-top: 3rem;
}

.app-footer {
    text-align: center;
    color: var(--text, #8B8D9C);
    font-size: 0.8rem;
    margin-top: 3rem;
}

/* ---------- login page ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    position: relative;
}

.login-theme-toggle {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
}

.login-wrap {
    width: 100%;
    max-width: 360px;
}

.login-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--card-background, rgba(24, 28, 58, 0.9));
    padding: 2.2rem 2rem;
    border-radius: 1.25rem;
    box-shadow: 0 10px 30px var(--card-shadow, rgba(0, 0, 0, 0.5));
    text-align: center;
    color: var(--text-title, #eaeaea);
}

.login-icon {
    font-size: 2.4rem;
    color: var(--text-title, #7C71DD);
}

.login-card h1 {
    margin: 0 0 0.25rem;
    font-family: "Lato", sans-serif;
    font-weight: 900;
    font-size: 1.4rem;
    color: var(--text-title, #7C71DD);
}

.login-error {
    background: rgba(220, 53, 69, 0.15);
    color: #ff8a93;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    margin: 0;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-subtitle, #8B8D9C);
}

.field input[type="text"],
.field input[type="password"] {
    background: rgba(127, 127, 127, 0.14);
    border: 1px solid rgba(127, 127, 127, 0.25);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    color: var(--text-title, #eaeaea);
    caret-color: var(--text-title, #eaeaea);
    font-family: inherit;
    font-size: 0.95rem;
    outline: 0;
}

.field input[type="text"]:focus,
.field input[type="password"]:focus {
    border-color: var(--text-title, #7C71DD);
}

.field-checkbox {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.login-submit {
    margin-top: 0.5rem;
    padding: 0.7rem 1rem;
    border: 0;
    border-radius: 8px;
    background: var(--text-header, #7C71DD);
    color: #12152B;
    font-family: "Lato", sans-serif;
    font-weight: 700;
    cursor: pointer;
}

.login-submit:hover {
    filter: brightness(1.08);
}
