/**
 * Portfolio Manager - Frontend Styles
 * Uses CSS custom properties injected from plugin settings (--pm-primary,
 * --pm-accent, --pm-radius, --pm-font) so admins can theme the grid without
 * touching CSS.
 */

.pm-portfolio-manager {
    --pm-primary: #4f46e5;
    --pm-accent: #f59e0b;
    --pm-radius: 12px;
    --pm-font: system-ui, -apple-system, sans-serif;
    font-family: var(--pm-font);
    color: #1f2937;
    line-height: 1.6;
}

/* Reset so the plugin renders consistently no matter what the active theme
   does to headings, lists, images and box-sizing globally. Scoped to this
   wrapper only so it never leaks into the rest of the theme. */
.pm-portfolio-manager,
.pm-portfolio-manager *,
.pm-portfolio-manager *::before,
.pm-portfolio-manager *::after {
    box-sizing: border-box;
}

.pm-portfolio-manager img {
    max-width: 100%;
    height: auto;
}

.pm-portfolio-manager h1,
.pm-portfolio-manager h2,
.pm-portfolio-manager h3 {
    line-height: 1.25;
    font-family: var(--pm-font);
}

.pm-portfolio-manager a {
    transition: color 0.15s ease;
}

.pm-search-bar {
    margin-bottom: 24px;
    position: relative;
}

.pm-search-bar::before {
    content: "";
    position: absolute;
    left: 16px;
    top: 50%;
    width: 16px;
    height: 16px;
    transform: translateY(-50%);
    background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    pointer-events: none;
}

.pm-search-input {
    width: 100%;
    max-width: 460px;
    padding: 13px 16px 13px 42px;
    border: 1.5px solid #e5e7eb;
    border-radius: var(--pm-radius);
    font-size: 15px;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pm-search-input:focus {
    outline: none;
    border-color: var(--pm-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.pm-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 32px;
    align-items: start;
}

.pm-layout-grid .pm-sidebar-filter {
    position: sticky;
    top: 24px;
}

/* Sidebar filter */
.pm-sidebar-filter {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: var(--pm-radius);
    padding: 22px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.pm-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #f0f1f3;
}

.pm-filter-header h3 {
    margin: 0;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pm-filter-header h3::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3'/%3E%3C/svg%3E");
}

.pm-clear-filters {
    background: none;
    border: none;
    color: var(--pm-primary);
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.pm-clear-filters:hover {
    background: #eef2ff;
}

.pm-selected-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.pm-selected-chips:not(:empty) {
    margin-bottom: 16px;
}

.pm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--pm-primary);
    color: #fff;
    padding: 5px 6px 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.pm-chip button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.pm-chip button:hover {
    background: rgba(255, 255, 255, 0.4);
}

.pm-filter-group {
    border-bottom: 1px solid #f0f1f3;
    padding: 12px 0;
}

.pm-filter-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.pm-filter-accordion-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: none;
    border: none;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    padding: 4px 0;
    color: #1f2937;
}

.pm-filter-group.is-collapsed .pm-filter-accordion-panel {
    display: none;
}

.pm-filter-group.is-collapsed .pm-accordion-icon {
    transform: rotate(180deg);
}

.pm-accordion-icon {
    display: inline-flex;
    transition: transform 0.2s ease;
    color: #9ca3af;
    font-size: 11px;
}

.pm-filter-accordion-panel {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
}

.pm-filter-checkbox {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.12s ease;
}

.pm-filter-checkbox:hover {
    background: #f9fafb;
}

.pm-filter-checkbox input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--pm-primary);
    flex-shrink: 0;
}

.pm-filter-checkbox span {
    flex: 1;
}

.pm-filter-checkbox em {
    color: #9ca3af;
    font-style: normal;
    font-size: 12px;
}

/* Toolbar */
.pm-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    font-size: 13px;
    color: #6b7280;
}

.pm-project-counter {
    display: inline-flex;
    align-items: center;
    background: #f9fafb;
    border: 1px solid #f0f1f3;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 600;
    color: #374151;
}

/* Grid */
.pm-grid-wrapper {
    position: relative;
}

.pm-grid {
    display: grid;
    grid-template-columns: repeat(var(--pm-columns, 4), 1fr);
    gap: 24px;
}

