/* Clinic section — plain, content-first reading pages, shared across Patient and
   Physician. Self-contained: does not depend on the site's main theme system,
   since this section is deliberately optimized for content-focus, printing, and
   QR-based navigation rather than the coffee-toned time-of-day theme used elsewhere. */

:root {
    --bg: #FFFFFF;
    --text: #1A1A1A;
    --muted: #666666;
    --accent: #1A1A1A;
    --line: #DDDDDD;
    --link: #0000EE;
    --link-visited: #551A8B;
}

[data-theme="dark"] {
    --bg: #121212;
    --text: #EAEAEA;
    --muted: #999999;
    --accent: #EAEAEA;
    --line: #333333;
    --link: #6699FF;
    --link-visited: #B18CE8;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Georgia, 'Iowan Old Style', 'Palatino Linotype', Cambria, serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.5rem 2rem 5rem;
}

.crumb {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.crumb a {
    color: var(--link);
    text-decoration: underline;
}

.crumb a:visited {
    color: var(--link-visited);
}

h1 {
    font-weight: 400;
    font-size: 2rem;
    margin: 0 0 2rem;
    color: var(--text);
}

p.subtitle {
    color: var(--muted);
    margin: -1.25rem 0 2rem;
    font-size: 1rem;
}

/* Directory: search + filters */

.search-input {
    display: block;
    width: 100%;
    font: inherit;
    font-size: 1rem;
    padding: 0.4rem 0;
    border: none;
    border-bottom: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    margin-bottom: 1.75rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.filters {
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.filters .filter-label {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-right: 0.75rem;
}

.filters button {
    font: inherit;
    font-size: 0.9rem;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    margin: 0 1.25rem 0.5rem 0;
}

.filters button.active {
    color: var(--accent);
    text-decoration: underline;
}

.filters-toggle {
    display: none;
}

.group {
    margin-bottom: 2.5rem;
}

.group h2 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 400;
    color: var(--muted);
    margin: 0 0 0.75rem;
}

.item-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.item {
    padding: 0.9rem 0;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.item .item-body {
    flex: 1;
    min-width: 0;
}

.item a {
    color: var(--link);
    text-decoration: underline;
    font-size: 1.05rem;
}

.item a:visited {
    color: var(--link-visited);
}

.item .desc {
    color: var(--muted);
    font-size: 0.92rem;
    margin-top: 0.3rem;
}

.item .meta {
    color: var(--muted);
    font-size: 0.8rem;
    margin-top: 0.4rem;
}

.item .meta span:not(:last-child)::after {
    content: " · ";
}

.item .item-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 4px;
    flex-shrink: 0;
}

/* Resource reading page */

.meta-line {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.meta-line span:not(:last-child)::after {
    content: " · ";
}

.desc-line {
    color: var(--muted);
    font-style: italic;
    margin-bottom: 2rem;
}

.actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2.5rem;
    font-size: 0.9rem;
}

.actions a {
    font-size: 0.9rem;
    color: var(--link);
    text-decoration: underline;
}

.actions a:visited {
    color: var(--link-visited);
}

.actions button {
    font: inherit;
    font-size: 0.9rem;
    color: var(--muted);
    background: none;
    border: none;
    text-decoration: none;
    cursor: pointer;
    padding: 0;
}

.actions button:hover {
    color: var(--accent);
}

article h1,
article h2,
article h3 {
    font-weight: 400;
    color: var(--text);
}

article a {
    color: var(--link);
    text-decoration: underline;
}

article a:visited {
    color: var(--link-visited);
}

article h2 {
    font-size: 1.4rem;
    margin: 2.5rem 0 1rem;
}

article h3 {
    font-size: 1.15rem;
    margin: 2rem 0 0.75rem;
}

article p {
    margin: 0 0 1.1rem;
}

article ul,
article ol {
    margin: 0 0 1.1rem 1.4rem;
}

article li {
    margin-bottom: 0.4rem;
}

article blockquote {
    margin: 1.5rem 0;
    padding-left: 1rem;
    border-left: 2px solid var(--line);
    color: var(--muted);
}

article code {
    font-family: ui-monospace, monospace;
    font-size: 0.9em;
    background: var(--line);
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

article pre {
    background: var(--line);
    padding: 1rem;
    overflow-x: auto;
    border-radius: 4px;
}

article pre code {
    background: none;
    padding: 0;
}

article table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1.2rem;
    font-size: 0.92rem;
}

article th,
article td {
    border-bottom: 1px solid var(--line);
    padding: 0.5rem 0.6rem;
    text-align: left;
}

article hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 2rem 0;
}

article img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.pdf-wrap iframe {
    width: 100%;
    height: 80vh;
    border: 1px solid var(--line);
}

.pdf-fallback {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.image-wrap {
    text-align: center;
}

.image-wrap img,
article img {
    cursor: zoom-in;
}

.image-wrap img {
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 4px;
}

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1.5rem;
    cursor: zoom-out;
}

.lightbox-overlay.open {
    display: flex;
}

.lightbox-overlay img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    cursor: zoom-out;
}

.lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1.25rem;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: none;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2001;
}

.qr-block {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--line);
    text-align: center;
}

.qr-block img {
    width: 120px;
    height: 120px;
}

.qr-block .qr-caption {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
}

/* Small QR badge for hub/nav pages with no server-rendered resource behind them */
.qr-badge {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    text-align: center;
    opacity: 0.85;
    z-index: 5;
}

.qr-badge canvas {
    width: 72px;
    height: 72px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    padding: 4px;
    display: block;
}

.qr-badge .qr-badge-caption {
    font-size: 0.65rem;
    color: var(--muted);
    margin-top: 0.3rem;
}

@media (max-width: 640px) {
    .qr-badge { display: none; }
}

.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--muted);
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 50%;
    cursor: pointer;
    font: inherit;
    font-size: 0.95rem;
}

.empty {
    color: var(--muted);
    padding: 3rem 0;
    text-align: center;
}

/* Portal / hub cards */

.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.portal-card {
    display: block;
    padding: 2rem 1.5rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, transform 0.15s;
}

.portal-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.portal-card h2 {
    font-weight: 400;
    font-size: 1.3rem;
    margin: 0 0 0.5rem;
    color: var(--text);
}

.portal-card p {
    color: var(--muted);
    font-size: 0.92rem;
    margin: 0;
}

.print-title,
.print-footer {
    display: none;
}

@media (max-width: 640px) {
    .page {
        padding: 1.25rem 1rem 4rem;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 1.25rem;
    }

    .search-input {
        font-size: 16px; /* prevents iOS Safari auto-zoom on focus */
        padding: 0.6rem 0;
        margin-bottom: 0.75rem;
    }

    /* Filters collapse behind a toggle button so they don't push content
       below the fold on phones; desktop keeps them open and skips the toggle. */
    .filters-toggle {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        width: 100%;
        font: inherit;
        font-size: 0.9rem;
        background: none;
        border: 1px solid var(--line);
        border-radius: 6px;
        color: var(--text);
        padding: 0.6rem 0.75rem;
        margin-bottom: 1rem;
        cursor: pointer;
    }

    .filters-toggle .chevron {
        margin-left: auto;
        transition: transform 0.15s;
    }

    .filters-toggle[aria-expanded="true"] .chevron {
        transform: rotate(180deg);
    }

    .filters-toggle .filter-count {
        color: var(--muted);
        font-size: 0.8rem;
    }

    .filters-wrap {
        display: none;
    }

    .filters-wrap.open {
        display: block;
    }

    .filters {
        margin-bottom: 1rem;
    }

    .filters button {
        display: inline-block;
        font-size: 0.95rem;
        padding: 0.35rem 0;
        margin: 0 1.25rem 0.6rem 0;
    }

    .item {
        padding: 1rem 0;
        gap: 0.85rem;
    }

    .item a {
        font-size: 1rem;
    }

    .item .item-thumb {
        width: 48px;
        height: 48px;
    }

    .actions {
        font-size: 0.95rem;
    }

    .actions a,
    .actions button {
        font-size: 0.95rem;
        padding: 0.4rem 0;
    }

    article h2 {
        font-size: 1.2rem;
        margin: 2rem 0 0.75rem;
    }

    article h3 {
        font-size: 1.05rem;
    }

    article table {
        font-size: 0.85rem;
    }

    .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1.2rem;
    }

    .table-scroll table {
        margin-bottom: 0;
    }

    .pdf-wrap iframe {
        height: 70vh;
    }

    .theme-toggle {
        bottom: 1rem;
        right: 1rem;
    }
}

@media print {
    .crumb, .actions, .theme-toggle, .meta-line, .qr-badge { display: none !important; }
    body { background: #fff; color: #000; }
    .print-title { display: block; font-size: 20pt; margin-bottom: 1rem; }
    .print-footer { display: block; font-size: 9pt; color: #666; border-top: 1px solid #ccc; padding-top: 0.5rem; margin-top: 2rem; }
}
