/* ReadLog theme, carried over from readlog-dotnet's wwwroot/css/site.css, which in
   turn carries the original Next.js app's MUI palette:
   primary #5D4E37 (espresso), secondary #8B6914 (ochre), page bg #FAFAF5.

   The .NET app themes Bootstrap 5 with these variables. There is no Bootstrap here:
   the brief asks for minimal styling and no build step, and pulling Bootstrap in
   would mean either vendoring 200 kB of CSS or depending on a CDN at runtime. So the
   handful of primitives the pages actually use are written out below. */

:root {
    --rl-primary: #5d4e37;
    --rl-primary-dark: #3e2723;
    --rl-secondary: #8b6914;
    --rl-bg: #fafaf5;
    --rl-surface: #ffffff;
    --rl-text: #2e2a23;
    --rl-muted: #7a7266;
    --rl-line: rgba(93, 78, 55, 0.15);
    --rl-danger: #a03030;
    --rl-success: #3d6b3d;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 15px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--rl-bg);
    color: var(--rl-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
}

a {
    color: var(--rl-primary);
}

a:hover {
    color: var(--rl-primary-dark);
}

/* --- Skip link ---------------------------------------------------------- */
.rl-skip {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--rl-surface);
    padding: 0.5rem 0.75rem;
    z-index: 10;
}

.rl-skip:focus {
    left: 0.5rem;
    top: 0.5rem;
}

/* --- Shell -------------------------------------------------------------- */
.rl-container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
}

.rl-navbar {
    background-color: var(--rl-surface);
    border-bottom: 1px solid var(--rl-line);
    box-shadow: 0 1px 3px rgba(62, 39, 35, 0.06);
}

.rl-navbar .rl-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.rl-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--rl-primary);
    text-decoration: none;
}

.rl-nav {
    display: flex;
    gap: 1rem;
    margin-right: auto;
    list-style: none;
    padding: 0;
    margin-top: 0;
    margin-bottom: 0;
}

.rl-nav a {
    color: var(--rl-primary);
    font-weight: 500;
    text-decoration: none;
}

.rl-nav a:hover,
.rl-nav a[aria-current="page"] {
    color: var(--rl-primary-dark);
    text-decoration: underline;
}

.rl-main {
    flex: 1 0 auto;
    padding: 1.5rem 0 2.5rem;
}

.rl-footer {
    flex-shrink: 0;
    background-color: var(--rl-surface);
    border-top: 1px solid var(--rl-line);
    color: var(--rl-muted);
    font-size: 0.85rem;
    padding: 1rem 0;
}

/* --- Widths ------------------------------------------------------------- */
.rl-narrow {
    max-width: 560px;
    margin: 0 auto;
}

.rl-medium {
    max-width: 820px;
    margin: 0 auto;
}

.rl-page-title {
    color: var(--rl-primary);
    font-weight: 700;
    font-size: 1.6rem;
    margin: 0 0 0.25rem;
}

/* --- Text helpers ------------------------------------------------------- */
.rl-muted {
    color: var(--rl-muted);
}

.rl-small {
    font-size: 0.85rem;
}

.rl-strong {
    font-weight: 600;
}

.rl-center {
    text-align: center;
}

.rl-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rl-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rl-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rl-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* --- Cards -------------------------------------------------------------- */
.rl-card {
    display: block;
    background: var(--rl-surface);
    border: 1px solid var(--rl-line);
    border-radius: 8px;
    padding: 0.75rem;
    color: inherit;
    text-decoration: none;
}

a.rl-card:hover {
    box-shadow: 0 2px 10px rgba(62, 39, 35, 0.12);
}

.rl-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.15rem;
}

/* --- Notices ------------------------------------------------------------ */
.rl-notice {
    background: #f1efe4;
    border: 1px solid var(--rl-line);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 1rem;
}

.rl-error {
    color: var(--rl-danger);
}

.rl-error-summary {
    border: 1px solid rgba(160, 48, 48, 0.4);
    background: #fbf2f2;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 1rem;
}

.rl-error-summary ul {
    margin: 0;
    padding-left: 1.1rem;
}

.rl-found {
    color: var(--rl-success);
    font-weight: 600;
}

/* --- Covers ------------------------------------------------------------- */
.rl-cover {
    object-fit: cover;
    border-radius: 6px;
    background-color: #efece3;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--rl-secondary);
}

.rl-cover-sm {
    width: 40px;
    height: 60px;
    font-size: 1.1rem;
}

