/*
Theme Name: MTHR Theme
Theme URI: https://example.com/mthr-theme
Description: Mexican Train House Rules - western/country/southwestern aesthetic, warm earthy palette, responsive card-based layout. No sidebar. Requires mthr-core plugin.
Version: 0.3.0
Author: MTHR
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: mthr-theme
*/

/* ==========================================================================
   Base - warm earthy, clean typography
   ========================================================================== */

* {
    box-sizing: border-box;
}

.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

body {
    margin: 0;
    font-family: var(--mthr-font-body);
    font-size: 16px;
    line-height: 1.6;
    background-color: var(--mthr-bg);
    color: var(--mthr-text);
}

a {
    color: var(--mthr-accent);
    text-decoration: none;
    transition: color var(--mthr-transition);
}

a:hover {
    color: var(--mthr-accent-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   Layout - no sidebar, full-width
   ========================================================================== */

.site-main {
    min-height: 50vh;
}

.site-footer {
    margin-top: var(--mthr-space-2xl);
    padding: var(--mthr-space-xl);
    background: var(--mthr-bg-footer);
    color: var(--mthr-nav-link);
    text-align: center;
}

.site-footer a {
    color: var(--mthr-nav-link);
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
    background: var(--mthr-bg-header);
    color: #f5f0e8;
    padding: var(--mthr-space-md) clamp(var(--mthr-space-md), 4vw, var(--mthr-space-xl));
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--mthr-space-sm);
}

.site-header a {
    color: var(--mthr-nav-link);
}

.site-header a:hover {
    color: var(--mthr-nav-link-hover);
}

.site-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.site-logo {
    max-height: 48px;
    width: auto;
}

.mthr-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--mthr-space-sm) var(--mthr-space-md);
}

.mthr-nav a {
    white-space: nowrap;
}

.mthr-my-house-link {
    font-weight: 600;
}

/* ==========================================================================
   Hero (homepage)
   ========================================================================== */

.mthr-hero {
    min-height: 180px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--mthr-tan);
}

@media (min-width: 768px) {
    .mthr-hero {
        min-height: 240px;
    }
}

/* ==========================================================================
   Home - Toolbar (search, sort), House card grid
   ========================================================================== */

.mthr-house-cards-wrapper {
    padding-top: 0;
}

.mthr-houses-toolbar {
    padding: var(--mthr-space-md) clamp(var(--mthr-space-md), 4vw, var(--mthr-space-xl));
    display: flex;
    flex-wrap: wrap;
    gap: var(--mthr-space-md);
    align-items: center;
    border-bottom: 1px solid var(--mthr-border);
}

.mthr-search-houses {
    display: flex;
    flex-wrap: wrap;
    gap: var(--mthr-space-sm);
    align-items: center;
}

.mthr-search-houses input[type="search"] {
    padding: var(--mthr-space-sm) var(--mthr-space-md);
    border: 1px solid var(--mthr-border);
    border-radius: var(--mthr-radius-sm);
    min-width: 180px;
}

.mthr-search-submit {
    padding: var(--mthr-space-sm) var(--mthr-space-md);
    background: var(--mthr-accent);
    color: #fff;
    border: none;
    border-radius: var(--mthr-radius-sm);
    cursor: pointer;
}

.mthr-search-submit:hover {
    background: var(--mthr-accent-hover);
}

.mthr-sort-houses {
    display: flex;
    flex-wrap: wrap;
    gap: var(--mthr-space-sm);
    align-items: center;
}

.mthr-sort-label {
    font-size: 0.9rem;
    color: var(--mthr-text-muted);
}

.mthr-sort-link {
    font-size: 0.9rem;
}

.mthr-sort-link.is-active {
    font-weight: 600;
}

.mthr-no-houses {
    padding: var(--mthr-space-2xl);
    text-align: center;
    color: var(--mthr-text-muted);
}

.mthr-house-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--mthr-space-lg);
    padding: clamp(var(--mthr-space-md), 4vw, var(--mthr-space-xl));
}

.mthr-house-card {
    background: var(--mthr-bg-card);
    border-radius: var(--mthr-radius-md);
    overflow: hidden;
    box-shadow: 0 2px 8px var(--mthr-shadow);
    transition: box-shadow var(--mthr-transition), transform var(--mthr-transition);
}

.mthr-house-card:hover {
    box-shadow: 0 4px 20px var(--mthr-shadow-hover);
    transform: translateY(-2px);
}

.mthr-house-card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--mthr-sand);
}

.mthr-house-card-content {
    padding: var(--mthr-space-md);
}

.mthr-house-card h2 {
    margin: 0 0 var(--mthr-space-sm);
    font-size: 1.2rem;
    font-weight: 600;
}