@media (max-width: 1024px) {
    .pm-layout {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 640px) {
    .pm-grid {
        grid-template-columns: 1fr;
    }
}

/* Skeleton loader */
.pm-skeleton-loader {
    display: grid;
    grid-template-columns: repeat(var(--pm-columns, 4), 1fr);
    gap: 24px;
    position: absolute;
    inset: 0;
}

.pm-skeleton-card {
    border-radius: var(--pm-radius);
    background: linear-gradient(90deg, #eee 25%, #f5f5f5 37%, #eee 63%);
    background-size: 400% 100%;
    animation: pm-skeleton-loading 1.4s ease infinite;
    aspect-ratio: 4 / 3;
}

@keyframes pm-skeleton-loading {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

.pm-grid.is-loading {
    opacity: 0.35;
    pointer-events: none;
}

/* Card */
.pm-card {
    border-radius: var(--pm-radius);
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.pm-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

.pm-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.pm-card-media {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #f3f4f6;
}

.pm-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.pm-card:hover .pm-card-image {
    transform: scale(1.06);
}

.pm-card-placeholder {
    width: 100%;
    height: 100%;
    background: #e5e7eb;
}

.pm-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent 60%);
    opacity: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 14px;
    transition: opacity 0.25s ease;
}

.pm-card:hover .pm-card-overlay {
    opacity: 1;
}

.pm-card-arrow {
    color: #fff;
    background: var(--pm-primary);
    border-radius: 999px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.pm-card-body {
    padding: 14px 16px;
}

.pm-card-title {
    margin: 0 0 4px;
    font-size: 16px;
}

.pm-card-category {
    font-size: 12px;
    color: var(--pm-accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pm-card-excerpt {
    margin: 8px 0 0;
    font-size: 13px;
    color: #6b7280;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pm-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.pm-pagination {
    text-align: center;
    margin-top: 32px;
}

/* ==========================================================================
   Single project ("case study") page
   ========================================================================== */

.pm-single-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 0 56px;
}

.pm-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 28px;
    font-size: 13px;
    color: #9ca3af;
}

.pm-breadcrumbs a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--pm-primary);
    text-decoration: none;
    font-weight: 600;
}

.pm-breadcrumbs a:hover {
    text-decoration: underline;
}

.pm-breadcrumb-sep {
    color: #d1d5db;
}

/* ---- Hero ---- */
.pm-hero {
    display: grid;
    gap: 40px;
    margin-bottom: 36px;
    align-items: center;
}

@media (min-width: 800px) {
    .pm-hero {
        grid-template-columns: 1.05fr 1fr;
    }

    .pm-hero--no-media {
        grid-template-columns: 1fr;
        max-width: 760px;
    }
}

.pm-hero-media {
    position: relative;
    border-radius: calc(var(--pm-radius) + 4px);
    overflow: hidden;
    box-shadow: 0 20px 45px -12px rgba(16, 24, 40, 0.25);
}

.pm-hero-media img {
    width: 100%;
    display: block;
}

.pm-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 16px;
    background: #eef2ff;
    color: var(--pm-primary);
}

.pm-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.pm-status-badge--ongoing {
    background: #fef3c7;
    color: #92400e;
}

.pm-status-badge--maintained {
    background: #dcfce7;
    color: #166534;
}

.pm-hero-title {
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.12;
    margin: 0 0 14px;
    letter-spacing: -0.01em;
}

.pm-hero-lede {
    font-size: 17px;
    line-height: 1.6;
    color: #4b5563;
    margin: 0 0 20px;
    max-width: 52ch;
}

.pm-tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.pm-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f9fafb;
    border: 1px solid #eef0f2;
    color: #4b5563;
    font-size: 12.5px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 999px;
}

.pm-tag svg {
    width: 12px;
    height: 12px;
    color: var(--pm-accent);
    flex-shrink: 0;
}

.pm-hero-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.pm-visit-website {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: var(--pm-primary);
    color: #fff !important;
    padding: 13px 26px;
    border-radius: var(--pm-radius);
    text-decoration: none;
    font-weight: 600;
    font-size: 14.5px;
    box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.5);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pm-visit-website svg {
    width: 16px;
    height: 16px;
}

.pm-visit-website:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px -6px rgba(79, 70, 229, 0.55);
}

.pm-share-links {
    display: flex;
    gap: 8px;
}

.pm-share-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #f3f4f6;
    color: #4b5563 !important;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.pm-share-links a:hover {
    background: var(--pm-primary);
    color: #fff !important;
    transform: translateY(-2px);
}

/* ---- Quick-fact strip ---- */
.pm-fact-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1px;
    background: #eef0f2;
    border: 1px solid #eef0f2;
    border-radius: var(--pm-radius);
    overflow: hidden;
    margin-bottom: 40px;
}

.pm-fact {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    padding: 18px 22px;
}

