@import 'variables.css';

dialog {
    width: 100%;
    max-width: 576px;
    height: 100vh;
    margin: 30px 0 0 0;
    padding: 20px 0 0 0px;
    border-radius: 20px 20px 0 0;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    box-sizing: border-box;
    background-color: #fff;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
}

dialog::before { /*タイトルバー上部の色づけ*/
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40px; /* 上部30pxのみ */
    background-color: #f4f4f4; /* 好きな色に変更 */
    border-radius: 20px 20px 0 0; /* dialog の角丸と一致させる */
}

dialog .spotlist-modal-container,
dialog .droplist-modal-container,
dialog .gemlist-modal-container {
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}

@media (max-width: 576px) {
    dialog .spotlist-modal-container,
    dialog .droplist-modal-container,
    dialog .gemlist-modal-container {
        max-height: calc(100dvh - 60px);
    }
}

dialog.modal-open {
    animation-name: modalIn;
    animation-duration: 0.25s;
    animation-fill-mode: forwards;
    animation-timing-function: ease-out;
}

dialog.modal-close {
    animation-name: modalOut;
    animation-duration: 0.25s;
    animation-fill-mode: forwards;
    animation-timing-function: ease-out;
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.6);
    animation-name: backdropIn;
    animation-duration: 0.25s;
    animation-fill-mode: forwards;
    animation-timing-function: ease-out;
}

dialog.second-modal::backdrop {
    background-color: rgba(0, 0, 0, 0);
}

dialog.modal-close::backdrop {
    animation-name: backdropOut;
    animation-duration: 0.25s;
    animation-fill-mode: forwards;
    animation-timing-function: ease-out;
}

body.modal-open {
    overflow: hidden;
}

.modal-container {
    border: none;
    padding: 0;
    position: relative;
}

.modal-title-container {
    top: 0;
    position: sticky;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 40px;
    padding-bottom: 12px;
    background-color: #f4f4f4;
    transition: box-shadow 0.2s ease;
}

.modal-title-container.scrolled {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3); /* スクロール後のシャドウ */
}

.modal-title-name {
    flex-grow: 1; /* width:100%のとき、closeボタンにかぶさらないように領域を確保する */
    font-size: 16px;
    color: #000;
    position: absolute;
    text-align: center;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 600;
    padding: 0 60px; /* 文字数超過の省略記号elipsisを適用するために必要な余白 */
}

@media (max-width: 575px) {
    .modal-title-name {
        width: 100%;
    }
}

@media (min-width: 576px) {
    .modal-title-name {
        width: calc(100% - 60px);
    }
}

.modal-name-line {
    display: block;
    position: relative;
    top: 1px;
    font-size: 17px;
    color: #000;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* 最大2行まで表示 */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis; /* 長い場合に省略記号を表示 */
    white-space: nomal; /* 折り返しを許可 */
}

.modal-mainname-line,
.modal-subname-line {
    display: block;
    position: relative;
    top: -2px;
    margin: 0;
    line-height: 1.3; /* 行間を詰める */
    max-height: 1.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap; /* 折り返さず、省略 */
}

.modal-mainname-line {
    font-size: 17px;
    color: #000;
}

.modal-subname-line {
    font-size: 15px;
    color: #909090;
}

.spotlist-modal-container,
.droplist-modal-container,
.gemlist-modal-container {
    padding-left: 20px;
    padding-bottom: 40px;
}

.dummy-button {
    visibility: hidden;
    outline: none;
}

.spot-button-back {
    fill: var(--spot-color);
    margin-left: 12px;
    width: 18px;
    height: 18px;
    margin-top: 6px;
}

.spot-button-label {
    display: flex;
    width: 30px;
    aspect-ratio: 1;
    border-radius: 50%;
    color: white;
    font-weight: bold;
    font-size: 14px; 
    margin-left: 3px;
    margin-bottom: 5px;
    justify-content: center;
    align-items: center;
    text-indent: 1px;
    z-index: 10;
    background-color: var(--spot-color);
}

.modal-titlebar-buttons {
    display: flex;
    gap: 20px;
    align-items: center;
}

.open-spot-modal-button,
.open-drop-modal-button,
.open-gem-modal-button {
    position: relative;
    top: -2px;
    border: none;
    outline: none;
    width: 28px;
    height: 28px;
    z-index: 10;
    visibility: hidden;
}

.open-spot-modal-button:focus,
.open-drop-modal-button:focus,
.open-gem-modal-button:focus {
    outline: none;
}

.open-spot-modal-button svg,
.open-drop-modal-button svg,
.open-gem-modal-button svg {
    stroke-width: 10;
}

.open-spot-modal-button {
    fill: var(--spot-color);
}

.open-drop-modal-button {
    fill: var(--drop-color);
}

.close-modal-button {
    position: relative;
    top: -2px;
    border: none;
    margin-right: 20px;
    outline: none;
    border-radius: 24px;
    background-color: #fff;
    fill: #cdcdcd;
    width: 24px;
    height: 24px;
}

.close-modal-button:focus {
    outline: none;
}

@keyframes modalIn {
    0% {
        transform: translate(-50%, 100%);
        opacity: 0.5;
    }
    100% {
        transform: translate(-50%, 0%);
        opacity: 1;
    }
}

@keyframes modalOut {
    0% {
        transform: translate(-50%, 0%);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, 100%);
        opacity: 0.5;
    }
}

@keyframes backdropIn {
    0% { opacity: 0; }
    100% { opacity: 0.6; }
}

@keyframes backdropOut {
    0% { opacity: 0.6; }
    100% { opacity: 0; }
}

:where(dialog) {
  width: unset;
  max-width: unset;
  height: unset;
  max-height: unset;
  padding: unset;
  color: unset;
  background-color: unset;
  border: unset;
  overflow: unset;
}

