/*
 * norithm.com
 * Main Stylesheet
 */

/* --- [1] Root Variables & Global Styles --- */

:root {
    --title-bar-color: #000080;
    --window-bg: #c0c0c0;
    --title-bar-text: #ffffff;
    --text-color: #000000;
    --desktop-bg: #008080;
    --highlight: #dfdfdf;
    --shadow: #808080;
}
* {
    box-sizing: border-box;
}
body {
    background-color: var(--desktop-bg); 
    font-family: Tahoma, "MS Sans Serif", Arial, sans-serif;
    font-size: 16px;
    color: var(--text-color); 
    margin: 0;
    padding: 0;
    padding-top: 54px; 
    padding-bottom: 0; 
}
a {
    color: var(--text-color); 
    text-decoration: underline; 
}
a:hover {
    color: var(--title-bar-color);
}
hr {
    border: none;
    border-top: 2px inset var(--shadow); 
    margin: 20px 0;
}

/* --- [2] Main Layout & Window Components --- */

.main-nav {
    position: fixed;
    top: 0; 
    bottom: auto; 
    left: 0;
    right: 0;
    background: var(--window-bg); 
    border-bottom: 2px outset var(--highlight); 
    border-top: none; 
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    min-height: 54px; 
    gap: 10px;
    transition: transform 0.3s ease-in-out;
}
/* Auto-hide classes */
.nav-hidden-desktop {
    transform: translateY(-100%); 
}
.nav-hidden-mobile {
    transform: translateY(100%); /* Slides down */
}
.site-title {
    font-weight: bold;
    font-size: 1.2em;
    white-space: nowrap;
    flex-shrink: 0; 
}
.site-title img {
    max-height: 32px;
    vertical-align: middle;
}
.desktop-nav-wrap {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-grow: 1; 
    min-width: 0; 
}
.nav-center-wrap {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-grow: 1; 
    min-width: 0; 
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0; 
}
.feed-links {
    border-left: 2px inset var(--shadow);
    padding-left: 15px;
    display: flex; 
    gap: 0; 
    flex-wrap: wrap; 
}
.feed-links a {
    font-weight: bold;
    color: var(--text-color);
    padding: 5px;
}
.feed-links a.button-link {
    text-decoration: none;
    border-left: none; 
}
.feed-links a.button-link:first-child {
    border-left: 2px outset var(--highlight); 
}
.user-menu {
    padding-left: 15px;
    white-space: nowrap;
}
.nav-icons {
    display: flex;
    gap: 0; 
    border-left: 2px inset var(--shadow); 
    padding-left: 15px; 
}
.nav-button {
    display: inline-flex; 
    align-items: center;
    justify-content: center;
    background: var(--window-bg);
    border: 2px outset var(--highlight);
    border-left: none; 
    padding: 4px 10px;
    color: var(--text-color);
    text-decoration: none;
    font-family: Arial, sans-serif; 
    font-size: 1.1em;
    cursor: pointer;
    min-width: 40px;
    min-height: 30px;
    text-align: center;
    line-height: 1; 
    white-space: nowrap;
}
.nav-icons .nav-button:first-child {
    border-left: 2px outset var(--highlight);
}
.nav-button:hover {
    text-decoration: none;
}
.nav-button:active {
    border-style: inset;
}
main.content {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}
footer {
    text-align: center;
    color: #fff;
    padding: 20px;
    font-size: 0.9em;
}
.window {
    background: var(--window-bg); 
    border: 2px outset var(--highlight); 
    box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
    margin-bottom: 20px;
}
.title-bar {
    background: var(--title-bar-color); 
    color: var(--title-bar-text); 
    padding: 4px 8px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.window-body {
    padding: 15px;
    min-height: 100px;
}

/* --- [3] Forms & Tables --- */
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
    border: 2px inset var(--shadow); 
    background: #ffffff;
    padding: 5px;
    font-family: inherit;
    font-size: 1em;
}
textarea {
    width: 100%;
}
button,
input[type="submit"],
input[type="file"]::file-selector-button {
    background: var(--window-bg); 
    border: 2px outset var(--highlight); 
    padding: 5px 15px;
    font-family: inherit;
    font-size: 1em;
    cursor: pointer;
}
button:active,
input[type="submit"]:active,
input[type="file"]::file-selector-button:active {
    border-style: inset;
}
.field-row {
    margin-bottom: 10px;
}
.field-row-stacked {
    margin-bottom: 10px;
}
.field-row-stacked label {
    display: block;
    margin-bottom: 4px;
}
.field-row-stacked input[type="text"],
.field-row-stacked input[type="password"],
.field-row-stacked input[type="email"],
.field-row-stacked textarea,
.field-row-stacked select {
    width: 100%;
}
fieldset {
    border: 2px inset var(--shadow);
    padding: 10px 15px 15px 15px;
    margin-bottom: 15px;
}
legend {
    font-weight: bold;
    padding: 0 5px;
    margin-left: 5px;
}
table {
    width: 100%;
    border-collapse: collapse;
    border: 2px inset var(--shadow); 
}
th, td {
    border: 1px inset var(--shadow); 
    padding: 8px;
    text-align: left;
}
thead th {
    background: var(--window-bg); 
    border-style: outset;
}
tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.3);
}

