/* =============================================
   HISTORIC PORTAL - Mobile Optimization Layer
   Loaded last → overrides desktop styles where needed
   ============================================= */

/* ============= UNIVERSAL MOBILE FIXES ============= */
* {
    -webkit-tap-highlight-color: rgba(200, 160, 80, 0.2);
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Better touch scrolling on iOS */
body {
    -webkit-overflow-scrolling: touch;
}

/* Prevent horizontal scroll caused by any element */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Lock body scroll when mobile menu open */
body.hp-menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ============= TABLET BREAKPOINT (≤ 968px) ============= */
@media (max-width: 968px) {

    /* Container padding */
    .hp-container {
        padding: 0 20px;
    }

    /* Top bar - hide date on tablet, keep socials */
    .hp-topbar {
        font-size: 11px;
        padding: 6px 0;
    }

    .hp-topbar-inner {
        justify-content: center;
        text-align: center;
    }

    .hp-topbar-date {
        font-size: 12px;
    }

    /* Header */
    .hp-header-inner {
        padding: 16px 20px;
        gap: 12px;
    }

    .hp-site-title {
        font-size: 1.5rem;
    }

    .hp-site-description {
        font-size: 11px;
    }

    /* Hide search toggle on tablet to save space */
    .hp-search-toggle {
        width: 40px;
        height: 40px;
    }

    /* Hero */
    .hp-hero {
        padding: 80px 0 80px;
        min-height: auto;
    }

    .hp-hero-title {
        font-size: clamp(2.4rem, 9vw, 4.5rem);
        line-height: 1;
    }

    .hp-hero-desc {
        font-size: 1.05rem;
        padding: 0 8px;
    }

    .hp-hero-label {
        font-size: 11px;
        margin-bottom: 24px;
    }

    .hp-hero-actions {
        flex-direction: column;
        align-items: stretch;
        max-width: 320px;
        margin-left: auto;
        margin-right: auto;
    }

    .hp-hero-actions .hp-btn {
        width: 100%;
    }

    .hp-hero-scroll {
        display: none;
    }

    /* Section spacing on tablet */
    .hp-categories,
    .hp-latest,
    .hp-newsletter-section {
        padding: 60px 0;
    }

    .hp-section-head {
        margin-bottom: 40px;
    }

    /* Categories: 2 columns on tablet */
    .hp-categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hp-category-card {
        padding: 32px 24px;
    }

    /* Featured post - stack on tablet */
    .hp-post-card-featured .hp-post-card-link {
        grid-template-columns: 1fr;
    }

    .hp-post-card-featured .hp-post-card-body {
        padding: 32px 24px;
    }

    /* Posts grid - 2 cols */
    .hp-posts-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 32px;
    }

    /* Newsletter */
    .hp-newsletter-box {
        grid-template-columns: 1fr;
        gap: 32px;
        text-align: center;
    }

    .hp-newsletter-form button {
        align-self: center;
    }

    /* Footer */
    .hp-footer {
        padding: 60px 0 0;
    }

    .hp-footer-top {
        grid-template-columns: 1fr;
        gap: 40px;
        padding-bottom: 40px;
    }

    .hp-footer-brand {
        text-align: center;
    }

    .hp-footer-logo {
        font-size: 28px;
    }

    .hp-footer-socials {
        justify-content: center;
    }

    .hp-footer-columns {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
    }

    .hp-footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 16px;
        padding: 24px 0;
    }

    .hp-legal-menu {
        justify-content: center;
        flex-wrap: wrap;
        gap: 16px;
    }

    /* Single post */
    .hp-single-hero {
        min-height: auto;
        padding: 60px 0 40px;
    }

    .hp-single-title {
        font-size: clamp(1.8rem, 6vw, 2.8rem);
    }

    .hp-single-wrapper {
        grid-template-columns: 1fr;
        gap: 40px;
        padding: 40px 20px;
    }

    .hp-single-content {
        font-size: 18px;
    }

    .hp-single-sidebar {
        position: static;
    }

    /* Legal pages - stack TOC on top */
    .hp-legal-wrapper {
        grid-template-columns: 1fr;
        gap: 32px;
        padding: 40px 20px;
    }

    .hp-legal-toc {
        position: static;
        order: 0;
    }

    /* About page */
    .hp-about-intro-grid,
    .hp-contact-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .hp-about-quote {
        padding: 40px 28px;
    }

    /* Post nav stack */
    .hp-post-nav {
        grid-template-columns: 1fr;
    }

    /* Author box */
    .hp-author-box {
        flex-direction: column;
        text-align: center;
        padding: 32px 24px;
    }
}

