/* ============================================================================
   LANDING PAGE - ADMIN EDITING STYLES
   Mirrors the wallet guide modal admin editing pattern for the landing page
   ============================================================================ */

/* Admin mode badge (reuses wallet pattern) */
#prototypeEvolutionSection .admin-mode-badge,
#aboutStorySection .admin-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    margin-bottom: 1rem;
}

#prototypeEvolutionSection .admin-mode-badge::before,
#aboutStorySection .admin-mode-badge::before {
    content: "⚙️";
}

/* Admin instructions */
#prototypeEvolutionSection .admin-instructions,
#aboutStorySection .admin-instructions {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 1.5rem;
    font-size: 0.8rem;
    color: #a78bfa;
    text-align: center;
}

#prototypeEvolutionSection .admin-instructions strong,
#aboutStorySection .admin-instructions strong {
    color: #c4b5fd;
}

/* ============================================================================
   IMAGE CARD - Admin Resizable
   ============================================================================ */

/* Admin mode: make image cards resizable */
.guide-row.admin-editing .image-card {
    resize: both;
    overflow: hidden;
    border: 2px dashed rgba(139, 92, 246, 0.5);
    position: relative;
    min-width: 120px;
    min-height: 80px;
}

.guide-row.admin-editing .image-card:hover {
    border-color: rgba(139, 92, 246, 0.8);
}

/* Image size display overlay */
.guide-row.admin-editing .image-card .size-display {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #a78bfa;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-family: monospace;
    pointer-events: none;
    z-index: 10;
}

/* Resize handle indicator for image card */
.guide-row.admin-editing .image-card::after {
    content: "⤡";
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-size: 16px;
    color: rgba(139, 92, 246, 0.8);
    pointer-events: none;
    z-index: 5;
}

/* ============================================================================
   TEXT CARD - Admin Resizable & Editable
   ============================================================================ */

.guide-row.admin-editing .text-card {
    resize: both;
    overflow: hidden;
    border: 2px dashed rgba(16, 185, 129, 0.5);
    position: relative;
    padding: 8px;
    border-radius: 8px;
}

.guide-row.admin-editing .text-card:hover {
    border-color: rgba(16, 185, 129, 0.8);
}

/* Text card size display */
.guide-row.admin-editing .text-card .text-size-display {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #10b981;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-family: monospace;
    pointer-events: none;
    z-index: 10;
}

/* Resize handle indicator for text card */
.guide-row.admin-editing .text-card::after {
    content: "⤡";
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-size: 16px;
    color: rgba(16, 185, 129, 0.8);
    pointer-events: none;
    z-index: 5;
}

/* Editable text fields */
.guide-row.admin-editing .editable-title,
.guide-row.admin-editing .editable-description {
    cursor: text;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 6px;
    transition: all 0.2s ease;
    position: relative;
    outline: none;
}

.guide-row.admin-editing .editable-title:hover,
.guide-row.admin-editing .editable-description:hover {
    border-color: rgba(251, 191, 36, 0.4);
    background: rgba(251, 191, 36, 0.05);
}

