/*
 * Custom styles for Versicherungstech Magazin enhancements.
 *
 * This stylesheet defines variables and overrides for dark mode,
 * positions the bookmark buttons on article cards and styles the
 * preferences modal. It is intentionally minimal and avoids
 * interfering with existing theme styles.
 */

/* Base variables for dark mode */
.dark-mode {
    --bg-color: #0a0a0a;
    --fg-color: #e2e2e2;
    --link-color: #00aaff;
}

/* Apply dark colours on body and common containers */
.dark-mode body,
.dark-mode .gh-site {
    background-color: var(--bg-color) !important;
    color: var(--fg-color) !important;
}
.dark-mode a {
    color: var(--link-color) !important;
}

/* Apply foreground colour to all text elements in dark mode to ensure
   readability. The !important flag is used sparingly here to override
   theme-specific colours. */
.dark-mode body,
.dark-mode body * {
    color: var(--fg-color) !important;
}

/* Bookmark button on cards */
.gh-card {
    position: relative;
}
/* Position and style the bookmark toggle star. Increase the size and add
   some padding so it’s easier to hit on touch devices. */
.bookmark-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: transparent;
    font-size: 2rem;
    line-height: 1;
    padding: 0.1rem;
    cursor: pointer;
    z-index: 10;
    /* Ensure the star intercepts clicks even if underlying links overlap */
    pointer-events: auto;
    /* Default star colour adapts to mode: in light mode a subtle grey,
       in dark mode it picks up the foreground colour via var(--fg-color). */
    color: var(--fg-color, #666666);
    transition: color 0.2s ease;
}

/* Bookmark list styles on the /bookmarks page */
.bookmark-list {
    margin-top: 1rem;
}

.bookmark-item a {
    display: block;
    padding: 0.5rem 0;
    /* Use link colour variable if defined or fallback to a vibrant blue */
    color: var(--link-color, #007acc);
    text-decoration: underline;
}

.bookmark-item a:hover {
    text-decoration: none;
}
.bookmark-toggle:hover {
    color: #f39c12;
}
.bookmark-toggle.active {
    color: #f39c12;
}

/* Preferences modal overlay */
#pref-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.pref-modal {
    background: #ffffff;
    color: #000000;
    padding: 2rem;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 90%;
    /* Use the same font as the site body text for consistency */
    font-family: var(--font-family-base, "Inter", Arial, sans-serif);
    font-size: 1rem;
}
.pref-modal h2 {
    margin-top: 0;
    font-size: 1.6rem;
}
.pref-modal .pref-section {
    margin: 1rem 0;
    font-size: 1rem;
}
.pref-modal select,
.pref-modal input[type="checkbox"] {
    margin-top: 0.3rem;
}
.pref-modal button {
    display: block;
    width: 100%;
    margin-top: 1rem;
    padding: 0.6rem;
    font-size: 1rem;
    background: #000000;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.pref-modal button:hover {
    background: #222222;
}

/* --- Start vtm-home additions --- */
/* Layout for enhanced home page sections */
.vtm-section {
    margin: 3rem 0;
}
.vtm-section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
}
.vtm-section-head h2 {
    margin: 0;
    font-size: 1.5rem;
}
.vtm-link {
    font-size: 0.9rem;
    text-decoration: none;
}

/* Grid layout for article cards */
.vtm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

