/* ==========================================================================
   DRA Framework — design system
   Modern dashboard layout: dark sidebar + light content + soft-shadow cards.
   ========================================================================== */

/* ----- Tokens ------------------------------------------------------------- */
:root {
    /* brand */
    --brand: #21949c;
    --brand-600: #1a767c;
    --brand-700: #145d62;
    --brand-50:  #e6f6f7;

    /* neutrals (light theme) */
    --bg:        #f6f7f9;
    --surface:   #ffffff;
    --surface-2: #fafbfc;
    --ink:       #0f172a;
    --ink-2:     #334155;
    --muted:     #64748b;
    --line:      #e5e7eb;
    --line-2:    #eef0f3;

    /* sidebar (always dark, both themes) */
    --side-bg:   #0f172a;
    --side-bg-2: #111c33;
    --side-ink:  #e2e8f0;
    --side-muted:#94a3b8;
    --side-line: #1e293b;
    --side-hover:#1e293b;
    --side-active:#21949c;

    /* feedback */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow:    0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);

    /* metrics */
    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;
    --side-w:    260px;

    /* type */
    --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
    --bg:        #0b1220;
    --surface:   #111827;
    --surface-2: #0f172a;
    --ink:       #e5e7eb;
    --ink-2:     #cbd5e1;
    --muted:     #94a3b8;
    --line:      #1f2937;
    --line-2:    #192033;
    --brand-50:  rgba(33, 148, 156, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow:    0 1px 3px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

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

html, body { height: 100%; }
html { scroll-behavior: smooth; background: var(--bg); }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; display: block; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-600); text-decoration: underline; }

h1, h2, h3, h4, h5 {
    margin: 0 0 0.4em;
    color: var(--ink);
    font-weight: 600;
    letter-spacing: -0.01em;
}

p { margin: 0 0 0.8em; color: var(--ink-2); }
small { color: var(--muted); }

button { font: inherit; cursor: pointer; }

/* ----- App layout --------------------------------------------------------- */
.app {
    display: grid;
    grid-template-columns: var(--side-w) 1fr;
    min-height: 100vh;
}

