/* リセットとベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #2c3e50;
    background-color: #f5f7fa;
    overflow-x: hidden;
}

/* ナビゲーション */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: all 0.3s ease;
}

.navbar.scroll-down {
    transform: translateY(-100%);
}

.navbar.scroll-up {
    transform: translateY(0);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.nav-brand a {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    text-decoration: none;
    background: linear-gradient(45deg, #3498db, #9b59b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background: #2c3e50;
    margin: 3px 0;
    transition: 0.3s;
    border-radius: 3px;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-menu li {
    margin: 0 0.5rem;
}

.nav-menu a {
    color: #2c3e50;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    font-weight: 500;
}

.nav-menu a:hover {
    background: #3498db;
    color: white;
    transform: translateY(-2px);
}

/* ヒーローセクション */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 80px 2rem 2rem;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    position: relative;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(52, 152, 219, 0.1) 0%, transparent 70%);
    animation: float 20s infinite ease-in-out;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(-100px, -100px) rotate(120deg); }
    66% { transform: translate(100px, -50px) rotate(240deg); }
}

.hero-content {
    text-align: center;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    margin-bottom: 1rem;
    line-height: 1.2;
}

.title-main {
    display: block;
    font-weight: 300;
    color: #34495e;
}

.title-accent {
    display: block;
    font-weight: 800;
    background: linear-gradient(45deg, #3498db, #9b59b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: #5a6c7d;
    margin-bottom: 3rem;
    line-height: 1.8;
}

.highlight {
    position: relative;
    font-weight: 600;
    color: #2c3e50;
}

.highlight::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3498db, #9b59b6);
    border-radius: 2px;
}

/* ヒーロービジュアル */
.hero-visual {
    margin: 3rem 0;
    position: relative;
    height: 200px;
    width: 100%;
    overflow: hidden;
}

.font-animation {
    display: flex;
    justify-content: center;
    gap: clamp(0.5rem, 3vw, 2rem);
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.letter {
    font-size: clamp(3rem, 6vw, 5rem);
    font-weight: 700;
    color: #2c3e50;
    position: relative;
    animation: letterFloat 3s infinite ease-in-out;
    animation-delay: calc(var(--i) * 0.2s);
}

.letter:nth-child(1) { --i: 0; }
.letter:nth-child(2) { --i: 1; }
.letter:nth-child(3) { --i: 2; }
.letter:nth-child(4) { --i: 3; }

@keyframes letterFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.hero-diagram {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 400px;
    opacity: 0.8;
}

/* CTA ボタン */
.hero-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.btn {
    padding: 0.8rem 2rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.btn-secondary {
    background: white;
    color: #3498db;
    border: 2px solid #3498db;
}

.btn-secondary:hover {
    background: #3498db;
    color: white;
    transform: translateY(-2px);
}

/* 特徴カード */
.hero-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 4rem;
    max-width: 900px;
    width: 100%;
    padding: 0 1rem;
    box-sizing: border-box;
}

.feature-card {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    text-align: center;
    box-sizing: border-box;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.feature-card p {
    color: #5a6c7d;
    font-size: 0.95rem;
}

/* メインコンテンツ */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 80px 2rem 2rem;
    width: 100%;
    box-sizing: border-box;
}

section {
    margin-bottom: 4rem;
    width: 100%;
    box-sizing: border-box;
}

h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: #2c3e50;
    border-bottom: 3px solid #3498db;
    padding-bottom: 0.5rem;
}

h3 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem;
    color: #34495e;
}

h4 {
    font-size: 1.2rem;
    margin: 1rem 0;
    color: #34495e;
}

.content-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow-x: auto;
}

/* 図解とダイアグラム */
.visual-intro,
.format-visual,
.structure-diagram,
.coordinate-system,
.metrics-diagram,
.horizontal-metrics {
    margin: 2rem 0;
    max-width: 100%;
    overflow-x: auto;
}

svg {
    max-width: 100%;
    height: auto;
    display: block;
}

.intro-diagram,
.format-diagram,
.file-structure,
.glyph-demo,
.coord-demo,
.vertical-metrics,
.h-metrics {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

/* フォーマット比較カード */
.format-comparison {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.format-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    transition: transform 0.3s ease;
    box-sizing: border-box;
    overflow: hidden;
}

.format-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.format-card h4 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.format-card ul {
    list-style: none;
    padding-left: 0;
}

.format-card li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.format-card li:before {
    content: "▸";
    position: absolute;
    left: 0;
    color: #3498db;
}

/* バイナリビュー */
.binary-view {
    margin: 2rem 0;
    overflow-x: auto;
}

.binary-data {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    max-width: 100%;
}

.binary-data .offset {
    color: #569cd6;
}

.binary-data .header {
    color: #ce9178;
}

.binary-data .data {
    color: #b5cea8;
}

.binary-data .table {
    color: #d7ba7d;
}

.binary-data .comment {
    color: #6a9955;
}

/* コードブロック */
.code-block {
    background: #282c34;
    color: #abb2bf;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    max-width: 100%;
}

.code-block .keyword {
    color: #c678dd;
}

.code-block .type {
    color: #e06c75;
}

.code-block .function {
    color: #61afef;
}

.code-block .string {
    color: #98c379;
}

.code-block .comment {
    color: #5c6370;
    font-style: italic;
}

/* インタラクティブ要素 */
.glyph-explanation,
.opentype-features,
.glyph-types,
.best-practices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.interactive-glyph,
.point-data,
.glyph-type-card,
.feature-card,
.practice-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    box-sizing: border-box;
    overflow: hidden;
}

