/*------------------------------------------------------------------
  upgrades.css - local enhancements layered on top of style.css
  Kept in a separate file on purpose: style.css is compiled from
  assets/scss/style.scss, so a sass rebuild would overwrite anything
  added there. Nothing here depends on the sass build.

  1. Light theme base
  2. Uniform card media
  3. Card + link polish
  4. Header / nav
  5. Theme toggle button
  6. Scroll progress bar
  7. Accessibility & motion
-------------------------------------------------------------------*/

/* ----------------------------------------------------------------
   1. Light theme base
   style.css ships 55 `.white-theme <child>` rules but never sets the
   page surface itself, so the light variant had no background. The
   class is applied to <html> (pre-paint, see index.html) which keeps
   every existing descendant selector working.
-------------------------------------------------------------------*/
html.white-theme,
html.white-theme body.dark-bg {
    background: #eef1f5;
    color: #4a4a4a;
}

/* Only the elements style.css leaves uncovered are restated here.
   Nav links, .home-intro h2, .section-heading h3 and the footer already
   have their own `.white-theme` rules upstream - don't duplicate them. */
html.white-theme .about-text h3,
html.white-theme .exp-box h5 {
    color: #1d1d1f;
}

html.white-theme .home-intro p,
html.white-theme .about-text p,
html.white-theme .section-heading p,
html.white-theme .exp-box span,
html.white-theme figcaption {
    color: #55555c;
}

/* The wordmark is flat light cyan (luminance ~202/255), so it all but
   disappears on a light surface. Darken it rather than swap the asset. */
html.white-theme .navbar-brand img {
    filter: brightness(0.55) saturate(1.3);
}

/* the decorative gradient blobs are tuned for a black page */
html.white-theme .right-effects,
html.white-theme .left-effects {
    opacity: 0.35;
}

/* ----------------------------------------------------------------
   2. Uniform card media
   .work-img had no rule at all, so every carousel thumbnail rendered
   at its own intrinsic aspect ratio - hence the ragged card heights.
   A fixed ratio also reserves the space before the (now lazy) image
   arrives, which is what keeps layout shift at zero.
-------------------------------------------------------------------*/
/* REQUIRED companion to the width/height attributes now on every <img>.
   style.css caps image width at 100% but never resets height, so a
   declared height attribute is taken literally and stretches the image
   vertically. Reset it once here; the sized rules below override it. */
img {
    height: auto;
}

.work-box .work-img {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
}

.work-box .work-img img,
.owl-carousel .owl-item .work-box .work-img img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    /* top-anchored so document screenshots keep their titles visible
       and portrait photos keep faces in frame */
    object-position: center top;
    transition: transform 0.5s ease;
}

.work-box:hover .work-img img {
    transform: scale(1.04);
}

/* The theme leaves .about-img img completely unsized, so it rendered at
   its intrinsic pixel width inside a much smaller circular frame and got
   cropped to whatever sat in the middle. Make it fill the frame instead. */
.about-section .about-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* reference headshots: square, so the circular mask never distorts */
.feature-box-03 .feature-img img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: center top;
}

/* ----------------------------------------------------------------
   3. Card + link polish
-------------------------------------------------------------------*/
/* .feature-content carries Bootstrap's .col but its parent is a flex box
   rather than a .row, so it inherits min-width:auto and refuses to shrink
   below its min-content width - which spills the page into horizontal
   overflow once a heading gets long enough. */
.feature-box-01 .feature-content {
    min-width: 0;
}

.feature-box-01 .feature-content h5,
.feature-box-01 .feature-content p {
    overflow-wrap: break-word;
}

.work-box,
.feature-box-01,
.feature-box-03,
.contact-name-01 {
    transition: transform 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}

.work-box:hover,
.feature-box-01:hover,
.contact-name-01:hover {
    transform: translateY(-6px);
    border-color: rgba(18, 194, 233, 0.55);
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.75);
}

html.white-theme .work-box:hover,
html.white-theme .feature-box-01:hover,
html.white-theme .contact-name-01:hover {
    box-shadow: 0 18px 40px -20px rgba(41, 41, 41, 0.3);
}

/* the contact tiles are wrapped in an anchor - stop it colouring the text */
.contact-name-01 h6,
a:hover .contact-name-01 h6 {
    margin-bottom: 2px;
}

/* several btn-bar rows now hold two links side by side */
.btn-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    align-items: center;
}

/* The one experience entry carrying a company link rendered the anchor
   inline, so it collided with the <small> date on the same line. */
