/* Import Inter from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ================= Global Styles ================= */
/* Set a global base font-size; 1rem = 15px */
:root {
    font-size: 15px;
    --background-color: #ffffff;
    --text-color: #000;
    --ribbon-background: rgba(255, 255, 255, 0.7);
    --toggle-color: #000;
    --tile-background: rgba(255, 255, 255, 0.7);
    --sidebar-background: rgba(255, 255, 255, 0.7);
    --sidebar-text-color: #000;
    --ribbon-height: 60px;
    --mobile-breakpoint: 768px;
}

/* Uniform Link Styling */
a {
    color: var(--sidebar-text-color);
    text-decoration: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
}

a:hover {
    opacity: 1;
}

/* ----- Base Styles ----- */
/* Apply font and spacing globally */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
}

/* Force all <p> tags to inherit global styles */
p {
    font-size: inherit;
    line-height: inherit;
    margin: 0 0 1em 0;
}

/* Force containers to inherit font settings */
.blog-post,
.category-content,
.category-tile,
.sidebar {
    font-size: inherit;
    line-height: inherit;
}

/* Explicitly reset nested elements */
.blog-post p,
.category-content p,
.category-tile p,
.sidebar a {
    font-size: 1rem; /* 14px via :root */
    line-height: 1.6;
}

body, html {
    margin: 0;
    height: 100%;
    width: 100%;
    background: var(--background-color);
    color: var(--text-color);
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
    /* All text will inherit the global font size (15px) */
}

/* Apply uniform left/right padding for content elements */
h1, h2, h3, h4, h5, h6, p, ul, ol, .author, .date {
    padding-left: 10px;
    padding-right: 10px;
}

#blog-post-list {
    padding-left: 40px;
    list-style-position: outside;
}  

/* For quote sections */
blockquote {
    padding-left: 25px;
    padding-right: 25px;
    margin-left: 10px;
    margin-right: 10px;
}

/* ----- Remove Local Font-Size Overrides for Text Containers ----- */
/* All paragraphs inside these containers will simply inherit the global font size */
.category-tile p,
.blog-post p,
.category-content p {
    margin: 0 0 1em 0 !important;
}

/* Sidebar links – remove local font-size overrides */
.sidebar a {
    color: var(--sidebar-text-color);
    text-decoration: none;
    margin: 0 0 0.5em 0 !important;
}

/* ----- Top Ribbon (Header) ----- */
.top-ribbon {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    height: 50px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--ribbon-background);
    color: var(--text-color);
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    position: relative;
}

.top-ribbon::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 100%;
    height: 8px;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.4) 0%,
        rgba(255, 255, 255, 0) 100%
    );
    pointer-events: none;
}

/* Nav toggle */
.nav-toggle {
    order: -1;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    margin: auto 20px;
    padding: 5px 0;
    position: relative;
    z-index: 1002;
}

.nav-toggle div {
    width: 20px;
    height: 2px;
    background: var(--toggle-color);
    margin: 3px 0;
}

/* Logo container */
.logo-container {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto; 
}

.logo-container a {
    display: flex;
    align-items: center;
    gap: 2px;
}

.logo-image {
    height: 30px;
    margin-right: 0;
    margin-left: 20px;
}

/* Brand name remains larger for emphasis */
.brand-name {
    font-size: 25px;
    margin: 0;
    white-space: nowrap;
}

/* ----- Search Bar ----- */
.search-bar {
    flex: 2;
    display: flex;
    justify-content: center;
    position: relative;
    margin: auto 1rem;
    margin-left: 1rem;
}

.search-bar input[type="text"] {
    padding: 0.2rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 200px;
    transition: width 0.3s;
}

.search-bar input[type="text"]:focus {
    width: 300px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 200px;
    max-width: 90vw;
    z-index: 1001;
    display: none;
}

.search-results.show {
    display: block;
}

.search-results div {
    padding: 0.5rem;
    border-bottom: 1px solid #ddd;
}

.search-results div:last-child {
    border-bottom: none;
}

/* ----- Hero Section ----- */
.hero {
    text-align: center;
    padding: 4rem 2rem 2rem;
}

.hero h2 {
    font-size: 1.5rem;
    margin: 0.5rem 0;
}

.hero p {
    font-size: 1.2rem;
    margin: 0;
}

/* ----- Category Tiles ----- */
.category-tiles {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 10px;
    margin: 0 auto;
    max-width: 1500px;
}

