/* Dark mode override layer.
   Activated by [data-theme="dark"] on <html>. Overrides only the surfaces the
   templates actually use. The vendored material.css is never edited; its utility
   classes use !important, so the overrides below do too where needed. */

/* IMPORTANT: djibe Material ships its own dark mode keyed on this same
   [data-theme="dark"] attribute, implemented as a whole page colour inversion:
       html[data-theme='dark'] { filter: invert(1) hue-rotate(180deg); }
   plus a counter inversion on <img>/<video> to make them look normal again.
   That inversion would flip every explicit colour below (dark backgrounds
   become light grey, accents hue shift). We use real, explicit colours
   instead, so cancel Material's inversion entirely. This MUST stay at the
   top, before the colour rules. */
[data-theme="dark"],
[data-theme="dark"] img,
[data-theme="dark"] video,
[data-theme="dark"] .prevent-dark-theme {
    -webkit-filter: none !important;
    filter: none !important;
}

[data-theme="dark"] {
    --dk-bg: #1e1e1e;          /* page background */
    --dk-surface: #1e1e1e;     /* content / modal surface */
    --dk-surface-2: #262626;   /* raised surface */
    --dk-surface-3: #2f2f2f;   /* badges, filled light buttons */
    --dk-text: rgba(255, 255, 255, 0.87);
    --dk-text-2: rgba(255, 255, 255, 0.60);
    --dk-border: rgba(255, 255, 255, 0.14);
    --dk-link: #b388ff;        /* purple links */
    --dk-link-hover: #cdb4ff;
}

/* Base surfaces */

[data-theme="dark"] body {
    background-color: var(--dk-bg) !important;
    color: var(--dk-text) !important;
}

/* Side drawer (the about me panel): a touch darker than the page so it reads
   as its own surface. */
[data-theme="dark"] .navdrawer-content {
    background-color: #1a1a1a !important;
    color: var(--dk-text) !important;
}

[data-theme="dark"] .navdrawer-divider {
    background-color: var(--dk-border) !important;
}

/* The drawer header behind the profile picture is hardcoded light grey. */
[data-theme="dark"] .navdrawer-header {
    background-color: #1a1a1a !important;
    border-bottom-color: var(--dk-border) !important;
}

/* Links */

[data-theme="dark"] a,
[data-theme="dark"] a:visited {
    color: var(--dk-link);
}

[data-theme="dark"] a:hover {
    color: var(--dk-link-hover);
}

/* main.css pins the home title link to black; lift it to the light text colour. */
[data-theme="dark"] a:link.main-title {
    color: var(--dk-text) !important;
}

/* Keep buttons rendered as links readable: button classes manage their own colour. */
[data-theme="dark"] a.btn {
    color: inherit;
}

/* Buttons */

/* Default and shaped buttons (expertise filters, Awards, Talks, Certificates,
   Papers) inherit Material's near black text; default them to light. The
   coloured variants below keep their own colours. */
[data-theme="dark"] .btn {
    color: var(--dk-text);
}

/* The active expertise filter darkens via a black gradient, invisible on a
   dark page; lighten it instead. */
[data-theme="dark"] .btn.active {
    background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.16));
}

/* Round buttons (expertise filters, Awards, Talks, Certificates, Papers):
   Material's black elevation shadows disappear on the dark page, leaving flat
   black pills. Swap them for a soft white glow plus a thin outline. The
   outline is a box-shadow ring rather than a real border: Material buttons
   are built with border: 0 and a fixed height, so a real border shrinks the
   content box and knocks the label off vertical centre (visible on the
   <input type="submit"> expertise filters). !important is required to beat
   .shadow-4 and the hover elevation shadows. The btn-outline-dark project
   buttons already look right, so leave them alone. */
[data-theme="dark"] .btn-shaped:not(.btn-outline-dark) {
    box-shadow: 0 0 0 1px var(--dk-border), 0 0 6px rgba(255, 255, 255, 0.25) !important;
}

[data-theme="dark"] .btn-shaped:not(.btn-outline-dark):hover,
[data-theme="dark"] .btn-shaped:not(.btn-outline-dark):focus {
    background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08));
}

/* btn-outline-dark (project link buttons) is invisible on a dark surface;
   invert to a light outline. */
[data-theme="dark"] .btn-outline-dark {
    color: var(--dk-text) !important;
    border-color: var(--dk-border) !important;
}

[data-theme="dark"] .btn-outline-dark:hover,
[data-theme="dark"] .btn-outline-dark:focus {
    background-color: var(--dk-text) !important;
    border-color: var(--dk-text) !important;
    color: #121212 !important;
}

/* btn-dark (Photography and Drums buttons): stay dark, but as a slightly
   raised surface with the same white glow and outline as the round buttons.
   The outline is a box-shadow ring for the same reason as above. */
[data-theme="dark"] .btn-dark {
    background-color: var(--dk-surface-3) !important;
    color: var(--dk-text) !important;
    box-shadow: 0 0 0 1px var(--dk-border), 0 0 6px rgba(255, 255, 255, 0.25) !important;
}

[data-theme="dark"] .btn-dark:hover,
[data-theme="dark"] .btn-dark:focus,
[data-theme="dark"] .btn-dark:active {
    background-color: #3a3a3a !important;
    color: var(--dk-text) !important;
}

/* Badges (project technologies): keep them as subtle raised chips. */
[data-theme="dark"] .badge-dark {
    background-color: var(--dk-surface-3) !important;
    color: var(--dk-text) !important;
}

/* Image frames use Bootstrap's light grey .border; dim it. */
[data-theme="dark"] .border {
    border-color: var(--dk-border) !important;
}

/* Social icons (GitHub, LinkedIn, email) are black translucent PNGs, nearly
   invisible on the dark drawer. Give them an even white glow (zero offset on
   both axes). drop-shadow follows the icon's shape, unlike box-shadow.
   !important is required to beat the inversion cancelling rule at the top.
   :not(.img-frame) keeps the competency icons out of this rule. */
[data-theme="dark"] .social-icons:not(.img-frame) {
    -webkit-filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.75)) !important;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.75)) !important;
}

/* Portfolio and modal pictures: an even white glow on all sides. */
[data-theme="dark"] .img-frame.border {
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.30);
}

/* Modals (Awards, Talks, Certificates, Papers) */

[data-theme="dark"] .modal-content {
    background-color: var(--dk-surface) !important;
    color: var(--dk-text) !important;
}

/* Material hardcodes dark secondary text on the modal body, which the
   inherited light colour above cannot reach. */
[data-theme="dark"] .modal-body {
    color: var(--dk-text) !important;
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: var(--dk-border) !important;
}

[data-theme="dark"] .close {
    color: var(--dk-text) !important;
    text-shadow: none !important;
}

/* Misc */

[data-theme="dark"] hr {
    border-top-color: var(--dk-border) !important;
}

[data-theme="dark"] ::selection {
    color: #121212;
    background-color: #bbbbbb;
}
