* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: linear-gradient(to right, oklch(0.7 0.14 255), oklch(0.7 0.14 340));
    --primary-color: oklch(0.7 0.14 255);
    --secondary-color: oklch(0.7 0.14 340);
    --tertiary-color: oklch(0.7 0.14 298);
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: Nunito, Merriweather, sans-serif;
    line-height: 1.5;
    color: hsl(var(--bc));
    background: var(--primary-gradient);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Typography scaling for readability on small screens */
h1 {
    font-size: 1.5rem;
    line-height: 1.2;
}

h2 {
    font-size: 1.25rem;
    line-height: 1.3;
    margin-bottom: 0.75rem;
}

h3 {
    font-size: 1.1rem;
    line-height: 1.4;
}

p {
    font-size: 0.95rem;
}

/* Animation for resource card hover with touch consideration */
.resource-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.resource-card:hover,
.resource-card:focus,
.resource-card:active {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Improved touch target sizes */
button,
.btn,
a.btn,
select {
    min-height: 2.75rem;
}

.btn-blue {
    background-color: var(--primary-color);
    border: 1px solid oklch(from var(--primary-color) l c h / 20%);
}

.btn-blue:hover {
    background-color: oklch(from var(--primary-color) l c h / 0.8);
    border-color: oklch(from var(--primary-color) l c h / 0.5);
}

.btn-pink {
    background-color: var(--secondary-color);
    border: 1px solid oklch(from var(--secondary-color) l c h / 20%);
    color: white;
}

.btn-pink:hover {
    background-color: oklch(from var(--secondary-color) l c h / 0.8);
    border-color: oklch(from var(--secondary-color) l c h / 0.5);
}

.badge-pink {
    background-color: var(--secondary-color);
    border: 1px solid oklch(from var(--secondary-color) l c h / 20%);
    color: white;
}

.text-blue {
    color: oklch(from var(--primary-color) calc(l - 0.2) c h);
}

.text-pink {
    color: oklch(from var(--secondary-color) calc(l + 0.05) c h);
}

/* Adjustments for form elements on mobile */
input,
select,
textarea {
    font-size: 1rem; /* Prevents iOS zoom on focus */
    padding: 0.625rem;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0); /* Start transparent */
}

.modal[open] {
    background-color: rgba(0, 0, 0, 0.7); /* Background overlay color */
}

/* Modal box should be positioned within the dialog */
.modal-box {
    position: relative;
    z-index: 1000;
    max-width: 500px;
    width: 90%;
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

@media (max-width: 640px) {
    .modal-box {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* The modal-backdrop element isn't necessary with this approach,
   as the dialog itself acts as the backdrop */
.modal-backdrop {
    display: none;
}

/* If you want to still use the modal-backdrop for click handling */
.modal::backdrop {
    background-color: transparent;
}

/* Dialog and modal styles */
dialog[open].modal {
    display: flex;
    z-index: 999;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 0; /* Removed padding to allow full-screen */
    inset: 0; /* Position the dialog to fill the entire viewport */
    height: 100vh; /* Ensure full height */
    width: 100vw; /* Ensure full width */
    max-width: 100vw; /* Override any max-width */
    max-height: 100vh; /* Override any max-height */
    margin: 0; /* Remove any margin */
}

.modal-box {
    width: 100%;
    max-width: 100%;
    height: 100%; /* Fill the entire height on mobile */
    max-height: 100vh; /* Allow full-screen height on mobile */
    margin: 0; /* Remove margin on mobile */
    border-radius: 0; /* Remove border radius on mobile for full-screen effect */
    overflow-y: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    padding: 1.5rem; /* Add consistent padding */
}

/* Animation for dialog opening */
dialog[open] .modal-box {
    animation: dialog-fade-in 0.3s ease-out;
}

@keyframes dialog-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

dialog.modal-closing {
    animation: dialog-fade-out 0.2s ease-out;
}

@keyframes dialog-fade-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Better spacing for filter panel on mobile */
#filterPanel {
    padding: 1rem;
    margin-bottom: 1rem;
}

#categoryFilters,
#tagFilters {
    margin-bottom: 1rem;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: hsl(var(--b2));
}

::-webkit-scrollbar-thumb {
    background: hsl(var(--bc) / 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--bc) / 0.4);
}

/* Toast notifications */
#toastContainer {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: none;
}

#toastContainer > * {
    pointer-events: auto;
    max-width: 20rem;
    width: calc(100% - 2rem);
}

/* Card improvements for mobile */
.card {
    break-inside: avoid;
    width: 100%;
}

.card-body {
    padding: 1rem;
}

