/* ==========================================================
   FACTORY PAGE
   Loaded only by Views/Factory/Index.cshtml via ~/bundles/factory-css.
   Site-wide components stay in style.css / mobile_style.css.
   ========================================================== */

/* ---- Intro: "OEM | ODM" box ----
   Outline drawn after the original artwork: top-left corner cut and a raised notch in the middle of the bottom
   edge. ::before is the black outline, ::after the white fill inset by --line (its corner cut is shortened by
   (2 - √2) × --line so the diagonal is as thick as the straight edges). */
.factory-intro {
    --line: 3px;
    --cut: 64px;
    --notch-from: 43.4%;
    --notch-to: 84.4%;
    --notch-depth: 40px;
    --notch-run: 64px;
    position: relative;
    isolation: isolate;
    padding: 48px clamp(24px, 6vw, 96px) calc(var(--notch-depth) + 40px);
    filter: drop-shadow(-4px 5px 5px rgba(0, 0, 0, 0.35));
}

.factory-intro::before,
.factory-intro::after {
    position: absolute;
    z-index: -1;
    content: "";
    clip-path: polygon(
        var(--corner) 0, 100% 0, 100% 100%,
        var(--notch-to) 100%,
        calc(var(--notch-to) - var(--notch-run)) calc(100% - var(--notch-depth)),
        calc(var(--notch-from) + var(--notch-run)) calc(100% - var(--notch-depth)),
        var(--notch-from) 100%,
        0 100%, 0 var(--corner));
}

.factory-intro::before {
    --corner: var(--cut);
    inset: 0;
    background-color: #111;
}

.factory-intro::after {
    --corner: calc(var(--cut) - var(--line) * 0.586);
    inset: var(--line);
    background-color: #fff;
}

.factory-intro__title {
    margin: 0 0 32px;
    color: #dcbc6e;
    font-family: "Sui Generis", Arial, sans-serif;
    font-size: clamp(32px, 4vw, 56px);
    font-weight: 400;
    line-height: 1.1;
    text-align: center;
}

.factory-intro__bar {
    display: inline-block;
    width: 3px;
    height: 0.9em;
    margin: 0 0.35em;
    vertical-align: -0.08em;
    background-color: currentColor;
}

.factory-intro p {
    margin: 0 0 20px;
    color: #222;
    font-size: 18px;
    line-height: 1.6;
}

/* Four illustrations; each image already holds its label and its up / down offset. */
.factory-strengths {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 32px;
    margin-bottom: 0;
    padding: 0;
    list-style: none;
}

.factory-strengths__img {
    display: block;
    width: 100%;
    height: auto;
}

/* ---- Product tabs ----
   One white artwork per product (600x146). Selected = the same art inverted (identical to the designer's black
   version); hover = the art multiplied over a grey gradient (identical to the "_d" version). clip-path repeats the
   artwork's 38px corner cut so neither colour shows outside it. */
.factory-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 32px;
}

.factory-tab {
    position: relative;
    isolation: isolate;
    display: block;
    padding: 0;
    border: 0;
    background: none;
    clip-path: polygon(6.33% 0, 100% 0, 100% 100%, 0 100%, 0 26.03%);
    cursor: pointer;
}

.factory-tab__img {
    display: block;
    width: 100%;
    height: auto;
}

.factory-tab.is-active .factory-tab__img {
    filter: invert(1);
}

@media (hover: hover) {
    .factory-tab:not(.is-active):hover {
        background: linear-gradient(90deg, #b4b4b4, #bfbfbf 40%, #c9c9c9 60%, #dcdcdc 80%, #fff);
    }

    .factory-tab:not(.is-active):hover .factory-tab__img {
        mix-blend-mode: multiply;
    }
}

/* clip-path would cut off an outline, so the focus ring is drawn inside. */
.factory-tab:focus-visible::after {
    position: absolute;
    inset: 0;
    border: 3px solid #ffed00;
    content: "";
}

.factory-panel:not(.is-active) {
    display: none;
}

/* ---- Production steps: two staggered columns, each overlapping the one before ---- */
.factory-steps {
    margin: 48px 0 0;
    padding: 0;
    list-style: none;
}

.factory-step {
    width: calc(50% - 24px);
}

.factory-step:nth-child(even) {
    margin-left: auto;
}

.factory-step + .factory-step {
    margin-top: -16%; /* of the list width: pulls each step up beside the previous one's video */
}

/* Title and text line up with the video window inside the frame (4.6% in). */
.factory-step__title {
    margin: 0;
    padding: 0 4.6%;
    color: #111;
    font-family: "Sui Generis", Arial, sans-serif;
    font-size: clamp(22px, 2.2vw, 30px);
    font-weight: 400;
    line-height: 1.2;
}

.factory-step__title b {
    margin-right: 0.6em;
    color: #dcbc6e;
    font-weight: 400;
}

.factory-step__text {
    margin: 10px 0 0;
    padding: 0 4.6%;
    color: #333;
    font-size: 16px;
    line-height: 1.6;
}

/* ---- Framed video ----
   The frame PNG is white outside a transparent window, so it masks the poster / clip underneath.
   Poster and clip fill the area covered by every frame's window (the union of the ten). */
.factory-video {
    position: relative;
    margin-top: 8px;
    aspect-ratio: 790 / 530;
}

.factory-video__poster,
.factory-video__clip {
    position: absolute;
    top: 8.3%;
    left: 4.6%;
    width: 90.8%;
    height: 83.4%;
    object-fit: cover;
}

.factory-video__poster {
    background-color: #ddd;
}

.factory-video__frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Play / pause button, only when the clip does not autoplay (reduced motion, data saver, autoplay blocked). */
.factory-video__toggle {
    position: absolute;
    top: 50%;
    left: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    font-size: 30px;
    background-color: rgba(17, 17, 17, 0.6);
    transform: translate(-50%, -50%);
    cursor: pointer;
}

.factory-video.is-manual .factory-video__toggle {
    display: flex;
}

.factory-video__toggle .bi-pause-fill,
.factory-video.is-playing .factory-video__toggle .bi-play-fill {
    display: none;
}

.factory-video.is-playing .factory-video__toggle .bi-pause-fill {
    display: inline;
}

/* While playing, the button only shows on hover / focus (it stays tappable). */
.factory-video.is-playing .factory-video__toggle {
    opacity: 0;
}

.factory-video.is-playing:hover .factory-video__toggle,
.factory-video__toggle:focus-visible {
    opacity: 1;
}

.factory-video__toggle:focus-visible {
    outline: 3px solid #ffed00;
    outline-offset: 2px;
}

/* ==========================================================
   Factory page: responsive
   ========================================================== */
@media (max-width: 991.98px) {
    /* One column. */
    .factory-step,
    .factory-step:nth-child(even) {
        width: 100%;
        max-width: 640px;
        margin-right: auto;
        margin-left: auto;
    }

    .factory-step + .factory-step {
        margin-top: 48px;
    }
}

@media (max-width: 767.98px) {
    /* Proportions of the phone artwork. */
    .factory-intro {
        --cut: 36px;
        --notch-from: 26.5%;
        --notch-to: 74%;
        --notch-depth: 24px;
        --notch-run: 32px;
        padding-top: 36px;
    }

    .factory-intro p {
        font-size: 15px;
    }

    .factory-strengths {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px 16px;
    }

    .factory-step__text {
        font-size: 15px;
    }
}

@media (max-width: 575.98px) {
    /* One button per row so the label inside the artwork stays readable. */
    .factory-tabs {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}
