/**
 * 原稿用紙エディタ スタイルシート
 * プレフィックス: gke- (Genkouyoushi Editor)
 */

/* ラッパー */
.gke-wrapper {
    margin: 0;
    padding: 0;
    display: flex;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-family: 'Noto Serif JP', 'Yu Mincho', 'Hiragino Mincho Pro', 'MS PMincho', serif;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

/* サイドバートグルボタン */
.gke-sidebar-toggle {
    position: absolute;
    right: -40px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 200;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    padding: 20px 10px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    writing-mode: vertical-rl;
    font-weight: 600;
}

.gke-sidebar-toggle:hover {
    right: -42px;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.4);
}

.gke-sidebar-toggle.gke-collapsed {
    position: fixed;
    left: 0;
    right: auto;
    border-radius: 0 8px 8px 0;
}

/* 左サイドバー（入力エリア） */
.gke-sidebar {
    width: 380px;
    background-color: rgba(255, 255, 255, 0.98);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    max-height: 100vh;
    transition: transform 0.3s ease;
    transform: translateX(0);
    position: relative;
}

.gke-sidebar.gke-collapsed {
    transform: translateX(-100%);
}

.gke-sidebar-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 20px;
    text-align: center;
}

.gke-title {
    margin: 0;
    font-size: 22px;
    font-weight: bold;
}

.gke-subtitle {
    margin: 8px 0 0 0;
    font-size: 13px;
    opacity: 0.9;
}

.gke-sidebar-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.gke-input-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gke-section-title {
    font-weight: 600;
    color: #667eea;
    font-size: 14px;
    padding-bottom: 5px;
    border-bottom: 2px solid #e0e0e0;
}

.gke-textarea {
    width: 100%;
    flex: 1;
    min-height: 300px;
    padding: 12px;
    font-size: 15px;
    font-family: 'Noto Serif JP', 'Yu Mincho', serif;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    resize: vertical;
    ime-mode: active;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.gke-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.gke-textarea.gke-has-placeholder {
    color: rgba(102, 126, 234, 0.4);
    font-style: italic;
}

.gke-controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.gke-button {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    font-family: 'Noto Sans JP', sans-serif;
    padding: 12px 20px;
    font-size: 14px;
}

.gke-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.gke-button:active {
    transform: translateY(0);
}

.gke-button:disabled {
    background: linear-gradient(135deg, #999, #777);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.gke-btn-clear {
    background: linear-gradient(135deg, #ef5350, #d32f2f) !important;
}

/* ヘルプモーダル */
.gke-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.gke-modal-overlay.gke-show {
    display: flex;
}

.gke-modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    position: relative;
    animation: gkeModalSlideIn 0.3s ease;
}

@keyframes gkeModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gke-modal-header {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
}

.gke-modal-body {
    font-size: 14px;
    line-height: 1.8;
    color: #333;
}

.gke-modal-body strong {
    color: #667eea;
    display: block;
    margin-top: 15px;
    margin-bottom: 5px;
}

.gke-modal-close {
    margin-top: 20px;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
}

.gke-modal-close:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* メインエリア（原稿用紙表示） */
.gke-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
    width: 100%;
    margin-left: 0;
    transition: margin-left 0.3s ease;
}

.gke-main-area.gke-sidebar-open {
    margin-left: 0;
}

.gke-manuscript-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-height: 100%;
    width: 100%;
}

.gke-page-navigation {
    display: flex;
    gap: 15px;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.95);
    padding: 12px 25px;
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gke-page-nav-button {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.gke-page-nav-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.gke-current-page-info {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    padding: 5px 15px;
    background-color: #f0f0f0;
    border-radius: 15px;
    min-width: 100px;
    text-align: center;
}

.gke-stats-info {
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
    padding: 5px 15px;
    background-color: #f8f9fa;
    border-radius: 15px;
    text-align: center;
}

.gke-pages-wrapper {
    display: flex;
    gap: 30px;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    width: 100%;
    padding: 10px 50px;
}

/* スクロールバーのカスタマイズ */
.gke-pages-wrapper::-webkit-scrollbar {
    height: 10px;
}

.gke-pages-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
}

.gke-pages-wrapper::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.6);
    border-radius: 5px;
}

.gke-pages-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.8);
}

.gke-page {
    background-color: white;
    border: 3px solid #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    grid-template-rows: repeat(20, 1fr);
    column-gap: 0.2%;
    row-gap: 0.6%;
    writing-mode: vertical-rl;
    text-orientation: upright;
    position: relative;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    width: min(calc(100vh - 120px) * 1.414, calc(100vw - 450px));
    height: min(calc(100vh - 120px), calc((100vw - 450px) / 1.414));
    padding: 4%;
    box-sizing: border-box;
}

.gke-page:hover {
    transform: scale(1.02);
}