/* --- [4] UCP & Admin Tabs --- */
menu[role="tablist"] {
    display: flex;
    padding: 0;
    margin: 0;
    border-bottom: 2px solid var(--shadow); 
    flex-wrap: wrap; 
}
menu[role="tablist"] button {
    border: 2px outset transparent;
    border-bottom: none;
    border-radius: 0;
    margin-bottom: -2px; 
    padding: 8px 12px;
}
menu[role="tablist"] button[aria-selected="true"] {
    border-color: var(--highlight); 
    border-bottom-color: var(--window-bg); 
    background: var(--window-bg); 
}
menu[role="tablist"] button[aria-selected="false"] {
    background: var(--shadow); 
    border-color: var(--shadow); 
}
section[role="tabpanel"] {
    padding-top: 20px;
}

/* --- [5] UI Components (Messages, etc) --- */
.message-success {
    background: #e6ffec; border: 1px solid green;
    color: green; padding: 10px; margin-bottom: 15px;
}
.message-error {
    background: #ffebeb; border: 1px solid red;
    color: red; padding: 10px; margin-bottom: 15px;
}
.delete-button {
    background: #c00000; color: #fff;
    border-color: #ff8080 #600000 #600000 #ff8080;
}
.delete-button:active {
    border-color: #600000 #ff8080 #ff8080 #600000;
}

/* --- [6] Homepage (Image Grid & Hashtag Cloud) --- */
.responsive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}
.grid-item {
    border: 2px outset var(--highlight); 
    background: #fff;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}
.grid-item a {
    display: block;
    line-height: 0;
    text-decoration: none; 
}
.grid-item a:hover {
    text-decoration: none;
}
.grid-item img {
    width: 100%;
    aspect-ratio: 1 / 1; 
    object-fit: cover;
    display: block;
}
.grid-item .image-meta {
    font-size: 0.85em;
    padding: 5px 8px;
    background: var(--window-bg); 
    border-top: 1px solid var(--shadow); 
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.grid-item .image-meta a {
    text-decoration: underline;
    line-height: 1.2;
}
.grid-item .hit-counter {
    font-size: 0.8em;
    padding: 0 8px 5px 8px;
    margin: 0;
    background: var(--window-bg);
}
.followed-indicator {
    color: green; font-weight: bold; font-size: 1.2em;
}
.hashtag-cloud {
    padding: 10px; text-align: center;
}
.hashtag-cloud a {
    display: inline-block; margin: 5px; line-height: 1.2;
    text-decoration: none;
}

/* --- [7] Lightbox --- */
#norithm-lightbox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); z-index: 2000;
    display: none; align-items: center; justify-content: center;
}
#norithm-lightbox.active {
    display: flex;
}
.lightbox-content {
    position: relative; max-width: 90vw; max-height: 90vh;
    display: flex; flex-direction: column;
}
.lightbox-content img {
    max-width: 100%; max-height: calc(90vh - 50px);
    object-fit: contain;
    border: 3px solid var(--highlight); 
}
.lightbox-description {
    background: var(--window-bg); 
    color: var(--text-color); 
    padding: 10px; font-size: 0.9em; text-align: center;
    border: 2px outset var(--highlight); 
    border-top: none; max-width: 100%;
}
.lightbox-controls {
    display: none; 
    background: var(--window-bg);
    color: var(--text-color);
    padding: 8px 10px;
    font-size: 0.9em;
    text-align: right;
    border: 2px outset var(--highlight);
    border-top-style: inset;
}
.lightbox-controls a {
    margin-left: 15px;
    text-decoration: underline;
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: fixed; background: rgba(40,40,40,0.5); color: #fff;
    border: 2px outset #fff; font-family: 'Arial', sans-serif;
    font-weight: bold; cursor: pointer; z-index: 2001; user-select: none;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255,255,255,0.3); color: #000;
}
.lightbox-close:active,
.lightbox-prev:active,
.lightbox-next:active {
    border-style: inset;
}
.lightbox-close {
    top: 20px; right: 20px; font-size: 2.5em; padding: 0 15px;
}
.lightbox-prev,
.lightbox-next {
    top: 50%; transform: translateY(-50%);
    font-size: 3em; padding: 10px 15px;
}
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

