/* Ticketta! 座席選択（案A「静かな受付」）。buyer.css の値を使う。 */
/* Standalone stylesheet; deliberately valid CSS as well as SCSS. */

/* ---- 共通 ---- */

.tk-seat-page {
    text-align: left;
}

/* バナー: 画像は切らずに全体を見せ、余白は同じ画像をぼかした背景で埋める */
.tk-seat-banner {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: var(--banner-max-height-panel);
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: var(--banner-letterbox);
}

.tk-seat-page .tk-seat-banner-blur {
    position: absolute;
    top: -32px;
    left: -32px;
    width: calc(100% + 64px);
    max-width: none;
    height: calc(100% + 64px);
    max-height: none;
    object-fit: cover;
    filter: blur(28px) saturate(0.85);
    opacity: 0.55;
}

.tk-seat-banner-veil {
    position: absolute;
    inset: 0;
    background: var(--banner-veil);
}

.tk-seat-banner .tk-seat-banner-img {
    position: relative;
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: var(--banner-max-height-panel);
}

.tk-seat-banner-sub {
    margin: var(--space-8) var(--space-16) 0;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
    text-align: left;
}

/* 進み具合の帯と公演名の間を詰めて、座席表の高さを確保する（Material Kit の .progress の下余白 20px を打ち消す） */
.tk-seat-progress .progress {
    margin-bottom: 0;
}

/* バナー画像は押すと拡大表示する */
.tk-seat-page .tk-seat-banner-zoom {
    padding: 0;
    border: 0;
    cursor: zoom-in;
}

/* 左右の余白（PC幅のパネルでは24px）を引いた幅いっぱいに広げる */
.tk-seat-page button.tk-seat-banner {
    width: calc(100% - var(--space-24) * 2);
}

.tk-seat-guide-narrow {
    display: none;
}

.tk-seat-banner-dialog:not([open]) {
    display: none;
}

.tk-seat-banner-dialog {
    width: fit-content;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 0;
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-float);
    overflow: auto;
}

.tk-seat-banner-dialog::backdrop {
    background: var(--scrim);
}

.tk-seat-banner-dialog img {
    display: block;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    margin: 0 auto;
    object-fit: contain;
}

.tk-seat-banner-dialog-close {
    position: absolute;
    top: var(--space-8);
    right: var(--space-8);
    z-index: 1;
    display: grid;
    place-items: center;
    width: var(--control-height);
    height: var(--control-height);
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.tk-seat-banner-dialog-close:focus-visible {
    outline: var(--focus-width) solid var(--action);
    outline-offset: 2px;
}

.tk-seat-toggle,
.tk-seat-head-toggle,
.tk-seat-list-toggle {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: inherit;
    cursor: pointer;
}

.tk-seat-toggle {
    display: inline;
}

.tk-seat-page button:focus-visible,
.tk-seat-page a:focus-visible,
.tk-seat-page input:focus-visible {
    outline: var(--focus-width) solid var(--action);
    outline-offset: 2px;
}

/* 案内と「座席おまかせ予約」 */
.tk-seat-page #guide {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-8);
    margin: 0 0 var(--space-8);
    font-weight: 700;
}

.tk-seat-page #guide .btn {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    min-height: var(--control-height-sm);
    margin: 0;
    padding: 0 var(--space-12);
    border: 1px solid var(--border-control);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: none;
    color: var(--action);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
    text-transform: none;
}

.tk-seat-page #guide .btn:hover {
    background: var(--action-subtle);
}

/* 座席表: 枠の中に座席表と凡例を縦に並べる */
.tk-seat-page #cell-map {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.tk-seat-page #cell-map .field {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    height: auto;
    border: 0;
}

.tk-seat-page #cell-map .tk-seat-check {
    fill: #111111;
    font-weight: 700;
    pointer-events: none;
}

.tk-seat-legend {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: var(--space-4) 14px;
    margin: 0;
    padding: 6px var(--space-12);
    border-top: 1px solid var(--border-subtle);
    color: var(--text);
    font-size: 12px;
    line-height: 1.5;
    list-style: none;
    text-align: left;
}

.tk-seat-legend li {
    display: inline-flex;
    align-items: center;
    gap: var(--space-4);
}