/* Hero area */
.vtm-hero {
    margin: 2rem 0 3rem;
}
.vtm-hero-card {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
    align-items: stretch;
}
.vtm-hero-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}
.vtm-hero-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.vtm-hero-title {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 2rem;
    line-height: 1.2;
}
.vtm-hero-excerpt {
    margin-bottom: 1rem;
    color: var(--fg-muted, #444);
    font-size: 1rem;
}
.vtm-btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: 999px;
    background: var(--accent-color, #0d1c3c);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Article cards */
.vtm-card {
    position: relative;
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.vtm-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
.vtm-card-media img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
}
.vtm-card-body {
    padding: 0.75rem 0.9rem 1rem;
}
.vtm-card-title {
    margin: 0.2rem 0 0.4rem;
    /* Increase title size for better readability */
    font-size: 1.2rem;
    line-height: 1.35;
}
/* Excerpts on cards: bigger font for better readability */
/* Excerpts on cards: bigger font for better readability */
.vtm-card-excerpt {
    margin: 0;
    color: var(--fg-muted, #444);
    /* Increase excerpt font size for improved readability */
    font-size: 1.15rem;
    line-height: 1.5;
}
/* Bookmark toggle button. Use CSS variables to adapt to dark/light modes. */
.bookmark-toggle {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    /* Increase size to make it easier to click */
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fg-color, #000);
}
.bookmark-toggle.active {
    background: #ffd700;
    color: var(--bg-color, #000);
}

/* Ensure bookmark toggles inside default Ghost cards (.gh-card) are large and visible */
.gh-card .bookmark-toggle {
    width: 40px;
    height: 40px;
    font-size: 1.4rem;
    background: rgba(255,255,255,0.9);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 10;
    cursor: pointer;
}
.gh-card .bookmark-toggle.active {
    background: #ffd700;
    color: #000;
}

/* Placeholder section for empty categories */
.vtm-placeholder-section {
    padding: 1rem 0;
    text-align: center;
    border-top: 1px dashed #ddd;
}
.vtm-placeholder {
    color: #777;
    font-style: italic;
    margin: 1rem 0;
}

/* Greeting and header extras */
.vtm-header-tools {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 1rem;
}
.vtm-greeting {
    font-weight: 600;
    font-size: 0.9rem;
}
.vtm-change-prefs {
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
}

@media (max-width: 768px) {
    .vtm-hero-card {
        grid-template-columns: 1fr;
    }
}
/* --- End vtm-home additions --- */

/* --- Begin vtm-home layout enhancements --- */

/* Layout container for hero and recommended sections */
.vtm-hero-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: flex-start;
}
@media (max-width: 960px) {
    .vtm-hero-container {
        grid-template-columns: 1fr;
    }
}

/* Right side recommended area */
.vtm-recommended-side {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.vtm-recommended-title {
    margin: 0 0 0.5rem;
    font-size: 1.4rem;
    font-weight: 600;
}

/* List layout for latest posts */
.vtm-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.vtm-list .vtm-card {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    border: none;
    padding: 0;
    box-shadow: none;
    background: transparent;
    position: relative;
}
.vtm-list .vtm-card:hover {
    transform: none;
    box-shadow: none;
}
.vtm-list .vtm-card-media {
    flex: 0 0 200px;
    max-width: 200px;
    height: auto;
}
.vtm-list .vtm-card-media img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 12px;
}
.vtm-list .vtm-card-body {
    flex: 1;
    padding: 0 1rem;
}
.vtm-list .bookmark-toggle {
    position: static;
    margin-left: auto;
    /* Align star to the top of the row and enlarge it slightly */
    margin-top: 0;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Dark mode adjustments for header and controls */
.dark-mode .gh-head,
.dark-mode .gh-head-inner,
.dark-mode .gh-head-menu,
.dark-mode .gh-head-actions {
    background-color: var(--bg-color) !important;
    color: var(--fg-color) !important;
}
.dark-mode .gh-head a,
.dark-mode .gh-head .gh-head-link,
.dark-mode .gh-head button {
    color: var(--fg-color) !important;
}
.dark-mode .gh-head-members a.gh-head-btn {
    border-color: var(--fg-color) !important;
    background-color: transparent !important;
}
.dark-mode .gh-head a,
.dark-mode .gh-head span,
.dark-mode .gh-head button {
    color: var(--fg-color) !important;
}
.dark-mode .gh-head {
    box-shadow: none !important;
}

/* Align header sections neatly on larger screens to prevent overlap. */
.gh-head-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.gh-head-brand {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.gh-head-menu {
    flex-grow: 1;
    display: flex;
    justify-content: center;
}
.gh-head-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Adjust recommended side to stack its cards vertically */
.vtm-recommended-side .vtm-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Better contrast for bookmark toggle in both modes */
.bookmark-toggle {
    color: #000;
}
.bookmark-toggle.active {
    background: #ffd700;
    color: #000;
}
/* Ensure the star symbol is visible in dark mode */
.dark-mode .bookmark-toggle {
    color: var(--fg-color, #ffffff);
}
.dark-mode .bookmark-toggle.active {
    color: var(--bg-color, #000000);
}

/* ----------------------------------------------------- */
/* Dark mode toggle slider styles */
/* The switch is built using a hidden checkbox and a slider span */
.dark-mode-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    margin-right: 0.5rem;
}
.dark-mode-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.dark-mode-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: background-color 0.2s;
    border-radius: 34px;
}
.dark-mode-switch .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background-color: #fff;
    transition: transform 0.2s;
    border-radius: 50%;
}
.dark-mode-switch input:checked + .slider {
    background-color: #444;
}
.dark-mode-switch input:checked + .slider:before {
    transform: translateX(24px);
}
/* Dark mode card backgrounds and text colours */
.dark-mode .vtm-card,
.dark-mode .vtm-hero-card {
    background-color: #141414 !important;
    border-color: #333 !important;
}
.dark-mode .vtm-recommended-side .vtm-card {
    background-color: #141414 !important;
    border-color: #333 !important;
}
.dark-mode .vtm-card-body,
.dark-mode .vtm-hero-content {
    color: var(--fg-color) !important;
}
.dark-mode .vtm-card-excerpt {
    color: var(--fg-color) !important;
}

/* --- End vtm-home layout enhancements --- */

/* --- Additional styles --- */
/* Greeting bar below navigation on the home page. Align to the right and use larger font. */
.vtm-greeting-bar {
    margin: 1rem 0;
    text-align: right;
    font-weight: 600;
    font-size: 1rem;
}
.dark-mode .vtm-greeting-bar {
    color: var(--fg-color) !important;
}