.gke-cell {
    border: 1px solid #e0e0e0;
    background-color: rgba(255, 255, 255, 0);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.gke-cell.gke-filled {
    background-color: white;
}

.gke-cell.gke-placeholder-text .gke-character,
.gke-cell.gke-placeholder-text .gke-small-char,
.gke-cell.gke-placeholder-text .gke-punctuation,
.gke-cell.gke-placeholder-text .gke-quote-end,
.gke-cell.gke-placeholder-text .gke-quote-start,
.gke-cell.gke-placeholder-text .gke-quote-with-period {
    opacity: 0.4;
}

.gke-character {
    font-size: clamp(14px, 1.5vw, 22px);
    font-weight: normal;
    color: #333;
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    text-orientation: upright;
    line-height: 1;
}

.gke-small-char {
    font-size: clamp(10px, 1.1vw, 16px);
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    text-orientation: upright;
}

.gke-punctuation {
    font-size: clamp(10px, 1.1vw, 16px);
    position: absolute;
    right: 3px;
    top: 3px;
    writing-mode: vertical-rl;
    text-orientation: upright;
}

.gke-quote-end {
    font-size: clamp(14px, 1.5vw, 22px);
    position: absolute;
    right: 3px;
    bottom: 3px;
    writing-mode: vertical-rl;
    text-orientation: upright;
}

.gke-quote-start {
    font-size: clamp(14px, 1.5vw, 22px);
    position: absolute;
    left: 3px;
    top: 3px;
    writing-mode: vertical-rl;
    text-orientation: upright;
}

.gke-quote-with-period {
    position: relative;
    width: 100%;
    height: 100%;
}

.gke-quote-with-period .gke-quote {
    font-size: clamp(14px, 1.5vw, 22px);
    position: absolute;
    right: 3px;
    bottom: 3px;
}

.gke-quote-with-period .gke-period {
    font-size: clamp(10px, 1vw, 14px);
    position: absolute;
    right: 3px;
    top: 3px;
}

/* ★PDF書き出し時だけ、サイズと文字サイズを固定して崩れを防ぐ */
body.gke-exporting .gke-page {
    width: 1123px !important;
    height: 794px !important;
    padding: 60px !important;
    transform: none !important;
}

body.gke-exporting .gke-character {
    font-size: 22px !important;
}

body.gke-exporting .gke-small-char {
    font-size: 16px !important;
}

body.gke-exporting .gke-punctuation {
    font-size: 16px !important;
}

body.gke-exporting .gke-quote-end,
body.gke-exporting .gke-quote-start {
    font-size: 22px !important;
}

body.gke-exporting .gke-quote-with-period .gke-quote {
    font-size: 22px !important;
}

body.gke-exporting .gke-quote-with-period .gke-period {
    font-size: 16px !important;
}

/* 印刷スタイル */
@media print {
    .gke-wrapper {
        background: white;
        overflow: visible;
    }

    .gke-sidebar {
        display: none !important;
    }

    .gke-main-area {
        padding: 0;
        overflow: visible;
    }

    .gke-page-navigation {
        display: none !important;
    }

    .gke-pages-wrapper {
        flex-direction: column;
        gap: 0;
        overflow: visible;
    }

    .gke-page {
        page-break-after: always;
        box-shadow: none;
        margin: 0 auto;
        width: 277mm !important;
        height: 190mm !important;
        padding: 15mm !important;
        box-sizing: border-box !important;
    }

    .gke-page:last-child {
        page-break-after: auto;
    }

    .gke-page:hover {
        transform: none;
    }

    @page {
        size: A4 landscape;
        margin: 10mm;
    }
}

/* レスポンシブ対応 */
@media (max-width: 1024px) {
    .gke-wrapper {
        flex-direction: column;
        overflow-y: auto;
    }

    .gke-sidebar {
        width: 100%;
        max-height: none;
    }

    .gke-main-area {
        padding: 20px;
        min-height: 600px;
    }

    .gke-page {
        width: min(calc(100vh - 300px) * 1.414, calc(100vw - 100px));
        height: min(calc(100vh - 300px), calc((100vw - 100px) / 1.414));
    }
}

@media (max-width: 768px) {
    .gke-sidebar-content {
        padding: 15px;
    }

    .gke-textarea {
        min-height: 200px;
    }

    .gke-controls-grid {
        grid-template-columns: 1fr;
    }

    .gke-page {
        width: min(calc(100vh - 350px) * 1.414, calc(100vw - 60px));
        height: min(calc(100vh - 350px), calc((100vw - 60px) / 1.414));
    }

    .gke-pages-wrapper {
        flex-direction: column;
    }
}

/* スクロールバーのカスタマイズ */
.gke-sidebar::-webkit-scrollbar,
.gke-main-area::-webkit-scrollbar {
    width: 8px;
}

.gke-sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.gke-sidebar::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.gke-sidebar::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}