.tk-seat-legend-swatch {
    display: inline-grid;
    place-items: center;
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.tk-seat-legend-swatch.is-selected {
    border-color: var(--seat-selected-border);
    background: var(--seat-selected);
    color: #111111;
}

.tk-seat-legend-swatch.is-invalid {
    border-color: var(--seat-invalid);
    background: var(--seat-invalid);
}

/* 選択中のチケットの一覧 */
.tk-seat-panel {
    text-align: left;
}

.tk-seat-panel h4 {
    margin: 0;
}

.tk-seat-panel .ticket-box {
    height: auto;
    overflow: visible;
}

.tk-seat-panel .type-container {
    display: block;
    width: 100%;
    margin: 0 0 var(--space-12);
    padding: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
}

.tk-seat-panel .type-container tbody {
    display: block;
}

.tk-seat-panel .type-container tr {
    display: flex;
}

.tk-seat-panel .type-container th {
    flex: 1;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.6;
}

.tk-seat-panel .ticket-container .ticket,
.tk-seat-panel .type-container .ticket {
    align-items: center;
    justify-content: space-between;
    gap: var(--space-16);
    width: 100%;
    min-height: 52px;
    margin: 0;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--border-subtle);
    border-radius: 0;
}

.tk-seat-panel .ticket .ticket-name {
    flex: 1;
    width: auto;
    min-width: 0;
    padding: 0;
    color: var(--text);
    font-weight: 700;
    line-height: 1.5;
    text-align: left;
    overflow-wrap: anywhere;
}

.tk-seat-panel .ticket .remove {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 36px;
    min-width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border-control);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: none;
    color: var(--text);
}

.tk-seat-panel .ticket .remove:hover {
    background: var(--action-subtle);
}

.tk-seat-panel .ticket .remove i {
    position: static;
    margin: 0;
    color: inherit;
    font-size: 16px;
    line-height: 1;
    transform: none;
}

.tk-seat-panel .ticket .select-box {
    padding: var(--space-8) 0;
}

.tk-seat-panel .close-button {
    display: none;
}

/* 枚数と小計、「次へ」 */
.tk-seat-summary {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    gap: var(--space-8);
}

.tk-seat-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-8);
}

.tk-seat-summary #tk-seat-total {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-8);
    margin: 0;
    color: var(--text);
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
}

.tk-seat-summary #tk-seat-total b {
    font-size: 20px;
    line-height: 1.4;
}

.tk-seat-fee-note {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.tk-seat-actions {
    display: flex;
    align-items: stretch;
    gap: var(--space-8);
}

.tk-seat-page .tk-seat-summary .tk-seat-next {
    flex: 1 1 auto;
    width: auto;
    min-height: var(--control-height);
    margin: 0;
    padding: 0 var(--space-24);
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--action);
    box-shadow: none;
    color: var(--on-action);
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.5;
    text-transform: none;
}

.tk-seat-page .tk-seat-summary .tk-seat-next:hover,
.tk-seat-page .tk-seat-summary .tk-seat-next:focus {
    background: var(--action-hover);
    box-shadow: none;
    color: var(--on-action);
}

/* ---- PC幅 ---- */

