:root {
    /* Color Variables for easy theming */
    --primary-bg: #333;
    --card-bg: #555;
    --input-bg: #444;
    --text-main: #00677b;
    --text-muted: #cccccc;
    --accent-pink: #f0abd6;
    --accent-blue: #a1d9e5;
    --rating-color:#a549cc;
    --shadow-color: #00677b;
    --border-light: rgba(255, 255, 255, 0.566);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    min-height:  calc(100vh - 128px);
    height: auto;
    color: var(--text-main);
    font-family: 'Courier New', monospace;
    background-color: var(--primary-bg);
}

/* =========================================
HEADER & NAVIGATION
========================================= */
    .site-header {
        position: relative;
        display: flex;
        align-items: center;
        background-color: var(--primary-bg);
        color: white;
        min-height: 64px;
        padding: 0.5rem 1rem;
    }

    /* TRUE center — ignores logo completely */
    .site-header h1 {
        font-family: 'Libre Baskerville';
        font-size: 3rem;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        margin: 0;
        white-space: nowrap;
    }

    /* Logo stays on the right */
    .menu-logo {
        margin-left: 0;
    }

    .menu-logo img {
        width: 60px;
        cursor: pointer;
        border-radius: 50%;
        border: 1px solid white;
        transition: width 0.3s ease;
    }

    .site-header.menu-open .menu-logo img {
        width: 150px;
    }

    /* Dropdown Menu */
    .menu-panel {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        transition: max-height 0.35s ease, opacity 0.4s ease;
        margin: 10px;
    }

    .site-header.menu-open .menu-panel {
        max-height: 200px;
        opacity: 1;
    }

    .menu-panel a {
        text-decoration: none;
        color: white;
    }

    .menu-panel a:hover{
        color: var(--accent-pink);
    }

    .auth-header {
        display: grid;
        grid-template-columns: 1fr;
        justify-content: flex-end;
        gap: 0.5rem;
        padding: 10px;
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
    }

    .log-btn {
        font-size: 0.9rem;
        text-align: center;
        text-decoration: none;
        background: var(--primary-bg);
        color: white;
        border-radius: 15px;
        border: 2px solid white;
        cursor: pointer;
        padding: 0.2rem 0.5rem;
    }

    .site-header .header-quote {
        transition: transform 0.3s ease;
    }

     /* This media is to avoid menu/header title overlap in narrow desktop layout*/
    @media (max-width: 925px) and (min-width: 769px) {
        .site-header.menu-open .header-quote {
            transform: translateX(calc(-50% + 60px));
        }
    }

    @media (max-width: 768px) {
        .site-header {
            flex-direction: column;
        }

        .site-header h1 {
            position: static;
            transform: none;
            text-align:center;
            margin-bottom: 0.5rem;
        }
        .site-header {
            flex-direction: column;
        }

        .site-header h1 {
            position: static;
            transform: none;
            text-align: center;
            margin: 0;
        }

        .site-header.menu-open h1 {
            margin-right: 0;
            transform: none;
        }

        .menu-logo {
            margin-left: 0;
        }

        .auth-header {
            position: relative;
            right: 10px;
            top: 10px;
            transform: none;
            padding-bottom: 1rem;
        }
    }

