/* 传统花楼机 - 中国风 / 达芬奇混合风 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;400;700&display=swap');

:root {
    --ink: #3b2c24;
    --paper: #f4ecce;
    --gold: #d4af37;
    --silk: #e8dcc4;
    --blue: #5b7c99;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--paper);
    /* 羊皮纸/宣纸底色 */
    font-family: 'Noto Serif SC', serif;
    color: var(--ink);
    background-image: radial-gradient(circle, rgba(139, 115, 85, 0.05) 0%, rgba(139, 115, 85, 0.2) 100%),
        url("data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h40v40H0z' fill='none'/%3E%3Cpath d='M20 0v40M0 20h40' stroke='%233b2c24' stroke-width='.1' stroke-opacity='.2'/%3E%3C/svg%3E");
}

/* ===== ENTRANCE (中国山水) ===== */
.entrance-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--paper);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 1.5s ease;
}

.entrance-svg {
    width: 60%;
    max-width: 600px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.anim-draw {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawInk 6s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

.delay-1 {
    animation-delay: 1s;
}

@keyframes drawInk {
    to {
        stroke-dashoffset: 0;
    }
}

.entrance-title {
    font-size: 3rem;
    margin-top: 20px;
    letter-spacing: 12px;
    color: var(--ink);
    opacity: 0;
    animation: fadeIn 2s 4s forwards;
}

.entrance-sub {
    font-size: 1rem;
    color: #665544;
    font-style: italic;
    opacity: 0;
    animation: fadeIn 2s 4.5s forwards;
    letter-spacing: 3px;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* ===== MAIN ===== */
.main-container {
    width: 100vw;
    height: 100vh;
    padding: 20px 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.back-link {
    color: var(--ink);
    text-decoration: none;
    font-size: 1.1rem;
    align-self: flex-start;
    margin-bottom: 20px;
    transition: color 0.3s;
}

.back-link:hover {
    color: var(--gold);
}

.loom-layout {
    display: flex;
    gap: 40px;
    flex: 1;
    min-height: 0;
}

/* Left Canvas */
.loom-center {
    flex: 2;
    height: 100%;
    border: 2px solid rgba(59, 44, 36, 0.2);
    border-radius: 6px;
    position: relative;
    background: radial-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0));
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.canvas-wrapper {
    width: 100%;
    height: 100%;
}

#loom-svg {
    width: 100%;
    height: 100%;
}

/* Right Panel */
.control-panel {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    border: 1px solid rgba(59, 44, 36, 0.1);
    background: rgba(244, 236, 206, 0.6);
    border-radius: 8px;
    font-size: 0.95rem;
}

.panel-title {
    font-size: 1.8rem;
    margin-bottom: 5px;
    color: #2a1e16;
}

.panel-desc {
    margin-bottom: 20px;
    line-height: 1.6;
    color: #4a3b32;
}

/* Action Sections */
.action-section {
    padding: 15px 0;
    border-top: 1px dashed rgba(59, 44, 36, 0.3);
    margin-bottom: 20px;
}

.action-section h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.file-input {
    display: none;
}

.upload-btn {
    display: inline-block;
    padding: 6px 14px;
    border: 1px solid var(--ink);
    border-radius: 3px;
    cursor: pointer;
    background: transparent;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.upload-btn:hover {
    background: var(--ink);
    color: var(--paper);
}

.action-btn {
    padding: 7px 16px;
    border: none;
    background: var(--gold);
    color: #222;
    font-weight: bold;
    font-family: 'Noto Serif SC';
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
    margin-left: 10px;
}

.action-btn:hover {
    filter: brightness(1.2);
}

.part-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.part-btn {
    text-align: left;
    padding: 8px 12px;
    border: 1px solid rgba(59, 44, 36, 0.3);
    background: rgba(255, 255, 255, 0.4);
    font-family: 'Noto Serif SC';
    cursor: pointer;
    transition: all 0.3s;
    color: var(--ink);
    display: flex;
    justify-content: space-between;
}

.part-btn span {
    font-size: 0.8rem;
    opacity: 0.6;
}

.part-btn:hover,
.part-btn.active {
    background: rgba(59, 44, 36, 0.1);
    border-color: var(--ink);
}

/* Tutorial & Status */
.tutorial-box {
    padding: 15px;
    border-left: 3px solid var(--gold);
    background: rgba(212, 175, 55, 0.1);
    line-height: 1.6;
    min-height: 100px;
}

.tutorial-box h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.1rem;
    color: #2a1e16;
}

.tutorial-box p {
    margin: 0;
}

.status-panel {
    margin-top: 20px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: #666;
    border-radius: 50%;
}

.status-dot.active {
    background: #39ff14;
    box-shadow: 0 0 8px #39ff14;
}

/* ====== SVG ANIMATIONS ====== */
.warp-line {
    stroke: rgba(139, 115, 85, 0.2);
    stroke-width: 1.5;
    transition: stroke 0.3s;
}

.warp-active {
    stroke: #d4af37;
    stroke-width: 2.5;
    filter: url(#glow);
}

.shuttle-fly {
    animation: flyShuttle 0.8s ease-in-out forwards;
}

.reed-beat {
    animation: beatReed 0.4s ease-out;
}

@keyframes flyShuttle {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(380px);
    }
}

@keyframes flyShuttleRev {
    0% {
        transform: translateX(380px);
    }

    100% {
        transform: translateX(0);
    }
}

@keyframes beatReed {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(40px);
    }

    100% {
        transform: translateY(0);
    }
}

/* ====== LEARN MODAL ====== */
.learn-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.learn-modal.hidden {
    display: none;
}

.learn-content {
    background: var(--paper);
    width: 1000px;
    max-width: 95vw;
    max-height: 90vh;
    border: 2px solid var(--gold);
    border-radius: 8px;
    padding: 30px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.learn-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: var(--ink);
    line-height: 1;
    transition: color 0.3s;
}

.learn-close:hover {
    color: var(--gold);
}

/* Color Palette Scrollbar Container (滑轮区) */
.color-palette-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 15px;
    border: 1px solid rgba(59, 44, 36, 0.2);
    background: rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    padding: 15px;
}

