/* ========================================================================== */
/* RESPONSIVE DESIGN, FULLWIDTH LAYOUT & MOBILE-FIRST SPECIFICATIONS         */
/* ========================================================================== */

/* Root Font Scaling & Fluid Units */
:root {
    --klb-font-scale: 1;
}

html {
    font-size: calc(16px * var(--klb-font-scale, 1));
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    background-color: #F8F6F0;
    color: #1E293B;
    transition: background-color 0.25s ease, color 0.25s ease;
    overflow-x: hidden;
    width: 100%;
    min-height: 100dvh;
    padding-bottom: 5rem; /* Room for mobile bottom bar */
}

@media (min-width: 1024px) {
    body {
        padding-bottom: 2rem;
    }
}

html.dark body {
    background-color: #181C24;
    color: #F1F5F9;
}

/* Fluid Fullwidth Container System */
.layout-fullwidth {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: clamp(0.75rem, 3vw, 3rem) !important;
    padding-right: clamp(0.75rem, 3vw, 3rem) !important;
}

.layout-standard {
    width: 100% !important;
    max-width: 1440px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: clamp(0.75rem, 2vw, 1.5rem) !important;
    padding-right: clamp(0.75rem, 2vw, 1.5rem) !important;
}

/* Fluid Responsive Typography */
.text-fluid-title {
    font-size: clamp(1.25rem, 2.5vw, 2rem);
    line-height: 1.2;
}

.text-fluid-lemma {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    line-height: 1.15;
}

.text-fluid-body {
    font-size: clamp(0.875rem, 1vw + 0.5rem, 1rem);
    line-height: 1.5;
}

/* Fluid Embedded Video Container (16:9 Aspect Ratio) */
.fluid-video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    border-radius: 0.75rem;
    background-color: #000000;
}

.fluid-video-container iframe,
.fluid-video-container video {
    position: absolute;
    top: 0;
    left: 0;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: none;
}

/* Safe Word Breaking */
.word-break-anywhere {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 3D Flashcard Flip Animation */
.perspective-1000 {
    perspective: 1000px;
}
.transform-style-3d {
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
}
.backface-hidden {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.rotate-y-180 {
    transform: rotateY(180deg);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.04);
}
::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.35);
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.65);
}

/* Performance: Content visibility for super-smooth mobile scrolling */
.entry-card-rendered {
    content-visibility: auto;
    contain-intrinsic-size: 1px 360px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Mobile Safe Areas (iPhone Notches & Home Bar) */
.pb-safe {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}
.pt-safe {
    padding-top: max(0.5rem, env(safe-area-inset-top));
}

/* Touch targets on mobile / touchscreens */
@media (hover: none) and (pointer: coarse) {
    button, a, select, input, .tab-btn {
        min-height: 42px;
        touch-action: manipulation;
    }
    .hover-label {
        max-width: none !important;
        opacity: 1 !important;
        margin-left: 0.35rem !important;
        display: inline !important;
    }
}

/* Desktop Hover expand */
@media (hover: hover) and (pointer: fine) {
    .compact-hover-btn .hover-label {
        max-width: 0;
        opacity: 0;
        overflow: hidden;
        white-space: nowrap;
        display: inline-block;
        vertical-align: middle;
        transition: max-width 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, margin 0.25s ease;
        margin-left: 0;
    }
    .compact-hover-btn:hover .hover-label,
    .compact-hover-btn:focus-visible .hover-label {
        max-width: 280px;
        opacity: 1;
        margin-left: 0.45rem;
    }
}

/* Card Layout View Modes */
#dictionary-cards-container.view-detail {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#dictionary-cards-container.view-compact {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#dictionary-cards-container.view-grid2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 900px) {
    #dictionary-cards-container.view-grid2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Pulsing Auto-Fill Glow Animation */
@keyframes autoFillGlow {
    0%, 100% { box-shadow: 0 0 0 rgba(79, 70, 229, 0); }
    50% { box-shadow: 0 0 15px rgba(79, 70, 229, 0.5); }
}
.autofill-active {
    animation: autoFillGlow 1.2s ease-in-out infinite;
}

/* 2-Column Book Print Format for PDF Export */
@media print {
    body {
        background: #FFFFFF !important;
        color: #000000 !important;
        font-size: 10pt;
        padding-bottom: 0 !important;
    }
    .no-print {
        display: none !important;
    }
    #print-book-container {
        display: block !important;
        column-count: 2;
        column-gap: 24px;
        column-rule: 1px solid #cbd5e1;
    }
    .entry-card-print {
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 14px;
        border-bottom: 1px dotted #94a3b8;
        padding-bottom: 8px;
    }
}
