/**
 * Block Editor Styles for Headline Ligatures & Styles
 */

/* Toolbar Button */
.typost-toolbar-button {
    position: relative;
}

.typost-toolbar-button.is-pressed {
    background-color: #1e1e1e;
}

.typost-toolbar-button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
    box-shadow: 0 0 0 1px #fff, 0 0 0 3px #0073aa;
}

/* Main Popover */
.typost-popover {
    z-index: 1000000;
}

.typost-popover .components-popover__content {
    min-width: 400px;
    max-width: 500px;
    max-height: 600px;
    overflow-y: hidden; /* Prevent outer scroll, let inner scrollable-content handle it */
    display: flex;
    flex-direction: column;
}

.typost-popover-content {
    padding: 0;
    display: flex;
    flex-direction: column;
    max-height: 600px;
}

/* Sticky Notice Wrapper */
.typost-sticky-notice-wrapper {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    border-bottom: 1px solid #ddd;
}

.typost-sticky-notice-wrapper .components-notice {
    margin: 0;
    border-radius: 0;
}

.typost-convert-link.components-button.is-link {
    font-size: inherit;
    padding: 0;
    height: auto;
    min-height: 0;
    vertical-align: baseline;
    text-decoration: underline;
}

/* Scrollable Content Wrapper */
.typost-scrollable-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.typost-popover-header {
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
    background: #f9f9f9;
}

.typost-popover-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1e1e1e;
}

/* Presets Section */
.typost-presets-section {
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
}

.typost-presets-section h4 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: #1e1e1e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.typost-presets-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.typost-preset-button {
    padding: 12px 14px;
    text-align: left;
    height: auto;
    min-height: 44px;
    white-space: normal;
    border-radius: 4px;
    transition: all 0.2s;
}

.typost-preset-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.typost-preset-button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.typost-preset-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
}

.typost-preset-features-list {
    font-size: 12px;
    color: #5e5e5e;
    font-family: monospace;
}

/* Features Section */
.typost-features-section {
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
    max-height: 300px;
    overflow-y: auto;
}

.typost-features-section h4 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: #1e1e1e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.typost-feature-category {
    margin-bottom: 0;
}

.typost-feature-category .components-panel__body-title {
    font-size: 13px;
    font-weight: 600;
}

.typost-feature-toggle {
    position: relative;
    padding: 8px 0;
    border-bottom: 1px solid #ddd;
}

.typost-feature-toggle:last-child {
    border-bottom: none;
}

.typost-feature-toggle .components-toggle-control {
    margin-bottom: 0;
}

.typost-feature-toggle .components-base-control__label {
    font-weight: 500;
    font-size: 13px;
}

.typost-feature-toggle .components-toggle-control__help {
    font-size: 13px;
    color: #5e5e5e;
    margin-top: 4px;
}

.typost-feature-code {
    position: absolute;
    top: 12px;
    right: 0;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-family: monospace;
    color: #1e1e1e;
}

/* Feature Preview Container */
.typost-feature-preview {
    margin-top: 8px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Interactive Feature Preview Button */
.typost-feature-apply-btn,
.components-button.typost-feature-apply-btn,
.editor-visual-editor .components-button.typost-feature-apply-btn {
    width: 100% !important;
    padding: 20px !important;
    background: #fff;
    border: 2px solid #e0e0e0 !important;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 54px !important;
    line-height: 1 !important;
    color: #000;
    font-weight: 500;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: none !important;
    min-height: auto !important;
    height: auto !important;
}

.typost-feature-apply-btn:hover {
    background: #f0f6fc;
    border-color: #2271b1 !important;
    box-shadow: 0 2px 4px rgba(34, 113, 177, 0.15);
}

.typost-feature-apply-btn:active {
    box-shadow: 0 1px 2px rgba(34, 113, 177, 0.2);
}

.typost-feature-apply-btn:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
    box-shadow: none;
}

/* Hover and active transforms - only when motion is preferred */
@media (prefers-reduced-motion: no-preference) {
    .typost-feature-apply-btn:hover,
    .components-button.typost-feature-apply-btn:hover,
    .editor-visual-editor .components-button.typost-feature-apply-btn:hover {
        transform: translateY(-1px);
    }

    .typost-feature-apply-btn:active,
    .components-button.typost-feature-apply-btn:active,
    .editor-visual-editor .components-button.typost-feature-apply-btn:active {
        transform: translateY(0);
    }
}

