/* Codex da Vinci - Renaissance Mathematical Manuscript Studio */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,600&family=EB+Garamond:ital,wght@0,400;0,600;1,400&family=Space+Mono:wght@400;700&display=swap');

:root {
    --parchment-bg: #f5efe6;
    --parchment-deep: #e8ded0;
    --ink-sepia: #2c221b;
    --ink-light: #5a4a3e;
    --ink-sanguine: #8c2d19;
    --brass-accent: #c59b27;
    --brass-glow: rgba(197, 155, 39, 0.35);
    --lapis-blue: #1e3a8a;
    --codex-border: rgba(90, 74, 62, 0.22);
    --codex-shadow: 0 20px 45px -10px rgba(44, 34, 27, 0.15), 0 0 0 1px rgba(90, 74, 62, 0.1);
}

body {
    background-color: var(--parchment-bg);
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(197, 155, 39, 0.05) 0%, transparent 60%),
        radial-gradient(circle at 85% 85%, rgba(140, 45, 25, 0.04) 0%, transparent 60%),
        linear-gradient(135deg, #f7f2ea 0%, #eee4d4 100%);
    color: var(--ink-sepia);
    font-family: 'EB Garamond', 'Cormorant Garamond', serif;
    min-height: 100vh;
    overflow-x: hidden;
    letter-spacing: 0.01em;
}

/* ダ・ヴィンチ手稿風パネル (Manuscript Folio Panel) */
.codex-panel {
    background: rgba(248, 244, 237, 0.85);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--codex-border);
    box-shadow: var(--codex-shadow);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}
.codex-panel::before {
    content: '';
    position: absolute;
    inset: 2px;
    border: 1px solid rgba(90, 74, 62, 0.08);
    pointer-events: none;
    border-radius: inherit;
}
.codex-panel:hover {
    border-color: rgba(197, 155, 39, 0.45);
    box-shadow: 0 25px 50px -10px rgba(44, 34, 27, 0.2), 0 0 0 1px rgba(197, 155, 39, 0.3);
}

/* 素描キャンバス・ステージ (Drawing Parchment Stage) */
.canvas-stage {
    position: relative;
    width: 100%;
    height: 480px;
    background: #fbf8f2;
    background-image: radial-gradient(circle at 50% 50%, #ffffff 0%, #f4ede2 100%);
    border-radius: 16px;
    border: 1px solid rgba(90, 74, 62, 0.25);
    box-shadow: inset 0 0 35px rgba(90, 74, 62, 0.08), 0 15px 35px rgba(44, 34, 27, 0.1);
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

#codex-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Zen全画面モード（手稿の世界に没入） */
body.zen-mode {
    overflow: hidden;
}
body.zen-mode .canvas-stage {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    z-index: 9990 !important;
    background: #f7f2e8 !important;
}
body.zen-mode .studio-console-ui {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.98);
}
body.zen-mode #knav-container {
    opacity: 0;
    pointer-events: none;
}
body.zen-mode #btn-exit-zen {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Zen解除ボタン */
#btn-exit-zen {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-15px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    background: rgba(248, 244, 237, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(197, 155, 39, 0.5);
    box-shadow: 0 10px 30px rgba(44, 34, 27, 0.25);
    color: var(--ink-sepia);
    font-family: 'Cinzel', serif;
}
#btn-exit-zen:hover {
    background: #ffffff;
    border-color: var(--brass-accent);
    box-shadow: 0 0 20px var(--brass-glow);
    transform: translateY(0) scale(1.03);
}

.studio-console-ui {
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 手稿インデックスタブ (Manuscript Chapter Tabs) */
.blade-tab {
    position: relative;
    padding: 9px 12px;
    border-radius: 8px;
    background: rgba(90, 74, 62, 0.03);
    border: 1px solid transparent;
    color: var(--ink-light);
    font-size: 13px;
    font-family: 'EB Garamond', serif;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
}
.blade-tab:hover {
    background: rgba(197, 155, 39, 0.08);
    color: var(--ink-sepia);
    border-color: rgba(197, 155, 39, 0.25);
}
.blade-tab.active {
    background: rgba(197, 155, 39, 0.15);
    border-color: var(--brass-accent);
    color: var(--ink-sepia);
    box-shadow: 0 3px 12px rgba(197, 155, 39, 0.2);
}
.blade-tab.active .tab-roman {
    background: var(--brass-accent);
    color: #ffffff;
    border-color: var(--brass-accent);
}

.tab-roman {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 22px;
    border-radius: 4px;
    background: rgba(90, 74, 62, 0.08);
    border: 1px solid rgba(90, 74, 62, 0.15);
    font-size: 11px;
    font-weight: 700;
    font-family: 'Cinzel', serif;
    color: var(--ink-sepia);
    flex-shrink: 0;
}

/* 真鍮の目盛りスライダー (Brass Scale Slider) */
input[type="range"].codex-slider {
    -webkit-appearance: none;
    appearance: none;
    background: rgba(90, 74, 62, 0.18);
    border-radius: 9999px;
    height: 3px;
    outline: none;
    transition: background 0.2s;
}
input[type="range"].codex-slider:hover {
    background: rgba(90, 74, 62, 0.3);
}
input[type="range"].codex-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--brass-accent);
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(44, 34, 27, 0.3);
    cursor: pointer;
    transition: all 0.15s ease;
}
input[type="range"].codex-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
    box-shadow: 0 0 12px var(--brass-glow), 0 0 0 1px var(--brass-accent);
}

/* 活版印刷・手稿風ボタン (Da Vinci Button) */
.btn-codex {
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Cinzel', serif;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(90, 74, 62, 0.25);
    background: rgba(255, 255, 255, 0.6);
    color: var(--ink-sepia);
    letter-spacing: 0.05em;
}
.btn-codex:hover {
    background: #ffffff;
    color: var(--ink-sepia);
    border-color: var(--brass-accent);
    box-shadow: 0 4px 12px rgba(197, 155, 39, 0.2);
    transform: translateY(-1px);
}
.btn-codex:active {
    transform: scale(0.97);
}

.btn-codex-primary {
    background: var(--ink-sepia);
    border-color: var(--ink-sepia);
    color: #fcf9f2;
}
.btn-codex-primary:hover {
    background: #1a1410;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(44, 34, 27, 0.3);
}

/* スクロールバー */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(90, 74, 62, 0.2);
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(90, 74, 62, 0.35);
}

/* トースト通知 */
.codex-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 80px);
    background: var(--ink-sepia);
    color: #f8fafc;
    border: 1px solid var(--brass-accent);
    box-shadow: 0 20px 40px rgba(44, 34, 27, 0.4);
    padding: 10px 22px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-family: 'Cinzel', serif;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}
.codex-toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
}

/* コードモーダル */
.code-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(44, 34, 27, 0.6);
    backdrop-filter: blur(10px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.code-modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}
.code-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -46%) scale(0.96);
    background: #1c1612;
    border: 1px solid var(--brass-accent);
    box-shadow: 0 35px 70px rgba(0, 0, 0, 0.7);
    border-radius: 12px;
    width: 90%;
    max-width: 740px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.code-modal.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
}