.mthr-house-card h2 a {
    color: var(--mthr-text);
}

.mthr-house-card h2 a:hover {
    color: var(--mthr-accent);
}

.mthr-house-card .mthr-excerpt {
    font-size: 0.9rem;
    color: var(--mthr-text-muted);
    margin: 0;
    line-height: 1.5;
}

.mthr-house-card-image-placeholder {
    height: 180px;
    background: var(--mthr-sand);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mthr-text-muted);
}

.mthr-house-card-updated,
.mthr-house-updated {
    font-size: 0.8rem;
    color: var(--mthr-text-muted);
    margin: var(--mthr-space-xs) 0;
}

.mthr-house-card-updated .mthr-updated-on,
.mthr-house-card-updated .mthr-updated-by,
.mthr-house-updated .mthr-updated-on,
.mthr-house-updated .mthr-updated-by {
    margin-right: 0.25em;
}

.mthr-house-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--mthr-space-md);
    margin-top: var(--mthr-space-sm);
}

.mthr-view-link,
.mthr-edit-link {
    font-size: 0.9rem;
}

.mthr-edit-link {
    font-weight: 500;
}

.mthr-card-editable .mthr-view-only-badge,
.mthr-card-view-only .mthr-edit-link {
    display: none;
}

/* ==========================================================================
   Single house
   ========================================================================== */

.mthr-single-house .site-main {
    max-width: 720px;
    margin: 0 auto;
    padding: clamp(var(--mthr-space-md), 4vw, var(--mthr-space-xl));
}

.mthr-house-header {
    margin-bottom: var(--mthr-space-xl);
}

.mthr-house-header h1 {
    margin: 0 0 var(--mthr-space-sm);
    font-weight: 600;
}

.mthr-house-header .mthr-house-updated {
    margin: 0 0 var(--mthr-space-sm);
}

.mthr-house-featured {
    margin-bottom: var(--mthr-space-xl);
}

.mthr-house-featured img {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    border-radius: var(--mthr-radius-sm);
}

.mthr-section-nav {
    position: sticky;
    top: 0;
    background: var(--mthr-bg);
    padding: var(--mthr-space-sm) 0;
    margin-bottom: var(--mthr-space-xl);
    border-bottom: 1px solid var(--mthr-border);
    z-index: 10;
}

.mthr-section-nav-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--mthr-space-sm) var(--mthr-space-md);
    margin: 0;
    padding: 0;
    list-style: none;
}

.mthr-section-nav a {
    font-size: 0.9rem;
}

.mthr-section {
    margin-bottom: var(--mthr-space-2xl);
    padding-top: var(--mthr-space-md);
}

.mthr-section[id] {
    scroll-margin-top: 5rem;
}

.mthr-section h3 {
    margin: 0 0 var(--mthr-space-sm);
    padding-bottom: var(--mthr-space-xs);
    border-bottom: 2px solid var(--mthr-border-accent);
    font-size: 1.1rem;
    font-weight: 600;
}

.mthr-section h4 {
    margin: var(--mthr-space-md) 0 var(--mthr-space-sm);
    font-size: 1rem;
    font-weight: 600;
}

/* Rules, photos, announcements, notes */
.mthr-rule-item,
.mthr-announcement-item,
.mthr-note-item {
    margin-bottom: var(--mthr-space-lg);
}

.mthr-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--mthr-space-md);
}

.mthr-photo-item img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--mthr-radius-sm);
}

.mthr-photo-expand {
    display: block;
    width: 100%;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: zoom-in;
    border-radius: var(--mthr-radius-sm);
    text-align: left;
}

.mthr-photo-expand:focus {
    outline: 2px solid var(--mthr-accent, #2271b1);
    outline-offset: 2px;
}

.mthr-photo-placeholder {
    min-height: 150px;
    background: var(--mthr-border-subtle, #ddd);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mthr-text-muted, #666);
    border-radius: var(--mthr-radius-sm);
    font-size: 0.9rem;
}

/* Photo lightbox (single house) */
html.mthr-photo-lightbox-open {
    overflow: hidden;
}

.mthr-photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--mthr-space-md);
    box-sizing: border-box;
}

.mthr-photo-lightbox[hidden] {
    display: none !important;
}

.mthr-photo-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    cursor: pointer;
}

.mthr-photo-lightbox-inner {
    position: relative;
    z-index: 1;
    max-width: min(96vw, 1200px);
    max-height: 92vh;
    margin: 0;
}

.mthr-photo-lightbox-inner img {
    display: block;
    max-width: 100%;
    max-height: 92vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--mthr-radius-sm);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.mthr-photo-lightbox-close {
    position: absolute;
    top: -2.5rem;
    right: 0;
    padding: 0.35rem 0.65rem;
    font-size: 1.5rem;
    line-height: 1;
    color: #fff;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: var(--mthr-radius-sm);
}