.guide-row.admin-editing .editable-title:focus,
.guide-row.admin-editing .editable-description:focus {
    border-color: rgba(251, 191, 36, 0.8);
    background: rgba(251, 191, 36, 0.1);
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

/* Edit indicator */
.guide-row.admin-editing .editable-title::before,
.guide-row.admin-editing .editable-description::before {
    content: "✏️";
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.guide-row.admin-editing .editable-title:hover::before,
.guide-row.admin-editing .editable-description:hover::before {
    opacity: 0.6;
}

/* ============================================================================
   POSITION BUTTONS
   ============================================================================ */

.landing-guide-grid .position-buttons {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    justify-content: center;
}

.landing-guide-grid .pos-btn {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(139, 92, 246, 0.5);
    border-radius: 8px;
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.landing-guide-grid .pos-btn:hover {
    background: rgba(139, 92, 246, 0.4);
    border-color: rgba(139, 92, 246, 0.8);
    color: white;
    transform: scale(1.1);
}

.landing-guide-grid .pos-btn:active {
    transform: scale(0.95);
}

.landing-guide-grid .pos-btn.active {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

/* ============================================================================
   ADMIN CONTROLS BAR
   ============================================================================ */

#prototypeEvolutionSection .admin-modal-controls,
#aboutStorySection .admin-modal-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(20, 20, 30, 0.95);
    border-top: 1px solid rgba(139, 92, 246, 0.3);
    margin-top: 2rem;
    border-radius: 12px;
}

/* ============================================================================
   STORY SECTION - Grid Layout
   Default: 4 blocks in a 2×2 grid
   Block 0 = main image (top-left), Block 1 = detail image (bottom-left),
   Block 2 = process image (bottom-right), Block 3 = story text (top-right, spans 2 rows)
   ============================================================================ */

.story-layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 1rem;
    align-items: stretch;
}

/* Default grid placement via order */
.story-block[data-card-index="0"] { order: 0; }
.story-block[data-card-index="1"] { order: 2; }
.story-block[data-card-index="2"] { order: 3; }
.story-block[data-card-index="3"] { order: 1; }

/* Tablet: 2-column layout — images top row, text spans below */
@media (min-width: 768px) and (max-width: 1023px) {
    .story-layout-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto;
    }

    .story-block[data-card-index="0"] { order: unset; grid-column: 1 / 3; grid-row: 1; }
    .story-block[data-card-index="1"] { order: unset; grid-column: 1; grid-row: 2; }
    .story-block[data-card-index="2"] { order: unset; grid-column: 2; grid-row: 2; }
    .story-block[data-card-index="3"] { order: unset; grid-column: 1 / 3; grid-row: 3; }
}

/* Desktop: 3-column layout — images left 2 cols, text right 1 col spanning rows */
@media (min-width: 1024px) {
    .story-layout-grid {
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-rows: auto auto;
    }

    .story-block[data-card-index="0"] { order: unset; grid-column: 1 / 3; grid-row: 1; }
    .story-block[data-card-index="1"] { order: unset; grid-column: 1; grid-row: 2; }
    .story-block[data-card-index="2"] { order: unset; grid-column: 2; grid-row: 2; }
    .story-block[data-card-index="3"] { order: unset; grid-column: 3; grid-row: 1 / 3; }
}

/* Image blocks min heights */
.story-block .image-card {
    min-height: 180px;
}

.story-block[data-card-index="0"] .image-card {
    min-height: 200px;
}

/* Mobile: constrain image heights so they don't dominate the screen */
@media (max-width: 767px) {
    .story-block .image-card,
    .story-block[data-card-index="0"] .image-card,
    .story-block[data-card-index="1"] .image-card,
    .story-block[data-card-index="2"] .image-card {
        width: 100% !important;
        height: auto !important;
        min-height: 120px !important;
        max-height: 45vw !important;
    }

    .story-block .image-card img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover;
    }
}

/* Story text content styling */
.story-text-content {
    padding: 1rem 0;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

@media (min-width: 768px) {
    .story-text-content {
        padding: 1rem;
    }
}

.story-block .image-card img {
    transition: transform 0.3s ease;
}

.story-block:not(.admin-editing) .image-card:hover img {
    transform: scale(1.03);
}

/* When not in admin mode, no dashed borders */
.story-block:not(.admin-editing) .image-card {
    border: none;
    resize: none;
}

/* ============================================================================
   DRAG HANDLE
   ============================================================================ */

.drag-handle {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    background: rgba(139, 92, 246, 0.7);
    border: 1px solid rgba(139, 92, 246, 0.9);
    border-radius: 6px;
    color: white;
    font-size: 14px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: all 0.2s ease;
    user-select: none;
    line-height: 1;
}

.drag-handle:hover {
    background: rgba(139, 92, 246, 0.95);
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

.drag-handle:active {
    cursor: grabbing;
}

/* Make story blocks position relative for drag handle */
.story-block.admin-editing {
    position: relative;
}

/* Dragging states */
.story-block.dragging {
    opacity: 0.4;
    outline: 2px dashed rgba(139, 92, 246, 0.6);
    outline-offset: 4px;
}

.story-block.drag-over {
    outline: 2px solid rgba(16, 185, 129, 0.8);
    outline-offset: 4px;
    background: rgba(16, 185, 129, 0.05);
    border-radius: 16px;
}

/* Order badge overlay (shows current position) */
.story-block.admin-editing .order-badge {
    position: absolute;
    top: 8px;
    left: 42px;
    background: rgba(0, 0, 0, 0.8);
    color: #a78bfa;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-family: monospace;
    pointer-events: none;
    z-index: 20;
}

/* ============================================================================
   ADMIN BUTTONS (self-contained for landing page)
   ============================================================================ */

#prototypeEvolutionSection .admin-save-btn,
#aboutStorySection .admin-save-btn {
    padding: 10px 24px;
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

#prototypeEvolutionSection .admin-save-btn:hover,
#aboutStorySection .admin-save-btn:hover {
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

#prototypeEvolutionSection .admin-save-btn:disabled,
#aboutStorySection .admin-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#prototypeEvolutionSection .admin-save-btn.saved,
#aboutStorySection .admin-save-btn.saved {
    background: linear-gradient(135deg, #10b981, #059669);
}

#prototypeEvolutionSection .admin-reset-btn,
#aboutStorySection .admin-reset-btn {
    padding: 10px 20px;
    background: rgba(107, 114, 128, 0.2);
    border: 1px solid rgba(107, 114, 128, 0.4);
    border-radius: 8px;
    color: #9ca3af;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

#prototypeEvolutionSection .admin-reset-btn:hover,
#aboutStorySection .admin-reset-btn:hover {
    background: rgba(107, 114, 128, 0.4);
    color: white;
    border-color: rgba(107, 114, 128, 0.6);
}

/* ============================================================================
   MOBILE: Hide all admin editing UI on small screens
   ============================================================================ */
@media (max-width: 767px) {
    .admin-mode-badge,
    .admin-instructions,
    .admin-modal-controls,
    .drag-handle,
    .position-buttons,
    .size-display,
    .text-size-display,
    .order-badge {
        display: none !important;
    }

    /* Disable admin resizing and dashed borders on mobile */
    .guide-row.admin-editing .image-card,
    .guide-row.admin-editing .text-card {
        resize: none;
        border: none;
    }

    .guide-row.admin-editing .text-card {
        overflow: visible;
        width: 100% !important;
        min-width: 0;
        padding: 0;
    }

    .guide-row.admin-editing .image-card::after,
    .guide-row.admin-editing .text-card::after {
        display: none;
    }

    /* Disable contenteditable styling on mobile */
    .guide-row.admin-editing .editable-title,
    .guide-row.admin-editing .editable-description {
        border: none;
        padding: 0;
        cursor: default;
    }
}

/* ============================================================================
   MOBILE: Prototype Evolution card improvements
   ============================================================================ */

/* Prevent horizontal overflow while letting cards grow vertically */
#prototypeEvolutionSection .guide-row.glass-card {
    overflow-x: hidden;
    overflow-y: visible;
    max-width: 100%;
}

