/* style.css - OpenMag Master Style */

:root {
    --primary-color: #007AFF;
    --bg-color: #ffffff;
    --sidebar-bg: #f8f9fa;
    --text-dark: #121212;
    --text-muted: #6c757d;
    --card-bg: #ffffff;
    --border-color: #eeeeee;
    --sidebar-width: 290px;
    --font-main: 'DM Sans', sans-serif;
    --font-serif: 'Playfair Display', serif;
}

* { box-sizing: border-box; }
a { text-decoration: none !important; color: inherit; }

body { 
    background-color: var(--bg-color); 
    font-family: var(--font-main); 
    margin: 0; 
    padding: 0;
    color: var(--text-dark);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

/* --- YLÄPALKKI (HEADER) --- */
header.main-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-left h1 {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    margin: 0;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    gap: 10px;
}

/* UNIFIED BUTTONS (30px height) */
.settings-btn,
.dark-select,
.sidebar-view-toggle button {
    height: 30px;
    padding: 0 16px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.settings-btn,
.dark-select,
.sidebar-view-toggle button.active {
    background-color: var(--text-dark);
    color: white;
}

.settings-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.settings-btn:hover { background-color: #333; }
.settings-btn.active { background-color: var(--primary-color); }

.settings-arrow {
    display: inline-block;
    transition: transform 0.25s ease;
    font-size: 0.55rem;
}
.settings-btn.active .settings-arrow { transform: rotate(180deg); }

.dark-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath fill='white' d='M0 2l4 4 4-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.dark-select:hover { background-color: #333; }

/* SETTINGS PANEL */
.settings-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    z-index: 999;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 25px;
}
.settings-panel.open {
    max-height: 600px;
    padding: 20px 25px 16px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.settings-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.settings-section-footer {
    margin-top: 12px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
    accent-color: var(--text-dark);
}

.settings-radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.15s;
}
.settings-radio-label:hover { color: var(--primary-color); }
.settings-radio-label input[type="radio"] {
    accent-color: var(--text-dark);
    cursor: pointer;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

#settings-lang-fallback-label {
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-dark);
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.15s;
}

.settings-note {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin: 8px 0 0;
    font-style: italic;
}

.settings-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.settings-apply-btn,
.settings-reset-btn {
    height: 28px;
    padding: 0 20px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    border: none;
    outline: none;
    transition: background-color 0.2s ease;
}
.settings-apply-btn {
    background-color: var(--text-dark);
    color: white;
}
.settings-apply-btn:hover { background-color: #333; }
.settings-reset-btn {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}
.settings-reset-btn:hover { color: var(--text-dark); border-color: var(--text-dark); }

@media (max-width: 900px) {
    .settings-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 650px) {
    .settings-grid { grid-template-columns: 1fr; gap: 16px; }
    .settings-panel.open { max-height: 1000px; }
}

/* RSS LINK ICONS */
.rss-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    color: var(--primary-color);
    opacity: 0.6;
    transition: all 0.2s ease;
    vertical-align: middle;
}

.rss-link:hover { opacity: 1; transform: scale(1.1); }
.rss-link svg { width: 22px; height: 22px; display: block; fill: currentColor; }

.title-link { cursor: pointer; transition: color 0.2s; }
.title-link:hover { color: var(--primary-color); }

/* --- SIDEBAR --- */
.sidebar { 
    height: 100vh; 
    width: var(--sidebar-width); 
    position: sticky;
    top: 0; 
    left: 0; 
    background-color: var(--sidebar-bg); 
    border-right: 1px solid var(--border-color);
    transition: transform 0.4s ease, margin-left 0.4s ease;
    flex-shrink: 0;
    overflow-y: auto;
    z-index: 2000;
}

.sidebar.closed { margin-left: calc(-1 * var(--sidebar-width)); }

/* SIDEBAR VIEW TOGGLE */
.sidebar-view-toggle {
    display: flex;
    padding: 4px;
    background: #eee;
    margin: 12px 20px;
    border-radius: 25px;
    gap: 4px;
    flex-wrap: wrap;
}

.sidebar-view-toggle button { 
    flex: 1; 
    background: none; 
    color: var(--text-muted); 
    white-space: nowrap;
}


/* SIDEBAR TOGGLE BUTTON */
#sidebar-toggle { 
    position: fixed; 
    top: 12px; 
    left: 20px; 
    z-index: 2500; 
    background: var(--text-dark); 
    color: white; 
    border: none; 
    padding: 0 18px;
    cursor: pointer; 
    font-size: 0.7rem; 
    font-weight: 700;
    transition: opacity 0.3s ease, transform 0.3s ease;
    border-radius: 20px;
    height: 30px;
}

@media (min-width: 651px) {
    #sidebar-toggle { display: none; }
}

@media (max-width: 650px) {
    header.main-header { padding-left: 80px; }
}

