/* Popular POEM Custom Styles */

/* Color scheme */
:root {
    --bg-light-grey: #f0f2f5;
    --navbar-dark-grey: #343a40;
    --btn-blue: #0d6efd;
    --btn-blue-hover: #0b5ed7;
}

/* Body layout for sticky footer */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-light-grey);
}

main {
    flex: 1;
}

/* Hero section */
.hero {
    background: var(--bg-light-grey);
    color: #212529;
    padding: 4rem 0;
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 3rem;
    font-weight: bold;
}

/* Hero carousel */
#intro-carousel {
    position: relative;
    margin-bottom: 1rem;
}

#intro-carousel .carousel-inner {
    min-height: 180px;
    display: flex;
    align-items: center;
}

#intro-carousel .carousel-item {
    padding: 1rem 3rem;
}

#intro-carousel .carousel-content {
    padding: 1rem;
}

#intro-carousel .carousel-label {
    font-size: 1rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

#intro-carousel .carousel-text {
    font-size: 1.25rem;
    line-height: 1.6;
    margin-bottom: 0;
}

#intro-carousel .carousel-poem {
    font-style: italic;
}

#intro-carousel .carousel-control-prev,
#intro-carousel .carousel-control-next {
    width: 10%;
    opacity: 0.5;
}

#intro-carousel .carousel-control-prev:hover,
#intro-carousel .carousel-control-next:hover {
    opacity: 0.9;
}

#intro-carousel .carousel-control-prev-icon,
#intro-carousel .carousel-control-next-icon {
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    padding: 1.25rem;
    background-size: 50%;
}

/* Cards */
.card {
    background-color: #ffffff;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

/* Content areas should have white background */
main .container {
    background-color: transparent;
}

/* Fix flexbox shrinking issue with nowrap content */
.poem-lines-column {
    min-width: 0;
    container-type: inline-size; /* Enable container queries */
}

/* Poem lines display */
.poem-lines {
    font-family: 'Hack', monospace;
    /* Use container query units (cqi) to scale based on actual container width
       75 chars in Hack ≈ 45em width, so font ≈ container-width / 50 (with padding buffer).
       Max raised to 1.5rem so the font can fill the column at Bootstrap xl/xxl widths. */
    font-size: clamp(0.45rem, 2cqi, 1.5rem);
    line-height: 1.4;
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-left: 3px solid #0d6efd;
    overflow-x: auto; /* Fallback: contain overflow if font calc is slightly off */
    direction: ltr; /* Poem content is always English/LTR regardless of UI language */
}

.poem-line,
.poem-line:hover,
.poem-line:visited,
.poem-line:active {
    color: inherit;
    text-decoration: none;
}

.poem-line {
    display: block;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

.poem-line:hover {
    background-color: rgba(13, 110, 253, 0.1);
}

/* Country distribution bar (rendered by JS as inline SVG) */
.country-bar {
    display: none;
    width: 100%;
    height: 4px;
}

.poem-line:hover + .country-bar {
    display: block;
}

/* Pie chart page */
.poem-line-preview {
    font-family: 'Hack', monospace;
    font-size: 0.95rem;
    background-color: #f8f9fa;
    border-left: 3px solid #0d6efd;
    padding: 0.75rem 1rem;
    white-space: nowrap;
    overflow-x: auto;
    direction: ltr; /* Poem content is always English/LTR regardless of UI language */
}

.pie-chart {
    display: block;
    margin: 0 auto;
}

.pie-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 0.3rem 0.65rem;
    border-radius: 4px;
    font-size: 0.85rem;
    pointer-events: none;
    white-space: nowrap;
    z-index: 1000;
}

/* Poem popularity popover */
.poem-popularity-popover {
    --bs-popover-max-width: 250px;
}

.poem-popularity-popover .popover-header {
    font-size: 0.875rem;
    background-color: #f8f9fa;
}

.poem-popularity-popover .popover-body {
    font-size: 0.875rem;
}

.popularity-stats {
    text-align: center;
}

.popularity-stats strong {
    font-size: 1.25rem;
    color: #0d6efd;
}

/* Poem detail */
.poem-header {
    border-bottom: 2px solid #0d6efd;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.poem-position {
    color: #6c757d;
    font-style: italic;
}

/* Character counter for message input */
.char-counter {
    font-size: 0.875rem;
    color: #6c757d;
}

.char-counter.warning {
    color: #ffc107;
}

.char-counter.danger {
    color: #dc3545;
}

.char-invalid {
    font-size: 0.875rem;
    color: #dc3545;
}

/* Streak badge */
.streak-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: #ffc107;
    color: #212529;
    border-radius: 2rem;
    font-weight: bold;
}

/* Poem list (compact view) */
.poem-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1rem;
}

.poem-list-main {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    min-width: 0;
}