/* --- [8] Admin & UCP Management --- */
.user-management-list {
    display: flex; flex-direction: column; gap: 10px;
}
.user-row {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(255,255,255,0.3); padding: 10px;
    border: 1px inset var(--shadow); flex-wrap: wrap; 
}
.user-info {
    line-height: 1.4; margin-right: 10px;
}
.user-info small {
    color: #333;
}
.user-actions {
    display: flex; gap: 10px; align-items: center;
    flex-wrap: wrap; 
}
.admin-form {
    display: inline-block; margin: 0;
}
.current-admin-tag {
    font-weight: bold;
    color: var(--title-bar-color); 
    padding: 5px 10px;
    background: var(--highlight); 
    border: 1px outset var(--highlight); 
}
.facet-manage-list {
    display: flex; flex-direction: column; gap: 10px;
}
.facet-row {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(255,255,255,0.3); padding: 10px;
    border: 1px inset var(--shadow); gap: 15px;
}
.facet-info {
    line-height: 1.4; flex-grow: 1; 
}
.facet-info p {
    margin: 0;
}
.manage-thumbnail {
    width: 80px; height: 80px; object-fit: cover;
    border: 2px outset var(--highlight); 
}
.button-link {
    background: var(--window-bg); 
    border: 2px outset var(--highlight); 
    padding: 5px 15px; cursor: pointer;
    text-decoration: none;
    color: var(--text-color); 
    white-space: nowrap; 
}
.button-link:hover {
    text-decoration: none;
}
.button-link:active {
    border-style: inset;
}
.edit-image-layout {
    display: flex; gap: 20px; flex-wrap: wrap; 
}
.edit-image-preview {
    flex-basis: 300px; flex-grow: 1;
}
.edit-image-preview img {
    width: 100%;
    border: 2px outset var(--highlight); 
}
.edit-image-form {
    flex-basis: 300px; flex-grow: 2;
}

/* --- [9] New Styles --- */
.clipboard-button {
    background: var(--window-bg);
    border: 2px outset var(--highlight);
    padding: 2px 8px;
    font-size: 0.9em;
    cursor: pointer;
    margin-left: 10px;
}
.clipboard-button:active {
    border-style: inset;
}
.hit-counter {
    font-size: 0.9em;
    color: var(--text-color);
    opacity: 0.7;
    margin-top: 10px;
}
.grid-item .hit-counter {
    font-size: 0.8em;
    padding: 0 8px 5px 8px;
    margin: 0;
    background: var(--window-bg);
}
.ucp-invites-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}
.ucp-invites-header h3 {
    margin: 0;
}
.topic-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}
.topic-details {
    flex-grow: 1;
}
.topic-follow-action {
    flex-shrink: 0;
    margin-top: 10px;
}
.lightbox-content img {
    cursor: pointer;
}
.image-page-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.topics-feed-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
}
.topic-list-item {
    display: flex;
    gap: 15px;
    border: 2px outset var(--highlight);
    background: rgba(255,255,255,0.3);
    padding: 10px;
    margin-bottom: 10px;
}
.topic-thumbnail {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border: 2px inset var(--shadow);
    background: var(--shadow);
    flex-shrink: 0;
}
.topic-list-details {
    flex-grow: 1;
}
.topic-list-details h3 {
    margin: 0 0 5px 0;
}
.topic-list-details h3 a {
    text-decoration: none;
    font-size: 1.2em;
}
.topic-list-stats {
    font-size: 0.9em;
    opacity: 0.8;
}
.topic-creator {
    font-size: 0.9em;
    margin-top: 10px;
    opacity: 0.8;
}
.topic-creator a {
    font-weight: bold;
}
.topic-voting {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    margin-left: 10px;
}
.vote-button {
    background: var(--window-bg);
    border: 2px outset var(--highlight);
    padding: 4px 8px;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
    width: 40px;
}
.vote-button:active {
    border-style: inset;
}
.vote-button.voted {
    border-style: inset;
    background: var(--shadow);
}
.vote-score {
    font-weight: bold;
    font-size: 1.2em;
}
.search-form {
    display: flex;
    margin: 0 0 0 15px;
}
.search-input {
    border: 2px inset var(--shadow);
    padding: 5px;
    font-size: 0.9em;
    border-right: 1px solid var(--shadow); 
}
.search-button {
    border: 2px outset var(--highlight);
    background: var(--window-bg);
    cursor: pointer;
    font-size: 0.9em;
    padding: 5px 10px;
    border-left: none; 
}
.search-button:active {
    border-style: inset;
}
.guest-theme-form {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0;
    margin-right: 15px;
}
.guest-theme-form label {
    margin-right: 5px;
    font-size: 0.9em;
    font-weight: bold;
    color: var(--text-color);
}
.guest-theme-form select {
    font-size: 0.9em;
    padding: 2px;
}
.nav-button.hidden {
    display: none;
}

