/**
 * Classic Editor Content Styles
 * 
 * This file provides styling for WordPress Classic Editor (TinyMCE) content
 * to ensure consistent appearance between the editor and frontend.
 * 
 * All styles are scoped under .entry-content to avoid conflicts with
 * global styles and Tailwind CSS.
 * 
 * @package TamanTheme
 * @author  TGN Digital
 */

/* ==========================================================================
   Base Content Wrapper
   ========================================================================== */

.entry-content {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.75;
    color: hsl(var(--foreground) / 0.9);
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
}

/* ==========================================================================
   Headings
   ========================================================================== */

.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6 {
    font-weight: 700;
    line-height: 1.3;
    color: hsl(var(--foreground));
    margin-top: 2em;
    margin-bottom: 0.75em;
    scroll-margin-top: 6rem;
}

.entry-content h1:first-child,
.entry-content h2:first-child,
.entry-content h3:first-child,
.entry-content h4:first-child,
.entry-content h5:first-child,
.entry-content h6:first-child {
    margin-top: 0;
}

.entry-content h1 {
    font-size: 2.25rem; /* 36px */
    margin-top: 0;
}

.entry-content h2 {
    font-size: 1.875rem; /* 30px */
    margin-top: 2.5em;
    margin-bottom: 1.5rem;
}

.entry-content h3 {
    font-size: 1.5rem; /* 24px */
    margin-top: 2em;
    margin-bottom: 1rem;
}

.entry-content h4 {
    font-size: 1.25rem; /* 20px */
    margin-top: 1.75em;
    margin-bottom: 0.75rem;
}

.entry-content h5 {
    font-size: 1.125rem; /* 18px */
    margin-top: 1.5em;
    margin-bottom: 0.5rem;
}