@media (min-width: 768px) {
    .tk-seat-page {
        width: 100%;
        max-width: 1600px;
        margin: 0 auto;
        padding: var(--space-12) var(--space-24) 0;
    }

    .tk-seat-head,
    .tk-seat-list-toggle {
        display: none;
    }

    .tk-seat-page .content_field {
        display: flex;
        align-items: flex-start;
        gap: var(--space-24);
        width: 100%;
    }

    /* 座席表: 画面の高さに合わせて広く取る */
    .tk-seat-page .content_field .map {
        flex: 999 1 640px;
        width: auto;
        min-width: 0;
        height: max(480px, calc(100vh - 220px));
    }

    /* 右のパネル: 上から公演名とバナー、選択中のチケット、枚数・小計と「次へ」。高さは座席表にそろえる */
    .tk-seat-page .content_field .tk-seat-panel {
        position: sticky;
        top: var(--space-16);
        display: flex;
        flex: 1 1 340px;
        flex-direction: column;
        min-width: 0;
        max-width: 380px;
        max-height: max(480px, calc(100vh - 220px));
        margin: 0;
        overflow: hidden;
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-md);
        background: var(--surface);
    }

    .tk-seat-panel > .span-title:first-child {
        flex-shrink: 0;
        border-bottom: 1px solid var(--border-subtle);
    }

    .tk-seat-panel .tk-seat-toggle {
        display: flex;
        align-items: center;
        gap: var(--space-8);
        width: 100%;
        min-height: 52px;
        padding: var(--space-8) var(--space-16) var(--space-8) var(--space-24);
        color: var(--text);
        font-family: var(--font-sans);
        font-size: 16px;
        line-height: 1.5;
    }

    .tk-seat-panel .tk-seat-toggle b {
        flex: 1;
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .tk-seat-panel .tk-seat-toggle::after {
        content: "▼";
        flex-shrink: 0;
        color: var(--text-muted);
        font-size: 12px;
        transition: transform 0.25s ease;
    }

    .tk-seat-panel .tk-seat-toggle[aria-expanded="true"]::after {
        transform: rotate(180deg);
    }

    .tk-seat-panel .tk-seat-toggle:focus-visible {
        outline-offset: -3px;
    }

    /* バナーの開閉は高さを滑らかに変える */
    .tk-seat-panel #concert-container {
        display: grid;
        grid-template-rows: 1fr;
        transition: grid-template-rows 0.25s ease;
    }

    .tk-seat-panel #concert-container.hidden {
        grid-template-rows: 0fr;
    }

    .tk-seat-banner-wrap {
        min-height: 0;
        overflow: hidden;
    }

    .tk-seat-banner-wrap > * {
        margin-right: var(--space-24);
        margin-left: var(--space-24);
    }

    .tk-seat-banner-wrap > :last-child {
        margin-bottom: var(--space-16);
    }

    .tk-seat-panel .seat-notice {
        margin-top: var(--space-8);
        font-size: 12px;
        line-height: 1.6;
        overflow-y: auto;
    }

    .tk-seat-panel #selected-tickets-title {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
    }

    .tk-seat-panel-heading {
        flex-shrink: 0;
        margin: 0;
        padding: var(--space-12) var(--space-24) var(--space-4);
        color: var(--text);
        font-family: var(--font-sans);
        font-size: 16px;
        font-weight: 700;
        line-height: 1.5;
    }

    .tk-seat-panel #selected-tickets-container {
        flex: 1 1 auto;
        min-height: 0;
        padding: 0 var(--space-24) var(--space-16);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    /* 最下部: 枚数と小計、「次へ」は一覧の長さに関わらず常に見える */
    .tk-seat-summary {
        padding: var(--space-16) var(--space-24);
        border-top: 1px solid var(--border-subtle);
        background: var(--surface-tint);
    }

    /* 公演をまたいだ選択パネルを開くボタンは画面の右下に置く */
    body.selection-map-page .selection-launcher {
        bottom: var(--bottom-bar-inset);
        background: var(--action);
        color: var(--on-action);
        text-transform: none;
    }
}

@media (min-width: 768px) and (prefers-reduced-motion: reduce) {
    .tk-seat-panel #concert-container,
    .tk-seat-panel .tk-seat-toggle::after {
        transition: none;
    }
}

/* ---- スマホ幅 ---- */

