/**
 * Pageify — Main Styles
 * Base elements, reset, typography.
 * Requires: variables.css loaded first.
 */

/* ── Reset ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: var(--pgf-font-size);
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--pgf-font);
    font-size: var(--pgf-font-size);
    line-height: var(--pgf-line-height);
    color: var(--pgf-text);
    background: var(--pgf-bg-alt);
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

body * {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
    body, body * {
        transition: none !important;
    }
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--pgf-text);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }
h5 { font-size: 0.875rem; }

p {
    margin-bottom: var(--pgf-space-md);
    color: var(--pgf-text-secondary);
}

a {
    color: var(--pgf-primary);
    text-decoration: none;
    transition: color var(--pgf-transition);
}

a:hover {
    color: var(--pgf-primary-hover);
    text-decoration: underline;
}

strong { font-weight: 600; }

small {
    font-size: 0.8125rem;
    color: var(--pgf-text-muted);
}

code {
    font-family: var(--pgf-font-mono);
    font-size: 0.875em;
    background: var(--pgf-bg-alt);
    padding: 2px 6px;
    border-radius: var(--pgf-radius-xs);
}

hr {
    border: none;
    height: 1px;
    background: var(--pgf-border);
    margin: var(--pgf-space-lg) 0;
}

/* ── Images ── */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ── Lists ── */
ul, ol {
    padding-left: var(--pgf-space-lg);
}

li {
    margin-bottom: var(--pgf-space-xs);
}

/* ── Selection ── */
::selection {
    background: var(--pgf-primary-light);
    color: var(--pgf-primary);
}

/* ── Focus visible (A11y) ── */
:focus-visible {
    outline: 2px solid var(--pgf-primary);
    outline-offset: 2px;
}

/* ── Scrollbar (Webkit) ── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--pgf-bg-alt);
}

::-webkit-scrollbar-thumb {
    background: var(--pgf-border);
    border-radius: var(--pgf-radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--pgf-text-muted);
}

/* ── Skip link (A11y) ── */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--pgf-space-md);
    padding: var(--pgf-space-sm) var(--pgf-space-md);
    background: var(--pgf-primary);
    color: var(--pgf-text-inverse);
    border-radius: var(--pgf-radius-sm);
    z-index: var(--pgf-z-toast);
    font-weight: 500;
}

.skip-link:focus {
    top: var(--pgf-space-md);
}

/* ── Utility classes ── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--pgf-text-muted); }
.text-secondary { color: var(--pgf-text-secondary); }
.text-success { color: var(--pgf-success); }
.text-warning { color: var(--pgf-warning); }
.text-danger { color: var(--pgf-danger); }
.text-primary { color: var(--pgf-primary); }
.text-gdpr { color: var(--pgf-gdpr); }

.mt-sm { margin-top: var(--pgf-space-sm); }
.mt-md { margin-top: var(--pgf-space-md); }
.mt-lg { margin-top: var(--pgf-space-lg); }
.mb-sm { margin-bottom: var(--pgf-space-sm); }
.mb-md { margin-bottom: var(--pgf-space-md); }
.mb-lg { margin-bottom: var(--pgf-space-lg); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hidden { display: none !important; }
.visible { display: block !important; }

/* ══════════════════════════════════════════
   RESPONSIVE — Liquid Layout
   ══════════════════════════════════════════ */

/* ── Tablet landscape / small desktop (max 1024px) ── */
@media (max-width: 1024px) {
    .sidebar {
        width: 64px;
        overflow: hidden;
    }
    .sidebar .sidebar-item span,
    .sidebar .sidebar-header .logo-text,
    .sidebar .sidebar-section-title,
    .sidebar .sidebar-footer .user-info,
    .sidebar .sidebar-lang,
    .sidebar .count {
        display: none;
    }
    .sidebar .sidebar-item {
        justify-content: center;
        padding: 10px;
    }
    .sidebar .sidebar-item i {
        margin: 0;
        font-size: 18px;
    }
    .main-content {
        margin-left: 64px;
    }
}

/* ── Tablet portrait (max 768px) ── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 299;
        transition: left 0.3s ease;
        box-shadow: none;
        overflow-y: auto;
    }
    .sidebar.open {
        left: 0;
        box-shadow: 4px 0 20px rgba(0,0,0,0.2);
    }
    .sidebar .sidebar-item span,
    .sidebar .sidebar-header .logo-text,
    .sidebar .sidebar-section-title,
    .sidebar .sidebar-footer .user-info,
    .sidebar .sidebar-lang,
    .sidebar .count {
        display: initial;
    }
    .sidebar .sidebar-item {
        justify-content: flex-start;
        padding: 10px 16px;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 298;
    }
    .sidebar-overlay.active {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .mobile-header {
        display: flex !important;
    }
    .topbar .topbar-left .breadcrumb {
        display: none;
    }
}

/* ── Smartphone (max 640px) ── */
@media (max-width: 640px) {
    body {
        font-size: 14px;
    }
    .topbar {
        padding: 0 12px;
        height: 48px;
    }
    .main-content {
        padding: 12px;
    }
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .content-header h1 {
        font-size: 20px;
    }
    /* Bookmark grid: 1 column on phone */
    .bookmark-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    /* Bookmark list: compact */
    .bookmark-card,
    .bookmark-item {
        padding: 10px 12px;
    }
    .bookmark-thumbnail {
        width: 48px;
        height: 48px;
    }
    /* View toggle: hide labels */
    .view-toggle span {
        display: none;
    }
    /* Modals: full-screen on mobile */
    .modal-content,
    .dialog-content {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    /* Settings page */
    .settings-grid {
        grid-template-columns: 1fr;
    }
    /* Pricing grid */
    .pricing-grid {
        grid-template-columns: 1fr;
        max-width: 400px;
    }
    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    /* Tags: wrap on small screens */
    .tag-list {
        flex-wrap: wrap;
    }
    /* Hide non-essential toolbar buttons */
    .toolbar-secondary {
        display: none;
    }
    /* Touch-friendly: larger tap targets */
    .btn, button {
        min-height: 44px;
        min-width: 44px;
    }
    .sidebar-item {
        min-height: 44px;
    }
    input, select, textarea {
        min-height: 44px;
        font-size: 16px; /* prevents iOS zoom on focus */
    }
}

/* ── Mobile header (hamburger) ── */
.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--pgf-bg);
    border-bottom: 1px solid var(--pgf-border);
    position: sticky;
    top: 0;
    z-index: 200;
}
.mobile-header .hamburger {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--pgf-text);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--pgf-radius-sm);
    cursor: pointer;
}
.mobile-header .hamburger:hover {
    background: var(--pgf-bg-hover);
}
.mobile-header .mobile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}
.mobile-header .mobile-logo img {
    width: 24px;
    height: 24px;
}
.mobile-header .mobile-logo span {
    font-weight: 700;
    font-size: 16px;
    color: var(--pgf-primary);
}
.mobile-header .mobile-actions {
    display: flex;
    gap: 4px;
}

/* ── Fluid grid utilities ── */
.fluid-grid {
    display: grid;
    gap: var(--pgf-space-md);
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ── Fluid typography ── */
h1 { font-size: clamp(1.25rem, 2vw + 0.5rem, 1.75rem); }
h2 { font-size: clamp(1.125rem, 1.5vw + 0.5rem, 1.5rem); }
h3 { font-size: clamp(1rem, 1.25vw + 0.5rem, 1.25rem); }
