/* Modernized and improved styles for The FOSS Place
 *
 * Changes:
 * - Introduced CSS variables for easy theming
 * - Added dark-mode support (prefers-color-scheme)
 * - Improved layout responsiveness and gap handling
 * - Better app-card visuals (shadows, spacing, responsive images)
 * - Accessible focus states and improved button/link styles
 * - Improved navbar styling & mobile behavior
 * - Utility classes for common blocks (screenshots grid, metadata, footer)
 */

/* Theme variables */
:root{
    --bg: #f4f4f4;
    --card: #ffffff;
    --muted: #666666;
    --text: #222222;
    --accent: #007bff;
    --accent-600: #0056b3;
    --nav-bg: #222222;
    --shadow: 0 6px 18px rgba(0,0,0,0.08);
    --radius: 10px;
    --max-width: 1200px;
    --gap: 1rem;
    --focus: 3px solid rgba(0,123,255,0.2);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root{
        --bg: #0f1113;
        --card: #0f1417;
        --muted: #a8b0b6;
        --text: #e6eef3;
        --accent: #3398ff;
        --accent-600: #1f6fd6;
        --nav-bg: #070808;
        --shadow: 0 6px 22px rgba(0,0,0,0.45);
    }
}

* { box-sizing: border-box; }

html,body {
    height: 100%;
    margin: 0;
    font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.45;
    font-size: 16px;
}

/* Header / Site title */
header {
    background-color: var(--nav-bg);
    color: white;
    text-align: center;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 120;
}

header h1 {
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Main content container */
main {
    max-width: var(--max-width);
    margin: 1.25rem auto;
    padding: 0 1rem;
}

/* Navigation Bar */
.navbar {
    background-color: var(--nav-bg);
    padding: 0;
    position: sticky;
    top: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    z-index: 100;
}

.nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.nav-menu li { margin: 0; }

.nav-link {
    display: block;
    padding: 0.9rem 1.25rem;
    color: white;
    text-decoration: none;
    transition: background-color 180ms ease, color 180ms ease, transform 120ms ease;
    font-weight: 600;
    font-size: 0.95rem;
}

.nav-link:hover,
.nav-link:focus {
    background-color: var(--accent);
    color: white;
    transform: translateY(-1px);
    outline: none;
}

.nav-link.active {
    background-color: var(--accent);
    color: white;
    border-bottom: 3px solid var(--accent-600);
}

/* App grid */
.app-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: calc(var(--gap) + 0.25rem);
    margin-top: 1rem;
}

/* Card */
.app-card {
    background-color: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    transition: transform 180ms ease, box-shadow 180ms ease;
    min-height: 220px;
}

.app-card:hover,
.app-card:focus-within {
    transform: translateY(-6px);
    box-shadow: 0 14px 34px rgba(0,0,0,0.12);
}

/* App icon */
.app-card img {
    width: 96px;
    height: 96px;
    border-radius: 14px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.04);
    background: linear-gradient(180deg, rgba(0,0,0,0.02), transparent);
}

/* Titles & text */
.app-card h2 {
    margin: 0.25rem 0;
    font-size: 1.05rem;
}

.app-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

/* Buttons / download links */
a.button, button {
    display: inline-block;
    background-color: var(--accent);
    color: #fff;
    border: none;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background-color 140ms ease, transform 120ms ease, box-shadow 120ms ease;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

a.button:hover, button:hover {
    background-color: var(--accent-600);
    transform: translateY(-2px);
}

a.button:focus, button:focus {
    outline: none;
    box-shadow: var(--focus);
}

/* Download link variant as plain anchor */
.app-meta {
    margin-top: auto;
}

/* Horizontal rule */
hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, rgba(0,0,0,0.04), rgba(0,0,0,0.08));
    margin: 1rem 0;
    border-radius: 1px;
}

/* Features list */
h3 { margin-top: 0.5rem; }
ul { padding-left: 1.25rem; margin-top: 0.25rem; color: var(--muted); }

/* Screenshots grid */
/* Add/replace the existing screenshots block with this improved version */

/* Screenshots grid (block container so text won't flow around images) */
.screenshots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.6rem;
    margin: 0.6rem 0 1rem 0;
    /* Prevent breaking inside multi-column / print contexts */
    break-inside: avoid;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    /* Make the screenshots a self-contained block so surrounding text doesn't wrap */
    display: block;
}

/* Ensure each screenshot is a block-level element that fills its grid cell */
.screenshots img {
    display: block;
    width: 100%;
    height: 280px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.04);
}
/* Metadata blocks used on individual app pages */
.meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}
.meta .version { color: var(--muted); font-weight: 600; }

/* Privacy / changelog */
.note {
    background: linear-gradient(180deg, rgba(0,0,0,0.02), transparent);
    padding: 0.75rem;
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}

/* Footer link */
footer {
    text-align: center;
    padding: 1.25rem;
    color: var(--muted);
}

/* Utility responsiveness */
@media (max-width: 768px) {
    header { padding: 0.9rem; }
    .app-container { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .app-card { padding: 1rem; min-height: 200px; }
    .screenshots img { height: 120px; }
}

/* Keyboard accessibility */
a:focus, button:focus, .nav-link:focus {
    outline: none;
    box-shadow: var(--focus);
    border-radius: 6px;
}

/* Small polish for text selection */
::selection {
    background: rgba(0,123,255,0.14);
}

/* Helper class for centered column layout on app detail pages */
.center-column {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

/* Small print */
.small {
    font-size: 0.9rem;
    color: var(--muted);
}