
/* =========================================
   SCROLL-DRIVEN SVG PRESENTATION
========================================= */

.scroll-presentation {
    --sp-background: #ffffff;
    --sp-text: #252525;
    --sp-accent: #287c91;

    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 4rem;

    /* width: min(100%, var(--theme-normal-container-max-width)); */
    max-width: var(--theme-normal-container-max-width);
    margin: 0 auto;

    background: var(--sp-background);
    color: var(--sp-text);
}

/* =========================================
   VISUAL TRACK
========================================= */

.sp-visual-track {
    grid-column: 1;
    grid-row: 1;

    position: relative;
    min-width: 0;
    align-self: stretch;
}

.sp-visual {
    position: relative;

    width: 100%;
    height: 85vh;
    min-height: 450px;

    display: flex;
    justify-content: center;
    align-items: center;

    overflow: hidden;
}

.sp-visual svg {
    display: block;
    width: 100%;
    max-height: 80vh;
    height: auto;
	contain: layout;
}

/* =========================================
   EXTERNAL SVG LOADING
========================================= */

/* Loading placeholder */

.sp-svg-loading {
    width: 100%;
    height: 100%;
    min-height: 200px;
}

/* Loaded SVG */

.sp-visual svg {
    display: block;
    width: 100%;
    height: auto;
}

/* SVG loading error */

.sp-svg-error {
    padding: 20px;
    text-align: center;
    color: #b00020;
}

/* =========================================
   TEXT CONTENT
========================================= */

.sp-content {
    grid-column: 2;
    grid-row: 1;

    min-width: 0;
}

.sp-content h2 {
    margin-bottom: 1.5rem;
    font-size: clamp(1.8rem, 3vw, 3rem);
    line-height: 1.2;
}

.sp-content p {
    font-size: 1.05rem;
    line-height: 1.8;
}

/* =========================================
   REDUCED MOTION
========================================= */

@media (prefers-reduced-motion: reduce) {
    .scroll-presentation *,
    .scroll-presentation *::before,
    .scroll-presentation *::after {
        scroll-behavior: auto !important;
    }
}

/* =========================================
   DESKTOP PRESENTATION PAGE
   Header + Presentation + Footer
========================================= */


/* =========================================
   BLOCKSY FULL-VIEWPORT PRESENTATION
========================================= */

@media (min-width: 768px) {

    /* Browser viewport */

    body.has-scroll-presentation {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    /* Blocksy's main wrapper */

    body.has-scroll-presentation #main-container {
        height: 100vh;
        height: 100dvh;
        min-height: 0;

        display: flex;
        flex-direction: column;

        overflow: hidden;
    }

    /* Standard Blocksy header */

    #main-container > #header {
        flex: 0 0 auto;
    }

    /* Custom menu, if it is a sibling of #header */

    #main-container > #menu-japan-main-header {
        flex: 0 0 auto;
        position: relative;
        z-index: 100;
    }

    /* Main content */

    #main-container > #main {
        flex: 1 1 0;
        min-height: 0;
        min-width: 0;

        display: flex;
        flex-direction: column;

        overflow: hidden;
    }

    /* Main content container */

    #main > .ct-container,
    #main > .ct-container-full {
        flex: 1 1 0;

        display: flex;
        flex-direction: column;

        width: 100%;
        max-width: none;

        height: 100%;
        min-height: 0;

        padding-top: 0;
        padding-bottom: 0;
    }

    /* Article */

    #main .ct-container > article,
    #main .ct-container-full > article {
        flex: 1 1 0;
        min-height: 0;
    }

    /* WordPress content */

    #main .entry-content {
        height: 100%;
        min-height: 0;
        margin: 0;
    }

    /* Presentation */

    .scroll-presentation {
        position: relative;

        display: grid;

        grid-template-columns:
            minmax(0, 1fr)
            minmax(0, 1fr);

        grid-template-rows: minmax(0, 1fr);

        gap: 2rem;

        width: 100%;
        max-width: var(--theme-normal-container-max-width);

        height: 100%;
        min-height: 0;

        margin: 0 auto;
        padding: 1rem 0;

        box-sizing: border-box;
        overflow: hidden;
    }

    /* SVG column */

    .sp-visual-track {
        grid-column: 1;
        grid-row: 1;

        height: 100%;
        min-height: 0;
    }

    .sp-visual {
        position: relative;

        height: 100%;
        min-height: 0;
        max-height: none;
    }

    .sp-visual svg {
        width: 100%;
        max-width: 100%;
        max-height: 100%;
    }

    /* Text column */

    .sp-content {
        grid-column: 2;
        grid-row: 1;

        height: 100%;
        min-height: 0;
        min-width: 0;

        overflow-y: auto;
        overflow-x: hidden;

        overscroll-behavior-y: contain;
        scrollbar-width: thin;
    }

}