/* Preview Section */
.typost-preview-section {
    padding: 16px 20px;
    background: #f9f9f9;
    border-bottom: 1px solid #ddd;
}

.typost-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.typost-preview-section h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #1e1e1e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.typost-preview-device-toggle {
    display: flex;
    gap: 0;
}

.typost-preview-device-toggle .components-button {
    min-height: 32px;
    padding: 4px 12px;
    font-size: 12px;
}

.typost-preview-text {
    font-size: 24px;
    padding: 16px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    margin-bottom: 12px;
    line-height: 1.4;
}

.typost-preview-features {
    font-size: 13px;
    color: #1e1e1e;
    font-family: monospace;
}

.typost-preview-features strong {
    font-weight: 600;
    color: #1e1e1e;
}

/* Clear Confirmation - Inline */
.typost-clear-confirmation-inline {
    padding: 0;
    margin: 0;
}

.typost-clear-confirmation-inline .components-notice {
    margin: 0;
    border-radius: 0;
}

.typost-clear-confirmation-inline .components-button-group {
    display: flex;
    gap: 8px;
    width: 100%;
}

.typost-clear-confirmation-inline .components-button {
    flex: 1;
    justify-content: center;
}

/* Action Buttons */
.typost-popover-actions {
    padding: 16px 20px;
    background: #f9f9f9;
}

.typost-popover-actions .components-button-group {
    display: flex;
    gap: 8px;
    width: 100%;
}

.typost-popover-actions .components-button {
    flex: 1;
    justify-content: center;
    min-height: 44px;
}

.typost-popover-actions .components-button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Styled Text in Editor */
.typost-styled {
    position: relative;
    border-bottom: 1px dotted rgba(0, 122, 204, 0.4);
}

.typost-styled:hover {
    background: rgba(0, 122, 204, 0.05);
}

/* Scrollbar Styling */
.typost-features-section::-webkit-scrollbar,
.typost-popover .components-popover__content::-webkit-scrollbar {
    width: 8px;
}

.typost-features-section::-webkit-scrollbar-track,
.typost-popover .components-popover__content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.typost-features-section::-webkit-scrollbar-thumb,
.typost-popover .components-popover__content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.typost-features-section::-webkit-scrollbar-thumb:hover,
.typost-popover .components-popover__content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive Adjustments */
@media (max-width: 600px) {
    .typost-popover .components-popover__content {
        min-width: 300px;
        max-width: 90vw;
    }

    .typost-presets-grid {
        grid-template-columns: 1fr;
    }
}