/* =========================================
LAYOUT & BACKGROUNDS
========================================= */
    .layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        min-height: calc(100vh - 64px);
        height: auto;
    }

    .layout-development {
        height: calc(100vh - 64px);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1.5rem;
        padding: 4rem;
        box-sizing: border-box;

        background-color:#c8e7f5;
        background-image:
            linear-gradient(var(--card-bg) 1px, transparent 1px),
            linear-gradient(90deg, var(--card-bg) 1px, transparent 1px);
        background-size: 40px 40px;
        background-position: 0 -1px;
    }

    .development{
        width: 100%;
        max-width: 800px;
        min-width: 400px
    }

    .left {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1.5rem;
        padding: 4rem;
        background-color: #f8f9ff;
        background-image:
            radial-gradient(circle at 20% 30%, #e3dbf0, transparent 60%),
            radial-gradient(circle at 80% 20%, var(--accent-pink), transparent 55%),
            radial-gradient(circle at 70% 80%, var(--accent-blue), transparent 60%),
            radial-gradient(circle at 30% 75%, #ea353e, transparent 65%);
    }

    .right, .layout-grid {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1.5rem;
        padding: 4rem;
        box-sizing: border-box;
        background-color:#c8e7f5;
        background-image:
            linear-gradient(#000 1px, transparent 1px),
            linear-gradient(90deg, #000 1px, transparent 1px);
        background-size: 40px 40px;
        background-position: 0 -1px;
    }

    .layout-grid {
        min-height: calc(100vh - 64px);
        height: auto;
    }

    .right > * {
        width: 100%;
        max-width: 420px;
    }

    .left,
    .right {
        flex: 1;
    }

    @media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        height: auto;
    }

    .left,
    .right {
        width: auto;
        min-height: auto;
        padding: 2rem;
    }

    .right {
        background-position: 0 -0.2px;
    }

    .logo {
        max-width: 180px;
    }

    .socials {
        gap: 1.2rem;
    }
    }

    .logo {
        width: 250px;
        height: auto;
        border-radius:50%;
        border: solid 1px white;
    }

    .menu-logo-img:hover{
        border: solid 3px var(--accent-pink);
    }

    .socials { display: flex; gap: 1.5rem; }

    .socials img {
        width: 28px;
        height: 28px;
        opacity: 1;
        display: inline-block;
        background: #f2ede7;
        padding: 4px;
        border-radius: 5px;
        transition: opacity 0.2s;

    }

    .socials img:hover {
        width: 32px;
        height: 32px;
        padding: 2px;
        background: rgb(160, 230, 237);
    }

    .socials i {
        font-size: 1.6rem;
        color: black;
        opacity: 0.85;
        transition: opacity 0.2s, transform 0.2s;
    }

    .socials i:hover {
        opacity: 1;
        transform: translateY(-5px);
    }

/* =========================================
FORUM POSTS
========================================= */
    .description-div {
        text-align: center;
        color: white;
        border: 2px solid white;
        background: var(--input-bg);
        padding: 0.5rem 1.5rem;
        font-size: 1.2rem;
        box-shadow: 5px 5px 15px 5px var(--shadow-color);
        border-radius: 8px;
    }

    .description-div h2 {
        font-family: 'Courier New';
    }

    .section-div {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        justify-content: center;
        color: white;
        border: 2px solid white;
        background: var(--card-bg);
        padding: 0.5rem 1.5rem;
        font-size: 1.2rem;
        max-width: 75%;
        box-shadow: 3px 2px 5px 2px var(--shadow-color);
        border-radius: 8px;
    }

    .signal{
        color: var(--text-muted);
        text-align: center;
        background: var(--input-bg);
        border: 2px solid white;
        padding: 1.5rem;
        border-radius: 15px;
        box-shadow: 5px 5px 15px 5px var(--shadow-color);
        max-width:300px;
        font-size: 1.1rem;
    }

    .error {
        padding-top: 1rem;
        color: white;
        margin-top: 0.5rem;
    }

/* =========================================
FORUM/LISTINGS POSTS
========================================= */
    .forum-section, .listings-section {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2rem;
        width: 100%;
        margin: 0 auto;
    }

    .post, .listing {
        width: 95%;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: left;

        color: white;
        border: 2px solid var(--border-light);
        background: var(--card-bg);
        gap: 1rem;
        padding: 1.5rem;
        font-size: 1.2rem;
        border-radius: 8px;
        box-shadow: 3px 3px 5px 2px var(--shadow-color);
    }

    .post h2, listing h2 {
        margin: 0;
    }

    .post p, listing p {
        font-family: system-ui;
    }

    .post-actions, .listing-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: center;
        justify-self: start;
        margin-top: 0.5rem;
        gap: 4rex;
    }

    .post-action-btn, .listing-action-btn{
        text-align: center;
        font-size: 0.95rem;
        padding: 0.4rem;
        border-radius: 12px;
    }

    .rating {
    display: inline-flex;
    flex-direction: row-reverse; /* KEY */
    gap: 4px;
    }

    .rating input {
        display: none;
    }

    .rating label {
        cursor: pointer;
    }

    /* Default = empty stars */
    .rating svg path:first-child {
        fill: none;
    }

    /* Hover fill */
    .rating label:hover svg path:first-child,
    .rating label:hover ~ label svg path:first-child {
        fill: var(--rating-color);
    }

    /* Checked fill */
    .rating input:checked ~ label svg path:first-child {
        fill: var(--rating-color);
    }


/* =========================================
COMMENTS/REVIEWS
========================================= */
    .comment-wrapper form, .review-wrapper form {
        margin-top: 0.4rem;
    }

    .comment-wrapper input, .review-wrapper input[type="text"] {
        width: 90%;
        padding: 0.3rem;
        font-size: 0.8rem;
        border-radius: 6px;
        border: none;
    }

    .comment-wrapper button, .review-wrapper button {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }

    .comment-wrapper::before, .review-wrapper::before {
        content: "";
        position: absolute;
        left: 0;
        top: 0.4rem;
        bottom: 0.4rem;
        width: 2px;
        background: rgba(255,255,255,0.15);
    }

    .comment-content, .review-content {
        text-align: left;
        padding-top: 10px;
        font-size: 1.05rem;
        border-bottom: 1px solid #000;
    }

    .comment-details, .review-details {
        align-items: left;
        font-size: 0.9rem;
    }

    details summary {
        list-style: none;
        cursor: pointer;
        font-size: 0.95rem;
        opacity: 0.8;
        padding: 8px;
        text-align: right;
        padding-left: 0;
        margin-left: 0;
    }

    details summary:hover {
    opacity: 1;
    }

    details summary::marker {
    display: none;
    }

    .comment-btn, .review-btn {
        font-size: 0.95rem;
        text-align: right;
    }

    .comments-section, .review-section {
        width: 100%;
        margin-top: 1rem;
    }

    .comment, .review {
        background: #666;
        padding: 0.7rem 0.9rem;
        border-radius: 6px;
        font-size: 0.95rem;
        text-align: left;

        margin-bottom: 0.4rem;
        border: 1px solid rgba(255,255,255,0.15);
    }

    .comment-actions, .review-actions {
        display: flex;
        gap: 0.8rem;
        margin-top: 5px;
    }

/* =========================================
UTILITIES & FOOTER
========================================= */
    .site-footer {
        min-height: 50px;
        background-color: var(--primary-bg);
        color: white;
        font-family: "Libre Baskerville", serif;
        font-size: 1rem;

        display: flex;
        justify-content: center;
        align-items: center;

        padding: 0.2rem 0.1rem;
        text-align: center;
    }

    button{
        background: var(--primary-bg);
        color: white;
        border-radius: 15px;
        border: 2px solid white;
        cursor: pointer;
    }

    button:hover, .nav-btn:hover, .log-btn:hover {
        background: var(--accent-pink);
        color: var(--primary-bg);
        transform: translateY(-2px);
    }

    .hidden {
        display: none;
    }

    .subjects {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 1.5rem;
        justify-items: center;

        width: 100%;
        max-width: 800px;
    }

    .subject-btn, .nav-btn {
        text-decoration: none;
        color: white;
        border: 2px solid white;
        padding: 1rem 2rem;
        font-size: 1.2rem;
        text-align: center;
        width: 100%;
        max-width: 200px;
        background: var(--primary-bg);
        transition: background 0.2s, color 0.2s;
        border-radius: 25px;
        box-shadow: 3px 5px 10px 5px var(--shadow-color);
        transform: translateY(-1px);
    }

    .subject-btn:hover {
        background: var(--accent-pink);
        color: var(--primary-bg);
    }

    .text-muted { opacity: 0.6; font-style: italic; }

    button.htmx-request {
        opacity: 0.8;
        pointer-events: none;
    }

    .char-counter {
        display: block;
        text-align: right;
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    .char-counter.limit-warning {
        color: #d9cb06; /* amber */
    }

    .char-counter.limit-exceeded {
        color: #dc7b26; /* red */
    }

    .feather-icon {
        height: 24px;
        width: auto;
    }

    .feather-icon-rating {
        height: 40px;
        width: auto;
    }

    .rating-container {
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    .rating-info li {
        margin-bottom: 10px;
    }

/* =========================================
FORMS & INPUTS
========================================= */
    .forum-form, .comment-form, .review-form {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 1rem;
        width: 100%;
        box-sizing: border-box;
        background: var(--input-bg);
        border: 2px solid white;
        padding: 1.5rem;
        border-radius: 15px;
        box-shadow: 3px 3px 2px 2px var(--shadow-color);
    }
    .comment-form {
        padding: 1rem;
    }

    .forum-form input,
    .forum-form textarea,
    .comment-form input,
    .comment-form textarea,
    .review-form input,
    .review-form textarea
    {
        font-family: system-ui;
        width: 95%;
        padding: 0.7rem;
        font-size: 1rem;
        border-radius: 10px;
        border: none;
    }

    .forum-form textarea {
        resize: vertical;
    }

    .forum-form button {
        align-self: center;
        padding: 0.6rem 1.5rem;
        font-size: 1rem;
        cursor: pointer;
    }

    .comment-form button {
        align-self: center;
        padding: 0.6rem 1.5rem;
        font-size: 1rem;
    }

    input:focus, textarea:focus {
        outline: 3px solid var(--accent-pink);
        border-color: transparent;
    }

    fieldset {
        display: grid;
        width: 95%;
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); /* Columns at least 150px wide, filling the space */
        gap: 0.5rem;
        border: 1px solid white;
        padding: 1rem;
        border-radius: 6px;
        color: white;
    }

    .checkbox-item {
        display: flex;
        align-items: center; /* Keeps text centered vertically with the box */
        cursor: pointer;     /* Makes the whole text clickable */
        user-select: none;   /* Prevents accidental text highlighting while clicking */
    }

    .checkbox-item input[type="checkbox"] {
        width: 1.1em;
        height: 1.1em;
        margin-right: 0.5rem;
        flex-shrink: 0; /* CRITICAL: Prevents long text from squishing the checkbox */

        /* Optional: Makes the checkbox color match your theme */
        accent-color: var(--accent-blue);
    }

/* =========================================
LOG-IN/SIGN-IN ERRORS
========================================= */

    /* Base error style */
    #error .error,
    #login-error .error {
    color: #b00020;
    background: #ffecec;
    border: 1px solid #f5a3a3;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-top: 0.75rem;
    }

    /* Animate when HTMX updates the target */
    #login-error.htmx-settling .error {
    animation: shakeFade 0.4s ease-out;
    }

    @keyframes shakeFade {
    0%   { opacity: 0; transform: translateY(-6px); }
    60%  { opacity: 1; transform: translateY(2px); }
    100% { transform: translateY(0); }
    }

