/**
 * Daily Tips — dashboard card, archive page and card viewer
 */

/* ---------- Category badges added with the 2027 tip packs ---------- */
.note-category-badge.equipment     { background: rgba(234, 179, 8, 0.15);  color: #eab308; border: 1px solid rgba(234, 179, 8, 0.28); }
.note-category-badge.physiology    { background: rgba(34, 197, 94, 0.15);  color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.25); }
.note-category-badge.regional      { background: rgba(99, 102, 241, 0.15); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.28); }
.note-category-badge.medicine      { background: rgba(244, 63, 94, 0.13);  color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.25); }
.note-category-badge.surgery       { background: rgba(14, 165, 233, 0.15); color: #38bdf8; border: 1px solid rgba(14, 165, 233, 0.25); }
.note-category-badge.perioperative { background: rgba(168, 162, 158, 0.15); color: #a8a29e; border: 1px solid rgba(168, 162, 158, 0.28); }

[data-theme="light"] .note-category-badge.equipment     { background: rgba(234, 179, 8, 0.14); color: #a16207; }
[data-theme="light"] .note-category-badge.physiology    { background: rgba(34, 197, 94, 0.12); color: #15803d; }
[data-theme="light"] .note-category-badge.regional      { background: rgba(99, 102, 241, 0.12); color: #4f46e5; }
[data-theme="light"] .note-category-badge.medicine      { background: rgba(244, 63, 94, 0.10); color: #be123c; }
[data-theme="light"] .note-category-badge.surgery       { background: rgba(14, 165, 233, 0.12); color: #0369a1; }
[data-theme="light"] .note-category-badge.perioperative { background: rgba(120, 113, 108, 0.12); color: #57534e; }

/* ---------- Shared tip content ---------- */
.dt-no {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.dt-kicker {
    margin: 0 0 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-blue);
    line-height: 1.4;
}

.dt-content {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
    overflow-wrap: break-word;
}

.dt-content b,
.dt-content strong {
    color: var(--text-primary);
    font-weight: 650;
}

.dt-content sub,
.dt-content sup {
    font-size: 0.72em;
    line-height: 0;
}

.dt-p {
    margin: 0 0 10px;
}

.dt-p:last-child {
    margin-bottom: 0;
}

.dt-alert {
    display: inline-block;
    margin-bottom: 8px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.6875rem;
    font-weight: 650;
}

.dt-alert--clinical {
    background: rgba(239, 68, 68, 0.14);
    color: #f87171;
}

.dt-alert--board {
    background: rgba(59, 130, 246, 0.14);
    color: #60a5fa;
}

[data-theme="light"] .dt-alert--clinical { color: #b91c1c; background: rgba(239, 68, 68, 0.10); }
[data-theme="light"] .dt-alert--board    { color: #1d4ed8; background: rgba(59, 130, 246, 0.10); }

.dt-chips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.dt-chip {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    font-size: 0.75rem;
    line-height: 1.35;
}

.dt-chip span {
    color: var(--text-muted);
}

.dt-chip strong {
    color: var(--text-primary);
    font-size: 0.875rem;
}

.dt-steps {
    list-style: none;
    counter-reset: dt-step;
    margin: 0;
    padding: 0;
}

.dt-steps li {
    counter-increment: dt-step;
    position: relative;
    padding-left: 32px;
    margin-bottom: 10px;
}

.dt-steps li:last-child {
    margin-bottom: 0;
}

.dt-steps li::before {
    content: counter(dt-step);
    position: absolute;
    left: 0;
    top: 1px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}

.dt-steps li strong {
    display: block;
}

.dt-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.dt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.dt-table th,
.dt-table td {
    padding: 7px 9px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border-color);
}

.dt-table tr:last-child th,
.dt-table tr:last-child td {
    border-bottom: 0;
}

.dt-table thead th {
    background: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 650;
}

.dt-table tbody th {
    color: var(--text-primary);
    font-weight: 600;
    width: 32%;
}

.dt-note {
    margin-top: 12px;
}

.screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

/* ---------- Buttons ---------- */
.dt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-hover);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.dt-btn:hover {
    border-color: var(--accent-blue);
}

.dt-btn--primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
}

.dt-btn--primary:hover {
    background: #2563eb;
    color: #fff;
}

.dt-btn:focus-visible,
.dt-filter:focus-visible,
.dt-tile:focus-visible,
.dt-today-card:focus-visible,
.dt-viewer-close:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.dt-btn[disabled] {
    opacity: 0.4;
    cursor: default;
}

/* ---------- Dashboard card ---------- */
.tip-note-card.is-card-tip {
    justify-content: flex-start;
}

.tip-note-card.is-card-tip .note-title {
    margin-bottom: 6px;
}

.dt-content--compact {
    font-size: 0.8125rem;
    line-height: 1.55;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    margin-bottom: 12px;
}

.dt-content--compact.is-clipped {
    -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent);
    mask-image: linear-gradient(to bottom, #000 78%, transparent);
}

.dt-content--compact .dt-steps span {
    display: block;
}

.dt-content--compact .dt-steps li {
    margin-bottom: 6px;
    padding-left: 28px;
}

.dt-content--compact .dt-steps li::before {
    width: 19px;
    height: 19px;
    line-height: 19px;
    font-size: 0.6875rem;
}

.dt-content--compact .dt-table {
    font-size: 0.75rem;
}

.dt-content--compact .dt-table th,
.dt-content--compact .dt-table td {
    padding: 5px 7px;
}

.dt-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* ---------- Archive page ---------- */
.daily-tips-page .main-content,
.daily-tips-main {
    display: block;
    flex: 1;
    min-width: 0;
    height: 100vh;
    overflow-y: auto;
    box-sizing: border-box;
    position: relative;
    padding: 0;
}

.dt-desktop-header {
    position: absolute;
    top: 24px;
    right: 32px;
    z-index: 5;
}

.dt-mobile-header {
    display: none;
}

.dt-page {
    box-sizing: border-box;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 40px 32px 64px;
}

.dt-intro {
    max-width: 640px;
    margin-bottom: 24px;
}

.dt-heading {
    margin: 0 0 6px;
    font-size: 2rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.15;
}

.dt-lede {
    margin: 0;
    font-size: 1rem;
    color: var(--text-secondary);
}

.dt-toolbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 28px;
}

.dt-search {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 420px;
    padding: 0 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
}

.dt-search:focus-within {
    border-color: var(--accent-blue);
}

.dt-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 0.9375rem;
    padding: 10px 0;
}

.dt-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.dt-filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 550;
    cursor: pointer;
}

.dt-filter span {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.dt-filter:hover {
    color: var(--text-primary);
}

.dt-filter.is-active {
    background: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--bg-primary);
}

.dt-filter.is-active span {
    color: inherit;
    opacity: 0.7;
}

/* Today */
.dt-today {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
    padding: 24px;
    margin-bottom: 40px;
    border-radius: var(--radius-xl);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.dt-today-card {
    display: block;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 9 / 16;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.dt-today-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dt-today-label {
    margin: 0 0 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent-blue);
}

.dt-today-title {
    margin: 0 0 14px;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-primary);
    max-width: 30ch;
}

.dt-today-body .dt-content {
    max-width: 68ch;
}

.dt-today-body .dt-card-actions {
    border-top: 0;
    padding-top: 18px;
}

/* Grid */
.dt-section-title {
    margin: 0 0 16px;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dt-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 24px 18px;
}

.dt-grid-item[hidden] {
    display: none;
}

.dt-tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.dt-tile-img {
    display: block;
    aspect-ratio: 9 / 16;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dt-tile-img img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dt-tile:hover .dt-tile-img {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.dt-tile-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.dt-tile-meta .note-category-badge {
    font-size: 0.5625rem;
    padding: 2px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 62%;
}

.dt-tile-meta time {
    white-space: nowrap;
}

.dt-tile-title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dt-empty {
    margin: 24px 0;
    color: var(--text-secondary);
}

/* ---------- Viewer ---------- */
.dt-viewer {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.dt-viewer[hidden] {
    display: none;
}

.dt-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 10, 18, 0.72);
    backdrop-filter: blur(4px);
}

.dt-viewer-panel {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    width: min(1040px, 100%);
    max-height: calc(100vh - 48px);
    border-radius: var(--radius-xl);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.dt-viewer--image-only .dt-viewer-panel {
    grid-template-columns: auto;
    width: auto;
}

.dt-viewer--image-only .dt-viewer-body {
    display: none;
}

.dt-viewer-image {
    background: #0b1530;
    display: flex;
}

.dt-viewer-image img {
    display: block;
    height: min(calc(100vh - 48px), 900px);
    width: auto;
    aspect-ratio: 9 / 16;
    object-fit: contain;
}

.dt-viewer-body {
    display: flex;
    flex-direction: column;
    padding: 28px 28px 24px;
}

.dt-viewer-body > .note-header {
    padding-right: 44px;
    overflow-y: auto;
    min-height: 0;
}

.dt-viewer-title {
    margin: 0 0 14px;
    font-size: 1.375rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
    padding-right: 32px;
}

.dt-viewer-lesson {
    margin: 18px 0 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.dt-viewer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
    padding-top: 20px;
}

.dt-viewer-actions .dt-btn--primary {
    margin-left: auto;
}

.dt-viewer-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
}

body.dt-viewer-open {
    overflow: hidden;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .dt-desktop-header {
        display: none;
    }

    .dt-mobile-header {
        display: block;
        position: sticky;
        top: 0;
        z-index: 5;
        padding: 10px 16px;
        min-height: 50px;
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border-color);
    }

    .dt-mobile-header .mobile-header-actions {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: relative;
    }

    .dt-mobile-header .mobile-header-logo {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    .dt-mobile-header .mobile-logo-image {
        max-width: 38px;
        max-height: 38px;
    }

    .dt-page {
        padding: 24px 16px 48px;
    }

    .dt-heading {
        font-size: 1.625rem;
    }

    .dt-today {
        grid-template-columns: 120px minmax(0, 1fr);
        gap: 16px;
        padding: 16px;
    }

    .dt-today-title {
        font-size: 1.125rem;
    }

    .dt-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        margin: 0 -16px;
        padding: 0 16px 4px;
        scrollbar-width: none;
    }

    .dt-filter {
        flex-shrink: 0;
    }

    .dt-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 20px 12px;
    }

    .dt-viewer {
        padding: 0;
        align-items: stretch;
    }

    .dt-viewer-panel {
        grid-template-columns: 1fr;
        width: 100%;
        max-height: none;
        height: 100%;
        border-radius: 0;
        overflow-y: auto;
        align-content: start;
        padding-top: 56px;
        box-sizing: border-box;
    }

    .dt-viewer-close {
        position: fixed;
        top: 9px;
        right: 12px;
    }

    .dt-viewer-body > .note-header {
        padding-right: 0;
    }

    .dt-viewer--image-only .dt-viewer-panel {
        background: #0b1530;
        align-content: center;
    }

    .dt-viewer-image {
        justify-content: center;
    }

    .dt-viewer-image img {
        width: 100%;
        height: auto;
        max-height: none;
    }

    .dt-viewer-body {
        overflow: visible;
        padding: 20px 16px 28px;
    }
}

@media (max-width: 560px) {
    .dt-today {
        grid-template-columns: 1fr;
    }

    .dt-today-card {
        width: 150px;
    }

    .dt-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .dt-tile-img,
    .dt-btn {
        transition: none;
    }

    .dt-tile:hover .dt-tile-img {
        transform: none;
    }
}