/* ============= MOBILE BREAKPOINT (≤ 600px) ============= */
@media (max-width: 600px) {

    body {
        font-size: 16px;
    }

    .hp-container {
        padding: 0 16px;
    }

    /* Top bar - vertical on mobile */
    .hp-topbar-inner {
        flex-direction: column;
        gap: 4px;
    }

    .hp-topbar-date {
        font-size: 11px;
    }

    .hp-topbar-socials {
        gap: 12px;
    }

    .hp-social-link {
        font-size: 10px;
    }

    /* Header more compact */
    .hp-header {
        position: sticky;
        top: 0;
    }

    .hp-header-inner {
        padding: 12px 16px;
        gap: 8px;
    }

    .hp-site-title {
        font-size: 1.25rem;
    }

    .hp-site-description {
        display: none; /* Save space on small screens */
    }

    /* Menu toggle: bigger touch target */
    .hp-menu-toggle {
        width: 44px;
        height: 44px;
        padding: 10px;
    }

    .hp-search-toggle {
        width: 40px;
        height: 40px;
    }

    /* Hero - reduce padding */
    .hp-hero {
        padding: 60px 0 60px;
    }

    .hp-hero-title {
        font-size: clamp(2rem, 11vw, 3.2rem);
        margin-bottom: 24px;
    }

    .hp-hero-desc {
        font-size: 1rem;
        margin-bottom: 32px;
    }

    .hp-hero-label {
        padding: 5px 16px;
        font-size: 10px;
        letter-spacing: 0.25em;
    }

    .hp-btn {
        padding: 13px 24px;
        font-size: 12px;
        min-height: 46px; /* Touch target */
    }

    /* Categories - 1 col */
    .hp-categories,
    .hp-latest,
    .hp-newsletter-section,
    .hp-about-intro,
    .hp-about-values,
    .hp-about-stats,
    .hp-about-cta,
    .hp-contact-content,
    .hp-archive {
        padding: 50px 0;
    }

    .hp-categories-grid {
        grid-template-columns: 1fr;
    }

    .hp-category-card {
        padding: 28px 20px;
    }

    .hp-category-num {
        font-size: 48px;
        margin-bottom: 20px;
    }

    .hp-category-name {
        font-size: 22px;
    }

    .hp-category-desc {
        font-size: 15px;
    }

    .hp-section-head {
        margin-bottom: 32px;
    }

    .hp-section-title {
        font-size: clamp(1.7rem, 6vw, 2.2rem);
    }

    .hp-section-label {
        font-size: 10px;
        padding: 0 24px;
    }

    /* Posts grid - 1 col on mobile */
    .hp-posts-grid {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .hp-post-card-featured {
        grid-column: 1;
    }

    .hp-post-card-featured .hp-post-card-title {
        font-size: 1.5rem;
    }

    .hp-post-card-featured .hp-post-card-body {
        padding: 24px 20px;
    }

    .hp-post-card-body {
        padding: 20px 0 0;
    }

    .hp-post-card-title {
        font-size: 20px;
    }

    .hp-post-card-excerpt {
        font-size: 16px;
    }

    .hp-post-card-meta {
        font-size: 10px;
        gap: 12px;
    }

    /* Newsletter - mobile friendly */
    .hp-newsletter-box {
        padding: 0 8px;
    }

    .hp-newsletter-form {
        max-width: 100%;
    }

    .hp-newsletter-form input {
        padding: 14px 16px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    /* Footer - 1 col */
    .hp-footer-columns {
        grid-template-columns: 1fr;
        gap: 28px;
        text-align: center;
    }

    .hp-footer-col {
        padding-bottom: 24px;
        border-bottom: 1px solid rgba(200, 160, 80, 0.1);
    }

    .hp-footer-col:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .hp-footer-links a {
        font-size: 16px;
        padding: 6px 0;
        display: inline-block;
    }

    .hp-footer-links a:hover {
        padding-left: 0;
    }

    .hp-newsletter input {
        font-size: 16px; /* Prevents iOS zoom */
    }

    /* Cookie banner - full width on mobile */
    .hp-cookie-banner {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        max-width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3) !important;
    }

    .hp-cookie-content {
        padding: 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .hp-cookie-icon {
        width: 40px;
        height: 40px;
    }

    .hp-cookie-text strong {
        font-size: 16px;
    }

    .hp-cookie-text p {
        font-size: 13px;
    }

    .hp-cookie-actions {
        margin-left: 0;
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }

    .hp-cookie-actions .hp-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
        min-height: 44px;
    }

    .hp-cookie-customize-panel {
        padding: 20px;
    }

    .hp-cookie-option {
        padding: 14px 0;
    }

    /* Single post hero - smaller on mobile */
    .hp-single-hero {
        min-height: 50vh;
        padding: 40px 0 32px;
    }

    .hp-single-title {
        font-size: clamp(1.6rem, 7vw, 2.3rem);
        margin-bottom: 24px;
    }

    .hp-single-meta {
        gap: 16px;
        font-size: 12px;
    }

    .hp-single-meta-divider {
        display: none;
    }

    .hp-single-author img {
        width: 40px;
        height: 40px;
    }

    .hp-single-wrapper {
        padding: 32px 16px;
        gap: 32px;
    }

    .hp-single-content {
        font-size: 17px;
        line-height: 1.7;
    }

    .hp-single-content h2 {
        font-size: 1.65rem;
        margin-top: 1.5em;
    }

    .hp-single-content h3 {
        font-size: 1.3rem;
    }

    .hp-single-content blockquote {
        padding: 12px 0 12px 20px;
        font-size: 1.15em;
    }

    /* Share buttons - wrap better */
    .hp-share-buttons {
        gap: 6px;
    }

    .hp-share-btn {
        padding: 10px 14px;
        font-size: 11px;
        flex: 1 1 calc(50% - 6px);
        text-align: center;
        min-width: 0;
    }

    /* Author box mobile */
    .hp-author-box img {
        width: 80px;
        height: 80px;
        margin: 0 auto;
    }

    .hp-author-box-name {
        font-size: 20px;
    }

    .hp-author-box-bio {
        font-size: 16px;
    }

    /* Post navigation */
    .hp-post-nav-prev,
    .hp-post-nav-next {
        padding: 18px;
    }

    .hp-post-nav-title {
        font-size: 16px;
    }

    /* Sidebar widgets */
    .widget {
        padding: 20px;
        margin-bottom: 24px;
    }

    .hp-related-list a {
        grid-template-columns: 70px 1fr;
        gap: 10px;
    }

    .hp-related-list img {
        width: 70px;
        height: 50px;
    }

    /* Page hero */
    .hp-page-hero,
    .hp-archive-hero {
        padding: 60px 0 50px;
    }

    .hp-page-hero-title,
    .hp-archive-title {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .hp-page-wrapper {
        padding: 40px 16px;
    }

    .hp-page-content {
        font-size: 17px;
    }

    /* Legal pages */
    .hp-legal-wrapper {
        padding: 32px 16px;
    }

    .hp-legal-toc {
        padding: 20px;
    }

    .hp-legal-toc a {
        padding: 8px 0 8px 28px;
        font-size: 15px;
    }

    .hp-legal-content {
        font-size: 17px;
    }

    .hp-legal-content h2 {
        font-size: 1.5rem;
        margin-top: 2em;
    }

    .hp-legal-content h3 {
        font-size: 1.2rem;
    }

    .hp-legal-contact-box,
    .hp-cookie-reopen-box {
        padding: 20px;
    }

    /* About page - mobile */
    .hp-about-intro-grid {
        gap: 32px;
    }

    .hp-about-quote {
        padding: 32px 24px;
    }

    .hp-about-quote-mark {
        font-size: 80px;
        top: -10px;
        left: 20px;
    }

    .hp-about-quote p {
        font-size: 18px;
    }

    .hp-values-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .hp-value-card {
        padding: 28px 24px;
    }

    .hp-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }

    .hp-stat-num {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .hp-cta-box {
        padding: 48px 24px;
    }

    .hp-cta-box h2 {
        font-size: clamp(1.6rem, 6vw, 2.2rem);
    }

    /* Contact page */
    .hp-contact-grid {
        gap: 40px;
    }

    .hp-contact-method {
        gap: 14px;
        padding: 16px 0;
    }

    .hp-contact-method-icon {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }

    .hp-contact-form-wrap {
        padding: 32px 20px;
    }

    .hp-contact-form-wrap h3 {
        font-size: 24px;
    }

    .hp-form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .hp-contact-form input,
    .hp-contact-form textarea {
        padding: 14px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    /* Search overlay - mobile */
    .hp-search-overlay .hp-search-input {
        font-size: 24px;
        padding: 12px 0;
    }

    .hp-search-close {
        top: 20px;
        right: 16px;
        width: 44px;
        height: 44px;
    }

    /* 404 */
    .hp-404 {
        padding: 60px 0;
    }

    .hp-404-number {
        font-size: clamp(6rem, 25vw, 10rem);
    }

    .hp-404-title {
        font-size: clamp(1.6rem, 6vw, 2.2rem);
    }

    .hp-404-desc {
        font-size: 17px;
    }

    /* Pagination */
    .hp-pagination .page-numbers {
        min-width: 40px;
        height: 40px;
        padding: 0 12px;
        font-size: 13px;
    }

    /* Back to top */
    .hp-back-to-top {
        bottom: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
    }

    /* Body content alignment on mobile */
    .hp-single-content img {
        margin: 1.5em 0;
        width: 100%;
    }

    /* Loader text smaller on mobile */
    .hp-loader-text {
        font-size: clamp(2rem, 11vw, 3rem) !important;
        letter-spacing: 0.04em !important;
    }

    .hp-loader-tagline {
        font-size: 0.85rem !important;
        letter-spacing: 0.2em !important;
        margin-bottom: 32px !important;
    }

    .hp-loader-bar {
        width: 180px !important;
    }

    .hp-transition-text {
        font-size: clamp(1.6rem, 8vw, 2.5rem) !important;
    }
}

/* ============= SMALL MOBILE (≤ 400px) ============= */
@media (max-width: 400px) {

    .hp-container {
        padding: 0 14px;
    }

    .hp-hero-title {
        font-size: clamp(1.8rem, 12vw, 2.6rem);
    }

    .hp-section-title {
        font-size: clamp(1.5rem, 7vw, 2rem);
    }

    .hp-post-card-featured .hp-post-card-title {
        font-size: 1.35rem;
    }

    /* Share buttons in single column on tiny screens */
    .hp-share-btn {
        flex: 1 1 100%;
    }

    .hp-single-title {
        font-size: clamp(1.5rem, 8vw, 2rem);
    }

    .hp-single-content {
        font-size: 16px;
    }

    .hp-legal-content {
        font-size: 16px;
    }

    .hp-cookie-text strong {
        font-size: 15px;
    }

    .hp-cookie-text p {
        font-size: 12.5px;
    }

    /* Stats: 1 col on tiny */
    .hp-stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============= LANDSCAPE PHONE FIXES ============= */
@media (max-width: 900px) and (orientation: landscape) {
    .hp-hero {
        padding: 50px 0 50px;
        min-height: auto;
    }

    .hp-hero-title {
        font-size: clamp(1.8rem, 5vw, 3rem);
        margin-bottom: 16px;
    }

    .hp-hero-desc {
        font-size: 0.95rem;
        margin-bottom: 24px;
    }

    .hp-loader-text {
        font-size: clamp(1.8rem, 6vw, 3rem) !important;
    }

    .hp-single-hero {
        min-height: auto;
        padding: 32px 0;
    }
}

/* ============= TOUCH-FRIENDLY OVERRIDES ============= */
@media (hover: none) and (pointer: coarse) {
    /* Touch device: bigger targets, no hover-only states */

    a, button {
        min-height: 44px;
    }

    .hp-main-nav a {
        padding: 14px 0;
    }

    .hp-post-card:active .hp-post-card-image img {
        transform: scale(1.04);
    }

    .hp-btn:active {
        transform: scale(0.97);
    }

    .hp-footer-links a {
        padding: 10px 0;
    }

    /* Disable expensive hover transforms */
    .hp-category-card:hover {
        transform: none;
    }

    .hp-value-card:hover {
        transform: none;
    }

    .hp-post-nav-prev:hover,
    .hp-post-nav-next:hover {
        transform: none;
    }
}

/* ============= DARK MODE READY (future) ============= */
@media (prefers-color-scheme: dark) {
    /* Reserved — currently theme is always light */
}

/* ============= REDUCED MOTION ============= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .hp-loader,
    .hp-transition {
        display: none !important;
    }
}

/* ============= PRINT STYLES ============= */
@media print {
    .hp-loader,
    .hp-transition,
    .hp-topbar,
    .hp-header,
    .hp-footer,
    .hp-cookie-banner,
    .hp-back-to-top,
    .hp-reading-progress,
    .hp-single-share,
    .hp-post-nav,
    .hp-single-sidebar,
    .hp-comments {
        display: none !important;
    }

    body {
        font-size: 12pt;
        color: #000;
        background: #fff;
    }

    .hp-single-content {
        font-size: 12pt;
        color: #000;
    }

    a {
        color: #000;
        text-decoration: underline;
    }
}