/* Resource card design improvements */
.resource-card .badge {
    font-size: 0.7rem;
    height: auto;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

/* Share button and report button improved touch targets */
.share-resource-btn,
.report-resource-btn {
    padding: 0.5rem;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.share-resource-btn:hover {
    background-color: hsl(var(--p) / 0.1);
}

.report-resource-btn:hover {
    background-color: hsl(var(--er) / 0.1);
}

/* Background gradient for header and footer */
.bg-gradient-to-r {
    background-size: 200% auto;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Resource list layout improvements for mobile */
#resourcesList {
    gap: 1rem;
}

a[href*="buymeacoffee"] {
    transition: all 0.3s ease;
}

a[href*="buymeacoffee"]:hover {
    transform: scale(1.05);
}

/* Dialog specific styles */
dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
}

#add-report-dialog[open].modal {
    display: flex;
    z-index: 999;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 0;
    inset: 0;
    height: 100vh;
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    margin: 0;
}

#add-report-dialog .modal-box {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Better mobile form layout in dialog */
@media (max-width: 640px) {
    .modal-box .label {
        margin-bottom: 0.2rem;
    }

    .modal-box input,
    .modal-box select,
    .modal-box textarea {
        font-size: 16px; /* Prevents iOS zoom */
    }
}

/* Medium screens (tablets) */
@media (min-width: 640px) {
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    p {
        font-size: 1rem;
    }

    .card-body {
        padding: 1.5rem;
    }

    #resourcesList {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-box {
        width: 90%;
        max-width: 42rem;
        height: auto; /* Auto height on larger screens */
        max-height: 85vh; /* Limit height on larger screens */
        margin: 1rem; /* Add margin on larger screens */
        border-radius: 0.5rem; /* Restore border radius on larger screens */
        padding: 2rem; /* Larger padding on bigger screens */
    }

    #add-report-dialog .modal-box {
        width: 90%;
        max-width: 32rem; /* Smaller than the add resource dialog */
        height: auto;
        max-height: 85vh;
        margin: 1rem;
        border-radius: 0.5rem;
        padding: 1rem;
    }
}

/* Large screens (desktops) */
@media (min-width: 1024px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    .modal-box {
        max-width: 56rem;
    }

    #resourcesList {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark mode compatibility improvements */
@media (prefers-color-scheme: dark) {
    .resource-card:hover {
        box-shadow: 0 6px 15px -3px rgba(0, 0, 0, 0.4);
    }

    .modal-backdrop {
        background-color: rgba(0, 0, 0, 0.7);
    }
}

/* Focus state improvements for accessibility */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid hsl(var(--p));
    outline-offset: 2px;
}

/* Error state for form elements */
.input-error,
.select-error,
.textarea-error {
    border-color: hsl(var(--er)) !important;
}

/* Loading indicator for form submission */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: calc(50% - 0.5rem);
    left: calc(50% - 0.5rem);
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: button-loading-spinner 0.75s linear infinite;
}

@keyframes button-loading-spinner {
    from {
        transform: rotate(0turn);
    }
    to {
        transform: rotate(1turn);
    }
}

.collapse-title {
    font-weight: 600;
    background-color: oklch(from var(--tertiary-color) l c h / 0.5);
}

.collapse[open] .collapse-title {
    background-color: oklch(from var(--tertiary-color) l c h);
}

.collapse-content {
    padding: .5rem !important;
    background-color: oklch(from var(--tertiary-color) l c h / 0.1);
}

.resource-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    border-color: rgba(147, 51, 234, 0.1);
}

.resource-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px -3px rgba(147, 51, 234, 0.1);
}

.share-resource-btn {
    color: oklch(from var(--primary-color) l c h);
    border-color: oklch(0 0 0 / 0.5);
}

.share-resource-btn:hover {
    color: oklch(from var(--primary-color) calc(l - 0.2) c h / 1);
    background-color: oklch(from var(--primary-color) l c h / 0.1);
}

.report-resource-btn {
    color: oklch(from var(--secondary-color) l c h);
    border-color: oklch(0 0 0 / 0.5);
}

.report-resource-btn:hover {
    color: oklch(from var(--secondary-color) calc(l - 0.2) c h / 1);
    background-color: oklch(from var(--secondary-color) l c h / 0.1);
}

#filterButton.btn-blue {
    background-color: oklch(from var(--secondary-color) l c h);
}

/* Badge colors */
.badge-success {
    background-color: #10b981 !important; /* emerald-500 */
    color: white !important;
}

.badge-warning {
    background-color: #f59e0b !important; /* amber-500 */
    color: white !important;
}