/* --- Vote Controls for Images --- */
.vote-controls {
    display: flex;
    gap: 5px;
    padding: 5px 8px;
    background: var(--window-bg);
    border-top: 1px solid var(--shadow);
    justify-content: center;
}
.vote-controls .vote-button {
    background: var(--window-bg);
    border: 2px outset var(--highlight);
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.9em;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.vote-controls .vote-button:active {
    border-style: inset;
}
.vote-controls .vote-button.voted {
    border-style: inset;
    background: var(--shadow);
}
.vote-controls .vote-count {
    font-weight: bold;
}

/* MOBILE FLYOUT STYLES */
.mobile-icon-bar {
    display: none; /* Hidden on desktop */
}
#mobile-flyout {
    display: none; 
    position: fixed;
    top: 54px; 
    left: 0;
    width: 100%;
    height: calc(100vh - 54px);
    background: var(--window-bg);
    border-top: 2px outset var(--highlight); 
    z-index: 999;
    padding: 20px;
    overflow-y: auto;
}
#mobile-flyout.active {
    display: block;
}
.flyout-search-form {
    display: flex;
    margin-bottom: 20px;
}
.flyout-search-form .search-input { flex-grow: 1; }
.flyout-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.flyout-link {
    display: block;
    background: var(--window-bg);
    border: 2px outset var(--highlight);
    padding: 12px 15px;
    text-decoration: none;
    font-size: 1.2em;
    font-weight: bold;
    color: var(--text-color);
}
.flyout-link span {
    display: inline-block;
    width: 30px;
    text-align: center;
    margin-right: 10px;
}
.flyout-link:active {
    border-style: inset;
}
.flyout-user-menu {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px inset var(--shadow);
}


/* --- [10] Mobile Responsive (FIXED) --- */

@media (max-width: 850px) {
    body {
        padding-top: 0; /* Remove top padding */
        padding-bottom: 54px; /* Add padding for bottom nav */
    }

    .main-nav {
        top: auto; /* Unset top */
        bottom: 0; /* Stick to bottom */
        border-bottom: none;
        border-top: 2px outset var(--highlight);
    }
    
    .nav-hidden {
        transform: translateY(100%); /* Hide by sliding down */
    }

    /* Hide desktop nav wrapper */
    .desktop-nav-wrap {
        display: none;
    }
    
    /* Show mobile icon bar */
    .mobile-icon-bar {
        display: flex;
        align-items: center;
        gap: 0; 
    }
    .mobile-icon-bar .nav-button {
        border-left: none;
        flex-grow: 1; /* Make buttons share space */
    }
    .mobile-icon-bar .nav-button:first-child {
        border-left: 2px outset var(--highlight);
    }
    
    /* Reposition flyout for bottom bar */
    #mobile-flyout {
        top: auto;
        bottom: 54px; 
        height: calc(100vh - 54px);
        border-top: none;
        border-bottom: 2px outset var(--highlight);
    }
    
    /* Stack topic list items on mobile */
    .topic-list-item {
        flex-wrap: wrap;
    }
    .topic-voting {
        flex-direction: row; 
        width: 100%;
        justify-content: center;
        order: 3; 
        margin-left: 0;
        margin-top: 10px;
    }
    
    .edit-image-layout {
        flex-direction: column; 
    }
}
