/* space.html — 空間シミュレーション専用ページ
   setmen.css のトークン（--ivory / --dark / --accent など）を前提に、
   このページ固有のレイアウトだけをここに置く。 */

.space-page {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--ivory, #f3e9dc);
    color: var(--dark, #241f19);
    font-family: var(--font-sans, 'Zen Kaku Gothic New', sans-serif);
}

/* ── ヘッダー ── */
.sp-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: var(--card-bg, #fdf9f3);
    border-bottom: 1px solid var(--border, #ddccb2);
}

.sp-back,
.sp-cart {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-size: 14px;
    letter-spacing: 0.04em;
    white-space: nowrap;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}

/* 見た目は変えずに当たり判定だけ広げる。アイコンだけの戻るボタンは
   実測20x20pxしかなく、指では狙いにくかった */
.sp-back,
.sp-cart {
    position: relative;
}

.sp-back::after,
.sp-cart::after {
    content: '';
    position: absolute;
    inset: -12px -10px;
}

.sp-back {
    color: var(--silver, #7a6f5f);
}

.sp-back:hover {
    color: var(--dark, #241f19);
}

.sp-cart {
    padding: 9px 18px;
    border: 1px solid var(--border, #ddccb2);
    border-radius: 999px;
    color: var(--accent-deep, #8a6a38);
}

.sp-cart:hover {
    background: var(--accent-deep, #8a6a38);
    border-color: var(--accent-deep, #8a6a38);
    color: var(--card-bg, #fdf9f3);
}

.sp-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-align: center;
    min-width: 0;
}

.sp-title-main {
    font-family: var(--font-serif, 'Shippori Mincho', serif);
    font-size: 16px;
    letter-spacing: 0.06em;
}

.sp-title-sub {
    font-size: 12px;
    color: var(--silver, #7a6f5f);
    letter-spacing: 0.06em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 40vw;
}

/* ── ステージ ── */
.sp-stage {
    flex: 1 1 auto;
    position: relative;
    min-height: 0;
    background:
        radial-gradient(120% 90% at 50% 8%, #ffffff 0%, var(--ivory, #f3e9dc) 62%, #e6dccd 100%);
}

.sp-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    /* OrbitControls にジェスチャーを渡す */
}

.sp-loading {
    position: absolute;
    inset: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    letter-spacing: 0.08em;
    color: var(--silver, #7a6f5f);
    pointer-events: none;
}

.sp-loading[hidden] {
    display: none;
}

.sp-hint,
.sp-note {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    text-align: center;
    pointer-events: none;
    color: var(--silver, #7a6f5f);
}

.sp-hint {
    bottom: 46px;
    font-size: 12px;
    letter-spacing: 0.1em;
}

.sp-note {
    bottom: 18px;
    padding: 0 20px;
    font-size: 11px;
    line-height: 1.7;
    color: var(--silver-light, #a89a84);
}

/* setmen.js がマテリアルの供給源として使う model-viewer。
   display:none にすると model-viewer が描画をやめてマテリアルを読めなくなるため、
   画面外へ追い出して「表示はされている」状態を保つ。 */
.sp-offscreen {
    position: fixed;
    left: -9999px;
    top: 0;
    width: 600px;
    height: 600px;
    pointer-events: none;
    opacity: 0.01;
}

.sp-offscreen model-viewer {
    width: 600px;
    height: 600px;
}

@media (max-width: 833.98px) {
    .sp-header {
        padding: 12px 14px;
        gap: 10px;
    }

    .sp-back span {
        display: none;
    }

    .sp-title-main {
        font-size: 14px;
    }

    .sp-title-sub {
        max-width: 48vw;
    }

    .sp-cart {
        padding: 8px 14px;
        font-size: 13px;
    }

    .sp-hint {
        bottom: 52px;
    }
}

/* ── 空間の設定パネル（setmen.html の STEP3 から移設） ──
   中身は .sm-group など configurator と同じ部品を使う。あちらは濃色サイドバー
   前提の配色なので、パネル自体も濃色にして見た目を合わせる。 */
.sp-controls {
    position: fixed;
    top: 76px;
    right: 20px;
    /* タブレット（834〜1179px）では3Dに被る面積を抑えるため細くする。
       ブレークポイントの定義は css/tokens.css の冒頭コメントを参照。 */
    width: clamp(260px, 26vw, 300px);
    max-height: calc(100dvh - 100px);
    overflow-y: auto;
    padding: 18px 18px 22px;
    background: rgba(21, 17, 9, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border, #3a3122);
    border-radius: 10px;
    color: var(--off-white, #f3e9dc);
    z-index: 20;
}

.sp-controls-title {
    margin: 0 0 14px;
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(243, 233, 220, 0.55);
}

.sp-controls .sm-group+.sm-group {
    margin-top: 18px;
}

/* ボトムシートにする帯。700px までだったが、701〜833px では
   幅300pxの固定パネルが画面の36〜39%を覆って3Dに被っていた。
   setmen.html のモバイルUIと同じ 833.98px で切り替える。 */
@media (max-width: 833.98px) {

    /* 横幅が足りないので画面下のシートにする。3Dは上半分で見せる */
    .sp-controls {
        position: static;
        width: auto;
        max-height: 40dvh;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        flex: 0 0 auto;
    }

    /* 操作ヒントはスマホでは出さない。
       ・文言が「ホイールでズーム」とマウス前提で、タッチ端末には合わない
       ・狭い画面では .sp-hint も .sp-note も複数行に折り返し、
         どちらも下端基準の絶対配置なので必ず重なる（bottom値の調整では
         折り返し行数に依存して破綻する）
       注記（現地調査の断り書き）の方は残す必要があるため、ヒントを落とす。 */
    .sp-hint {
        display: none;
    }
}
