/* ===========================
   DOI Portal - Public Theme
   Style: Clean Academic
   Story 2.2: Public Publisher Page
   =========================== */

:root {
    --portal-primary: #1a365d;
    --portal-secondary: #3182ce;
    --portal-text: #1a202c;
    --portal-text-muted: #4a5568;
    --portal-bg: #ffffff;
    --portal-bg-secondary: #f7fafc;
    --portal-border: #e2e8f0;
}

/* ===========================
   Layout - Flex container for sticky footer
   =========================== */

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

.portal-content {
    flex: 1 0 auto;
}

.portal-footer {
    flex-shrink: 0;
}

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

.portal-header {
    border-bottom: 1px solid var(--portal-border);
}

.portal-header .navbar-brand {
    font-weight: 700;
    color: var(--portal-primary);
}

.portal-header .nav-link {
    color: var(--portal-text);
    font-weight: 500;
}

.portal-header .nav-link:hover,
.portal-header .nav-link.active {
    color: var(--portal-secondary);
}

/* ===========================
   Publisher Cards
   =========================== */

.publisher-card {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    border: 1px solid var(--portal-border);
}

.publisher-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.publisher-card .card-title a {
    color: var(--portal-primary);
    text-decoration: none;
}

.publisher-card .card-title a:hover {
    color: var(--portal-secondary);
}

.publisher-card .card-img-placeholder {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--portal-bg-secondary);
}

.publisher-card .card-img-top {
    height: 120px;
    object-fit: contain;
    padding: 1rem;
    background-color: var(--portal-bg-secondary);
}

/* ===========================
   Publisher Detail
   =========================== */

.publisher-detail-card .card-img-top {
    max-height: 200px;
    object-fit: contain;
    padding: 1.5rem;
    background-color: var(--portal-bg-secondary);
}

.publisher-info-list li {
    margin-bottom: 0.75rem;
}

.publisher-info-list a {
    color: var(--portal-secondary);
}

.publisher-info-list a:hover {
    color: var(--portal-primary);
}

/* ===========================
   Empty States
   =========================== */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state i {
    font-size: 4rem;
    color: var(--portal-text-muted);
    opacity: 0.5;
}

.empty-state p {
    color: var(--portal-text-muted);
    margin-top: 1rem;
}

/* ===========================
   Footer
   =========================== */

.portal-footer {
    background-color: var(--portal-primary) !important;
}

.portal-footer h5 {
    font-weight: 600;
}

/* ===========================
   Breadcrumbs
   =========================== */

.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
}

.breadcrumb-item a {
    color: var(--portal-secondary);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--portal-primary);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--portal-text-muted);
}

/* ===========================
   DOI Prefix Badge
   =========================== */

.doi-prefix-badge {
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875rem;
    color: var(--portal-text-muted);
}

/* ===========================
   Home Page - Hero Section (Story 4.1)
   =========================== */

.hero-section {
    background: linear-gradient(135deg, var(--portal-primary) 0%, var(--portal-secondary) 100%) !important;
}

.hero-section .form-control:focus {
    box-shadow: 0 0 0 0.25rem rgba(49, 130, 206, 0.25);
    border-color: var(--portal-secondary);
}

/* ===========================
   Home Page - Stat & Quick Link Cards (Story 4.1)
   =========================== */

.stat-card,
.publication-card,
.quick-link-card {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    border: 1px solid var(--portal-border);
}

.stat-card:hover,
.publication-card:hover,
.quick-link-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.stat-card:focus-within,
.publication-card:focus-within,
.quick-link-card:focus-within {
    outline: 2px solid var(--portal-secondary);
    outline-offset: 2px;
}

.publication-card .card-title a {
    color: var(--portal-primary);
}

.publication-card .card-title a:hover {
    color: var(--portal-secondary);
}

/* ===========================
   Search Results (Story 4.2)
   =========================== */

.search-results .card {
    transition: box-shadow 0.2s ease;
}

.search-results .card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.search-results .card-title a {
    color: var(--portal-primary);
}

.search-results .card-title a:hover {
    color: var(--portal-secondary);
}

mark {
    background-color: #fff3cd;
    padding: 0.1em 0.2em;
    border-radius: 2px;
}

/* ===========================
   Filter Sidebar (Story 4.3)
   =========================== */

.filter-sidebar .card-body {
    padding: 1.25rem;
}

.filter-sidebar fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.filter-sidebar legend {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.filter-sidebar .form-check {
    margin-bottom: 0.25rem;
}

.filter-sidebar .form-check-label {
    font-size: 0.875rem;
    color: var(--portal-text);
}

/* Active filter tags */
.filter-tag {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    padding: 0.35em 0.65em;
}

.filter-tag a {
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
}

.filter-tag a:hover {
    opacity: 0.7;
}

/* Year range inputs */
.filter-sidebar .row .form-control-sm {
    font-size: 0.875rem;
}

/* ===========================
   Responsive Adjustments
   =========================== */

@media (max-width: 767.98px) {
    .portal-content {
        padding-top: 1rem;
        /* Note: padding-bottom for mobile is handled by the floating-action-bar
           media query at 991.98px (5rem) on article pages. This rule only sets
           the non-article-page default. The 991.98px rule has cascade priority
           since it appears later in the file. */
        padding-bottom: 1rem;
    }

    .publisher-card .card-img-top,
    .publisher-card .card-img-placeholder {
        height: 100px;
    }

    .portal-footer .text-md-end {
        text-align: left !important;
        margin-top: 1rem;
    }

    /* Home page hero responsive (Story 4.1) */
    .hero-section {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .hero-section .input-group-lg .form-control,
    .hero-section .input-group-lg .btn {
        min-height: 48px;
    }

    /* Search results responsive (Story 4.2) */
    .search-results .card-body {
        padding: 0.75rem;
    }

    .search-results .btn,
    .search-results .page-link,
    .search-results .card-title a {
        min-height: 44px;
        min-width: 44px;
    }

    /* Filter offcanvas mobile (Story 4.3) */
    .offcanvas .filter-sidebar .card {
        border: none;
        box-shadow: none;
    }

    .offcanvas .filter-sidebar .card-body {
        padding: 0;
    }
}

/* ===========================
   Article Landing Page (Story 4.4)
   =========================== */

/* Article header */
.article-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--portal-primary);
    line-height: 1.3;
}

