/* write_page.css */

#write-page {
    width: 90%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Align title to the left */
    padding: 32px;
    gap: 24px;
}

#write-page h2 {
    font-size: 2em;
    color: #232946;
    margin-bottom: 16px;
}

.stories-grid {
    width: 100%;
    display: grid;
    /* This creates a responsive grid that fits as many 180px columns as possible */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 32px;
}

.story-card {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease-in-out;
}

.story-card:hover {
    transform: translateY(-5px);
}

.story-card .story-cover {
    width: 100%;
    /* Maintain a book-like aspect ratio */
    aspect-ratio: 2 / 3; 
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 8px 8px 16px rgba(0,0,0,0.22);
    background: #181a20; /* Placeholder color */
}

.story-card .story-title {
    color: #e0e5ff;
    font-weight: 500;
    margin-top: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* "Create New Story" button styling */
.create-new-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    aspect-ratio: 2 / 3; /* Match aspect ratio of other cards */
    border-radius: 4px;
    border: 2px dashed #444857;
    background-color: rgba(35, 36, 43, 0.5);
    color: #232946;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.create-new-card:hover {
    background-color: #23242b;
    color: #e0e5ff;
    border-color: #6a82fb;
}

.create-new-card svg {
    stroke: currentColor;
    margin-bottom: 8px;
}

.create-new-card span {
    font-weight: 500;
    text-align: center;
}

/* write_page.css - ADD THESE STYLES */

/* --- Story Editor View --- */
#story-editor-view {
    width: 100%;
    max-width: 800px; /* Constrain width for readability */
    flex-direction: column; /* Ensure it stacks vertically */
    gap: 20px;
}

.editor-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.editor-header h2 {
    margin: 0; /* Remove default margin */
}

.editor-actions {
    display: flex;
    gap: 10px;
}

.editor-field {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.editor-field label {
    font-weight: 600;
    color: #b9bde6;
}

/* The "Inset" Panel Style */
.inset-panel {
    background-color: #1c1e24; /* A color slightly different from the background */
    border: 1px solid #111;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 1rem;
    color: #e0e5ff;
    width: 100%;
    box-sizing: border-box; /* Important for padding and width */
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); /* The key to the inset look */
    transition: all 0.2s;
}

.inset-panel:focus {
    outline: none;
    background-color: #181a20;
    border-color: #6a82fb;
}

textarea.inset-panel {
    resize: vertical; /* Allow vertical resizing */
    font-family: 'Segoe UI', Arial, sans-serif;
}


/* --- Genre Selector --- */
.genre-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.genre-tag {
    display: inline-block;
    padding: 8px 16px;
    background-color: #232946;
    color: #e0e5ff;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    user-select: none; /* Prevent text selection on click */
}

/* Hide the actual checkbox */
.genre-tag input[type="checkbox"] {
    display: none;
}

/* Style the tag when its checkbox is checked */
.genre-tag input[type="checkbox"]:checked + label, /* This is for future use */
.genre-tag input[type="checkbox"]:checked {
    background: linear-gradient(90deg, #6a82fb 0%, #fc5c7d 100%);
    font-weight: 600;
}
.genre-tag:has(input:checked) { /* A modern way to style the parent label */
    background: linear-gradient(90deg, #6a82fb 0%, #fc5c7d 100%);
    font-weight: 600;
    color: #fff;
}

/* write_page.css */

.char-counter {
    text-align: right;
    font-size: 0.8em;
    color: #888da1; /* A muted color */
    padding-right: 4px;
}
