/* =================================================================
 * ガボールパッチ視力トレーニング (visiontest-gabor)
 * スコープは #app-visiontest-gabor に限定
 * ================================================================= */

/* --- HUD --- */
#app-visiontest-gabor .gp-hud {
    background-color: var(--bs-body-bg);
}

#app-visiontest-gabor .gp-hud-label {
    font-size: 0.7rem;
    line-height: 1.1;
    color: var(--bs-secondary-color);
}

#app-visiontest-gabor .gp-hud-value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

#app-visiontest-gabor .gp-hud-value.warn {
    color: var(--bs-danger);
}

/* --- 盤面ラッパー（グレー背景でパッチをなじませる） --- */
#app-visiontest-gabor .gp-stage-wrap {
    position: relative;
    background-color: #808080;
    /* 開始前は盤面もお手本も空のため、オーバーレイが潰れないよう高さを確保する */
    min-height: 420px;
}

/* 自動計測モードのパッチ。盤面と同じ中間グレーに溶け込ませる */
#app-visiontest-gabor .gp-auto-canvas {
    max-width: 100%;
    height: auto;
    background-color: #808080;
}

/* お手本フレーム */
#app-visiontest-gabor .gp-ref-frame {
    width: 96px;
    height: 96px;
    border-radius: 12px;
    overflow: hidden;
    /* 囲み枠は付けない。上のラベルでお手本と分かるため、
       枠があるとかえって縞の見え方を邪魔する */
    background-color: #808080;
}

#app-visiontest-gabor #gp-ref-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- 盤面グリッド --- */
#app-visiontest-gabor .gp-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols, 4), 1fr);
    gap: 6px;
    width: 100%;
    max-width: 440px;
}

#app-visiontest-gabor .gp-cell {
    position: relative;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    background: #808080;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.08s ease, border-color 0.15s ease;
    touch-action: manipulation;
}

#app-visiontest-gabor .gp-cell canvas {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

#app-visiontest-gabor .gp-cell:active {
    transform: scale(0.96);
}

/* グレー地（#808080）に乗る文字・線は、明るい色＋暗い縁取りで輪郭を立てる */
#app-visiontest-gabor .gp-ref-label {
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

/* 正解（見つけた）。目印は右上のチェックのみ。囲み枠は縞の見え方を邪魔するため付けない */
#app-visiontest-gabor .gp-cell.found {
    cursor: default;
}

#app-visiontest-gabor .gp-cell.found::after {
    content: "\f00c";
    /* fa-check */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    font-size: 0.8rem;
    color: #fff;
    background: #198754;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* 誤タップ */
#app-visiontest-gabor .gp-cell.wrong {
    border-color: #ff5c69;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5);
    animation: gpShake 0.35s;
}

/* お手本の傾きを一時表示（わからない時） */
#app-visiontest-gabor .gp-cell.reveal {
    border-color: #ffc107;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(255, 193, 7, 0.6) inset;
}

/* キーボード操作時のフォーカス。既定の淡い青はグレー地で埋もれるため上書き */
#app-visiontest-gabor .gp-cell:focus-visible {
    outline: none;
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.6);
}

@keyframes gpShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-4px);
    }

    40%,
    80% {
        transform: translateX(4px);
    }
}

/* ラウンドクリア時のフラッシュ */
#app-visiontest-gabor .gp-grid.clear-flash {
    animation: gpClearFlash 0.5s ease;
}

@keyframes gpClearFlash {
    0% {
        filter: brightness(1);
    }

    40% {
        filter: brightness(1.35);
    }

    100% {
        filter: brightness(1);
    }
}

/* --- スタート前オーバーレイ --- */
#app-visiontest-gabor .gp-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(33, 37, 41, 0.82);
    color: #fff;
    z-index: 10;
    border-radius: inherit;
}

#app-visiontest-gabor .gp-overlay.d-none {
    display: none !important;
}

/* --- レスポンシブ --- */
@media (max-width: 576px) {
    #app-visiontest-gabor .gp-hud-value {
        font-size: 1.05rem;
    }

    #app-visiontest-gabor .gp-grid {
        gap: 5px;
        max-width: 360px;
    }
}