/* ACCORDION MENU */
.category-group { border-bottom: 1px solid var(--border-color); }
.category-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 15px 20px; 
    font-weight: 700; 
    text-transform: uppercase;
    font-size: 0.65rem; 
    letter-spacing: 2px; 
    cursor: pointer;
    transition: background 0.2s;
}
.category-header:hover { color: var(--primary-color); background-color: #fff; }
.category-header::after { content: '+'; font-size: 1rem; color: #ccc; transition: transform 0.3s; }
.category-group.open .category-header::after { content: '−'; color: var(--primary-color); }

.source-submenu { max-height: 0; overflow: hidden; transition: max-height 0.4s ease-out; background-color: #fff; }
.category-group.open .source-submenu { max-height: 2000px; }

.source-item { 
    cursor: pointer; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    font-size: 0.85rem; 
    color: var(--text-muted); 
    padding: 10px 20px;
    transition: all 0.2s;
}
.source-item:hover, .source-item.active { color: var(--primary-color); background: #fcfcfc; }
.source-item.active { font-weight: 700; border-left: 3px solid var(--primary-color); }
.source-item span { font-size: 0.7rem; color: #b7b7b7; font-weight: 400; }

/* --- CONTENT AREA --- */
main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }

#feed-header-area { display: flex; align-items: center; gap: 20px; margin: 10px 20px; min-height: 90px; }
#feed-info-container { display: flex; flex-direction: column; justify-content: center; flex-grow: 1; }
#feed-logo-container { flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
#feed-logo-container img { max-width: 60px; max-height: 60px; width: auto; height: auto; display: block; }
#feed-logo-container.dark-bg { background-color: #1a1a1a; border-radius: 8px; }

.view-title { font-family: var(--font-serif); font-size: 2.4rem; line-height: 1.1; display: flex; align-items: center; gap: 15px; margin: 0; }
#current-view-description { font-size: 0.95rem; color: var(--text-muted); margin-top: 8px; }

/* --- GRID & CARDS --- */
.grid { width: 100%; max-width: 1400px; margin: 0 auto; padding: 0 20px; opacity: 0; transition: opacity 0.5s ease; }
.grid.loaded { opacity: 1; }
.grid-sizer, .grid-item { width: 31%; }

.grid-item {
    position: relative;
    margin-bottom: 25px; 
    background: var(--card-bg); 
    border: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}
.grid-item:hover { border-color: var(--primary-color); }
.grid-item img { width: 100%; height: auto; display: block; background-color: #f8f9fa; }

.content { padding: 15px; }

.category-label { 
    text-transform: uppercase; 
    font-size: 0.6rem; 
    letter-spacing: 2px; 
    color: var(--primary-color); 
    font-weight: 700; 
    margin-bottom: 10px; 
    display: block; 
    cursor: pointer;
}

.grid-item h2 { font-family: var(--font-serif); margin: 0 0 12px; font-size: 1.35rem; line-height: 1.25; }
.grid-item p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0; }

.meta-info { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-top: 15px; 
    padding-top: 15px; 
    border-top: 1px solid #f8f9fa;
    font-size: 0.6rem; 
    letter-spacing: 1px; 
    color: #999; 
    text-transform: uppercase;
}

/* BOOKMARK BUTTON ON CARD */
.bookmark-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    color: white;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
}

.bookmark-btn:hover {
    transform: scale(1.15);
}

/* Filled white star when bookmarked, on image */
.bookmark-btn[aria-pressed="true"] {
    color: white;
}

/* Outline white star when not bookmarked, on image */
.bookmark-btn[aria-pressed="false"] {
    color: white;
}

/* When card has no image, star uses text colour instead of white */
.no-image .bookmark-btn {
    color: var(--text-muted);
    filter: none;
    text-shadow: none;
    opacity: 1;
}

.no-image .bookmark-btn[aria-pressed="false"] {
    color: var(--text-muted);
    opacity: 1;
}

.no-image .bookmark-btn[aria-pressed="true"] {
    color: var(--text-dark);
}

.no-image .bookmark-btn:hover {
    filter: none;
    color: var(--primary-color);
}

#scroll-sentinel { text-align: center; padding: 80px 0; color: #bbb; text-transform: uppercase; letter-spacing: 3px; font-size: 0.8rem; }

/* --- RESPONSIVE --- */
@media (max-width: 1100px) { 
    .grid-sizer, .grid-item { width: 48%; } 
}

@media (max-width: 650px) { 
    .grid-sizer, .grid-item { width: 46%; }
    .grid { padding: 0 10px; }
    .grid-item { margin-bottom: 12px; }
    .content { padding: 10px; }
    .grid-item h2 { font-size: 1.1rem; }
    .sidebar { position: fixed; transform: translateX(-100%); z-index: 3000; }
    .sidebar.open { transform: translateX(0); }
    .sidebar.closed { margin-left: 0; }
    .header-left h1 { font-size: 1.1rem; }
    .dark-select { padding: 6px 10px; padding-right: 25px; font-size: 0.65rem; }
    .view-title { font-size: 1.8rem; }
}

@media (max-width: 360px) {
    .grid-sizer, .grid-item { width: 100%; }
}
