/* ============================================
   SCREENWRITER PRO - Screenplay Formatting
   Industry-standard screenplay layout
   ============================================ */

/* ============================================
   Page Layout
   Standard: 8.5" x 11", Courier 12pt
   Margins: 1.5" left, 1" right, 1" top/bottom
   ============================================ */

.page {
    /* Page dimensions - scaled for screen */
    width: 8.5in;
    min-height: 11in;
    padding: 1in 1in 1in 1.5in;

    /* Paper appearance */
    background: var(--color-bg-page);
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.3),
        0 10px 40px rgba(0, 0, 0, 0.4);
    border-radius: var(--radius-sm);

    /* Typography */
    font-family: var(--font-screenplay);
    font-size: 12pt;
    line-height: 1;
    color: var(--color-text-page);

    /* Content */
    position: relative;
}

/* Page number */
.page::before {
    content: attr(data-page-number);
    position: absolute;
    top: 0.5in;
    right: 1in;
    font-family: var(--font-screenplay);
    font-size: 12pt;
    color: var(--color-text-page);
}

/* ============================================
   Element Base Styles
   ============================================ */

.element {
    position: relative;
    outline: none;
    min-height: 1em;
    line-height: 1;
    margin-bottom: 12pt;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.element:focus {
    background: rgba(124, 58, 237, 0.05);
    border-radius: 2px;
}

/* Placeholder text for empty elements */
.element:empty::before {
    content: attr(data-placeholder);
    color: #999;
    font-style: italic;
    pointer-events: none;
}

.element:focus:empty::before {
    content: '';
}

/* ============================================
   Scene Heading (Slug Line)
   INT./EXT. LOCATION - TIME
   ============================================ */

.element.scene-heading,
.element[data-type="scene-heading"] {
    text-transform: uppercase;
    font-weight: bold;
    margin-top: 24pt;
    margin-bottom: 12pt;
}

.element.scene-heading:first-child,
.element[data-type="scene-heading"]:first-child {
    margin-top: 0;
}

/* Scene heading indicator */
.element.scene-heading::after,
.element[data-type="scene-heading"]::after {
    content: '';
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 100%;
    min-height: 14px;
    background: linear-gradient(135deg, var(--color-accent-primary), var(--color-accent-secondary));
    border-radius: 2px;
    opacity: 0.7;
}

/* ============================================
   Action (Description)
   Full width, normal case
   ============================================ */

.element.action,
.element[data-type="action"] {
    /* Default styling - full width */
    margin-bottom: 12pt;
}

/* ============================================
   Character Name
   ALL CAPS, indented ~3.7" from page left
   Page left padding is 1.5". We need 2.2" more.
   ============================================ */

.element.character,
.element[data-type="character"] {
    text-transform: uppercase;
    margin-left: 2.2in; /* 1.5 + 2.2 = 3.7in */
    margin-top: 12pt;
    margin-bottom: 0;
    width: auto;
}

/* ============================================
   Dialogue
   Indented ~2.5" from page left.
   Page left padding is 1.5". We need 1.0" more.
   Max width ~3.5" to 4".
   ============================================ */

.element.dialogue,
.element[data-type="dialogue"] {
    margin-left: 1.0in; /* 1.5 + 1.0 = 2.5in */
    width: 3.5in;
    margin-top: 0;
    margin-bottom: 12pt;
}

/* ============================================
   Parenthetical
   Indented ~3.1" from page left.
   Page left padding is 1.5". We need 1.6" more.
   ============================================ */

.element.parenthetical,
.element[data-type="parenthetical"] {
    margin-left: 1.6in; /* 1.5 + 1.6 = 3.1in */
    width: 2.0in;
    margin-top: 0;
    margin-bottom: 0;
}

/* ============================================
   Page Break
   ============================================ */

.page-break {
    position: relative;
    height: 2px;
    margin: 24pt 0;
    background: linear-gradient(90deg, transparent, var(--color-border), transparent);
}

.page-break::before {
    content: 'PAGE BREAK';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 2px 12px;
    background: var(--color-bg-page);
    font-size: 8pt;
    color: #999;
    letter-spacing: 1px;
}

/* ============================================
   Continued (CONT'D)
   ============================================ */

.character-continued::after {
    content: " (CONT'D)";
}

/* MORE and CONTINUED at page breaks */
.page-break-more::after {
    content: '(MORE)';
    display: block;
    text-align: center;
    margin-top: 12pt;
    font-family: var(--font-screenplay);
}

.page-break-continued::before {
    content: attr(data-character) " (CONT'D)";
    display: block;
    text-transform: uppercase;
    margin-left: 2.2in;
    margin-bottom: 0;
}

/* ============================================
   Notes / Comments (off-script)
   ============================================ */

.note {
    position: absolute;
    right: -2in;
    width: 1.8in;
    padding: 8px 12px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: 10pt;
    color: #856404;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.note-indicator {
    position: absolute;
    right: 0;
    top: 0;
    width: 8px;
    height: 8px;
    background: #ffc107;
    border-radius: 50%;
}

/* ============================================
   Revision Marks
   ============================================ */

.revision-insert {
    background: rgba(63, 185, 80, 0.2);
    border-bottom: 2px solid var(--color-success);
}

.revision-delete {
    background: rgba(248, 81, 73, 0.2);
    text-decoration: line-through;
    color: var(--color-danger);
}

.revision-asterisk::after {
    content: '*';
    position: absolute;
    right: -0.3in;
    color: var(--color-accent-primary);
}

/* ============================================
   Selection and Cursor
   ============================================ */

.element::selection,
.element *::selection {
    background: rgba(124, 58, 237, 0.3);
}

/* Remote cursor (for collaboration) */
.remote-cursor {
    position: absolute;
    width: 2px;
    height: 1.2em;
    animation: blink 1s infinite;
}

.remote-cursor-label {
    position: absolute;
    top: -18px;
    left: 0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-ui);
    font-size: 10px;
    color: white;
    white-space: nowrap;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

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

@media print {
    body {
        background: white;
    }

    .toolbar,
    .sidebar,
    .status-bar,
    .note,
    .page-break::before,
    .element.scene-heading::after,
    .element.character::before,
    .remote-cursor,
    .remote-cursor-label {
        display: none !important;
    }

    .page-wrapper {
        padding: 0;
        overflow: visible;
    }

    .page {
        box-shadow: none;
        border-radius: 0;
        width: 100%;
        min-height: auto;
        page-break-after: always;
    }

    .element:focus {
        background: none;
    }
}

/* ============================================
   Element Type Colors (for visual distinction)
   ============================================ */

/* Optional: subtle left border colors */
.element.scene-heading {
    border-left-color: #7c3aed;
}

.element.action {
    border-left-color: transparent;
}

.element.character {
    border-left-color: #3b82f6;
}

.element.dialogue {
    border-left-color: #10b981;
}

.element.parenthetical {
    border-left-color: #f59e0b;
}

.element.transition {
    border-left-color: #ec4899;
}

/* ============================================
   Responsive Screenplay (smaller screens)
   ============================================ */

@media (max-width: 900px) {
    .page {
        width: 100%;
        min-width: 320px;
        padding: 0.5in;
        font-size: 11pt;
    }

    .element.character,
    .element[data-type="character"] {
        margin-left: 1.5in;
    }

    .element.dialogue,
    .element[data-type="dialogue"] {
        margin-left: 0.5in;
        width: auto;
        max-width: 3.5in;
    }

    .element.parenthetical,
    .element[data-type="parenthetical"] {
        margin-left: 0.8in;
        width: auto;
        max-width: 2in;
    }

    .element.scene-heading::after,
    .element.character::before {
        display: none;
    }
}