.about-text .about-row .col-6>a {
    display: block;
    margin-bottom: 2px;
}

/* Long unbreakable tokens - "Cybersecurity/ML/NLP/AI" is 202px as one
   unit - sat in a col-6 that is only ~136px wide at 320px viewports and
   pushed the whole page into horizontal scroll. Let them break. */
.about-text .about-row h5,
.about-text .about-row h6,
.about-text .about-row p,
.about-text .about-row a,
.about-text .about-row small {
    overflow-wrap: break-word;
}

/* Pre-existing mobile bug: the three hero stat boxes sat in a flex row
   with no wrap and 35px of side padding each, so on any screen under
   ~430px the third box pushed ~100px past the viewport and the whole
   page scrolled sideways. Let them wrap and tighten the padding. */
.home-section .home-intro .hs-exp {
    flex-wrap: wrap;
    row-gap: 22px;
}

@media (max-width: 575px) {
    .home-section .home-intro .hs-exp .exp-box {
        padding-right: 18px;
    }

    .home-section .home-intro .hs-exp .exp-box+.exp-box {
        padding-left: 18px;
    }

    .home-section .home-intro .hs-exp h5 {
        font-size: 36px;
    }

    .home-section .home-intro .hs-exp span {
        font-size: 12px;
        letter-spacing: 1px;
    }
}

/* ----------------------------------------------------------------
   4. Header / nav
   The nav grew to eight items, so let it wrap gracefully instead of
   overflowing on mid-size desktops.
-------------------------------------------------------------------*/
@media (min-width: 992px) {
    .main-header .navbar-nav {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .main-header .navbar-nav>li>.nav-link {
        white-space: nowrap;
    }
}

/* ----------------------------------------------------------------
   5. Theme toggle button
-------------------------------------------------------------------*/
.theme-toggle {
    -webkit-appearance: none;
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    margin-left: 14px;
    flex: 0 0 auto;
    transition: background 0.3s ease, color 0.3s ease, transform 0.3s ease;
}

.theme-toggle:hover {
    background: #12c2e9;
    border-color: #12c2e9;
    transform: rotate(-18deg);
}

html.white-theme .theme-toggle {
    border-color: rgba(41, 41, 41, 0.18);
    background: rgba(255, 255, 255, 0.6);
    color: #1d1d1f;
}

html.white-theme .theme-toggle:hover {
    color: #fff;
}

/* only one of the two glyphs shows, depending on the active theme */
.theme-toggle .bi-sun {
    display: none;
}

html.white-theme .theme-toggle .bi-sun {
    display: inline-block;
}

html.white-theme .theme-toggle .bi-moon-stars {
    display: none;
}

/* Below lg the hamburger appears and the 319px wordmark can fill the row
   on its own, so absolute positioning collides with one or the other
   depending on width. Keep the toggle in the flex flow instead and just
   order it ahead of the hamburger - then wrapping sorts itself out and
   nothing can overlap at any width. */
@media (max-width: 991px) {
    .theme-toggle {
        position: static;
        order: 2;
        margin-left: auto;
        margin-right: 10px;
    }

    .main-header .navbar-toggler {
        order: 3;
    }

    .main-header .navbar-collapse {
        order: 4;
    }
}

/* ----------------------------------------------------------------
   6. Scroll progress bar
-------------------------------------------------------------------*/
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    transform: scaleX(0);
    transform-origin: 0 50%;
    background: linear-gradient(to right, #12c2e9, #c471ed, #f64f59);
    z-index: 100000;
    pointer-events: none;
    will-change: transform;
}

/* ----------------------------------------------------------------
   7. Accessibility & motion
-------------------------------------------------------------------*/
/* style.css sets `* { outline: none !important }`, which removes the
   keyboard focus ring entirely. Put a visible one back for keyboard
   users without bringing back mouse-click outlines. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #12c2e9 !important;
    outline-offset: 3px;
    border-radius: 4px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100001;
    padding: 12px 20px;
    background: #12c2e9;
    color: #fff;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    left: 0;
    color: #fff;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }

    .work-box:hover .work-img img,
    .work-box:hover,
    .feature-box-01:hover,
    .contact-name-01:hover,
    .theme-toggle:hover {
        transform: none;
    }
}

/* the loader is a full-screen cover; fade it rather than cutting it */
#loading {
    transition: opacity 0.4s ease;
}

#loading.is-hidden {
    opacity: 0;
}
