/* =========================
   Reset
========================= */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f5f7fb;
    color: #172033;
    line-height: 1.6;
}

/* =========================
   Layout
========================= */

.container {
    width: min(100% - 32px, 1100px);
    margin-inline: auto;
}

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

.site-header {
    padding: 65px 0 50px;
    background: linear-gradient(135deg, #312e81, #6d28d9);
    color: white;
}

.eyebrow {
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.85;
}

h1 {
    max-width: 750px;
    font-size: clamp(2.2rem, 6vw, 3.6rem);
    line-height: 1.1;
}

.intro {
    max-width: 650px;
    margin-top: 16px;
    font-size: 1.05rem;
    opacity: 0.9;
}

/* =========================
   Main
========================= */

main {
    padding: 40px 0;
}

/* =========================
   Add Section
========================= */

.add-section {
    padding: 28px;
    margin-bottom: 35px;
    background: white;
    border: 1px solid #dfe3eb;
    border-radius: 14px;
    box-shadow: 0 8px 25px rgba(23, 32, 51, 0.06);
}

.add-section h2,
.reading-section h2 {
    margin-bottom: 5px;
    font-size: 1.55rem;
}

#readingForm {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 16px;
    align-items: end;
    margin-top: 22px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

label {
    font-weight: 700;
    font-size: 0.9rem;
}

input {
    width: 100%;
    min-height: 46px;
    padding: 11px 13px;
    border: 1px solid #cbd3df;
    border-radius: 8px;
    background: white;
    color: #172033;
    font: inherit;
}

input::placeholder {
    color: #8a94a6;
}

/* =========================
   Buttons
========================= */

button {
    min-height: 46px;
    padding: 11px 18px;
    border-radius: 8px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

button:active {
    transform: translateY(1px);
}

.primary-button {
    border: 2px solid #4f46e5;
    background: #4f46e5;
    color: white;
}

.primary-button:hover {
    background: #4338ca;
}

.secondary-button {
    border: 2px solid #4f46e5;
    background: white;
    color: #4f46e5;
}

.secondary-button:hover {
    background: #eef2ff;
}

/* =========================
   Keyboard Focus
========================= */

button:focus-visible,
input:focus-visible {
    outline: 4px solid #f59e0b;
    outline-offset: 3px;
}

/* =========================
   Section Heading
========================= */

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.section-heading p {
    color: #667085;
}

.item-count {
    padding: 6px 11px;
    border-radius: 999px;
    background: #ede9fe;
    color: #5b21b6;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

/* =========================
   State Cards
========================= */

.state-card {
    padding: 45px 25px;
    border-radius: 14px;
    text-align: center;
}

.state-card h3 {
    margin: 12px 0 8px;
    font-size: 1.35rem;
}

.state-card p {
    max-width: 600px;
    margin: 0 auto 20px;
    color: #667085;
}

.loading-state {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
}

.error-state {
    background: #fff1f2;
    border: 1px solid #fecdd3;
}

.error-state p {
    color: #7f1d1d;
}

.empty-state {
    background: white;
    border: 1px dashed #cbd3df;
}

/* =========================
   State Icons
========================= */

.state-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin: 0 auto;
    border-radius: 50%;
    background: #e0e7ff;
    color: #3730a3;
    font-size: 1.4rem;
    font-weight: 800;
}

.error-state .state-icon {
    background: #ffe4e6;
    color: #be123c;
}

/* =========================
   Loading Spinner
========================= */

.loader {
    width: 42px;
    height: 42px;
    margin: 0 auto;
    border: 4px solid #c7d2fe;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =========================
   Reading List
========================= */

.reading-list {
    display: grid;
    gap: 14px;
}

.reading-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px;
    background: white;
    border: 1px solid #dfe3eb;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(23, 32, 51, 0.05);
}

.reading-content {
    min-width: 0;
}

.reading-content h3 {
    margin-bottom: 5px;
    font-size: 1.05rem;
    overflow-wrap: anywhere;
}

.reading-content a {
    color: #4f46e5;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.remove-button {
    flex-shrink: 0;
    border: 2px solid #e11d48;
    background: white;
    color: #be123c;
}

.remove-button:hover {
    background: #fff1f2;
}

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

.site-footer {
    padding: 25px 0;
    border-top: 1px solid #dfe3eb;
    background: white;
    color: #667085;
    text-align: center;
    font-size: 0.9rem;
}

/* =========================
   Tablet
========================= */

@media (max-width: 850px) {

    #readingForm {
        grid-template-columns: 1fr 1fr;
    }

    #readingForm .primary-button {
        width: 100%;
    }
}

/* =========================
   Mobile
========================= */

@media (max-width: 600px) {

    .container {
        width: min(100% - 24px, 1100px);
    }

    .site-header {
        padding: 45px 0 35px;
    }

    main {
        padding: 25px 0;
    }

    .add-section {
        padding: 20px;
    }

    #readingForm {
        grid-template-columns: 1fr;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .reading-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .remove-button {
        width: 100%;
    }

    .state-card {
        padding: 35px 18px;
    }
}

/* =========================
   Very Narrow Screens
========================= */

@media (max-width: 360px) {

    .container {
        width: calc(100% - 20px);
    }

    h1 {
        font-size: 2rem;
    }

    .add-section {
        padding: 16px;
    }

    .state-card {
        padding: 30px 14px;
    }
}