/* =========================================
LOADING SPRITE ANIMATION
========================================= */
    .crow-loader {
        width: 100px;
        height: 100px;
        background-image: url("../assets/flying-crow.svg");
        background-repeat: no-repeat;
        background-size: 1000% 100%;
        animation: crow-sprite 0.8s infinite steps(9) alternate;
    }

    @keyframes crow-sprite {
        from { background-position: 0 0; }
        to   { background-position: 100% 0; }
    }

    /* Hidden unless HTMX request is active */
    .htmx-indicator {
        display: none;
    }

    /* Shown automatically by HTMX */
    .htmx-request .htmx-indicator {
        display: block;
    }

    /* Optional positioning */
    #global-loader {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 9999;
        pointer-events: none;

        /* soft glow background */
        padding: 12px;
        border-radius: 50%;

        background: radial-gradient(
            circle,
            rgba(255, 255, 255, 0.35) 0%,
            rgba(255, 255, 255, 0.2) 40%,
            rgba(255, 255, 255, 0.05) 70%,
            rgba(255, 255, 255, 0) 90%
        );
    }

/* =========================================
   MOBILE & TABLET OPTIMIZATIONS
   (Applies to anything smaller than an iPad in portrait)
========================================= */
@media (max-width: 480px) {

    /* 1. LAYOUT: Reduce the massive desktop padding */
    .layout-development, .left, .right, .layout-grid {
        padding: 1rem;
        width: 100%;
    }

    .section-div {
        max-width: 100%;
    }


    /* 2. BUTTONS: Fix the Forum/Listing buttons (Side-by-side, not stacked) */
    .post-actions, .listing-actions {
        display: flex;          /* Use Flex instead of Grid */
        gap: 0.5rem;           /* Small gap between buttons */
        width: 100%;
        margin-top: 1rem;
    }

    .post-action-btn, .listing-action-btn {
        flex: 1;               /* Both buttons take equal width */
        font-size: 0.85rem;    /* Smaller text */
        padding: 0.6rem 0.2rem;/* Tappable area, but not huge */
        border-radius: 8px;
        white-space: nowrap;   /* Prevents text from breaking */
    }

    /* 3. CARDS: Make posts compact */
    .post, .listing {
        padding: 1rem;         /* Reduce internal padding */
        width: 100%;           /* Ensure full width */
        box-shadow: 2px 2px 4px 1px var(--shadow-color); /* Smaller shadow */
    }

    /* 4. NAV: Fix the huge Home/Subject buttons */
    .nav-btn, .subject-btn {
        font-size: 1rem;
        padding: 0.8rem 1rem;
        box-sizing: border-box;
    }

    /* 5. FORMS: Prevent them from looking squeezed */
    .forum-form, .comment-form, .review-form {
        padding: 1rem;
        width: 100%;
    }

    /* Force 2 columns for checkboxes on mobile (instead of auto-fill) */
    fieldset {
        grid-template-columns: 1fr 1fr;
    }
}