/* ----- Sidebar ------------------------------------------------------------ */
.sidebar {
    background: var(--side-bg);
    color: var(--side-ink);
    padding: 22px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    border-right: 1px solid var(--side-line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 6px 14px;
    border-bottom: 1px solid var(--side-line);
}
.brand img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 2px var(--brand);
}
.brand .brand-name {
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    font-size: 15px;
    line-height: 1.2;
}
.brand .brand-tag {
    color: var(--side-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 2px;
}

.side-section-title {
    color: var(--side-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin: 8px 8px 6px;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--side-ink);
    font-size: 13.5px;
    text-decoration: none;
    line-height: 1.35;
    transition: background 0.15s ease, color 0.15s ease;
}
.side-nav a:hover {
    background: var(--side-hover);
    color: #fff;
    text-decoration: none;
}
.side-nav a.active {
    background: rgba(33, 148, 156, 0.18);
    color: #fff;
    box-shadow: inset 2px 0 0 var(--side-active);
}
.side-nav .icon {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    color: var(--side-muted);
}
.side-nav a:hover .icon,
.side-nav a.active .icon { color: var(--brand); }

.side-author {
    margin-top: auto;
    padding: 14px 10px;
    border-top: 1px solid var(--side-line);
    display: flex;
    align-items: center;
    gap: 10px;
}
.side-author img {
    width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
}
.side-author .name { color: #fff; font-size: 13px; font-weight: 600; }
.side-author .role { color: var(--side-muted); font-size: 11px; }

.theme-toggle {
    margin: 4px 8px 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: var(--side-bg-2);
    border: 1px solid var(--side-line);
    color: var(--side-ink);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    width: max-content;
}
.theme-toggle:hover { background: var(--side-hover); color: #fff; }

/* ----- Main content ------------------------------------------------------- */
.main {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 28px;
    padding: 28px 32px 60px;
}

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

.page-header {
    margin-bottom: 22px;
}
.page-header h1 {
    font-size: 22px;
    margin: 0 0 4px;
}
.page-header p {
    color: var(--muted);
    margin: 0;
    font-size: 14px;
}

/* ----- Card grid ---------------------------------------------------------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: #d7dde6;
}
[data-theme="dark"] .card:hover { border-color: #2b3550; }

.card-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--brand);
    font-weight: 600;
}
.card-title {
    font-size: 16px;
    line-height: 1.3;
    margin: 0;
    color: var(--ink);
}
.card-date {
    color: var(--muted);
    font-size: 12px;
}
.card-text {
    color: var(--ink-2);
    font-size: 13.5px;
    margin: 0;
    flex: 1;
}
.card-footer {
    margin-top: 6px;
    display: flex;
    justify-content: flex-end;
}

/* ----- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.btn-primary:hover {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
}
.btn-ghost {
    background: transparent;
    color: var(--ink);
    border-color: var(--line);
}
.btn-ghost:hover { background: var(--surface-2); border-color: #d7dde6; }
.btn .icon { width: 14px; height: 14px; }

/* ----- Aside column (publications, panels) -------------------------------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 16px 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}
.panel-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin: 0 0 10px;
    font-weight: 600;
}
.panel-group { margin-bottom: 14px; }
.panel-group:last-child { margin-bottom: 0; }
.panel-group h4 {
    font-size: 12.5px;
    color: var(--brand);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 6px;
    font-weight: 700;
}
.pub-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pub-list li {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 12.5px;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.pub-list li:hover { border-color: var(--brand); background: var(--brand-50); }
.pub-list a {
    color: var(--ink);
    flex: 1;
    line-height: 1.35;
}
.pub-list a:hover { color: var(--brand); text-decoration: none; }
.pill {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--brand-50);
    color: var(--brand-700);
    flex: 0 0 auto;
}
[data-theme="dark"] .pill { color: var(--brand); }

/* ----- Author panel (right aside compact) --------------------------------- */
.author-panel { text-align: left; }
.author-panel .author-head {
    display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.author-panel .author-head img {
    width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
}
.author-panel .author-head .name { font-weight: 600; color: var(--ink); font-size: 14px; }
.author-panel .author-head .role { color: var(--muted); font-size: 12px; }
.author-socials {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.author-socials a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--line-2);
    color: var(--ink-2);
    transition: all 0.15s ease;
}
.author-socials a:hover {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.author-socials .icon { width: 16px; height: 16px; }

/* ----- Lightbox (PNG viewer) --------------------------------------------- */
.lightbox {
    position: fixed; inset: 0;
    background: rgba(7, 12, 22, 0.78);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}
.lightbox.open { opacity: 1; pointer-events: auto; }
.lightbox-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: min(1100px, 92vw);
    max-height: 92vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.lightbox-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
}
.lightbox-head h3 { margin: 0; font-size: 16px; }
.lightbox-close {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink-2);
    border-radius: var(--radius-sm);
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: var(--surface-2); color: var(--ink); }
.lightbox-body {
    overflow: auto;
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.lightbox-body img { max-width: 100%; max-height: 78vh; border-radius: var(--radius-sm); }

/* ----- Footer ------------------------------------------------------------- */
.app-footer {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    margin-top: 30px;
    padding: 16px 0 0;
    color: var(--muted);
    font-size: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    justify-content: space-between;
    align-items: center;
}
.app-footer .version {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 2px 8px;
    border-radius: 999px;
}
.app-footer .copy {
    color: #9aa0a6;
    font-size: 11px;
}

/* ----- DRA instance pages (dra1/dra2) ------------------------------------ */
.dra-page {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 280px;
    gap: 24px;
    padding: 28px 32px 60px;
}
.dra-page > .toc { position: sticky; top: 28px; align-self: start; }
.dra-page > .center { min-width: 0; }
.dra-page .figure {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}
.dra-page .figure img { border-radius: var(--radius-sm); margin: 0 auto; }
.dra-page .figure-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--brand);
    font-weight: 700;
    margin: 0 0 10px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.data-table th, .data-table td {
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line-2);
    vertical-align: top;
}
.data-table thead th {
    background: var(--surface-2);
    color: var(--ink);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }

/* ----- Mobile ------------------------------------------------------------- */
@media (max-width: 1100px) {
    .main { grid-template-columns: 1fr; }
    .aside { order: 2; }
    .dra-page { grid-template-columns: 1fr; }
    .dra-page > .toc { position: static; }
}
@media (max-width: 800px) {
    :root { --side-w: 100%; }
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: static; height: auto; flex-direction: row;
        flex-wrap: wrap; gap: 8px;
        padding: 12px 16px;
    }
    .side-section-title, .side-author { display: none; }
    .side-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
    .side-nav a { padding: 6px 10px; }
    .brand { padding: 0; border: 0; margin-right: auto; }
    .brand .brand-tag { display: none; }
    .main { padding: 18px 16px 40px; }
    .dra-page { padding: 18px 16px 40px; }
}