@media (max-width: 767px) {
    .tk-seat-page {
        padding: 0;
    }

    /* 上部の公演名: 押すとバナーと日時を隠して1行に縮める */
    .tk-seat-head {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0 var(--space-12);
        padding: var(--space-8) var(--space-16);
    }

    .tk-seat-head .tk-seat-head-toggle {
        flex: 1 1 0;
        min-width: 0;
    }

    .tk-seat-head .tk-seat-head-notice {
        flex: 1 0 100%;
    }

    .tk-seat-guide-wide {
        display: none;
    }

    .tk-seat-guide-narrow {
        display: inline;
    }

    .tk-seat-head-toggle {
        display: flex;
        align-items: center;
        gap: var(--space-12);
        width: 100%;
        min-height: 44px;
        color: var(--text);
        font-family: var(--font-sans);
        text-align: left;
    }

    .tk-seat-head-toggle::after {
        content: "▼";
        flex-shrink: 0;
        color: var(--text-muted);
        font-size: 12px;
        transition: transform 0.25s ease;
    }

    .tk-seat-head.is-collapsed .tk-seat-head-toggle::after {
        transform: rotate(180deg);
    }

    .tk-seat-thumb {
        position: relative;
        display: flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        width: 72px;
        height: 48px;
        overflow: hidden;
        border-radius: var(--radius-sm);
        background: var(--banner-letterbox);
        transition: width 0.25s ease, height 0.25s ease, opacity 0.25s ease;
    }

    .tk-seat-thumb .tk-seat-thumb-img {
        position: relative;
        display: block;
        max-width: 100%;
        max-height: 100%;
    }

    .tk-seat-head-text {
        display: flex;
        flex: 1;
        flex-direction: column;
        min-width: 0;
    }

    .tk-seat-head-title {
        font-size: 15px;
        line-height: 1.5;
        overflow-wrap: anywhere;
    }

    .tk-seat-head-date {
        max-height: 3em;
        overflow: hidden;
        color: var(--text-muted);
        font-size: 12px;
        font-weight: 400;
        line-height: 1.5;
        transition: max-height 0.25s ease, opacity 0.25s ease;
    }

    .tk-seat-head-notice {
        margin: var(--space-4) 0 0;
        font-size: 12px;
        line-height: 1.6;
    }

    .tk-seat-head.is-collapsed .tk-seat-thumb {
        width: 0;
        height: 0;
        opacity: 0;
        visibility: hidden;
    }

    /* 縮めたときは、公演名の行の上下も詰めて座席表に高さを回す */
    .tk-seat-head.is-collapsed {
        gap: 0;
        padding-top: var(--space-4);
        padding-bottom: 0;
    }

    .tk-seat-head.is-collapsed .tk-seat-head-toggle {
        min-height: 36px;
    }

    .tk-seat-head.is-collapsed .tk-seat-head-title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .tk-seat-head.is-collapsed .tk-seat-head-date {
        max-height: 0;
        opacity: 0;
    }

    .tk-seat-head.is-collapsed .tk-seat-head-notice {
        display: none;
    }

    .tk-seat-page #guide {
        flex-wrap: nowrap;
        padding: 0 var(--space-16) var(--space-8);
        font-size: 14px;
    }

    .tk-seat-page .content_field #cell-map {
        width: auto;
        margin: 0 var(--space-8);
    }

    /* 画面下部のバー: 選択中のチケットの開閉、枚数と小計、選択パネルと「次へ」 */
    .tk-seat-page .content_field .tk-seat-panel {
        left: 0;
        margin: 0;
        padding: var(--space-8) var(--space-16) calc(var(--space-12) + env(safe-area-inset-bottom));
        border-top: 1px solid var(--border-subtle);
        background: var(--surface);
        box-shadow: var(--shadow-bar);
    }

    .tk-seat-panel > .span-title:first-child,
    .tk-seat-panel-heading {
        display: none;
    }

    body.selection-map-page .tk-seat-panel #selected-tickets-title {
        display: block;
    }

    .tk-seat-panel #selected-tickets-container {
        height: auto;
        max-height: 45vh;
        overflow-y: auto;
        overscroll-behavior: contain;
        transition: max-height 0.25s ease;
    }

    .tk-seat-panel #selected-tickets-container.hidden {
        height: auto;
        max-height: 0;
        overflow: hidden;
    }

    .tk-seat-summary {
        gap: var(--space-4);
    }

    .tk-seat-list-toggle {
        display: inline-flex;
        flex-shrink: 0;
        align-items: center;
        gap: 6px;
        min-height: 44px;
        padding: 0 var(--space-4);
        color: var(--action);
        font-family: var(--font-sans);
        font-size: 14px;
        font-weight: 700;
        line-height: 1.5;
    }

    .tk-seat-list-toggle::after {
        content: "▲";
        font-size: 12px;
        transition: transform 0.25s ease;
    }

    .tk-seat-list-toggle[aria-expanded="true"]::after {
        transform: rotate(180deg);
    }

    .tk-seat-summary #tk-seat-total {
        justify-content: flex-end;
        font-size: 14px;
    }

    .tk-seat-fee-note {
        font-size: 11px;
        text-align: right;
    }

    .tk-seat-page .tk-seat-summary .tk-seat-next {
        min-height: 48px;
    }

    body.selection-map-page .tk-seat-actions .selection-launcher {
        position: static;
        flex-shrink: 0;
        width: auto;
        min-height: 48px;
        margin: 0;
        padding: 0 var(--space-16);
        border: 1px solid var(--border-control);
        border-radius: var(--radius-full);
        background: var(--surface);
        box-shadow: none;
        color: var(--action);
        font-size: 14px;
        font-weight: 700;
        white-space: nowrap;
    }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
    .tk-seat-head-toggle::after,
    .tk-seat-thumb,
    .tk-seat-head-date,
    .tk-seat-panel #selected-tickets-container,
    .tk-seat-list-toggle::after {
        transition: none;
    }
}