.category-tile {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 200px;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    background: var(--tile-background);
    color: var(--text-color);
    padding: 0.5rem;
    width: 100%;
    box-sizing: border-box;
    text-decoration: none;
}

.category-tile:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 25px rgba(0, 122, 255, 0.12);
    z-index: 10;
}

.category-tile::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 4px;
    box-shadow: 
        0 0 35px rgba(255, 255, 255, 0.1),
        0 0 15px rgba(255, 255, 255, 0.05);
    pointer-events: none;
    opacity: 0.8;
    z-index: -1;
}

.category-tile h2 {
    text-align: center;
    margin: 0;
}

.category-tile-content {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    height: 100%;
}

.category-tile img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 0.5rem;
}

.category-tile p {
    margin: 0;
    flex: 1;
    align-self: flex-start;
    padding: 0 0.2rem;
}

/* ----- Sidebar ----- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 200px;
    transform: translateX(-100%);
    transition: transform 0.3s;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-background);
    color: var(--text-color);
    z-index: 1001;
}

.sidebar.active {
    transform: translateX(0);
}

.sidebar a {
    color: var(--sidebar-text-color);
    text-decoration: none;
    font-size: inherit !important;
    line-height: inherit !important;
    margin: 0 0 0.5em 0 !important;
}

.sidebar .subcategories a {
    margin-left: 1rem !important;
    display: block;
}

.sidebar .subcategories {
    display: none;
}

.sidebar .subcategories.active {
    display: block;
}

/* ----- Footer ----- */
.main-content {
    padding-bottom: 40px;
}

.rumi-quote {
    text-align: center;
    margin-top: 2rem;
    font-style: italic;
    padding: 0 25px;
    margin: 0 10px;
}

.footer {
    text-align: center;
    padding: 1rem;
    background: var(--ribbon-background);
    position: sticky;
    width: 100%;
    bottom: 0;
    font-size: 0.8rem;
}

/* Category Content Styles */
.category-content {
    margin-top: 4rem;
    padding: 0 10px;
}

.category-content a:not([href*="index.html"]):not([href*="home"]) {
    color: var(--text-color) !important;
    text-decoration: none;
}

.category-content a:visited:not([href*="index.html"]):not([href*="home"]) {
    color: #777 !important;
}

/* For category content links, remove local font-size overrides */
.category-content a:not([href*="index.html"]):not([href*="home"]):link,
.category-content a:not([href*="index.html"]):not([href*="home"]):visited {
    display: inline-block;
}

/* ----- Blog Post Styles ----- */
.blog-post {
    margin-top: 4rem;
    padding: 0 10px;
}

.blog-post h2 {
    margin-top: 2rem;
}

.blog-post p {
    line-height: 1.6 !important; 
}

/* Ensure images and videos follow container width */
.blog-post img,
.blog-post video {
    width: 100%;
    height: auto;
    margin-bottom: 1rem;
}

.blog-post .author {
    font-style: italic;
    margin-bottom: 1rem;
}

.blog-post .date {
    color: #777;
    margin-bottom: 1rem;
}

/* ----- Comments Section Styling ----- */
.blog-post .comments {
    margin-top: 2rem;
}

.blog-post .comments h3 {
    margin-bottom: 1rem;
}

.comments-container {
    max-width: 800px;
    margin: 0 auto;
}

.comment {
    margin: 1rem 0;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding-left: 15px;
    padding-right: 15px;
}

.comment .comment-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    color: #666;
}

.comment .comment-meta strong {
    font-weight: 600;
    color: #333;
}

.comment p {
    margin-bottom: 15px;
}

/* Comment content truncation */
.comment-content {
    position: relative;
    overflow: hidden;
    --lines-to-show: 4;
    max-height: calc(var(--lines-to-show) * 1em * 1.6); /* 1.6 matches global line-height */
    line-height: inherit; /* Use global 1.6 */
    margin-bottom: 15px;
}

.comment-content.expanded {
    max-height: none;
    overflow: visible;    
}

.read-more {
    color: #666;
    cursor: pointer;
    display: inline-block;
    padding: 2px 5px;
    background: none;
    font-size: 0.85em;
    border-radius: 3px;
    margin-bottom: 10px;
}

.read-more:hover {
    color: #333;
    background-color: #f0f0f0;
}

/* Reply section styling */
.toggle-replies {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #666;
    cursor: pointer;
    padding: 3px 5px;
    font-size: 0.9em;
    border-radius: 3px;
    background: none;
    margin-right: 10px;
}