/* =========================================
   MOBILE FIXED-VIEWPORT LAYOUT
========================================= */

@media (max-width: 767px) {

    /* Entire page */

    body.has-scroll-presentation {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    /* Blocksy wrapper */

    body.has-scroll-presentation #main-container {
        height: 100vh;
        height: 100dvh;
        min-height: 0;

        display: flex;
        flex-direction: column;

        overflow: hidden;
    }

    /* Standard header */

    #main-container > #header {
        flex: 0 0 auto;
    }

    /* Custom Japanese menu */

    #main-container > #menu-japan-main-header {
        flex: 0 0 auto;
        position: relative;
        z-index: 100;
    }

    /* Main content */

    #main-container > #main {
        flex: 1 1 0;
        min-height: 0;
        min-width: 0;

        display: flex;
        flex-direction: column;

        overflow: hidden;
    }

    #main > .ct-container,
    #main > .ct-container-full {
        flex: 1 1 0;

        display: flex;
        flex-direction: column;

        width: 100%;
        max-width: none;

        height: 100%;
        min-height: 0;

        padding-top: 0;
        padding-bottom: 0;
    }

    #main .ct-container > article,
    #main .ct-container-full > article {
        flex: 1 1 0;
        min-height: 0;
    }

    #main .entry-content {
        height: 100%;
        min-height: 0;
        margin: 0;
    }

    /* Footer */

    #main-container > #footer {
        flex: 0 0 auto;
    }

    /* =====================================
       COMMON PRESENTATION
    ===================================== */

    .scroll-presentation {
        display: grid;

        width: 100%;
        max-width: var(--theme-normal-container-max-width);

        height: 100%;
        min-height: 0;

        margin: 0 auto;
        padding: 0;

        gap: 0;
        overflow: hidden;

        box-sizing: border-box;
    }

    .sp-visual-track {
        position: relative;
        min-width: 0;
        min-height: 0;

        z-index: 5;
        pointer-events: none;
    }

    .sp-visual {
        position: relative;

        width: 100%;
        height: 100%;
        min-height: 0;
        max-height: none;

        display: flex;
        align-items: center;
        justify-content: center;

        background: var(--sp-background);
    }

    .sp-visual svg {
        display: block;
        width: 90%;
        height: 90%;
        max-width: 100%;
        max-height: 100%;
    }

    .sp-content {
        min-width: 0;
        min-height: 0;

        height: 100%;

        overflow-y: auto;
        overflow-x: hidden;

        overscroll-behavior-y: contain;
    }

    /* =====================================
       LANDSCAPE SVG
       SVG ABOVE TEXT
    ===================================== */

    .scroll-presentation.mobile-landscape {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(130px, 34%) minmax(0, 1fr);
    }

    .mobile-landscape .sp-visual-track {
        grid-column: 1;
        grid-row: 1;
    }

    .mobile-landscape .sp-content {
        grid-column: 1;
        grid-row: 2;
    }

    /* =====================================
       PORTRAIT SVG
       SVG LEFT, TEXT RIGHT
    ===================================== */

    .scroll-presentation.mobile-portrait {
        grid-template-columns: minmax(0, 42%) minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
        column-gap: 0.5rem;
    }

    .mobile-portrait .sp-visual-track {
        grid-column: 1;
        grid-row: 1;
    }

    .mobile-portrait .sp-content {
        grid-column: 2;
        grid-row: 1;
    }

}

@media (max-width: 767px) and (max-height: 700px) {

    .mobile-landscape {
        grid-template-rows: minmax(110px, 28%) minmax(0, 1fr);
    }

    .mobile-portrait {
        grid-template-columns: minmax(0, 38%) minmax(0, 1fr);
    }

}

/* =========================================
   MOBILE DEVICE HELD IN LANDSCAPE
   SVG LEFT, TEXT RIGHT
========================================= */