/* Override wallet.css .guide-row grid styles for prototype cards so the
   inner flexbox controls layout and the glass-card auto-sizes to content */
#prototypeEvolutionSection .guide-row.glass-card .image-card {
    overflow: hidden;
}

/* Prevent flex children from forcing overflow */
#prototypeEvolutionSection .guide-row .flex {
    min-width: 0;
}

/* Reset wallet.css .text-card visual styles for prototype cards —
   the glass-card already provides background/border */
#prototypeEvolutionSection .guide-row .text-card {
    grid-area: unset;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    min-width: 0;
}

#prototypeEvolutionSection .guide-row .text-card:hover {
    border-color: transparent;
    box-shadow: none;
}

@media (max-width: 767px) {
    /* Reset wallet.css display:grid — use block so the inner flex-col
       controls the vertical stack and the card grows to fit all content */
    #prototypeEvolutionSection .guide-row {
        display: block !important;
        padding-bottom: 0;
        border-bottom: none;
        overflow-x: hidden;
        overflow-y: visible;
    }

    /* The inner flex container must not exceed the card width */
    #prototypeEvolutionSection .guide-row > .flex {
        min-width: 0;
        overflow-x: hidden;
        overflow-y: visible;
    }

    /* Move image to the top of the card on mobile */
    #prototypeEvolutionSection .guide-row .image-card.flex-shrink-0 {
        order: -1;
        width: 100% !important;
        height: auto !important;
        max-height: 200px;
    }

    /* Version circle right after image */
    #prototypeEvolutionSection .guide-row .flex-shrink-0[class*="rounded-full"] {
        order: 0;
        margin: 0 auto;
    }

    /* Text card last, auto-size to content */
    #prototypeEvolutionSection .guide-row .text-card {
        order: 1;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-width: 0;
        overflow-x: hidden;
        overflow-y: visible;
        overflow-wrap: anywhere;
    }

    /* Description text scrollable when it exceeds card height */
    #prototypeEvolutionSection .guide-row .editable-description {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* Remove text-right alignment on mobile for readability */
    #prototypeEvolutionSection .guide-row.text-right {
        text-align: left !important;
    }

    /* Stack V-tag chips — allow horizontal scroll if needed */
    #prototypeEvolutionSection .flex-wrap.gap-2 {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
        padding-bottom: 0.25rem;
    }

    #prototypeEvolutionSection .flex-wrap.gap-2::-webkit-scrollbar {
        display: none;
    }
}
