/* ===================================
   Quest Board - Styles
   おうちクエストボード
   =================================== */

/* --- CSS Variables (Design System) --- */
:root {
    /* Base Colors */
    --color-bg: #F5F5F0;
    --color-text: #57534E;
    --color-white: #FFFFFF;

    /* Card Colors */
    --color-border-card: #FCD34D;
    --color-border-header: #FDE68A;

    /* Stamp Colors */
    --color-stamp-border: #E5E7EB;
    --color-stamp-bg: #F9FAFB;
    --color-stamp-hover: #FCA5A5;
    --color-stamp-active: #F87171;
    --color-stamp-active-bg: #FEF2F2;
    --color-stamp-icon: #EF4444;
    --color-stamp-focus: #F97316;

    /* 印刷用設定 */
    --print-stamp-border-width: 3px;
    --print-stamp-font-size: clamp(14pt, 4vw, 24pt);
    --print-goal-font-size: 9pt;

    /* Goal Colors */
    --color-goal-border: #FCD34D;
    --color-goal-bg: #FFFBEB;
    --color-goal-text: #F59E0B;

    /* Reward Colors */
    --color-reward-bg: #FFF7ED;
    --color-reward-border: #FED7AA;

    /* Toast Colors */
    --color-toast-success: #10B981;
    --color-toast-info: #3B82F6;

    /* Typography */
    --font-family: 'Zen Maru Gothic', sans-serif;

    /* Spacing */
    --card-padding: 40px;
    --card-border-width: 8px;
    --card-border-radius: 20px;

    /* Animation */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* --- Base & Print Settings --- */
body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23E6E6DC' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    color: var(--color-text);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- クエストボード本体 --- */
.quest-card {
    width: 100%;
    max-width: 700px;
    aspect-ratio: 1.414 / 1;
    background: var(--color-white);
    border: var(--card-border-width) solid var(--color-border-card);
    border-radius: var(--card-border-radius);
    padding: var(--card-padding);
    margin: 0 auto;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-normal);
}

.quest-header {
    text-align: center;
    border-bottom: 3px dashed var(--color-border-header);
    padding-bottom: 15px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.stamp-grid-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stamp-grid {
    display: grid;
    gap: 15px;
    width: 100%;
}

/* --- スタンプスポット --- */
.stamp-spot {
    appearance: none;
    -webkit-appearance: none;
    aspect-ratio: 1;
    border: 3px dashed var(--color-stamp-border);
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    color: var(--color-stamp-border);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    line-height: 1;
    background-color: var(--color-stamp-bg);
    user-select: none;
    outline: none;
}

.stamp-number {
    position: relative;
    z-index: 10;
}

/* ホバー状態 */
.stamp-spot:hover {
    border-color: var(--color-stamp-hover);
    color: var(--color-stamp-hover);
    transform: scale(1.05);
}

/* フォーカス状態（キーボードアクセシビリティ） */
.stamp-spot:focus-visible {
    outline: 3px solid var(--color-stamp-focus);
    outline-offset: 2px;
    border-color: var(--color-stamp-focus);
}

.stamp-spot:active {
    transform: scale(0.95);
}

/* スタンプ済み状態 */
.stamp-spot.stamped {
    border: 3px solid var(--color-stamp-active);
    background-color: var(--color-stamp-active-bg);
    color: transparent;
    animation: stamp-bounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stamp-mark {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--color-stamp-icon);
    z-index: 20;
}

/* 花丸アイコン */
.hanamaru-icon {
    width: 70%;
    height: 70%;
}

.stamp-spot.stamped .stamp-mark {
    display: flex;
}

@keyframes stamp-bounce {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
        opacity: 1;
    }

    100% {
        transform: scale(1);
    }
}

/* ゴール特別装飾 */
.stamp-spot.goal {
    border-color: var(--color-goal-border);
    background-color: var(--color-goal-bg);
}

.stamp-spot.goal::after {
    content: 'GOAL';
    position: absolute;
    bottom: -22px;
    font-size: 12px;
    font-weight: 900;
    color: var(--color-goal-text);
    letter-spacing: 0.05em;
}