@media (max-width: 767px) and (orientation: landscape) {

    .scroll-presentation {
        display: grid !important;

        grid-template-columns:
            minmax(0, 38%)
            minmax(0, 1fr) !important;

        grid-template-rows: minmax(0, 1fr) !important;

        column-gap: 0.5rem !important;
        row-gap: 0 !important;
    }

    /* SVG column */

    .scroll-presentation .sp-visual-track {
        grid-column: 1 !important;
        grid-row: 1 !important;

        display: block !important;

        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;
    }

    .scroll-presentation .sp-visual {
        width: 100%;
        height: 100%;
        min-height: 0;

        display: flex;
        align-items: center;
        justify-content: center;
    }

    .scroll-presentation .sp-visual svg {
        display: block !important;

        width: 90%;
        height: 90%;

        max-width: 100%;
        max-height: 100%;
    }

    /* Text column */

    .scroll-presentation .sp-content {
        grid-column: 2 !important;
        grid-row: 1 !important;

        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;

        overflow-y: auto;
        overflow-x: hidden;
    }

}

/* Final overrides keep the illustration beside long-form text at every viewport. */
.scroll-presentation {
    grid-template-columns: var(--sp-visual-width, 50%) minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    column-gap: 1.25rem !important;
    row-gap: 0 !important;
}

.scroll-presentation .sp-visual-track {
    grid-column: 1 !important;
    grid-row: 1 !important;
    min-width: 0;
    min-height: 0;
}

.scroll-presentation .sp-content {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-snap-type: none !important;
    scroll-behavior: auto;
}

.scroll-presentation .sp-content > * {
    scroll-snap-align: none !important;
    scroll-snap-stop: normal !important;
}

.scroll-presentation .sp-visual {
    width: 100%;
    height: 100%;
    min-height: 0;
}

.scroll-presentation .sp-visual svg {
    width: auto !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.sp-navigation {
    display: none !important;
}

.sp-marker {
    display: inline-block;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    vertical-align: baseline;
}

/* Exception: a landscape SVG above the text on a portrait mobile screen uses full width. */
.scroll-presentation.sp-stacked {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(110px, 34%) minmax(0, 1fr) !important;
}

.scroll-presentation.sp-stacked .sp-visual-track {
    grid-column: 1 !important;
    grid-row: 1 !important;
}

.scroll-presentation.sp-stacked .sp-content {
    grid-column: 1 !important;
    grid-row: 2 !important;
}

.scroll-presentation.sp-stacked .sp-visual svg {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

@media (max-width: 767px) and (orientation: portrait) and (max-height: 700px) {
    .scroll-presentation.sp-stacked {
        grid-template-rows: minmax(90px, 28%) minmax(0, 1fr) !important;
    }
}

/* Use the full phone viewport width for the combined SVG and text columns. */
@media (max-width: 767px) {
    .scroll-presentation {
        width: 100vw !important;
        max-width: none !important;
        margin-left: calc(50% - 50vw) !important;
        margin-right: calc(50% - 50vw) !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/*
 * Portal page layouts add two block-group wrappers around presentations.
 * Pass the available viewport height through those wrappers so the SVG and
 * text scroller can size themselves just as they do on an unwrapped page.
 * These constraints only apply when a presentation is present; normal portal
 * pages retain their natural height and document scrolling.
 */
body.has-scroll-presentation .portal-layout {
    height: 100%;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    align-content: stretch;
}

body.has-scroll-presentation .portal-main {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    min-width: 0;
}

body.has-scroll-presentation .portal-main > .scroll-presentation {
    flex: 1 1 0;
    width: 100% !important;
    max-width: none !important;
    height: 100%;
    min-height: 0;
    margin: 0 !important;
}

/* Keep a long desktop sidebar independently scrollable beside the text pane. */
@media (min-width: 769px) {
body.has-scroll-presentation .portal-layout > .portal-sidebar {
        height: 100%;
        max-height: 100%;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        scrollbar-width: thin;
    }

    /* Use normal block flow inside the scrollport to prevent flex shrink/clipping. */
    body.has-scroll-presentation .portal-layout > .portal-sidebar {
        display: block !important;
    }

    body.has-scroll-presentation .portal-layout > .portal-sidebar > .portal-sidebar__toggle {
        display: none !important;
    }

    body.has-scroll-presentation .portal-layout > .portal-sidebar > .portal-sidebar__category {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        height: auto;
        margin-bottom: 0;
        margin-top: var(--wp--style--block-gap, 1.5rem);
    }

    body.has-scroll-presentation .portal-layout .portal-sidebar__title,
    body.has-scroll-presentation .portal-layout .portal-sidebar__panel {
        display: block;
        height: auto;
        min-height: 0;
    }
}