.entry-content h6 {
    font-size: 1rem; /* 16px */
    margin-top: 1.5em;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Responsive Headings */
@media (max-width: 768px) {
    .entry-content h1 {
        font-size: 1.875rem; /* 30px */
    }
    
    .entry-content h2 {
        font-size: 1.5rem; /* 24px */
    }
    
    .entry-content h3 {
        font-size: 1.25rem; /* 20px */
    }
}

/* ==========================================================================
   Paragraphs
   ========================================================================== */

.entry-content p {
    margin-top: 0;
    margin-bottom: 1.5rem;
    line-height: 1.75;
}

.entry-content p:last-child {
    margin-bottom: 0;
}

/* First paragraph drop cap (optional) */
.entry-content > p:first-of-type::first-letter {
    /* Uncomment to enable drop cap effect
    float: left;
    font-size: 3.5em;
    line-height: 0.8;
    margin-right: 0.1em;
    margin-top: 0.1em;
    color: hsl(var(--primary));
    font-weight: 700;
    */
}

/* ==========================================================================
   Lists
   ========================================================================== */

.entry-content ul,
.entry-content ol {
    margin-top: 0;
    margin-bottom: 1.5rem;
    padding-left: 1.625rem;
}

.entry-content ul {
    list-style-type: disc;
}

.entry-content ol {
    list-style-type: decimal;
}

.entry-content li {
    margin-bottom: 0.5rem;
    line-height: 1.75;
}

.entry-content li:last-child {
    margin-bottom: 0;
}

/* Nested lists */
.entry-content ul ul,
.entry-content ol ol,
.entry-content ul ol,
.entry-content ol ul {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.entry-content ul ul {
    list-style-type: circle;
}

.entry-content ul ul ul {
    list-style-type: square;
}

/* List item paragraphs */
.entry-content li > p {
    margin-bottom: 0.75rem;
}

.entry-content li > p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   Links
   ========================================================================== */

.entry-content a {
    color: hsl(var(--primary));
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.entry-content a:hover {
    color: hsl(var(--primary) / 0.8);
    text-decoration-thickness: 2px;
}

.entry-content a:focus {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
    border-radius: 2px;
}

/* ==========================================================================
   Strong & Emphasis
   ========================================================================== */

.entry-content strong,
.entry-content b {
    font-weight: 600;
    color: hsl(var(--foreground));
}

.entry-content em,
.entry-content i {
    font-style: italic;
}

/* ==========================================================================
   Blockquotes
   ========================================================================== */

.entry-content blockquote {
    margin: 2rem 0;
    padding: 1.25rem 1.5rem;
    border-left: 4px solid hsl(var(--primary));
    background-color: hsl(var(--muted) / 0.3);
    font-style: italic;
    color: hsl(var(--foreground) / 0.8);
    border-radius: 0 0.5rem 0.5rem 0;
}

.entry-content blockquote p {
    margin-bottom: 0.75rem;
}

.entry-content blockquote p:last-child {
    margin-bottom: 0;
}

.entry-content blockquote cite {
    display: block;
    margin-top: 1rem;
    font-size: 0.875rem;
    font-style: normal;
    color: hsl(var(--muted-foreground));
}

.entry-content blockquote cite::before {
    content: "— ";
}

/* ==========================================================================
   Images
   ========================================================================== */

.entry-content img {
    max-width: 100%;
    height: auto;
    width: auto;
    border-radius: 0.5rem;
    display: block;
}

.entry-content a img,
.entry-content picture img,
.entry-content figure img,
.entry-content .wp-caption img,
.entry-content .gallery img {
    max-width: 100%;
    height: auto;
}

/* WordPress alignment classes */
.entry-content .alignleft {
    float: left;
    margin: 0.5rem 1.5rem 1rem 0;
    max-width: min(100%, 320px);
}

.entry-content .alignright {
    float: right;
    margin: 0.5rem 0 1rem 1.5rem;
    max-width: min(100%, 320px);
}

.entry-content .aligncenter {
    display: block;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

.entry-content .alignnone {
    max-width: 100%;
    margin: 1.5rem 0;
}

/* WordPress figure/caption */
.entry-content figure {
    max-width: 100%;
    margin: 2rem 0;
}

.entry-content .wp-caption {
    width: auto !important;
    max-width: 100% !important;
    margin: 2rem 0;
}

.entry-content figure,
.entry-content .wp-caption,
.entry-content .gallery,
.entry-content .gallery-item,
.entry-content .gallery-icon,
.entry-content .gallery-icon a {
    box-sizing: border-box;
}

.entry-content .gallery,
.entry-content .gallery-item,
.entry-content .gallery-icon,
.entry-content .gallery-icon a {
    min-width: 0;
    max-width: 100%;
}

.entry-content figcaption,
.entry-content .wp-caption-text {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    text-align: center;
    color: hsl(var(--muted-foreground));
    font-style: italic;
}

/* Clear floats */
.entry-content::after {
    content: "";
    display: table;
    clear: both;
}

/* ==========================================================================
   Horizontal Rule
   ========================================================================== */

.entry-content hr {
    margin: 2.5rem 0;
    border: 0;
    border-top: 1px solid hsl(var(--border));
}

/* ==========================================================================
   Code & Pre
   ========================================================================== */

.entry-content code {
    font-family: "Courier New", Courier, monospace;
    font-size: 0.875em;
    padding: 0.2em 0.4em;
    background-color: hsl(var(--muted));
    border-radius: 0.25rem;
    color: hsl(var(--foreground));
}

.entry-content pre {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background-color: hsl(var(--muted));
    border-radius: 0.5rem;
    overflow-x: auto;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.875rem;
    line-height: 1.7;
}

.entry-content pre code {
    padding: 0;
    background-color: transparent;
    font-size: inherit;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.entry-content table {
    width: 100%;
    margin: 2rem 0;
    border-collapse: collapse;
    font-size: 0.875rem;
    overflow: hidden;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.entry-content thead {
    background-color: hsl(var(--muted));
}

.entry-content th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: hsl(var(--foreground));
    border-bottom: 2px solid hsl(var(--border));
}

.entry-content td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid hsl(var(--border));
}

.entry-content tbody tr:last-child td {
    border-bottom: none;
}

.entry-content tbody tr:hover {
    background-color: hsl(var(--muted) / 0.3);
}

/* Responsive tables */
@media (max-width: 768px) {
    .entry-content .alignleft,
    .entry-content .alignright,
    .entry-content .aligncenter,
    .entry-content .alignnone,
    .entry-content .wp-caption,
    .entry-content figure {
        float: none;
        display: block;
        width: 100% !important;
        max-width: 100%;
        margin-right: 0;
        margin-left: 0;
    }

    .entry-content table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* ==========================================================================
   Embeds & iframes
   ========================================================================== */

.entry-content iframe,
.entry-content embed,
.entry-content object,
.entry-content video {
    max-width: 100%;
    margin: 2rem 0;
    border-radius: 0.5rem;
}

/* Responsive video wrapper (16:9) */
.entry-content .video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    margin: 2rem 0;
    border-radius: 0.5rem;
}

.entry-content .video-wrapper iframe,
.entry-content .video-wrapper embed,
.entry-content .video-wrapper object,
.entry-content .video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
}

/* WordPress embed blocks */
.entry-content .wp-block-embed {
    margin: 2rem 0;
}

.entry-content .wp-block-embed__wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
}

.entry-content .wp-block-embed__wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ==========================================================================
   WordPress Gallery
   ========================================================================== */

.entry-content .gallery {
    margin: 2rem 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    max-width: 100%;
}

.entry-content .gallery-item {
    position: relative;
}

.entry-content .gallery-icon {
    overflow: hidden;
}

.entry-content .gallery-icon a {
    display: block;
}

.entry-content .gallery-icon img {
    width: 100%;
    height: auto;
    border-radius: 0.375rem;
    transition: transform 0.3s ease;
}

.entry-content .gallery-icon a:hover img {
    transform: scale(1.05);
}

.entry-content .gallery-caption {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    text-align: center;
    color: hsl(var(--muted-foreground));
}

@media (max-width: 768px) {
    .entry-content .gallery {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.entry-content .text-center {
    text-align: center;
}

.entry-content .text-left {
    text-align: left;
}

.entry-content .text-right {
    text-align: right;
}

/* Print styles */
@media print {
    .entry-content {
        font-size: 12pt;
    }
    
    .entry-content a {
        text-decoration: underline;
        color: #000;
    }
    
    .entry-content a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.875em;
    }
}