.poem-list-main strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.poem-list-position {
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.poem-list-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.poem-list-count {
    font-size: 0.85rem;
    white-space: nowrap;
}

.poem-list-edit {
    font-size: 0.9rem;
    cursor: pointer;
    color: #6c757d;
}

.poem-list-edit:hover {
    color: #0d6efd;
}

.poem-list-arrow {
    font-size: 1.25rem;
    color: #adb5bd;
    line-height: 1;
}

@media (max-width: 575.98px) {
    .poem-list-item {
        flex-wrap: wrap;
    }

    .poem-list-main {
        flex-direction: column;
        gap: 0;
        width: 100%;
    }

    .poem-list-meta {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Search results */
.search-result {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
}

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

.search-result:hover {
    background-color: #f8f9fa;
}

/* Form styling */
textarea.form-control::placeholder {
    color: #c0c5cb;
}

.form-label {
    font-weight: 500;
}

/* Button styling - blue buttons */
.btn-primary {
    background-color: var(--btn-blue);
    border-color: var(--btn-blue);
}

.btn-primary:hover {
    background-color: var(--btn-blue-hover);
    border-color: var(--btn-blue-hover);
}

/* Navbar dark grey */
.navbar-dark-grey {
    background-color: var(--navbar-dark-grey) !important;
}

/* Footer on light grey background */
footer {
    background-color: #e9ecef !important;
}

/* Normalize dropdown option height across scripts (Arabic/Devanagari glyphs are taller than Latin) */
footer select.form-select option {
    line-height: 1.5;
    font-size: 0.875rem;
}

/* Alert styling for Django messages */
.alert-debug {
    background-color: #e2e3e5;
    border-color: #d3d6d8;
    color: #41464b;
}

.alert-error {
    background-color: #f8d7da;
    border-color: #f5c2c7;
    color: #842029;
}

/* Autocomplete dropdown */
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 2px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
}

.autocomplete-item:hover {
    background-color: #f8f9fa;
}

.autocomplete-item.active {
    background-color: #0d6efd;
    color: white;
}

/* Utility class for CSP-compliant hiding (instead of inline style="display: none;") */
.d-none-initial {
    display: none;
}

/* Cookie Consent Banner */
.cookie-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--navbar-dark-grey);
    color: #ffffff;
    padding: 1rem 0;
    z-index: 9999;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

.cookie-consent-banner p {
    margin-bottom: 0;
    font-size: 0.9rem;
}

.cookie-consent-link {
    color: #ffffff;
    text-decoration: underline;
}

.cookie-consent-link:hover {
    color: #e9ecef;
}

/* Cookie consent notice for forms */
.cookie-consent-required {
    background-color: #fff3cd;
    border: 1px solid #ffecb5;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.cookie-consent-required a {
    color: #664d03;
    text-decoration: underline;
    cursor: pointer;
}

/* About page — sidebar nav + scrollspy */
html {
    scroll-behavior: smooth;
}

.about-sidebar {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding-right: 1rem;
}

.about-sidebar .nav-link {
    color: #495057;
    padding: 0.25rem 0.75rem;
    border-left: 2px solid transparent;
    border-radius: 0;
    font-size: 0.875rem;
}

.about-sidebar .nav-link:hover {
    color: #0d6efd;
    background-color: transparent;
}

.about-sidebar .nav-link.active {
    color: #0d6efd;
    background-color: transparent;
    border-left-color: #0d6efd;
    font-weight: 500;
}

.about-nav-top {
    font-weight: 500;
    font-size: 0.9rem !important;
    margin-top: 0.5rem;
}

.about-nav-sub {
    font-size: 0.8rem !important;
}

.about-section {
    padding-bottom: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid #dee2e6;
}

.about-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.about-section > h1,
.about-section > h2 {
    margin-bottom: 1rem;
}

.about-item {
    background-color: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}

.about-subsection {
    font-weight: 600;
    font-size: 1.05rem;
    margin-top: 0;
    margin-bottom: 0.75rem;
    padding-top: 0;
    color: #212529;
}

.about-item p:last-child,
.about-item ul:last-child,
.about-item ol:last-child {
    margin-bottom: 0;
}

/* Signup progress steps (1→2→3) */
.signup-progress {
    margin-bottom: 1.5rem;
}
.signup-progress .steps-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.signup-progress .step {
    text-align: center;
    flex: 0 0 auto;
}
.signup-progress .step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e9ecef;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}
.signup-progress .step.active .step-number {
    background: #0d6efd;
    color: white;
}
.signup-progress .step.completed .step-number {
    background: #198754;
    color: white;
}
.signup-progress .step-line {
    flex: 1;
    height: 2px;
    background: #e9ecef;
    margin: 0 8px;
}
.signup-progress .step-line.completed {
    background: #198754;
}
.signup-progress .step-label {
    font-size: 0.85rem;
    margin-top: 4px;
    color: #6c757d;
}
.signup-progress .step.active .step-label {
    color: #0d6efd;
    font-weight: 500;
}
.signup-progress .step.completed .step-label {
    color: #198754;
}