/* テーブル */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    table-layout: fixed;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

.data-table code {
    background: #e8f4fd;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

/* ベジェ曲線デモ */
.bezier-explanation {
    margin: 2rem 0;
    overflow-x: auto;
}

#bezier-demo {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

.bezier-controls {
    text-align: center;
    margin: 1rem 0;
}

.bezier-controls button {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin: 0 0.5rem;
    transition: background 0.3s ease;
}

.bezier-controls button:hover {
    background: #2980b9;
}

.bezier-controls label {
    display: inline-block;
    margin: 0 1rem;
}

.bezier-controls input[type="range"] {
    width: 200px;
    vertical-align: middle;
}

/* フォントビューア */
.font-viewer {
    margin: 2rem 0;
}

.viewer-controls {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.viewer-controls label {
    margin-right: 1rem;
}

.viewer-controls button {
    background: #2ecc71;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 1rem;
}

.viewer-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.table-list,
.table-detail,
.glyph-preview {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    min-height: 400px;
    box-sizing: border-box;
    overflow: auto;
}

/* グリフエディタ */
.glyph-editor {
    margin: 2rem 0;
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
}

.editor-toolbar {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px 8px 0 0;
    border: 1px solid #e0e0e0;
    border-bottom: none;
}

.editor-toolbar button {
    background: #34495e;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 0.5rem;
}

#editor-canvas {
    border: 1px solid #e0e0e0;
    background: white;
    display: block;
    cursor: crosshair;
    max-width: 100%;
    width: 100%;
    height: auto;
}

.point-list {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 0 0 8px 8px;
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

#point-table {
    width: 100%;
    font-size: 0.9rem;
}

/* 実践セクション */
.practice-example {
    margin: 2rem 0;
    overflow-x: auto;
}

.validation-tool {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    overflow-x: auto;
}

.next-steps {
    background: #e8f4fd;
    border-left: 4px solid #3498db;
    padding: 1.5rem;
    margin: 2rem 0;
}

.next-steps ul {
    list-style: none;
    padding-left: 0;
}

.next-steps li {
    padding: 0.5rem 0;
    padding-left: 2rem;
    position: relative;
}

.next-steps li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: #3498db;
    font-weight: bold;
}

/* フッター */
footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: 4rem;
}

footer p {
    margin: 0.5rem 0;
    opacity: 0.9;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    /* ハンバーガーメニュー */
    .nav-toggle {
        display: flex;
    }
    
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 60px;
        flex-direction: column;
        background-color: white;
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0,0,0,0.05);
        padding: 2rem 0;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-menu li {
        margin: 0.5rem 0;
    }
    
    .nav-menu a {
        display: block;
        padding: 1rem 2rem;
        font-size: 1.1rem;
    }
    
    /* ハンバーガーアニメーション */
    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .nav-toggle.active span:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }
    
    .nav-toggle.active span:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }
    
    /* ヒーローセクション */
    .hero {
        padding: 60px 1rem 2rem;
    }
    
    .font-animation {
        gap: 1rem;
    }
    
    .letter {
        font-size: 2.5rem;
    }
    
    .hero-features {
        gap: 1rem;
        margin-top: 2rem;
    }
    
    .feature-card {
        padding: 1.5rem;
    }
    
    /* コンテンツ */
    .viewer-display {
        grid-template-columns: 1fr;
    }
    
    .format-comparison,
    .glyph-explanation,
    .opentype-features,
    .glyph-types {
        grid-template-columns: 1fr;
    }
    
    main {
        padding: 0 1rem;
        margin-top: 0;
    }
    
    .content-box {
        padding: 1rem;
    }
    
    /* SVGのサイズ調整 */
    svg {
        max-height: 300px;
    }
    
    /* テーブルのスクロール */
    .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* コードブロック */
    .code-block,
    .binary-data {
        font-size: 12px;
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.9rem;
    }
    
    .feature-icon {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.2rem;
    }
}

/* アニメーション */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.control-point {
    animation: pulse 2s infinite;
    cursor: pointer;
}

.control-point:hover {
    fill: #c0392b;
}

/* 印刷対応 */
@media print {
    nav,
    .viewer-controls,
    .editor-toolbar,
    .bezier-controls,
    footer {
        display: none;
    }
    
    main {
        max-width: 100%;
    }
    
    .content-box {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}