.rl-cover-md {
    width: 80px;
    height: 120px;
    font-size: 1.5rem;
}

.rl-cover-lg {
    width: 120px;
    height: 180px;
    font-size: 2rem;
    box-shadow: 0 1px 4px rgba(62, 39, 35, 0.2);
}

.rl-cover-grid {
    width: 100%;
    aspect-ratio: 2 / 3;
    height: auto;
    font-size: 1.8rem;
    box-shadow: 0 1px 4px rgba(62, 39, 35, 0.15);
}

/* --- Grid --------------------------------------------------------------- */
.rl-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

@media (min-width: 600px) {
    .rl-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 820px) {
    .rl-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.rl-grid-item {
    display: block;
    text-align: center;
    color: inherit;
    text-decoration: none;
}

.rl-grid-author {
    font-size: 0.75rem;
    color: var(--rl-muted);
}

/* --- Badges and stars --------------------------------------------------- */
.rl-badge {
    display: inline-block;
    color: var(--rl-primary);
    background-color: transparent;
    border: 1px solid rgba(93, 78, 55, 0.4);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.1rem 0.55rem;
    white-space: nowrap;
}

.rl-stars {
    color: var(--rl-secondary);
    letter-spacing: 1px;
    font-size: 0.95rem;
    white-space: nowrap;
}

.rl-star {
    color: rgba(93, 78, 55, 0.3);
}

.rl-star-filled {
    color: var(--rl-secondary);
}

/* --- Forms -------------------------------------------------------------- */
.rl-field {
    margin-bottom: 1rem;
}

.rl-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.rl-input,
.rl-select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid rgba(93, 78, 55, 0.35);
    border-radius: 6px;
    background: var(--rl-surface);
    color: inherit;
    font: inherit;
}

.rl-input:focus,
.rl-select:focus {
    outline: 2px solid var(--rl-secondary);
    outline-offset: 1px;
}

.rl-fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 1rem;
}

.rl-legend {
    font-weight: 500;
    padding: 0;
    margin-bottom: 0.25rem;
}

/* Radio group styled as a segmented control. The radio itself stays in the DOM and
   keeps focus and keyboard behaviour; only its box is hidden. */
.rl-segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.rl-segmented input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.rl-segmented label {
    display: inline-block;
    border: 1px solid var(--rl-primary);
    border-radius: 6px;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    color: var(--rl-primary);
}

.rl-segmented input:checked + label {
    background: var(--rl-primary);
    color: #fff;
}

.rl-segmented input:focus-visible + label {
    outline: 2px solid var(--rl-secondary);
    outline-offset: 2px;
}

/* --- Buttons ------------------------------------------------------------ */
.rl-btn {
    display: inline-block;
    border: 1px solid var(--rl-primary);
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    background: var(--rl-primary);
    color: #fff;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.rl-btn:hover {
    background: var(--rl-primary-dark);
    border-color: var(--rl-primary-dark);
    color: #fff;
}

.rl-btn-outline {
    background: transparent;
    color: var(--rl-primary);
}

.rl-btn-outline:hover {
    background: var(--rl-primary);
    color: #fff;
}

.rl-btn-danger {
    background: transparent;
    border-color: var(--rl-danger);
    color: var(--rl-danger);
}

.rl-btn-danger:hover {
    background: var(--rl-danger);
    border-color: var(--rl-danger);
    color: #fff;
}

.rl-btn-sm {
    font-size: 0.85rem;
    padding: 0.25rem 0.6rem;
}

.rl-btn-block {
    display: block;
    width: 100%;
}

/* --- List group --------------------------------------------------------- */
.rl-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--rl-line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--rl-surface);
}

.rl-list > * {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--rl-line);
    color: inherit;
    text-decoration: none;
}

.rl-list > *:last-child {
    border-bottom: 0;
}

.rl-list > a:hover {
    background: #f5f2e9;
}

/* --- Account ------------------------------------------------------------ */
.rl-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--rl-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    flex-shrink: 0;
    object-fit: cover;
}

.rl-stat {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.1;
}

/* --- Book detail -------------------------------------------------------- */
.rl-description {
    line-height: 1.7;
}

.rl-description img {
    max-width: 100%;
    height: auto;
}

/* --- Demo banner -------------------------------------------------------- */
.rl-demo {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--rl-muted);
}

.rl-demo select {
    font: inherit;
    padding: 0.15rem 0.3rem;
    border: 1px solid rgba(93, 78, 55, 0.35);
    border-radius: 4px;
    background: var(--rl-surface);
    color: inherit;
}
