/* =============================================================
   helloAnime — mobile.css
   Mobile-specific overrides (loaded on all screens, targets ≤767px)
   ============================================================= */

@media (max-width: 767px) {

    /* --- Layout --------- */
    :root {
        --sidebar-width: 280px;
    }

    body {
        padding-left: 0;
    }

    /* FOOTER */
    .site-footer {
        margin-left: 0;
    }

    /* Sidebar becomes a left-edge drawer on mobile */
    .site-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        z-index: 300;
        width: var(--sidebar-width);
    }

    .site-sidebar.drawer-open {
        transform: translateX(0);
        box-shadow: 4px 0 40px rgba(0, 0, 0, 0.5);
    }

    /* Show close button inside sidebar on mobile */
    .sidebar-close-btn {
        display: flex;
    }

    .site-main {
        margin-left: 0;
        padding-top: 56px;    /* topbar */
        padding-bottom: 64px; /* bottom tab bar */
    }

    /* --- Topbar --------- */
    .mobile-topbar {
        display: flex;
    }

    /* --- Bottom Tab Bar --------------------------------------------------- */
    .mobile-bottom-nav {
        display: flex;
    }

    /* --- Player --------- */
    .player-section {
        position: static;
    }

    .player-container {
        max-height: none;
    }

    .server-switcher {
        padding: 6px 12px;
        gap: 6px;
    }

    .server-tab {
        padding: 4px 10px;
        font-size: 0.78rem;
    }

    .ep-nav-controls {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }

    .episode-info-bar {
        padding: 10px 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    /* Comment */

    .ep-comments-wrap {
        padding: 0 3px 2px !important;
    }

    .ha-comments{
        padding: 5px 10px !important;
    }

    /* --- Section ---------------------------------------------------------- */
    .section-title {
        font-size: 0.85rem;
    }

    /* --- Anime Grid ------------------------------------------------------- */
    .anime-grid {
        gap: 8px;
        padding: 0 6px 10px;
    }

    /* Card link wrapper — makes card clickable on mobile */
    .anime-card-link {
        display: block;
        text-decoration: none;
        color: inherit;
        height: 100%;
    }

    /* Show overlay and buttons on mobile (no hover required) */
    .anime-card-link .card-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(10,10,15,0.95) 0%, rgba(10,10,15,0.6) 50%, transparent 100%);
    }

    .anime-card-link .overlay-actions {
        display: flex !important;
    }

    .anime-card-info {
        padding: 8px 10px;
    }

    .anime-card-title {
        font-size: 0.8rem;
        -webkit-line-clamp: 2;
        line-height: 1.3;
        word-break: break-word;
    }

    .card-meta {
        font-size: 0.7rem;
    }

    /* --- Hero Banner ------------------------------------------------------ */
    .hero-banner {
        min-height: 260px;
    }

    .hero-content {
        flex-direction: column;
        gap: 12px;
        padding: 0 16px 24px;
        margin-top: 1rem;
    }

    .hero-poster {
        width: 90px;
        height: 130px;
        border-radius: 8px;
        flex-shrink: 0;
    }

    .hero-info {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .hero-title {
        font-size: 1.25rem;
    }

    .hero-synopsis {
        display: none;
    }

    .hero-ctas {
        gap: 8px;
    }

    .hero-ctas .btn {
        padding: 8px 16px;
        font-size: 0.82rem;
    }

    .hero-arrows {
        top: 90%;
    }

    .hero-dots {
        bottom: 20px;
    }

    /* --- Scroll Row ------------------------------------------------------- */
    .scroll-row {
        padding-bottom: 8px;
        gap: 10px;
        padding-left: 6px;
        padding-right: 6px;
    }

    .scroll-row .anime-card {
        width: 170px;
        min-width: 170px;
        flex: 0 0 170px;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .scroll-row .card-poster {
        flex-shrink: 0;
    }

    .scroll-row .card-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        padding: 8px 10px;
        min-height: 70px;
    }

    .scroll-row .card-title {
        white-space: nowrap;
        font-size: 0.78rem;
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 4px;
        flex-shrink: 0;
    }

    .scroll-row .card-meta {
        font-size: 0.68rem;
        margin-top: auto;
    }

    /* --- Single Anime ----------------------------------------------------- */
    .anime-detail-layout {
        grid-template-columns: 1fr;
        row-gap: 12px;
    }

    .anime-next-ep-countdown-wrap {
        margin-top: 0 !important;
    }

    .anime-poster-widget-area {
        margin-top: 0 !important;
    }

    .anime-detail-poster {
        width: 140px;
        align-self: center;
        margin: 0 auto;
    }

    .anime-detail-container {
        margin-top: -12px;
        padding: 10px 12px 22px;
        border-radius: 16px 16px 0 0;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.22);
    }

    .anime-detail-title {
        font-size: 1.35rem;
    }

    .episodes-section {
        padding: 0 16px 24px;
    }

    .episodes-grid {
        grid-template-columns: 1fr;
    }

    .ep-filter-tab {
        padding: 5px 10px;
        font-size: 0.78rem;
    }

    .ep-search {
        width: 140px;
        font-size: 0.82rem;
    }

    /* --- Browse / Filters ------------------------------------------------- */
    .browse-layout {
        grid-template-columns: 1fr;
    }

    .filters-sidebar {
        position: fixed;
        left: 0;
        right: 0;
        top: 60px; /* below topbar */
        max-height: calc(100vh - 60px);
        overflow-y: auto;
        background: var(--bg-surface);
        border-top: 1px solid var(--border);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 180;
        padding: 16px;
    }

    form#browse-filter-form {
        margin-bottom: 3rem;
    }

    .filters-sidebar.open {
        transform: translateY(0);
    }

    /* --- Schedule --------------------------------------------------------- */
    .schedule-day {
        padding: 0 16px 20px;
    }

    .day-label {
        padding: 20px 16px 12px;
        font-size: 1rem;
    }

    /* --- Blog post cards -------------------------------------------------- */
    .posts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* --- Single post ------------------------------------------------------ */
    .single-post-hero {
        height: 200px;
    }

    .single-post-layout {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .single-post-sidebar {
        position: static;
    }

    .post-nav {
        grid-template-columns: 1fr;
    }

    .post-nav-next {
        grid-column: 1;
        text-align: left;
        justify-content: flex-start;
    }

    .post-author-box {
        flex-direction: column;
    }

    /* --- Section Spacing -------------------------------------------------- */
    .section-header {
        padding: 20px 16px 14px;
    }

    /* --- Pagination ------------------------------------------------------- */
    .pagination-wrap {
        padding: 20px 16px;
    }

    .page-numbers {
        padding: 7px 11px;
        font-size: 0.82rem;
    }

    /* --- Toast ------------------------------------------------------------ */
    #toast-container {
        right: 12px;
        bottom: 72px;
    }

    /* --- Search Overlay --------------------------------------------------- */
    .search-overlay {
        padding: 56px 14px 20px;
    }

    .search-overlay-bar input {
        font-size: 1rem;
    }

    /* --- Watchlist -------------------------------------------------------- */
    .watchlist-header {
        padding: 20px 16px 12px;
    }

    /* --- Misc ------------------------------------------------------------- */
    .download-section {
        margin: 0;
    }

    .download-body {
        padding: 4px 16px 12px;
    }

    .archive-header {
        padding: 24px 16px 16px;
    }

    .archive-title {
        font-size: 1.5rem;
    }

    .browse-sort-bar {
        padding: 10px 16px;
    }

    .badge {
        padding: 2px 3px;
        font-size: 0.6rem;
    }

    /* --- Comments --------------------------------------------------------- */
    .ha-comments {
        margin-top: 32px;
        padding-top: 28px;
    }

    .ha-comment-inner {
        position: relative; /* positioning context for abs avatar */
        gap: 0;
        flex-direction: column;
    }

    .ha-comment-body {
        width: 100% !important;
        padding-left: 38px; /* 28px avatar + 10px gap */
    }

    .ha-comment-avatar-wrap {
        position: absolute;
        top: 10px; /* aligns avatar with author name row */
        left: 3px;
        z-index: 1;
    }

    .ha-comment-avatar {
        width: 28px;
        height: 28px;
    }

    /* Reduce depth indentation on small screens */
    .ha-comment-list .children {
        padding-left: 10px;
        margin-left: 18px;
    }

    /* Reply collapse */
    .ha-comment-list .children.is-collapsed {
        display: none;
    }

    .ha-replies-toggle {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        margin: 4px 0 6px 38px; /* indent to match body left edge */
        padding: 4px 10px 4px 8px;
        font-size: 0.72rem;
        font-weight: 600;
        color: rgba(var(--accent-rgb), 0.85);
        background: rgba(var(--accent-rgb), 0.07);
        border: 1px solid rgba(var(--accent-rgb), 0.18);
        border-radius: 999px;
        cursor: pointer;
        transition: background 0.15s, color 0.15s;
        line-height: 1;
    }

    .ha-replies-toggle:hover,
    .ha-replies-toggle[aria-expanded="true"] {
        background: rgba(var(--accent-rgb), 0.14);
        color: var(--accent-primary);
    }

    /* Ensure badge icon doesn't overflow tight layouts */
    .ha-comment-badge-icon {
        width: 17px;
        height: 17px;
    }

    /* Flip tooltip rightward — badge sits near left edge on mobile,
       so the centered-above default gets clipped off screen */
    .ha-comment-badge-icon::after {
        bottom: auto;
        top: 50%;
        left: calc(100% + 8px);
        right: auto;
        transform: translateY(-50%);
    }

    .ha-comment-meta {
        gap: 5px;
    }

    /* Timestamp pushes to next line on very narrow screens */
    .ha-comment-time {
        margin-left: 0;
        width: 100%;
        order: 10;
    }

    /* Reaction trigger — keep compact on small screens */
    .ha-reaction-trigger {
        padding: 3px 8px;
        font-size: 0.73rem;
    }

    /* Open dropdown downward on mobile so it never clips the viewport edge.
       The upward default works on desktop, but on narrow screens the pill
       (≈260px wide) would overflow whichever side the trigger is near. */
    .ha-reaction-dropdown {
        bottom: auto;
        top: calc(100% + 8px);
        left: 0;
        right: auto;
        transform-origin: top left;
        transform: translateY(-8px) scale(0.86);
    }

    .ha-comment-reactions.is-open .ha-reaction-dropdown {
        transform: translateY(0) scale(1);
    }

    /* Caret points upward */
    .ha-reaction-dropdown::after {
        bottom: auto;
        top: -6px;
        left: 20px;
        right: auto;
        transform: rotate(-135deg);
    }

    button.ha-comment-share span {
        display: none;
    }

    .ha-comment-actions {
        gap: 4px;
        flex-wrap: wrap;
    }

    .ha-comment-actions .comment-reply-link,
    .ha-comment-edit,
    .ha-comment-share {
        padding: 6px 10px;
        min-height: 36px;
        font-size: 0.78rem;
    }

    /* Form */
    #respond {
        padding: 20px 16px;
        border-radius: 12px;
    }

    .ha-form-user-info {
        padding: 10px 14px;
        gap: 10px;
    }

    .ha-form-user-avatar {
        width: 34px;
        height: 34px;
    }

    .ha-comment-textarea {
        min-height: 100px;
        font-size: 0.875rem;
    }

    .ha-comment-submit-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ha-comment-submit-btn {
        justify-content: center;
    }

}


