<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('world_web_story_pages', function (Blueprint $table): void {
            $table->id();
            $table->foreignId('story_id')->constrained('world_web_stories')->cascadeOnDelete();
            $table->foreignId('artwork_id')->nullable()->constrained('artworks')->nullOnDelete();
            $table->unsignedInteger('position');
            $table->enum('layout', ['cover', 'artwork', 'creator', 'mood', 'collection', 'cta']);
            $table->enum('background_type', ['image', 'video', 'gradient']);
            $table->string('background_path')->nullable();
            $table->string('background_mobile_path')->nullable();
            $table->string('headline')->nullable();
            $table->text('body')->nullable();
            $table->string('cta_label')->nullable();
            $table->string('cta_url')->nullable();
            $table->text('alt_text')->nullable();
            $table->string('caption')->nullable();
            $table->string('credit_text')->nullable();
            $table->enum('text_position', ['top', 'center', 'bottom'])->default('bottom');
            $table->unsignedTinyInteger('overlay_strength')->default(35);
            $table->enum('animation', ['fade-in', 'fly-in-bottom', 'pulse', 'pan-left', 'pan-right'])->nullable();
            $table->boolean('active')->default(true);
            $table->timestamps();
            $table->softDeletes();

            $table->index(['story_id', 'position']);
            $table->index(['story_id', 'active']);
            $table->index('artwork_id');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('world_web_story_pages');
    }
};