/* --- 報酬エリア --- */
.reward-area {
    margin-top: 20px;
    background-color: var(--color-reward-bg);
    border: 2px solid var(--color-reward-border);
    border-radius: 15px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

/* --- スキップリンク --- */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    z-index: 100;
    text-decoration: none;
    font-weight: bold;
    border-radius: 0 0 4px 0;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 0;
}

/* --- Toast通知 --- */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: toast-in 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-white);
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.toast.success {
    background-color: var(--color-toast-success);
}

.toast.info {
    background-color: var(--color-toast-info);
}

/* トースト退出アニメーション */
.toast.toast-exit {
    opacity: 0;
    transform: translateX(100%);
}

@keyframes toast-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* --- アニメーション軽減設定 (prefers-reduced-motion) --- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- 印刷用スタイル（全サイズ・縦横完全対応） --- */
@media print {
    @page {
        margin: 5mm;
        size: auto;
    }

    html,
    body {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
        min-height: 100%;
        background: white;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        overflow: visible;
    }

    .no-print {
        display: none !important;
    }

    main {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 !important;
        box-sizing: border-box;
        overflow: visible !important;
    }

    .quest-container {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent !important;
        padding: 0 !important;
        /* 用紙端からの安全領域 */
        overflow: visible !important;
    }

    /* カード本体：用紙サイズに合わせて最大化しつつ収める */
    .quest-card {
        border-width: 3px;
        border-radius: 8px;
        box-shadow: none;
        margin: 0;
        padding: 15px;

        width: min(100%, 141.4vh);
        height: auto;
        max-width: 100%;
        max-height: 100%;
        aspect-ratio: 1.414 / 1;

        display: flex;
        flex-direction: column;
        justify-content: center;
        /* 中身を中央寄せ */

        /* ページ分割禁止 */
        break-inside: avoid;
        page-break-inside: avoid;
        page-break-after: avoid;
        transform: none !important;
    }

    /* ヘッダー */
    .quest-header {
        flex: 0 0 auto;
        margin-bottom: 1vh;
        border-bottom-width: 2px;
        padding-bottom: 0.5vh;
        text-align: center;
    }

    /* スタンプグリッドエリア */
    .stamp-grid-container {
        flex: 0 0 auto;
        /* 無理に伸ばさない */
        position: relative;
        width: 100%;
        min-height: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: visible;
        padding: 1vh 0 2.5vh;
    }

    .stamp-grid {
        display: grid;
        width: 100%;
        height: auto;
        /* グリッドの高さもなりゆき */
        align-content: center;
        justify-content: center;
        gap: 1.5vmin;
        max-height: 100%;
    }

    /* スタンプ一つ一つ */
    .stamp-spot {
        aspect-ratio: 1 / 1;
        width: auto;
        height: auto;
        max-height: 100%;
        /* コンテナからはみ出さない */

        display: flex;
        align-items: center;
        justify-content: center;

        border-width: var(--print-stamp-border-width);
        border-style: dashed;
        border-color: var(--color-stamp-border);
        font-size: var(--print-stamp-font-size);
        font-weight: 700;
        position: relative;
    }

    .stamp-spot.goal::after {
        font-size: var(--print-goal-font-size);
        bottom: -18%;
        font-weight: 800;
    }

    /* ご褒美エリア */
    .reward-area {
        flex: 0 0 auto;
        /* 縮小しない */
        margin-top: 1vh;
        padding: 8px;
        border-width: 1px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 10%;
        /* 最低限の高さを確保 */
    }

    .reward-area .material-symbols-rounded {
        font-size: 16pt;
    }

    .reward-area .flex-1 {
        min-width: 0;
        /* テキスト切り詰め用 */
    }

    .reward-area .text-\[10px\] {
        font-size: 7pt;
    }

    .reward-area .truncate {
        font-size: clamp(10pt, 3vw, 14pt);
    }

    /* 印刷時のスタンプスタイル */
    .stamp-spot.stamped {
        border: 2px dashed var(--color-stamp-border) !important;
        background-color: var(--color-stamp-bg) !important;
        color: var(--color-stamp-border) !important;
        -webkit-print-color-adjust: exact;
    }

    .stamp-spot.stamped .stamp-mark {
        display: none !important;
    }
}