.color-palette-container::-webkit-scrollbar {
    width: 8px;
}

.color-palette-container::-webkit-scrollbar-track {
    background: rgba(59, 44, 36, 0.1);
    border-radius: 4px;
}

.color-palette-container::-webkit-scrollbar-thumb {
    background: var(--blue);
    border-radius: 4px;
}

.swatch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px dashed rgba(59, 44, 36, 0.2);
}

.swatch-row:last-child {
    border-bottom: none;
}

.swatch-color-box {
    width: 60px;
    height: 30px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.3);
}

.swatch-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.swatch-name {
    font-weight: bold;
    font-family: 'Noto Serif SC';
    color: var(--ink);
}

.swatch-hex {
    font-family: monospace;
    font-size: 0.9rem;
    color: #666;
}

.swatch-count {
    font-size: 0.9rem;
    color: #888;
    font-style: italic;
}

/* Layout: Two col */
.learn-layout {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

/* Right: Blueprint */
.blueprint-container {
    flex: 2;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(59, 44, 36, 0.5);
    background: #e2d8bd;
    border-radius: 4px;
    overflow: hidden;
}

.blueprint-header {
    background: var(--ink);
    color: var(--paper);
    padding: 8px;
    text-align: center;
    font-weight: bold;
    font-size: 0.9rem;
    letter-spacing: 2px;
}

.blueprint-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* CSS Grid overlay effect for the canvas */
#blueprint-canvas {
    image-rendering: pixelated;
    background-image:
        linear-gradient(to right, rgba(0, 0, 0, 0.1) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.1) 1px, transparent 1px);
    background-size: 10px 10px;
    /* will be adjusted dynamically or just visually approximate */
}

/* Tooltip Float */
.blueprint-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(42, 30, 22, 0.95);
    color: #fff;
    padding: 10px 14px;
    border-radius: 4px;
    border: 1px solid var(--gold);
    font-size: 0.85rem;
    line-height: 1.6;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    transform: translate(15px, 15px);
    white-space: nowrap;
}

.blueprint-tooltip.hidden {
    display: none;
}

/* Blueprint Search Area */
.blueprint-search {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.6);
    border-bottom: 1px solid rgba(59, 44, 36, 0.2);
    font-size: 0.85rem;
}

.blueprint-search label {
    font-weight: bold;
    color: var(--ink);
}

.blueprint-search input {
    width: 50px;
    padding: 2px 4px;
    border: 1px solid rgba(59, 44, 36, 0.4);
    border-radius: 2px;
    background: var(--paper);
    font-family: monospace;
    text-align: center;
}

.blueprint-search-btn {
    padding: 4px 10px;
    font-size: 0.8rem;
    margin-left: 0;
}

.blueprint-result {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--blue);
    font-weight: bold;
}

/* Crosshair for jumping to coordinates */
.blueprint-crosshair {
    position: absolute;
    width: 10px;
    /* will scale in JS */
    height: 10px;
    border: 2px solid #ff3d3d;
    box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.3);
    /* Dim everything else a bit */
    pointer-events: none;
    z-index: 5;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.blueprint-crosshair::before,
.blueprint-crosshair::after {
    content: '';
    position: absolute;
    background: #ff3d3d;
}

.blueprint-crosshair::before {
    inset: 50% -10px auto -10px;
    height: 1px;
}

.blueprint-crosshair::after {
    inset: -10px 50% -10px auto;
    width: 1px;
}

.blueprint-crosshair.hidden {
    display: none;
}