/* === Sonorité SP(スマホ)版: PSD(375px基準)座標をそのまま反映した絶対配置システム ===
   PC版(home.css)とは独立したファイル。768px以下でのみ有効にし、769px以上ではPC版(.psd-page等)を表示する。 */

@media (min-width: 769px) {
    .sp-root,
    .sp-menu-overlay {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .psd-header-container,
    .psd-page {
        display: none !important;
    }

    .sp-root {
        display: block;
        --sp-w: 375; /* SP版PSDキャンバス基準幅 */
    }

    /* === ヘッダー(スティッキー、PC版と同じ「別コンテナに外出し」手法) === */
    .sp-header-container {
        position: relative;
        width: 100%;
        container-type: inline-size;
    }

    /* 高さ0のラッパーにすることで、後続のPSD座標(--y)を一切ずらさずに追従させる(PC版.site-header-stickyと同じ手法。
       実高さを持たせると親コンテナの下端に即座に突き当たりstickyが機能しなくなるため) */
    .sp-header {
        position: sticky;
        top: 0;
        z-index: 200;
        height: 0;
    }

    .sp-header-bg {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: calc(59 / var(--sp-w) * 100cqw);
        background-color: var(--bg-paper);
        opacity: 0;
        transition: opacity 0.2s ease;
        pointer-events: none;
    }

    .sp-header.is-stuck .sp-header-bg {
        opacity: 0.96;
    }

    .sp-header-logo {
        position: absolute;
        left: calc(26 / var(--sp-w) * 100cqw);
        top: calc(24 / var(--sp-w) * 100cqw);
        width: calc(29 / var(--sp-w) * 100cqw);
        height: calc(28 / var(--sp-w) * 100cqw);
    }

    .sp-header-logo img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .sp-header-title-sub {
        position: absolute;
        left: calc(58 / var(--sp-w) * 100cqw);
        top: calc(31 / var(--sp-w) * 100cqw);
        font-size: calc(12 / var(--sp-w) * 100cqw);
        white-space: nowrap;
        color: var(--text-main);
    }

    .sp-header-title-main {
        position: absolute;
        left: calc(158 / var(--sp-w) * 100cqw);
        top: calc(27 / var(--sp-w) * 100cqw);
        font-size: calc(22 / var(--sp-w) * 100cqw);
        white-space: nowrap;
        color: var(--text-main);
    }

    .sp-hamburger-btn {
        position: absolute;
        left: calc(320 / var(--sp-w) * 100cqw);
        top: calc(23 / var(--sp-w) * 100cqw);
        width: calc(28 / var(--sp-w) * 100cqw);
        height: calc(14 / var(--sp-w) * 100cqw);
        padding: 0;
        border: none;
        background: none;
        cursor: pointer;
    }

    .sp-hamburger-btn span {
        position: absolute;
        left: 0;
        width: 100%;
        /* PSD実測: bounds高さ5pxは余白込みで、実際の線の太さは3px */
        height: calc(3 / var(--sp-w) * 100cqw);
        background-color: #4e4a45;
    }

    .sp-hamburger-btn span:nth-child(1) {
        top: calc(2.5 / var(--sp-w) * 100cqw);
    }

    .sp-hamburger-btn span:nth-child(2) {
        top: calc(10.5 / var(--sp-w) * 100cqw);
    }

    /* === 絶対配置システム(PSDレイヤーのbbox座標をcqw変換) === */
    .sp-page {
        position: relative;
        width: 100%;
        container-type: inline-size;
        background-color: var(--bg-paper);
        overflow: hidden;
    }

    .sp-section {
        position: relative;
        width: 100%;
        height: calc(var(--h) / var(--sp-w) * 100cqw);
        overflow: hidden;
        scroll-margin-top: calc(59 / var(--sp-w) * 100cqw);
    }

    /* === MOVIE(YouTube動画, SP版)。PC版(home.css)と同じマークアップをSP版PSD基準幅(375)の比率で組み直す === */
    .movie-section--sp {
        padding: calc(35 / var(--sp-w) * 100cqw) calc(25 / var(--sp-w) * 100cqw) calc(50 / var(--sp-w) * 100cqw);
        scroll-margin-top: calc(59 / var(--sp-w) * 100cqw);
    }

    .movie-section--sp .movie-heading {
        margin: 0;
        font-size: calc(16 / var(--sp-w) * 100cqw);
        font-weight: 300;
        line-height: 1.4;
        letter-spacing: 0.075em;
        text-align: center;
        color: var(--primary-color);
    }

    .movie-section--sp .movie-heading-line {
        width: calc(150 / var(--sp-w) * 100cqw);
        height: 1px;
        margin: calc(6 / var(--sp-w) * 100cqw) auto 0;
        background-color: #a4a4a4;
    }

    /* SP版: 1枚は画面幅の約8割。次の動画が右に少し見えて、スワイプで送れることが分かるようにする */
    .movie-section--sp .movie-carousel {
        margin: calc(28 / var(--sp-w) * 100cqw) calc(-25 / var(--sp-w) * 100cqw) 0;
    }

    .movie-section--sp .movie-scroll {
        gap: calc(14 / var(--sp-w) * 100cqw);
        padding: 0 calc(25 / var(--sp-w) * 100cqw) calc(10 / var(--sp-w) * 100cqw);
        scroll-padding-left: calc(25 / var(--sp-w) * 100cqw);
    }

    .movie-section--sp .movie-card {
        width: calc(290 / var(--sp-w) * 100cqw);
    }

    .movie-section--sp .movie-card-caption {
        margin-top: calc(8 / var(--sp-w) * 100cqw);
        font-size: calc(11 / var(--sp-w) * 100cqw);
    }

    .movie-section--sp .movie-scroll-btn {
        display: none;
    }

    .sp-abs {
        position: absolute;
        left: calc(var(--x) / var(--sp-w) * 100cqw);
        top: calc(var(--y) / var(--sp-w) * 100cqw);
    }

    .sp-box {
        position: absolute;
        left: calc(var(--x) / var(--sp-w) * 100cqw);
        top: calc(var(--y) / var(--sp-w) * 100cqw);
        width: calc(var(--w) / var(--sp-w) * 100cqw);
        height: calc(var(--h) / var(--sp-w) * 100cqw);
    }

    .sp-img {
        position: absolute;
        left: calc(var(--x) / var(--sp-w) * 100cqw);
        top: calc(var(--y) / var(--sp-w) * 100cqw);
        width: calc(var(--w) / var(--sp-w) * 100cqw);
        height: calc(var(--h) / var(--sp-w) * 100cqw);
        max-width: none;
        object-fit: cover;
    }

    .sp-text {
        position: absolute;
        left: calc(var(--x) / var(--sp-w) * 100cqw);
        top: calc(var(--y) / var(--sp-w) * 100cqw);
        width: calc(var(--w) / var(--sp-w) * 100cqw);
        font-size: calc(var(--fs) / var(--sp-w) * 100cqw);
        font-weight: 300;
        line-height: 1.4;
        margin: 0;
        color: var(--text-main);
        text-decoration: none;
        white-space: nowrap;
    }

    .sp-text--wrap {
        white-space: normal;
        text-align: justify;
    }

    .sp-text--wrap p {
        margin: 0;
    }

    .sp-text--wrap p + p {
        margin-top: 1em;
    }

    .sp-font-jp-heading {
        font-family: var(--font-jp-heading);
        font-weight: 400;
        letter-spacing: 0.1em;
    }

    .sp-font-jp-body {
        font-family: var(--font-jp-body);
        font-weight: 400;
        letter-spacing: 0.075em;
    }

    .sp-font-logo {
        font-family: var(--font-logo);
        font-weight: 500;
        line-height: 1;
    }

    .sp-label {
        letter-spacing: 0.1em;
    }

    .sp-line {
        position: absolute;
        background-color: #a4a4a4;
    }

    /* 縦書き(英字を横向きのまま上→下に並べる。CONDUCTOR見出し等)
       h2等の要素は writing-mode:vertical-rl 下では margin-block(既定は上下マージン)が
       左右マージンとして作用し位置がずれるため、margin を明示的に0にする */
    .sp-text--vertical {
        margin: 0;
        font-weight: 300;
        color: var(--text-main);
        writing-mode: vertical-rl;
        text-orientation: sideways;
        white-space: nowrap;
    }

    .sp-hero-cta {
        display: block;
        position: absolute;
        left: calc(var(--x) / var(--sp-w) * 100cqw);
        top: calc(var(--y) / var(--sp-w) * 100cqw);
        width: calc(var(--w) / var(--sp-w) * 100cqw);
        height: calc(var(--h) / var(--sp-w) * 100cqw);
    }

    .sp-hero-cta img {
        display: block;
        width: 100%;
        height: 100%;
    }

    /* 背景画像(枠・矢印など)の上に文字をHTMLテキストとして重ねるボタン。
       PC版と同じ考え方: 文字を画像に焼き込まないことで、どんな解像度でもシャープに表示する */
    .sp-hero-cta-bg-img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: fill;
    }

    /* 単色角丸ボタン(CONTACT CTA等)。画像を使わずCSSだけで再現し、解像度に一切依存しない */
    .sp-cta-box {
        position: absolute;
        left: calc(var(--x) / var(--sp-w) * 100cqw);
        top: calc(var(--y) / var(--sp-w) * 100cqw);
        width: calc(var(--w) / var(--sp-w) * 100cqw);
        height: calc(var(--h) / var(--sp-w) * 100cqw);
        background-color: #8fa59a;
        border-radius: calc(5 / var(--sp-w) * 100cqw);
        text-decoration: none;
    }

    /* === HISTORY: 年表(縦書き曲目、列数可変・横スクロール。PC版と同じ考え方) === */
    .sp-history-timeline-viewport {
        position: absolute;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        cursor: grab;
    }

    .sp-history-timeline-viewport::-webkit-scrollbar {
        display: none;
    }

    .sp-history-timeline-viewport.is-dragging {
        cursor: grabbing;
        user-select: none;
    }

    .sp-history-timeline {
        /* CSS Gridのrepeat(N, max-content)は、複数列のトラックサイズが独立して計算されず
           全列が最大幅に揃ってしまう(曲数の少ない年まで幅広の年に引きずられる)ことがあるため、
           各カードが自分のコンテンツ幅だけを持てるFlexboxで組む(PC版と同じ考え方) */
        display: flex;
        height: 100%;
    }

    .sp-history-year-card {
        position: relative;
        flex: 0 0 auto;
        text-align: center;
    }

    .sp-history-year-card .year {
        /* absoluteだとテキスト幅がgridの自動サイズ計算(max-content)に反映されず、
           年号どうしが詰まって重なるため、static(通常フロー)にしてwidth:max-contentで
           実際の文字幅をセル幅計算に反映させる */
        width: max-content;
        margin: 0 auto;
        font-size: calc(14 / var(--sp-w) * 100cqw);
        font-weight: 300;
        font-style: italic;
        letter-spacing: 0.05em;
        line-height: 1;
        color: var(--text-main);
    }

    .sp-history-year-card .programs {
        /* position:staticのままにして、複数曲で幅が増える年はgrid-template-columnsの
           max-contentがその実際の幅を拾えるようにする(absoluteだとgridの自動サイズ計算に
           幅が反映されず、隣の年と重なってしまう)。width:max-contentでflexのstretchを防ぐ */
        width: max-content;
        margin: calc(20 / var(--sp-w) * 100cqw) auto 0;
        writing-mode: vertical-rl;
        text-orientation: mixed;
        list-style: none;
        padding: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: calc(6 / var(--sp-w) * 100cqw);
        height: calc(226 / var(--sp-w) * 100cqw);
        font-size: calc(10 / var(--sp-w) * 100cqw);
        line-height: 1;
        font-family: var(--font-jp-body);
    }

    .sp-history-year-card .programs li {
        white-space: nowrap;
        text-align: left;
    }

    .sp-history-year-card .programs .piece-stack {
        writing-mode: horizontal-tb;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        /* 最長曲名(13文字「弦楽のためのトリプティーク」)が1列に収まる高さを確保 */
        height: calc(216 / var(--sp-w) * 100cqw);
    }

    .sp-history-year-card .programs .piece-composer,
    .sp-history-year-card .programs .piece-sep,
    .sp-history-year-card .programs .piece-title {
        writing-mode: vertical-rl;
        text-orientation: mixed;
        letter-spacing: 0.1em;
    }

    .sp-history-year-card .programs .piece-composer {
        flex: none;
        white-space: nowrap;
    }

    .sp-history-year-card .programs .piece-sep {
        flex: none;
        white-space: nowrap;
        margin: 0.15em 0;
    }

    .sp-history-year-card .programs .piece-title {
        flex: 1 1 auto;
        min-height: 0;
        white-space: normal;
    }

    /* === NEXT CONCERT: 日付ボックス・PROGRAM等 === */
    .sp-concert-date-box {
        position: absolute;
        border: 1px solid #c2c2c2;
    }

    .sp-concert-program-list {
        list-style: none;
        margin: 0;
        padding: 0;
        font-size: calc(11 / var(--sp-w) * 100cqw);
        font-family: var(--font-jp-body);
        line-height: 1.7;
    }

    .sp-concert-program-list li {
        padding: 0.1em 0;
    }

    /* === フッター(CONTACTセクション内) === */
    .sp-footer-logo {
        object-fit: contain;
    }

    /* === ハンバーガーメニュー(開いた状態、常に画面全体を覆う。スクロール位置に関わらず同じデザインを表示) === */
    .sp-menu-overlay {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        z-index: 1000;
        background-color: rgba(255, 255, 255, 0.85);
        overflow: hidden;
        container-type: inline-size;
        visibility: hidden;
        transform: translateY(-100%);
        transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.6s;
    }

    .sp-menu-overlay.is-open {
        visibility: visible;
        transform: translateY(0);
        transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0s;
    }

    .sp-menu-visual {
        position: absolute;
        left: calc(101 / 375 * 100cqw);
        top: calc(-477 / 375 * 100cqw);
        width: calc(361 / 375 * 100cqw);
        height: calc(1014 / 375 * 100cqw);
        background-image: url('/images/sp/menu/instrument-silhouette.png');
        background-size: 100% 100%;
        background-repeat: no-repeat;
    }

    .sp-menu-area {
        position: absolute;
        left: calc(101 / 375 * 100cqw);
        top: calc(-477 / 375 * 100cqw);
        width: calc(361 / 375 * 100cqw);
        height: calc(1014 / 375 * 100cqw);
        background-color: rgba(110, 121, 114, 0.85);
        -webkit-mask-image: url('/images/sp/menu/instrument-silhouette.png');
        mask-image: url('/images/sp/menu/instrument-silhouette.png');
        -webkit-mask-size: 100% 100%;
        mask-size: 100% 100%;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
    }

    .sp-menu-content {
        position: absolute;
        inset: 0;
    }

    .sp-menu-close {
        position: absolute;
        left: calc(336 / 375 * 100cqw);
        top: calc(25 / 375 * 100cqw);
        width: calc(21 / 375 * 100cqw);
        height: calc(21 / 375 * 100cqw);
        padding: 0;
        border: none;
        background: none;
        color: #daddd8;
        font-size: calc(21 / 375 * 100cqw);
        line-height: 1;
        cursor: pointer;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sp-menu-logo {
        margin: 0;
        color: #daddd8;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sp-menu-overlay.is-open .sp-menu-close,
    .sp-menu-overlay.is-open .sp-menu-logo {
        opacity: 1;
        transition: opacity 0.4s ease 0.15s;
    }

    .sp-menu-logo-sub {
        position: absolute;
        left: calc(180 / 375 * 100cqw);
        top: calc(86 / 375 * 100cqw);
        font-size: calc(12 / 375 * 100cqw);
        white-space: nowrap;
    }

    .sp-menu-logo-main {
        position: absolute;
        left: calc(280 / 375 * 100cqw);
        top: calc(83 / 375 * 100cqw);
        font-size: calc(22 / 375 * 100cqw);
        white-space: nowrap;
    }

    .sp-menu-nav {
        position: absolute;
        left: calc(200 / 375 * 100cqw);
        top: calc(182 / 375 * 100cqw);
        display: flex;
        flex-direction: column;
        gap: calc(40 / 375 * 100cqw);
    }

    /* MOVIEが加わって7項目になるときは、最後の項目がメニュー背景からはみ出さないよう間隔を詰める(6項目時と同じ全体の高さ) */
    .sp-menu-nav--with-movie {
        gap: calc(30 / 375 * 100cqw);
    }

    .sp-menu-nav a {
        display: block;
        font-size: calc(18 / 375 * 100cqw);
        font-weight: 300;
        line-height: 1;
        letter-spacing: 0.075em;
        color: #daddd8;
        text-decoration: none;
        white-space: nowrap;
        opacity: 0;
        transform: translateY(-10px);
        transition: opacity 0.35s ease, transform 0.35s ease;
    }

    /* メニュー展開時、ナビ項目を上から順に時間差でフェードインさせる */
    .sp-menu-overlay.is-open .sp-menu-nav a {
        opacity: 1;
        transform: translateY(0);
        transition: opacity 0.45s ease, transform 0.45s ease;
    }

    .sp-menu-overlay.is-open .sp-menu-nav a:nth-child(1) { transition-delay: 0.22s; }
    .sp-menu-overlay.is-open .sp-menu-nav a:nth-child(2) { transition-delay: 0.28s; }
    .sp-menu-overlay.is-open .sp-menu-nav a:nth-child(3) { transition-delay: 0.34s; }
    .sp-menu-overlay.is-open .sp-menu-nav a:nth-child(4) { transition-delay: 0.40s; }
    .sp-menu-overlay.is-open .sp-menu-nav a:nth-child(5) { transition-delay: 0.46s; }
    .sp-menu-overlay.is-open .sp-menu-nav a:nth-child(6) { transition-delay: 0.52s; }
    .sp-menu-overlay.is-open .sp-menu-nav a:nth-child(7) { transition-delay: 0.58s; }

    /* PSDには存在しない要素だが、PC版(.psd-members-link)と同様に団員専用ページへの導線を追加 */
    .sp-menu-nav-members {
        font-size: calc(14 / 375 * 100cqw) !important;
        font-weight: 600 !important;
        color: rgba(218, 221, 216, 0.85) !important;
    }

    body.sp-menu-open {
        overflow: hidden;
    }
}
