/* ── AI Story Prompt Generator — Widget Styles ────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400;1,600&family=DM+Sans:wght@400;500&display=swap');

/* Custom properties */
.aspg-widget {
    --aspg-ink:        #1a1209;
    --aspg-parchment:  #fdf6e8;
    --aspg-cream:      #f5ead0;
    --aspg-amber:      #b8842a;
    --aspg-amber-dark: #8a5f18;
    --aspg-amber-glow: rgba(184,132,42,0.15);
    --aspg-border:     rgba(184,132,42,0.35);
    --aspg-text-muted: #7a6545;
    --aspg-error:      #c0392b;
    --aspg-radius:     12px;
    --aspg-shadow:     0 4px 32px rgba(26,18,9,0.12), 0 1px 4px rgba(26,18,9,0.08);

    font-family: 'DM Sans', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--aspg-ink);
}

/* ── Widget shell ─────────────────────────────────────────────────────── */

.aspg-inner {
    background: var(--aspg-parchment);
    border: 1.5px solid var(--aspg-border);
    border-radius: var(--aspg-radius);
    box-shadow: var(--aspg-shadow);
    max-width: 580px;
    margin: 2rem auto;
    overflow: hidden;
    position: relative;
}

/* Decorative top stripe */
.aspg-inner::before {
    content: '';
    display: block;
    height: 4px;
    background: linear-gradient(90deg, var(--aspg-amber-dark) 0%, var(--aspg-amber) 50%, var(--aspg-amber-dark) 100%);
}

/* Subtle parchment texture */
.aspg-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(ellipse at 80% 10%, rgba(184,132,42,0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 20% 90%, rgba(184,132,42,0.05) 0%, transparent 50%);
}

/* ── Header ───────────────────────────────────────────────────────────── */

.aspg-header {
    padding: 2rem 2rem 1.25rem;
    text-align: center;
    position: relative;
    z-index: 1;
}

.aspg-quill-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 0.75rem;
    color: var(--aspg-amber);
    opacity: 0.9;
}

.aspg-quill-icon svg {
    width: 100%;
    height: 100%;
}

.aspg-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.9rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 0.35rem;
    color: var(--aspg-ink);
    line-height: 1.2;
}

.aspg-subtitle {
    font-size: 0.88rem;
    color: var(--aspg-text-muted);
    margin: 0;
    letter-spacing: 0.01em;
}

/* ── Form ─────────────────────────────────────────────────────────────── */

.aspg-form {
    padding: 0 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    z-index: 1;
}

.aspg-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--aspg-text-muted);
    margin-bottom: 0.4rem;
}

.aspg-select-wrapper {
    display: flex;
    flex-direction: column;
}

.aspg-select-box {
    position: relative;
}

.aspg-select-box select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    color: var(--aspg-ink);
    background: var(--aspg-cream);
    border: 1.5px solid var(--aspg-border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.aspg-select-box select:focus {
    border-color: var(--aspg-amber);
    box-shadow: 0 0 0 3px var(--aspg-amber-glow);
}

.aspg-select-box select:hover {
    border-color: var(--aspg-amber);
}

.aspg-chevron {
    position: absolute;
    right: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--aspg-text-muted);
    pointer-events: none;
    transition: transform 0.2s;
}

.aspg-chevron svg {
    width: 100%;
    height: 100%;
}

/* ── Generate button ──────────────────────────────────────────────────── */

.aspg-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: #fff;
    background: linear-gradient(135deg, var(--aspg-amber) 0%, var(--aspg-amber-dark) 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 2px 12px rgba(184,132,42,0.35);
    outline: none;
}

.aspg-btn:hover:not(:disabled) {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 4px 18px rgba(184,132,42,0.45);
}

.aspg-btn:active:not(:disabled) {
    transform: translateY(0);
}

.aspg-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.aspg-btn-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.aspg-btn:hover:not(:disabled) .aspg-btn-icon {
    transform: translateX(3px);
}

.aspg-btn-icon svg {
    width: 100%;
    height: 100%;
}

/* ── Result area ──────────────────────────────────────────────────────── */

.aspg-result-area {
    margin: 0 2rem 2rem;
    min-height: 100px;
    border: 1.5px dashed var(--aspg-border);
    border-radius: 8px;
    background: rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    overflow: hidden;
    transition: border-color 0.3s;
}

.aspg-result-area:has(.aspg-result-output:not([hidden])) {
    border-style: solid;
    border-color: var(--aspg-border);
}

/* Idle state */
.aspg-result-idle {
    text-align: center;
    padding: 1.5rem;
    color: var(--aspg-text-muted);
}

.aspg-result-idle p {
    font-size: 0.88rem;
    margin: 0.5rem 0 0;
    font-style: italic;
}

.aspg-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--aspg-border);
    border-radius: 50%;
    margin: 0 3px;
    animation: aspg-pulse 1.4s ease-in-out infinite;
}

.aspg-dot:nth-child(2) { animation-delay: 0.2s; }
.aspg-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes aspg-pulse {
    0%, 80%, 100% { transform: scale(1); opacity: 0.4; }
    40%           { transform: scale(1.3); opacity: 1; }
}

/* Loading state */
.aspg-result-loading {
    text-align: center;
    padding: 1.5rem;
    color: var(--aspg-text-muted);
}

.aspg-result-loading p {
    font-size: 0.88rem;
    margin: 0.5rem 0 0;
    font-style: italic;
}

.aspg-spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto;
    color: var(--aspg-amber);
    animation: aspg-spin 0.9s linear infinite;
}

.aspg-spinner svg {
    width: 100%;
    height: 100%;
}

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

/* Output state */
.aspg-result-output {
    padding: 1.5rem;
    width: 100%;
    animation: aspg-fade-in 0.5s ease;
}

@keyframes aspg-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.aspg-genre-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--aspg-amber-glow);
    color: var(--aspg-amber-dark);
    border: 1px solid var(--aspg-border);
    border-radius: 20px;
    margin-bottom: 0.9rem;
}

.aspg-prompt-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.2rem;
    font-style: italic;
    line-height: 1.65;
    color: var(--aspg-ink);
    margin: 0 0 1rem;
    padding: 0;
    border: none;
    quotes: '\201C' '\201D';
}

.aspg-prompt-text::before { content: open-quote; }
.aspg-prompt-text::after  { content: close-quote; }

.aspg-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--aspg-text-muted);
    background: transparent;
    border: 1px solid var(--aspg-border);
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    outline: none;
}

.aspg-copy-btn:hover {
    color: var(--aspg-amber-dark);
    border-color: var(--aspg-amber);
    background: var(--aspg-amber-glow);
}

.aspg-copy-btn svg {
    width: 14px;
    height: 14px;
}

/* Error state */
.aspg-result-error {
    padding: 1.25rem 1.5rem;
    text-align: center;
    color: var(--aspg-error);
}

.aspg-error-icon {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 0.4rem;
}

.aspg-result-error p {
    margin: 0;
    font-size: 0.9rem;
}

/* ── Attribution ──────────────────────────────────────────────────────── */

.aspg-attribution {
    text-align: center;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-size: 0.88rem;
    color: var(--aspg-text-muted);
    margin: 0.5rem auto 0;
    max-width: 580px;
    letter-spacing: 0.01em;
    opacity: 0.8;
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .aspg-header { padding: 1.5rem 1.25rem 1rem; }
    .aspg-form   { padding: 0 1.25rem 1.25rem; }
    .aspg-result-area { margin: 0 1.25rem 1.5rem; }
    .aspg-title  { font-size: 1.55rem; }
}