/* Animation - Respect reduced motion preference */
@media (prefers-reduced-motion: no-preference) {
    @keyframes hlsFadeIn {
        from {
            opacity: 0;
            transform: translateY(-4px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .typost-popover .components-popover__content {
        animation: hlsFadeIn 0.2s ease-out;
    }

    .typost-preset-button:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        transition: all 0.2s;
    }
}

@media (prefers-reduced-motion: reduce) {
    .typost-popover .components-popover__content {
        animation: none;
    }

    .typost-preset-button:hover {
        transform: none;
        box-shadow: 0 0 0 2px #0073aa;
        transition: none;
    }
}

/* Font, Font Weight, Letter Spacing, and Font Size Sections */
.typost-font-section,
.typost-fontweight-section,
.typost-letterspacing-section,
.typost-lineheight-section,
.typost-fontsize-section {
    margin: 0 1rem;
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
}

.typost-font-section h4,
.typost-fontweight-section h4,
.typost-letterspacing-section h4,
.typost-lineheight-section h4,
.typost-fontsize-section h4 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: #1e1e1e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Accessibility Warning */
.typost-accessibility-warning {
    padding: 16px 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    margin: 16px 20px;
}

.typost-warning-message {
    font-size: 13px;
    color: #856404;
    margin: 0 0 12px 0;
    line-height: 1.5;
}

.typost-accessibility-warning .components-button-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.typost-accessibility-warning .components-button {
    width: 100%;
    justify-content: center;
    min-height: 36px;
}

.typost-warning-settings-link {
    margin: 8px 0 0 0;
    font-size: 12px;
    text-align: right;
}

.typost-warning-settings-link a {
    color: #0073aa;
    text-decoration: underline;
}

/* Active Feature Panel Highlighting */
.typost-feature-category-panel.has-active-features > .components-panel__body-title {
    background-color: #f0f6fc !important;
}

.typost-feature-category-panel.has-active-features > .components-panel__body-title button {
    color: #0783be !important;
    font-weight: 600 !important;
}

/* ========================================
   Modal Styles - Draggable & Resizable
   ======================================== */

/* Reduce background dimming - much more transparent */
.typost-modal .components-modal__screen-overlay {
    background-color: rgba(0, 0, 0, 0.1) !important;
}

/* Modal frame positioning overrides */
.typost-modal .components-modal__frame {
    position: fixed !important;
    transform: none !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
    background-color: #fff;
}

/* Override WordPress modal content padding */
.typost-modal .components-modal__content,
.typost-modal .components-modal__content.hide-header {
    margin-top: 0 !important;
    padding: 0 !important;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Draggable header */
.typost-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
    background: #f9f9f9;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 20;
    flex-shrink: 0;
}

.typost-modal-header:active {
    cursor: grabbing;
}

.typost-modal.is-dragging .typost-modal-header {
    cursor: grabbing;
}

.typost-modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1e1e1e;
    pointer-events: none;
    flex: 1;
}

.typost-modal-header:focus {
    outline: 2px solid #0073aa;
    outline-offset: -2px;
}

/* Close button styling */
.typost-modal-close-button {
    flex-shrink: 0;
    margin-left: 16px;
    pointer-events: auto;
}

.typost-modal-close-button:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Modal content wrapper with scroll */
.typost-modal-content {
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
}

/* Scrollbar styling for modal content */
.typost-modal-content::-webkit-scrollbar {
    width: 8px;
}

.typost-modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.typost-modal-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.typost-modal-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Resize handles container */
.typost-resize-handles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* Individual resize handles */
.typost-resize-handle {
    position: absolute;
    pointer-events: auto;
    z-index: 10;
}

/* Corner handles - larger hit area (16px) */
.typost-resize-handle-ne,
.typost-resize-handle-nw,
.typost-resize-handle-se,
.typost-resize-handle-sw {
    width: 16px;
    height: 16px;
}

/* Edge handles - 8px hit area */
.typost-resize-handle-n,
.typost-resize-handle-s {
    left: 16px;
    right: 16px;
    height: 8px;
}

.typost-resize-handle-e,
.typost-resize-handle-w {
    top: 16px;
    bottom: 16px;
    width: 8px;
}

/* Positioning */
.typost-resize-handle-n {
    top: 0;
    cursor: ns-resize;
}

.typost-resize-handle-ne {
    top: 0;
    right: 0;
    cursor: nesw-resize;
}

.typost-resize-handle-e {
    right: 0;
    cursor: ew-resize;
}

.typost-resize-handle-se {
    bottom: 0;
    right: 0;
    cursor: nwse-resize;
}

.typost-resize-handle-s {
    bottom: 0;
    cursor: ns-resize;
}

.typost-resize-handle-sw {
    bottom: 0;
    left: 0;
    cursor: nesw-resize;
}

.typost-resize-handle-w {
    left: 0;
    cursor: ew-resize;
}

.typost-resize-handle-nw {
    top: 0;
    left: 0;
    cursor: nwse-resize;
}

/* Visual indicator for SE corner (most common resize) */
.typost-resize-handle-se::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background-image: linear-gradient(
        135deg,
        transparent 0%,
        transparent 46%,
        #999 46%,
        #999 54%,
        transparent 54%
    );
    opacity: 0.4;
}

.typost-modal.is-resizing .typost-resize-handle-se::after {
    opacity: 0.8;
}

/* Modal state classes */
.typost-modal.is-dragging {
    -webkit-user-select: none;
    user-select: none;
}

.typost-modal.is-resizing {
    -webkit-user-select: none;
    user-select: none;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .typost-modal .components-modal__frame {
        transition: none !important;
    }
}