.mthr-photo-lightbox-close:hover,
.mthr-photo-lightbox-close:focus {
    background: rgba(255, 255, 255, 0.15);
}

@media (min-width: 600px) {
    .mthr-photo-lightbox-close {
        top: 0;
        right: -3rem;
    }
}

.mthr-members ul {
    margin: 0;
    padding-left: 1.25rem;
}

/* ==========================================================================
   Edit UI & view-only cues
   ========================================================================== */

body.mthr-view-only .mthr-edit-trigger,
body.mthr-view-only .mthr-add-trigger,
body.mthr-view-only .mthr-featured-image-trigger,
body.mthr-view-only .mthr-delete-trigger {
    display: none !important;
}

body.mthr-view-only .mthr-view-only-badge {
    display: inline;
}

body.mthr-can-edit .mthr-view-only-badge {
    display: none;
}

.mthr-view-only-badge {
    display: none;
    font-size: 0.85em;
    color: var(--mthr-text-muted);
    margin-left: var(--mthr-space-sm);
}

.mthr-edit-trigger,
.mthr-add-trigger,
.mthr-featured-image-trigger {
    font-size: 0.85rem;
    padding: var(--mthr-space-xs) var(--mthr-space-sm);
    margin-left: var(--mthr-space-sm);
    cursor: pointer;
}

.mthr-delete-trigger {
    color: #c00;
    font-size: 0.85rem;
    cursor: pointer;
}

.mthr-editable-content {
    min-height: 1em;
}

/* ==========================================================================
   Profile page
   ========================================================================== */

.mthr-profile .site-main {
    max-width: 560px;
    margin: 0 auto;
    padding: clamp(var(--mthr-space-md), 4vw, var(--mthr-space-xl));
}

.mthr-profile-card {
    background: var(--mthr-bg-card);
    border-radius: var(--mthr-radius-md);
    padding: var(--mthr-space-lg);
    box-shadow: 0 2px 8px var(--mthr-shadow);
}

.mthr-profile-card h2 {
    margin-top: 0;
}

.mthr-profile-message {
    padding: var(--mthr-space-md);
    margin-bottom: var(--mthr-space-lg);
    border-radius: var(--mthr-radius-sm);
}

.mthr-profile-message-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.mthr-profile-message-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.mthr-profile-form .mthr-profile-field,
.mthr-profile-photo-section,
.mthr-profile-password-section {
    margin-bottom: var(--mthr-space-lg);
}

.mthr-profile-form label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--mthr-space-xs);
}

.mthr-profile-form input[type="text"],
.mthr-profile-form input[type="password"],
.mthr-profile-form input[type="file"],
.mthr-profile-form textarea {
    width: 100%;
    max-width: 400px;
    padding: var(--mthr-space-sm);
    border: 1px solid var(--mthr-border);
    border-radius: var(--mthr-radius-sm);
}

.mthr-profile-form textarea {
    resize: vertical;
}

.mthr-profile-field-readonly p {
    margin: 0;
    color: var(--mthr-text-muted);
}

.mthr-profile-field-help {
    font-size: 0.85rem;
    color: var(--mthr-text-muted);
    margin: var(--mthr-space-xs) 0 0 !important;
}

.mthr-profile-photo-preview {
    margin-bottom: var(--mthr-space-sm);
}

.mthr-profile-photo-img {
    border-radius: 50%;
    width: 96px;
    height: 96px;
    object-fit: cover;
}

.mthr-profile-photo-placeholder .mthr-profile-avatar {
    border-radius: 50%;
}

.mthr-profile-remove-photo {
    display: block;
    margin-top: var(--mthr-space-sm);
    font-size: 0.9rem;
}

.mthr-profile-password-section h3 {
    margin: 0 0 var(--mthr-space-sm);
    font-size: 1rem;
}

.mthr-profile-submit {
    margin-top: var(--mthr-space-xl);
}

.mthr-profile-save {
    padding: var(--mthr-space-sm) var(--mthr-space-lg);
    background: var(--mthr-accent);
    color: #fff;
    border: none;
    border-radius: var(--mthr-radius-sm);
    cursor: pointer;
}

.mthr-profile-save:hover {
    background: var(--mthr-accent-hover);
}

/* ==========================================================================
   Responsive - mobile-friendly
   ========================================================================== */

@media (max-width: 480px) {
    .mthr-house-cards {
        grid-template-columns: 1fr;
        padding: var(--mthr-space-md);
    }

    .mthr-photos-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mthr-house-card:hover {
        transform: none;
    }
}

@media (max-width: 360px) {
    .site-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
