/* logboxd - minimal dark brown theme */

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Variables */
:root {
    --bg: #1a1410;
    --surface: #2a2218;
    --border: #3d3228;
    --text: #f5f5f0;
    --text-muted: #a89888;
    --link: #d4a574;
    --link-hover: #e8c49a;
    --accent: #8b6f47;
    --accent-hover: #a07f52;
    --error: #c45a4a;
    --success: #5a8a5a;
    --spacing: 1rem;
    --radius: 3px;
}

/* Base */
html {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 0.5rem;
    font-weight: 600;
    line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }

p { margin-bottom: 0.75rem; }

a {
    color: var(--link);
    text-decoration: underline;
}

a:hover {
    color: var(--link-hover);
}

small {
    font-size: 0.85rem;
    color: var(--text-muted);
}

hgroup {
    margin-bottom: 1rem;
}

hgroup p {
    color: var(--text-muted);
    margin: 0;
}

/* Layout */
.container {
    width: 100%;
    padding: 0 var(--spacing);
}

main {
    flex: 1;
    padding: var(--spacing) 0;
}

/* Grid */
.grid {
    display: grid;
    gap: var(--spacing);
}

@media (min-width: 600px) {
    .grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

/* Navigation */
header {
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 1rem;
    align-items: center;
}

nav a {
    text-decoration: none;
}

nav a:hover {
    text-decoration: underline;
}

nav strong {
    font-size: 1.1rem;
    color: var(--text);
}

/* Footer */
footer {
    border-top: 1px solid var(--border);
    padding: 1rem 0;
    margin-top: 2rem;
    text-align: center;
}

/* Forms */
label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

input, select, textarea {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--link);
}

input::placeholder {
    color: var(--text-muted);
}

input[type="search"] {
    -webkit-appearance: none;
}

/* Buttons */
button, [type="submit"], [type="button"], .button {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: var(--text);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
}

button:hover, [type="submit"]:hover, [type="button"]:hover, .button:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

button.outline, .button.outline {
    background: transparent;
    border-color: var(--border);
}

button.outline:hover, .button.outline:hover {
    border-color: var(--text-muted);
}

button.secondary, .button.secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}

button.secondary:hover, .button.secondary:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

button.small, [type="submit"].small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Article / Card */
article {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--spacing);
    margin-bottom: var(--spacing);
}

/* Details / Summary */
details {
    margin-bottom: var(--spacing);
}

summary {
    cursor: pointer;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    list-style: none;
}

summary::-webkit-details-marker {
    display: none;
}

summary::before {
    content: "+ ";
}

details[open] summary::before {
    content: "- ";
}

summary:hover {
    border-color: var(--text-muted);
}

summary[role="button"] {
    display: inline-block;
}

/* Tab Navigation */
nav ul li a[aria-current="page"] {
    color: var(--text);
    font-weight: 600;
}

/* Error */
.error {
    color: var(--error);
}

/* Search Results */
.search-results {
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Only add scroll when not in modal */
details .search-results {
    max-height: 300px;
    overflow-y: auto;
}

.search-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.search-result:last-child {
    border-bottom: none;
}

.result-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.result-poster {
    width: 40px;
    height: 60px;
    object-fit: cover;
    flex-shrink: 0;
}

.result-info {
    min-width: 0;
}

.result-info strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin: 0;
    flex-shrink: 0;
}

