/* ==========================================================================
   座席図の共通の見た目（docs/seat-system-design.md 14 章。public/script/seating/layout-render.js が作る要素）
   - 手書きの CSS。すべて .seat-map の中だけに効く（既存のページには触らない）。
   - 地は #111、文字は白、細い線、アクセントは #0092ca、数字は Thasadith。金色・グラデーションは使わない。動きは付けない。
   - 席の状態は色だけに頼らない：売切＝濃い灰色＋×、選択＝太い白の枠＋✓、販売停止＝斜線、確保中＝点線の枠、
     販売していない席＝薄い点線の枠、ほかのチケットの席など＝薄く（data-dim）、おまかせの対象外＝左上の小さい三角。
   - ページごとの違い（購入者の図の高さ、座席ボードの色の決まりなど）は、ページの CSS で下の変数か属性を上書きする。
     例：.seat-picker .seat-map { --sm-height: 70vh; }
   ========================================================================== */

/* 数字用の Thasadith（同じオリジンの /vendor/mypage-fonts/。購入画面の "Thasadith" はロゴの字だけなので、別の名前で足す） */
@font-face {
    font-family: "Seat Map Thasadith";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../vendor/mypage-fonts/thasadith-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.seat-map {
    --sm-ground: #111;
    --sm-surface: #1a1c20;
    --sm-raised: #22252a;
    --sm-line: rgba(255, 255, 255, .12);
    --sm-line-strong: rgba(255, 255, 255, .26);
    --sm-text: #eef0f4;
    --sm-muted: #a3acb8;
    --sm-faint: #7d8693;
    --sm-accent: #0092ca;
    --sm-accent-soft: rgba(0, 146, 202, .14);
    --sm-focus: #79d2f4;
    --sm-seat: #737b87;          /* 色の決まっていない席 */
    --sm-taken: #303338;         /* 売切の席 */
    --sm-taken-mark: #c5cad2;
    --sm-selected: #fff;
    --sm-issue: #e0a43a;         /* エディタの要確認 */
    --sm-num-font: "Thasadith", "Seat Map Thasadith", "Helvetica Neue", Arial, sans-serif;
    --sm-font: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    --sm-height: 420px;
    --sm-radius: 12px;

    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    color: var(--sm-text);
    font-family: var(--sm-font);
}

/* 図を入れ物いっぱいに広げる（全画面のダイアログなど。入れ物に高さを付ける） */
.seat-map.seat-map--fill { height: 100%; }
.seat-map.seat-map--fill .seat-map__frame { flex: 1 1 auto; height: auto; min-height: 0; }
/* 枠の高さを図の縦横比に合わせる（createSeatMap の fitHeight。--sm-aspect は layout-render.js が今の階の図から入れる） */
.seat-map.seat-map--fit-height .seat-map__frame {
    height: auto;
    aspect-ratio: var(--sm-aspect, 4 / 3);
    min-height: var(--sm-min-height, 240px);
    max-height: var(--sm-max-height, 75vh);
}

.seat-map [hidden] { display: none !important; }

.seat-map .seat-map__sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* --- 上の帯：階の切り替え・拡大縮小 --------------------------------------- */
.seat-map .seat-map__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
}
.seat-map .seat-map__floors {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.seat-map .seat-map__floor-tab,
.seat-map .seat-map__zoom-btn {
    min-height: 40px;
    margin: 0;
    padding: 6px 14px;
    border: 1px solid var(--sm-line-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--sm-text);
    font: inherit;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
}
.seat-map .seat-map__floor-tab:hover,
.seat-map .seat-map__zoom-btn:hover:not(:disabled) { border-color: rgba(255, 255, 255, .5); }
/* 選んでいる階：塗りつぶし（色だけでなく、地と文字の入れ替えで分かる） */
.seat-map .seat-map__floor-tab[aria-pressed="true"] {
    border-color: var(--sm-text);
    background: var(--sm-text);
    color: var(--sm-ground);
    font-weight: 700;
}
.seat-map .seat-map__zoom {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.seat-map .seat-map__zoom-btn {
    min-width: 40px;
    padding: 6px 10px;
    border-radius: 8px;
    font-family: var(--sm-num-font);
    font-size: 18px;
}
.seat-map .seat-map__zoom-btn--fit { font-family: var(--sm-font); font-size: 13px; }
.seat-map .seat-map__zoom-btn:disabled { opacity: .35; cursor: default; }
.seat-map .seat-map__zoom-value {
    min-width: 3.6em;
    color: var(--sm-muted);
    font-family: var(--sm-num-font);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.seat-map :is(.seat-map__floor-tab, .seat-map__zoom-btn):focus-visible {
    outline: 2px solid var(--sm-focus);
    outline-offset: 2px;
}

/* --- 図の枠 ---------------------------------------------------------------- */
.seat-map .seat-map__frame {
    position: relative;
    height: var(--sm-height);
    min-height: 200px;
    overflow: hidden;
    border: 1px solid var(--sm-line);
    border-radius: var(--sm-radius);
    background: var(--sm-ground);
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}
/*
 * 動かしている間は、この <svg> に CSS の transform が掛かる（viewport.js。描き直さずに GPU で動かす）。
 * 枠の外の部分も描いておき（overflow: visible。枠が切り取る）、動かしたときに空白が見えないようにする。
 */
.seat-map .seat-map__svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    outline: none;
    touch-action: none;
    cursor: default;
    transform-origin: 0 0;
    will-change: transform;
}
.seat-map .seat-map__svg:focus-visible { outline: 2px solid var(--sm-focus); outline-offset: -3px; }
.seat-map .seat-map__frame[data-pan-ready] .seat-map__svg { cursor: grab; }
.seat-map .seat-map__frame:is([data-gesture="pan"], [data-gesture="pinch"]) .seat-map__svg { cursor: grabbing; }
.seat-map .seat-map__frame[data-gesture="drag"] .seat-map__svg { cursor: crosshair; }

/* --- 図形（舞台・通路など。席の下） ------------------------------------------ */
.seat-map .seat-map__element > :is(rect, circle, polygon, polyline, path) {
    fill: rgba(255, 255, 255, .045);
    stroke: rgba(255, 255, 255, .22);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}
.seat-map .seat-map__element > :is(polyline, path) { fill: none; }
.seat-map .seat-map__element[data-type="stage"] > :is(rect, circle, polygon) {
    fill: #2b2e34;
    stroke: rgba(255, 255, 255, .5);
}
.seat-map .seat-map__element[data-type="aisle"] > :is(rect, circle, polygon) {
    fill: rgba(255, 255, 255, .025);
    stroke: rgba(255, 255, 255, .14);
    stroke-dasharray: 4 3;
}
.seat-map .seat-map__element[data-type="pillar"] > :is(rect, circle, polygon) { fill: #3b3f46; stroke: rgba(255, 255, 255, .3); }
.seat-map .seat-map__element:is([data-type="wall"], [data-type="rail"]) > :is(rect, circle, polygon, polyline, path) {
    fill: none;
    stroke: rgba(255, 255, 255, .42);
    stroke-width: 2;
}
.seat-map .seat-map__element:is([data-type="floor-boundary"], [data-type="balcony"], [data-type="overhang"]) > :is(rect, circle, polygon, polyline, path) {
    fill: none;
    stroke: rgba(255, 255, 255, .26);
    stroke-dasharray: 6 4;
}
.seat-map .seat-map__element:is([data-type="entrance"], [data-type="exit"], [data-type="stairs"]) > :is(rect, circle, polygon) {
    fill: rgba(255, 255, 255, .06);
    stroke: rgba(255, 255, 255, .34);
}
.seat-map .seat-map__element-label {
    fill: var(--sm-muted);
    font-family: var(--sm-font);
    letter-spacing: .08em;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}
.seat-map .seat-map__element[data-type="stage"] .seat-map__element-label { fill: var(--sm-text); letter-spacing: .2em; }
.seat-map .seat-map__element-text {
    fill: var(--sm-muted);
    font-family: var(--sm-font);
    font-size: 14px;
}
.seat-map .seat-map__element[data-selected] > :is(rect, circle, polygon, polyline, path) {
    stroke: var(--sm-accent);
    stroke-width: 2;
    stroke-dasharray: none;
}
.seat-map .seat-map__stage-front {
    stroke: var(--sm-accent);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

/* --- 席 -------------------------------------------------------------------- */
.seat-map .seat-map__seat {
    fill: var(--seat-color, var(--sm-seat));
    stroke: rgba(0, 0, 0, .4);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}
.seat-map .seat-map__svg[data-interactive] .seat-map__seat[aria-disabled="false"] { cursor: pointer; }
.seat-map .seat-map__svg[data-interactive] .seat-map__seat[aria-disabled="false"]:hover {
    stroke: var(--sm-text);
    stroke-width: 1.5;
}
/* 売切：濃い灰色（＋×） */
.seat-map .seat-map__seat[data-state="taken"] {
    fill: var(--sm-taken);
    stroke: rgba(255, 255, 255, .1);
}
/* 確保中：点線の枠 */
.seat-map .seat-map__seat[data-state="held"] {
    fill-opacity: .55;
    stroke: var(--sm-text);
    stroke-width: 1.5;
    stroke-dasharray: 3 2;
}
/* 販売していない席：薄い点線の枠だけ */
.seat-map .seat-map__seat[data-state="unavailable"] {
    fill: rgba(255, 255, 255, .05);
    stroke: rgba(255, 255, 255, .2);
    stroke-dasharray: 2 2;
}
/* 販売停止：色を薄くして斜線 */
.seat-map .seat-map__seat[data-state="disabled"] {
    fill-opacity: .3;
    stroke: rgba(255, 255, 255, .3);
}
/* 薄く（ほかのチケットの席など） */
.seat-map .seat-map__seat[data-dim] { opacity: .28; }
/* 選んでいる席：太い白の枠（＋✓） */
.seat-map .seat-map__seat[data-selected] {
    stroke: var(--sm-selected);
    stroke-width: 2.5;
    stroke-dasharray: none;
    opacity: 1;
}
/* エディタの要確認 */
.seat-map .seat-map__seat[data-issue] {
    stroke: var(--sm-issue);
    stroke-width: 2;
    stroke-dasharray: 4 2;
}
.seat-map .seat-map__seat[data-issue][data-selected] { stroke: var(--sm-selected); stroke-dasharray: 4 2; }
.seat-map .seat-map__seat:focus { outline: none; }
.seat-map .seat-map__seat:focus-visible {
    stroke: var(--sm-focus);
    stroke-width: 3;
    stroke-dasharray: none;
}

/* 席の印（×・✓・斜線・三角・属性）。押した位置は下の席に届く */
.seat-map :is(.seat-map__marks, .seat-map__numbers, .seat-map__rows, .seat-map__overlay, .seat-map__underlay) { pointer-events: none; }
.seat-map .seat-map__mark--x { fill: var(--sm-taken-mark); }
.seat-map .seat-map__mark--check {
    fill: #fff;
    stroke: rgba(0, 0, 0, .65);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}
.seat-map .seat-map__mark--hatch {
    fill: none;
    stroke: rgba(255, 255, 255, .62);
    stroke-width: 1.2;
}
.seat-map .seat-map__mark--flag {
    fill: #fff;
    stroke: rgba(0, 0, 0, .55);
    stroke-width: .8;
}
/* 属性の印（車椅子席など）の色は、layout-render.js の defs の中に属性で持つ（<use> の中身には CSS が届かないため） */
.seat-map .seat-map__badge { opacity: .95; }

/* 席の番号（拡大したときだけ）。白の字に濃い縁取りで、どの色の席の上でも読める */
.seat-map:not([data-numbers]) .seat-map__numbers { display: none; }
.seat-map .seat-map__number {
    fill: #fff;
    stroke: rgba(0, 0, 0, .6);
    stroke-width: 2.2px;
    stroke-linejoin: round;
    paint-order: stroke;
    font-family: var(--sm-num-font);
    font-size: 11px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
}
/* 売切の席は × を見せる（番号と重ねない）。販売していない席の番号は薄く */
.seat-map .seat-map__number[data-state="taken"] { display: none; }
.seat-map .seat-map__number[data-state="unavailable"] { fill: rgba(255, 255, 255, .45); }
/* ✓ を描く図では、選んだ席の番号を消して ✓ を見せる */
.seat-map[data-selected-mark="check"] .seat-map__number[data-selected] { display: none; }

/* 列名（列の両端） */
.seat-map:not([data-row-labels]) .seat-map__rows { display: none; }
.seat-map .seat-map__row-label {
    fill: var(--sm-muted);
    font-family: var(--sm-num-font);
    font-size: 13px;
    text-anchor: middle;
    dominant-baseline: central;
}
.seat-map .seat-map__row-label[data-interactive] { fill: var(--sm-text); cursor: pointer; pointer-events: auto; }
.seat-map .seat-map__row-label[data-interactive]:hover { fill: var(--sm-focus); text-decoration: underline; }

/* --- 範囲選択・下絵・方眼（座席ボード・エディタ） ------------------------------ */
.seat-map .seat-map__marquee {
    fill: var(--sm-accent-soft);
    stroke: var(--sm-accent);
    stroke-width: 1.5;
    stroke-dasharray: 5 3;
    vector-effect: non-scaling-stroke;
}
.seat-map .seat-map__lasso {
    fill: rgba(0, 146, 202, .1);
    stroke: var(--sm-accent);
    stroke-width: 1.5;
    stroke-dasharray: 5 3;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}
.seat-map .seat-map__bounds {
    fill: none;
    stroke: rgba(255, 255, 255, .1);
    stroke-dasharray: 6 4;
    vector-effect: non-scaling-stroke;
}
.seat-map .seat-map__grid-line {
    fill: none;
    stroke: rgba(255, 255, 255, .07);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

/* --- 凡例（renderLegend） ---------------------------------------------------- */
.seat-map.seat-map--legend { display: block; }
.seat-map .seat-map__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
    line-height: 1.4;
}
.seat-map .seat-map__legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.seat-map .seat-map__legend-swatch {
    flex: none;
    width: 24px;
    height: 22px;
    overflow: visible;
}
.seat-map .seat-map__legend-note {
    color: var(--sm-muted);
    font-family: var(--sm-num-font);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
    .seat-map { --sm-height: 360px; }
    .seat-map .seat-map__floor-tab { padding: 6px 12px; }
}

@media (forced-colors: active) {
    .seat-map .seat-map__seat { stroke: CanvasText; }
    .seat-map .seat-map__seat[data-selected] { stroke: Highlight; }
    .seat-map .seat-map__mark--x,
    .seat-map .seat-map__mark--check { fill: CanvasText; }
}