/* --- Small phones (≤ 480px) -------------------------------------------- */
@media (max-width: 480px) {
    .logo-text {font-size: 1.5rem !important;}
    .anime-grid {
        gap: 5px;
        padding: 0 10px 16px;
    }

    .anime-grid-lg {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 8px;
        padding: 0 10px 16px;
    }

    .anime-grid-related {
        gap: 6px;
    }

    .scroll-row .anime-card {
        width: 190px;
        min-width: 190px;
        flex: 0 0 190px;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .scroll-row .card-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        padding: 8px 10px;
        min-height: 70px;
    }

    .scroll-row .card-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0.78rem;
        margin-bottom: 4px;
        flex-shrink: 0;
    }

    .scroll-row .card-meta {
        font-size: 0.68rem;
        margin-top: auto;
    }
}


/* --- Tablet (768–1023px): compact sidebar ------------------------------ */
@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --sidebar-width: 220px;
    }

    .site-sidebar {
        width: var(--sidebar-width);
    }

    .site-sidebar .sidebar-trending {
        display: none;
    }

    .site-footer {
        margin-left: var(--sidebar-width);
    }

    /* Wide layout has no persistent sidebar — footer spans full width */
    body.ha-layout-wide .site-footer {
        margin-left: 0;
    }

    .anime-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .anime-grid-lg {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 10px;
    }

    .anime-grid-related {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .anime-detail-layout {
        grid-template-columns: 200px 1fr;
    }
}


/* --- Desktop (≥ 768px): hide mobile-only elements ---------------------- */
@media (min-width: 768px) {
    .mobile-bottom-nav,
    .drawer-overlay,
    .sidebar-close-btn {
        display: none !important;
    }

    /* Restore hover behavior on desktop */
    .anime-card-link .card-overlay {
        opacity: 0;
    }

    .anime-card-link:hover .card-overlay {
        opacity: 1;
    }
}