.search-result select {
    margin: 0;
    width: auto;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.search-result button {
    margin: 0;
    width: auto;
}

/* Media Grid */
.media-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.media-card {
    text-align: center;
    padding: 0.5rem;
}

.media-card a {
    color: var(--text);
    text-decoration: none;
}

.media-card a:hover {
    text-decoration: underline;
}

.media-poster {
    width: 100%;
    max-width: 100px;
    height: auto;
    margin-bottom: 0.5rem;
}

.media-title {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.media-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.media-actions {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    flex-wrap: wrap;
}

.media-actions button {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
}

/* Link Cards */
.link-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.link-image {
    width: 80px;
    height: 60px;
    object-fit: cover;
    flex-shrink: 0;
}

.link-info {
    flex: 1;
    min-width: 0;
}

.link-info a {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-info small {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Activity Feed */
.activity-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.activity-content {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.activity-image {
    width: 50px;
    height: 75px;
    object-fit: cover;
    flex-shrink: 0;
}

.activity-info {
    flex: 1;
    min-width: 0;
}

.activity-info small {
    display: block;
    margin-top: 0.25rem;
}

/* Quiz */
.quiz-item {
    text-align: center;
}

.quiz-poster {
    max-width: 200px;
    max-height: 300px;
    margin: 0 auto 1rem;
}

.quiz-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Add Options */
.add-options {
    padding: 1rem 0;
}

.add-options h4 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.add-options h4:first-child {
    margin-top: 0;
}

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }

/* Images */
img {
    max-width: 100%;
    height: auto;
}

/* Onboarding quiz - left aligned */
.quiz-item {
    text-align: left;
}

.quiz-item img.quiz-poster {
    max-width: 200px;
    height: auto;
    margin: 0 0 1rem 0;
}

.quiz-item h2,
.quiz-item p {
    text-align: left;
}

.quiz-item .grid {
    justify-content: flex-start;
}

/* Landing */
.landing {
    padding: 4rem 0;
}

.landing h1 {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
}

.landing p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.landing-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.landing-actions a:not(.button) {
    color: var(--text-muted);
}

.landing-actions a:not(.button):hover {
    color: var(--text);
}

/* Avatar styles */
.nav-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 0.25rem;
}

.nav-avatar-placeholder {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    vertical-align: middle;
    margin-right: 0.25rem;
}

.user-link {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.profile-header {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.profile-nav {
    margin-bottom: 1.5rem;
}

.profile-add {
    margin-bottom: 1.5rem;
}

.profile-avatar-container {
    position: relative;
    flex-shrink: 0;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.profile-avatar-placeholder {
    background: var(--surface);
}

.avatar-upload-form {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
}

.avatar-upload-label {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    font-size: 0.65rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-muted);
}

.avatar-upload-label:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.avatar-upload-label input {
    display: none;
}

/* Nav Dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
}

.nav-dropdown-toggle:hover {
    background: transparent;
    border: none;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    min-width: 150px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-direction: column;
    padding: 0.25rem 0;
    z-index: 100;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: flex;
}

.nav-dropdown-menu li {
    padding: 0;
}

.nav-dropdown-menu li a,
.nav-dropdown-menu li button {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.9rem;
}

.nav-dropdown-menu li a:hover,
.nav-dropdown-menu li button:hover {
    background: var(--bg);
    text-decoration: none;
}

.nav-dropdown-menu form {
    margin: 0;
}

/* Add Modal - CSS-only with :target */
.add-modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.add-modal-backdrop:target {
    display: flex;
}

.add-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    margin: 0;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
}

.close-button {
    font-size: 1.5rem;
    padding: 0.25rem 0.5rem;
    color: var(--text-muted);
    line-height: 1;
    text-decoration: none;
}

.close-button:hover {
    color: var(--text);
}

/* Modal Tabs - CSS-only with radio buttons */
.modal-tabs {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.modal-tabs input[type="radio"] {
    display: none;
}

.tab-labels {
    display: flex;
    gap: 0;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
}

.tab-labels .tab {
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-labels .tab:hover {
    color: var(--text);
    border-bottom-color: var(--border);
}

/* Active tab styling */
#tab-radio-search:checked ~ .tab-labels label[for="tab-radio-search"],
#tab-radio-link:checked ~ .tab-labels label[for="tab-radio-link"] {
    color: var(--link);
    border-bottom-color: var(--link);
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

/* Show content based on checked radio */
#tab-radio-search:checked ~ .tab-content-search {
    display: block;
}

#tab-radio-link:checked ~ .tab-content-link {
    display: block;
}

/* HTMX Loading Indicator */
.htmx-indicator {
    display: none;
    padding: 0.5rem 0;
    color: var(--text-muted);
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: block;
}

/* Unified Results */
.result-section-header {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0.75rem 0 0.5rem;
}

.result-section-header:first-child {
    margin-top: 0;
}

.no-results {
    color: var(--text-muted);
    padding: 1rem 0;
}

/* Add Button */
.add-button {
    width: 100%;
    margin-bottom: var(--spacing);
}

/* Already added state */
.search-result.already-added {
    opacity: 0.6;
}

.added-label {
    color: var(--success);
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
}