.article-subtitle {
    font-size: 1.15rem;
    line-height: 1.4;
}

/* Author list */
.article-authors .author-entry {
    padding: 0.25rem 0;
}

.article-authors .author-entry .fw-semibold {
    color: var(--portal-text);
}

/* ORCID icon link */
.orcid-link {
    color: #a6ce39;
    text-decoration: none;
    font-size: 0.875rem;
}

.orcid-link:hover {
    color: #82a82e;
    text-decoration: underline;
}

.orcid-link img {
    vertical-align: text-bottom;
}

/* Withdrawn banner */
.withdrawn-banner {
    border-left: 4px solid #dc3545;
    background-color: #f8d7da;
}

.withdrawn-banner .alert-heading {
    color: #842029;
}

/* Metadata section */
.article-metadata dl.row dt {
    font-weight: 600;
    color: var(--portal-text);
}

.article-metadata dl.row dd {
    color: var(--portal-text-muted);
}

.article-metadata dl.row dd a {
    color: var(--portal-secondary);
    word-break: break-all;
}

.article-metadata dl.row dd a:hover {
    color: var(--portal-primary);
}

/* Keyword tags */
.keyword-tag {
    font-size: 0.8rem;
    font-weight: 400;
    padding: 0.35em 0.65em;
}

/* ===========================
   Floating Action Bar (Story 4.5)
   =========================== */

/* Desktop: Vertical bar on right side */
.floating-action-bar {
    position: fixed;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1030;
    padding: 0.75rem;
    background: white;
    border-radius: 2rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--portal-border);
}

/* FAB buttons - round on desktop */
.fab-btn {
    width: 48px;
    height: 48px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    padding: 0;
    position: relative;
}

.fab-btn:focus-visible {
    outline: 2px solid var(--portal-secondary);
    outline-offset: 2px;
}

.fab-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Label visible only on mobile */
.fab-label {
    font-size: 0.7rem;
    margin-left: 0.25rem;
}

/* Share dropdown */
.fab-share-dropdown {
    position: absolute;
    left: -200px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: 1px solid var(--portal-border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 1031;
    padding: 0.5rem 0;
}

.fab-share-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    width: 100%;
    border: none;
    background: none;
    color: var(--portal-text);
    text-decoration: none;
    font-size: 0.875rem;
    cursor: pointer;
    text-align: left;
}

.fab-share-option:hover {
    background-color: var(--portal-bg-secondary);
    color: var(--portal-primary);
}

/* Mobile: Horizontal bar at bottom */
@media (max-width: 991.98px) {
    .floating-action-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        transform: none;
        flex-direction: row;
        justify-content: space-around;
        border-radius: 0;
        padding: 0.75rem 1rem;
        border-top: 1px solid var(--portal-border);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
        gap: 0;
    }

    .fab-btn {
        width: auto;
        height: auto;
        min-width: 44px;
        min-height: 44px;
        border-radius: 0.5rem;
        font-size: 1rem;
        padding: 0.5rem 0.75rem;
        flex-direction: column;
        gap: 0.125rem;
    }

    .fab-label {
        display: block !important;
        margin-left: 0;
    }

    /* Share dropdown on mobile - above button */
    .fab-share-dropdown {
        left: 50%;
        transform: translateX(-50%);
        top: auto;
        bottom: 100%;
        margin-bottom: 0.5rem;
    }

    /* Padding on main content so bar does not cover content.
       Scoped to only apply when floating-action-bar is present on the page
       using the :has() selector (supported in all modern browsers). */
    .portal-content:has(.floating-action-bar) {
        padding-bottom: 5rem;
    }
}

/* ===========================
   Citation Modal (Story 4.7)
   =========================== */

/* Plain text citation - selectable text with padding */
.citation-text {
    padding: 1rem;
    background-color: var(--portal-bg-secondary);
    border-radius: 0.375rem;
    border: 1px solid var(--portal-border);
    line-height: 1.6;
    color: var(--portal-text);
    user-select: all;
    -webkit-user-select: all;
}

/* Code format (BibTeX/RIS) - monospace in code block */
.citation-code pre {
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    border: 1px solid var(--portal-border);
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.citation-code code {
    color: var(--portal-text);
}

/* Tab active state aligned with portal theme */
#citationTabs .nav-link {
    color: var(--portal-text-muted);
    font-size: 0.9rem;
}

#citationTabs .nav-link:hover {
    color: var(--portal-primary);
}

#citationTabs .nav-link.active {
    color: var(--portal-primary);
    border-bottom-color: var(--portal-primary);
    font-weight: 600;
}

/* ===========================
   Accessibility
   =========================== */

.portal-header .nav-link:focus,
.publisher-card:focus-within,
.breadcrumb-item a:focus {
    outline: 2px solid var(--portal-secondary);
    outline-offset: 2px;
}

/* Skip to content link for screen readers */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: var(--portal-primary);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 9999;
}

.skip-link:focus {
    top: 0;
}
