/**
 * AI Web Stories Frontend CSS
 * Public-facing styles for the plugin
 */

/* ==========================================================================
   Story Embed Styles
   ========================================================================== */

.ai-web-story-embed {
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-web-story-embed p {
    margin: 0;
    font-size: 16px;
    color: #495057;
    line-height: 1.5;
}

.ai-web-story-embed a {
    color: #007cba;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.ai-web-story-embed a:hover {
    color: #005177;
    text-decoration: underline;
}

.ai-web-story-embed a:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ==========================================================================
   Story Preview Styles (for unsaved stories)
   ========================================================================== */

.ai-web-story-preview {
    margin: 20px auto;
    max-width: 600px;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 20px;
    background: linear-gradient(135deg, #fff9c4 0%, #ffeaa7 100%);
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.2);
}

.ai-web-story-preview p {
    margin: 8px 0;
    color: #856404;
    line-height: 1.5;
}

.ai-web-story-preview p:first-child {
    font-weight: 600;
    font-size: 16px;
}

.ai-web-story-preview em {
    color: #6c5700;
    font-size: 14px;
    font-style: italic;
}

/* ==========================================================================
   Story Placeholder Styles
   ========================================================================== */

.ai-web-story-placeholder {
    margin: 20px auto;
    max-width: 600px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    background: #f8f9fa;
    color: #6c757d;
}

.ai-web-story-placeholder p {
    margin: 0;
    font-size: 14px;
    font-style: italic;
    line-height: 1.5;
}

.ai-web-story-placeholder::before {
    content: "📱";
    font-size: 32px;
    display: block;
    margin-bottom: 10px;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.ai-web-story-loading {
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
    padding: 40px 20px;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    background: #f8f9fa;
}

.ai-web-story-loading::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #007cba;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

.ai-web-story-loading::after {
    content: "Loading AI Web Story...";
    color: #6c757d;
    font-size: 14px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Error States
   ========================================================================== */

.ai-web-story-error {
    margin: 20px auto;
    max-width: 600px;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 20px;
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    text-align: center;
}

.ai-web-story-error::before {
    content: "⚠️";
    font-size: 24px;
    display: block;
    margin-bottom: 10px;
}

.ai-web-story-error p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* ==========================================================================
   Responsive Web Story Container
   ========================================================================== */

.ai-web-story-container {
    position: relative;
    margin: 20px auto;
    max-width: 400px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.ai-web-story-container::before {
    content: "";
    display: block;
    padding-top: 177.78%; /* 9:16 aspect ratio */
}

.ai-web-story-frame {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: none;
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

/* ==========================================================================
   Story Metadata
   ========================================================================== */

.ai-web-story-meta {
    margin: 15px auto;
    max-width: 400px;
    text-align: center;
    color: #6c757d;
    font-size: 13px;
}

.ai-web-story-meta .story-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 5px;
}

.ai-web-story-meta .story-info {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.ai-web-story-meta .story-info span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-web-story-meta .story-info span::before {
    font-size: 12px;
}

.ai-web-story-meta .slides-count::before {
    content: "📄";
}

.ai-web-story-meta .duration::before {
    content: "⏱️";
}

.ai-web-story-meta .ai-generated::before {
    content: "🤖";
}

/* ==========================================================================
   Story Actions
   ========================================================================== */

.ai-web-story-actions {
    margin: 15px auto;
    max-width: 400px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ai-web-story-actions a,
.ai-web-story-actions button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    border: 1px solid #007cba;
    border-radius: 4px;
    color: #007cba;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-web-story-actions a:hover,
.ai-web-story-actions button:hover {
    background: #007cba;
    color: white;
}

.ai-web-story-actions a:focus,
.ai-web-story-actions button:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.ai-web-story-actions .primary {
    background: #007cba;
    color: white;
}

.ai-web-story-actions .primary:hover {
    background: #005177;
}

/* ==========================================================================
   Widget Styles
   ========================================================================== */

.widget .ai-web-stories-widget {
    margin-bottom: 20px;
}

.widget .ai-web-story-embed {
    margin: 10px 0;
    padding: 15px;
    font-size: 14px;
}

.widget .ai-web-story-container {
    max-width: 100%;
    margin: 10px 0;
}

.widget .ai-web-story-meta {
    max-width: 100%;
    margin: 10px 0;
    font-size: 12px;
}

.widget .ai-web-story-actions {
    max-width: 100%;
    margin: 10px 0;
}

.widget .ai-web-story-actions a,
.widget .ai-web-story-actions button {
    font-size: 11px;
    padding: 6px 10px;
}

/* ==========================================================================
   Archive Page Styles
   ========================================================================== */

.post-type-archive-web-story .ai-web-story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    margin: 30px 0;
}

.post-type-archive-web-story .ai-web-story-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post-type-archive-web-story .ai-web-story-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.post-type-archive-web-story .story-thumbnail {
    aspect-ratio: 9 / 16;
    background: #f8f9fa;
    position: relative;
    overflow: hidden;
}

.post-type-archive-web-story .story-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-type-archive-web-story .story-content {
    padding: 20px;
}

.post-type-archive-web-story .story-title {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.post-type-archive-web-story .story-title a {
    color: #333;
    text-decoration: none;
}

.post-type-archive-web-story .story-title a:hover {
    color: #007cba;
}

.post-type-archive-web-story .story-excerpt {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

/* ==========================================================================
   Accessibility Features
   ========================================================================== */

.ai-web-story-embed:focus-within,
.ai-web-story-container:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

.skip-to-story {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.skip-to-story:focus {
    position: static;
    width: auto;
    height: auto;
    background: #007cba;
    color: white;
    padding: 8px 12px;
    text-decoration: none;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 10px;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .ai-web-story-embed,
    .ai-web-story-preview,
    .ai-web-story-placeholder {
        background: white !important;
        border: 1px solid #000 !important;
        box-shadow: none !important;
        color: #000 !important;
    }
    
    .ai-web-story-actions,
    .ai-web-story-container {
        display: none !important;
    }
    
    .ai-web-story-embed::after {
        content: " (AI-generated Web Story)";
        font-size: 12px;
        color: #666;
    }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .ai-web-story-embed {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .ai-web-story-embed a {
        color: #63b3ed;
    }
    
    .ai-web-story-embed a:hover {
        color: #90cdf4;
    }
    
    .ai-web-story-preview {
        background: linear-gradient(135deg, #744210 0%, #975a16 100%);
        border-color: #d69e2e;
        color: #fbb03b;
    }
    
    .ai-web-story-preview em {
        color: #f6e05e;
    }
    
    .ai-web-story-placeholder {
        background: #2d3748;
        border-color: #4a5568;
        color: #a0aec0;
    }
    
    .ai-web-story-loading {
        background: #2d3748;
        border-color: #4a5568;
        color: #a0aec0;
    }
    
    .ai-web-story-loading::before {
        border-color: #63b3ed;
        border-top-color: transparent;
    }
    
    .ai-web-story-meta {
        color: #a0aec0;
    }
    
    .ai-web-story-meta .story-title {
        color: #e2e8f0;
    }
    
    .ai-web-story-actions a,
    .ai-web-story-actions button {
        border-color: #63b3ed;
        color: #63b3ed;
    }
    
    .ai-web-story-actions a:hover,
    .ai-web-story-actions button:hover {
        background: #63b3ed;
        color: #1a202c;
    }
    
    .ai-web-story-actions .primary {
        background: #63b3ed;
        color: #1a202c;
    }
    
    .ai-web-story-actions .primary:hover {
        background: #90cdf4;
    }
}

/* ==========================================================================
   High Contrast Mode
   ========================================================================== */

@media (prefers-contrast: high) {
    .ai-web-story-embed,
    .ai-web-story-preview,
    .ai-web-story-placeholder {
        border-width: 2px;
        border-color: #000;
    }
    
    .ai-web-story-actions a,
    .ai-web-story-actions button {
        border-width: 2px;
        border-color: #000;
        color: #000;
    }
    
    .ai-web-story-actions a:hover,
    .ai-web-story-actions button:hover {
        background: #000;
        color: #fff;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .ai-web-story-embed,
    .ai-web-story-actions a,
    .ai-web-story-actions button,
    .post-type-archive-web-story .ai-web-story-card {
        transition: none;
    }
    
    .post-type-archive-web-story .ai-web-story-card:hover {
        transform: none;
    }
    
    .ai-web-story-loading::before {
        animation: none;
    }
    
    .ai-web-story-loading::before {
        content: "⏳";
        width: auto;
        height: auto;
        border: none;
        margin-right: 5px;
    }
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */

@media screen and (max-width: 768px) {
    .ai-web-story-embed,
    .ai-web-story-preview,
    .ai-web-story-placeholder {
        margin: 15px auto;
        padding: 15px;
    }
    
    .ai-web-story-container {
        max-width: 300px;
        margin: 15px auto;
    }
    
    .ai-web-story-meta,
    .ai-web-story-actions {
        max-width: 300px;
        margin: 10px auto;
    }
    
    .ai-web-story-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .ai-web-story-actions a,
    .ai-web-story-actions button {
        width: 100%;
        justify-content: center;
        max-width: 200px;
    }
    
    .post-type-archive-web-story .ai-web-story-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        margin: 20px 0;
    }
    
    .post-type-archive-web-story .story-content {
        padding: 15px;
    }
}

@media screen and (max-width: 480px) {
    .ai-web-story-embed,
    .ai-web-story-preview,
    .ai-web-story-placeholder {
        margin: 10px;
        padding: 12px;
        font-size: 14px;
    }
    
    .ai-web-story-container {
        max-width: 280px;
    }
    
    .ai-web-story-meta {
        font-size: 12px;
    }
    
    .ai-web-story-meta .story-info {
        flex-direction: column;
        gap: 5px;
    }
    
    .post-type-archive-web-story .story-title {
        font-size: 16px;
    }
    
    .post-type-archive-web-story .story-excerpt {
        font-size: 13px;
    }
}