.pm-fact-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #eef2ff;
    color: var(--pm-primary);
    flex-shrink: 0;
}

.pm-fact-icon svg {
    width: 18px;
    height: 18px;
}

.pm-fact-label {
    display: block;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9ca3af;
    font-weight: 600;
}

.pm-fact-value {
    display: block;
    font-size: 14.5px;
    font-weight: 700;
    color: #1f2937;
    margin-top: 2px;
}

/* ---- Body ---- */
.pm-single-body {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 48px;
    align-items: start;
}

@media (max-width: 900px) {
    .pm-single-body {
        grid-template-columns: 1fr;
    }
}

.pm-full-description {
    font-size: 16px;
    line-height: 1.75;
    color: #374151;
}

.pm-full-description p {
    margin: 0 0 18px;
}

.pm-section-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 18px;
    padding-left: 14px;
    border-left: 4px solid var(--pm-accent);
}

.pm-screenshot-section,
.pm-gallery-section {
    margin-top: 44px;
}

/* Browser-chrome frame around the full-page screenshot */
.pm-browser-frame {
    border-radius: var(--pm-radius);
    overflow: hidden;
    border: 1px solid #e5e7eb;
    box-shadow: 0 16px 40px -16px rgba(16, 24, 40, 0.2);
}

.pm-browser-chrome {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f3f4f6;
    padding: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
}

.pm-browser-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pm-browser-dot--red { background: #f87171; }
.pm-browser-dot--yellow { background: #fbbf24; }
.pm-browser-dot--green { background: #34d399; }

.pm-browser-url {
    margin-left: 10px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 3px 12px;
    font-size: 12px;
    color: #6b7280;
    flex: 1;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pm-screenshot-scroll {
    max-height: 640px;
    overflow-y: auto;
    scroll-behavior: smooth;
    cursor: zoom-in;
    background: #fff;
}

.pm-screenshot-image {
    width: 100%;
    display: block;
}

.pm-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.pm-gallery-item-btn {
    position: relative;
    display: block;
    padding: 0;
    border: none;
    background: none;
    border-radius: var(--pm-radius);
    overflow: hidden;
    cursor: zoom-in;
    aspect-ratio: 4 / 3;
}

.pm-gallery-slide {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.pm-gallery-item-btn:hover .pm-gallery-slide {
    transform: scale(1.06);
}

.pm-gallery-zoom {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(17, 24, 39, 0.35);
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.pm-gallery-item-btn:hover .pm-gallery-zoom {
    opacity: 1;
}

/* ---- Sidebar ---- */
.pm-sticky-sidebar {
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pm-info-box,
.pm-related-box {
    background: #f9fafb;
    border: 1px solid #f0f1f3;
    border-radius: var(--pm-radius);
    padding: 22px;
}

.pm-info-box h3,
.pm-related-box h3 {
    margin: 0 0 16px;
    font-size: 14.5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
}

.pm-info-list {
    margin: 0 0 18px;
}

.pm-info-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13.5px;
}

.pm-info-list div:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.pm-info-list dt {
    color: #6b7280;
}

.pm-info-list dd {
    margin: 0;
    font-weight: 700;
    text-align: right;
    color: #1f2937;
}

.pm-info-box-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: var(--pm-primary);
    color: #fff !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    padding: 12px 16px;
    border-radius: var(--pm-radius);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pm-info-box-cta svg {
    width: 15px;
    height: 15px;
}

.pm-info-box-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px -6px rgba(79, 70, 229, 0.5);
}

.pm-related-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    text-decoration: none;
    color: inherit;
    font-size: 13.5px;
    font-weight: 600;
}

.pm-related-item:last-child {
    margin-bottom: 0;
}

.pm-related-item img,
.pm-related-item-placeholder {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.pm-related-item-placeholder {
    display: block;
    background: #e5e7eb;
}

/* ---- Prev/next nav ---- */
.pm-prev-next-nav {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 48px;
    border-top: 1px solid #e5e7eb;
    padding-top: 28px;
}

.pm-prev-next-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #1f2937;
    font-weight: 600;
    font-size: 14px;
    max-width: 45%;
}

.pm-prev-next-nav a svg {
    flex-shrink: 0;
    color: var(--pm-primary);
}

.pm-prev-next-nav a span {
    display: flex;
    flex-direction: column;
}

.pm-nav-next {
    margin-left: auto;
    text-align: right;
}

.pm-nav-next span {
    align-items: flex-end;
}

.pm-prev-next-nav a small {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #9ca3af;
    margin-bottom: 2px;
}

.pm-prev-next-nav a:hover {
    color: var(--pm-primary);
}