.toggle-replies:hover {
    color: #333;
    background-color: #f0f0f0;
}

.comment-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 15px;
}

.comment-form {
    margin-top: 15px;
    padding: 10px;
    background: none;
    border-radius: 8px;
}

.comment-form .form-group {
    margin-bottom: 10px;
}

.comment-form textarea,
.comment-form input {
    width: 98%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.comment-form button {
    background: none;
    color: #666;
    border: 1px solid #ddd;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.comment-form button:hover {
    background-color: #e9e9e9;
    color: #000;
}

.reply-btn, .like-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #666;
    transition: color 0.3s ease;
}

.reply-btn svg, .like-btn svg {
    stroke: #666;
    transition: stroke 0.3s ease;
}

.reply-btn:hover, .like-btn:hover {
    color: #333;
}

.reply-btn:hover svg, .like-btn:hover svg {
    stroke: #333;
}

.like-container {
    display: flex;
    align-items: center;
    gap: 5px;
}

.like-count {
    font-size: 0.9rem;
    color: #666;
}

.like-btn.liked svg {
    fill: #666;
    stroke: #666;
}

.replies {
    margin-top: 15px;
    padding-left: 20px;
    border-left: 2px solid #e9e9e9;
    display: none;
}

.replies.visible {
    display: block;
}

.error {
    color: red;
    padding: 1rem;
}

/* Login, Register and Contact Form styles */
form {
    display: block;
    padding-left: 15px;
    padding-right: 15px;
}

label, input, textarea, button, select {
    display: block;
    margin-bottom: 10px;
}

.flash {
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.flash.success,
.flash.danger {
    background: var(--background-color);
    color: var(--text-color);
}

/* Submit Button Styling for Forms */
form button,
form input[type="submit"],
#reset-password-form button {
    background: none;
    color: #666;
    border: 1px solid #ddd;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

form button:hover,
form input[type="submit"]:hover,
#reset-password-form button:hover {
    background-color: #e9e9e9;
    color: #000;
}

/* Reset Password Form */
#reset-password-form {
    display: none;
    margin-top: 20px;
    padding-left: 15px;
    padding-right: 15px;
}

/* ================= Mobile Optimization ================= */
@media (max-width: 767px) {
    .top-ribbon {
        justify-content: space-between;
        height: 50px;
        padding: 0;
    }

    .nav-toggle {
        display: flex !important;
        flex-direction: column;
        cursor: pointer;
        margin: 0 1rem;
        position: relative;
        z-index: 1002;
    }
    .nav-toggle div {
        margin: 2px 0;
    }

    .logo-container {
        margin: 0 auto;
    }

    .logo-image {
        height: 30px;
    }
    .brand-name {
        font-size: 25px;
    }

    .search-bar {
        flex: none;
        width: auto;
        margin: 0 1rem 0 auto;
        box-sizing: border-box;
    }
    .search-bar input[type="text"] {
        padding: 0.5rem 0.5rem;
        width: 45px;
        transition: width 0.3s;
        white-space: nowrap;
    }
    .search-bar input[type="text"]:focus {
        width: 80px;
    }
    .search-results {
        max-width: 40vw;
    }

    .category-tile {
        width: 100% !important;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
    }
    .category-tile-content {
        flex-direction: column;
    }
    .category-tile img {
        width: 100%;
        height: auto;
        margin-bottom: 1rem;
    }
    .category-tile p {
        padding-right: 0;
    }

    .sidebar {
        width: 40%;
        max-width: 250px;
        padding-top: 3rem;
        left: 0;
    }

    .hero {
        padding: 2rem 1rem 1rem;
    }
    .category-content {
        margin-top: 2rem;
    }
    .blog-post {
        margin-top: 2rem;
    }
    .category-content p,
    .main-content > * {
        padding-left: 15px;
        padding-right: 15px;
    }

    .comment {
        padding: 10px;
    }

    .blog-post {
        padding-left: 10px;
    }
}

@media (max-width: 480px) {
    html, body {
        overflow-x: hidden;
    }
    .category-tile h3 {
        font-size: 1.1rem;
    }
}

/* Mobile browser fullscreen on scrolling down */
@media (max-width: 768px) {
    .main-content {
        height: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .top-ribbon {
        position: sticky;
        top: 0;
        left: 0;
        right: 0;
    }

    .sidebar {
        top: 60px;
        height: calc(100% - 60px);
    }

    body {
        overflow-y: scroll;
        scroll-behavior: smooth;
    }

    html {
        overflow: initial;
    }
}